You are on page 1of 2

Untitled7.

ipynb Comment Share


File Edit View Insert Runtime Tools Help
+Code + Text Disk Editing

1mport numPy as npP


from matplotlib import pyplotas plt

yo 1
12
22

deltax =(xf-x0)/(n-1)
x =np.linspace (x0,xf,n)
def f(x,Y):
return (2-y**2)/(5*x)
np.2eros([n]D
y[o] =y0
PY np.2eros ([n])
PYI6]=None

for i in range(1,n):
Py[il =deltax*f(x[i-11,y[i-1]) +y[i-1]
ylil =deltax/2*( f(xlil.py[i]) f(x[i-11,y[i-1])) +y[i-1]
print("x_n\t itern\t n")
for i in range(n):
print (x[i], "\t",format (py[il, '6f'),"\t",format (y[il, '6f*))
plt.plot(x,y)
plt.xlabel("value ofx")
Plt.ylabel("value of y")
PLt.title(Approximation Solution with Modified Euler's Method")
Value of y

You might also like