long runtime when trying to solve a simple system
5 views (last 30 days)
Show older comments
Pau Forcadell Campos
on 13 Mar 2022
Edited: Walter Roberson
on 13 Mar 2022
First of all, I am a newbie to matlab, so maybe I am commiting an ovbious error. All feedback is thankfully accepted.
I have coded a simple program in order to find the solutions to a system of two algebraic equations. When I start it, it can be running for an hour and it doesn't find the solution. I also find it strange because I figured it should strain my CPU, but it runs at only 10% usage.
syms x y;
[solx,soly] = solve((100*pi*(x.^2))/((((y-x)/2)+0.0022*(x.^2)-0.158*x+0.21)*pi*(x-(3^(1/2)*(-0.0006*(x.^2)+0.0569*x+0.6606)))) == 690, (7850*((y^3)-pi*((-0.0022*(x^2)+0.158*x-0.21)*(1.0498*x+5.3137)*(1.0498*x+5.3137))-(0.5*pi)*(y-x*(0.0022*(x^2)-0.158*x+0.21)))) == 10);
disp [solx,soly]
Is the code wrong? Am I missing something? I just want to find the values of x and y.
0 Comments
Accepted Answer
Walter Roberson
on 13 Mar 2022
Edited: Walter Roberson
on 13 Mar 2022
Exact solutions requires the roots of a degree 12 polynomial.
syms x y;
eqn = [(100*pi*(x.^2))/((((y-x)/2)+0.0022*(x.^2)-0.158*x+0.21)*pi*(x-(3^(1/2)*(-0.0006*(x.^2)+0.0569*x+0.6606)))) == 690, (7850*((y^3)-pi*((-0.0022*(x^2)+0.158*x-0.21)*(1.0498*x+5.3137)*(1.0498*x+5.3137))-(0.5*pi)*(y-x*(0.0022*(x^2)-0.158*x+0.21)))) == 10]
%
% [solx, soly] = solve(eqn)
string(eqn)
part_y = solve(eqn(1), y)
eqn2 = subs(eqn(2), y, part_y)
part_x = solve(eqn2, x);
full_x = part_x
full_y = subs(part_y, x, full_x)
vpa(full_x, 16)
vpa(full_y, 16)
0 Comments
More Answers (0)
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!





