?

Average Error: 16.7 → 2.7
Time: 1.1min
Precision: binary64
Cost: 143560

?

\[ \begin{array}{c}[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\ \end{array} \]
\[\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R \]
\[\begin{array}{l} t_0 := \cos \phi_1 \cdot \cos \phi_2\\ t_1 := \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \left(\lambda_1 - \lambda_2\right) \cdot t_0\right) \cdot R\\ t_2 := \sin \lambda_1 \cdot \sin \lambda_2\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{-302}:\\ \;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, e^{\mathsf{log1p}\left(t_2\right)} + -1\right)\right)\right)\right)\right)\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;R \cdot \left(\lambda_2 - \lambda_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t_0 \cdot \left(t_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\right)\\ \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (*
  (acos
   (+
    (* (sin phi1) (sin phi2))
    (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
  R))
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* (cos phi1) (cos phi2)))
        (t_1
         (*
          (acos
           (+ (* (sin phi1) (sin phi2)) (* (cos (- lambda1 lambda2)) t_0)))
          R))
        (t_2 (* (sin lambda1) (sin lambda2))))
   (if (<= t_1 -1e-302)
     (*
      R
      (-
       (* PI 0.5)
       (asin
        (fma
         (sin phi1)
         (sin phi2)
         (*
          (cos phi1)
          (*
           (cos phi2)
           (fma (cos lambda2) (cos lambda1) (+ (exp (log1p t_2)) -1.0))))))))
     (if (<= t_1 0.0)
       (* R (- lambda2 lambda1))
       (*
        R
        (acos
         (fma
          (sin phi1)
          (sin phi2)
          (* t_0 (+ t_2 (* (cos lambda2) (cos lambda1)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos(phi1) * cos(phi2);
	double t_1 = acos(((sin(phi1) * sin(phi2)) + (cos((lambda1 - lambda2)) * t_0))) * R;
	double t_2 = sin(lambda1) * sin(lambda2);
	double tmp;
	if (t_1 <= -1e-302) {
		tmp = R * ((((double) M_PI) * 0.5) - asin(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * fma(cos(lambda2), cos(lambda1), (exp(log1p(t_2)) + -1.0)))))));
	} else if (t_1 <= 0.0) {
		tmp = R * (lambda2 - lambda1);
	} else {
		tmp = R * acos(fma(sin(phi1), sin(phi2), (t_0 * (t_2 + (cos(lambda2) * cos(lambda1))))));
	}
	return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2)
	return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R)
end
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = Float64(cos(phi1) * cos(phi2))
	t_1 = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(Float64(lambda1 - lambda2)) * t_0))) * R)
	t_2 = Float64(sin(lambda1) * sin(lambda2))
	tmp = 0.0
	if (t_1 <= -1e-302)
		tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * fma(cos(lambda2), cos(lambda1), Float64(exp(log1p(t_2)) + -1.0))))))));
	elseif (t_1 <= 0.0)
		tmp = Float64(R * Float64(lambda2 - lambda1));
	else
		tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(t_0 * Float64(t_2 + Float64(cos(lambda2) * cos(lambda1)))))));
	end
	return tmp
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-302], N[(R * N[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Exp[N[Log[1 + t$95$2], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(R * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(t$95$0 * N[(t$95$2 + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \left(\lambda_1 - \lambda_2\right) \cdot t_0\right) \cdot R\\
t_2 := \sin \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{-302}:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, e^{\mathsf{log1p}\left(t_2\right)} + -1\right)\right)\right)\right)\right)\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;R \cdot \left(\lambda_2 - \lambda_1\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t_0 \cdot \left(t_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\right)\\


\end{array}

Error?

Derivation?

  1. Split input into 3 regimes
  2. if (*.f64 (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) R) < -9.9999999999999996e-303

    1. Initial program 14.4

      \[\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R \]
    2. Simplified14.4

      \[\leadsto \color{blue}{\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\right) \cdot R} \]
      Proof

      [Start]14.4

      \[ \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R \]

      fma-def [=>]14.4

      \[ \cos^{-1} \color{blue}{\left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)} \cdot R \]

      associate-*l* [=>]14.4

      \[ \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \color{blue}{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\right)\right) \cdot R \]
    3. Applied egg-rr14.4

      \[\leadsto \color{blue}{\left(\pi \cdot 0.5 + \left(-\sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\right)\right)} \cdot R \]
    4. Simplified14.4

      \[\leadsto \color{blue}{\left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right)\right)\right)\right)} \cdot R \]
      Proof

      [Start]14.4

      \[ \left(\pi \cdot 0.5 + \left(-\sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\right)\right) \cdot R \]

      sub-neg [<=]14.4

      \[ \color{blue}{\left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\right)} \cdot R \]

      *-commutative [=>]14.4

      \[ \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \color{blue}{\left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right)}\right)\right)\right) \cdot R \]
    5. Applied egg-rr0.8

      \[\leadsto \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\color{blue}{\left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2\right)\right)\right)\right) \cdot R \]
    6. Simplified0.8

      \[\leadsto \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\color{blue}{\mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2\right)\right)\right)\right) \cdot R \]
      Proof

      [Start]0.8

      \[ \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\right)\right)\right)\right) \cdot R \]

      *-commutative [=>]0.8

      \[ \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\left(\color{blue}{\cos \lambda_2 \cdot \cos \lambda_1} + \sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\right)\right)\right)\right) \cdot R \]

      cos-neg [<=]0.8

      \[ \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\left(\color{blue}{\cos \left(-\lambda_2\right)} \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\right)\right)\right)\right) \cdot R \]

      fma-def [=>]0.8

      \[ \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\color{blue}{\mathsf{fma}\left(\cos \left(-\lambda_2\right), \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2\right)\right)\right)\right) \cdot R \]

      cos-neg [=>]0.8

      \[ \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\mathsf{fma}\left(\color{blue}{\cos \lambda_2}, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\right)\right)\right)\right) \cdot R \]
    7. Applied egg-rr0.8

      \[\leadsto \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \color{blue}{e^{\mathsf{log1p}\left(\sin \lambda_1 \cdot \sin \lambda_2\right)} - 1}\right) \cdot \cos \phi_2\right)\right)\right)\right) \cdot R \]

    if -9.9999999999999996e-303 < (*.f64 (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) R) < -0.0

    1. Initial program 51.9

      \[\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R \]
    2. Simplified51.9

      \[\leadsto \color{blue}{\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\right) \cdot R} \]
      Proof

      [Start]51.9

      \[ \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R \]

      fma-def [=>]51.9

      \[ \cos^{-1} \color{blue}{\left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)} \cdot R \]

      associate-*l* [=>]51.9

      \[ \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \color{blue}{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\right)\right) \cdot R \]
    3. Taylor expanded in phi2 around 0 53.1

      \[\leadsto \cos^{-1} \color{blue}{\left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_1\right)} \cdot R \]
    4. Taylor expanded in phi1 around 0 53.9

      \[\leadsto \cos^{-1} \color{blue}{\cos \left(\lambda_1 - \lambda_2\right)} \cdot R \]
    5. Simplified53.9

      \[\leadsto \cos^{-1} \color{blue}{\cos \left(\lambda_2 - \lambda_1\right)} \cdot R \]
      Proof

      [Start]53.9

      \[ \cos^{-1} \cos \left(\lambda_1 - \lambda_2\right) \cdot R \]

      sub-neg [=>]53.9

      \[ \cos^{-1} \cos \color{blue}{\left(\lambda_1 + \left(-\lambda_2\right)\right)} \cdot R \]

      remove-double-neg [<=]53.9

      \[ \cos^{-1} \cos \left(\color{blue}{\left(-\left(-\lambda_1\right)\right)} + \left(-\lambda_2\right)\right) \cdot R \]

      mul-1-neg [<=]53.9

      \[ \cos^{-1} \cos \left(\left(-\color{blue}{-1 \cdot \lambda_1}\right) + \left(-\lambda_2\right)\right) \cdot R \]

      distribute-neg-in [<=]53.9

      \[ \cos^{-1} \cos \color{blue}{\left(-\left(-1 \cdot \lambda_1 + \lambda_2\right)\right)} \cdot R \]

      cos-neg [=>]53.9

      \[ \cos^{-1} \color{blue}{\cos \left(-1 \cdot \lambda_1 + \lambda_2\right)} \cdot R \]

      +-commutative [=>]53.9

      \[ \cos^{-1} \cos \color{blue}{\left(\lambda_2 + -1 \cdot \lambda_1\right)} \cdot R \]

      mul-1-neg [=>]53.9

      \[ \cos^{-1} \cos \left(\lambda_2 + \color{blue}{\left(-\lambda_1\right)}\right) \cdot R \]

      unsub-neg [=>]53.9

      \[ \cos^{-1} \cos \color{blue}{\left(\lambda_2 - \lambda_1\right)} \cdot R \]
    6. Taylor expanded in lambda2 around 0 29.7

      \[\leadsto \color{blue}{\left(-1 \cdot \lambda_1 + \lambda_2\right)} \cdot R \]
    7. Simplified29.7

      \[\leadsto \color{blue}{\left(\lambda_2 - \lambda_1\right)} \cdot R \]
      Proof

      [Start]29.7

      \[ \left(-1 \cdot \lambda_1 + \lambda_2\right) \cdot R \]

      mul-1-neg [=>]29.7

      \[ \left(\color{blue}{\left(-\lambda_1\right)} + \lambda_2\right) \cdot R \]

      +-commutative [=>]29.7

      \[ \color{blue}{\left(\lambda_2 + \left(-\lambda_1\right)\right)} \cdot R \]

      sub-neg [<=]29.7

      \[ \color{blue}{\left(\lambda_2 - \lambda_1\right)} \cdot R \]

    if -0.0 < (*.f64 (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) R)

    1. Initial program 14.2

      \[\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R \]
    2. Simplified14.2

      \[\leadsto \color{blue}{\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\right) \cdot R} \]
      Proof

      [Start]14.2

      \[ \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R \]

      fma-def [=>]14.2

      \[ \cos^{-1} \color{blue}{\left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)} \cdot R \]

      associate-*l* [=>]14.2

      \[ \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \color{blue}{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\right)\right) \cdot R \]
    3. Applied egg-rr0.8

      \[\leadsto \cos^{-1} \color{blue}{\left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2\right) + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right) + \sin \phi_1 \cdot \sin \phi_2\right)\right)} \cdot R \]
    4. Simplified0.8

      \[\leadsto \cos^{-1} \color{blue}{\left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)} \cdot R \]
      Proof

      [Start]0.8

      \[ \cos^{-1} \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2\right) + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right) + \sin \phi_1 \cdot \sin \phi_2\right)\right) \cdot R \]

      +-commutative [=>]0.8

      \[ \cos^{-1} \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2\right) + \color{blue}{\left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)}\right) \cdot R \]

      *-commutative [<=]0.8

      \[ \cos^{-1} \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2\right) + \left(\sin \phi_1 \cdot \sin \phi_2 + \color{blue}{\left(\sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)}\right)\right) \cdot R \]

      +-commutative [<=]0.8

      \[ \cos^{-1} \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2\right) + \color{blue}{\left(\left(\sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right) + \sin \phi_1 \cdot \sin \phi_2\right)}\right) \cdot R \]

      associate-+r+ [=>]0.8

      \[ \cos^{-1} \color{blue}{\left(\left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2\right) + \left(\sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) + \sin \phi_1 \cdot \sin \phi_2\right)} \cdot R \]

      +-commutative [=>]0.8

      \[ \cos^{-1} \color{blue}{\left(\sin \phi_1 \cdot \sin \phi_2 + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2\right) + \left(\sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)} \cdot R \]

      fma-def [=>]0.8

      \[ \cos^{-1} \color{blue}{\left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2\right) + \left(\sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)} \cdot R \]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) \cdot R \leq -1 \cdot 10^{-302}:\\ \;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, e^{\mathsf{log1p}\left(\sin \lambda_1 \cdot \sin \lambda_2\right)} + -1\right)\right)\right)\right)\right)\\ \mathbf{elif}\;\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) \cdot R \leq 0:\\ \;\;\;\;R \cdot \left(\lambda_2 - \lambda_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\right)\\ \end{array} \]

