## Syntax

``pade(f,var)``
``pade(f,var,a)``
``pade(___,Name,Value)``

## Description

example

````pade(f,var)` returns the third-order Padé approximant of the expression `f` at ```var = 0```. For details, see Padé Approximant.If you do not specify `var`, then `pade` uses the default variable determined by `symvar(f,1)`.```

example

````pade(f,var,a)` returns the third-order Padé approximant of expression `f` at the point `var = a`.```

example

````pade(___,Name,Value)` uses additional options specified by one or more `Name,Value` pair arguments. You can specify `Name,Value` after the input arguments in any of the previous syntaxes.```

## Examples

### Find Padé Approximant for Symbolic Expressions

Find the Padé approximant of `sin(x)`. By default, `pade` returns a third-order Padé approximant.

```syms x pade(sin(x))```
```ans = -(x*(7*x^2 - 60))/(3*(x^2 + 20))```

### Specify Expansion Variable

If you do not specify the expansion variable, `symvar` selects it. Find the Padé approximant of `sin(x) + cos(y)`. The `symvar` function chooses `x` as the expansion variable.

```syms x y pade(sin(x) + cos(y))```
```ans = (- 7*x^3 + 3*cos(y)*x^2 + 60*x + 60*cos(y))/(3*(x^2 + 20))```

Specify the expansion variable as `y`. The `pade` function returns the Padé approximant with respect to `y`.

`pade(sin(x) + cos(y),y)`
```ans = (12*sin(x) + y^2*sin(x) - 5*y^2 + 12)/(y^2 + 12)```

### Approximate Value of Function at Particular Point

Find the value of `tan(3*pi/4)`. Use `pade` to find the Padé approximant for `tan(x)` and substitute into it using `subs` to find `tan(3*pi/4)`.

```syms x f = tan(x); P = pade(f); y = subs(P,x,3*pi/4)```
```y = (pi*((9*pi^2)/16 - 15))/(4*((9*pi^2)/8 - 5))```

Use `vpa` to convert `y` into a numeric value.

`vpa(y)`
```ans = -1.2158518789569086447244881326842```

### Increase Accuracy of Padé Approximant

You can increase the accuracy of the Padé approximant by increasing the order. If the expansion point is a pole or a zero, the accuracy can also be increased by setting `OrderMode` to `relative`. The `OrderMode` option has no effect if the expansion point is not a pole or zero.

Find the Padé approximant of `tan(x)` using `pade` with an expansion point of `0` and `Order` of ```[1 1]```. Find the value of `tan(1/5)` by substituting into the Padé approximant using `subs`, and use `vpa` to convert `1/5` into a numeric value.

```syms x p11 = pade(tan(x),x,0,'Order',[1 1]) p11 = subs(p11,x,vpa(1/5)) ```
```p11 = x p11 = 0.2```

Find the approximation error by subtracting `p11` from the actual value of `tan(1/5)`.

```y = tan(vpa(1/5)); error = y - p11```
```error = 0.0027100355086724833213582716475345```

Increase the accuracy of the Padé approximant by increasing the order using `Order`. Set `Order` to ```[2 2]```, and find the error.

```p22 = pade(tan(x),x,0,'Order',[2 2]) p22 = subs(p22,x,vpa(1/5)); error = y - p22```
```p22 = -(3*x)/(x^2 - 3) error = 0.0000073328059697806186555689448317799```

The accuracy increases with increasing order.

If the expansion point is a pole or zero, the accuracy of the Padé approximant decreases. Setting the `OrderMode` option to `relative` compensates for the decreased accuracy. For details, see Padé Approximant. Because the `tan` function has a zero at `0`, setting `OrderMode` to `relative` increases accuracy. This option has no effect if the expansion point is not a pole or zero.

```p22Rel = pade(tan(x),x,0,'Order',[2 2],'OrderMode','relative') p22Rel = subs(p22Rel,x,vpa(1/5)); error = y - p22Rel```
```p22Rel = (x*(x^2 - 15))/(3*(2*x^2 - 5)) error = 0.0000000084084014806113311713765317725998```

The accuracy increases if the expansion point is a pole or zero and `OrderMode` is set to `relative`.

