Borrar filtros
Borrar filtros

The solution process takes too long+vpasolve

9 visualizaciones (últimos 30 días)
Pooneh Shah Malekpoor
Pooneh Shah Malekpoor el 10 de Jul. de 2020
Comentada: Pooneh Shah Malekpoor el 10 de Jul. de 2020
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 comentarios
John D'Errico
John D'Errico el 10 de Jul. de 2020
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 el 10 de Jul. de 2020
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.

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by