Average Error: 24.2 → 14.0
Time: 2.0min
Precision: binary64
Cost: 145216
\[R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
\[\begin{array}{l} t_0 := \sin \left(0.5 \cdot \phi_1\right)\\ t_1 := \sin \left(0.5 \cdot \phi_2\right)\\ t_2 := \cos \left(0.5 \cdot \phi_1\right)\\ t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_4 := t_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_3\right)\\ t_5 := \cos \left(0.5 \cdot \phi_2\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(t_5, t_0, t_1 \cdot \left(-t_2\right)\right)\right)}^{2} + t_4}}{\sqrt{1 - \left(t_4 + {\left(t_0 \cdot t_5 - t_1 \cdot t_2\right)}^{2}\right)}}\right) \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (*
  R
  (*
   2.0
   (atan2
    (sqrt
     (+
      (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
      (*
       (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0)))
       (sin (/ (- lambda1 lambda2) 2.0)))))
    (sqrt
     (-
      1.0
      (+
       (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
       (*
        (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0)))
        (sin (/ (- lambda1 lambda2) 2.0))))))))))
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (* 0.5 phi1)))
        (t_1 (sin (* 0.5 phi2)))
        (t_2 (cos (* 0.5 phi1)))
        (t_3 (sin (/ (- lambda1 lambda2) 2.0)))
        (t_4 (* t_3 (* (* (cos phi1) (cos phi2)) t_3)))
        (t_5 (cos (* 0.5 phi2))))
   (*
    R
    (*
     2.0
     (atan2
      (sqrt (+ (pow (fma t_5 t_0 (* t_1 (- t_2))) 2.0) t_4))
      (sqrt (- 1.0 (+ t_4 (pow (- (* t_0 t_5) (* t_1 t_2)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0))) * sin(((lambda1 - lambda2) / 2.0))))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0))) * sin(((lambda1 - lambda2) / 2.0))))))));
}
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin((0.5 * phi1));
	double t_1 = sin((0.5 * phi2));
	double t_2 = cos((0.5 * phi1));
	double t_3 = sin(((lambda1 - lambda2) / 2.0));
	double t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3);
	double t_5 = cos((0.5 * phi2));
	return R * (2.0 * atan2(sqrt((pow(fma(t_5, t_0, (t_1 * -t_2)), 2.0) + t_4)), sqrt((1.0 - (t_4 + pow(((t_0 * t_5) - (t_1 * t_2)), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2)
	return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * sin(Float64(Float64(lambda1 - lambda2) / 2.0))) * sin(Float64(Float64(lambda1 - lambda2) / 2.0))))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * sin(Float64(Float64(lambda1 - lambda2) / 2.0))) * sin(Float64(Float64(lambda1 - lambda2) / 2.0)))))))))
