Cannot solve symbolically returning a numeric approximation

11 views (last 30 days)
Hello, I am trying to solve the function shown in the figure below in terms of (k) but I am getting this warnning, the function is attached as an image. now this is how I solved it.
function [k] = Calculatek()
P`=0.5, P = 10000, k should be 75
P = input('Please Enter value of P : ');
Pd = input('Please Enter value of P''' );
K=sym( 'K') % define symbolic function for equation solver
num= (1-K/P)^(2*(P-K+0.5));
den= (1-2*K/P)^(P-2*K+0.5);
fun=Pd-( 1 - (num/den));
Temp=solve(fun);
k= double(Temp);
now I know for a fact that if P = 100000 and p' = 0.5, k should be 250 and if P = 10000 and p' = 0.5 k should be 75.
I am sure Matlab can solve this but I keep on getting this :
>> Calculatek
Please Enter value of P : 100000
Please Enter value of P'0.5
K =
K
Warning: Cannot solve symbolically.
Returning a numeric approximation instead.
> In solve (line 305)
In Calculatek (line 19)
ans =
-263.6242
which I am sure is not correct
what I am doing wrong? can anyone help.
thanks
  2 Comments
John D'Errico
John D'Errico on 29 Nov 2015
Edited: John D'Errico on 29 Nov 2015
p' is not a valid variable name in MATLAB, so the above code does not run. Regardless, you never actually use the value of p' in that code. Perhaps you intended the first line to be commented out, and you are using Pd as the value of p'.

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 29 Nov 2015
Edited: John D'Errico on 29 Nov 2015
P = 10000
Pd = 0.5;
syms K
num= (1-K/P)^(2*(P-K+0.5));
den= (1-2*K/P)^(P-2*K+0.5);
fun=Pd-( 1 - (num/den));
pretty(fun)
20001
2 K - -----
/ K \ 2 / K \20001 - 2 K 1
| 1 - ---- | | 1 - ----- | - -
\ 5000 / \ 10000 / 2
Problems with big exponents are always dangerous to try to solve. However, IF you give the solver a hint of which solution you are interested in...
vpasolve(fun,100)
ans =
82.911209433548073806263919152479
I don't know how you decided that 75 was the solution. That seems to be a bit off, as is verified by the plot. So I might disagree with your claim of FACT.
ezplot(fun,[50,100])
grid on
  2 Comments
Ayman El Hajjar
Ayman El Hajjar on 29 Nov 2015
I actually agree with you on this answer however I was expecting 75 when P = 10000 250 when P= 100000
the results are published in an ACM paper that was cited 3986 times since 2002.
your answer is great it does what I need, thanks a lot for your help.
I changed my file and is now working partially with me ( I got the same results as yours for P = 10000.
function [k] = New()
P = input('Please Enter value of P : ');
Pd = input('Please Enter value of P''' );
syms K
num= (1-(K/P))^(2*P-2*K+1);
den= (1-(2*K/P))^(P-2*K+0.5);
k=vpasolve(Pd== 1- num/den,K,[0 5000])
k= double(k)
end
but for P = 250 , it is throwing some odd result: Please Enter value of P : 250 Please Enter value of P'0.5
k =
Empty sym: 0-by-1
k =
Empty matrix: 0-by-1
ans =
Empty matrix: 0-by-1
Walter Roberson
Walter Roberson on 30 Nov 2015
for P = 250, there are two real-valued solutions, one about -13.5 and the other about +12.8 . My tests with a different product suggests that symbolic packages may have difficulty finding both solutions; it is even possible that MuPAD is only able to find the negative one in this case.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!