Midpoint on a great circle

Percentage Accurate: 98.6% → 99.6%
Time: 26.8s
Alternatives: 26
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (+
  lambda1
  (atan2
   (* (cos phi2) (sin (- lambda1 lambda2)))
   (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2):
	return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2)
	return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))))
end
function tmp = code(lambda1, lambda2, phi1, phi2)
	tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 26 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 98.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (+
  lambda1
  (atan2
   (* (cos phi2) (sin (- lambda1 lambda2)))
   (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2):
	return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2)
	return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))))
end
function tmp = code(lambda1, lambda2, phi1, phi2)
	tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}

Alternative 1: 99.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\mathsf{fma}\left(\cos \phi_2 \cdot \sin \lambda_2, \sin \lambda_1, \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1\right) + \cos \phi_1\right)} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (+
  lambda1
  (atan2
   (*
    (cos phi2)
    (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
   (fma
    (* (cos phi2) (sin lambda2))
    (sin lambda1)
    (+ (* (cos phi2) (* (cos lambda2) (cos lambda1))) (cos phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), fma((cos(phi2) * sin(lambda2)), sin(lambda1), ((cos(phi2) * (cos(lambda2) * cos(lambda1))) + cos(phi1))));
}
function code(lambda1, lambda2, phi1, phi2)
	return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), fma(Float64(cos(phi2) * sin(lambda2)), sin(lambda1), Float64(Float64(cos(phi2) * Float64(cos(lambda2) * cos(lambda1))) + cos(phi1)))))
end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\mathsf{fma}\left(\cos \phi_2 \cdot \sin \lambda_2, \sin \lambda_1, \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1\right) + \cos \phi_1\right)}
\end{array}
Derivation
  1. Initial program 97.4%

    \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sin-diffN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    2. --lowering--.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\left(\sin \lambda_1 \cdot \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\sin \lambda_1, \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    4. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    5. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\cos \lambda_1, \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    7. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    8. sin-lowering-sin.f6497.6%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
  4. Applied egg-rr97.6%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  5. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \color{blue}{\cos \phi_1}\right)\right)\right) \]
    2. cos-diffN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right) + \cos \phi_1\right)\right)\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right) + \cos \phi_1\right)\right)\right) \]
    4. distribute-lft-inN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1\right) + \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right) + \cos \color{blue}{\phi_1}\right)\right)\right) \]
    5. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right) + \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1\right)\right) + \cos \color{blue}{\phi_1}\right)\right)\right) \]
    6. associate-+l+N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right) + \color{blue}{\left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1\right) + \cos \phi_1\right)}\right)\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\cos \phi_2 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1\right) + \left(\cos \phi_2 \cdot \color{blue}{\left(\cos \lambda_2 \cdot \cos \lambda_1\right)} + \cos \phi_1\right)\right)\right)\right) \]
    8. associate-*r*N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\left(\cos \phi_2 \cdot \sin \lambda_2\right) \cdot \sin \lambda_1 + \left(\color{blue}{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1\right)} + \cos \phi_1\right)\right)\right)\right) \]
    9. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\left(\cos \phi_2 \cdot \sin \lambda_2\right) \cdot \sin \lambda_1 + \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2 + \cos \color{blue}{\phi_1}\right)\right)\right)\right) \]
    10. accelerator-lowering-fma.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{fma.f64}\left(\left(\cos \phi_2 \cdot \sin \lambda_2\right), \color{blue}{\sin \lambda_1}, \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2 + \cos \phi_1\right)\right)\right)\right) \]
    11. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{fma.f64}\left(\mathsf{*.f64}\left(\cos \phi_2, \sin \lambda_2\right), \sin \color{blue}{\lambda_1}, \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2 + \cos \phi_1\right)\right)\right)\right) \]
    12. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{fma.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \sin \lambda_2\right), \sin \lambda_1, \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2 + \cos \phi_1\right)\right)\right)\right) \]
    13. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{fma.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\lambda_2\right)\right), \sin \lambda_1, \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2 + \cos \phi_1\right)\right)\right)\right) \]
    14. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{fma.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\lambda_2\right)\right), \mathsf{sin.f64}\left(\lambda_1\right), \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2 + \cos \phi_1\right)\right)\right)\right) \]
  6. Applied egg-rr99.7%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\color{blue}{\mathsf{fma}\left(\cos \phi_2 \cdot \sin \lambda_2, \sin \lambda_1, \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1\right) + \cos \phi_1\right)}} \]
  7. Add Preprocessing

Alternative 2: 99.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (+
  lambda1
  (atan2
   (*
    (cos phi2)
    (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
   (+
    (cos phi1)
    (*
     (cos phi2)
     (+ (* (cos lambda2) (cos lambda1)) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (Math.cos(phi1) + (Math.cos(phi2) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda1) * Math.sin(lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2):
	return lambda1 + math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (math.cos(phi1) + (math.cos(phi2) * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda1) * math.sin(lambda2))))))
function code(lambda1, lambda2, phi1, phi2)
	return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2)))))))
end
function tmp = code(lambda1, lambda2, phi1, phi2)
	tmp = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))));
end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Derivation
  1. Initial program 97.4%

    \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sin-diffN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    2. --lowering--.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\left(\sin \lambda_1 \cdot \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\sin \lambda_1, \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    4. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    5. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\cos \lambda_1, \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    7. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    8. sin-lowering-sin.f6497.6%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
  4. Applied egg-rr97.6%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  5. Step-by-step derivation
    1. cos-diffN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \left(\cos \lambda_1 \cdot \cos \lambda_2 + \color{blue}{\sin \lambda_1 \cdot \sin \lambda_2}\right)\right)\right)\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \left(\cos \lambda_2 \cdot \cos \lambda_1 + \color{blue}{\sin \lambda_1} \cdot \sin \lambda_2\right)\right)\right)\right)\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \left(\sin \lambda_1 \cdot \sin \lambda_2 + \color{blue}{\cos \lambda_2 \cdot \cos \lambda_1}\right)\right)\right)\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{+.f64}\left(\left(\sin \lambda_1 \cdot \sin \lambda_2\right), \color{blue}{\left(\cos \lambda_2 \cdot \cos \lambda_1\right)}\right)\right)\right)\right)\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\sin \lambda_1, \sin \lambda_2\right), \left(\color{blue}{\cos \lambda_2} \cdot \cos \lambda_1\right)\right)\right)\right)\right)\right) \]
    6. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \sin \lambda_2\right), \left(\cos \color{blue}{\lambda_2} \cdot \cos \lambda_1\right)\right)\right)\right)\right)\right) \]
    7. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right), \left(\cos \lambda_2 \cdot \cos \lambda_1\right)\right)\right)\right)\right)\right) \]
    8. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\cos \lambda_2, \color{blue}{\cos \lambda_1}\right)\right)\right)\right)\right)\right) \]
    9. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \cos \color{blue}{\lambda_1}\right)\right)\right)\right)\right)\right) \]
    10. cos-lowering-cos.f6499.7%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{cos.f64}\left(\lambda_1\right)\right)\right)\right)\right)\right)\right) \]
  6. Applied egg-rr99.7%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}} \]
  7. Final simplification99.7%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
  8. Add Preprocessing

Alternative 3: 98.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \lambda_1 \cdot \sin \lambda_2\right)} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (+
  lambda1
  (atan2
   (*
    (cos phi2)
    (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
   (+
    (cos phi1)
    (*
     (cos phi2)
     (+ (* (cos lambda2) (cos lambda1)) (* lambda1 (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (lambda1 * sin(lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (lambda1 * sin(lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (Math.cos(phi1) + (Math.cos(phi2) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (lambda1 * Math.sin(lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2):
	return lambda1 + math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (math.cos(phi1) + (math.cos(phi2) * ((math.cos(lambda2) * math.cos(lambda1)) + (lambda1 * math.sin(lambda2))))))
function code(lambda1, lambda2, phi1, phi2)
	return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(lambda1 * sin(lambda2)))))))
end
function tmp = code(lambda1, lambda2, phi1, phi2)
	tmp = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (lambda1 * sin(lambda2))))));
end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(lambda1 * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Derivation
  1. Initial program 97.4%

    \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sin-diffN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    2. --lowering--.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\left(\sin \lambda_1 \cdot \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\sin \lambda_1, \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    4. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    5. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\cos \lambda_1, \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    7. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    8. sin-lowering-sin.f6497.6%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
  4. Applied egg-rr97.6%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  5. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \color{blue}{\cos \phi_1}\right)\right)\right) \]
    2. cos-diffN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right) + \cos \phi_1\right)\right)\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right) + \cos \phi_1\right)\right)\right) \]
    4. distribute-lft-inN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1\right) + \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right) + \cos \color{blue}{\phi_1}\right)\right)\right) \]
    5. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right) + \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1\right)\right) + \cos \color{blue}{\phi_1}\right)\right)\right) \]
    6. associate-+l+N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right) + \color{blue}{\left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1\right) + \cos \phi_1\right)}\right)\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\cos \phi_2 \cdot \left(\sin \lambda_2 \cdot \sin \lambda_1\right) + \left(\cos \phi_2 \cdot \color{blue}{\left(\cos \lambda_2 \cdot \cos \lambda_1\right)} + \cos \phi_1\right)\right)\right)\right) \]
    8. associate-*r*N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\left(\cos \phi_2 \cdot \sin \lambda_2\right) \cdot \sin \lambda_1 + \left(\color{blue}{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1\right)} + \cos \phi_1\right)\right)\right)\right) \]
    9. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\left(\cos \phi_2 \cdot \sin \lambda_2\right) \cdot \sin \lambda_1 + \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2 + \cos \color{blue}{\phi_1}\right)\right)\right)\right) \]
    10. accelerator-lowering-fma.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{fma.f64}\left(\left(\cos \phi_2 \cdot \sin \lambda_2\right), \color{blue}{\sin \lambda_1}, \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2 + \cos \phi_1\right)\right)\right)\right) \]
    11. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{fma.f64}\left(\mathsf{*.f64}\left(\cos \phi_2, \sin \lambda_2\right), \sin \color{blue}{\lambda_1}, \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2 + \cos \phi_1\right)\right)\right)\right) \]
    12. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{fma.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \sin \lambda_2\right), \sin \lambda_1, \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2 + \cos \phi_1\right)\right)\right)\right) \]
    13. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{fma.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\lambda_2\right)\right), \sin \lambda_1, \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2 + \cos \phi_1\right)\right)\right)\right) \]
    14. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{fma.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\lambda_2\right)\right), \mathsf{sin.f64}\left(\lambda_1\right), \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2 + \cos \phi_1\right)\right)\right)\right) \]
  6. Applied egg-rr99.7%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\color{blue}{\mathsf{fma}\left(\cos \phi_2 \cdot \sin \lambda_2, \sin \lambda_1, \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1\right) + \cos \phi_1\right)}} \]
  7. Taylor expanded in phi2 around inf

    \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \color{blue}{\left(\cos \phi_1 + \left(\cos \lambda_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right) + \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)}\right)\right) \]
  8. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\cos \phi_1 + \left(\left(\cos \lambda_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2 + \color{blue}{\cos \phi_2} \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\cos \phi_1 + \left(\left(\cos \lambda_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2 + \left(\sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \color{blue}{\cos \phi_2}\right)\right)\right)\right) \]
    3. distribute-rgt-inN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \left(\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\right)\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}\right)\right)\right) \]
    5. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \left(\color{blue}{\cos \phi_2} \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)\right)\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \left(\left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \color{blue}{\cos \phi_2}\right)\right)\right)\right) \]
    7. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right), \color{blue}{\cos \phi_2}\right)\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(\cos \lambda_1 \cdot \cos \lambda_2\right), \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right), \cos \color{blue}{\phi_2}\right)\right)\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\cos \lambda_1, \cos \lambda_2\right), \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right), \cos \phi_2\right)\right)\right)\right) \]
    10. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \cos \lambda_2\right), \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right), \cos \phi_2\right)\right)\right)\right) \]
    11. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right), \cos \phi_2\right)\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\sin \lambda_1, \sin \lambda_2\right)\right), \cos \phi_2\right)\right)\right)\right) \]
    13. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \sin \lambda_2\right)\right), \cos \phi_2\right)\right)\right)\right) \]
    14. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right), \cos \phi_2\right)\right)\right)\right) \]
    15. cos-lowering-cos.f6499.7%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right), \mathsf{cos.f64}\left(\phi_2\right)\right)\right)\right)\right) \]
  9. Simplified99.7%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\color{blue}{\cos \phi_1 + \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}} \]
  10. Taylor expanded in lambda1 around 0

    \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \color{blue}{\left(\lambda_1 \cdot \sin \lambda_2\right)}\right), \mathsf{cos.f64}\left(\phi_2\right)\right)\right)\right)\right) \]
  11. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\lambda_1, \sin \lambda_2\right)\right), \mathsf{cos.f64}\left(\phi_2\right)\right)\right)\right)\right) \]
    2. sin-lowering-sin.f6497.8%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\lambda_1, \mathsf{sin.f64}\left(\lambda_2\right)\right)\right), \mathsf{cos.f64}\left(\phi_2\right)\right)\right)\right)\right) \]
  12. Simplified97.8%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \left(\cos \lambda_1 \cdot \cos \lambda_2 + \color{blue}{\lambda_1 \cdot \sin \lambda_2}\right) \cdot \cos \phi_2} \]
  13. Final simplification97.8%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \lambda_1 \cdot \sin \lambda_2\right)} \]
  14. Add Preprocessing

