- Don't indcrease n to 20.
- Get a bigger, faster computer.
The solution process takes too long+vpasolve
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
John D'Errico
il 10 Lug 2020
Recommendation(s)?
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?
Risposte (0)
Vedere anche
Categorie
Scopri di più su Systems of Nonlinear Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!