MA3520 Struthers Sp2016 Exam 2:  
Name_________________

Show integrals etc. you enter in calculators. 
Explain what you do. No imaginary numbers in answers.  
desolve is not an acceptable technique. Read the instructions.  
Use the back of a page to show additional work.

Solve (dP/dt)=(2/t)P-t                 P(3)=1

DSolve[ {
P'[t]==2/t P[t] - t,
P[3]==1
},
P[t],t]//Expand

Solve ((y^2) (e^(x (y^2)))+cos(x)) dx=-(2 x y (e^(x (y^2)))+(2/(4 (y^2)+1)))dy                y(π/2)=0

({{ Q1     ,    Q2   ,    Q3   ,    Q4   ,    Total   }, {      ,       ,       ,       ,       }})

Clear[x,y,f]
f[x_,y_]:= (E^(x (y^2)))+ Sin[x]+ArcTan[2y]
f[π/2,0]
D[f[x,y],y]//TraditionalForm

Solve y'+ 2 x y=x (e^(-(x^2)))

({{Score/25}, {      }})

y[x]/.DSolve[y'[x]+2 x y[x]==x (E^(- (x^2))),y[x],x][[1]]

Use Euler method to obtain a 4 decimal approximation of y(2.3) for 
	 x y'=-2y+1 with y(2.2)=0.1. 
First use h=0.1 and then h=0.05. The solution of the IVP is
  	 y=0.5 - 1.936 (x^(-2))

({{Score/25}, {      }})

({{   (Subscript[x, n])   ,    (Subscript[y, n])   ,    Actual  Value  ,    Abs Error   ,    %Relative Error   }, {2.20   ,            ,       ,       ,       }, {2.30    ,          ,       ,       ,       }, {      ,       ,       ,       ,       }, {      ,       ,       ,       ,       }})

({{   (Subscript[x, n])   ,    (Subscript[y, n])   ,    Actual  Value  ,    Abs Error   ,    %Relative Error   }, {2.20   ,            ,       ,       ,       }, { 2.25    ,          ,       ,       ,       }, {    ,       ,       ,       ,       }, {      ,       ,       ,       ,       }})

Clear[y,x]
f[x_,y_]:=(1 -2 y)/x
h=0.1;
{x0,y0}={2.2,0.1};
ySol[x_]=Expand[ y[x]/.DSolve[ { y'[x]==f[x,y[x]],y[2.2]==0.1},y[x],x][[1]]]
{x,y}={x0,y0};
TableForm[
Join[ {{x,y,ySol[x0],0.0,0.0}},
Table[
{x,y}={x,y}+h {1, f[x,y]};
{x,y,ySol[x],Abs[y-ySol[x]], 100Abs[y-ySol[x]]/Abs[ySol[x]]},
{1}]
],
TableHeadings->{Automatic,{"(Subscript[x, n])", "(Subscript[y, n])", "Actual Value", "Abs. Error", "%Relative Error"}}
]
h=0.05;
{x,y}={x0,y0};
TableForm[
Join[ {{x,y,ySol[x0],0.0,0.0}},
Table[
{x,y}={x,y}+h {1, f[x,y]};
{x,y,ySol[x],Abs[y-ySol[x]], 100Abs[y-ySol[x]]/Abs[ySol[x]]},
{2}]
],
TableHeadings->{Automatic,{"(Subscript[x, n])", "(Subscript[y, n])", "Actual Value", "Abs. Error", "%Relative Error"}}
]