Can MATLAB solve 3 order equation including square root of the variable?
Show older comments
Hi there,
I am using MATLAB to solve the below equation to obtain x. All the other variables are known.

The code used is shown below.
if true
% code
syms a b c d e f g R x
eqn = a*x^3 + b*sqrt(R^2-x^2)*x^2 + c*x^2 + d*sqrt(R^2-x^2)*x...
+ e*x + f*sqrt(R^2-x^2) + g == 0;
sol = solve(eqn, x, 'ReturnConditions', true)
end
Then I have the results:
>> sol.conditions
=
(d^2 - 4*b*f)^(1/2) ~= d + 2*b*z1 & d + 2*b*z1 + (d^2 - 4*b*f)^(1/2) ~= 0 & a^2 + b^2 ~= 0 & R^2*b^2*z1^4 + 2*R^2*b*d*z1^3 + 2*R^2*b*f*z1^2 + R^2*d^2*z1^2 + 2*R^2*d*f*z1 + R^2*f^2 == a^2*z1^6 + 2*a*c*z1^5 + 2*a*e*z1^4 + 2*a*g*z1^3 + b^2*z1^6 + 2*b*d*z1^5 + 2*b*f*z1^4 + c^2*z1^4 + 2*c*e*z1^3 + 2*c*g*z1^2 + d^2*z1^4 + 2*d*f*z1^3 + e^2*z1^2 + 2*e*g*z1 + f^2*z1^2 + g^2 & (signIm(((a*z1^3 + c*z1^2 + e*z1 + g)*1i)/(b*z1^2 + d*z1 + f)) == -1 | a*z1^3 + c*z1^2 + e*z1 + g == 0) & b ~= 0
>> sol.parameters
=
z1
>> sol.x
ans =
z1
Does this mean there is no solution for the equation, please?
Thanks.
Accepted Answer
More Answers (1)
Duncan Lilley
on 18 Oct 2017
0 votes
Hello,
If a symbolic equation has no solution, then "solve" would return empty. The return value you have received indicates that there is a solution, but because there are so many variables and terms within square roots, the symbolic solution is subject to conditions. Whatever values satisfy the conditions on parameter "z1" are valid solutions to "x".
If you want a numeric solution, since the other variables are known, you can substitute for those values and get a numeric solution by using "vpasolve". You can find the documentation page for "vpasolve" here.
If, however, you wish to have a symbolic solution, this page may help you with troubleshooting equation solutions from the "solve" function.
More information regarding the differences between symbolic and numeric can be found on this documentation page.
Categories
Find more on Equation Solving in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!