Mathematical Minimum (for Aspiring Physicists)
Numerical Solution for 2nd Order Differential Equations
In general, a 2nd order differential equation involves the independent variable x, the dependent variable y, its 1st derivative dy/dx, and the 2nd derivative d(dy/dx)/dx. Numerical solution requires only simple programming whenever we can isolate the 2nd derivative in the form:
Thus, we can rewrite the original equation as:
In the form of difference equation:
Input parameters include the step size dx, the number of steps max, and and the initial conditions x(0), y(0), z(0).
Numerical integration is carried out by iteration as shown below (in Basic, also see actual example for a cosmological model):
#from the actual expression of the function at x0
if (n-max)=0 then goto Ende
#from the actual expression of the function
print xnn;:print ", ";:print ynn
The numerical solution for 1st order differential equation follows the same idea only simpler (see a Basic Program for the Logistic Equation). Other "home-made" programs such as Base Conversion (between decimal, hexadecimal, and binary), Unit Conversion (fps to SI, SI to fps), Mathematical Functions, and Loan Payment (all in Basic) are available (just clicking the link) to show the subtlety of computer programming.