[Python in Jupyter Notebook]
Give the code to define a function describing the system of ordinary differential equations above.
Analysis of yet another method for solving ODEs
In case you haven't realized, there are a lot of methods for solving ODEs, with various properties. This homework set asks you to analyze one of them to determine its order of accuracy and stability characteristics.
Here's the method:
In [16]:
def unknownMethod(npts, t):
y = np.zeros(npts)
y[0] = y0
for i in range(npts-1):
h = t[i+1] - t[i]
k1 = f(y[i], t[i])
k2 = f(y[i] + 2.0*h*k1/3.0, t[i] + 2.0*h/3.0)
y[i+1] = y[i] + h*.25*k1 + .75*k2
return y
This method is one of a class of very commonly-used ODE solvers called Runge-Kutta methods.
question 1
Define a function describing the system of ordinary differential equations:
dx/dt = v
dv/dt = k/m
With k/m = 1 s^-2
(i.e. the mass-spring oscillator described in lecture)