end
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(0.5 * phi1))
	t_1 = sin(Float64(0.5 * phi2))
	t_2 = cos(Float64(0.5 * phi1))
	t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0))
	t_4 = Float64(t_3 * Float64(Float64(cos(phi1) * cos(phi2)) * t_3))
	t_5 = cos(Float64(0.5 * phi2))
	return Float64(R * Float64(2.0 * atan(sqrt(Float64((fma(t_5, t_0, Float64(t_1 * Float64(-t_2))) ^ 2.0) + t_4)), sqrt(Float64(1.0 - Float64(t_4 + (Float64(Float64(t_0 * t_5) - Float64(t_1 * t_2)) ^ 2.0)))))))
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(t$95$5 * t$95$0 + N[(t$95$1 * (-t$95$2)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$4 + N[Power[N[(N[(t$95$0 * t$95$5), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right)
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \phi_1\right)\\
t_1 := \sin \left(0.5 \cdot \phi_2\right)\\
t_2 := \cos \left(0.5 \cdot \phi_1\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_3\right)\\
t_5 := \cos \left(0.5 \cdot \phi_2\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(t_5, t_0, t_1 \cdot \left(-t_2\right)\right)\right)}^{2} + t_4}}{\sqrt{1 - \left(t_4 + {\left(t_0 \cdot t_5 - t_1 \cdot t_2\right)}^{2}\right)}}\right)
\end{array}

Error

Derivation

  1. Initial program 24.2

    \[R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
  2. Applied egg-rr23.7

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\color{blue}{\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
  3. Applied egg-rr14.0

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\color{blue}{\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
  4. Taylor expanded in phi1 around inf 14.0

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\color{blue}{{\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right)\right)}^{2}} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
  5. Simplified14.0

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\color{blue}{{\left(\mathsf{fma}\left(\cos \left(0.5 \cdot \phi_2\right), \sin \left(0.5 \cdot \phi_1\right), \sin \left(0.5 \cdot \phi_2\right) \cdot \left(-\cos \left(0.5 \cdot \phi_1\right)\right)\right)\right)}^{2}} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)}}{\sqrt{1 - \left({\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}\right) \]
    Proof
    (pow.f64 (fma.f64 (cos.f64 (*.f64 1/2 phi2)) (sin.f64 (*.f64 1/2 phi1)) (*.f64 (sin.f64 (*.f64 1/2 phi2)) (neg.f64 (cos.f64 (*.f64 1/2 phi1))))) 2): 0 points increase in error, 0 points decrease in error
    (pow.f64 (fma.f64 (cos.f64 (*.f64 1/2 phi2)) (sin.f64 (*.f64 1/2 phi1)) (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 (sin.f64 (*.f64 1/2 phi2)) (cos.f64 (*.f64 1/2 phi1)))))) 2): 0 points increase in error, 0 points decrease in error
    (pow.f64 (Rewrite<= fma-neg_binary64 (-.f64 (*.f64 (cos.f64 (*.f64 1/2 phi2)) (sin.f64 (*.f64 1/2 phi1))) (*.f64 (sin.f64 (*.f64 1/2 phi2)) (cos.f64 (*.f64 1/2 phi1))))) 2): 8 points increase in error, 6 points decrease in error
    (pow.f64 (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 (sin.f64 (*.f64 1/2 phi1)) (cos.f64 (*.f64 1/2 phi2)))) (*.f64 (sin.f64 (*.f64 1/2 phi2)) (cos.f64 (*.f64 1/2 phi1)))) 2): 0 points increase in error, 0 points decrease in error
  6. Final simplification14.0

    \[\leadsto R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\cos \left(0.5 \cdot \phi_2\right), \sin \left(0.5 \cdot \phi_1\right), \sin \left(0.5 \cdot \phi_2\right) \cdot \left(-\cos \left(0.5 \cdot \phi_1\right)\right)\right)\right)}^{2} + \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)}}{\sqrt{1 - \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) + {\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right)\right)}^{2}\right)}}\right) \]

Alternatives

