필터 지우기
필터 지우기

How do I get real roots only from the Newton Raphson method for solving multivariable equation?

조회 수: 1 (최근 30일)
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
Walter Roberson
Walter Roberson 2018년 8월 11일
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.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by