The RK4 method for solving an initial-value problem over an interval [a, b] results in a finite set of points that are supposed to approximate points on the graph of the exact solution. To expand this set of discrete points to an approximate solution defined at all points on the interval [a, b], we can use an interpolating function.
This is a function, supported by most computer algebra systems, that agrees with the given data exactly and assumes a smooth transition between data points. These interpolating functions may be polynomials or sets of polynomials joined together smoothly. In Mathematica the command y[1]Interpolation[data] can be used to obtain an interpolating function through the points data = {{x0, y0}, {x1, y1}, . . . , {xn, yn}}. The interpolating function y[x] can now be treated like any other function built into the computer algebra system.
(a) Find the analytic solution of the initial-value problem y’ = -y + 10 sin 3x; y(0) = 0 on the interval [0, 2]. Graph this solution and find its positive roots.
(b) Use the RK4 method with h = 0.1 to approximate a solution of the initial-value problem in part (a).
Obtain an interpolating function and graph it. Find the positive roots of the interpolating function of the interval [0, 2].