strange solution of an equation by Symbolic Toolbox
12 次查看(过去 30 天)
显示 更早的评论
I come across to an equation I was not able to solve analytically (an advanced math exercise from last year of secondary school of my son). I applied Symbolic Toolbox. It yields two solutions. The 1st one (purely real) fits the equation when put into it. But the 2nd one (purely complex) doesn't ?!? I'm not an expert in Sym. Toolbox, but I follow the help recommendations. Any ideas, recomendations ... ?
the scrip:
%hadanka
clear all
syms x complex % variable definition
digits(64); % just for security ...
a=3*sqrt(x^2-9)+4*sqrt(x^2-16)+5*sqrt(x^2-25)==120/x; % the equation
disp(a);
R=solve(a,x) % equation solving ...
x0=vpa(R); % evaluation of results (following Help for 'solve' fcn)
disp(x0);
% check 1st solution
x1=double(x0(1));
L1=3*sqrt(x1^2-9)+4*sqrt(x1^2-16)+5*sqrt(x1^2-25);
R1=120/x1;
disp(num2str([L1 R1 L1-R1]));
% check 2nd solution
x1=double(x0(2));
L2=3*sqrt(x1^2-9)+4*sqrt(x1^2-16)+5*sqrt(x1^2-25);
R2=120/x1;
disp(num2str([L2 R2 L2-R2])); % PROBLEM !!!
% end
0 个评论
采纳的回答
Paul
2022-12-6
编辑:Paul
2022-12-6
This is interesting. Don't understand why solve appears to be using the 12th root in its solution, looks like it should be the 8th
clear all
syms x complex % variable definition
digits(64); % just for security ...
a=3*sqrt(x^2-9)+4*sqrt(x^2-16)+5*sqrt(x^2-25)==120/x; % the equation
disp(a);
R=solve(a,x); % equation solving ...
x0=vpa(R); % evaluation of results (following Help for 'solve' fcn)
disp(x0);
% check 1st solution
x1=double(x0(1));
L1=3*sqrt(x1^2-9)+4*sqrt(x1^2-16)+5*sqrt(x1^2-25);
R1=120/x1;
disp(num2str([L1 R1 L1-R1]));
% check 2nd solution
format long e
x1=double(x0(2))
L2=3*sqrt(x1^2-9)+4*sqrt(x1^2-16)+5*sqrt(x1^2-25);
R2=120/x1;
disp(num2str([L2 R2 L2-R2])); % PROBLEM !!!
% end
Take a look at the second solution.
R(2)
Use the 8th root of the polynomial in sigma1 instead of the 12th (I don't know how root orders the roots of the polynomial)
syms z
R2solnew = subs(R(2),root(z^14 + 150*z^12 + 4375*z^10 - 158700*z^8 - 5920625*z^6 + 76593750*z^4 + 1954625625*z^2 - sym("22500000000"), z, 12),root(z^14 + 150*z^12 + 4375*z^10 - 158700*z^8 - 5920625*z^6 + 76593750*z^4 + 1954625625*z^2 - sym("22500000000"), z, 8));
Sub R2solnew into a and check the vpa answer, it seems to check out.
v = vpa(subs(a,x,R2solnew))
lhs(v) - rhs(v)
Check the answer symbolically, checks out
simplify(subs(a,x,R2solnew))
Check the answer in double, checks out.
format long e
x1=double(R2solnew)
L2=3*sqrt(x1^2-9)+4*sqrt(x1^2-16)+5*sqrt(x1^2-25);
R2=120/x1;
([L2 R2 L2-R2]).'
5 个评论
Torsten
2022-12-11
编辑:Torsten
2022-12-11
You can square your equation several times.
Finally you will arrive at a polynomial of degree 16 for which you can calculate its roots and check which of these roots satisfies your original equation.
syms x
a = 3*sqrt(x^2-9)+4*sqrt(x^2-16)+5*sqrt(x^2-25)==120/x
am = expand(a*x)
am = am - 5*x*sqrt(x^2-25)
am = simplify(expand(am^2))
am = am - 12*x^2
am = simplify(expand(am^2))
am = am - 2500*x^4 - x^8
am = expand(am^2)
am = rhs(am)-lhs(am)
r = vpasolve(am==0) % calculate the roots of the deduced polynomial
a = rhs(a)-lhs(a);
sol = r(abs(double(subs(a,x,r)))<1e-6) % check which of the roots satisfies your original equation
更多回答(2 个)
Torsten
2022-12-6
编辑:Torsten
2022-12-6
A MATLAB error.
A second "solution" is computed that does not solve the equation.
MATLAB needs to square your equation several times in order to arrive at the polynomial of degree 14 of which MATLAB computes a root to get a solution of your equation. During this squaring, solutions for the squared systems arise that often don't satisfy the original equation.
But why MATLAB internally does not check the final output - I don't know.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!