Alternative 4: 98.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (+
  lambda1
  (atan2
   (*
    (cos phi2)
    (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
   (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2):
	return lambda1 + math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2)
	return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))))
end
function tmp = code(lambda1, lambda2, phi1, phi2)
	tmp = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Derivation
  1. Initial program 97.4%

    \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sin-diffN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    2. --lowering--.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\left(\sin \lambda_1 \cdot \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\sin \lambda_1, \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    4. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    5. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\cos \lambda_1, \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    7. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    8. sin-lowering-sin.f6497.6%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
  4. Applied egg-rr97.6%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  5. Add Preprocessing

Alternative 5: 97.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (+
  lambda1
  (atan2
   (*
    (cos phi2)
    (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
   (+ (cos phi1) (* (cos phi2) (cos lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos(lambda2))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos(lambda2))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos(lambda2))));
}
def code(lambda1, lambda2, phi1, phi2):
	return lambda1 + math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (math.cos(phi1) + (math.cos(phi2) * math.cos(lambda2))))
function code(lambda1, lambda2, phi1, phi2)
	return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * cos(lambda2)))))
end
function tmp = code(lambda1, lambda2, phi1, phi2)
	tmp = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos(lambda2))));
end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2}
\end{array}
Derivation
  1. Initial program 97.4%

    \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in lambda1 around 0

    \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
  4. Step-by-step derivation
    1. cos-negN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
    2. cos-lowering-cos.f6497.4%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
  5. Simplified97.4%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
  6. Step-by-step derivation
    1. sin-diffN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    2. --lowering--.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\left(\sin \lambda_1 \cdot \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\sin \lambda_1, \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    4. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \cos \lambda_2\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\cos \lambda_1, \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    7. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \sin \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    8. sin-lowering-sin.f6497.5%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{sin.f64}\left(\lambda_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\lambda_1\right), \mathsf{sin.f64}\left(\lambda_2\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
  7. Applied egg-rr97.5%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \]
  8. Add Preprocessing

Alternative 6: 87.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\cos \phi_2 \leq 0.97:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_2 + \cos \phi_1}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (- lambda1 lambda2))))
   (if (<= (cos phi2) 0.97)
     (+ lambda1 (atan2 (* (cos phi2) t_0) (+ (cos phi2) (cos phi1))))
     (+
      lambda1
      (atan2 t_0 (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin((lambda1 - lambda2));
	double tmp;
	if (cos(phi2) <= 0.97) {
		tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + cos(phi1)));
	} else {
		tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin((lambda1 - lambda2))
    if (cos(phi2) <= 0.97d0) then
        tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + cos(phi1)))
    else
        tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.sin((lambda1 - lambda2));
	double tmp;
	if (Math.cos(phi2) <= 0.97) {
		tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (Math.cos(phi2) + Math.cos(phi1)));
	} else {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.sin((lambda1 - lambda2))
	tmp = 0
	if math.cos(phi2) <= 0.97:
		tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (math.cos(phi2) + math.cos(phi1)))
	else:
		tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (cos(phi2) <= 0.97)
		tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(cos(phi2) + cos(phi1))));
	else
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = sin((lambda1 - lambda2));
	tmp = 0.0;
	if (cos(phi2) <= 0.97)
		tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + cos(phi1)));
	else
		tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.97], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.97:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_2 + \cos \phi_1}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 phi2) < 0.96999999999999997

    1. Initial program 95.2%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6495.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified95.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in lambda2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(\cos \phi_1 + \cos \phi_2\right)}\right)\right) \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \phi_2 + \color{blue}{\cos \phi_1}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\cos \phi_2, \color{blue}{\cos \phi_1}\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \color{blue}{\phi_1}\right)\right)\right) \]
      4. cos-lowering-cos.f6471.6%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\phi_1\right)\right)\right)\right) \]
    8. Simplified71.6%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_2 + \cos \phi_1}} \]

    if 0.96999999999999997 < (cos.f64 phi2)

    1. Initial program 99.3%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\left(\lambda_1 - \lambda_2\right)\right), \mathsf{+.f64}\left(\color{blue}{\mathsf{cos.f64}\left(\phi_1\right)}, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      2. --lowering--.f6498.3%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    5. Simplified98.3%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 87.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\cos \phi_2 \leq 0.97:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_2 + \cos \phi_1}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \cos \phi_1}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
   (if (<= (cos phi2) 0.97)
     (+ lambda1 (atan2 t_0 (+ (cos phi2) (cos phi1))))
     (+ lambda1 (atan2 t_0 (+ (cos lambda2) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos(phi2) * sin((lambda1 - lambda2));
	double tmp;
	if (cos(phi2) <= 0.97) {
		tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)));
	} else {
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = cos(phi2) * sin((lambda1 - lambda2))
    if (cos(phi2) <= 0.97d0) then
        tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)))
    else
        tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
	double tmp;
	if (Math.cos(phi2) <= 0.97) {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi2) + Math.cos(phi1)));
	} else {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda2) + Math.cos(phi1)));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2))
	tmp = 0
	if math.cos(phi2) <= 0.97:
		tmp = lambda1 + math.atan2(t_0, (math.cos(phi2) + math.cos(phi1)))
	else:
		tmp = lambda1 + math.atan2(t_0, (math.cos(lambda2) + math.cos(phi1)))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2)))
	tmp = 0.0
	if (cos(phi2) <= 0.97)
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi2) + cos(phi1))));
	else
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda2) + cos(phi1))));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = cos(phi2) * sin((lambda1 - lambda2));
	tmp = 0.0;
	if (cos(phi2) <= 0.97)
		tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)));
	else
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.97], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.97:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_2 + \cos \phi_1}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \cos \phi_1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 phi2) < 0.96999999999999997

    1. Initial program 95.2%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6495.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified95.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in lambda2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(\cos \phi_1 + \cos \phi_2\right)}\right)\right) \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \phi_2 + \color{blue}{\cos \phi_1}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\cos \phi_2, \color{blue}{\cos \phi_1}\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \color{blue}{\phi_1}\right)\right)\right) \]
      4. cos-lowering-cos.f6471.6%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\phi_1\right)\right)\right)\right) \]
    8. Simplified71.6%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_2 + \cos \phi_1}} \]

    if 0.96999999999999997 < (cos.f64 phi2)

    1. Initial program 99.3%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6499.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified99.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(\cos \lambda_2 + \cos \phi_1\right)}\right)\right) \]
    7. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \color{blue}{\phi_1}\right)\right)\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \phi_1 + \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right) \]
      5. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \lambda_2\right)\right)\right) \]
      6. cos-lowering-cos.f6498.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right) \]
    8. Simplified98.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \lambda_2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \phi_2 \leq 0.97:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_2 + \cos \phi_1}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_2 + \cos \phi_1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 84.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\cos \phi_2 \leq 0.93:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_2 + \left(1 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \cos \phi_1}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
   (if (<= (cos phi2) 0.93)
     (+
      lambda1
      (atan2
       t_0
       (+
        (cos phi2)
        (+
         1.0
         (*
          (* phi1 phi1)
          (+
           -0.5
           (*
            (* phi1 phi1)
            (+
             0.041666666666666664
             (* (* phi1 phi1) -0.001388888888888889)))))))))
     (+ lambda1 (atan2 t_0 (+ (cos lambda2) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos(phi2) * sin((lambda1 - lambda2));
	double tmp;
	if (cos(phi2) <= 0.93) {
		tmp = lambda1 + atan2(t_0, (cos(phi2) + (1.0 + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	} else {
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = cos(phi2) * sin((lambda1 - lambda2))
    if (cos(phi2) <= 0.93d0) then
        tmp = lambda1 + atan2(t_0, (cos(phi2) + (1.0d0 + ((phi1 * phi1) * ((-0.5d0) + ((phi1 * phi1) * (0.041666666666666664d0 + ((phi1 * phi1) * (-0.001388888888888889d0)))))))))
    else
        tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
	double tmp;
	if (Math.cos(phi2) <= 0.93) {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi2) + (1.0 + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	} else {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda2) + Math.cos(phi1)));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2))
	tmp = 0
	if math.cos(phi2) <= 0.93:
		tmp = lambda1 + math.atan2(t_0, (math.cos(phi2) + (1.0 + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))))
	else:
		tmp = lambda1 + math.atan2(t_0, (math.cos(lambda2) + math.cos(phi1)))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2)))
	tmp = 0.0
	if (cos(phi2) <= 0.93)
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi2) + Float64(1.0 + Float64(Float64(phi1 * phi1) * Float64(-0.5 + Float64(Float64(phi1 * phi1) * Float64(0.041666666666666664 + Float64(Float64(phi1 * phi1) * -0.001388888888888889)))))))));
	else
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda2) + cos(phi1))));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = cos(phi2) * sin((lambda1 - lambda2));
	tmp = 0.0;
	if (cos(phi2) <= 0.93)
		tmp = lambda1 + atan2(t_0, (cos(phi2) + (1.0 + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	else
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.93], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi2], $MachinePrecision] + N[(1.0 + N[(N[(phi1 * phi1), $MachinePrecision] * N[(-0.5 + N[(N[(phi1 * phi1), $MachinePrecision] * N[(0.041666666666666664 + N[(N[(phi1 * phi1), $MachinePrecision] * -0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.93:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_2 + \left(1 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \cos \phi_1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 phi2) < 0.930000000000000049

    1. Initial program 95.0%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6495.0%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified95.0%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \left(\cos \lambda_2 \cdot \cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)}\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\cos \lambda_2 \cdot \cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right) \]
      2. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \cos \phi_2 + {\color{blue}{\phi_1}}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\cos \phi_2 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\left(\cos \phi_2 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \color{blue}{\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\cos \phi_2, \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \left(\color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \left({\color{blue}{\phi_1}}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      7. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right), \left({\phi_1}^{\color{blue}{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      8. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \left({\phi_1}^{\color{blue}{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\left({\phi_1}^{2}\right), \color{blue}{\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)}\right)\right)\right)\right)\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\left(\phi_1 \cdot \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      12. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      14. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)\right), \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified81.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1 + \left(\cos \phi_2 \cdot \cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + -0.5\right)\right)}} \]
    9. Taylor expanded in lambda2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \left(\cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)}\right)\right) \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\left(\cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right) + \color{blue}{1}\right)\right)\right) \]
      2. associate-+l+N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \phi_2 + \color{blue}{\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right) + 1\right)}\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\cos \phi_2, \color{blue}{\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right) + 1\right)}\right)\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)} + 1\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{+.f64}\left(\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right), \color{blue}{1}\right)\right)\right)\right) \]
    11. Simplified66.4%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_2 + \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + -0.5\right) + 1\right)}} \]

    if 0.930000000000000049 < (cos.f64 phi2)

    1. Initial program 99.4%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6499.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified99.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(\cos \lambda_2 + \cos \phi_1\right)}\right)\right) \]
    7. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \color{blue}{\phi_1}\right)\right)\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \phi_1 + \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right) \]
      5. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \lambda_2\right)\right)\right) \]
      6. cos-lowering-cos.f6496.8%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right) \]
    8. Simplified96.8%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \lambda_2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \phi_2 \leq 0.93:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_2 + \left(1 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_2 + \cos \phi_1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 84.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\cos \phi_2 \leq 0.93:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_2 + \left(1 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (- lambda1 lambda2))))
   (if (<= (cos phi2) 0.93)
     (+
      lambda1
      (atan2
       (* (cos phi2) t_0)
       (+
        (cos phi2)
        (+
         1.0
         (*
          (* phi1 phi1)
          (+
           -0.5
           (*
            (* phi1 phi1)
            (+
             0.041666666666666664
             (* (* phi1 phi1) -0.001388888888888889)))))))))
     (+ lambda1 (atan2 t_0 (+ (cos phi1) (* (cos phi2) (cos lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin((lambda1 - lambda2));
	double tmp;
	if (cos(phi2) <= 0.93) {
		tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + (1.0 + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	} else {
		tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos(lambda2))));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin((lambda1 - lambda2))
    if (cos(phi2) <= 0.93d0) then
        tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + (1.0d0 + ((phi1 * phi1) * ((-0.5d0) + ((phi1 * phi1) * (0.041666666666666664d0 + ((phi1 * phi1) * (-0.001388888888888889d0)))))))))
    else
        tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos(lambda2))))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.sin((lambda1 - lambda2));
	double tmp;
	if (Math.cos(phi2) <= 0.93) {
		tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (Math.cos(phi2) + (1.0 + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	} else {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + (Math.cos(phi2) * Math.cos(lambda2))));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.sin((lambda1 - lambda2))
	tmp = 0
	if math.cos(phi2) <= 0.93:
		tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (math.cos(phi2) + (1.0 + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))))
	else:
		tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + (math.cos(phi2) * math.cos(lambda2))))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (cos(phi2) <= 0.93)
		tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(cos(phi2) + Float64(1.0 + Float64(Float64(phi1 * phi1) * Float64(-0.5 + Float64(Float64(phi1 * phi1) * Float64(0.041666666666666664 + Float64(Float64(phi1 * phi1) * -0.001388888888888889)))))))));
	else
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + Float64(cos(phi2) * cos(lambda2)))));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = sin((lambda1 - lambda2));
	tmp = 0.0;
	if (cos(phi2) <= 0.93)
		tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + (1.0 + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	else
		tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos(lambda2))));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.93], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi2], $MachinePrecision] + N[(1.0 + N[(N[(phi1 * phi1), $MachinePrecision] * N[(-0.5 + N[(N[(phi1 * phi1), $MachinePrecision] * N[(0.041666666666666664 + N[(N[(phi1 * phi1), $MachinePrecision] * -0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.93:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_2 + \left(1 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 phi2) < 0.930000000000000049

    1. Initial program 95.0%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6495.0%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified95.0%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \left(\cos \lambda_2 \cdot \cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)}\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\cos \lambda_2 \cdot \cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right) \]
      2. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \cos \phi_2 + {\color{blue}{\phi_1}}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\cos \phi_2 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\left(\cos \phi_2 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \color{blue}{\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\cos \phi_2, \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \left(\color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \left({\color{blue}{\phi_1}}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      7. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right), \left({\phi_1}^{\color{blue}{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      8. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \left({\phi_1}^{\color{blue}{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\left({\phi_1}^{2}\right), \color{blue}{\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)}\right)\right)\right)\right)\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\left(\phi_1 \cdot \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      12. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      14. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)\right), \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified81.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1 + \left(\cos \phi_2 \cdot \cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + -0.5\right)\right)}} \]
    9. Taylor expanded in lambda2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \left(\cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)}\right)\right) \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\left(\cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right) + \color{blue}{1}\right)\right)\right) \]
      2. associate-+l+N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \phi_2 + \color{blue}{\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right) + 1\right)}\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\cos \phi_2, \color{blue}{\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right) + 1\right)}\right)\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)} + 1\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{+.f64}\left(\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right), \color{blue}{1}\right)\right)\right)\right) \]
    11. Simplified66.4%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_2 + \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + -0.5\right) + 1\right)}} \]

    if 0.930000000000000049 < (cos.f64 phi2)

    1. Initial program 99.4%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6499.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified99.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\left(\lambda_1 - \lambda_2\right)\right), \mathsf{+.f64}\left(\color{blue}{\mathsf{cos.f64}\left(\phi_1\right)}, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
      2. --lowering--.f6496.7%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    8. Simplified96.7%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \phi_2 \leq 0.93:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_2 + \left(1 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 98.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (+
  lambda1
  (atan2
   (* (cos phi2) (sin (- lambda1 lambda2)))
   (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2):
	return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2)
	return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))))
