Solve takes forever without error message for certain input values
1 view (last 30 days)
Show older comments
Hello, I try to solve following equation using matlab (R2016a+Symbolic Toolbox):
syms R2
eta=(2*R2 + 499999999999999999999999974/5)/(2*(99999999999999999999999999*R2 - 1549999999999999999999999987/5)) - 28670157817202169/38280596832649216
u =- (500000000000000000000000000*R2)/(31*(99999999999999999999999999*R2 - 1549999999999999999999999987/5)) - 3511406642924695/36028797018963968
v =3511406642924695/36028797018963968 - (500000000000000000000000000*R2)/(31*(99999999999999999999999999*R2 - 1549999999999999999999999987/5))
R2a=solve(eta==sqrt(abs(u*v)),R2);
R2a=double(R2a)
R2b=solve(eta==-sqrt(abs(u*v)),R2);
R2b=double(R2b)
R2ges=transpose([transpose(R2a) transpose(R2b)])
This works fine and will deliver two solutions for R2 in seconds. However the same code with different input parameters eta u and v will not give a solution in reasonable time without bringing any kind of error message.
syms R2
eta =(2*R2 + 4499999999999999999999999801/45)/(2*(99999999999999999999999999*R2 - 2711111111111111111111111089/10)) - 4465535319756041/38280596832649216
u =- (1125000000000000000000000000*R2)/(61*(99999999999999999999999999*R2 - 2711111111111111111111111089/10)) - 7022813285849393/72057594037927936
v =7022813285849393/72057594037927936 - (1125000000000000000000000000*R2)/(61*(99999999999999999999999999*R2 - 2711111111111111111111111089/10))
R2a=solve(eta==sqrt(abs(u*v)),R2);
R2a=double(R2a)
R2b=solve(eta==-sqrt(abs(u*v)),R2);
R2b=double(R2b)
R2ges=transpose([transpose(R2a) transpose(R2b)])
If I stop the code, I get the following message:
Operation terminated by user during mupadengine/evalin (line 102)
In mupadengine/feval (line 158)
[S,err] = evalin(engine,stmt,'message');
In solve (line 292)
sol = eng.feval('solve', eqns, vars, solveOptions);
In forum_test (line 29)
R2a=solve(eta==sqrt(abs(u*v)),R2);
Do you have any ideas how to resolve the problem? I want to solve this equation a lot of times in order to find certain cases that fulfill other conditions. However, if in a loop iteration, one of the "solve" lines takes forever, this does obviously not work and will make it very impractical for example to have a lot of iterations run over night.
Thanks and best regards, Tina
2 Comments
Torsten
on 21 Aug 2017
What you have after multiplication with the denominators is a polynomial equation of 4th degree in R2. There is an analytic solution formula for such polynomials. Why don't you use it directly ?
Best wishes
Torsten.
Answers (1)
See Also
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!