Professional Documents
Culture Documents
61 Onwards - Prac1
61 Onwards - Prac1
Roll number :
Division : INFT - D5B
Academic Year : 2022-23
Batch : 61 onwards (Q7)
---------------------------------------------------------------------------------------------------------
// User input
x0 = 0.2;
y0 = 1;
h = 0.1;
xn = input("Enter the final value of xn: ");
n = (xn - x0) / h;
mprintf("step=\n");
mprintf("at x=\n");
mprintf("Euler solution y=\n");
mprintf("modified solution =\n");
for i = 1:n
mprintf("Step = %.1f\n", h);
mprintf("At x = %.1f\n", x);
mprintf("Euler solution y = %.5f\n", y);
mprintf("Modified solution = %.5f\n", y);
k1 = f(x, y);
k2 = f(x + h, y + h * k1);
y = y + (h / 2) * (k1 + k2);
x = x + h;
end