Scilab Program - eulers formula - IProgramX

Program

  function[]=eu(x0,y0,xn,h,f)
      y(1)=y0;
      j=(xn-x0)/h;
      for i=1:j
          y(i+1)=y(i)+h*f(x0,y(i))
          x0=x0+h;
          printf('\ny(%g)=%g\n',x0,y(i+1));
   
  end
  endfunction

Output:

  deff('y=f(x,y)','y=2+sqrt(x*y)')

  eu(1,1,1.6,0.1,f)

y(1.1)=1.3

y(1.2)=1.61958

y(1.3)=1.95899

y(1.4)=2.31858

y(1.5)=2.69874

y(1.6)=3.09994

Post a Comment

0 Comments