Quantcast
Channel: MATLAB Central Newsreader - tag:"homework"
Viewing all articles
Browse latest Browse all 36

Re: Finding roots from bessel functions

$
0
0
Hello all,

I came across this post while looking for a solution to a similar problem. I also needed to find multiple roots to a nonlinear equation composed of Bessel functions, F(x) = 0.

I solved my problem by writing a function as below. The function:
* First identifies the 'approximate' locations of roots by evaluating F(x) on a sufficiently fine regular grid of x and searching for sign changes across x.
* Disects the x-domain into non-overlapping sub-intervals, each containing one and only one root.
* Finally it runs 'fzero' on each sub-interval to determine the precise values of roots. This eliminates the guess work associated with initial values

The function will return as many roots as needed depending on the upper bound of the initial grid x. The roots will be the smallest unique roots returned in ascending order.

Note that there has to be a sign change around each root for this to work. Fortunately this was always the case for my problem.

Also the variables were defined according to my specific problem but the function itself can easily be adapted to other problems. I hope it will be useful to those who are looking for a solution to a similar problem.

Altug


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function alpha_n = calculate_alpha_roots(nus)
%CALCULATE_ALPHA_ROOTS calculates and returns the roots of a specific
%nonlinear equation composed of bessel functions and is parameterized by
%the input parameter, 'nus'.
%INPUT:
% nus: parameter in function 'func'
%OUTPUT
% alpha_n: The smallest 'N_roots_returned' many roots of equation
% 'func = 0'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N_roots_returned = 256;

% Define Bessel functions:
J0 = @(z)(besselj(0,z));
J1 = @(z)(besselj(1,z));

% Characteristic equation (func(x)= 0) for which we are seeking the
% roots x.
func = @(x)(J1(x) - (1 - nus).*x .*J0(x)./(1 - 2.* nus));

% Find approximate locations of the roots, exploiting the fact that each
% root is associated with a change of sign.

% Computational grid for determination of approximate locations of roots:
x = 0:0.1:1000; % The interval needs to be large enough to satisfy
                % N_roots_found >= N_roots_returned
                
F = func(x);
SF = sign(F);
% Difference of signs between successive grid points
DSF = (SF(2:end) - SF(1:end-1));
% If there is a sign change, then there is a root in the vicinity.
approximate_roots = x(abs(DSF)>0);
approximate_roots = sort(approximate_roots(:));

% Disect the domain into regions containing one and only one root:
bounds = 0.5*(approximate_roots(1:end-1)+approximate_roots(2:end));
bounds(end+1) = max(x);
N_roots_found = numel(approximate_roots);
roots = zeros(N_roots_found,1);

% Find precise locations of the roots by running fzero within each region.
% We know the first root: x = 0;
for i = 2:N_roots_found
    lb = bounds(i-1);
    ub = bounds(i);
    roots(i) = fzero(func, [lb ub]);
end

alpha_n = roots(1:N_roots_returned);

end % function
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


"cevik1404" wrote in message <n24ski$4js$1@newscl01ah.mathworks.com>...
> "Robi" wrote in message <gu32me$lg4$1@fred.mathworks.com>...
> > Hi
> > I am a new user of Matlab and new in this site. I am trying to find a number of roots or multiple roots (i.e., x in the following equation) from a non-linear equation of bessel functions which is given below:
> >
> > x*J'(m,x*r)+H*J(m,x*r)=0
> > where
> > J'(m,x*r) is the first derivative of Bessel function J(m,x*r)
> > m= degree and r=ro (say, known) and H is a known constant
> >
> > Please, help me to figure this out.
> >
> > thanks
> >
>
> Hi Robi
>
> I am also trying to find roots of bessel function like your quest?ion (x*J'(m,x*r)+H*J(m,x*r)=0
> ) could you help me about it .. ? am new at matlab ..

Viewing all articles
Browse latest Browse all 36

Trending Articles