long runtime when trying to solve a simple system

조회 수: 5 (최근 30일)
Pau  Forcadell Campos
Pau Forcadell Campos 2022년 3월 13일
편집: Walter Roberson 2022년 3월 13일
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.

채택된 답변

Walter Roberson
Walter Roberson 2022년 3월 13일
편집: Walter Roberson 2022년 3월 13일
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]
eqn = 
%
% [solx, soly] = solve(eqn)
string(eqn)
ans = 1×2 string array
"(100*x^2)/((x - 3^(1/2)*((569*x)/10000 - (3*x^2)/5000 + 3303/5000))*(y/2 - (329*x)/500 + (11*x^2)/5000 + 21/100)) == 690" "7850*y^3 - 3925*pi*(y - x*((11*x^2)/5000 - (79*x)/500 + 21/100)) + 7850*pi*((5249*x)/5000 + 53137/10000)^2*((11*x^2)/5000 - (79*x)/500 + 21/100) == 10"
part_y = solve(eqn(1), y)
part_y = 
eqn2 = subs(eqn(2), y, part_y)
eqn2 = 
part_x = solve(eqn2, x);
full_x = part_x
full_x = 
full_y = subs(part_y, x, full_x)
full_y = 
vpa(full_x, 16)
ans = 
vpa(full_y, 16)
ans = 

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by