4.11 How to numerically solve a set of non-linear equations?

Numerically solve the following three equations for \(e,a,f\) \begin {align*} eq1 &= r1 - a(e-1) \\ eq2 &= delT - \sqrt {\frac {a^3}{\mu }}(e*\sinh (f)-f) \\ eq3 &= r2 - a(e \cosh (f)-1) \end {align*}

Mathematica

ClearAll[a, e, f] 
delT = 5.215*60*60; 
r1 = 200 + 6378; 
r2 = 130000; 
mu = 3.986*10^5; 
eq1 = r1 - a*(e - 1) == 0; 
eq2 = delT - Sqrt[a^3/mu]* 
     (e*Sinh[f] - f) == 0; 
 
eq3 = r2 - a*(e*Cosh[f]-1)==0; 
sol = NSolve[{eq1, eq2, eq3}, 
           {a, e, f}, Reals]
 

{{a->12029.39633, 
  e->1.546827108, 
  f->2.721303232}}
 

 

Matlab

clear all 
syms a e f; 
delT = 5.215*60*60; 
r1   = 200+6378; 
r2   = 130000; 
mu   = 3.986*10^5; 
eq1  = r1 - a*(e-1); 
eq2  = delT - sqrt(a^3/mu)*(e*sinh(f)-f); 
eq3  = r2 - a*(e*cosh(f)-1); 
sol = feval(symengine,'numeric::solve',... 
          {eq1,eq2,eq3}); 
vpa(sol,6)
 

ans = 
[a == 12029.4, e == 1.54683, f == 2.7213]
 

Another option is solve but slower

sol  = solve(eq1,eq2,eq3,a,e,f);
 

sol = 
    a: [1x1 sym] 
    e: [1x1 sym] 
    f: [1x1 sym] 
 
sol.a 
12029.396328714435126444927089827 
 
sol.e 
1.5468271075497087492979481526009 
 
sol.f 
2.7213032317471583123822097902877