Alternatives

Alternative 1
Error2.6
Cost143561
\[\begin{array}{l} t_0 := \cos \phi_1 \cdot \cos \phi_2\\ t_1 := \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \left(\lambda_1 - \lambda_2\right) \cdot t_0\right) \cdot R\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{-302} \lor \neg \left(t_1 \leq 0\right):\\ \;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t_0 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\lambda_2 - \lambda_1\right)\\ \end{array} \]
Alternative 2
Error2.7
Cost143560
\[\begin{array}{l} t_0 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\\ t_1 := \cos \phi_1 \cdot \cos \phi_2\\ t_2 := \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \left(\lambda_1 - \lambda_2\right) \cdot t_1\right) \cdot R\\ \mathbf{if}\;t_2 \leq -1 \cdot 10^{-302}:\\ \;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\right)\right)\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;R \cdot \left(\lambda_2 - \lambda_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t_1 \cdot t_0\right)\right)\\ \end{array} \]
Alternative 3
Error2.7
Cost143560
\[\begin{array}{l} t_0 := \cos \phi_1 \cdot \cos \phi_2\\ t_1 := \sin \lambda_1 \cdot \sin \lambda_2\\ t_2 := \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \left(\lambda_1 - \lambda_2\right) \cdot t_0\right) \cdot R\\ \mathbf{if}\;t_2 \leq -1 \cdot 10^{-302}:\\ \;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, t_1\right)\right)\right)\right)\right)\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;R \cdot \left(\lambda_2 - \lambda_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t_0 \cdot \left(t_1 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\right)\\ \end{array} \]
Alternative 4
Error2.6
Cost137289
\[\begin{array}{l} t_0 := \cos \phi_1 \cdot \cos \phi_2\\ t_1 := \sin \phi_1 \cdot \sin \phi_2\\ t_2 := \cos^{-1} \left(t_1 + \cos \left(\lambda_1 - \lambda_2\right) \cdot t_0\right) \cdot R\\ \mathbf{if}\;t_2 \leq -1 \cdot 10^{-302} \lor \neg \left(t_2 \leq 0\right):\\ \;\;\;\;R \cdot \cos^{-1} \left(t_1 + t_0 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\lambda_2 - \lambda_1\right)\\ \end{array} \]
Alternative 5
Error10.7
Cost58696
\[\begin{array}{l} t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_2 \leq -4.4 \cdot 10^{-7}:\\ \;\;\;\;R + R \cdot \left(\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right) + -1\right)\\ \mathbf{elif}\;\phi_2 \leq 5.6 \cdot 10^{-21}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \log \left(e^{\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\right)}\right)\\ \end{array} \]
Alternative 6
Error10.6
Cost58696
\[\begin{array}{l} t_0 := \mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\\ \mathbf{if}\;\phi_1 \leq -7.2 \cdot 10^{-7}:\\ \;\;\;\;R \cdot \left(\pi \cdot 0.5\right) - R \cdot \sin^{-1} t_0\\ \mathbf{elif}\;\phi_1 \leq 2.7 \cdot 10^{-6}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \log \left(e^{\cos^{-1} t_0}\right)\\ \end{array} \]
Alternative 7
Error10.8
Cost58568
\[\begin{array}{l} t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_2 \leq -6 \cdot 10^{-8}:\\ \;\;\;\;R + R \cdot \left(\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right) + -1\right)\\ \mathbf{elif}\;\phi_2 \leq 5.6 \cdot 10^{-21}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot e^{\log \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\right)}\\ \end{array} \]
Alternative 8
Error10.8
Cost58568
\[\begin{array}{l} t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_2 \leq -9.5 \cdot 10^{-8}:\\ \;\;\;\;R + R \cdot \left(\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right) + -1\right)\\ \mathbf{elif}\;\phi_2 \leq 5.6 \cdot 10^{-21}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \log \left(e^{\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\right)}\right)\\ \end{array} \]
Alternative 9
Error10.8
Cost45892
\[\begin{array}{l} t_0 := \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\\ \mathbf{if}\;\phi_2 \leq -3.8 \cdot 10^{-7}:\\ \;\;\;\;R \cdot \left(-1 + \left(1 + t_0\right)\right)\\ \mathbf{elif}\;\phi_2 \leq 5.6 \cdot 10^{-21}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot t_0\\ \end{array} \]
Alternative 10
Error10.8
Cost45892
\[\begin{array}{l} t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_2 \leq -9.5 \cdot 10^{-8}:\\ \;\;\;\;R + R \cdot \left(\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right) + -1\right)\\ \mathbf{elif}\;\phi_2 \leq 5.6 \cdot 10^{-21}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\right)\\ \end{array} \]
Alternative 11
Error10.8
Cost45768
\[\begin{array}{l} t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_2 \leq -1.45 \cdot 10^{-7}:\\ \;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + t_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) \cdot R\\ \mathbf{elif}\;\phi_2 \leq 5.6 \cdot 10^{-21}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\right)\\ \end{array} \]
Alternative 12
Error10.8
Cost45641
\[\begin{array}{l} \mathbf{if}\;\phi_2 \leq -6.8 \cdot 10^{-8} \lor \neg \left(\phi_2 \leq 5.6 \cdot 10^{-21}\right):\\ \;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) \cdot R\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\ \end{array} \]
Alternative 13
Error15.9
Cost39500
\[\begin{array}{l} t_0 := \cos \phi_1 \cdot \cos \phi_2\\ t_1 := R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\ t_2 := \sin \phi_1 \cdot \sin \phi_2\\ \mathbf{if}\;\lambda_1 \leq -1.95 \cdot 10^{+204}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\lambda_1 \leq -0.034:\\ \;\;\;\;R \cdot \cos^{-1} \left(t_2 + \cos \lambda_1 \cdot t_0\right)\\ \mathbf{elif}\;\lambda_1 \leq 6.5 \cdot 10^{-17}:\\ \;\;\;\;R \cdot \cos^{-1} \left(t_2 + \cos \lambda_2 \cdot t_0\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 14
Error10.8
Cost39497
\[\begin{array}{l} \mathbf{if}\;\phi_2 \leq -7.5 \cdot 10^{-8} \lor \neg \left(\phi_2 \leq 5.6 \cdot 10^{-21}\right):\\ \;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) \cdot R\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\ \end{array} \]
Alternative 15
Error28.2
Cost39377
\[\begin{array}{l} t_0 := \sin \phi_1 \cdot \sin \phi_2\\ t_1 := R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_2, \cos \phi_1, t_0\right)\right)\\ \mathbf{if}\;\phi_2 \leq -0.24:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\phi_2 \leq 0.031:\\ \;\;\;\;R \cdot \cos^{-1} \left(t_0 + \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right) \cdot \left(1 + \left(\phi_2 \cdot \phi_2\right) \cdot -0.5\right)\right)\\ \mathbf{elif}\;\phi_2 \leq 2.3 \cdot 10^{+206} \lor \neg \left(\phi_2 \leq 1.08 \cdot 10^{+282}\right):\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 16
Error28.2
Cost39377
\[\begin{array}{l} t_0 := \sin \phi_1 \cdot \sin \phi_2\\ \mathbf{if}\;\phi_2 \leq -0.135:\\ \;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_2, \cos \phi_1, t_0\right)\right)\\ \mathbf{elif}\;\phi_2 \leq 0.04:\\ \;\;\;\;R \cdot \cos^{-1} \left(t_0 + \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right) \cdot \left(1 + \left(\phi_2 \cdot \phi_2\right) \cdot -0.5\right)\right)\\ \mathbf{elif}\;\phi_2 \leq 2.3 \cdot 10^{+206} \lor \neg \left(\phi_2 \leq 1.02 \cdot 10^{+282}\right):\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \cos \phi_2\right)\right)\\ \end{array} \]
Alternative 17
Error22.7
Cost39377
\[\begin{array}{l} \mathbf{if}\;\phi_2 \leq -0.006:\\ \;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_2, \cos \phi_1, \sin \phi_1 \cdot \sin \phi_2\right)\right)\\ \mathbf{elif}\;\phi_2 \leq 3.7 \cdot 10^{+24}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\ \mathbf{elif}\;\phi_2 \leq 2.3 \cdot 10^{+206} \lor \neg \left(\phi_2 \leq 9.2 \cdot 10^{+281}\right):\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \cos \phi_2\right)\right)\\ \end{array} \]
Alternative 18
Error17.1
Cost39369
\[\begin{array}{l} \mathbf{if}\;\phi_2 \leq -6 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 5.6 \cdot 10^{-21}\right):\\ \;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \lambda_1 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\ \end{array} \]
Alternative 19
Error28.2
Cost33480
\[\begin{array}{l} t_0 := \sin \phi_1 \cdot \sin \phi_2\\ t_1 := R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \cos \phi_2\right)\\ \mathbf{if}\;\phi_2 \leq -0.21:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\phi_2 \leq 0.0146:\\ \;\;\;\;R \cdot \cos^{-1} \left(t_0 + \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right) \cdot \left(1 + \left(\phi_2 \cdot \phi_2\right) \cdot -0.5\right)\right)\\ \mathbf{elif}\;\phi_2 \leq 2.3 \cdot 10^{+206} \lor \neg \left(\phi_2 \leq 10^{+282}\right):\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 20
Error28.3
Cost33105
\[\begin{array}{l} t_0 := R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \cos \phi_2\right)\\ t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_2 \leq -0.25:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\phi_2 \leq 1.06 \cdot 10^{-5}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t_1\right)\\ \mathbf{elif}\;\phi_2 \leq 2.3 \cdot 10^{+206} \lor \neg \left(\phi_2 \leq 7.8 \cdot 10^{+281}\right):\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t_1\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 21
Error28.4
Cost33105
\[\begin{array}{l} t_0 := \sin \phi_1 \cdot \sin \phi_2\\ t_1 := R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \cos \phi_2\right)\\ \mathbf{if}\;\phi_2 \leq -0.018:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\phi_2 \leq 1450000:\\ \;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\ \mathbf{elif}\;\phi_2 \leq 2.3 \cdot 10^{+206} \lor \neg \left(\phi_2 \leq 7.8 \cdot 10^{+281}\right):\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 22
Error43.0
Cost19916
\[\begin{array}{l} t_0 := R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\ \mathbf{if}\;\phi_2 \leq -1.65 \cdot 10^{-279}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\phi_2 \leq 1.1 \cdot 10^{-82}:\\ \;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\\ \mathbf{elif}\;\phi_2 \leq 4.5 \cdot 10^{+27}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \cos \phi_2\\ \end{array} \]
Alternative 23
Error40.4
Cost19916
\[\begin{array}{l} t_0 := R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\ \mathbf{if}\;\phi_2 \leq -3.3 \cdot 10^{-263}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\phi_2 \leq 2.6 \cdot 10^{-96}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right)\\ \mathbf{elif}\;\phi_2 \leq 3.7 \cdot 10^{+24}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right)\\ \end{array} \]
Alternative 24
Error33.3
Cost19780
\[\begin{array}{l} \mathbf{if}\;\phi_2 \leq 3.7 \cdot 10^{+24}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right)\\ \end{array} \]
Alternative 25
Error32.0
Cost19780
\[\begin{array}{l} t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_1 \leq -1.35 \cdot 10^{+14}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t_0\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t_0\right)\\ \end{array} \]
Alternative 26
Error36.7
Cost19652
\[\begin{array}{l} \mathbf{if}\;\lambda_1 \leq -0.04:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right)\\ \end{array} \]
Alternative 27
Error50.0
Cost13388
\[\begin{array}{l} \mathbf{if}\;\phi_2 \leq -4 \cdot 10^{-107}:\\ \;\;\;\;R \cdot \cos^{-1} \cos \phi_1\\ \mathbf{elif}\;\phi_2 \leq -2.2 \cdot 10^{-263}:\\ \;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\ \mathbf{elif}\;\phi_2 \leq 5.6 \cdot 10^{-21}:\\ \;\;\;\;R \cdot \cos^{-1} \cos \lambda_2\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \cos \phi_2\\ \end{array} \]
Alternative 28
Error46.1
Cost13256
\[\begin{array}{l} \mathbf{if}\;\lambda_1 \leq -0.00145:\\ \;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\ \mathbf{elif}\;\lambda_1 \leq -1.12 \cdot 10^{-240}:\\ \;\;\;\;R \cdot \cos^{-1} \cos \phi_1\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \cos \lambda_2\\ \end{array} \]
Alternative 29
Error44.6
Cost13252
\[\begin{array}{l} \mathbf{if}\;\phi_2 \leq 2.7 \cdot 10^{-7}:\\ \;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \cos \phi_2\\ \end{array} \]
Alternative 30
Error51.2
Cost13124
\[\begin{array}{l} \mathbf{if}\;\lambda_1 \leq -2.6 \cdot 10^{-6}:\\ \;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\lambda_2 - \lambda_1\right)\\ \end{array} \]
Alternative 31
Error47.1
Cost13124
\[\begin{array}{l} \mathbf{if}\;\lambda_1 \leq -0.034:\\ \;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\ \mathbf{else}:\\ \;\;\;\;R \cdot \cos^{-1} \cos \lambda_2\\ \end{array} \]
Alternative 32
Error58.6
Cost521
\[\begin{array}{l} \mathbf{if}\;\lambda_2 \leq 5.6 \cdot 10^{-115} \lor \neg \left(\lambda_2 \leq 5.4 \cdot 10^{+155}\right):\\ \;\;\;\;\lambda_1 \cdot \left(-R\right)\\ \mathbf{else}:\\ \;\;\;\;\lambda_2 \cdot R\\ \end{array} \]
Alternative 33
Error58.8
Cost320
\[R \cdot \left(\lambda_2 - \lambda_1\right) \]
Alternative 34
Error60.0
Cost192
\[\lambda_2 \cdot R \]

Error

Reproduce?

herbie shell --seed 2023039 
(FPCore (R lambda1 lambda2 phi1 phi2)
  :name "Spherical law of cosines"
  :precision binary64
  (* (acos (+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))) R))