Integrations of Bessel functions

114 visualizaciones (últimos 30 días)
Javeria
Javeria el 16 de Ag. de 2025 a las 14:41
Comentada: Javeria el 19 de Ag. de 2025 a las 3:50
I have these two integrals and i want to find its analytical integral i tried in MATLAB symbolic tool box but i could not.
How to find this integral analytically.

Respuesta aceptada

Torsten
Torsten el 16 de Ag. de 2025 a las 14:54
Editada: Torsten el 16 de Ag. de 2025 a las 22:49
For the first integral I_1, see
For this example, the closed-form expression works:
f = @(x)besselj(0,2*x).*besselj(0,3*x).*x;
integral(f,0,4,'AbsTol',1e-12,'RelTol',1e-12)
ans = -0.1100
4/(2^2-3^2)*(3*besselj(0,2*4)*besselj(-1,3*4)-2*besselj(-1,2*4)*besselj(0,3*4))
ans = -0.1100
But I can't reproduce the result claimed under "One obtains finally":
f = @(x)besseli(0,2*x).*besselj(0,3*x).*x;
integral(f,0,4,'AbsTol',1e-12,'RelTol',1e-12)
ans = -76.4537
4*3/(2^2+3^2)*besselj(1,3*4)*besseli(0,2*4)
ans = -88.1889
Wolframalpha gives a solution for I_2 for l = 0 and l = 1:

Más respuestas (1)

Umar
Umar el 16 de Ag. de 2025 a las 16:58

Hi @Javeria,

I read your comments and implemented the analytical formulas for the two Bessel function integrals directly in MATLAB. The script computes their exact values without using the symbolic toolbox, so it provides the analytical results you were looking for. This should fully answer your questions.

Implementation

%==========================================================
% Bessel product integrals (analytic evaluation, no toolbox)
%==========================================================
% Integral 1:
%   I = ∫_0^a r J0(nu r) I0(mu r) dr
% General closed form:
%   I = (a/(nu^2+mu^2)) * [ nu*J1(nu a) I0(mu a) + mu*J0(nu a) I1(mu a) ]
%
% If J0(nu a) = 0 (typical boundary condition), it reduces to:
%   I = (a*nu/(nu^2+mu^2)) * J1(nu a) I0(mu a)
function val = besselJI0_int(nu, mu, a)
  term1 = nu * besselj(1, nu*a) * besseli(0, mu*a);
  term2 = mu * besselj(0, nu*a) * besseli(1, mu*a);
  val = a/(nu^2 + mu^2) * (term1 + term2);
end
% ------------------------------------------------------------
% Integral 2:
%   I = ∫_0^R r J_l(k0 r) I_l(chi r) dr
% General closed form:
%   I = (R/(k0^2+chi^2)) * [ k0 J_{l+1}(k0 R) I_l(chi R)
%                             + chi J_l(k0 R) I_{l+1}(chi R) ]
function val = besselJI_int(l, k0, chi, R)
  term1 = k0 * besselj(l+1, k0*R) * besseli(l, chi*R);
  term2 = chi * besselj(l, k0*R) * besseli(l+1, chi*R);
  val = R/(k0^2 + chi^2) * (term1 + term2);
end
% ============================================================
% Example usage
% ============================================================
% Parameters
nu  = 2.5;   % example value for nu
mu  = 1.2;   % example value for mu
a   = 1.0;   % upper limit
k0  = 3.0;   % example k0
chi = 1.5;   % example chi
R   = 1.0;   % upper limit
l   = 0;     % order
% Compute integrals
I1 = besselJI0_int(nu, mu, a);
I2 = besselJI_int(l, k0, chi, R);
% Display results
fprintf('Integral 1 result = %.6f\n', I1);
fprintf('Integral 2 result = %.6f\n', I2);

Results

Furthermore, My solution implements the exact analytical formulas for integrals of products of Bessel J and modified Bessel I functions, allowing direct computation without the symbolic toolbox. I also appreciate @Torsten’s comments—they correctly point out that formulas for J⋅J integrals don’t directly carry over to J⋅I integrals. His observations helped clarify why a naive application of the J⋅J formula wouldn’t match the numerical result. My script builds on this understanding to provide the correct analytical values for the J⋅I case.

  17 comentarios
