Solve takes forever without error message for certain input values
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Torsten
2017년 8월 21일
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.
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!