How do I get real roots only from the Newton Raphson method for solving multivariable equation?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi All,
I'm using the following lines of codes to call on the new_raph.m function to get solutions for x & y.
b0=1;
z=linspace(0.5,1,2);
u0=(b0/2/pi).*asin(z);
x0=linspace(.1,.9,length(z)); y0=linspace(1*exp(1),5*exp(1),length(z));
syms x y
assume(x,'real')
assume(y,'real')
for j=1:length(z)
equation1=2.*x.*log(y)-(pi*y.^2.*z(j))+(y.^2.*asin(z(j)).*sin(2.*pi.*(u0(j)+x)/b0));
equation2=x.^2./y-2*pi.*y.*z(j).*x+2.*y.*(cos(2*pi.*u0(j)./b0)-cos(2.*pi.*(u0(j)+x)./b0));
[p(j) q(j)]=new_raph(equation1, equation2, x0(j),y0(j));
end
I only want real roots but the function is giving me complex roots. Can anyone suggest a better way of doing this where I can get real numbers only for the system of equations? Thanks!
1 commentaire
Walter Roberson
le 11 Août 2018
Never eval() a symbolic expression. Symbolic expressions are in a language which is not quite MATLAB.
Use \ in preference to inv() as inv() introduces inaccuracies.
Réponses (0)
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!