## for the RK2 image in the ODE lesson
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0,100)
y = ((x-2)**2)-0.01*x**3
dy_30 = 29*x-(870-514)
dy_55 = 15.25*x-(1145.25-1455)
plt.plot(x,y)
plt.plot(x,dy_30,label=r'Slope at $t$')
plt.plot(x,dy_55,label=r'Slope at $t+\frac{h}{2}$')
plt.scatter(30,514,marker='o',color='black')
plt.scatter(80,964,marker='o',color='black')
#plt.scatter(80,1964,marker='x',color='black')
#plt.scatter(80, 1529.65,marker='x',color='black')
plt.xticks([30,80],[r'$t$',r'$t+h$'])
plt.yticks([])
plt.legend()
<matplotlib.legend.Legend at 0x11672be80>
part 1 - describing 5 different equations using technical language
part 2 - generic vs physical notation for another equation: see Quora "what precisely is a differential equation?" for more examples.
part 3 - Apply Euler's method to one of the problems in part 2 questions. Explore accuracy as the timestep is changed.
part 4 - why is the Lorenz equation not a partial differential equation? Turn another equation into two simultaneous equations.
part 5 - Use timeit function to compare this to the built-in function for Runge Kutta.
Task: Implement Euler and Runge Kutta for two body and three body problem (see previous lab notes). Or should it be the pendulum problem with increasing complexity, then the state space?
Extension: Leapfrog integration scheme
See the 3blue1red (or whatever it is) channel of DE's - looks like some great videos.
problem with the 2-body problem. Are coupled together. Not so simple as just dependent on g.
Should include something on simple harmonic motion? Think about the different levels of approximation: non-linear, then when theta is large. a = -gsin(theta). Then include air resistance: -mu theta.
Differential solutions are really difficult to solve analytically- even something simple like the simple harmonic motion. For damped, there is no way to write a full analytic solution. Indepentent are initial angle and velocity. This can be described fully with these two (acceleration depends on them). See state space (an abstract thing) which is different from physical space the pendulum is in. Plot the spiral inwards and you can see the vector field. Everything moves into -is attracted by - a single value. think about what happens if the pendulum is really fast to begin with - it spins around a few times. What happens when mu is changed? Think also about stability.
Think about state space vs phase space.
Any system can be described by a vector field so it's a vey general approach. 3 body problem - 18 degrees of freedom (3*6)
The romance equations by stiglitz, new york times. The tactics for one case transfer across to other ones.
Simulate what the universe would do but using finite timesteps. there is always a trade off between accuracy and efficiency.
Chaos theory tells us there are limits to how well numerical models can work: small changes to initial conditions has massive changes in results.