The solution process takes too long+vpasolve

조회 수: 12 (최근 30일)
Pooneh Shah Malekpoor
Pooneh Shah Malekpoor 2020년 7월 10일
댓글: Pooneh Shah Malekpoor 2020년 7월 10일
Hello, I am solving a single variable nonlinear equation(i.e. eqn) using vpasolve. The solution speed is fine if n is equal to 10. However, it gets (kind of) stuck when I increase the n to 20. What is your recommendation?
*P.S. This code is a part of a major code in which C, l, beta, A, rho and... are all defined.
tol=0.001;
Error=100;
te=0;
EE=sym(zeros(n+1,1));
while Error>tol
syms x positive
for i=1:n+1
if i==1
EE(1,1)=0;
else
EE(i,1)=(((C*l(i-1)/x)+(((tan(phi*pi/180))/x)*((rho*9.81*A(i-1)*(cos(beta(i-1))))+(EE(i-1)*(sin(beta(i-1)-(te))))))-(rho*9.81*A(i-1)*(sin(beta(i-1))))+(EE(i-1)*(cos(beta(i-1)-(te)))))/((cos(beta(i-1)-(te)))+((sin(beta(i-1)-(te)))*(tan(phi*pi/180))/x)));
end
end
eqn = (simplify((EE(n+1,1))));
[k] =max(vpasolve(eqn, x ,[0.1 5]));
  댓글 수: 2
John D'Errico
John D'Errico 2020년 7월 10일
Recommendation(s)?
  1. Don't indcrease n to 20.
  2. Get a bigger, faster computer.
As you increase n, at each iteration, each step uses the result from the previous step in the loop.
You don't tell us what all of those unknown constants are, so I cannot really do too much. But remember that EE is getting bigger, nastier, messier, at each and every step. So what do you expect?
Pooneh Shah Malekpoor
Pooneh Shah Malekpoor 2020년 7월 10일
My analyses is such that I should compare the results also for n=20. so, the results for n=20 is as important as when n=10.
My question is, Does vpasolve, fsolve and fzero have the same speed when solving such an equation?
I should say again that C,phi and rho are constants and all A, beta, l are coded based on geometrical coordinates. The main problem (as you mentioned) in this nonlinear equation is that there are EE on both sides.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by