end
function tmp = code(lambda1, lambda2, phi1, phi2)
	tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Derivation
  1. Initial program 97.4%

    \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 11: 97.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (+
  lambda1
  (atan2
   (* (cos phi2) (sin (- lambda1 lambda2)))
   (+ (cos phi1) (* (cos phi2) (cos lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos(lambda2))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos(lambda2))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos(lambda2))));
}
def code(lambda1, lambda2, phi1, phi2):
	return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos(lambda2))))
function code(lambda1, lambda2, phi1, phi2)
	return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(lambda2)))))
end
function tmp = code(lambda1, lambda2, phi1, phi2)
	tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos(lambda2))));
end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2}
\end{array}
Derivation
  1. Initial program 97.4%

    \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in lambda1 around 0

    \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
  4. Step-by-step derivation
    1. cos-negN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
    2. cos-lowering-cos.f6497.4%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
  5. Simplified97.4%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
  6. Add Preprocessing

Alternative 12: 82.3% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\ t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_2 \leq 29000000000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot \left(1 + \phi_2 \cdot \left(\phi_2 \cdot -0.5\right)\right)}{\cos \phi_1 + t\_0}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{\left(t\_0 + 1\right) + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \phi_1 \cdot \left(\phi_1 \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* (cos phi2) (cos (- lambda1 lambda2))))
        (t_1 (sin (- lambda1 lambda2))))
   (if (<= phi2 29000000000.0)
     (+
      lambda1
      (atan2 (* t_1 (+ 1.0 (* phi2 (* phi2 -0.5)))) (+ (cos phi1) t_0)))
     (+
      lambda1
      (atan2
       (* (cos phi2) t_1)
       (+
        (+ t_0 1.0)
        (*
         (* phi1 phi1)
         (+
          -0.5
          (*
           phi1
           (*
            phi1
            (+
             0.041666666666666664
             (* (* phi1 phi1) -0.001388888888888889))))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos(phi2) * cos((lambda1 - lambda2));
	double t_1 = sin((lambda1 - lambda2));
	double tmp;
	if (phi2 <= 29000000000.0) {
		tmp = lambda1 + atan2((t_1 * (1.0 + (phi2 * (phi2 * -0.5)))), (cos(phi1) + t_0));
	} else {
		tmp = lambda1 + atan2((cos(phi2) * t_1), ((t_0 + 1.0) + ((phi1 * phi1) * (-0.5 + (phi1 * (phi1 * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = cos(phi2) * cos((lambda1 - lambda2))
    t_1 = sin((lambda1 - lambda2))
    if (phi2 <= 29000000000.0d0) then
        tmp = lambda1 + atan2((t_1 * (1.0d0 + (phi2 * (phi2 * (-0.5d0))))), (cos(phi1) + t_0))
    else
        tmp = lambda1 + atan2((cos(phi2) * t_1), ((t_0 + 1.0d0) + ((phi1 * phi1) * ((-0.5d0) + (phi1 * (phi1 * (0.041666666666666664d0 + ((phi1 * phi1) * (-0.001388888888888889d0)))))))))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.cos(phi2) * Math.cos((lambda1 - lambda2));
	double t_1 = Math.sin((lambda1 - lambda2));
	double tmp;
	if (phi2 <= 29000000000.0) {
		tmp = lambda1 + Math.atan2((t_1 * (1.0 + (phi2 * (phi2 * -0.5)))), (Math.cos(phi1) + t_0));
	} else {
		tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_1), ((t_0 + 1.0) + ((phi1 * phi1) * (-0.5 + (phi1 * (phi1 * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.cos(phi2) * math.cos((lambda1 - lambda2))
	t_1 = math.sin((lambda1 - lambda2))
	tmp = 0
	if phi2 <= 29000000000.0:
		tmp = lambda1 + math.atan2((t_1 * (1.0 + (phi2 * (phi2 * -0.5)))), (math.cos(phi1) + t_0))
	else:
		tmp = lambda1 + math.atan2((math.cos(phi2) * t_1), ((t_0 + 1.0) + ((phi1 * phi1) * (-0.5 + (phi1 * (phi1 * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))
	t_1 = sin(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (phi2 <= 29000000000.0)
		tmp = Float64(lambda1 + atan(Float64(t_1 * Float64(1.0 + Float64(phi2 * Float64(phi2 * -0.5)))), Float64(cos(phi1) + t_0)));
	else
		tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), Float64(Float64(t_0 + 1.0) + Float64(Float64(phi1 * phi1) * Float64(-0.5 + Float64(phi1 * Float64(phi1 * Float64(0.041666666666666664 + Float64(Float64(phi1 * phi1) * -0.001388888888888889)))))))));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = cos(phi2) * cos((lambda1 - lambda2));
	t_1 = sin((lambda1 - lambda2));
	tmp = 0.0;
	if (phi2 <= 29000000000.0)
		tmp = lambda1 + atan2((t_1 * (1.0 + (phi2 * (phi2 * -0.5)))), (cos(phi1) + t_0));
	else
		tmp = lambda1 + atan2((cos(phi2) * t_1), ((t_0 + 1.0) + ((phi1 * phi1) * (-0.5 + (phi1 * (phi1 * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 29000000000.0], N[(lambda1 + N[ArcTan[N[(t$95$1 * N[(1.0 + N[(phi2 * N[(phi2 * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[(t$95$0 + 1.0), $MachinePrecision] + N[(N[(phi1 * phi1), $MachinePrecision] * N[(-0.5 + N[(phi1 * N[(phi1 * N[(0.041666666666666664 + N[(N[(phi1 * phi1), $MachinePrecision] * -0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 29000000000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot \left(1 + \phi_2 \cdot \left(\phi_2 \cdot -0.5\right)\right)}{\cos \phi_1 + t\_0}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{\left(t\_0 + 1\right) + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \phi_1 \cdot \left(\phi_1 \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi2 < 2.9e10

    1. Initial program 97.6%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\color{blue}{\left(1 + \frac{-1}{2} \cdot {\phi_2}^{2}\right)}, \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-1}{2} \cdot {\phi_2}^{2}\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left({\phi_2}^{2} \cdot \frac{-1}{2}\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(\left(\phi_2 \cdot \phi_2\right) \cdot \frac{-1}{2}\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      4. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(\phi_2 \cdot \left(\phi_2 \cdot \frac{-1}{2}\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\phi_2, \left(\phi_2 \cdot \frac{-1}{2}\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      6. *-lowering-*.f6483.1%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\phi_2, \mathsf{*.f64}\left(\phi_2, \frac{-1}{2}\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    5. Simplified83.1%

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

    if 2.9e10 < phi2

    1. Initial program 96.9%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in phi1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)}\right)\right) \]
    4. Step-by-step derivation
      1. associate-+r+N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\left(1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) + \color{blue}{{\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\left(1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right), \color{blue}{\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + 1\right), \left(\color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right), 1\right), \left(\color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\cos \phi_2, \cos \left(\lambda_1 - \lambda_2\right)\right), 1\right), \left({\color{blue}{\phi_1}}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \left(\lambda_1 - \lambda_2\right)\right), 1\right), \left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      7. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\left(\lambda_1 - \lambda_2\right)\right)\right), 1\right), \left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), 1\right), \left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), 1\right), \mathsf{*.f64}\left(\left({\phi_1}^{2}\right), \color{blue}{\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)}\right)\right)\right)\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), 1\right), \mathsf{*.f64}\left(\left(\phi_1 \cdot \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), 1\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right) \]
      12. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), 1\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)\right)\right)\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), 1\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \frac{-1}{2}\right)\right)\right)\right)\right) \]
      14. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), 1\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\frac{-1}{2} + \color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)}\right)\right)\right)\right)\right) \]
      15. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), 1\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\frac{-1}{2}, \color{blue}{\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)\right)}\right)\right)\right)\right)\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), 1\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\frac{-1}{2}, \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(\color{blue}{\frac{1}{24}} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)\right)\right)\right)\right)\right)\right) \]
      17. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), 1\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\frac{-1}{2}, \left(\phi_1 \cdot \color{blue}{\left(\phi_1 \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), 1\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\frac{-1}{2}, \left(\phi_1 \cdot \left(\left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) \cdot \color{blue}{\phi_1}\right)\right)\right)\right)\right)\right)\right) \]
    5. Simplified82.5%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + 1\right) + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \phi_1 \cdot \left(\phi_1 \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(\phi_1 \cdot \phi_1\right)\right)\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq 29000000000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \left(1 + \phi_2 \cdot \left(\phi_2 \cdot -0.5\right)\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + 1\right) + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \phi_1 \cdot \left(\phi_1 \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 82.2% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_2 \leq 29000000000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \left(1 + \phi_2 \cdot \left(\phi_2 \cdot -0.5\right)\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \left(\cos \phi_2 \cdot \cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (- lambda1 lambda2))))
   (if (<= phi2 29000000000.0)
     (+
      lambda1
      (atan2
       (* t_0 (+ 1.0 (* phi2 (* phi2 -0.5))))
       (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
     (+
      lambda1
      (atan2
       (* (cos phi2) t_0)
       (+
        1.0
        (+
         (* (cos phi2) (cos lambda2))
         (*
          (* phi1 phi1)
          (+
           -0.5
           (*
            (* phi1 phi1)
            (+
             0.041666666666666664
             (* (* phi1 phi1) -0.001388888888888889))))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin((lambda1 - lambda2));
	double tmp;
	if (phi2 <= 29000000000.0) {
		tmp = lambda1 + atan2((t_0 * (1.0 + (phi2 * (phi2 * -0.5)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
	} else {
		tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + ((cos(phi2) * cos(lambda2)) + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin((lambda1 - lambda2))
    if (phi2 <= 29000000000.0d0) then
        tmp = lambda1 + atan2((t_0 * (1.0d0 + (phi2 * (phi2 * (-0.5d0))))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
    else
        tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0d0 + ((cos(phi2) * cos(lambda2)) + ((phi1 * phi1) * ((-0.5d0) + ((phi1 * phi1) * (0.041666666666666664d0 + ((phi1 * phi1) * (-0.001388888888888889d0)))))))))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.sin((lambda1 - lambda2));
	double tmp;
	if (phi2 <= 29000000000.0) {
		tmp = lambda1 + Math.atan2((t_0 * (1.0 + (phi2 * (phi2 * -0.5)))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
	} else {
		tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (1.0 + ((Math.cos(phi2) * Math.cos(lambda2)) + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.sin((lambda1 - lambda2))
	tmp = 0
	if phi2 <= 29000000000.0:
		tmp = lambda1 + math.atan2((t_0 * (1.0 + (phi2 * (phi2 * -0.5)))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
	else:
		tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (1.0 + ((math.cos(phi2) * math.cos(lambda2)) + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (phi2 <= 29000000000.0)
		tmp = Float64(lambda1 + atan(Float64(t_0 * Float64(1.0 + Float64(phi2 * Float64(phi2 * -0.5)))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))));
	else
		tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(1.0 + Float64(Float64(cos(phi2) * cos(lambda2)) + Float64(Float64(phi1 * phi1) * Float64(-0.5 + Float64(Float64(phi1 * phi1) * Float64(0.041666666666666664 + Float64(Float64(phi1 * phi1) * -0.001388888888888889)))))))));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = sin((lambda1 - lambda2));
	tmp = 0.0;
	if (phi2 <= 29000000000.0)
		tmp = lambda1 + atan2((t_0 * (1.0 + (phi2 * (phi2 * -0.5)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
	else
		tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + ((cos(phi2) * cos(lambda2)) + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 29000000000.0], N[(lambda1 + N[ArcTan[N[(t$95$0 * N[(1.0 + N[(phi2 * N[(phi2 * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[(phi1 * phi1), $MachinePrecision] * N[(-0.5 + N[(N[(phi1 * phi1), $MachinePrecision] * N[(0.041666666666666664 + N[(N[(phi1 * phi1), $MachinePrecision] * -0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 29000000000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \left(1 + \phi_2 \cdot \left(\phi_2 \cdot -0.5\right)\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \left(\cos \phi_2 \cdot \cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi2 < 2.9e10

    1. Initial program 97.6%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\color{blue}{\left(1 + \frac{-1}{2} \cdot {\phi_2}^{2}\right)}, \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-1}{2} \cdot {\phi_2}^{2}\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left({\phi_2}^{2} \cdot \frac{-1}{2}\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(\left(\phi_2 \cdot \phi_2\right) \cdot \frac{-1}{2}\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      4. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(\phi_2 \cdot \left(\phi_2 \cdot \frac{-1}{2}\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\phi_2, \left(\phi_2 \cdot \frac{-1}{2}\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      6. *-lowering-*.f6483.1%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\phi_2, \mathsf{*.f64}\left(\phi_2, \frac{-1}{2}\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    5. Simplified83.1%

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

    if 2.9e10 < phi2

    1. Initial program 96.9%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6496.9%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified96.9%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \left(\cos \lambda_2 \cdot \cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)}\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\cos \lambda_2 \cdot \cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right) \]
      2. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \cos \phi_2 + {\color{blue}{\phi_1}}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\cos \phi_2 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\left(\cos \phi_2 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \color{blue}{\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\cos \phi_2, \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \left(\color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \left({\color{blue}{\phi_1}}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      7. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right), \left({\phi_1}^{\color{blue}{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      8. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \left({\phi_1}^{\color{blue}{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\left({\phi_1}^{2}\right), \color{blue}{\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)}\right)\right)\right)\right)\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\left(\phi_1 \cdot \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      12. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      14. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)\right), \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified82.5%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1 + \left(\cos \phi_2 \cdot \cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + -0.5\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq 29000000000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \left(1 + \phi_2 \cdot \left(\phi_2 \cdot -0.5\right)\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \left(\cos \phi_2 \cdot \cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 84.4% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\cos \phi_2 \leq 0.93:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_2 + \left(1 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \cos \phi_1}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (- lambda1 lambda2))))
   (if (<= (cos phi2) 0.93)
     (+
      lambda1
      (atan2
       (* (cos phi2) t_0)
       (+
        (cos phi2)
        (+
         1.0
         (*
          (* phi1 phi1)
          (+
           -0.5
           (*
            (* phi1 phi1)
            (+
             0.041666666666666664
             (* (* phi1 phi1) -0.001388888888888889)))))))))
     (+ lambda1 (atan2 t_0 (+ (cos lambda2) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin((lambda1 - lambda2));
	double tmp;
	if (cos(phi2) <= 0.93) {
		tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + (1.0 + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	} else {
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin((lambda1 - lambda2))
    if (cos(phi2) <= 0.93d0) then
        tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + (1.0d0 + ((phi1 * phi1) * ((-0.5d0) + ((phi1 * phi1) * (0.041666666666666664d0 + ((phi1 * phi1) * (-0.001388888888888889d0)))))))))
    else
        tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.sin((lambda1 - lambda2));
	double tmp;
	if (Math.cos(phi2) <= 0.93) {
		tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (Math.cos(phi2) + (1.0 + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	} else {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda2) + Math.cos(phi1)));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.sin((lambda1 - lambda2))
	tmp = 0
	if math.cos(phi2) <= 0.93:
		tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (math.cos(phi2) + (1.0 + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))))
	else:
		tmp = lambda1 + math.atan2(t_0, (math.cos(lambda2) + math.cos(phi1)))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (cos(phi2) <= 0.93)
		tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(cos(phi2) + Float64(1.0 + Float64(Float64(phi1 * phi1) * Float64(-0.5 + Float64(Float64(phi1 * phi1) * Float64(0.041666666666666664 + Float64(Float64(phi1 * phi1) * -0.001388888888888889)))))))));
	else
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda2) + cos(phi1))));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = sin((lambda1 - lambda2));
	tmp = 0.0;
	if (cos(phi2) <= 0.93)
		tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + (1.0 + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	else
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.93], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi2], $MachinePrecision] + N[(1.0 + N[(N[(phi1 * phi1), $MachinePrecision] * N[(-0.5 + N[(N[(phi1 * phi1), $MachinePrecision] * N[(0.041666666666666664 + N[(N[(phi1 * phi1), $MachinePrecision] * -0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.93:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_2 + \left(1 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \cos \phi_1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 phi2) < 0.930000000000000049

    1. Initial program 95.0%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6495.0%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified95.0%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \left(\cos \lambda_2 \cdot \cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)}\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\cos \lambda_2 \cdot \cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right) \]
      2. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \cos \phi_2 + {\color{blue}{\phi_1}}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\cos \phi_2 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\left(\cos \phi_2 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \color{blue}{\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\cos \phi_2, \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \left(\color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \left({\color{blue}{\phi_1}}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      7. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right), \left({\phi_1}^{\color{blue}{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      8. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \left({\phi_1}^{\color{blue}{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\left({\phi_1}^{2}\right), \color{blue}{\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)}\right)\right)\right)\right)\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\left(\phi_1 \cdot \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      12. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      14. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)\right), \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified81.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1 + \left(\cos \phi_2 \cdot \cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + -0.5\right)\right)}} \]
    9. Taylor expanded in lambda2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \left(\cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)}\right)\right) \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\left(\cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right) + \color{blue}{1}\right)\right)\right) \]
      2. associate-+l+N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \phi_2 + \color{blue}{\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right) + 1\right)}\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\cos \phi_2, \color{blue}{\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right) + 1\right)}\right)\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)} + 1\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{+.f64}\left(\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right), \color{blue}{1}\right)\right)\right)\right) \]
    11. Simplified66.4%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_2 + \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + -0.5\right) + 1\right)}} \]

    if 0.930000000000000049 < (cos.f64 phi2)

    1. Initial program 99.4%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6499.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified99.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\left(\lambda_1 - \lambda_2\right)\right), \mathsf{+.f64}\left(\color{blue}{\mathsf{cos.f64}\left(\phi_1\right)}, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
      2. --lowering--.f6496.7%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    8. Simplified96.7%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \]
    9. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(\cos \lambda_2 + \cos \phi_1\right)}\right)\right) \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \phi_1 + \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\lambda_2}\right)\right)\right) \]
      4. cos-lowering-cos.f6496.7%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right) \]
    11. Simplified96.7%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \lambda_2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \phi_2 \leq 0.93:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_2 + \left(1 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_2 + \cos \phi_1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 79.7% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\cos \phi_2 \leq 0.5:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \left(\cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \cos \phi_1}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (- lambda1 lambda2))))
   (if (<= (cos phi2) 0.5)
     (+
      lambda1
      (atan2
       (* (cos phi2) t_0)
       (+
        1.0
        (+
         (cos lambda2)
         (*
          (* phi1 phi1)
          (+
           -0.5
           (*
            (* phi1 phi1)
            (+
             0.041666666666666664
             (* (* phi1 phi1) -0.001388888888888889)))))))))
     (+ lambda1 (atan2 t_0 (+ (cos lambda2) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin((lambda1 - lambda2));
	double tmp;
	if (cos(phi2) <= 0.5) {
		tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + (cos(lambda2) + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	} else {
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin((lambda1 - lambda2))
    if (cos(phi2) <= 0.5d0) then
        tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0d0 + (cos(lambda2) + ((phi1 * phi1) * ((-0.5d0) + ((phi1 * phi1) * (0.041666666666666664d0 + ((phi1 * phi1) * (-0.001388888888888889d0)))))))))
    else
        tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.sin((lambda1 - lambda2));
	double tmp;
	if (Math.cos(phi2) <= 0.5) {
		tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (1.0 + (Math.cos(lambda2) + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	} else {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda2) + Math.cos(phi1)));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.sin((lambda1 - lambda2))
	tmp = 0
	if math.cos(phi2) <= 0.5:
		tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (1.0 + (math.cos(lambda2) + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))))
	else:
		tmp = lambda1 + math.atan2(t_0, (math.cos(lambda2) + math.cos(phi1)))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (cos(phi2) <= 0.5)
		tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(1.0 + Float64(cos(lambda2) + Float64(Float64(phi1 * phi1) * Float64(-0.5 + Float64(Float64(phi1 * phi1) * Float64(0.041666666666666664 + Float64(Float64(phi1 * phi1) * -0.001388888888888889)))))))));
	else
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda2) + cos(phi1))));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = sin((lambda1 - lambda2));
	tmp = 0.0;
	if (cos(phi2) <= 0.5)
		tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + (cos(lambda2) + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * (0.041666666666666664 + ((phi1 * phi1) * -0.001388888888888889))))))));
	else
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.5], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[(N[Cos[lambda2], $MachinePrecision] + N[(N[(phi1 * phi1), $MachinePrecision] * N[(-0.5 + N[(N[(phi1 * phi1), $MachinePrecision] * N[(0.041666666666666664 + N[(N[(phi1 * phi1), $MachinePrecision] * -0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.5:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \left(\cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \cos \phi_1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 phi2) < 0.5

    1. Initial program 94.3%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6494.3%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified94.3%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \left(\cos \lambda_2 \cdot \cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)}\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\cos \lambda_2 \cdot \cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right) \]
      2. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \cos \phi_2 + {\color{blue}{\phi_1}}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\cos \phi_2 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\left(\cos \phi_2 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \color{blue}{\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\cos \phi_2, \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \left(\color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \left({\color{blue}{\phi_1}}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      7. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right), \left({\phi_1}^{\color{blue}{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      8. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \left({\phi_1}^{\color{blue}{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\left({\phi_1}^{2}\right), \color{blue}{\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)}\right)\right)\right)\right)\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\left(\phi_1 \cdot \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      12. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      14. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)\right), \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified82.8%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1 + \left(\cos \phi_2 \cdot \cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + -0.5\right)\right)}} \]
    9. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \left(\cos \lambda_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)}\right)\right) \]
    10. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\cos \lambda_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\cos \lambda_2, \color{blue}{\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \left(\color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\left({\phi_1}^{2}\right), \color{blue}{\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)}\right)\right)\right)\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\left(\phi_1 \cdot \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      7. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)\right), \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left({\phi_1}^{2}\right), \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)\right), \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      11. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\left(\phi_1 \cdot \phi_1\right), \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)\right), \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)\right), \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      13. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(\frac{-1}{720} \cdot {\phi_1}^{2}\right)\right)\right), \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\frac{-1}{720}, \left({\phi_1}^{2}\right)\right)\right)\right), \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      15. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\frac{-1}{720}, \left(\phi_1 \cdot \phi_1\right)\right)\right)\right), \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      16. *-lowering-*.f6455.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\frac{-1}{720}, \mathsf{*.f64}\left(\phi_1, \phi_1\right)\right)\right)\right), \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
    11. Simplified55.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1 + \left(\cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(\left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(\phi_1 \cdot \phi_1\right)\right) + -0.5\right)\right)}} \]

    if 0.5 < (cos.f64 phi2)

    1. Initial program 99.1%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6499.0%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified99.0%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\left(\lambda_1 - \lambda_2\right)\right), \mathsf{+.f64}\left(\color{blue}{\mathsf{cos.f64}\left(\phi_1\right)}, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
      2. --lowering--.f6492.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    8. Simplified92.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \]
    9. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(\cos \lambda_2 + \cos \phi_1\right)}\right)\right) \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \phi_1 + \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\lambda_2}\right)\right)\right) \]
      4. cos-lowering-cos.f6492.3%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right) \]
    11. Simplified92.3%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \lambda_2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification79.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \phi_2 \leq 0.5:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \left(\cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.001388888888888889\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_2 + \cos \phi_1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 82.3% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\ t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_2 \leq 29000000000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot \left(1 + \phi_2 \cdot \left(\phi_2 \cdot -0.5\right)\right)}{\cos \phi_1 + t\_0}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{t\_0 + \left(1 + \phi_1 \cdot \left(\phi_1 \cdot -0.5\right)\right)}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* (cos phi2) (cos (- lambda1 lambda2))))
        (t_1 (sin (- lambda1 lambda2))))
   (if (<= phi2 29000000000.0)
     (+
      lambda1
      (atan2 (* t_1 (+ 1.0 (* phi2 (* phi2 -0.5)))) (+ (cos phi1) t_0)))
     (+
      lambda1
      (atan2 (* (cos phi2) t_1) (+ t_0 (+ 1.0 (* phi1 (* phi1 -0.5)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos(phi2) * cos((lambda1 - lambda2));
	double t_1 = sin((lambda1 - lambda2));
	double tmp;
	if (phi2 <= 29000000000.0) {
		tmp = lambda1 + atan2((t_1 * (1.0 + (phi2 * (phi2 * -0.5)))), (cos(phi1) + t_0));
	} else {
		tmp = lambda1 + atan2((cos(phi2) * t_1), (t_0 + (1.0 + (phi1 * (phi1 * -0.5)))));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = cos(phi2) * cos((lambda1 - lambda2))
    t_1 = sin((lambda1 - lambda2))
    if (phi2 <= 29000000000.0d0) then
        tmp = lambda1 + atan2((t_1 * (1.0d0 + (phi2 * (phi2 * (-0.5d0))))), (cos(phi1) + t_0))
    else
        tmp = lambda1 + atan2((cos(phi2) * t_1), (t_0 + (1.0d0 + (phi1 * (phi1 * (-0.5d0))))))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.cos(phi2) * Math.cos((lambda1 - lambda2));
	double t_1 = Math.sin((lambda1 - lambda2));
	double tmp;
	if (phi2 <= 29000000000.0) {
		tmp = lambda1 + Math.atan2((t_1 * (1.0 + (phi2 * (phi2 * -0.5)))), (Math.cos(phi1) + t_0));
	} else {
		tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_1), (t_0 + (1.0 + (phi1 * (phi1 * -0.5)))));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.cos(phi2) * math.cos((lambda1 - lambda2))
	t_1 = math.sin((lambda1 - lambda2))
	tmp = 0
	if phi2 <= 29000000000.0:
		tmp = lambda1 + math.atan2((t_1 * (1.0 + (phi2 * (phi2 * -0.5)))), (math.cos(phi1) + t_0))
	else:
		tmp = lambda1 + math.atan2((math.cos(phi2) * t_1), (t_0 + (1.0 + (phi1 * (phi1 * -0.5)))))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))
	t_1 = sin(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (phi2 <= 29000000000.0)
		tmp = Float64(lambda1 + atan(Float64(t_1 * Float64(1.0 + Float64(phi2 * Float64(phi2 * -0.5)))), Float64(cos(phi1) + t_0)));
	else
		tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), Float64(t_0 + Float64(1.0 + Float64(phi1 * Float64(phi1 * -0.5))))));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = cos(phi2) * cos((lambda1 - lambda2));
	t_1 = sin((lambda1 - lambda2));
	tmp = 0.0;
	if (phi2 <= 29000000000.0)
		tmp = lambda1 + atan2((t_1 * (1.0 + (phi2 * (phi2 * -0.5)))), (cos(phi1) + t_0));
	else
		tmp = lambda1 + atan2((cos(phi2) * t_1), (t_0 + (1.0 + (phi1 * (phi1 * -0.5)))));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 29000000000.0], N[(lambda1 + N[ArcTan[N[(t$95$1 * N[(1.0 + N[(phi2 * N[(phi2 * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(t$95$0 + N[(1.0 + N[(phi1 * N[(phi1 * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 29000000000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot \left(1 + \phi_2 \cdot \left(\phi_2 \cdot -0.5\right)\right)}{\cos \phi_1 + t\_0}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{t\_0 + \left(1 + \phi_1 \cdot \left(\phi_1 \cdot -0.5\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi2 < 2.9e10

    1. Initial program 97.6%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\color{blue}{\left(1 + \frac{-1}{2} \cdot {\phi_2}^{2}\right)}, \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-1}{2} \cdot {\phi_2}^{2}\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left({\phi_2}^{2} \cdot \frac{-1}{2}\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(\left(\phi_2 \cdot \phi_2\right) \cdot \frac{-1}{2}\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      4. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(\phi_2 \cdot \left(\phi_2 \cdot \frac{-1}{2}\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\phi_2, \left(\phi_2 \cdot \frac{-1}{2}\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
      6. *-lowering-*.f6483.1%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\phi_2, \mathsf{*.f64}\left(\phi_2, \frac{-1}{2}\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right)\right) \]
    5. Simplified83.1%

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

    if 2.9e10 < phi2

    1. Initial program 96.9%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in phi1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \left(\frac{-1}{2} \cdot {\phi_1}^{2} + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}\right)\right) \]
    4. Step-by-step derivation
      1. associate-+r+N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\left(1 + \frac{-1}{2} \cdot {\phi_1}^{2}\right) + \color{blue}{\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\right)\right)\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \color{blue}{\left(1 + \frac{-1}{2} \cdot {\phi_1}^{2}\right)}\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {\phi_1}^{2}\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\cos \phi_2, \cos \left(\lambda_1 - \lambda_2\right)\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {\phi_1}^{2}\right)\right)\right)\right) \]
      5. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \left(\lambda_1 - \lambda_2\right)\right), \left(1 + \frac{-1}{2} \cdot {\phi_1}^{2}\right)\right)\right)\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\left(\lambda_1 - \lambda_2\right)\right)\right), \left(1 + \frac{-1}{2} \cdot {\phi_1}^{2}\right)\right)\right)\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(1 + \frac{-1}{2} \cdot {\phi_1}^{2}\right)\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {\phi_1}^{2}\right)}\right)\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \color{blue}{\phi_1}\right)\right)\right)\right)\right)\right) \]
      10. associate-*r*N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\left(\frac{-1}{2} \cdot \phi_1\right) \cdot \color{blue}{\phi_1}\right)\right)\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\phi_1 \cdot \color{blue}{\left(\frac{-1}{2} \cdot \phi_1\right)}\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\phi_1, \color{blue}{\left(\frac{-1}{2} \cdot \phi_1\right)}\right)\right)\right)\right)\right) \]
      13. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\phi_1, \left(\phi_1 \cdot \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right)\right) \]
      14. *-lowering-*.f6482.5%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\phi_1, \mathsf{*.f64}\left(\phi_1, \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right)\right) \]
    5. Simplified82.5%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \left(1 + \phi_1 \cdot \left(\phi_1 \cdot -0.5\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq 29000000000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \left(1 + \phi_2 \cdot \left(\phi_2 \cdot -0.5\right)\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \left(1 + \phi_1 \cdot \left(\phi_1 \cdot -0.5\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 81.9% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_2 \leq 29000000000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \left(1 + \phi_1 \cdot \left(\phi_1 \cdot -0.5\right)\right)}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (- lambda1 lambda2))))
   (if (<= phi2 29000000000.0)
     (+
      lambda1
      (atan2
       (* t_0 (+ 1.0 (* -0.5 (* phi2 phi2))))
       (+ (cos phi1) (* (cos phi2) (cos lambda2)))))
     (+
      lambda1
      (atan2
       (* (cos phi2) t_0)
       (+
        (* (cos phi2) (cos (- lambda1 lambda2)))
        (+ 1.0 (* phi1 (* phi1 -0.5)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin((lambda1 - lambda2));
	double tmp;
	if (phi2 <= 29000000000.0) {
		tmp = lambda1 + atan2((t_0 * (1.0 + (-0.5 * (phi2 * phi2)))), (cos(phi1) + (cos(phi2) * cos(lambda2))));
	} else {
		tmp = lambda1 + atan2((cos(phi2) * t_0), ((cos(phi2) * cos((lambda1 - lambda2))) + (1.0 + (phi1 * (phi1 * -0.5)))));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin((lambda1 - lambda2))
    if (phi2 <= 29000000000.0d0) then
        tmp = lambda1 + atan2((t_0 * (1.0d0 + ((-0.5d0) * (phi2 * phi2)))), (cos(phi1) + (cos(phi2) * cos(lambda2))))
    else
        tmp = lambda1 + atan2((cos(phi2) * t_0), ((cos(phi2) * cos((lambda1 - lambda2))) + (1.0d0 + (phi1 * (phi1 * (-0.5d0))))))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.sin((lambda1 - lambda2));
	double tmp;
	if (phi2 <= 29000000000.0) {
		tmp = lambda1 + Math.atan2((t_0 * (1.0 + (-0.5 * (phi2 * phi2)))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos(lambda2))));
	} else {
		tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), ((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (1.0 + (phi1 * (phi1 * -0.5)))));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.sin((lambda1 - lambda2))
	tmp = 0
	if phi2 <= 29000000000.0:
		tmp = lambda1 + math.atan2((t_0 * (1.0 + (-0.5 * (phi2 * phi2)))), (math.cos(phi1) + (math.cos(phi2) * math.cos(lambda2))))
	else:
		tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), ((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (1.0 + (phi1 * (phi1 * -0.5)))))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (phi2 <= 29000000000.0)
		tmp = Float64(lambda1 + atan(Float64(t_0 * Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2)))), Float64(cos(phi1) + Float64(cos(phi2) * cos(lambda2)))));
	else
		tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(1.0 + Float64(phi1 * Float64(phi1 * -0.5))))));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = sin((lambda1 - lambda2));
	tmp = 0.0;
	if (phi2 <= 29000000000.0)
		tmp = lambda1 + atan2((t_0 * (1.0 + (-0.5 * (phi2 * phi2)))), (cos(phi1) + (cos(phi2) * cos(lambda2))));
	else
		tmp = lambda1 + atan2((cos(phi2) * t_0), ((cos(phi2) * cos((lambda1 - lambda2))) + (1.0 + (phi1 * (phi1 * -0.5)))));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 29000000000.0], N[(lambda1 + N[ArcTan[N[(t$95$0 * N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(phi1 * N[(phi1 * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 29000000000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \left(1 + \phi_1 \cdot \left(\phi_1 \cdot -0.5\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi2 < 2.9e10

    1. Initial program 97.6%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6497.5%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified97.5%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\color{blue}{\left(1 + \frac{-1}{2} \cdot {\phi_2}^{2}\right)}, \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-1}{2} \cdot {\phi_2}^{2}\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left({\phi_2}^{2}\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(\phi_2 \cdot \phi_2\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f6483.0%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(\phi_2, \phi_2\right)\right)\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    8. Simplified83.0%

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

    if 2.9e10 < phi2

    1. Initial program 96.9%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in phi1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \left(\frac{-1}{2} \cdot {\phi_1}^{2} + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}\right)\right) \]
    4. Step-by-step derivation
      1. associate-+r+N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\left(1 + \frac{-1}{2} \cdot {\phi_1}^{2}\right) + \color{blue}{\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\right)\right)\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \color{blue}{\left(1 + \frac{-1}{2} \cdot {\phi_1}^{2}\right)}\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {\phi_1}^{2}\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\cos \phi_2, \cos \left(\lambda_1 - \lambda_2\right)\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {\phi_1}^{2}\right)\right)\right)\right) \]
      5. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \left(\lambda_1 - \lambda_2\right)\right), \left(1 + \frac{-1}{2} \cdot {\phi_1}^{2}\right)\right)\right)\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\left(\lambda_1 - \lambda_2\right)\right)\right), \left(1 + \frac{-1}{2} \cdot {\phi_1}^{2}\right)\right)\right)\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(1 + \frac{-1}{2} \cdot {\phi_1}^{2}\right)\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {\phi_1}^{2}\right)}\right)\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \color{blue}{\phi_1}\right)\right)\right)\right)\right)\right) \]
      10. associate-*r*N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\left(\frac{-1}{2} \cdot \phi_1\right) \cdot \color{blue}{\phi_1}\right)\right)\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\phi_1 \cdot \color{blue}{\left(\frac{-1}{2} \cdot \phi_1\right)}\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\phi_1, \color{blue}{\left(\frac{-1}{2} \cdot \phi_1\right)}\right)\right)\right)\right)\right) \]
      13. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\phi_1, \left(\phi_1 \cdot \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right)\right) \]
      14. *-lowering-*.f6482.5%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\phi_1, \mathsf{*.f64}\left(\phi_1, \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right)\right) \]
    5. Simplified82.5%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \left(1 + \phi_1 \cdot \left(\phi_1 \cdot -0.5\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_2 \leq 29000000000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \left(1 + \phi_1 \cdot \left(\phi_1 \cdot -0.5\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 82.5% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_1 \leq 1.2 \cdot 10^{-5}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_2 \cdot \cos \lambda_2 + 1}\\ \mathbf{elif}\;\phi_1 \leq 3.1 \cdot 10^{+96}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_2 + \cos \phi_1}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
   (if (<= phi1 1.2e-5)
     (+ lambda1 (atan2 t_0 (+ (* (cos phi2) (cos lambda2)) 1.0)))
     (if (<= phi1 3.1e+96)
       (+ lambda1 (atan2 t_0 (+ (cos phi1) (cos (- lambda1 lambda2)))))
       (+ lambda1 (atan2 t_0 (+ (cos phi2) (cos phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos(phi2) * sin((lambda1 - lambda2));
	double tmp;
	if (phi1 <= 1.2e-5) {
		tmp = lambda1 + atan2(t_0, ((cos(phi2) * cos(lambda2)) + 1.0));
	} else if (phi1 <= 3.1e+96) {
		tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2))));
	} else {
		tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = cos(phi2) * sin((lambda1 - lambda2))
    if (phi1 <= 1.2d-5) then
        tmp = lambda1 + atan2(t_0, ((cos(phi2) * cos(lambda2)) + 1.0d0))
    else if (phi1 <= 3.1d+96) then
        tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2))))
    else
        tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
	double tmp;
	if (phi1 <= 1.2e-5) {
		tmp = lambda1 + Math.atan2(t_0, ((Math.cos(phi2) * Math.cos(lambda2)) + 1.0));
	} else if (phi1 <= 3.1e+96) {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos((lambda1 - lambda2))));
	} else {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi2) + Math.cos(phi1)));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2))
	tmp = 0
	if phi1 <= 1.2e-5:
		tmp = lambda1 + math.atan2(t_0, ((math.cos(phi2) * math.cos(lambda2)) + 1.0))
	elif phi1 <= 3.1e+96:
		tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos((lambda1 - lambda2))))
	else:
		tmp = lambda1 + math.atan2(t_0, (math.cos(phi2) + math.cos(phi1)))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2)))
	tmp = 0.0
	if (phi1 <= 1.2e-5)
		tmp = Float64(lambda1 + atan(t_0, Float64(Float64(cos(phi2) * cos(lambda2)) + 1.0)));
	elseif (phi1 <= 3.1e+96)
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(Float64(lambda1 - lambda2)))));
	else
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi2) + cos(phi1))));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = cos(phi2) * sin((lambda1 - lambda2));
	tmp = 0.0;
	if (phi1 <= 1.2e-5)
		tmp = lambda1 + atan2(t_0, ((cos(phi2) * cos(lambda2)) + 1.0));
	elseif (phi1 <= 3.1e+96)
		tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2))));
	else
		tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, 1.2e-5], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3.1e+96], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq 1.2 \cdot 10^{-5}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_2 \cdot \cos \lambda_2 + 1}\\

