{}
run-icon
main.py
def f(x,y): z=y-x return z x0=float(input("Enter the initial value of x = ")) y0=float(input("Enter the initial value of y = ")) h=float(input("Enter the step size h = ")) n=int(input("Enter the number of iterations n = ")) count=1 while (count<=n): k1=f(x0,y0) k2=f(x0+h/2,y0+(h*k1/2)) k3=f(x0+h/2,y0+(h*k2/2)) k4=f(x0+h,y0+h*k3) y1=y0+(h/6)*(k1+2*k2+2*k3+k4) print("The value of k1 =",k1,"k2=",k2,"k3= ",k3,"k4=",k4) print("The new value of y is",y1) x0=x0+h y0=y1 count=count+1
Output