dirac

Dirac delta function

Description

example

````dirac(x)` represents the Dirac delta function of `x`.```

example

````dirac(n,x)` represents the `n`th derivative of the Dirac delta function at `x`.```

Examples

Handle Expressions Involving Dirac and Heaviside Functions

Compute derivatives and integrals of expressions involving the Dirac delta and Heaviside functions.

Find the first and second derivatives of the Heaviside function. The result is the Dirac delta function and its first derivative.

```syms x diff(heaviside(x), x) diff(heaviside(x), x, x)```
```ans = dirac(x) ans = dirac(1, x)```

Find the indefinite integral of the Dirac delta function. The integral of the Dirac delta function is the Heaviside function.

`int(dirac(x), x)`
```ans = sign(x)/2```

Find the integral of this expression involving the Dirac delta function.

```syms a int(dirac(x - a)*sin(x), x, -Inf, Inf)```
```ans = sin(a)```

Use Assumptions on Variables

`dirac` takes into account assumptions on variables.

```syms x real assumeAlso(x ~= 0) dirac(x)```
```ans = 0```

For further computations, clear the assumptions.

`syms x clear`

Evaluate Dirac delta Function for Symbolic Matrix

Compute the Dirac delta function of `x` and its first three derivatives.

Use a vector `n = [0, 1, 2, 3]` to specify the order of derivatives. The `dirac` function expands the scalar into a vector of the same size as `n` and computes the result.

```n = [0, 1, 2, 3]; d = dirac(n, x)```
```d = [ dirac(x), dirac(1, x), dirac(2, x), dirac(3, x)]```

Substitute `x` with `0`.

`subs(d, x, 0)`
```ans = [ Inf, -Inf, Inf, -Inf]```

Input Arguments

collapse all

`x` — Inputnumber | symbolic number | symbolic variable | symbolic expression | symbolic function | vector | matrix | multidimensional array

Input, specified as a number, symbolic number, variable, expression, or function, representing a real number. This input can also be a vector, matrix, or multidimensional array of numbers, symbolic numbers, variables, expressions, or functions.

`n` — Order of derivativenonnegative number | symbolic variable | symbolic expression | symbolic function | vector | matrix | multidimensional array

Order of derivative, specified as a nonnegative number, or symbolic variable, expression, or function representing a nonnegative number. This input can also be a vector, matrix, or multidimensional array of nonnegative numbers, symbolic numbers, variables, expressions, or functions.

collapse all

Dirac delta Function

The Dirac delta function, δ(x), has the value 0 for all x ≠ 0, and ∞ for x = 0.

For any smooth function f and a real number a,

$\underset{-\infty }{\overset{\infty }{\int }}dirac\left(x-a\right)\text{ }f\left(x\right)=f\left(a\right)$

Tips

• For complex values `x` with nonzero imaginary parts, `dirac` returns `NaN`.

• `dirac` returns floating-point results for numeric arguments that are not symbolic objects.

• `dirac` acts element-wise on nonscalar inputs.

• 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, then `dirac` expands the scalar into a vector or matrix of the same size as the other argument with all elements equal to that scalar.