How to calculate Bessel function of order zero?

Click For Summary
SUMMARY

The discussion centers on calculating the Bessel function of order zero, specifically using MATLAB's besseli function. The user initially encounters issues with plotting due to incorrect element-wise operations in their script. The solution involves adding dots for element-wise division and multiplication in the calculation of h. The corrected code successfully generates the expected plot.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of Bessel functions, specifically besseli
  • Knowledge of element-wise operations in MATLAB
  • Basic plotting techniques in MATLAB
NEXT STEPS
  • Study MATLAB's element-wise operations and syntax
  • Explore the properties and applications of Bessel functions
  • Learn advanced plotting techniques in MATLAB
  • Investigate numerical methods for solving differential equations involving Bessel functions
USEFUL FOR

Mathematicians, engineers, and researchers who require accurate plotting of Bessel functions in MATLAB, as well as students learning numerical methods and MATLAB programming.

positroncascade
Messages
2
Reaction score
0
TL;DR
I try to plot a figure from an article. The analytical solution is given by Bessel function of order zero. I wrote my MATLAB script but it doesn't give results as expected. I need help on evaluating Bessel function of order zero.
Hello everyone.

I try to plot a figure from a journal article. I gave the equations in the inserted image. I wrote the script given below for that. I expect to obtain a plot like the one given on the left but I end up with something totally different. So, the values of ##I_{0}## and ##I_{1}## are probably wrong. How can I evaluate them correctly? Can you help me to spot my error?

Matlab:
phi = linspace(0.001, 1000, 1000000);
v = 2;
lRp = sqrt((1./phi).*((v+1)^2-1));
I1 = besseli(1,lRp);
I0 = besseli(0,lRp);
h = 1 - 2./lRp*(I1/I0);
plot(phi,h)
set(gca, 'XScale', 'log')

Thank you so much!

Capture.PNG
 
Last edited:
Physics news on Phys.org
You are missing dots in line 6. Fixed:
[CODE title="Matlab"]phi = linspace(0.001, 1000, 1000000);
v = 2;
lRp = sqrt((1./phi).*((v+1)^2-1));
I1 = besseli(1,lRp);
I0 = besseli(0,lRp);
h = 1 - 2./lRp.*(I1./I0);
plot(phi,h)
set(gca, 'XScale', 'log')[/CODE]
 
  • Like
Likes   Reactions: DrClaude and positroncascade

Similar threads

Replies
5
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K