\mathbf{elif}\;\phi_1 \leq 3.1 \cdot 10^{+96}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_2 + \cos \phi_1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if phi1 < 1.2e-5

    1. Initial program 97.3%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6497.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified97.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \cos \lambda_2 \cdot \cos \phi_2\right)}\right)\right) \]
    7. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(1 + \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \cos \color{blue}{\phi_2}\right)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(1 + \cos \phi_2 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\cos \phi_2 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\cos \phi_2, \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
      5. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
      6. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      7. cos-lowering-cos.f6485.9%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    8. Simplified85.9%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1 + \cos \phi_2 \cdot \cos \lambda_2}} \]

    if 1.2e-5 < phi1 < 3.0999999999999998e96

    1. Initial program 97.5%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)\right)}\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \left(\lambda_1 - \lambda_2\right)}\right)\right)\right) \]
      2. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\left(\lambda_1 - \lambda_2\right)}\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\left(\lambda_1 - \lambda_2\right)\right)\right)\right)\right) \]
      4. --lowering--.f6490.3%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified90.3%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}} \]

    if 3.0999999999999998e96 < phi1

    1. Initial program 98.0%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6498.0%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified98.0%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in lambda2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(\cos \phi_1 + \cos \phi_2\right)}\right)\right) \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \phi_2 + \color{blue}{\cos \phi_1}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\cos \phi_2, \color{blue}{\cos \phi_1}\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \color{blue}{\phi_1}\right)\right)\right) \]
      4. cos-lowering-cos.f6480.1%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\phi_1\right)\right)\right)\right) \]
    8. Simplified80.1%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_2 + \cos \phi_1}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_1 \leq 1.2 \cdot 10^{-5}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_2 \cdot \cos \lambda_2 + 1}\\ \mathbf{elif}\;\phi_1 \leq 3.1 \cdot 10^{+96}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_2 + \cos \phi_1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 82.4% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_1 \leq 1.7 \cdot 10^{-5}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_2 \cdot \cos \lambda_2 + 1}\\ \mathbf{elif}\;\phi_1 \leq 3 \cdot 10^{+96}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \cos \phi_1}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_2 + \cos \phi_1}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
   (if (<= phi1 1.7e-5)
     (+ lambda1 (atan2 t_0 (+ (* (cos phi2) (cos lambda2)) 1.0)))
     (if (<= phi1 3e+96)
       (+ lambda1 (atan2 t_0 (+ (cos lambda2) (cos phi1))))
       (+ lambda1 (atan2 t_0 (+ (cos phi2) (cos phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos(phi2) * sin((lambda1 - lambda2));
	double tmp;
	if (phi1 <= 1.7e-5) {
		tmp = lambda1 + atan2(t_0, ((cos(phi2) * cos(lambda2)) + 1.0));
	} else if (phi1 <= 3e+96) {
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
	} else {
		tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = cos(phi2) * sin((lambda1 - lambda2))
    if (phi1 <= 1.7d-5) then
        tmp = lambda1 + atan2(t_0, ((cos(phi2) * cos(lambda2)) + 1.0d0))
    else if (phi1 <= 3d+96) then
        tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)))
    else
        tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
	double tmp;
	if (phi1 <= 1.7e-5) {
		tmp = lambda1 + Math.atan2(t_0, ((Math.cos(phi2) * Math.cos(lambda2)) + 1.0));
	} else if (phi1 <= 3e+96) {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda2) + Math.cos(phi1)));
	} else {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi2) + Math.cos(phi1)));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2))
	tmp = 0
	if phi1 <= 1.7e-5:
		tmp = lambda1 + math.atan2(t_0, ((math.cos(phi2) * math.cos(lambda2)) + 1.0))
	elif phi1 <= 3e+96:
		tmp = lambda1 + math.atan2(t_0, (math.cos(lambda2) + math.cos(phi1)))
	else:
		tmp = lambda1 + math.atan2(t_0, (math.cos(phi2) + math.cos(phi1)))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2)))
	tmp = 0.0
	if (phi1 <= 1.7e-5)
		tmp = Float64(lambda1 + atan(t_0, Float64(Float64(cos(phi2) * cos(lambda2)) + 1.0)));
	elseif (phi1 <= 3e+96)
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda2) + cos(phi1))));
	else
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi2) + cos(phi1))));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = cos(phi2) * sin((lambda1 - lambda2));
	tmp = 0.0;
	if (phi1 <= 1.7e-5)
		tmp = lambda1 + atan2(t_0, ((cos(phi2) * cos(lambda2)) + 1.0));
	elseif (phi1 <= 3e+96)
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
	else
		tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, 1.7e-5], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3e+96], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq 1.7 \cdot 10^{-5}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_2 \cdot \cos \lambda_2 + 1}\\

