%% Second Order Pade Approximation
% Use padecoef to estimate the value of e^{-2s} to second order.

[a,b] = padecoef(2,2)

% The result indicates that the second order approximation is
% f(s) \approx \frac{a}{b} = \frac{s^2 - 3s+3}{s^2 + 3s + 3}.
%
% Compare the approximation to the actual value at s = 0.25.

f_approx = @(s) (s^2 - 3*s+3)/(s^2 + 3*s + 3);
f_actual = @(s) exp(-2*s);
abs(f_approx(0.25) - f_actual(0.25))

% Copyright 2012 The MathWorks, Inc.