www.gusucode.com > symbolic 源码程序 matlab案例代码 > symbolic/PlotTheAccuracyOfThePadApproximantExample.m

    %% Plot Accuracy of Pade Approximant
% Plot the difference between |exp(x)| and its Pade 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 Pade
% 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')