\mathbf{elif}\;\phi_1 \leq 3 \cdot 10^{+96}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \cos \phi_1}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_2 + \cos \phi_1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if phi1 < 1.7e-5

    1. Initial program 97.3%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6497.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified97.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \cos \lambda_2 \cdot \cos \phi_2\right)}\right)\right) \]
    7. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(1 + \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \cos \color{blue}{\phi_2}\right)\right)\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(1 + \cos \phi_2 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\cos \phi_2 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\cos \phi_2, \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
      5. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
      6. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      7. cos-lowering-cos.f6485.9%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    8. Simplified85.9%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1 + \cos \phi_2 \cdot \cos \lambda_2}} \]

    if 1.7e-5 < phi1 < 3e96

    1. Initial program 97.5%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6497.5%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified97.5%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(\cos \lambda_2 + \cos \phi_1\right)}\right)\right) \]
    7. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \color{blue}{\phi_1}\right)\right)\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \phi_1 + \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right) \]
      4. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right) \]
      5. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \lambda_2\right)\right)\right) \]
      6. cos-lowering-cos.f6490.3%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right) \]
    8. Simplified90.3%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \lambda_2}} \]

    if 3e96 < phi1

    1. Initial program 98.0%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6498.0%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified98.0%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in lambda2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(\cos \phi_1 + \cos \phi_2\right)}\right)\right) \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \left(\cos \phi_2 + \color{blue}{\cos \phi_1}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\cos \phi_2, \color{blue}{\cos \phi_1}\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \color{blue}{\phi_1}\right)\right)\right) \]
      4. cos-lowering-cos.f6480.1%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\phi_1\right)\right)\right)\right) \]
    8. Simplified80.1%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_2 + \cos \phi_1}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_1 \leq 1.7 \cdot 10^{-5}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_2 \cdot \cos \lambda_2 + 1}\\ \mathbf{elif}\;\phi_1 \leq 3 \cdot 10^{+96}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_2 + \cos \phi_1}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_2 + \cos \phi_1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 79.2% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\cos \phi_2 \leq 0.5:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{-0.001388888888888889 \cdot {\phi_1}^{6}}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \cos \phi_1}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (- lambda1 lambda2))))
   (if (<= (cos phi2) 0.5)
     (+
      lambda1
      (atan2 (* (cos phi2) t_0) (* -0.001388888888888889 (pow phi1 6.0))))
     (+ lambda1 (atan2 t_0 (+ (cos lambda2) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin((lambda1 - lambda2));
	double tmp;
	if (cos(phi2) <= 0.5) {
		tmp = lambda1 + atan2((cos(phi2) * t_0), (-0.001388888888888889 * pow(phi1, 6.0)));
	} else {
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin((lambda1 - lambda2))
    if (cos(phi2) <= 0.5d0) then
        tmp = lambda1 + atan2((cos(phi2) * t_0), ((-0.001388888888888889d0) * (phi1 ** 6.0d0)))
    else
        tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.sin((lambda1 - lambda2));
	double tmp;
	if (Math.cos(phi2) <= 0.5) {
		tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (-0.001388888888888889 * Math.pow(phi1, 6.0)));
	} else {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda2) + Math.cos(phi1)));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.sin((lambda1 - lambda2))
	tmp = 0
	if math.cos(phi2) <= 0.5:
		tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (-0.001388888888888889 * math.pow(phi1, 6.0)))
	else:
		tmp = lambda1 + math.atan2(t_0, (math.cos(lambda2) + math.cos(phi1)))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (cos(phi2) <= 0.5)
		tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(-0.001388888888888889 * (phi1 ^ 6.0))));
	else
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda2) + cos(phi1))));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = sin((lambda1 - lambda2));
	tmp = 0.0;
	if (cos(phi2) <= 0.5)
		tmp = lambda1 + atan2((cos(phi2) * t_0), (-0.001388888888888889 * (phi1 ^ 6.0)));
	else
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.5], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(-0.001388888888888889 * N[Power[phi1, 6.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.5:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{-0.001388888888888889 \cdot {\phi_1}^{6}}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \cos \phi_1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 phi2) < 0.5

    1. Initial program 94.3%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6494.3%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified94.3%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(1 + \left(\cos \lambda_2 \cdot \cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)}\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\cos \lambda_2 \cdot \cos \phi_2 + {\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right) \]
      2. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \cos \phi_2 + {\color{blue}{\phi_1}}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \left(\cos \phi_2 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\left(\cos \phi_2 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \color{blue}{\left({\phi_1}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)}\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\cos \phi_2, \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \left(\color{blue}{{\phi_1}^{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)\right), \left({\color{blue}{\phi_1}}^{2} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      7. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right), \left({\phi_1}^{\color{blue}{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      8. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \left({\phi_1}^{\color{blue}{2}} \cdot \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\left({\phi_1}^{2}\right), \color{blue}{\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) - \frac{1}{2}\right)}\right)\right)\right)\right)\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\left(\phi_1 \cdot \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\color{blue}{{\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      12. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right) + \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      14. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\left({\phi_1}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {\phi_1}^{2}\right)\right), \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified82.8%

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

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \color{blue}{\left(\frac{-1}{720} \cdot {\phi_1}^{6}\right)}\right)\right) \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{*.f64}\left(\frac{-1}{720}, \color{blue}{\left({\phi_1}^{6}\right)}\right)\right)\right) \]
      2. pow-lowering-pow.f6454.1%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{*.f64}\left(\frac{-1}{720}, \mathsf{pow.f64}\left(\phi_1, \color{blue}{6}\right)\right)\right)\right) \]
    11. Simplified54.1%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{-0.001388888888888889 \cdot {\phi_1}^{6}}} \]

    if 0.5 < (cos.f64 phi2)

    1. Initial program 99.1%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6499.0%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified99.0%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\left(\lambda_1 - \lambda_2\right)\right), \mathsf{+.f64}\left(\color{blue}{\mathsf{cos.f64}\left(\phi_1\right)}, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
      2. --lowering--.f6492.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    8. Simplified92.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \]
    9. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(\cos \lambda_2 + \cos \phi_1\right)}\right)\right) \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \phi_1 + \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\lambda_2}\right)\right)\right) \]
      4. cos-lowering-cos.f6492.3%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right) \]
    11. Simplified92.3%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \lambda_2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification79.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \phi_2 \leq 0.5:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{-0.001388888888888889 \cdot {\phi_1}^{6}}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_2 + \cos \phi_1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 21: 70.3% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\cos \phi_1 \leq 0.995:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + 1}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{1 + \left(\cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot 0.041666666666666664\right)\right)}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (- lambda1 lambda2))))
   (if (<= (cos phi1) 0.995)
     (+ lambda1 (atan2 t_0 (+ (cos phi1) 1.0)))
     (+
      lambda1
      (atan2
       t_0
       (+
        1.0
        (+
         (cos lambda2)
         (*
          (* phi1 phi1)
          (+ -0.5 (* (* phi1 phi1) 0.041666666666666664))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin((lambda1 - lambda2));
	double tmp;
	if (cos(phi1) <= 0.995) {
		tmp = lambda1 + atan2(t_0, (cos(phi1) + 1.0));
	} else {
		tmp = lambda1 + atan2(t_0, (1.0 + (cos(lambda2) + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * 0.041666666666666664))))));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin((lambda1 - lambda2))
    if (cos(phi1) <= 0.995d0) then
        tmp = lambda1 + atan2(t_0, (cos(phi1) + 1.0d0))
    else
        tmp = lambda1 + atan2(t_0, (1.0d0 + (cos(lambda2) + ((phi1 * phi1) * ((-0.5d0) + ((phi1 * phi1) * 0.041666666666666664d0))))))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.sin((lambda1 - lambda2));
	double tmp;
	if (Math.cos(phi1) <= 0.995) {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + 1.0));
	} else {
		tmp = lambda1 + Math.atan2(t_0, (1.0 + (Math.cos(lambda2) + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * 0.041666666666666664))))));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.sin((lambda1 - lambda2))
	tmp = 0
	if math.cos(phi1) <= 0.995:
		tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + 1.0))
	else:
		tmp = lambda1 + math.atan2(t_0, (1.0 + (math.cos(lambda2) + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * 0.041666666666666664))))))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (cos(phi1) <= 0.995)
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + 1.0)));
	else
		tmp = Float64(lambda1 + atan(t_0, Float64(1.0 + Float64(cos(lambda2) + Float64(Float64(phi1 * phi1) * Float64(-0.5 + Float64(Float64(phi1 * phi1) * 0.041666666666666664)))))));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = sin((lambda1 - lambda2));
	tmp = 0.0;
	if (cos(phi1) <= 0.995)
		tmp = lambda1 + atan2(t_0, (cos(phi1) + 1.0));
	else
		tmp = lambda1 + atan2(t_0, (1.0 + (cos(lambda2) + ((phi1 * phi1) * (-0.5 + ((phi1 * phi1) * 0.041666666666666664))))));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.995], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(1.0 + N[(N[Cos[lambda2], $MachinePrecision] + N[(N[(phi1 * phi1), $MachinePrecision] * N[(-0.5 + N[(N[(phi1 * phi1), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.995:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + 1}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{1 + \left(\cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot 0.041666666666666664\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 phi1) < 0.994999999999999996

    1. Initial program 95.8%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6495.6%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified95.6%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\left(\lambda_1 - \lambda_2\right)\right), \mathsf{+.f64}\left(\color{blue}{\mathsf{cos.f64}\left(\phi_1\right)}, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
      2. --lowering--.f6476.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    8. Simplified76.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \]
    9. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(\cos \lambda_2 + \cos \phi_1\right)}\right)\right) \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \phi_1 + \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\lambda_2}\right)\right)\right) \]
      4. cos-lowering-cos.f6474.9%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right) \]
    11. Simplified74.9%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \lambda_2}} \]
    12. Taylor expanded in lambda2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(1 + \cos \phi_1\right)}\right)\right) \]
    13. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \phi_1 + \color{blue}{1}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{1}\right)\right)\right) \]
      3. cos-lowering-cos.f6465.6%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), 1\right)\right)\right) \]
    14. Simplified65.6%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + 1}} \]

    if 0.994999999999999996 < (cos.f64 phi1)

    1. Initial program 98.9%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6498.9%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified98.9%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\left(\lambda_1 - \lambda_2\right)\right), \mathsf{+.f64}\left(\color{blue}{\mathsf{cos.f64}\left(\phi_1\right)}, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
      2. --lowering--.f6475.7%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    8. Simplified75.7%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \]
    9. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(\cos \lambda_2 + \cos \phi_1\right)}\right)\right) \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \phi_1 + \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\lambda_2}\right)\right)\right) \]
      4. cos-lowering-cos.f6475.7%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right) \]
    11. Simplified75.7%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \lambda_2}} \]
    12. Taylor expanded in phi1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(1 + \left(\cos \lambda_2 + {\phi_1}^{2} \cdot \left(\frac{1}{24} \cdot {\phi_1}^{2} - \frac{1}{2}\right)\right)\right)}\right)\right) \]
    13. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\cos \lambda_2 + {\phi_1}^{2} \cdot \left(\frac{1}{24} \cdot {\phi_1}^{2} - \frac{1}{2}\right)\right)}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\cos \lambda_2, \color{blue}{\left({\phi_1}^{2} \cdot \left(\frac{1}{24} \cdot {\phi_1}^{2} - \frac{1}{2}\right)\right)}\right)\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \left(\color{blue}{{\phi_1}^{2}} \cdot \left(\frac{1}{24} \cdot {\phi_1}^{2} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\left({\phi_1}^{2}\right), \color{blue}{\left(\frac{1}{24} \cdot {\phi_1}^{2} - \frac{1}{2}\right)}\right)\right)\right)\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\left(\phi_1 \cdot \phi_1\right), \left(\color{blue}{\frac{1}{24} \cdot {\phi_1}^{2}} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\color{blue}{\frac{1}{24} \cdot {\phi_1}^{2}} - \frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      7. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\frac{1}{24} \cdot {\phi_1}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \left(\frac{1}{24} \cdot {\phi_1}^{2} + \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\left(\frac{1}{24} \cdot {\phi_1}^{2}\right), \color{blue}{\frac{-1}{2}}\right)\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{24}, \left({\phi_1}^{2}\right)\right), \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      11. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{24}, \left(\phi_1 \cdot \phi_1\right)\right), \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f6475.7%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\phi_1, \phi_1\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\phi_1, \phi_1\right)\right), \frac{-1}{2}\right)\right)\right)\right)\right)\right) \]
    14. Simplified75.7%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1 + \left(\cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.041666666666666664 \cdot \left(\phi_1 \cdot \phi_1\right) + -0.5\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification71.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \phi_1 \leq 0.995:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + 1}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{1 + \left(\cos \lambda_2 + \left(\phi_1 \cdot \phi_1\right) \cdot \left(-0.5 + \left(\phi_1 \cdot \phi_1\right) \cdot 0.041666666666666664\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 22: 70.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\cos \phi_1 \leq 0.981:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + 1}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + 1}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (- lambda1 lambda2))))
   (if (<= (cos phi1) 0.981)
     (+ lambda1 (atan2 t_0 (+ (cos phi1) 1.0)))
     (+ lambda1 (atan2 t_0 (+ (cos lambda2) 1.0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin((lambda1 - lambda2));
	double tmp;
	if (cos(phi1) <= 0.981) {
		tmp = lambda1 + atan2(t_0, (cos(phi1) + 1.0));
	} else {
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + 1.0));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin((lambda1 - lambda2))
    if (cos(phi1) <= 0.981d0) then
        tmp = lambda1 + atan2(t_0, (cos(phi1) + 1.0d0))
    else
        tmp = lambda1 + atan2(t_0, (cos(lambda2) + 1.0d0))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.sin((lambda1 - lambda2));
	double tmp;
	if (Math.cos(phi1) <= 0.981) {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + 1.0));
	} else {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda2) + 1.0));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.sin((lambda1 - lambda2))
	tmp = 0
	if math.cos(phi1) <= 0.981:
		tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + 1.0))
	else:
		tmp = lambda1 + math.atan2(t_0, (math.cos(lambda2) + 1.0))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (cos(phi1) <= 0.981)
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + 1.0)));
	else
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda2) + 1.0)));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = sin((lambda1 - lambda2));
	tmp = 0.0;
	if (cos(phi1) <= 0.981)
		tmp = lambda1 + atan2(t_0, (cos(phi1) + 1.0));
	else
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + 1.0));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.981], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.981:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + 1}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + 1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 phi1) < 0.980999999999999983

    1. Initial program 95.7%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6495.5%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified95.5%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\left(\lambda_1 - \lambda_2\right)\right), \mathsf{+.f64}\left(\color{blue}{\mathsf{cos.f64}\left(\phi_1\right)}, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
      2. --lowering--.f6477.0%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    8. Simplified77.0%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \]
    9. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(\cos \lambda_2 + \cos \phi_1\right)}\right)\right) \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \phi_1 + \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\lambda_2}\right)\right)\right) \]
      4. cos-lowering-cos.f6475.6%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right) \]
    11. Simplified75.6%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \lambda_2}} \]
    12. Taylor expanded in lambda2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(1 + \cos \phi_1\right)}\right)\right) \]
    13. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \phi_1 + \color{blue}{1}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{1}\right)\right)\right) \]
      3. cos-lowering-cos.f6467.5%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), 1\right)\right)\right) \]
    14. Simplified67.5%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + 1}} \]

    if 0.980999999999999983 < (cos.f64 phi1)

    1. Initial program 98.9%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6498.9%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified98.9%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\left(\lambda_1 - \lambda_2\right)\right), \mathsf{+.f64}\left(\color{blue}{\mathsf{cos.f64}\left(\phi_1\right)}, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
      2. --lowering--.f6475.1%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    8. Simplified75.1%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \]
    9. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(\cos \lambda_2 + \cos \phi_1\right)}\right)\right) \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \phi_1 + \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\lambda_2}\right)\right)\right) \]
      4. cos-lowering-cos.f6475.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right) \]
    11. Simplified75.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \lambda_2}} \]
    12. Taylor expanded in phi1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(1 + \cos \lambda_2\right)}\right)\right) \]
    13. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \lambda_2 + \color{blue}{1}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \lambda_2, \color{blue}{1}\right)\right)\right) \]
      3. cos-lowering-cos.f6473.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), 1\right)\right)\right) \]
    14. Simplified73.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \lambda_2 + 1}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 23: 75.7% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_2 + \cos \phi_1} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (+ lambda1 (atan2 (sin (- lambda1 lambda2)) (+ (cos lambda2) (cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + atan2(sin((lambda1 - lambda2)), (cos(lambda2) + cos(phi1)));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(lambda2) + cos(phi1)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (Math.cos(lambda2) + Math.cos(phi1)));
}
def code(lambda1, lambda2, phi1, phi2):
	return lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (math.cos(lambda2) + math.cos(phi1)))
function code(lambda1, lambda2, phi1, phi2)
	return Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(cos(lambda2) + cos(phi1))))
