i want to find the solution to an equation containing bessel function x*besselj(​1,x)-C*bes​selj(0,x). I am using newton raphson method but I am getting NaN as the root.

1 visualización (últimos 30 días)
clc
close all
x=linspace(0,100,10^6);
Bi=0.1;
error=10;
for i=1:10^6
x(i+1)=x(i)-(x(i).*besselj(1,x(i))-Bi*besselj(0,x(i)))./(x(i).*besselj(0,x(i))+Bi*besselj(1,(x(i))));
err(i)=abs((x(i+1)-x(i))/x(i));
if err(i)<error;
break
end
end
root=x(i)
This is my code, could anyone please point out the errors?

Respuestas (1)

Walter Roberson
Walter Roberson el 16 de Dic. de 2019
x(1) is 0. besselj(1,0) is 0 and Bi*0 is 0. besslj(0,0) is 1, but you multiply that by x(1) which is 0. So your denominator of your expression is 0. The numerator is non-zero and positive so you get infinity as the result of the division.
That infinity then poisons everything else.

Community Treasure Hunt

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

Start Hunting!

Translated by