strange solution of an equation by Symbolic Toolbox
Show older comments
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
Accepted Answer
More Answers (2)
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.
Petr Kolar
on 29 Mar 2023
0 votes
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!



