?

Average Error: 39.1 → 0.5
Time: 21.1s
Precision: binary64
Cost: 40964

?

\[ \begin{array}{c}[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\ \end{array} \]
\[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
\[\begin{array}{l} t_0 := \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\\ t_1 := \cos \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\\ \mathbf{if}\;\lambda_2 \leq 5 \cdot 10^{+76}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\frac{\lambda_2 + \lambda_1}{\frac{\lambda_2}{t_0} + \frac{\lambda_1}{t_1}} \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \frac{\lambda_2 + \lambda_1}{\frac{\lambda_2}{t_1} + \frac{\lambda_1}{t_0}}, \phi_1 - \phi_2\right)\\ \end{array} \]
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (*
  R
  (sqrt
   (+
    (*
     (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0)))
     (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0))))
    (* (- phi1 phi2) (- phi1 phi2))))))
(FPCore (R lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (cos (* 0.5 (+ phi1 phi2))))
        (t_1
         (-
          (* (cos (* 0.5 phi2)) (cos (* 0.5 phi1)))
          (* (sin (* 0.5 phi2)) (sin (* 0.5 phi1))))))
   (if (<= lambda2 5e+76)
     (*
      R
      (hypot
       (*
        (/ (+ lambda2 lambda1) (+ (/ lambda2 t_0) (/ lambda1 t_1)))
        (- lambda1 lambda2))
       (- phi1 phi2)))
     (*
      R
      (hypot
       (*
        (- lambda1 lambda2)
        (/ (+ lambda2 lambda1) (+ (/ lambda2 t_1) (/ lambda1 t_0))))
       (- phi1 phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * sqrt(((((lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0))) * ((lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0)))) + ((phi1 - phi2) * (phi1 - phi2))));
}
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos((0.5 * (phi1 + phi2)));
	double t_1 = (cos((0.5 * phi2)) * cos((0.5 * phi1))) - (sin((0.5 * phi2)) * sin((0.5 * phi1)));
	double tmp;
	if (lambda2 <= 5e+76) {
		tmp = R * hypot((((lambda2 + lambda1) / ((lambda2 / t_0) + (lambda1 / t_1))) * (lambda1 - lambda2)), (phi1 - phi2));
	} else {
		tmp = R * hypot(((lambda1 - lambda2) * ((lambda2 + lambda1) / ((lambda2 / t_1) + (lambda1 / t_0)))), (phi1 - phi2));
	}
	return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	return R * Math.sqrt(((((lambda1 - lambda2) * Math.cos(((phi1 + phi2) / 2.0))) * ((lambda1 - lambda2) * Math.cos(((phi1 + phi2) / 2.0)))) + ((phi1 - phi2) * (phi1 - phi2))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.cos((0.5 * (phi1 + phi2)));
	double t_1 = (Math.cos((0.5 * phi2)) * Math.cos((0.5 * phi1))) - (Math.sin((0.5 * phi2)) * Math.sin((0.5 * phi1)));
	double tmp;
	if (lambda2 <= 5e+76) {
		tmp = R * Math.hypot((((lambda2 + lambda1) / ((lambda2 / t_0) + (lambda1 / t_1))) * (lambda1 - lambda2)), (phi1 - phi2));
	} else {
		tmp = R * Math.hypot(((lambda1 - lambda2) * ((lambda2 + lambda1) / ((lambda2 / t_1) + (lambda1 / t_0)))), (phi1 - phi2));
	}
	return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
	return R * math.sqrt(((((lambda1 - lambda2) * math.cos(((phi1 + phi2) / 2.0))) * ((lambda1 - lambda2) * math.cos(((phi1 + phi2) / 2.0)))) + ((phi1 - phi2) * (phi1 - phi2))))
def code(R, lambda1, lambda2, phi1, phi2):
	t_0 = math.cos((0.5 * (phi1 + phi2)))
	t_1 = (math.cos((0.5 * phi2)) * math.cos((0.5 * phi1))) - (math.sin((0.5 * phi2)) * math.sin((0.5 * phi1)))
	tmp = 0
	if lambda2 <= 5e+76:
		tmp = R * math.hypot((((lambda2 + lambda1) / ((lambda2 / t_0) + (lambda1 / t_1))) * (lambda1 - lambda2)), (phi1 - phi2))
	else:
		tmp = R * math.hypot(((lambda1 - lambda2) * ((lambda2 + lambda1) / ((lambda2 / t_1) + (lambda1 / t_0)))), (phi1 - phi2))
	return tmp
function code(R, lambda1, lambda2, phi1, phi2)
	return Float64(R * sqrt(Float64(Float64(Float64(Float64(lambda1 - lambda2) * cos(Float64(Float64(phi1 + phi2) / 2.0))) * Float64(Float64(lambda1 - lambda2) * cos(Float64(Float64(phi1 + phi2) / 2.0)))) + Float64(Float64(phi1 - phi2) * Float64(phi1 - phi2)))))
end
function code(R, lambda1, lambda2, phi1, phi2)
	t_0 = cos(Float64(0.5 * Float64(phi1 + phi2)))
	t_1 = Float64(Float64(cos(Float64(0.5 * phi2)) * cos(Float64(0.5 * phi1))) - Float64(sin(Float64(0.5 * phi2)) * sin(Float64(0.5 * phi1))))
	tmp = 0.0
	if (lambda2 <= 5e+76)
		tmp = Float64(R * hypot(Float64(Float64(Float64(lambda2 + lambda1) / Float64(Float64(lambda2 / t_0) + Float64(lambda1 / t_1))) * Float64(lambda1 - lambda2)), Float64(phi1 - phi2)));
	else
		tmp = Float64(R * hypot(Float64(Float64(lambda1 - lambda2) * Float64(Float64(lambda2 + lambda1) / Float64(Float64(lambda2 / t_1) + Float64(lambda1 / t_0)))), Float64(phi1 - phi2)));
	end
	return tmp
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
	tmp = R * sqrt(((((lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0))) * ((lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0)))) + ((phi1 - phi2) * (phi1 - phi2))));
end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
	t_0 = cos((0.5 * (phi1 + phi2)));
	t_1 = (cos((0.5 * phi2)) * cos((0.5 * phi1))) - (sin((0.5 * phi2)) * sin((0.5 * phi1)));
	tmp = 0.0;
	if (lambda2 <= 5e+76)
		tmp = R * hypot((((lambda2 + lambda1) / ((lambda2 / t_0) + (lambda1 / t_1))) * (lambda1 - lambda2)), (phi1 - phi2));
	else
		tmp = R * hypot(((lambda1 - lambda2) * ((lambda2 + lambda1) / ((lambda2 / t_1) + (lambda1 / t_0)))), (phi1 - phi2));
	end
	tmp_2 = tmp;
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[Sqrt[N[(N[(N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(N[(phi1 + phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(N[(phi1 + phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(phi1 - phi2), $MachinePrecision] * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(0.5 * N[(phi1 + phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 5e+76], N[(R * N[Sqrt[N[(N[(N[(lambda2 + lambda1), $MachinePrecision] / N[(N[(lambda2 / t$95$0), $MachinePrecision] + N[(lambda1 / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[(N[(lambda2 + lambda1), $MachinePrecision] / N[(N[(lambda2 / t$95$1), $MachinePrecision] + N[(lambda1 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2 + N[(phi1 - phi2), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]]]]
R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\\
t_1 := \cos \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right)\\
\mathbf{if}\;\lambda_2 \leq 5 \cdot 10^{+76}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\frac{\lambda_2 + \lambda_1}{\frac{\lambda_2}{t_0} + \frac{\lambda_1}{t_1}} \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right)\\

\mathbf{else}:\\
\;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \frac{\lambda_2 + \lambda_1}{\frac{\lambda_2}{t_1} + \frac{\lambda_1}{t_0}}, \phi_1 - \phi_2\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if lambda2 < 4.99999999999999991e76

    1. Initial program 32.6

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Simplified2.4

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
      Proof

      [Start]32.6

      \[ R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]

      hypot-def [=>]2.4

      \[ R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Applied egg-rr15.4

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\frac{\left(\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2\right) \cdot \cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}{\lambda_1 + \lambda_2}}, \phi_1 - \phi_2\right) \]
    4. Applied egg-rr2.4

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\frac{\lambda_1 + \lambda_2}{\frac{\lambda_1 + \lambda_2}{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}} \cdot \left(\lambda_1 - \lambda_2\right)}, \phi_1 - \phi_2\right) \]
    5. Taylor expanded in lambda1 around 0 2.4

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\lambda_1 + \lambda_2}{\color{blue}{\frac{\lambda_2}{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)} + \frac{\lambda_1}{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}}} \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right) \]
    6. Applied egg-rr0.2

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\lambda_1 + \lambda_2}{\frac{\lambda_2}{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)} + \frac{\lambda_1}{\color{blue}{\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)}}} \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right) \]
    7. Simplified0.2

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

      [Start]0.2

      \[ R \cdot \mathsf{hypot}\left(\frac{\lambda_1 + \lambda_2}{\frac{\lambda_2}{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)} + \frac{\lambda_1}{\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)}} \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right) \]

      *-commutative [=>]0.2

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

      *-commutative [=>]0.2

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

    if 4.99999999999999991e76 < lambda2

    1. Initial program 53.7

      \[R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]
    2. Simplified6.6

      \[\leadsto \color{blue}{R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
      Proof

      [Start]53.7

      \[ R \cdot \sqrt{\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\right) + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)} \]

      hypot-def [=>]6.6

      \[ R \cdot \color{blue}{\mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right)} \]
    3. Applied egg-rr47.0

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\frac{\left(\lambda_1 \cdot \lambda_1 - \lambda_2 \cdot \lambda_2\right) \cdot \cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}{\lambda_1 + \lambda_2}}, \phi_1 - \phi_2\right) \]
    4. Applied egg-rr6.7

      \[\leadsto R \cdot \mathsf{hypot}\left(\color{blue}{\frac{\lambda_1 + \lambda_2}{\frac{\lambda_1 + \lambda_2}{\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)}} \cdot \left(\lambda_1 - \lambda_2\right)}, \phi_1 - \phi_2\right) \]
    5. Taylor expanded in lambda1 around 0 6.7

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\lambda_1 + \lambda_2}{\color{blue}{\frac{\lambda_2}{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)} + \frac{\lambda_1}{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}}} \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right) \]
    6. Applied egg-rr1.3

      \[\leadsto R \cdot \mathsf{hypot}\left(\frac{\lambda_1 + \lambda_2}{\frac{\lambda_2}{\color{blue}{\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)}} + \frac{\lambda_1}{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}} \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right) \]
    7. Simplified1.3

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

      [Start]1.3

      \[ R \cdot \mathsf{hypot}\left(\frac{\lambda_1 + \lambda_2}{\frac{\lambda_2}{\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)} + \frac{\lambda_1}{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}} \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right) \]

      *-commutative [=>]1.3

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

      *-commutative [=>]1.3

      \[ R \cdot \mathsf{hypot}\left(\frac{\lambda_1 + \lambda_2}{\frac{\lambda_2}{\cos \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right) - \color{blue}{\sin \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right)}} + \frac{\lambda_1}{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}} \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;\lambda_2 \leq 5 \cdot 10^{+76}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\frac{\lambda_2 + \lambda_1}{\frac{\lambda_2}{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)} + \frac{\lambda_1}{\cos \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right)}} \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \frac{\lambda_2 + \lambda_1}{\frac{\lambda_2}{\cos \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right)} + \frac{\lambda_1}{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)}}, \phi_1 - \phi_2\right)\\ \end{array} \]

