' File XVIIISpring2 - -  Spring-Pendulum System

g = 9.801 :  pi = 3.14159
m = 1                                     ' 1 kg mass.
k = 100                                  ' Restoring force in N/m
th = 10 pi / 180                  ' 10 degrees off center.
d = 1                                      ' Length of spring at rest.
xo = -1
zo =d                          ' stretch of spring at 10 degrees due to gravity.

uo = 0                                    ' Set Vx = 0   (theta prime = 0)
wo = 0                                   ' Set Vy = 0.   (r prime = 0)
to = -pi/10  :  tf = pi/10                  ' Set time for pendulum motion.

F{t,x,u,z,w} =  u
G{t,x,u,z,w} = (-g*Sin[x] - 2 * w * u) / (d+z)

H{t,x,u,z,w} =  w
R{t,x,u,z,w} =  (-k*z + m*g*Cos[x] + m*(d+z) *u^2) / m

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



