How to solve for multiple roots
22 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, I am trying to solve the first 500 roots of the following equation tan (x)= (3x)/(3+(60.5*(x^2)) But I cannot figure out how to do it. Any help will be appreciated.
0 commentaires
Réponse acceptée
John D'Errico
le 4 Nov 2018
Modifié(e) : John D'Errico
le 4 Nov 2018
The first 500 roots? Why 500? Are there 500 such roots?
By the way, I think you need to learn to use fewer parens.
f = @(x) tan(x) - 3*x./(3+60.5*x.^2);
One root clearly lies at x == 0. In fact, quick examination suggests that n*pi is a good approximation to all non-negative roots.
f(pi*(0:10))
ans =
0 -0.015705 -0.0078821 -0.0052584 -0.0039448 -0.0031562 -0.0026303 -0.0022546 -0.0019728 -0.0017537 -0.0015783
So just use a loop, calling fzero for each starting value n*pi.
xn = zeros(1,11);
for n = 1:10;
xn(n+1) = fzero(f,n*pi);
end
xn
xn =
Columns 1 through 7
0 3.15721947602233 6.29105738669815 9.43003337009966 12.570314108792 15.7111187818028 18.8521858417768
Columns 8 through 11
21.9934029606895 25.134713911635 28.2760874364729 31.4175047721421
ezplot(f,[0,35])
hold on
refline(0,0)
plot(xn,0,'ro')
0 commentaires
Plus de réponses (2)
madhan ravi
le 4 Nov 2018
syms x
e1=tan(x)==(3*x)/(3+(60.5*(x^2)))
vpasolve(e1,x,1)
1 commentaire
madhan ravi
le 4 Nov 2018
Modifié(e) : madhan ravi
le 4 Nov 2018
For multiple roots you have to specify the interval
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!