Function approximation Copyright © 2004-2012 DigiArea, Inc. . All rights reserved. Description: This worksheet illustrates LdeApprox package capability of doing polynomial approximation of a given function. This method can be used if one knows an LDE which the function satisfies. First of all we load LdeApprox package and define a function to approximate and corresponding LDE. Then we use ApproxSol procedure to find 3-rd degree polynomial approximation for the LDE solution on interval x=[-h,h]. Finally we compare the function and corresponding polynomial approximation using Maple™ procedure plot3d . This loads the package. restart: Examples: Let us try to find polynomial approximation of simple function: fun:=y(x)=exp(-n*x);
It is obvious that the function satisfies the following initial value problem: ivp:={diff(y(x),x)+n*y(x)=0,y(0)=1};
Finding 3-rd degree polynomial approximation of the IVP solution on interval [-h, h]. apr:=ApproxSol(ivp, y(x), x=-h..h,3);
Comparing exact and approximate results for h = 1 and n = 1/4 plot(subs({h=1,n=1/4},subs(fun,y(x))-subs(apr,y(x))),x=-1..1);
Comparing exact and approximate results for h = 1/2 and n = -3..3 using Maple™ function plot3d plot3d(subs({h=1/2},subs(fun,y(x))-subs(apr,y(x))),n=-3..3,x=-1/2..1/2,axes=boxed);
Comparing exact and approximate results for n = 1/2 and h = -2..2 using Maple™ function plot3d . plot3d(subs({n=1/2},subs(fun,y(x))-subs(apr,y(x))),x=-h..h,h=-2..2,axes=boxed);
Not bad for 3-rd degree polynomial approximation, isn't it? |


![[Maple Plot]](Maple/LdeApprox/examples/images/func7.gif)
![[Maple Plot]](Maple/LdeApprox/examples/images/func8.gif)
![[Maple Plot]](Maple/LdeApprox/examples/images/func9.gif)