end
function tmp = code(lambda1, lambda2, phi1, phi2)
	tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(lambda2) + cos(phi1)));
end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_2 + \cos \phi_1}
\end{array}
Derivation
  1. Initial program 97.4%

    \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in lambda1 around 0

    \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
  4. Step-by-step derivation
    1. cos-negN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
    2. cos-lowering-cos.f6497.4%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
  5. Simplified97.4%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
  6. Taylor expanded in phi2 around 0

    \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
  7. Step-by-step derivation
    1. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\left(\lambda_1 - \lambda_2\right)\right), \mathsf{+.f64}\left(\color{blue}{\mathsf{cos.f64}\left(\phi_1\right)}, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    2. --lowering--.f6476.0%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
  8. Simplified76.0%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \]
  9. Taylor expanded in phi2 around 0

    \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(\cos \lambda_2 + \cos \phi_1\right)}\right)\right) \]
  10. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \phi_1 + \color{blue}{\cos \lambda_2}\right)\right)\right) \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \lambda_2}\right)\right)\right) \]
    3. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\lambda_2}\right)\right)\right) \]
    4. cos-lowering-cos.f6475.3%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right) \]
  11. Simplified75.3%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \lambda_2}} \]
  12. Final simplification75.3%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_2 + \cos \phi_1} \]
  13. Add Preprocessing

