Question: Euler help please

April 23 2014 c4meleon 15
Maple V
0

Hi, I have a homework to do that I am strugling with:

write a procedure which uses euler's method to solve a given initial value problem.
the imput should be the differential equation and the initial value.
using this programme find y(1) if dy/dx= x^2*y^3 and y(0)=1, and use maple dsolve command to check the solution.

That is what I have managed to do, but somehow it is not working correctelly, can somebody help please?

eul:=proc(f,h,x0,y0,xn)
  local no_points,x_old,x_new,y_old,y_new,i:
  no_points:=round(evalf((xn-x0)/h)):
  x_old:=x0:
  y_old:=y0:
 
  for i from 1 to no_points do
      x_new:=x_old+h:
      y_new:=y_old+evalf(h*f(x_old,y_old)):
      x_old:=x_new:
      y_old:=y_new:
  od:
  y_new:
end:


Thanks

Please Wait...