' File XVIIISpring - -  Spring-Pendulum System

g = 9.801 :  pi = 3.14159
d = 1	                             ' Length of one meter.
m = 1                                     ' 1 kg mass.
k = 100                                  ' Restoring force in N/m
th = 10 pi / 180                  ' 10 degrees off center.

xo = d * Cos[th]
zo = d * Sin[th]                      ' yo

uo = 0                                    ' xo'
wo = 1                                   ' yo'

to = 0  :  tf = pi                     ' Set time for pendulum motion.
V{a,b} = Sqrt[a^2 + b^2]

F{t,x,u,z,w} = u
G{t,x,u,z,w} = -k * x * (1 - d / V{x,z}) / m

H{t,x,u,z,w} = w
R{t,x,u,z,w} =  g - k * z * (1 - d / V{x,z}) / m

IVP[F,G,H,R,{to,tf, xo,uo,zo,wo} {1, 0.02, 2}]

' NOTE: Check out the phase plot. The model was derived with the downward motion (y-axis)
'   positive.  Hence, the arc trace will appear upside down for the spring-pendulum motion. To 
'  correct if desired, unlock 2D, flip the y-axis and rotate the x-axis as shown in the WalkThru
'  document.

' Try  tf = 8 and check the phase plane paths. We have here two sets of  motions:
'    the swing of the pendulum itself, and the changing length of the pendulum because
'    we are using a  spring rather than a rigid rod. Check out using k = 10000 value for the 
'    spring constant.