Alternative 24: 67.8% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_1 \leq 2.8:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \left(1 + -0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + 1}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (sin (- lambda1 lambda2))))
   (if (<= phi1 2.8)
     (+ lambda1 (atan2 t_0 (+ (cos lambda2) (+ 1.0 (* -0.5 (* phi1 phi1))))))
     (+ lambda1 (atan2 t_0 (+ (cos phi1) 1.0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin((lambda1 - lambda2));
	double tmp;
	if (phi1 <= 2.8) {
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + (1.0 + (-0.5 * (phi1 * phi1)))));
	} else {
		tmp = lambda1 + atan2(t_0, (cos(phi1) + 1.0));
	}
	return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin((lambda1 - lambda2))
    if (phi1 <= 2.8d0) then
        tmp = lambda1 + atan2(t_0, (cos(lambda2) + (1.0d0 + ((-0.5d0) * (phi1 * phi1)))))
    else
        tmp = lambda1 + atan2(t_0, (cos(phi1) + 1.0d0))
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.sin((lambda1 - lambda2));
	double tmp;
	if (phi1 <= 2.8) {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda2) + (1.0 + (-0.5 * (phi1 * phi1)))));
	} else {
		tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + 1.0));
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.sin((lambda1 - lambda2))
	tmp = 0
	if phi1 <= 2.8:
		tmp = lambda1 + math.atan2(t_0, (math.cos(lambda2) + (1.0 + (-0.5 * (phi1 * phi1)))))
	else:
		tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + 1.0))
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = sin(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (phi1 <= 2.8)
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda2) + Float64(1.0 + Float64(-0.5 * Float64(phi1 * phi1))))));
	else
		tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + 1.0)));
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = sin((lambda1 - lambda2));
	tmp = 0.0;
	if (phi1 <= 2.8)
		tmp = lambda1 + atan2(t_0, (cos(lambda2) + (1.0 + (-0.5 * (phi1 * phi1)))));
	else
		tmp = lambda1 + atan2(t_0, (cos(phi1) + 1.0));
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, 2.8], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] + N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq 2.8:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_2 + \left(1 + -0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + 1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi1 < 2.7999999999999998

    1. Initial program 97.3%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6497.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified97.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\left(\lambda_1 - \lambda_2\right)\right), \mathsf{+.f64}\left(\color{blue}{\mathsf{cos.f64}\left(\phi_1\right)}, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
      2. --lowering--.f6474.7%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    8. Simplified74.7%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \]
    9. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(\cos \lambda_2 + \cos \phi_1\right)}\right)\right) \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \phi_1 + \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\lambda_2}\right)\right)\right) \]
      4. cos-lowering-cos.f6473.8%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right) \]
    11. Simplified73.8%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \lambda_2}} \]
    12. Taylor expanded in phi1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(1 + \left(\cos \lambda_2 + \frac{-1}{2} \cdot {\phi_1}^{2}\right)\right)}\right)\right) \]
    13. Step-by-step derivation
      1. associate-+r+N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\left(1 + \cos \lambda_2\right) + \color{blue}{\frac{-1}{2} \cdot {\phi_1}^{2}}\right)\right)\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\left(\cos \lambda_2 + 1\right) + \color{blue}{\frac{-1}{2}} \cdot {\phi_1}^{2}\right)\right)\right) \]
      3. associate-+l+N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \lambda_2 + \color{blue}{\left(1 + \frac{-1}{2} \cdot {\phi_1}^{2}\right)}\right)\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \lambda_2, \color{blue}{\left(1 + \frac{-1}{2} \cdot {\phi_1}^{2}\right)}\right)\right)\right) \]
      5. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {\phi_1}^{2}\right)\right)\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {\phi_1}^{2}\right)}\right)\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({\phi_1}^{2}\right)}\right)\right)\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(\phi_1 \cdot \color{blue}{\phi_1}\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f6470.2%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(\phi_1, \color{blue}{\phi_1}\right)\right)\right)\right)\right)\right) \]
    14. Simplified70.2%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \lambda_2 + \left(1 + -0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right)}} \]

    if 2.7999999999999998 < phi1

    1. Initial program 97.9%

      \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in lambda1 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
    4. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
      2. cos-lowering-cos.f6497.9%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    5. Simplified97.9%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
    6. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\left(\lambda_1 - \lambda_2\right)\right), \mathsf{+.f64}\left(\color{blue}{\mathsf{cos.f64}\left(\phi_1\right)}, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
      2. --lowering--.f6480.1%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    8. Simplified80.1%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \]
    9. Taylor expanded in phi2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(\cos \lambda_2 + \cos \phi_1\right)}\right)\right) \]
    10. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \phi_1 + \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \lambda_2}\right)\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\lambda_2}\right)\right)\right) \]
      4. cos-lowering-cos.f6480.3%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right) \]
    11. Simplified80.3%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \lambda_2}} \]
    12. Taylor expanded in lambda2 around 0

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(1 + \cos \phi_1\right)}\right)\right) \]
    13. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \phi_1 + \color{blue}{1}\right)\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{1}\right)\right)\right) \]
      3. cos-lowering-cos.f6470.1%

        \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), 1\right)\right)\right) \]
    14. Simplified70.1%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + 1}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 25: 65.8% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_2 + 1} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (+ lambda1 (atan2 (sin (- lambda1 lambda2)) (+ (cos lambda2) 1.0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + atan2(sin((lambda1 - lambda2)), (cos(lambda2) + 1.0));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(lambda2) + 1.0d0))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (Math.cos(lambda2) + 1.0));
}
def code(lambda1, lambda2, phi1, phi2):
	return lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (math.cos(lambda2) + 1.0))
