Bessel functions
This example demonstrates the calculation of a Bessel function of the first kind, a Bessel function of the second kind, and a spherical Bessel function of the first kind at a point. x=2.5.
To implement the example, we will need a library SpecialFunctions  It is designed to calculate special mathematical functions used in science and engineering.
Pkg.add("SpecialFunctions")
using SpecialFunctions
x = 2.5
Definition of the Bessel function of the first kind
Bessel functions of the first kind are denoted as , where — the order of the function, and — an argument. They are solutions of the Bessel differential equation.:
These functions are used in mathematics, physics, and engineering to describe vibrations of circular membranes, wave propagation, thermal processes, and many other phenomena.
How does the code work?
- 
Calculation of Bessel functions: 
 The code calculates three Bessel functions of the first kind of different orders:- besselj0(x)calculates the function .
- besselj(1, x)calculates the function .
- besselj(2, x)calculates the function .
 
- 
Conclusions of the results: 
 The calculation results are displayed in the console with an explanation of which function was calculated.
Why is this necessary?
The use of Bessel functions is useful for modeling physical processes related to wave propagation, vibrations of mechanical systems, calculations of electromagnetic fields, and much more. For example, in acoustics they help to analyze the propagation of sound waves inside cylindrical objects, and in optics they help to describe the distribution of light intensity in laser beams.
Thus, the code serves as a clear example of how easy it is to calculate important special functions used in scientific research and engineering calculations.
j0 = besselj0(x)  # J_0(x) - для нулевого порядка
j1 = besselj(1, x) # J_1(x) - для первого порядка
j2 = besselj(2, x) # J_2(x) - для второго порядка
println("Функции Бесселя первого рода:")
println("J_0($x) = ", j0)
println("J_1($x) = ", j1)
println("J_2($x) = ", j2)
Definition of the Bessel function of the second kind
Bessel functions of the second kind, also known as Neumann functions, are denoted as . These are independent solutions of the same Bessel differential equation as functions of the first kind, but they have a singularity at zero (when , the value tends to infinity). The equation looks like this:
They are important where solutions other than regular type solutions are needed. , especially in problems involving boundary conditions admitting singular points.
- 
Calculation of Bessel functions of the second kind:\ The 
 code calculates two Bessel functions of the second kind of different orders:- bessely0(x)calculates the function .
- bessely(1, x)calculates the function .
 
- 
Conclusions of the results: 
 The calculation results are output to the console with an indication of the specific function and its result.
Bessel functions of the second kind are often necessary for a complete analysis of a physical phenomenon when regular solutions are insufficient. For example, in electrical engineering, they allow you to calculate the characteristics of coaxial transmission lines, in mechanics — vibrations of rods and plates of complex shape, and in astronomy — the movement of planets around the Sun.
The code clearly shows how to quickly and conveniently implement calculations of important special functions needed in scientific work and engineering applications.
# Функции Бесселя второго рода (Y_n(x)) - также называемые функциями Неймана
y0 = bessely0(x)  # Y_0(x)
y1 = bessely(1, x) # Y_1(x)
println("\nФункции Бесселя второго рода:")
println("Y_0($x) = ", y0)
println("Y_1($x) = ", y1)
Definition of a spherical Bessel function of the first kind
Spherical Bessel functions are modifications of the usual Bessel functions and are used in solving three-dimensional problems in spherical coordinates. The first spherical Bessel function is denoted as and is related to the usual Bessel function by the following relation:
This relationship allows us to move from standard Bessel functions to special cases that are mainly applicable to describe the radial dependence of waves in three-dimensional spaces.
Calculation of the spherical Bessel function
The code calculates the first spherical Bessel function of order 1 for a given argument using the above transformation formula:
The function is applied here besselj, which computes the standard Bessel function of the order . The result is displayed in the console with an explanation that it is the first spherical Bessel function that has been calculated.
Spherical Bessel functions are widely used in the analysis of wave processes in spherically symmetric systems, such as sound propagation in limited volumes, the study of particle scattering in quantum mechanics, and the study of the properties of atoms and molecules. The presented code fragment provides an effective way to calculate an important physical quantity necessary for the subsequent analysis of complex spatial models.
# Сферические функции Бесселя
sph_j1 = sqrt(π/(2x)) * besselj(1.5, x) # j_1(x)
println("\nСферическая функция Бесселя первого рода:")
println("j_1($x) = ", sph_j1)
Conclusion
In this example, we looked at Engee programs that demonstrate the calculation of various types of Bessel functions.
In addition to the examples provided, the library SpecialFunctions.jl It offers ample opportunities for implementing many other useful operations, including:
- Calculation of the gamma function and beta features .
- Work with orthogonal polynomials such as Legendre polynomials, Hermite polynomials and others.
- The use of elliptic integrals.
- Analysis of statistical distributions (normal, binomial, ** Poisson distribution** and others).
Thus, the presented material represents only a small part of the library's rich functionality, which allows solving a wide variety of scientific and applied tasks.