フィルターのクリア

Matlab solver for natural log equation

10 ビュー (過去 30 日間)
Shane Palmer
Shane Palmer 2020 年 11 月 20 日
編集済み: Walter Roberson 2020 年 11 月 20 日
Hello,
I thought this was a simple solver equation, I know I am doing something wrong, because the result should be about S=1429.
This is my code:
syms x
eqn = log(0.5) == (-27109/x)-0.95*log(x)+25.18
S = vpasolve(eqn,x)
Matlab gives me a very large S =672919621689.2986708066438355574
What am I doing wrong here?

採用された回答

John D'Errico
John D'Errico 2020 年 11 月 20 日
編集済み: John D'Errico 2020 年 11 月 20 日
Does a solution near(er) to zero exist? PLOT IT!!!!!!
syms x
f = (-27109/x)-0.95*log(x)+25.18 - log(0.5);
fplot(f,[10,1000])
Do you see anything strange? A solution would correspond to a point where that curve crosses the line y == 0. Looking a little further up, we finally see this:
fplot(f,[200,1e4])
yline(0);
So a solution seems to occur near x == 1500.
S = vpasolve(f,x,1500)
S = 
1428.9171626682572235629898202448
However, it you look further out, the curve reaches a peak, and then starts to drop again. It may well cross zero again out there.
fplot(f,[10000,1e6])
yline(0);
Did you tell vpasolve which root it should find? Should it know?
vpasolve is a numerical root finder. It looks for a root, near where you tell it to look. If you don't tell it where, it picks a spot. And sometimes, it may end up converging to a solution you don't like.
  1 件のコメント
Shane Palmer
Shane Palmer 2020 年 11 月 20 日
Thank you very helpful.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 11 月 20 日
編集済み: Walter Roberson 2020 年 11 月 20 日
Q = @sym; %convert to rational
syms x
eqn = log(Q(0.5)) == (-Q(27109)/x)-Q(0.95)*log(x)+Q(25.18)
eqn = 
S = solve(eqn,x)
S = 
vpa(S)
ans = 
You can see from this that there are two solutions. You could use an initial value in vpasolve to get the other one

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by