Skip to main content
added additional material
Source Link
bbgodfrey
  • 63k
  • 18
  • 94
  • 169

A few changes give the desired result.

sol = Flatten@ NDSolve[{θ''[t] == ϕ'[t]^2 Cos[θ[t]] - g/l Sin[θ[t]], ϕ''[t] == (-2 ϕ'[t] θ'[t] Cos[θ[t]])/Sin[θ[t]], θ[0] == π/2, θ'[0] == 0, ϕ[0] == π/2, ϕ'[0] == 1} /. {g -> 9.81, l -> 1}, {θ, ϕ}, {t, 0, 10}] x[t_] := Evaluate[(Sin[θ[t]] Cos[ϕ[t]]) /. sol] y[t_] := Evaluate[(Sin[θ[t]] Sin[ϕ[t]]) /. sol] z[t_] := Evaluate[Cos[θ[t]] /. sol] ParametricPlot3D[{x[t], y[t], z[t]}, {t, 0, 10}] 

enter image description here

By the way, replacing the last four lines by

ParametricPlot3D[{Sin[θ[t]] Cos[ϕ[t]], Sin[θ[t]] Sin[ϕ[t]], Cos[θ[t]]} /. sol, {t, 0, 10}] 

is a bit simpler. Also, there is no need to use SetDelayed to define sys and ic. Use Set instead.

A few changes give the desired result.

sol = Flatten@ NDSolve[{θ''[t] == ϕ'[t]^2 Cos[θ[t]] - g/l Sin[θ[t]], ϕ''[t] == (-2 ϕ'[t] θ'[t] Cos[θ[t]])/Sin[θ[t]], θ[0] == π/2, θ'[0] == 0, ϕ[0] == π/2, ϕ'[0] == 1} /. {g -> 9.81, l -> 1}, {θ, ϕ}, {t, 0, 10}] x[t_] := Evaluate[(Sin[θ[t]] Cos[ϕ[t]]) /. sol] y[t_] := Evaluate[(Sin[θ[t]] Sin[ϕ[t]]) /. sol] z[t_] := Evaluate[Cos[θ[t]] /. sol] ParametricPlot3D[{x[t], y[t], z[t]}, {t, 0, 10}] 

enter image description here

A few changes give the desired result.

sol = Flatten@ NDSolve[{θ''[t] == ϕ'[t]^2 Cos[θ[t]] - g/l Sin[θ[t]], ϕ''[t] == (-2 ϕ'[t] θ'[t] Cos[θ[t]])/Sin[θ[t]], θ[0] == π/2, θ'[0] == 0, ϕ[0] == π/2, ϕ'[0] == 1} /. {g -> 9.81, l -> 1}, {θ, ϕ}, {t, 0, 10}] x[t_] := Evaluate[(Sin[θ[t]] Cos[ϕ[t]]) /. sol] y[t_] := Evaluate[(Sin[θ[t]] Sin[ϕ[t]]) /. sol] z[t_] := Evaluate[Cos[θ[t]] /. sol] ParametricPlot3D[{x[t], y[t], z[t]}, {t, 0, 10}] 

enter image description here

By the way, replacing the last four lines by

ParametricPlot3D[{Sin[θ[t]] Cos[ϕ[t]], Sin[θ[t]] Sin[ϕ[t]], Cos[θ[t]]} /. sol, {t, 0, 10}] 

is a bit simpler. Also, there is no need to use SetDelayed to define sys and ic. Use Set instead.

Source Link
bbgodfrey
  • 63k
  • 18
  • 94
  • 169

A few changes give the desired result.

sol = Flatten@ NDSolve[{θ''[t] == ϕ'[t]^2 Cos[θ[t]] - g/l Sin[θ[t]], ϕ''[t] == (-2 ϕ'[t] θ'[t] Cos[θ[t]])/Sin[θ[t]], θ[0] == π/2, θ'[0] == 0, ϕ[0] == π/2, ϕ'[0] == 1} /. {g -> 9.81, l -> 1}, {θ, ϕ}, {t, 0, 10}] x[t_] := Evaluate[(Sin[θ[t]] Cos[ϕ[t]]) /. sol] y[t_] := Evaluate[(Sin[θ[t]] Sin[ϕ[t]]) /. sol] z[t_] := Evaluate[Cos[θ[t]] /. sol] ParametricPlot3D[{x[t], y[t], z[t]}, {t, 0, 10}] 

enter image description here