Alternative 1
Error14.0
Cost138880
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + {\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right)\right)}^{2}\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right) \end{array} \]
Alternative 2
Error21.7
Cost138564
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := \cos \phi_1 \cdot \cos \phi_2\\ t_2 := {\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right)\right)}^{2}\\ t_3 := \sqrt{t_0 \cdot \left(t_1 \cdot t_0\right) + t_2}\\ \mathbf{if}\;\lambda_2 \leq 5.660701856510052 \cdot 10^{-8}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{1 - \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right) + t_2\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{1 - \left(t_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2} + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\right)\\ \end{array} \]
Alternative 3
Error19.9
Cost138564
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := \cos \phi_1 \cdot \cos \phi_2\\ t_2 := {\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right)\right)}^{2}\\ t_3 := t_0 \cdot \left(t_1 \cdot t_0\right) + t_2\\ \mathbf{if}\;\lambda_2 \leq 5.660701856510052 \cdot 10^{-8}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3}}{\sqrt{1 - \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right) + t_2\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - t_3}}\right)\\ \end{array} \]
Alternative 4
Error23.6
Cost112960
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right)\right)}^{2}}}{\sqrt{1 + \left(\left(-0.5 + 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right) - t_1\right)}}\right) \end{array} \]
Alternative 5
Error24.2
Cost93120
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 + \left(\left(-0.5 + 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right) - t_1\right)}}\right) \end{array} \]
Alternative 6
Error28.4
Cost92356
\[\begin{array}{l} t_0 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ \mathbf{if}\;\phi_1 \leq -0.08185144995903733:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_0, \cos \phi_1, {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)}}{\sqrt{{\cos \left(0.5 \cdot \phi_1\right)}^{2} - \cos \phi_1 \cdot t_0}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left({\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)\\ \end{array} \]
Alternative 7
Error28.4
Cost92228
\[\begin{array}{l} t_0 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ \mathbf{if}\;\phi_1 \leq -0.08185144995903733:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_0, \cos \phi_1, {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)}}{\sqrt{{\cos \left(0.5 \cdot \phi_1\right)}^{2} - \cos \phi_1 \cdot t_0}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(0.5 \cdot \phi_2\right)}^{2} - \cos \phi_2 \cdot t_0}}\right)\\ \end{array} \]
Alternative 8
Error36.7
Cost91524
\[\begin{array}{l} t_0 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_2 := \sin \left(0.5 \cdot \phi_1\right)\\ t_3 := \cos \left(0.5 \cdot \phi_1\right)\\ \mathbf{if}\;\phi_1 \leq -2.1306788411190297 \cdot 10^{-6}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_0, \cos \phi_1, {t_2}^{2}\right)}}{\sqrt{{t_3}^{2} - \cos \phi_1 \cdot t_0}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right) + {\left(t_2 \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot t_3\right)}^{2}}}{\sqrt{0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}}\right)\\ \end{array} \]
Alternative 9
Error36.7
Cost86084
\[\begin{array}{l} t_0 := \sin \left(0.5 \cdot \phi_1\right)\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_2 := \cos \left(0.5 \cdot \phi_1\right)\\ \mathbf{if}\;\phi_1 \leq -2.1306788411190297 \cdot 10^{-6}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{t_0}^{2} + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{{t_2}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right) + {\left(t_0 \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot t_2\right)}^{2}}}{\sqrt{0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}}\right)\\ \end{array} \]
Alternative 10
Error36.8
Cost85700
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ \mathbf{if}\;\phi_1 \leq -2.1306788411190297 \cdot 10^{-6}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(0.5 \cdot \phi_1\right)}^{2} + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{{\cos \left(0.5 \cdot \phi_1\right)}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{0.5 + 0.5 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)}}\right)\\ \end{array} \]
Alternative 11
Error37.0
Cost85252
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ \mathbf{if}\;\phi_1 \leq -2.1306788411190297 \cdot 10^{-6}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(0.5 \cdot \phi_1\right)}^{2} + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{{\cos \left(0.5 \cdot \phi_1\right)}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\log \left(1 + \mathsf{expm1}\left(0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right)\\ \end{array} \]
Alternative 12
Error41.5
Cost85188
\[\begin{array}{l} t_0 := \cos \phi_1 \cdot \cos \phi_2\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ \mathbf{if}\;\phi_2 \leq 4.209973433128665 \cdot 10^{-114}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{t_0}, \sin \left(0.5 \cdot \phi_1\right)\right)}{\sqrt{{\cos \left(0.5 \cdot \phi_1\right)}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(t_0 \cdot t_1\right) + {\left(0.5 \cdot \left(\phi_1 \cdot \cos \left(0.5 \cdot \phi_2\right)\right) + \sin \left(\phi_2 \cdot -0.5\right) \cdot \left(1 + \phi_1 \cdot \left(\phi_1 \cdot -0.125\right)\right)\right)}^{2}}}{\sqrt{0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}}\right)\\ \end{array} \]
Alternative 13
Error41.7
Cost79040
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\log \left(1 + \mathsf{expm1}\left(0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right) \end{array} \]
Alternative 14
Error41.7
Cost78912
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{0.5 + 0.5 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right) \end{array} \]
Alternative 15
Error43.7
Cost66116
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\ \mathbf{if}\;\phi_2 \leq 2.7363919694528616 \cdot 10^{-43}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(0.5 \cdot \phi_1\right)}^{2}}}{\sqrt{0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{0.5 + 0.5 \cdot \cos \lambda_2}}\right)\\ \end{array} \]
Alternative 16
Error44.5
Cost66116
\[\begin{array}{l} t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\ t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\\ \mathbf{if}\;\lambda_2 \leq 5.531159080550539 \cdot 10^{-78}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \sin \left(0.5 \cdot \lambda_1\right)}}{\sqrt{0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot t_2 + t_0}}{\sqrt{0.5 + 0.5 \cdot \cos \lambda_2}}\right)\\ \end{array} \]
Alternative 17
Error43.1
Cost66116
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ t_1 := \sqrt{t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\ \mathbf{if}\;\lambda_2 \leq 5.660701856510052 \cdot 10^{-8}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{0.5 + 0.5 \cdot \cos \lambda_1}}\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{0.5 + 0.5 \cdot \cos \lambda_2}}\right)\\ \end{array} \]
Alternative 18
Error41.7
Cost66112
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}}\right) \end{array} \]
Alternative 19
Error44.7
Cost65984
\[\begin{array}{l} t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\ R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + {\sin \left(0.5 \cdot \phi_1\right)}^{2}}}{\sqrt{0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}}\right) \end{array} \]
Alternative 20
Error55.1
Cost65536
\[R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_2}}{\sqrt{{\cos \left(0.5 \cdot \phi_1\right)}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right) \]

Error

Reproduce

herbie shell --seed 2022310 
(FPCore (R lambda1 lambda2 phi1 phi2)
  :name "Distance on a great circle"
  :precision binary64
  (* R (* 2.0 (atan2 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))) (sqrt (- 1.0 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))))))))