# besselk

Modified Bessel function of the second kind for symbolic expressions

## Syntax

``besselk(nu,z)``

## Description

example

````besselk(nu,z)` returns the modified Bessel function of the second kind, Kν(z).```

## Examples

### Find Modified Bessel Function of Second Kind

Compute the modified Bessel functions of the second kind for these numbers. Because these numbers are not symbolic objects, you get floating-point results.

```[besselk(0, 5), besselk(-1, 2), besselk(1/3, 7/4),... besselk(1, 3/2 + 2*i)]```
```ans = 0.0037 + 0.0000i 0.1399 + 0.0000i 0.1594 + 0.0000i -0.1620 - 0.1066i```

Compute the modified Bessel functions of the second kind for the numbers converted to symbolic objects. For most symbolic (exact) numbers, `besselk` returns unresolved symbolic calls.

```[besselk(sym(0), 5), besselk(sym(-1), 2),... besselk(1/3, sym(7/4)), besselk(sym(1), 3/2 + 2*i)]```
```ans = [ besselk(0, 5), besselk(1, 2), besselk(1/3, 7/4), besselk(1, 3/2 + 2i)]```

For symbolic variables and expressions, `besselk` also returns unresolved symbolic calls:

```syms x y [besselk(x, y), besselk(1, x^2), besselk(2, x - y), besselk(x^2, x*y)]```
```ans = [ besselk(x, y), besselk(1, x^2), besselk(2, x - y), besselk(x^2, x*y)]```

### Special Values of Modified Bessel Function of Second Kind

If the first parameter is an odd integer multiplied by 1/2, `besselk` rewrites the Bessel functions in terms of elementary functions:

```syms x besselk(1/2, x)```
```ans = (2^(1/2)*pi^(1/2)*exp(-x))/(2*x^(1/2))```
`besselk(-1/2, x)`
```ans = (2^(1/2)*pi^(1/2)*exp(-x))/(2*x^(1/2))```
`besselk(-3/2, x)`
```ans = (2^(1/2)*pi^(1/2)*exp(-x)*(1/x + 1))/(2*x^(1/2))```
`besselk(5/2, x)`
```ans = (2^(1/2)*pi^(1/2)*exp(-x)*(3/x + 3/x^2 + 1))/(2*x^(1/2))```

### Solve Bessel Differential Equation for Bessel Functions

Solve this second-order differential equation. The solutions are the modified Bessel functions of the first and the second kind.

```syms nu w(z) dsolve(z^2*diff(w, 2) + z*diff(w) -(z^2 + nu^2)*w == 0)```
```ans = C2*besseli(nu, z) + C3*besselk(nu, z)```

Verify that the modified Bessel function of the second kind is a valid solution of the modified Bessel differential equation:

```syms nu z isAlways(z^2*diff(besselk(nu, z), z, 2) + z*diff(besselk(nu, z), z)... - (z^2 + nu^2)*besselk(nu, z) == 0)```
```ans = logical 1```

### Differentiate Modified Bessel Function of Second Kind

Differentiate the expressions involving the modified Bessel functions of the second kind:

```syms x y diff(besselk(1, x)) diff(diff(besselk(0, x^2 + x*y -y^2), x), y)```
```ans = - besselk(1, x)/x - besselk(0, x) ans = (2*x + y)*(besselk(0, x^2 + x*y - y^2)*(x - 2*y) +... (besselk(1, x^2 + x*y - y^2)*(x - 2*y))/(x^2 + x*y - y^2)) -... besselk(1, x^2 + x*y - y^2) ```

### Find Bessel Function for Matrix Input

Call `besselk` for the matrix `A` and the value 1/2. The result is a matrix of the modified Bessel functions ```besselk(1/2, A(i,j))```.

```syms x A = [-1, pi; x, 0]; besselk(1/2, A)```
```ans = [ -(2^(1/2)*pi^(1/2)*exp(1)*1i)/2, (2^(1/2)*exp(-pi))/2] [ (2^(1/2)*pi^(1/2)*exp(-x))/(2*x^(1/2)), Inf]```

### Plot Modified Bessel Functions of Second Kind

Plot the modified Bessel functions of the second kind for $v=0,1,2,3$.

```syms x y fplot(besselk(0:3, x)) axis([0 4 0 4]) grid on ylabel('K_v(x)') legend('K_0','K_1','K_2','K_3', 'Location','Best') title('Modified Bessel functions of the second kind')``` ## Input Arguments

collapse all

Input, specified as a number, vector, matrix, array, or a symbolic number, variable, expression, function, or array. If `nu` is a vector or matrix, `besseli` returns the modified Bessel function of the first kind for each element of `nu`.

Input, specified as a number, vector, matrix, array, or a symbolic number, variable, expression, function, or array. If `nu` is a vector or matrix, `besseli` returns the modified Bessel function of the first kind for each element of `nu`.

collapse all

### Modified Bessel Functions of the Second Kind

The modified Bessel differential equation

`${z}^{2}\frac{{d}^{2}w}{d{z}^{2}}+z\frac{dw}{dz}-\left({z}^{2}+{\nu }^{2}\right)w=0$`

has two linearly independent solutions. These solutions are represented by the modified Bessel functions of the first kind, Iν(z), and the modified Bessel functions of the second kind, Kν(z):

`$w\left(z\right)={C}_{1}{I}_{\nu }\left(z\right)+{C}_{2}{K}_{\nu }\left(z\right)$`

The modified Bessel functions of the second kind are defined via the modified Bessel functions of the first kind:

`${K}_{\nu }\left(z\right)=\frac{\pi /2}{\mathrm{sin}\left(\nu \pi \right)}\left({I}_{-\nu }\left(z\right)-{I}_{\nu }\left(z\right)\right)$`

Here Iν(z) are the modified Bessel functions of the first kind:

`${I}_{\nu }\left(z\right)=\frac{{\left(z/2\right)}^{\nu }}{\sqrt{\pi }\Gamma \left(\nu +1/2\right)}\underset{0}{\overset{\pi }{\int }}{e}^{z\mathrm{cos}\left(t\right)}\mathrm{sin}{\left(t\right)}^{2\nu }dt$`

## Tips

• Calling `besselk` for a number that is not a symbolic object invokes the MATLAB® `besselk` function.

• At least one input argument must be a scalar or both arguments must be vectors or matrices of the same size. If one input argument is a scalar and the other one is a vector or a matrix, `besselk(nu,z)` expands the scalar into a vector or matrix of the same size as the other argument with all elements equal to that scalar.

 Olver, F. W. J. “Bessel Functions of Integer Order.” Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. (M. Abramowitz and I. A. Stegun, eds.). New York: Dover, 1972.

 Antosiewicz, H. A. “Bessel Functions of Fractional Order.” Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. (M. Abramowitz and I. A. Stegun, eds.). New York: Dover, 1972.

## Support

#### Mathematical Modeling with Symbolic Math Toolbox

Get examples and videos