Numerical Solutions to Harmonic Motion Problems

I wish to discuss the way to set up and solve harmonic motion - both simple harmonic and not - in this section. The process will look just like our previous numerical methods exercises. It will entail:[br]
[list=1][*]Finding all the relevant forces and expressing them mathematically[/*][*]Setting the sum of the forces equal to mass times acceleration[/*][*]Solving for acceleration (v')[/*][*]Giving GeoGebra expressions for r', v' and having it solve them numerically[br][/*][/list]
Simple Harmonic Motion Numerical Solution
There is only one force acting in a system that is simple harmonic. It is a linear restoring force. Therefore, our only force is [math]F_x=-kx.[/math] Therefore we can write [math]-kx=ma,[/math] which gives us [math]a=-kx/m.[/math] [br][br]Within GeoGebra, we need to enter three statements: 1)[code] r_x'(t,r_x,v_x)=v_x[/code], 2) [code]v_x'(t,r_x,v_x)=-k*r_x/m[br][/code], and 3) [code]NSolveODE({r_x',v_x'},0,{1,0},100)[/code]. In the last statement I used an initial position of 1 (assumed meter), zero initial velocity and run the calculation for 100 seconds into the future. Let's see what the solution looks like.
Numerical Solution
Harmonic Motion (non-simple)
If you wish to calculate harmonic motion with a restoring force that is anything but linear, such as [math]F_x=-x^3[/math], the solution will still oscillate, but the position versus time will not lead to a true sinusoidal function. Adding another force that is velocity-dependent can make the motion damped. Try it out in GeoGebra.

Information: Numerical Solutions to Harmonic Motion Problems