besselj
Bessel function of first kind
Description
J = besselj(
computes the Bessel function of the first kind
Jν(z) for each element in array nu
,Z
)Z
.
Examples
Plot Bessel Functions of First Kind
Define the domain.
z = 0:0.1:20;
Calculate the first five Bessel functions of the first kind. Each row of J
contains the values of one order of the function evaluated at the points in z
.
J = zeros(5,201); for i = 0:4 J(i+1,:) = besselj(i,z); end
Plot all of the functions in the same figure.
plot(z,J) grid on legend('J_0','J_1','J_2','J_3','J_4','Location','Best') title('Bessel Functions of the First Kind for $\nu \in [0, 4]$','interpreter','latex') xlabel('z','interpreter','latex') ylabel('$J_\nu(z)$','interpreter','latex')
Calculate Exponentially Scaled Bessel Function
Calculate the unscaled (J
) and scaled (Js
) Bessel function of the first kind for complex values of .
x = -10:0.3:10; y = x'; z = x + 1i*y; scale = 1; J = besselj(2,z); Js = besselj(2,z,scale);
Compare the plots of the imaginary part of the scaled and unscaled functions. For large values of abs(imag(z))
, the unscaled function quickly overflows the limits of double precision and stops being computable. The scaled function removes this dominant exponential behavior from the calculation, and thus has a larger range of computability compared to the unscaled function.
surf(x,y,imag(J)) title('Bessel Function of the First Kind','interpreter','latex') xlabel('real(z)','interpreter','latex') ylabel('imag(z)','interpreter','latex')
surf(x,y,imag(Js)) title('Scaled Bessel Function of the First Kind','interpreter','latex') xlabel('real(z)','interpreter','latex') ylabel('imag(z)','interpreter','latex')
Input Arguments
nu
— Equation order
scalar | vector | matrix | multidimensional array
Equation order, specified as a scalar, vector, matrix, or multidimensional array.
nu
is a real number that specifies the order of the Bessel function of the first kind. nu
and
Z
must be the same size, or one of them can be scalar.
Example: besselj(3,0:5)
Data Types: single
| double
Z
— Functional domain
scalar | vector | matrix | multidimensional array
Functional domain, specified as a scalar, vector, matrix, or multidimensional array.
besselj
is real-valued where Z
is positive.
nu
and Z
must be the same size, or one of them
can be scalar.
Example: besselj(1,[1-1i 1+0i 1+1i])
Data Types: single
| double
Complex Number Support: Yes
scale
— Toggle to scale function
0
(default) | 1
Toggle to scale function, specified as one of these values:
0
(default) — No scaling1
— Scale the output ofbesselj
byexp(-abs(imag(Z)))
On the complex plane, the magnitude of besselj
grows
rapidly as the value of abs(imag(Z))
increases, so exponentially
scaling the output is useful for large values of abs(imag(Z))
where
the results otherwise quickly lose accuracy or overflow the limits of double
precision.
Example: besselj(3,0:5,1)
More About
Bessel Functions
This differential equation, where ν is a real constant, is called Bessel's equation:
Its solutions are known as Bessel functions.
The Bessel functions of the first kind, denoted Jν(z) and J–ν(z), form a fundamental set of solutions of Bessel's equation for noninteger ν. Jν(z) is defined by
The Bessel functions of the second kind, denoted Yν(z), form a second solution of Bessel's equation that is linearly independent of Jν(z). Yν(z) is defined by
You can calculate Bessel functions of the second kind using bessely
.
Tips
The Bessel functions are related to the Hankel functions, also called Bessel functions of the third kind:
is besselh
, Jν(z) is besselj
, and Yν(z) is bessely
. The Hankel functions also form a
fundamental set of solutions to Bessel's equation (see besselh
).
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. For more information, see Tall Arrays.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Always returns a complex result.
Strict single-precision calculations are not supported. In the generated code, single-precision inputs produce single-precision outputs. However, variables inside the function might be double-precision.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Usage notes and limitations:
Always returns a complex result.
Strict single-precision calculations are not supported. In the generated code, single-precision inputs produce single-precision outputs. However, variables inside the function might be double-precision.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
Usage notes and limitations:
The order
nu
must contain nonnegative, real, integer values.The argument
Z
must contain real values.
For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced before R2006a
Apri esempio
Si dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)