### Plot Accuracy of Padé Approximant

Plot the difference between `exp(x)` and its Padé approximants of orders `[1 1]` through `[4 4]`. Use `axis` to focus on the region of interest. The plot shows that accuracy increases with increasing order of the Padé approximant.

```syms x expr = exp(x); hold on grid on for i = 1:4 fplot(expr - pade(expr,'Order',i)) end axis([-4 4 -4 4]) legend('Order [1,1]','Order [2,2]','Order [3,3]','Order [4,4]',... 'Location','Best') title('Difference Between exp(x) and its Pade Approximant') ylabel('Error')```

## Input Arguments

collapse all

Input to approximate, specified as a symbolic number, variable, vector, matrix, multidimensional array, function, or expression.

Expansion variable, specified as a symbolic variable. If you do not specify `var`, then `pade` uses the default variable determined by `symvar(f,1)`.

Expansion point, specified as a number, or a symbolic number, variable, function, or expression. The expansion point cannot depend on the expansion variable. You also can specify the expansion point as a `Name,Value` pair argument. If you specify the expansion point both ways, then the `Name,Value` pair argument takes precedence.

### Name-Value Pair Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside quotes. You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

Example: `pade(f,'Order',[2 2])` returns the Padé approximant of `f` of order ```m = 2``` and `n = 2`.

Expansion point, specified as a number, or a symbolic number, variable, function, or expression. The expansion point cannot depend on the expansion variable. You can also specify the expansion point using the input argument `a`. If you specify the expansion point both ways, then the `Name,Value` pair argument takes precedence.

Order of the Padé approximant, specified as an integer, a vector of two integers, or a symbolic integer, or vector of two integers. If you specify a single integer, then the integer specifies both the numerator order m and denominator order n producing a Padé approximant with m = n. If you specify a vector of two integers, then the first integer specifies m and the second integer specifies n. By default, `pade` returns a Padé approximant with m = n = 3.

Flag that selects absolute or relative order for Padé approximant, specified as `'absolute'` or `'relative'`. The default value of `'absolute'` uses the standard definition of the Padé approximant. If you set `'OrderMode'` to `'relative'`, it only has an effect when there is a pole or a zero at the expansion point `a`. In this case, to increase accuracy, `pade` multiplies the numerator by ```(var - a)p``` where `p` is the multiplicity of the zero or pole at the expansion point. For details, see Padé Approximant.

collapse all

By default, `pade` approximates the function f(x) using the standard form of the Padé approximant of order [mn] around x = x0 which is

`$\frac{{a}_{0}+{a}_{1}\left(x-{x}_{0}\right)+...+{a}_{m}{\left(x-{x}_{0}\right)}^{m}}{1+{b}_{1}\left(x-{x}_{0}\right)+...+{b}_{n}{\left(x-{x}_{0}\right)}^{n}}.$`

When `OrderMode` is `relative`, and a pole or zero exists at the expansion point x = x0, the `pade` function uses this form of the Padé approximant

`$\frac{{\left(x-{x}_{0}\right)}^{p}\left({a}_{0}+{a}_{1}\left(x-{x}_{0}\right)+...+{a}_{m}{\left(x-{x}_{0}\right)}^{m}\right)}{1+{b}_{1}\left(x-{x}_{0}\right)+...+{b}_{n}{\left(x-{x}_{0}\right)}^{n}}.$`

The parameters p and a0 are given by the leading order term f = a0 (x - x0)p + O((x - x0)p + 1) of the series expansion of f around x = x0. Thus, p is the multiplicity of the pole or zero at x0.

## Tips

• If you use both the third argument `a` and `ExpansionPoint` to specify the expansion point, the value specified via `ExpansionPoint` prevails.

## Algorithms

• The parameters a1,…,bn are chosen such that the series expansion of the Padé approximant coincides with the series expansion of f to the maximal possible order.

• The expansion points ±∞ and ±i∞ are not allowed.

• When `pade` cannot find the Padé approximant, it returns the function call.

• For `pade` to return the Padé approximant, a Taylor or Laurent series expansion of f must exist at the expansion point.