function code(lambda1, lambda2, phi1, phi2)
	return Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(cos(lambda2) + 1.0)))
end
function tmp = code(lambda1, lambda2, phi1, phi2)
	tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(lambda2) + 1.0));
end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_2 + 1}
\end{array}
Derivation
  1. Initial program 97.4%

    \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in lambda1 around 0

    \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}\right)\right)\right)\right) \]
  4. Step-by-step derivation
    1. cos-negN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \cos \lambda_2\right)\right)\right)\right) \]
    2. cos-lowering-cos.f6497.4%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
  5. Simplified97.4%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \color{blue}{\cos \lambda_2}} \]
  6. Taylor expanded in phi2 around 0

    \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
  7. Step-by-step derivation
    1. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\left(\lambda_1 - \lambda_2\right)\right), \mathsf{+.f64}\left(\color{blue}{\mathsf{cos.f64}\left(\phi_1\right)}, \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
    2. --lowering--.f6476.0%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\phi_1}\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\phi_2\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right)\right) \]
  8. Simplified76.0%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2} \]
  9. Taylor expanded in phi2 around 0

    \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(\cos \lambda_2 + \cos \phi_1\right)}\right)\right) \]
  10. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \phi_1 + \color{blue}{\cos \lambda_2}\right)\right)\right) \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \phi_1, \color{blue}{\cos \lambda_2}\right)\right)\right) \]
    3. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \cos \color{blue}{\lambda_2}\right)\right)\right) \]
    4. cos-lowering-cos.f6475.3%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\phi_1\right), \mathsf{cos.f64}\left(\lambda_2\right)\right)\right)\right) \]
  11. Simplified75.3%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \phi_1 + \cos \lambda_2}} \]
  12. Taylor expanded in phi1 around 0

    \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \color{blue}{\left(1 + \cos \lambda_2\right)}\right)\right) \]
  13. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \left(\cos \lambda_2 + \color{blue}{1}\right)\right)\right) \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\cos \lambda_2, \color{blue}{1}\right)\right)\right) \]
    3. cos-lowering-cos.f6467.5%

      \[\leadsto \mathsf{+.f64}\left(\lambda_1, \mathsf{atan2.f64}\left(\mathsf{sin.f64}\left(\mathsf{\_.f64}\left(\lambda_1, \lambda_2\right)\right), \mathsf{+.f64}\left(\mathsf{cos.f64}\left(\lambda_2\right), 1\right)\right)\right) \]
  14. Simplified67.5%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{\cos \lambda_2 + 1}} \]
  15. Add Preprocessing

Alternative 26: 51.5% accurate, 614.0× speedup?

\[\begin{array}{l} \\ \lambda_1 \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 lambda1)
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = lambda1
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	return lambda1;
}
def code(lambda1, lambda2, phi1, phi2):
	return lambda1
function code(lambda1, lambda2, phi1, phi2)
	return lambda1
end
function tmp = code(lambda1, lambda2, phi1, phi2)
	tmp = lambda1;
end
code[lambda1_, lambda2_, phi1_, phi2_] := lambda1
\begin{array}{l}

\\
\lambda_1
\end{array}
Derivation
  1. Initial program 97.4%

    \[\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in lambda1 around inf

    \[\leadsto \color{blue}{\lambda_1} \]
  4. Step-by-step derivation
    1. Simplified51.6%

      \[\leadsto \color{blue}{\lambda_1} \]
    2. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2024192 
    (FPCore (lambda1 lambda2 phi1 phi2)
      :name "Midpoint on a great circle"
      :precision binary64
      (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))