Code covered by the BSD License

### Luigi Sanguigno (view profile)

The Padé approximant often gives better approximation of the function than truncating its Taylor series, and it may still work where the Taylor series does not converge. For these reasons Padé approximants are used extensively in computer calculations.

## Contents

[P,Q]=PADE(F,Xo,N,M) gives the Padé approximant to function F about the point X=Xo, with numerator order N and denominator order M. The function F must accept X and nth as inputs and it must return the value of the nth derivative of F calculated at X. PADE returns two polynomial forms representing respectively the numerator and the denominator of rational approximating form.

## Example 1

```% Define f and its derivatives.
f=@(x,n) cat(2,log(1-x),...
-factorial(n(2:end)-1)./((1-x).^n(2:end)));

% Display the results.
x=linspace(0,1,30);
plot(x,log(1-x),...
x,polyval(p,x)./polyval(q,x),'o');
```

## Example 2

```% Define f and its derivatives.
f=@(x,n) cat(2,exp(-x),exp(-x)*((-1).^n(2:end)));