April 29, 2009

?O

?Series

?Normal

?LogicalExpand

LogicalExpand[a[0]+a[1]*x+a[2]*x^2 +O[x]^3 ==  x^2+2x+3]

?&&

Series[E^x,{x,0,20}]

Series[Sin[x],{x,0,20}]

Series[Cos[x],{x,0,20}]

Series[ArcTan[x],{x,0,20}]

Series[Log[1+x],{x,0,20}]

Series[Log[1-x],{x,0,20}]

Series[ Integrate[E^t/(1+t^2),{t,0,x}],{x,0,20}]

g[x_] = Series[E^x/(1+x^2),{x,0,20}]

Integrate[ g[t],{t,0,x}]

1.  Find the polynomial approximation f(x) of order 20 to the function y(x) that satisfies 
            y'(x) = y(x)   and   y(0) = 1.

y = 1 + Sum[a[i]*x^i,{i,1,20}] + O[x]^21

eqn = D[y,x]-y == 0

expr=LogicalExpand[eqn]

sol = Solve[expr]

y = y /. sol[[1]]

f[x_] = Normal[y]

Series[f[x] - Exp[x],{x,0,20}]

Plot[f[x],{x,-2,2},
AspectRatio->Automatic]

2.  Find the polynomial approximation g(x) of order 10 to the function y(x) that satisfies 
                    y''(x) + 2y'(x) + y(x) = 0, y(0) = 1, and y'(0) = 0.

y = 1 +0x+Sum[a[i]*x^i,{i,2,10}] + O[x]^11

equation = D[y,{x,2}]+2D[y,x]+y == 0

expression = LogicalExpand[equation];

solution = Solve[expression]

y = y /. solution[[1]]

g[x_] = Normal[y]

Series[g[x] - (x+1)E^(-x)  , {x,0,10}]

The function

{ (x+1)E^(-x) /. x->5, D[(x+1)E^(-x),x] /. x->5 }

3.  Find the polynomial approximation h(x) of order 10 to the function y(x) that satisfies 
                    y''(x) + 2y'(x) + y(x) = 0, y(5) = 6/e^5, and y'(0) = -5/e^5.

?O

y = (6/E^5) +(-5/E^5)(x-5)+Sum[a[i]*(x-5)^i,{i,2,10}] + O[x,5]^11

eqn = D[y,{x,2}]+2D[y,x]+y == 0

expr = LogicalExpand[eqn];

sol= Solve[expr]

y = y /. sol[[1]]

h[x_] = Normal[y]

Series[ h[x] - (x+1)E^(-x) , {x,5,10}]

{h[5], h'[5], h[5.1]}

Note that the function g(x) approximates y(x) = (x+1) Exp(-x) well for x near x = 0 
(and badly near x = 5); whereas, 
h(x) approximates y(x) = (x+1) Exp(-x) well near x = 5 (and badly near x = 0).

Derivative[2][y]

4.  Find the polynomial approximation f(x) of order 10 for the function y(x) that satisfies 
        y''(x) + (1+x) y(x) + (1+x+x^2) y(x)  =  (1 + x + x^2 + x^3) , 
                           y(7) = 1, and y'(7) = 2.   
Also, plot f(x) over the interval 6 ≤ x ≤ 8.

y = 1 + 2(x-7) + Sum[ a[k]*(x-7)^k,{k,2,10} ] +O[x,7]^11

Series[ 1+x,{x,7,10}]

Series[1+x+x^2, {x,7,10}]

Series[ 1+x+x^2+x^3, {x,7,10}]

eqn = D[y,{x,2}]+Series[ 1+x,{x,7,10}]*D[y,x]+Series[1+x+x^2, {x,7,10}]*y == Series[ 1+x+x^2+x^3, {x,7,10}]

expr = LogicalExpand[ eqn ]

sol = Solve[ expr ]

y = y /. sol[[1]]

f[x_] = Normal[y]

Plot[f[x],{x,6,8}]

Clear[y]

sol = NDSolve[ {y''[x] + (1+x)y'[x]+(1+x+x^2)y[x] == 1+x+x^2+x^3, y[7]==2,y'[7]==3},y[x],{x,6,8} ]

y[x_] = y[x] /. sol[[1]]

Plot [ { y[x],f[x]},{x,6,8}]

?NDSolve

5.  Find the polynomial approximation g(x) of order 10 to the function y(x) that satisfies 
                   (x-1) y''(x) + 2x y'(x) + 2 y(x) =0, y(0) = 1, and y'(0) = 1.

y = 1 + x + Sum[a[i]*x^i,{i,2,10}] +O[x,0]^11

eqn = (x-1)D[y,{x,2}]+2x*D[y,x]+2y == 0

expr = LogicalExpand[ eqn]

sol = Solve[expr]

y = y /. sol[[1]]

g[x_] = Normal[y]

Series[ g[x] - 1/(1-x), {x,0,30}]

6.  Find the polynomial approximation h(x) of order 10 to the function y(x) that satisfies 
                   (x^2+1) y''(x) - 6x y'(x) + 12 y(x) =0, y(0) = 2, and y'(0) = 3;
also, plot h(x) over the interval  -2.5 ≤ x ≤ 3.5.

y = 2 + 3x + Sum[a[i]*x^i,{i,2,10}] + O[x,0]^11

eqn = ((x^2+1)*D[y,{x,2}]-6x*D[y,{x,1}] + 12y)== 0

expr = LogicalExpand[ eqn ]

sol = Solve[ expr ]

y = y /. sol[[1]]

h[x_] = Normal[y]

Plot[h[x],{x,-2.5,3.5}]

Check:

(x^2+1)h''[x] - 6x*h'[x] + 12*h[x] // Expand

h[0]

h'[0]