Torsten
Torsten el 18 de Ag. de 2025 a las 10:25
Editada: Torsten el 18 de Ag. de 2025 a las 17:37
You could try like this, but the array E1 (and others) are not defined. So I don't know if it works.
clear all;
close all;
clc;
tic;
tau = [0.4 1];
hold on
for i = 1:numel(tau)
[omega,eta] = compute_eta(tau(i));
plot(2*pi./omega, eta, 'k', 'LineWidth', 1.5); %%% this is T which is T= 2*pi/omega plotting against T
end
hold off
xlabel('$T$', 'Interpreter', 'latex');
ylabel('$|\eta / (iA)|$', 'Interpreter', 'latex');
title('Wave motion amplitude for $R_E = 138$', 'Interpreter', 'latex');
legend({'$\tau=0.4$'}, ...
'Interpreter','latex','Location','northwest');
grid on;
xlim([5 35]); % Match the reference plot
ylim([0 4.5]); % Optional: based on expected peak height
elapsedTime = toc;
disp(['Time consuming = ', num2str(elapsedTime), ' s']);
function [omega,eta0] = compute_eta(tau)
%clear all;
%close all;
%clc;
%tic;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Parameters from your setup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N = 100; % Number of N modes
M = 100; % Number of M modes
Q = 100; % Number of Q modes
RI = 34.5; % Inner radius (m)
% ratio = 47.5/34.5; % Ratio R_E / R_I
RE = 47.5; % outer radius (m)
% h = 200/34.5 * RI; % Water depth (m)
h = 200;
d = 38; % Interface depth (m)
b = h-d; % Distance from cylinder bottom to seabed (m)
g = 9.81; % Gravity (m/s^2)
%tau = 1.0; % porosity ratio %%% need loop for this one
l = 0; % Azimuthal order
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% === Compute Bessel roots and scaled chi values ===
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
roots = bessel0j(l, Q); % Zeros of J_l(x)
chi = roots ./ RI; % chi_q^l = roots scaled by radius
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ===== Define Range for k_0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
X_kRE = linspace(0.0025, 0.16,100); %%%%%% this is now k_0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ==============Initialize eta0 array before loop
%===============Initialize omega array before loop
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
eta0 = zeros(size(X_kRE)); % Preallocate
omega = zeros(size(X_kRE)); %%%% omega preallocate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for idx = 1:length(X_kRE)
wk = X_kRE(idx); % dimensional wavenumber
omega(idx) = sqrt(g * wk * tanh(wk * h)); % dispersion relation
%%%%%%%%%%%%% Compute group velocity %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Cg(idx) = (g * tanh(wk * h) + g * wk * h * (sech(wk * h))^2) ...
* omega(idx) / (2 * g * wk * tanh(wk * h));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% =======Compute a1 based on tau
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a1(idx) = 0.93 * (1 - tau) * Cg(idx);
% dissip(idx) = a1(idx)/omega(idx);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%=============== Find derivative of Z0 at z = -d
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Z0d = (cosh(wk * h) * wk * sinh(wk * b)) / (2 * wk * h + sinh(2 * wk * h));
fun_alpha = @(x) omega(idx)^2 + g*x.*tan(x*h); %dispersion equation for evanescent modes
for n = 1:N
if n == 1
k(n) = -1i * wk;
else
x0_left = (2*n - 3) * pi / (2*h);
x0_right = (2*n - 1) * pi / (2*h);
guess = (x0_left + x0_right)/2;
% Use lsqnonlin for better convergence
k(n) = lsqnonlin(fun_alpha, guess, x0_left, x0_right,optimset('Display','none'));
%%%%%%%%%%%%% Derivative of Z_n at z = -d %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Znd(n) = -k(n) * (cos(k(n)*h) * sin(k(n)*b)) / (2*k(n)*h + sin(2*k(n)*h));
end
end
%% finding the root \lemda_m =m*pi/b%%%%%%
for j=1:M
m(j)=(pi*(j-1))/b;
end
%
% H(q): diagonal term (exponential form)
H1 = zeros(Q,1);
for q = 1:Q
% dissip =
r = exp(-2*chi(q)*b); % e^{-2*chi*b}
mid = 4*r/(1 - r^2) - E1(q); % 2/sinh(2*chi*b) - C_m
H1(q) = mid + 1i*a1(idx)*chi(q)/omega(idx); % mid + i*(a1/w)*chi
end
H = diag(H1);
%%%%%%%%%%matric G%%%%%%%%%%%%%%%%%%
G = zeros(Q, N); % Preallocate
for q = 1:Q
G(q,1) = 1i * 2*(a1(idx)/(omega(idx)*RI))* Z0d ...
* ( chi(q) / (chi(q)^2 - wk^2) )* ( besselj(l, wk*RI) / dbesselj(l, wk*RI) ); % this one is my calculated
% G(q,1) = -1i * (2*a1(idx)/omega(idx)) ... %%%%% Prof.chen solution
% * ( Z0d * chi(q) * besselj(l, wk*RI) ) ...
% / ( (wk^2 - chi(q)^2) * dbesselj(l, wk*RI) );
end
% %G_qn
for q = 1:Q
for n = 2:N
G(q, n) = 1i * 2*(a1(idx)/(omega(idx)*RI))* Znd(n) ...
* ( chi(q) / (k(n)^2 + chi(q)^2) )* ( besseli(l, k(n)*RI) / dbesseli(l, k(n)*RI) ); % this one is my calculated
% G(q,n) = -1i * (2*a1(idx)/omega(idx)) ... %%%%% Prof.chen solution
% * ( Znd(n) * chi(q) * besseli(l, k(n)*RI) ) ...
% / ( (k(n)^2 + chi(q)^2) * dbesseli(l, k(n)*RI) );
end
end
% % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%% Wave motion%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
term1 = (d_vec(1)*cosh(wk*h)^2) / ((2*wk*h + sinh(2*wk*h)) * dbesselj(l, wk*RI));
sum1 = 0;
for n =2:N
sum1 = sum1 + d_vec(n)*cos(k(n)*h)^2/ ((2*k(n)*h + sin(2*k(n)*h))* dbesseli(l, k(n)*RI));
end
phiUell = 0;
for q =1:Q
phiUell = phiUell +e_vec(q)* S_q(q);
end
eta0(idx) = abs(term1+sum1+phiUell);
end
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % % Plotting Data
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
%plot(2*pi./omega, eta0, 'k', 'LineWidth', 1.5); %%% this is T which is T= 2*pi/omega plotting against T
%hold on; % Add extra plots on same figure
% % %
%xlabel('$T$', 'Interpreter', 'latex');
%ylabel('$|\eta / (iA)|$', 'Interpreter', 'latex');
%title('Wave motion amplitude for $R_E = 138$', 'Interpreter', 'latex');
%legend({'$\tau=0.4$'}, ...
% 'Interpreter','latex','Location','northwest');
%grid on;
%xlim([5 35]); % Match the reference plot
%ylim([0 4.5]); % Optional: based on expected peak height
%
%elapsedTime = toc;
%disp(['Time consuming = ', num2str(elapsedTime), ' s']);
end
function x = bessel0j(l,q,opt)
% a row vector of the first q roots of bessel function Jl(x), integer order.
% if opt = 'd', row vector of the first q roots of dJl(x)/dx, integer order.
% if opt is not provided, the default is zeros of Jl(x).
% all roots are positive, except when l=0,
% x=0 is included as a root of dJ0(x)/dx (standard convention).
%
% starting point for for zeros of Jl was borrowed from Cleve Moler,
% but the starting points for both Jl and Jl' can be found in
% Abramowitz and Stegun 9.5.12, 9.5.13.
%
% David Goodmanson
%
% x = bessel0j(l,q,opt)
k = 1:q;
if nargin==3 && opt=='d'
beta = (k + l/2 - 3/4)*pi;
mu = 4*l^2;
x = beta - (mu+3)./(8*beta) - 4*(7*mu^2+82*mu-9)./(3*(8*beta).^3);
for j=1:8
xnew = x - besseljd(l,x)./ ...
(besselj(l,x).*((l^2./x.^2)-1) -besseljd(l,x)./x);
x = xnew;
end
if l==0
x(1) = 0; % correct a small numerical difference from 0
end
else
beta = (k + l/2 - 1/4)*pi;
mu = 4*l^2;
x = beta - (mu-1)./(8*beta) - 4*(mu-1)*(7*mu-31)./(3*(8*beta).^3);
for j=1:8
xnew = x - besselj(l,x)./besseljd(l,x);
x = xnew;
end
end
end
% --- Local helper function for derivative of Bessel function ---
function dJ = besseljd(l, x)
dJ = 0.5 * (besselj(l - 1, x) - besselj(l + 1, x));
end
function out = dbesselh(l, z)
%DBESSELH Derivative of the Hankel function of the first kind
% out = dbesselh(l, z)
% Returns d/dz [H_l^{(1)}(z)] using the recurrence formula:
% H_l^{(1)'}(z) = 0.5 * (H_{l-1}^{(1)}(z) - H_{l+1}^{(1)}(z))
out = 0.5 * (besselh(l-1, 1, z) - besselh(l+1, 1, z));
end
function out = dbesseli(l, z)
%DBESSELI Derivative of the modified Bessel function of the first kind
% out = dbesseli(l, z)
% Returns d/dz [I_l(z)] using the recurrence formula:
% I_l'(z) = 0.5 * (I_{l-1}(z) + I_{l+1}(z))
out = 0.5 * (besseli(l-1, z) + besseli(l+1, z));
end
function out = dbesselj(l, z)
%DBESSELJ Derivative of the Bessel function of the first kind
% out = dbesselj(l, z)
% Returns d/dz [J_l(z)] using the recurrence formula:
% J_l'(z) = 0.5 * (J_{l-1}(z) - J_{l+1}(z))
out = 0.5 * (besselj(l-1, z) - besselj(l+1, z));
end
function out = dbesselk(l, z)
%DBESSELK Derivative of the modified Bessel function of the second kind
% out = dbesselk(l, z)
% Returns d/dz [K_l(z)] using the recurrence formula:
% K_l'(z) = -0.5 * (K_{l-1}(z) + K_{l+1}(z))
out = -0.5 * (besselk(l-1, z) + besselk(l+1, z));
end
Javeria
Javeria el 19 de Ag. de 2025 a las 3:50
@Torsten @Umar Thank you for your suggestions and help. It works for my problem.

Iniciar sesión para comentar.

Categorías

Más información sobre Special Functions en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by