# limit

Limit of symbolic expression

## Syntax

``limit(f,var,a)``
``limit(f,a)``
``limit(f)``
``limit(f,var,a,"left")``
``limit(f,var,a,"right")``

## Description

````limit(f,var,a)` returns the bidirectional limit of the symbolic expression `f` when `var` approaches `a`.```

example

````limit(f,a)` uses the default variable found by `symvar`.```
````limit(f)` returns the limit at `0`.```
````limit(f,var,a,"left")` returns the left-side limit of `f` as `var` approaches `a`.```

example

````limit(f,var,a,"right")` returns the right-side limit of `f` as `var` approaches `a`.```

example

## Examples

collapse all

Calculate the bidirectional limit of this symbolic expression as `x` approaches `0`.

```syms x h f = sin(x)/x; limit(f,x,0)```
`ans = $1$`

Calculate the limit of this expression as `h` approaches `0`.

```f = (sin(x+h)-sin(x))/h; limit(f,h,0)```
`ans = $\mathrm{cos}\left(x\right)$`

Calculate the right- and left-side limits of symbolic expressions.

```syms x f = 1/x; limit(f,x,0,"right")```
`ans = $\infty$`
`limit(f,x,0,"left")`
`ans = $-\infty$`

Because the limit from the left is not equal to the limit from the right, the two-sided limit does not exist. In this case, `limit` returns `NaN` (Not a Number).

`limit(f,x,0)`
`ans = $\mathrm{NaN}$`

Calculate the limit of expressions in a symbolic vector. `limit` acts element-wise on the vector.

```syms x a V = [(1+a/x)^x exp(-x)]; limit(V,x,Inf)```
`ans = $\left(\begin{array}{cc}{\mathrm{e}}^{a}& 0\end{array}\right)$`

Calculate the right-side limit of ${\mathit{x}}^{\mathit{n}}$ as $\mathit{x}\to {0}^{+}$ for real $n$ and then for positive $n$.

Create the symbolic variables `x` and `n`. When you create symbolic variables, they are assumed to be complex by default. Set the assumption that `n` is real.

```syms x n assume(n,"real")```

Find the limit using this assumption.

`limit(x^n,x,0,"right")`
```ans =  ```

Next, assume that `n` is positive. Find the limit using this assumption.

```assume(n>0) limit(x^n,x,0,"right")```
`ans = $0$`

## Input Arguments

collapse all

Input, specified as a symbolic expression, function, vector, or matrix.

Independent variable, specified as a symbolic variable. If you do not specify `var`, then `symvar` determines the independent variable.

Limit point, specified as a number or a symbolic number, variable, or expression.

collapse all

### Bidirectional Limit

`$L=\underset{x\to a}{\mathrm{lim}}f\left(x\right),x-a\in ℝ\text{\}\left\{0\right\}.$`

### Left-Side Limit

`$L=\underset{x\to {a}^{-}}{\mathrm{lim}}f\left(x\right),x-a<0.$`

### Right-Side Limit

`$L=\underset{x\to {a}^{+}}{\mathrm{lim}}f\left(x\right),x-a>0.$`

## Version History

Introduced before R2006a