I've got two equations that describe a Geodesic on a sphere. $$ \frac{\mathrm d^2 u}{\mathrm d\lambda^2} - \cos u \sin u \frac{\mathrm dv}{\mathrm d\lambda} \frac{\mathrm dv}{\mathrm d\lambda} = 0 \\ \frac{\mathrm d^2 v}{\mathrm d\lambda^2} - 2\cot u \frac{\mathrm du}{\mathrm d\lambda} \frac{\mathrm dv}{\mathrm d\lambda} = 0 $$

Can Mathematica solve these equations? I'm still pretty new, but this is my attempt so far:

Eq1 = Derivative[2][u] - Cos[u]*Sin[u]*D[v, λ]*D[v, λ] == 0
Eq2 = Derivative[2][v] + 2*Cot[u]*D[u, λ]*D[v, λ] == 0
NDSolve[{Eq1, Eq2}, {u, v}, λ]

But I'm not capturing the second derivative properly:

NDSolve::dvnoarg: The function u^′′ appears with no arguments.

  • 3
    $\begingroup$ u and v need to be specified as u[lambda] and v[lambda] $\endgroup$
    – Bill Watts
    Dec 23, 2019 at 18:05
  • $\begingroup$ @Quarkly: What is represented by $(u,v)?$ Lat/long of a great circle? I plotted it 3D but there is a waviness. $\endgroup$
    – Narasimham
    May 25, 2020 at 18:58
  • $\begingroup$ @Narasimham - Yes, latitude and longitude of a 2D surface embedded in a 3D sphere. $\endgroup$
    – Quark Soup
    May 25, 2020 at 19:06
  • $\begingroup$ @Quarkly Trying to verify the geodesic great circle for you. If not appropriate please feel free so we can roll back.. $\endgroup$
    – Narasimham
    May 26, 2020 at 7:04
  • $\begingroup$ @ Quarky: Remember having seen such in DG text reference by DJ Struik, but have no copy with me now. Also when the sign before Cot[u] in second equation is changed, situation remains the same. $\endgroup$
    – Narasimham
    May 26, 2020 at 8:52

2 Answers 2


There were syntactic and conceptual problems with your formulation.

Conceptually, NDSolve is a numerical solver, so you need to specify boundary conditions as well as a numerical range of integration for the independent variable, which were missing in your formulation.

Syntactically, NDSolve was complaining about the fact that you had not specified the independent variable for the $u$ and $v$ functions each time. A human reader might be able to infer that from context, but a computer system has to have it all spelled out unequivocally.

Here is an example to show you how you might be able to set this up. Note that I have made no attempt to choose reasonable constraints and boundary conditions; I have just chosen numbers that would give a solution, to give you a jump start on the syntax.

Eq1 = Derivative[2][u][λ] - Cos[u[λ]] Sin[u[λ]] D[v[λ], λ] D[v[λ], λ] == 0
Eq2 = Derivative[2][v][λ] + 2 Cot[u[λ]] D[u[λ], λ] D[v[λ], λ] == 0
  {Eq1, Eq2, 
   u[0] == 1000, u'[0] == 5, v'[0] == 5, v[0] == 1000}, 
  {u, v}, {λ, 1, 2}

enter image description here

  • 1
    $\begingroup$ If you think about what Mathematica is doing here, it's mind boggling. $\endgroup$
    – Quark Soup
    Dec 23, 2019 at 19:37

Seems wavy, not like a great circle?

{r[t_], th[t_]} = {u[t], v[t]} /. First[%]
Plot[{r[λ], th[λ]}, {λ, 0, 2 }]
  {r[t] Cos[th[t]], r[t] Sin[th[t]], r[t]}, 
  {t, 0, Pi/2}

enter image description here

Also plotted both possibilities for (lat,long); the great circle is not seen.

Eq1 = Derivative[2][u][λ] - 
    Cos[u[λ]] Sin[u[λ]] D[v[λ], λ] D[v[λ], λ] == 0;
Eq2 = Derivative[2][v][λ] + 
    2 Cot[u[λ]] D[u[λ], λ] D[v[λ], λ] == 0;
  {Eq1, Eq2, u[0] == 10, 
   u'[0] == 5, v'[0] == 5, 
   v[0] == 10},
  {u, v}, {λ, 0, 2}];

{ph[t_], th[t_]} = {u[t], v[t]} /. First[%]
Plot[{r[λ], th[λ]}, {λ, 0, 2}]
g1 = ParametricPlot3D[{Cos[ph[t]] Cos[th[t]], Cos[ph[t]] Sin[th[t]], 
   Sin[ph[t]]}, {t, 0, Pi/2}]
g2 = ParametricPlot3D[{Cos[th[t]] Cos[ph[t]], Cos[th[t]] Sin[ph[t]], 
   Sin[th[t]]}, {t, 0, Pi/2}]
sph = ParametricPlot3D[{Cos[ph] Cos[th], Cos[ph] Sin[th], 
   Sin[ph]}, {ph, -1.5, 1.5}, {th, 0, Pi 2}, PlotStyle -> Opacity[.05]]
Show[{g1, g2, sph}, PlotRange -> All]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.