Final answer:
To numerically approximate the solution of the given differential equation using the Euler, Improved Euler, and fourth order Runge Kutta methods, follow the provided steps. Then calculate the exact solution and percent deviation at x = 1, and compare the accuracy of the methods.
Step-by-step explanation:
To numerically approximate the solution of the differential equation dy/dx = x - y + 2, with the initial condition y(0) = 2, on the interval [0,1] using the Euler, Improved Euler, and fourth order Runge Kutta methods, we can follow these steps:
Euler Method:
- Choose a step size h (0.05, 0.1, or 0.25) for the interval [0,1].
- Start with the initial condition y(0) = 2.
- Use the formula: y[i+1] = y[i] + h * (x[i] - y[i] + 2), where x[i] = i * h.
- Repeat step 3 for all values of i in the interval [0,1/h].
Improved Euler Method:
- Choose a step size h (0.05, 0.1, or 0.25) for the interval [0,1].
- Start with the initial condition y(0) = 2.
- Use the formulas:
- k1 = h * (x[i] - y[i] + 2), where x[i] = i * h
- k2 = h * (x[i+1] - (y[i]+k1) + 2), where x[i+1] = (i+1) * h
- y[i+1] = y[i] + 0.5 * (k1 + k2)
- Repeat step 3 for all values of i in the interval [0,1/h].
Fourth Order Runge Kutta Method:
- Choose a step size h (0.05, 0.1, or 0.25) for the interval [0,1].
- Start with the initial condition y(0) = 2.
- Use the formulas:
- k1 = h * (x[i] - y[i] + 2), where x[i] = i * h
- k2 = h * ((x[i] + h/2) - (y[i] + 0.5*k1) + 2)
- k3 = h * ((x[i] + h/2) - (y[i] + 0.5*k2) + 2)
- k4 = h * ((x[i] + h) - (y[i] + k3) + 2)
- y[i+1] = y[i] + (1/6) * (k1 + 2*k2 + 2*k3 + k4)
- Repeat step 3 for all values of i in the interval [0,1/h].
Next, calculate the exact solution to the differential equation and the percent deviation from the exact solution for each case at x = 1. Finally, compare the accuracy of the Euler, Improved Euler, and fourth order Runge Kutta methods.