Alternatives

Alternative 1
Error2.0
Cost40832
\[R \cdot \mathsf{hypot}\left(\frac{\lambda_2 + \lambda_1}{\frac{\lambda_2}{\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)} + \frac{\lambda_1}{\cos \left(0.5 \cdot \phi_2\right) \cdot \cos \left(0.5 \cdot \phi_1\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right)}} \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right) \]
Alternative 2
Error12.9
Cost13768
\[\begin{array}{l} \mathbf{if}\;\lambda_2 \leq -1.75 \cdot 10^{+128}:\\ \;\;\;\;R \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right)\\ \mathbf{elif}\;\lambda_2 \leq 1.38 \cdot 10^{+175}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_1 - \lambda_2, \phi_1 - \phi_2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\lambda_2 \cdot R\right) \cdot \sqrt{0.5 + 0.5 \cdot \cos \left(\phi_1 + \phi_2\right)}\\ \end{array} \]
Alternative 3
Error6.4
Cost13700
\[\begin{array}{l} \mathbf{if}\;\phi_1 \leq -360:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right)\\ \end{array} \]
Alternative 4
Error3.7
Cost13696
\[R \cdot \mathsf{hypot}\left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right), \phi_1 - \phi_2\right) \]
Alternative 5
Error9.0
Cost13568
\[R \cdot \mathsf{hypot}\left(\cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 - \lambda_2\right), \phi_1 - \phi_2\right) \]
Alternative 6
Error15.6
Cost7236
\[\begin{array}{l} \mathbf{if}\;\lambda_1 \leq -6.1 \cdot 10^{+240}:\\ \;\;\;\;R \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_1 - \lambda_2, \phi_1 - \phi_2\right)\\ \end{array} \]
Alternative 7
Error41.8
Cost7112
\[\begin{array}{l} \mathbf{if}\;\lambda_2 \leq -2.35 \cdot 10^{-113}:\\ \;\;\;\;R \cdot \left(-\lambda_1\right)\\ \mathbf{elif}\;\lambda_2 \leq 6.4 \cdot 10^{+142}:\\ \;\;\;\;R \cdot \phi_2 - R \cdot \phi_1\\ \mathbf{else}:\\ \;\;\;\;\lambda_2 \cdot \left(R \cdot \cos \left(0.5 \cdot \phi_1\right)\right)\\ \end{array} \]
Alternative 8
Error41.6
Cost7112
\[\begin{array}{l} \mathbf{if}\;\lambda_2 \leq -2.35 \cdot 10^{-113}:\\ \;\;\;\;R \cdot \left(-\lambda_1\right)\\ \mathbf{elif}\;\lambda_2 \leq 2.3 \cdot 10^{+129}:\\ \;\;\;\;R \cdot \phi_2 - R \cdot \phi_1\\ \mathbf{else}:\\ \;\;\;\;\lambda_2 \cdot \left(R \cdot \cos \left(0.5 \cdot \phi_2\right)\right)\\ \end{array} \]
Alternative 9
Error41.6
Cost7112
\[\begin{array}{l} \mathbf{if}\;\lambda_2 \leq -2.35 \cdot 10^{-113}:\\ \;\;\;\;R \cdot \left(-\lambda_1\right)\\ \mathbf{elif}\;\lambda_2 \leq 6.6 \cdot 10^{+129}:\\ \;\;\;\;R \cdot \phi_2 - R \cdot \phi_1\\ \mathbf{else}:\\ \;\;\;\;\cos \left(0.5 \cdot \phi_2\right) \cdot \left(\lambda_2 \cdot R\right)\\ \end{array} \]
Alternative 10
Error15.6
Cost7108
\[\begin{array}{l} \mathbf{if}\;\lambda_1 \leq -5.1 \cdot 10^{+241}:\\ \;\;\;\;\lambda_1 \cdot \left(R \cdot \cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_1 - \lambda_2, \phi_1 - \phi_2\right)\\ \end{array} \]
Alternative 11
Error15.6
Cost7108
\[\begin{array}{l} \mathbf{if}\;\lambda_1 \leq -2.1 \cdot 10^{+241}:\\ \;\;\;\;\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right) \cdot \left(R \cdot \lambda_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \mathsf{hypot}\left(\lambda_1 - \lambda_2, \phi_1 - \phi_2\right)\\ \end{array} \]
Alternative 12
Error14.2
Cost6912
\[R \cdot \mathsf{hypot}\left(\lambda_1 - \lambda_2, \phi_1 - \phi_2\right) \]
Alternative 13
Error47.0
Cost652
\[\begin{array}{l} \mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-32}:\\ \;\;\;\;R \cdot \left(-\phi_1\right)\\ \mathbf{elif}\;\phi_1 \leq -3.6 \cdot 10^{-175}:\\ \;\;\;\;R \cdot \phi_2\\ \mathbf{elif}\;\phi_1 \leq 1.4 \cdot 10^{-228}:\\ \;\;\;\;R \cdot \left(-\lambda_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \]
Alternative 14
Error43.1
Cost580
\[\begin{array}{l} \mathbf{if}\;\lambda_1 \leq -3.4 \cdot 10^{+136}:\\ \;\;\;\;R \cdot \left(-\lambda_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2 - R \cdot \phi_1\\ \end{array} \]
Alternative 15
Error43.0
Cost452
\[\begin{array}{l} \mathbf{if}\;\lambda_1 \leq -2.3 \cdot 10^{+136}:\\ \;\;\;\;R \cdot \left(-\lambda_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \left(\phi_2 - \phi_1\right)\\ \end{array} \]
Alternative 16
Error46.1
Cost388
\[\begin{array}{l} \mathbf{if}\;\phi_2 \leq 3.6 \cdot 10^{-81}:\\ \;\;\;\;R \cdot \left(-\lambda_1\right)\\ \mathbf{else}:\\ \;\;\;\;R \cdot \phi_2\\ \end{array} \]
Alternative 17
Error54.1
Cost192
\[R \cdot \phi_2 \]

Error

Reproduce?

herbie shell --seed 2023018 
(FPCore (R lambda1 lambda2 phi1 phi2)
  :name "Equirectangular approximation to distance on a great circle"
  :precision binary64
  (* R (sqrt (+ (* (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0))) (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0)))) (* (- phi1 phi2) (- phi1 phi2))))))