# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

# `dirac`

The Dirac delta distribution

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```dirac(`x`)
dirac(`x`, `n`)
```

## Description

`dirac(x)` represents the Dirac delta distribution.

`dirac(x, n)` represents the n-th derivative of the delta distribution.

The calls `dirac(x, 0)` and `dirac(x)` are equivalent.

If the argument `x` represents a non-zero number, then 0 is returned. If `x` is a non-real number of domain type `DOM_COMPLEX`, then `undefined` is returned. For all other arguments, a symbolic function call is returned.

`dirac` does not have a predefined value at the origin. Use

`unprotect(dirac): dirac(0) := myValue:`

and

`dirac(float(0)) := myFloatValue: protect(dirac):`

to assign a value (e.g., `infinity`).

For univariate linear expressions, the simplification rule

is implemented for real numerical values `a`.

The integration function `int` treats `dirac` as the usual delta distribution. Cf. Example 3.

## Environment Interactions

`dirac` reacts to properties of identifiers.

## Examples

### Example 1

`dirac` returns 0 for arguments representing non-zero real numbers:

```dirac(-3), dirac(3/2), dirac(2.1, 1), dirac(3*PI), dirac(sqrt(3), 3)```

Arguments of domain type `DOM_COMPLEX` yield `undefined`:

`dirac(1 + I), dirac(2/3 + 7*I), dirac(0.1*I, 1), dirac(ln(-5))`

A symbolic call is returned for other arguments:

`dirac(0), dirac(x), dirac(x + I, 2), dirac(x, n)`

`dirac(2*x - 1, n)`

A natural value for `dirac(0)` is `infinity`:

`unprotect(dirac): dirac(0) := infinity: dirac(0)`

`delete dirac(0): protect(dirac): dirac(0)`

### Example 2

`dirac` reacts to assumptions set by `assume`:

`assume(x < 0): dirac(x)`

`assume(x, Type::Real): assume(x <> 0, _and): dirac(x)`

`unassume(x):`

### Example 3

The symbolic integration function `int` treats `dirac` as the delta distribution:

`int(f(x)*dirac(x - y^2), x = -infinity..infinity)`

```int(int(f(x, y)*dirac(x - y^2), x = -infinity..infinity), y = -1..1)```

The indefinite integral of `dirac` involves the `sign` function:

`int(f(x)*dirac(x), x), int(f(x)*dirac(x, 1), x)`

`int` can handle the distribution only if the argument of `dirac` is linear in the integration variable:

```int(f(x)*dirac(2*x - 3), x = -10..10), int(f(x)*dirac(x^2), x = -10..10)```

Also note that `dirac` should not be used for numerical integration, since the numerical algorithm will typically fail to detect the delta peak:

`numeric::int(dirac(x - 3), x = -10..10)`

## Parameters

 `x` `n` An arithmetical expression representing a nonnegative integer

## Return Values

Arithmetical expression.

`x`

## See Also

### MuPAD Functions

Was this topic helpful?

#### Mathematical Modeling with Symbolic Math Toolbox

Get examples and videos