Destination given bearing on a great circle

Percentage Accurate: 99.7% → 99.8%
Time: 20.2s
Alternatives: 20
Speedup: 1.3×

Specification

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

\\
\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\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 20 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: 99.7% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.3× speedup?

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

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

    \[\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)} \]
  2. Add Preprocessing
  3. Applied egg-rr99.8%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{fma}\left(\left(-\sin \phi_1\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(-\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \phi_1\right)\right) \cdot \cos delta\right) + \cos delta\right)}} \]
  4. Step-by-step derivation
    1. distribute-lft-neg-inN/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \color{blue}{\left(\mathsf{neg}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right)\right) \cdot \cos delta} + \cos delta\right)} \]
    2. distribute-lft1-inN/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \color{blue}{\left(\left(\mathsf{neg}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right)\right) + 1\right) \cdot \cos delta}\right)} \]
    3. *-lowering-*.f64N/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \color{blue}{\left(\left(\mathsf{neg}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right)\right) + 1\right) \cdot \cos delta}\right)} \]
    4. +-lowering-+.f64N/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \color{blue}{\left(\left(\mathsf{neg}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right)\right) + 1\right)} \cdot \cos delta\right)} \]
    5. neg-lowering-neg.f64N/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\color{blue}{\left(\mathsf{neg}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right)\right)} + 1\right) \cdot \cos delta\right)} \]
    6. sub-negN/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\color{blue}{\left(\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right)\right)}\right)\right) + 1\right) \cdot \cos delta\right)} \]
    7. +-commutativeN/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right) + \frac{1}{2}\right)}\right)\right) + 1\right) \cdot \cos delta\right)} \]
    8. *-commutativeN/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(\color{blue}{\cos \left(2 \cdot \phi_1\right) \cdot \frac{1}{2}}\right)\right) + \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta\right)} \]
    9. distribute-rgt-neg-inN/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\left(\color{blue}{\cos \left(2 \cdot \phi_1\right) \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} + \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta\right)} \]
    10. accelerator-lowering-fma.f64N/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\color{blue}{\mathsf{fma}\left(\cos \left(2 \cdot \phi_1\right), \mathsf{neg}\left(\frac{1}{2}\right), \frac{1}{2}\right)}\right)\right) + 1\right) \cdot \cos delta\right)} \]
    11. cos-2N/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\mathsf{fma}\left(\color{blue}{\cos \phi_1 \cdot \cos \phi_1 - \sin \phi_1 \cdot \sin \phi_1}, \mathsf{neg}\left(\frac{1}{2}\right), \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta\right)} \]
    12. cos-sumN/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\mathsf{fma}\left(\color{blue}{\cos \left(\phi_1 + \phi_1\right)}, \mathsf{neg}\left(\frac{1}{2}\right), \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta\right)} \]
    13. cos-lowering-cos.f64N/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\mathsf{fma}\left(\color{blue}{\cos \left(\phi_1 + \phi_1\right)}, \mathsf{neg}\left(\frac{1}{2}\right), \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta\right)} \]
    14. +-lowering-+.f64N/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\mathsf{fma}\left(\cos \color{blue}{\left(\phi_1 + \phi_1\right)}, \mathsf{neg}\left(\frac{1}{2}\right), \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta\right)} \]
    15. metadata-evalN/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), \color{blue}{\frac{-1}{2}}, \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta\right)} \]
    16. cos-lowering-cos.f6499.8

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(-\sin \phi_1\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(-\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), -0.5, 0.5\right)\right) + 1\right) \cdot \color{blue}{\cos delta}\right)} \]
  5. Applied egg-rr99.8%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(-\sin \phi_1\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \color{blue}{\left(\left(-\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), -0.5, 0.5\right)\right) + 1\right) \cdot \cos delta}\right)} \]
  6. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \color{blue}{\tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta\right) \cdot \left(\cos \phi_1 \cdot \cos theta\right) + \left(\left(\mathsf{neg}\left(\left(\cos \left(\phi_1 + \phi_1\right) \cdot \frac{-1}{2} + \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta} + \lambda_1} \]
    2. +-lowering-+.f64N/A

      \[\leadsto \color{blue}{\tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta\right) \cdot \left(\cos \phi_1 \cdot \cos theta\right) + \left(\left(\mathsf{neg}\left(\left(\cos \left(\phi_1 + \phi_1\right) \cdot \frac{-1}{2} + \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta} + \lambda_1} \]
  7. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right), \cos delta, \sin delta \cdot \left(\left(-\sin \phi_1\right) \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right)\right)} + \lambda_1} \]
  8. Final simplification99.8%

    \[\leadsto \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right), \cos delta, -\sin delta \cdot \left(\sin \phi_1 \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right)\right)} + \lambda_1 \]
  9. Add Preprocessing

Alternative 2: 72.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := 1 - \phi_1 \cdot \phi_1\\ t_2 := \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)}\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-63}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{t\_1}\\ \mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\lambda_1\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{0.5 \cdot \left(\cos \left(theta - delta\right) - \cos \left(theta + delta\right)\right)}{t\_1}\\ \end{array} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (let* ((t_1 (- 1.0 (* phi1 phi1)))
        (t_2
         (atan2
          (* (cos phi1) (* (sin theta) (sin delta)))
          (-
           (cos delta)
           (*
            (sin phi1)
            (sin
             (asin
              (+
               (* (cos delta) (sin phi1))
               (* (cos theta) (* (sin delta) (cos phi1)))))))))))
   (if (<= t_2 -5e-63)
     (+ lambda1 (atan2 (* (sin theta) delta) t_1))
     (if (<= t_2 4e-79)
       lambda1
       (+
        lambda1
        (atan2
         (* 0.5 (- (cos (- theta delta)) (cos (+ theta delta))))
         t_1))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double t_1 = 1.0 - (phi1 * phi1);
	double t_2 = atan2((cos(phi1) * (sin(theta) * sin(delta))), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (sin(delta) * cos(phi1)))))))));
	double tmp;
	if (t_2 <= -5e-63) {
		tmp = lambda1 + atan2((sin(theta) * delta), t_1);
	} else if (t_2 <= 4e-79) {
		tmp = lambda1;
	} else {
		tmp = lambda1 + atan2((0.5 * (cos((theta - delta)) - cos((theta + delta)))), t_1);
	}
	return tmp;
}
real(8) function code(lambda1, phi1, phi2, delta, theta)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8), intent (in) :: delta
    real(8), intent (in) :: theta
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = 1.0d0 - (phi1 * phi1)
    t_2 = atan2((cos(phi1) * (sin(theta) * sin(delta))), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (sin(delta) * cos(phi1)))))))))
    if (t_2 <= (-5d-63)) then
        tmp = lambda1 + atan2((sin(theta) * delta), t_1)
    else if (t_2 <= 4d-79) then
        tmp = lambda1
    else
        tmp = lambda1 + atan2((0.5d0 * (cos((theta - delta)) - cos((theta + delta)))), t_1)
    end if
    code = tmp
end function
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double t_1 = 1.0 - (phi1 * phi1);
	double t_2 = Math.atan2((Math.cos(phi1) * (Math.sin(theta) * Math.sin(delta))), (Math.cos(delta) - (Math.sin(phi1) * Math.sin(Math.asin(((Math.cos(delta) * Math.sin(phi1)) + (Math.cos(theta) * (Math.sin(delta) * Math.cos(phi1)))))))));
	double tmp;
	if (t_2 <= -5e-63) {
		tmp = lambda1 + Math.atan2((Math.sin(theta) * delta), t_1);
	} else if (t_2 <= 4e-79) {
		tmp = lambda1;
	} else {
		tmp = lambda1 + Math.atan2((0.5 * (Math.cos((theta - delta)) - Math.cos((theta + delta)))), t_1);
	}
	return tmp;
}
def code(lambda1, phi1, phi2, delta, theta):
	t_1 = 1.0 - (phi1 * phi1)
	t_2 = math.atan2((math.cos(phi1) * (math.sin(theta) * math.sin(delta))), (math.cos(delta) - (math.sin(phi1) * math.sin(math.asin(((math.cos(delta) * math.sin(phi1)) + (math.cos(theta) * (math.sin(delta) * math.cos(phi1)))))))))
	tmp = 0
	if t_2 <= -5e-63:
		tmp = lambda1 + math.atan2((math.sin(theta) * delta), t_1)
	elif t_2 <= 4e-79:
		tmp = lambda1
	else:
		tmp = lambda1 + math.atan2((0.5 * (math.cos((theta - delta)) - math.cos((theta + delta)))), t_1)
	return tmp
function code(lambda1, phi1, phi2, delta, theta)
	t_1 = Float64(1.0 - Float64(phi1 * phi1))
	t_2 = atan(Float64(cos(phi1) * Float64(sin(theta) * sin(delta))), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(cos(delta) * sin(phi1)) + Float64(cos(theta) * Float64(sin(delta) * cos(phi1)))))))))
	tmp = 0.0
	if (t_2 <= -5e-63)
		tmp = Float64(lambda1 + atan(Float64(sin(theta) * delta), t_1));
	elseif (t_2 <= 4e-79)
		tmp = lambda1;
	else
		tmp = Float64(lambda1 + atan(Float64(0.5 * Float64(cos(Float64(theta - delta)) - cos(Float64(theta + delta)))), t_1));
	end
	return tmp
end
function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
	t_1 = 1.0 - (phi1 * phi1);
	t_2 = atan2((cos(phi1) * (sin(theta) * sin(delta))), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (sin(delta) * cos(phi1)))))))));
	tmp = 0.0;
	if (t_2 <= -5e-63)
		tmp = lambda1 + atan2((sin(theta) * delta), t_1);
	elseif (t_2 <= 4e-79)
		tmp = lambda1;
	else
		tmp = lambda1 + atan2((0.5 * (cos((theta - delta)) - cos((theta + delta)))), t_1);
	end
	tmp_2 = tmp;
end
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(1.0 - N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[theta], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, -5e-63], N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * delta), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 4e-79], lambda1, N[(lambda1 + N[ArcTan[N[(0.5 * N[(N[Cos[N[(theta - delta), $MachinePrecision]], $MachinePrecision] - N[Cos[N[(theta + delta), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := 1 - \phi_1 \cdot \phi_1\\
t_2 := \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)}\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{-63}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{t\_1}\\

\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-79}:\\
\;\;\;\;\lambda_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < -5.0000000000000002e-63

    1. Initial program 99.7%

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

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\phi_1 \cdot \left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) + \cos delta}} \]
      2. *-commutativeN/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) \cdot \phi_1} + \cos delta} \]
      3. sub-negN/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
      4. mul-1-negN/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\color{blue}{\left(\mathsf{neg}\left(\phi_1 \cdot \cos delta\right)\right)} + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right) \cdot \phi_1 + \cos delta} \]
      5. distribute-neg-outN/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
      6. distribute-lft-neg-outN/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \phi_1\right)\right)} + \cos delta} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \left(\mathsf{neg}\left(\phi_1\right)\right)} + \cos delta} \]
      8. mul-1-negN/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \color{blue}{\left(-1 \cdot \phi_1\right)} + \cos delta} \]
      9. accelerator-lowering-fma.f64N/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{fma}\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta, -1 \cdot \phi_1, \cos delta\right)}} \]
    5. Simplified75.2%

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

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 + -1 \cdot {\phi_1}^{2}}} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 + \color{blue}{\left(\mathsf{neg}\left({\phi_1}^{2}\right)\right)}} \]
      2. unsub-negN/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
      3. --lowering--.f64N/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
      4. unpow2N/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
      5. *-lowering-*.f6464.8

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
    8. Simplified64.8%

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

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
      2. sin-lowering-sin.f64N/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta} \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
      3. sin-lowering-sin.f6458.0

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{1 - \phi_1 \cdot \phi_1} \]
    11. Simplified58.0%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
    12. Taylor expanded in delta around 0

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
    13. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
      2. sin-lowering-sin.f6459.6

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{delta \cdot \color{blue}{\sin theta}}{1 - \phi_1 \cdot \phi_1} \]
    14. Simplified59.6%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]

    if -5.0000000000000002e-63 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < 4e-79

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{\lambda_1} \]
    4. Step-by-step derivation
      1. Simplified87.7%

        \[\leadsto \color{blue}{\lambda_1} \]

      if 4e-79 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta))))))))

      1. Initial program 99.8%

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

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

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\phi_1 \cdot \left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) + \cos delta}} \]
        2. *-commutativeN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) \cdot \phi_1} + \cos delta} \]
        3. sub-negN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
        4. mul-1-negN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\color{blue}{\left(\mathsf{neg}\left(\phi_1 \cdot \cos delta\right)\right)} + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right) \cdot \phi_1 + \cos delta} \]
        5. distribute-neg-outN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
        6. distribute-lft-neg-outN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \phi_1\right)\right)} + \cos delta} \]
        7. distribute-rgt-neg-inN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \left(\mathsf{neg}\left(\phi_1\right)\right)} + \cos delta} \]
        8. mul-1-negN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \color{blue}{\left(-1 \cdot \phi_1\right)} + \cos delta} \]
        9. accelerator-lowering-fma.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{fma}\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta, -1 \cdot \phi_1, \cos delta\right)}} \]
      5. Simplified81.4%

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 + -1 \cdot {\phi_1}^{2}}} \]
      7. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 + \color{blue}{\left(\mathsf{neg}\left({\phi_1}^{2}\right)\right)}} \]
        2. unsub-negN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
        3. --lowering--.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
        4. unpow2N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
        5. *-lowering-*.f6470.0

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
      8. Simplified70.0%

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
      10. Step-by-step derivation
        1. *-lowering-*.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
        2. sin-lowering-sin.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta} \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
        3. sin-lowering-sin.f6462.3

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{1 - \phi_1 \cdot \phi_1} \]
      11. Simplified62.3%

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
      12. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin theta \cdot \sin delta}}{1 - \phi_1 \cdot \phi_1} \]
        2. sin-multN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\frac{\cos \left(theta - delta\right) - \cos \left(theta + delta\right)}{2}}}{1 - \phi_1 \cdot \phi_1} \]
        3. div-invN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\left(\cos \left(theta - delta\right) - \cos \left(theta + delta\right)\right) \cdot \frac{1}{2}}}{1 - \phi_1 \cdot \phi_1} \]
        4. metadata-evalN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\cos \left(theta - delta\right) - \cos \left(theta + delta\right)\right) \cdot \color{blue}{\frac{1}{2}}}{1 - \phi_1 \cdot \phi_1} \]
        5. *-lowering-*.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\left(\cos \left(theta - delta\right) - \cos \left(theta + delta\right)\right) \cdot \frac{1}{2}}}{1 - \phi_1 \cdot \phi_1} \]
        6. --lowering--.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\left(\cos \left(theta - delta\right) - \cos \left(theta + delta\right)\right)} \cdot \frac{1}{2}}{1 - \phi_1 \cdot \phi_1} \]
        7. cos-lowering-cos.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\color{blue}{\cos \left(theta - delta\right)} - \cos \left(theta + delta\right)\right) \cdot \frac{1}{2}}{1 - \phi_1 \cdot \phi_1} \]
        8. --lowering--.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\cos \color{blue}{\left(theta - delta\right)} - \cos \left(theta + delta\right)\right) \cdot \frac{1}{2}}{1 - \phi_1 \cdot \phi_1} \]
        9. cos-lowering-cos.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\cos \left(theta - delta\right) - \color{blue}{\cos \left(theta + delta\right)}\right) \cdot \frac{1}{2}}{1 - \phi_1 \cdot \phi_1} \]
        10. +-lowering-+.f6465.4

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\cos \left(theta - delta\right) - \cos \color{blue}{\left(theta + delta\right)}\right) \cdot 0.5}{1 - \phi_1 \cdot \phi_1} \]
      13. Applied egg-rr65.4%

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\left(\cos \left(theta - delta\right) - \cos \left(theta + delta\right)\right) \cdot 0.5}}{1 - \phi_1 \cdot \phi_1} \]
    5. Recombined 3 regimes into one program.
    6. Final simplification75.0%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)} \leq -5 \cdot 10^{-63}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{1 - \phi_1 \cdot \phi_1}\\ \mathbf{elif}\;\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)} \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\lambda_1\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{0.5 \cdot \left(\cos \left(theta - delta\right) - \cos \left(theta + delta\right)\right)}{1 - \phi_1 \cdot \phi_1}\\ \end{array} \]
    7. Add Preprocessing

    Alternative 3: 72.6% accurate, 0.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := 1 - \phi_1 \cdot \phi_1\\ t_2 := \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)}\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-63}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{t\_1}\\ \mathbf{elif}\;t\_2 \leq 0.45:\\ \;\;\;\;\lambda_1\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(theta \cdot \sin delta\right)}{t\_1}\\ \end{array} \end{array} \]
    (FPCore (lambda1 phi1 phi2 delta theta)
     :precision binary64
     (let* ((t_1 (- 1.0 (* phi1 phi1)))
            (t_2
             (atan2
              (* (cos phi1) (* (sin theta) (sin delta)))
              (-
               (cos delta)
               (*
                (sin phi1)
                (sin
                 (asin
                  (+
                   (* (cos delta) (sin phi1))
                   (* (cos theta) (* (sin delta) (cos phi1)))))))))))
       (if (<= t_2 -5e-63)
         (+ lambda1 (atan2 (* (sin theta) delta) t_1))
         (if (<= t_2 0.45)
           lambda1
           (+ lambda1 (atan2 (* (cos phi1) (* theta (sin delta))) t_1))))))
    double code(double lambda1, double phi1, double phi2, double delta, double theta) {
    	double t_1 = 1.0 - (phi1 * phi1);
    	double t_2 = atan2((cos(phi1) * (sin(theta) * sin(delta))), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (sin(delta) * cos(phi1)))))))));
    	double tmp;
    	if (t_2 <= -5e-63) {
    		tmp = lambda1 + atan2((sin(theta) * delta), t_1);
    	} else if (t_2 <= 0.45) {
    		tmp = lambda1;
    	} else {
    		tmp = lambda1 + atan2((cos(phi1) * (theta * sin(delta))), t_1);
    	}
    	return tmp;
    }
    
    real(8) function code(lambda1, phi1, phi2, delta, theta)
        real(8), intent (in) :: lambda1
        real(8), intent (in) :: phi1
        real(8), intent (in) :: phi2
        real(8), intent (in) :: delta
        real(8), intent (in) :: theta
        real(8) :: t_1
        real(8) :: t_2
        real(8) :: tmp
        t_1 = 1.0d0 - (phi1 * phi1)
        t_2 = atan2((cos(phi1) * (sin(theta) * sin(delta))), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (sin(delta) * cos(phi1)))))))))
        if (t_2 <= (-5d-63)) then
            tmp = lambda1 + atan2((sin(theta) * delta), t_1)
        else if (t_2 <= 0.45d0) then
            tmp = lambda1
        else
            tmp = lambda1 + atan2((cos(phi1) * (theta * sin(delta))), t_1)
        end if
        code = tmp
    end function
    
    public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
    	double t_1 = 1.0 - (phi1 * phi1);
    	double t_2 = Math.atan2((Math.cos(phi1) * (Math.sin(theta) * Math.sin(delta))), (Math.cos(delta) - (Math.sin(phi1) * Math.sin(Math.asin(((Math.cos(delta) * Math.sin(phi1)) + (Math.cos(theta) * (Math.sin(delta) * Math.cos(phi1)))))))));
    	double tmp;
    	if (t_2 <= -5e-63) {
    		tmp = lambda1 + Math.atan2((Math.sin(theta) * delta), t_1);
    	} else if (t_2 <= 0.45) {
    		tmp = lambda1;
    	} else {
    		tmp = lambda1 + Math.atan2((Math.cos(phi1) * (theta * Math.sin(delta))), t_1);
    	}
    	return tmp;
    }
    
    def code(lambda1, phi1, phi2, delta, theta):
    	t_1 = 1.0 - (phi1 * phi1)
    	t_2 = math.atan2((math.cos(phi1) * (math.sin(theta) * math.sin(delta))), (math.cos(delta) - (math.sin(phi1) * math.sin(math.asin(((math.cos(delta) * math.sin(phi1)) + (math.cos(theta) * (math.sin(delta) * math.cos(phi1)))))))))
    	tmp = 0
    	if t_2 <= -5e-63:
    		tmp = lambda1 + math.atan2((math.sin(theta) * delta), t_1)
    	elif t_2 <= 0.45:
    		tmp = lambda1
    	else:
    		tmp = lambda1 + math.atan2((math.cos(phi1) * (theta * math.sin(delta))), t_1)
    	return tmp
    
    function code(lambda1, phi1, phi2, delta, theta)
    	t_1 = Float64(1.0 - Float64(phi1 * phi1))
    	t_2 = atan(Float64(cos(phi1) * Float64(sin(theta) * sin(delta))), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(cos(delta) * sin(phi1)) + Float64(cos(theta) * Float64(sin(delta) * cos(phi1)))))))))
    	tmp = 0.0
    	if (t_2 <= -5e-63)
    		tmp = Float64(lambda1 + atan(Float64(sin(theta) * delta), t_1));
    	elseif (t_2 <= 0.45)
    		tmp = lambda1;
    	else
    		tmp = Float64(lambda1 + atan(Float64(cos(phi1) * Float64(theta * sin(delta))), t_1));
    	end
    	return tmp
    end
    
    function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
    	t_1 = 1.0 - (phi1 * phi1);
    	t_2 = atan2((cos(phi1) * (sin(theta) * sin(delta))), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (sin(delta) * cos(phi1)))))))));
    	tmp = 0.0;
    	if (t_2 <= -5e-63)
    		tmp = lambda1 + atan2((sin(theta) * delta), t_1);
    	elseif (t_2 <= 0.45)
    		tmp = lambda1;
    	else
    		tmp = lambda1 + atan2((cos(phi1) * (theta * sin(delta))), t_1);
    	end
    	tmp_2 = tmp;
    end
    
    code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(1.0 - N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[theta], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, -5e-63], N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * delta), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.45], lambda1, N[(lambda1 + N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(theta * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := 1 - \phi_1 \cdot \phi_1\\
    t_2 := \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)}\\
    \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-63}:\\
    \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{t\_1}\\
    
    \mathbf{elif}\;t\_2 \leq 0.45:\\
    \;\;\;\;\lambda_1\\
    
    \mathbf{else}:\\
    \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(theta \cdot \sin delta\right)}{t\_1}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < -5.0000000000000002e-63

      1. Initial program 99.7%

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

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

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\phi_1 \cdot \left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) + \cos delta}} \]
        2. *-commutativeN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) \cdot \phi_1} + \cos delta} \]
        3. sub-negN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
        4. mul-1-negN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\color{blue}{\left(\mathsf{neg}\left(\phi_1 \cdot \cos delta\right)\right)} + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right) \cdot \phi_1 + \cos delta} \]
        5. distribute-neg-outN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
        6. distribute-lft-neg-outN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \phi_1\right)\right)} + \cos delta} \]
        7. distribute-rgt-neg-inN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \left(\mathsf{neg}\left(\phi_1\right)\right)} + \cos delta} \]
        8. mul-1-negN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \color{blue}{\left(-1 \cdot \phi_1\right)} + \cos delta} \]
        9. accelerator-lowering-fma.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{fma}\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta, -1 \cdot \phi_1, \cos delta\right)}} \]
      5. Simplified75.2%

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 + -1 \cdot {\phi_1}^{2}}} \]
      7. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 + \color{blue}{\left(\mathsf{neg}\left({\phi_1}^{2}\right)\right)}} \]
        2. unsub-negN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
        3. --lowering--.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
        4. unpow2N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
        5. *-lowering-*.f6464.8

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
      8. Simplified64.8%

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
      10. Step-by-step derivation
        1. *-lowering-*.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
        2. sin-lowering-sin.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta} \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
        3. sin-lowering-sin.f6458.0

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{1 - \phi_1 \cdot \phi_1} \]
      11. Simplified58.0%

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
      12. Taylor expanded in delta around 0

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
      13. Step-by-step derivation
        1. *-lowering-*.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
        2. sin-lowering-sin.f6459.6

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{delta \cdot \color{blue}{\sin theta}}{1 - \phi_1 \cdot \phi_1} \]
      14. Simplified59.6%

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]

      if -5.0000000000000002e-63 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < 0.450000000000000011

      1. Initial program 99.8%

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

        \[\leadsto \color{blue}{\lambda_1} \]
      4. Step-by-step derivation
        1. Simplified84.4%

          \[\leadsto \color{blue}{\lambda_1} \]

        if 0.450000000000000011 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta))))))))

        1. Initial program 99.9%

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

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

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\phi_1 \cdot \left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) + \cos delta}} \]
          2. *-commutativeN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) \cdot \phi_1} + \cos delta} \]
          3. sub-negN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
          4. mul-1-negN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\color{blue}{\left(\mathsf{neg}\left(\phi_1 \cdot \cos delta\right)\right)} + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right) \cdot \phi_1 + \cos delta} \]
          5. distribute-neg-outN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
          6. distribute-lft-neg-outN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \phi_1\right)\right)} + \cos delta} \]
          7. distribute-rgt-neg-inN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \left(\mathsf{neg}\left(\phi_1\right)\right)} + \cos delta} \]
          8. mul-1-negN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \color{blue}{\left(-1 \cdot \phi_1\right)} + \cos delta} \]
          9. accelerator-lowering-fma.f64N/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{fma}\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta, -1 \cdot \phi_1, \cos delta\right)}} \]
        5. Simplified83.0%

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

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 + -1 \cdot {\phi_1}^{2}}} \]
        7. Step-by-step derivation
          1. mul-1-negN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 + \color{blue}{\left(\mathsf{neg}\left({\phi_1}^{2}\right)\right)}} \]
          2. unsub-negN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
          3. --lowering--.f64N/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
          4. unpow2N/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
          5. *-lowering-*.f6468.9

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
        8. Simplified68.9%

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

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

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\left(\sin delta \cdot theta\right)} \cdot \cos \phi_1}{1 - \phi_1 \cdot \phi_1} \]
          2. *-lowering-*.f64N/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\left(\sin delta \cdot theta\right)} \cdot \cos \phi_1}{1 - \phi_1 \cdot \phi_1} \]
          3. sin-lowering-sin.f6466.6

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\color{blue}{\sin delta} \cdot theta\right) \cdot \cos \phi_1}{1 - \phi_1 \cdot \phi_1} \]
        11. Simplified66.6%

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\left(\sin delta \cdot theta\right)} \cdot \cos \phi_1}{1 - \phi_1 \cdot \phi_1} \]
      5. Recombined 3 regimes into one program.
      6. Final simplification74.8%

        \[\leadsto \begin{array}{l} \mathbf{if}\;\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)} \leq -5 \cdot 10^{-63}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{1 - \phi_1 \cdot \phi_1}\\ \mathbf{elif}\;\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)} \leq 0.45:\\ \;\;\;\;\lambda_1\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(theta \cdot \sin delta\right)}{1 - \phi_1 \cdot \phi_1}\\ \end{array} \]
      7. Add Preprocessing

      Alternative 4: 72.9% accurate, 0.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_1 := 1 - \phi_1 \cdot \phi_1\\ t_2 := \sin theta \cdot \sin delta\\ t_3 := \tan^{-1}_* \frac{\cos \phi_1 \cdot t\_2}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)}\\ \mathbf{if}\;t\_3 \leq -5 \cdot 10^{-63}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{t\_1}\\ \mathbf{elif}\;t\_3 \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\lambda_1\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_2}{t\_1}\\ \end{array} \end{array} \]
      (FPCore (lambda1 phi1 phi2 delta theta)
       :precision binary64
       (let* ((t_1 (- 1.0 (* phi1 phi1)))
              (t_2 (* (sin theta) (sin delta)))
              (t_3
               (atan2
                (* (cos phi1) t_2)
                (-
                 (cos delta)
                 (*
                  (sin phi1)
                  (sin
                   (asin
                    (+
                     (* (cos delta) (sin phi1))
                     (* (cos theta) (* (sin delta) (cos phi1)))))))))))
         (if (<= t_3 -5e-63)
           (+ lambda1 (atan2 (* (sin theta) delta) t_1))
           (if (<= t_3 4e-79) lambda1 (+ lambda1 (atan2 t_2 t_1))))))
      double code(double lambda1, double phi1, double phi2, double delta, double theta) {
      	double t_1 = 1.0 - (phi1 * phi1);
      	double t_2 = sin(theta) * sin(delta);
      	double t_3 = atan2((cos(phi1) * t_2), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (sin(delta) * cos(phi1)))))))));
      	double tmp;
      	if (t_3 <= -5e-63) {
      		tmp = lambda1 + atan2((sin(theta) * delta), t_1);
      	} else if (t_3 <= 4e-79) {
      		tmp = lambda1;
      	} else {
      		tmp = lambda1 + atan2(t_2, t_1);
      	}
      	return tmp;
      }
      
      real(8) function code(lambda1, phi1, phi2, delta, theta)
          real(8), intent (in) :: lambda1
          real(8), intent (in) :: phi1
          real(8), intent (in) :: phi2
          real(8), intent (in) :: delta
          real(8), intent (in) :: theta
          real(8) :: t_1
          real(8) :: t_2
          real(8) :: t_3
          real(8) :: tmp
          t_1 = 1.0d0 - (phi1 * phi1)
          t_2 = sin(theta) * sin(delta)
          t_3 = atan2((cos(phi1) * t_2), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (sin(delta) * cos(phi1)))))))))
          if (t_3 <= (-5d-63)) then
              tmp = lambda1 + atan2((sin(theta) * delta), t_1)
          else if (t_3 <= 4d-79) then
              tmp = lambda1
          else
              tmp = lambda1 + atan2(t_2, t_1)
          end if
          code = tmp
      end function
      
      public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
      	double t_1 = 1.0 - (phi1 * phi1);
      	double t_2 = Math.sin(theta) * Math.sin(delta);
      	double t_3 = Math.atan2((Math.cos(phi1) * t_2), (Math.cos(delta) - (Math.sin(phi1) * Math.sin(Math.asin(((Math.cos(delta) * Math.sin(phi1)) + (Math.cos(theta) * (Math.sin(delta) * Math.cos(phi1)))))))));
      	double tmp;
      	if (t_3 <= -5e-63) {
      		tmp = lambda1 + Math.atan2((Math.sin(theta) * delta), t_1);
      	} else if (t_3 <= 4e-79) {
      		tmp = lambda1;
      	} else {
      		tmp = lambda1 + Math.atan2(t_2, t_1);
      	}
      	return tmp;
      }
      
      def code(lambda1, phi1, phi2, delta, theta):
      	t_1 = 1.0 - (phi1 * phi1)
      	t_2 = math.sin(theta) * math.sin(delta)
      	t_3 = math.atan2((math.cos(phi1) * t_2), (math.cos(delta) - (math.sin(phi1) * math.sin(math.asin(((math.cos(delta) * math.sin(phi1)) + (math.cos(theta) * (math.sin(delta) * math.cos(phi1)))))))))
      	tmp = 0
      	if t_3 <= -5e-63:
      		tmp = lambda1 + math.atan2((math.sin(theta) * delta), t_1)
      	elif t_3 <= 4e-79:
      		tmp = lambda1
      	else:
      		tmp = lambda1 + math.atan2(t_2, t_1)
      	return tmp
      
      function code(lambda1, phi1, phi2, delta, theta)
      	t_1 = Float64(1.0 - Float64(phi1 * phi1))
      	t_2 = Float64(sin(theta) * sin(delta))
      	t_3 = atan(Float64(cos(phi1) * t_2), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(cos(delta) * sin(phi1)) + Float64(cos(theta) * Float64(sin(delta) * cos(phi1)))))))))
      	tmp = 0.0
      	if (t_3 <= -5e-63)
      		tmp = Float64(lambda1 + atan(Float64(sin(theta) * delta), t_1));
      	elseif (t_3 <= 4e-79)
      		tmp = lambda1;
      	else
      		tmp = Float64(lambda1 + atan(t_2, t_1));
      	end
      	return tmp
      end
      
      function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
      	t_1 = 1.0 - (phi1 * phi1);
      	t_2 = sin(theta) * sin(delta);
      	t_3 = atan2((cos(phi1) * t_2), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (sin(delta) * cos(phi1)))))))));
      	tmp = 0.0;
      	if (t_3 <= -5e-63)
      		tmp = lambda1 + atan2((sin(theta) * delta), t_1);
      	elseif (t_3 <= 4e-79)
      		tmp = lambda1;
      	else
      		tmp = lambda1 + atan2(t_2, t_1);
      	end
      	tmp_2 = tmp;
      end
      
      code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(1.0 - N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[theta], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$3, -5e-63], N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * delta), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 4e-79], lambda1, N[(lambda1 + N[ArcTan[t$95$2 / t$95$1], $MachinePrecision]), $MachinePrecision]]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_1 := 1 - \phi_1 \cdot \phi_1\\
      t_2 := \sin theta \cdot \sin delta\\
      t_3 := \tan^{-1}_* \frac{\cos \phi_1 \cdot t\_2}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)}\\
      \mathbf{if}\;t\_3 \leq -5 \cdot 10^{-63}:\\
      \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{t\_1}\\
      
      \mathbf{elif}\;t\_3 \leq 4 \cdot 10^{-79}:\\
      \;\;\;\;\lambda_1\\
      
      \mathbf{else}:\\
      \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_2}{t\_1}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < -5.0000000000000002e-63

        1. Initial program 99.7%

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

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

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\phi_1 \cdot \left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) + \cos delta}} \]
          2. *-commutativeN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) \cdot \phi_1} + \cos delta} \]
          3. sub-negN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
          4. mul-1-negN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\color{blue}{\left(\mathsf{neg}\left(\phi_1 \cdot \cos delta\right)\right)} + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right) \cdot \phi_1 + \cos delta} \]
          5. distribute-neg-outN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
          6. distribute-lft-neg-outN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \phi_1\right)\right)} + \cos delta} \]
          7. distribute-rgt-neg-inN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \left(\mathsf{neg}\left(\phi_1\right)\right)} + \cos delta} \]
          8. mul-1-negN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \color{blue}{\left(-1 \cdot \phi_1\right)} + \cos delta} \]
          9. accelerator-lowering-fma.f64N/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{fma}\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta, -1 \cdot \phi_1, \cos delta\right)}} \]
        5. Simplified75.2%

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

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 + -1 \cdot {\phi_1}^{2}}} \]
        7. Step-by-step derivation
          1. mul-1-negN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 + \color{blue}{\left(\mathsf{neg}\left({\phi_1}^{2}\right)\right)}} \]
          2. unsub-negN/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
          3. --lowering--.f64N/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
          4. unpow2N/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
          5. *-lowering-*.f6464.8

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
        8. Simplified64.8%

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

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
        10. Step-by-step derivation
          1. *-lowering-*.f64N/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
          2. sin-lowering-sin.f64N/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta} \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
          3. sin-lowering-sin.f6458.0

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{1 - \phi_1 \cdot \phi_1} \]
        11. Simplified58.0%

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
        12. Taylor expanded in delta around 0

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
        13. Step-by-step derivation
          1. *-lowering-*.f64N/A

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
          2. sin-lowering-sin.f6459.6

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{delta \cdot \color{blue}{\sin theta}}{1 - \phi_1 \cdot \phi_1} \]
        14. Simplified59.6%

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]

        if -5.0000000000000002e-63 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < 4e-79

        1. Initial program 99.8%

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

          \[\leadsto \color{blue}{\lambda_1} \]
        4. Step-by-step derivation
          1. Simplified87.7%

            \[\leadsto \color{blue}{\lambda_1} \]

          if 4e-79 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta))))))))

          1. Initial program 99.8%

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

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

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\phi_1 \cdot \left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) + \cos delta}} \]
            2. *-commutativeN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) \cdot \phi_1} + \cos delta} \]
            3. sub-negN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
            4. mul-1-negN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\color{blue}{\left(\mathsf{neg}\left(\phi_1 \cdot \cos delta\right)\right)} + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right) \cdot \phi_1 + \cos delta} \]
            5. distribute-neg-outN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
            6. distribute-lft-neg-outN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \phi_1\right)\right)} + \cos delta} \]
            7. distribute-rgt-neg-inN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \left(\mathsf{neg}\left(\phi_1\right)\right)} + \cos delta} \]
            8. mul-1-negN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \color{blue}{\left(-1 \cdot \phi_1\right)} + \cos delta} \]
            9. accelerator-lowering-fma.f64N/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{fma}\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta, -1 \cdot \phi_1, \cos delta\right)}} \]
          5. Simplified81.4%

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

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 + -1 \cdot {\phi_1}^{2}}} \]
          7. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 + \color{blue}{\left(\mathsf{neg}\left({\phi_1}^{2}\right)\right)}} \]
            2. unsub-negN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
            3. --lowering--.f64N/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
            4. unpow2N/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
            5. *-lowering-*.f6470.0

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
          8. Simplified70.0%

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

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
          10. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
            2. sin-lowering-sin.f64N/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta} \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
            3. sin-lowering-sin.f6462.3

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{1 - \phi_1 \cdot \phi_1} \]
          11. Simplified62.3%

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
        5. Recombined 3 regimes into one program.
        6. Final simplification74.3%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)} \leq -5 \cdot 10^{-63}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{1 - \phi_1 \cdot \phi_1}\\ \mathbf{elif}\;\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)} \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\lambda_1\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \sin delta}{1 - \phi_1 \cdot \phi_1}\\ \end{array} \]
        7. Add Preprocessing

        Alternative 5: 72.1% accurate, 0.5× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_1 := 1 - \phi_1 \cdot \phi_1\\ t_2 := \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)}\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-63}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{t\_1}\\ \mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\lambda_1\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \mathsf{fma}\left(delta, -0.16666666666666666 \cdot \left(delta \cdot delta\right), delta\right)}{t\_1}\\ \end{array} \end{array} \]
        (FPCore (lambda1 phi1 phi2 delta theta)
         :precision binary64
         (let* ((t_1 (- 1.0 (* phi1 phi1)))
                (t_2
                 (atan2
                  (* (cos phi1) (* (sin theta) (sin delta)))
                  (-
                   (cos delta)
                   (*
                    (sin phi1)
                    (sin
                     (asin
                      (+
                       (* (cos delta) (sin phi1))
                       (* (cos theta) (* (sin delta) (cos phi1)))))))))))
           (if (<= t_2 -5e-63)
             (+ lambda1 (atan2 (* (sin theta) delta) t_1))
             (if (<= t_2 4e-79)
               lambda1
               (+
                lambda1
                (atan2
                 (*
                  (sin theta)
                  (fma delta (* -0.16666666666666666 (* delta delta)) delta))
                 t_1))))))
        double code(double lambda1, double phi1, double phi2, double delta, double theta) {
        	double t_1 = 1.0 - (phi1 * phi1);
        	double t_2 = atan2((cos(phi1) * (sin(theta) * sin(delta))), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (sin(delta) * cos(phi1)))))))));
        	double tmp;
        	if (t_2 <= -5e-63) {
        		tmp = lambda1 + atan2((sin(theta) * delta), t_1);
        	} else if (t_2 <= 4e-79) {
        		tmp = lambda1;
        	} else {
        		tmp = lambda1 + atan2((sin(theta) * fma(delta, (-0.16666666666666666 * (delta * delta)), delta)), t_1);
        	}
        	return tmp;
        }
        
        function code(lambda1, phi1, phi2, delta, theta)
        	t_1 = Float64(1.0 - Float64(phi1 * phi1))
        	t_2 = atan(Float64(cos(phi1) * Float64(sin(theta) * sin(delta))), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(cos(delta) * sin(phi1)) + Float64(cos(theta) * Float64(sin(delta) * cos(phi1)))))))))
        	tmp = 0.0
        	if (t_2 <= -5e-63)
        		tmp = Float64(lambda1 + atan(Float64(sin(theta) * delta), t_1));
        	elseif (t_2 <= 4e-79)
        		tmp = lambda1;
        	else
        		tmp = Float64(lambda1 + atan(Float64(sin(theta) * fma(delta, Float64(-0.16666666666666666 * Float64(delta * delta)), delta)), t_1));
        	end
        	return tmp
        end
        
        code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(1.0 - N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[theta], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, -5e-63], N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * delta), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 4e-79], lambda1, N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * N[(delta * N[(-0.16666666666666666 * N[(delta * delta), $MachinePrecision]), $MachinePrecision] + delta), $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_1 := 1 - \phi_1 \cdot \phi_1\\
        t_2 := \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)}\\
        \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-63}:\\
        \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{t\_1}\\
        
        \mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-79}:\\
        \;\;\;\;\lambda_1\\
        
        \mathbf{else}:\\
        \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \mathsf{fma}\left(delta, -0.16666666666666666 \cdot \left(delta \cdot delta\right), delta\right)}{t\_1}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < -5.0000000000000002e-63

          1. Initial program 99.7%

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

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

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\phi_1 \cdot \left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) + \cos delta}} \]
            2. *-commutativeN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) \cdot \phi_1} + \cos delta} \]
            3. sub-negN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
            4. mul-1-negN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\color{blue}{\left(\mathsf{neg}\left(\phi_1 \cdot \cos delta\right)\right)} + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right) \cdot \phi_1 + \cos delta} \]
            5. distribute-neg-outN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
            6. distribute-lft-neg-outN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \phi_1\right)\right)} + \cos delta} \]
            7. distribute-rgt-neg-inN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \left(\mathsf{neg}\left(\phi_1\right)\right)} + \cos delta} \]
            8. mul-1-negN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \color{blue}{\left(-1 \cdot \phi_1\right)} + \cos delta} \]
            9. accelerator-lowering-fma.f64N/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{fma}\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta, -1 \cdot \phi_1, \cos delta\right)}} \]
          5. Simplified75.2%

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

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 + -1 \cdot {\phi_1}^{2}}} \]
          7. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 + \color{blue}{\left(\mathsf{neg}\left({\phi_1}^{2}\right)\right)}} \]
            2. unsub-negN/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
            3. --lowering--.f64N/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
            4. unpow2N/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
            5. *-lowering-*.f6464.8

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
          8. Simplified64.8%

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

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
          10. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
            2. sin-lowering-sin.f64N/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta} \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
            3. sin-lowering-sin.f6458.0

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{1 - \phi_1 \cdot \phi_1} \]
          11. Simplified58.0%

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
          12. Taylor expanded in delta around 0

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
          13. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
            2. sin-lowering-sin.f6459.6

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{delta \cdot \color{blue}{\sin theta}}{1 - \phi_1 \cdot \phi_1} \]
          14. Simplified59.6%

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]

          if -5.0000000000000002e-63 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < 4e-79

          1. Initial program 99.8%

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

            \[\leadsto \color{blue}{\lambda_1} \]
          4. Step-by-step derivation
            1. Simplified87.7%

              \[\leadsto \color{blue}{\lambda_1} \]

            if 4e-79 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta))))))))

            1. Initial program 99.8%

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

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

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\phi_1 \cdot \left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) + \cos delta}} \]
              2. *-commutativeN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) \cdot \phi_1} + \cos delta} \]
              3. sub-negN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
              4. mul-1-negN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\color{blue}{\left(\mathsf{neg}\left(\phi_1 \cdot \cos delta\right)\right)} + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right) \cdot \phi_1 + \cos delta} \]
              5. distribute-neg-outN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
              6. distribute-lft-neg-outN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \phi_1\right)\right)} + \cos delta} \]
              7. distribute-rgt-neg-inN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \left(\mathsf{neg}\left(\phi_1\right)\right)} + \cos delta} \]
              8. mul-1-negN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \color{blue}{\left(-1 \cdot \phi_1\right)} + \cos delta} \]
              9. accelerator-lowering-fma.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{fma}\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta, -1 \cdot \phi_1, \cos delta\right)}} \]
            5. Simplified81.4%

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

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 + -1 \cdot {\phi_1}^{2}}} \]
            7. Step-by-step derivation
              1. mul-1-negN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 + \color{blue}{\left(\mathsf{neg}\left({\phi_1}^{2}\right)\right)}} \]
              2. unsub-negN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
              3. --lowering--.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
              4. unpow2N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
              5. *-lowering-*.f6470.0

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
            8. Simplified70.0%

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

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
            10. Step-by-step derivation
              1. *-lowering-*.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
              2. sin-lowering-sin.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta} \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
              3. sin-lowering-sin.f6462.3

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{1 - \phi_1 \cdot \phi_1} \]
            11. Simplified62.3%

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
            12. Taylor expanded in delta around 0

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\left(delta \cdot \left(1 + \frac{-1}{6} \cdot {delta}^{2}\right)\right)} \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
            13. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(delta \cdot \color{blue}{\left(\frac{-1}{6} \cdot {delta}^{2} + 1\right)}\right) \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
              2. distribute-lft-inN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\left(delta \cdot \left(\frac{-1}{6} \cdot {delta}^{2}\right) + delta \cdot 1\right)} \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
              3. *-rgt-identityN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(delta \cdot \left(\frac{-1}{6} \cdot {delta}^{2}\right) + \color{blue}{delta}\right) \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
              4. accelerator-lowering-fma.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\mathsf{fma}\left(delta, \frac{-1}{6} \cdot {delta}^{2}, delta\right)} \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
              5. *-lowering-*.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(delta, \color{blue}{\frac{-1}{6} \cdot {delta}^{2}}, delta\right) \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
              6. unpow2N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(delta, \frac{-1}{6} \cdot \color{blue}{\left(delta \cdot delta\right)}, delta\right) \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
              7. *-lowering-*.f6461.0

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(delta, -0.16666666666666666 \cdot \color{blue}{\left(delta \cdot delta\right)}, delta\right) \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
            14. Simplified61.0%

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\mathsf{fma}\left(delta, -0.16666666666666666 \cdot \left(delta \cdot delta\right), delta\right)} \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
          5. Recombined 3 regimes into one program.
          6. Final simplification74.0%

            \[\leadsto \begin{array}{l} \mathbf{if}\;\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)} \leq -5 \cdot 10^{-63}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{1 - \phi_1 \cdot \phi_1}\\ \mathbf{elif}\;\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)} \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\lambda_1\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \mathsf{fma}\left(delta, -0.16666666666666666 \cdot \left(delta \cdot delta\right), delta\right)}{1 - \phi_1 \cdot \phi_1}\\ \end{array} \]
          7. Add Preprocessing

          Alternative 6: 72.6% accurate, 0.5× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_1 := \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)}\\ t_2 := \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{1 - \phi_1 \cdot \phi_1}\\ \mathbf{if}\;t\_1 \leq -5 \cdot 10^{-63}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\lambda_1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
          (FPCore (lambda1 phi1 phi2 delta theta)
           :precision binary64
           (let* ((t_1
                   (atan2
                    (* (cos phi1) (* (sin theta) (sin delta)))
                    (-
                     (cos delta)
                     (*
                      (sin phi1)
                      (sin
                       (asin
                        (+
                         (* (cos delta) (sin phi1))
                         (* (cos theta) (* (sin delta) (cos phi1))))))))))
                  (t_2 (+ lambda1 (atan2 (* (sin theta) delta) (- 1.0 (* phi1 phi1))))))
             (if (<= t_1 -5e-63) t_2 (if (<= t_1 4e-79) lambda1 t_2))))
          double code(double lambda1, double phi1, double phi2, double delta, double theta) {
          	double t_1 = atan2((cos(phi1) * (sin(theta) * sin(delta))), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (sin(delta) * cos(phi1)))))))));
          	double t_2 = lambda1 + atan2((sin(theta) * delta), (1.0 - (phi1 * phi1)));
          	double tmp;
          	if (t_1 <= -5e-63) {
          		tmp = t_2;
          	} else if (t_1 <= 4e-79) {
          		tmp = lambda1;
          	} else {
          		tmp = t_2;
          	}
          	return tmp;
          }
          
          real(8) function code(lambda1, phi1, phi2, delta, theta)
              real(8), intent (in) :: lambda1
              real(8), intent (in) :: phi1
              real(8), intent (in) :: phi2
              real(8), intent (in) :: delta
              real(8), intent (in) :: theta
              real(8) :: t_1
              real(8) :: t_2
              real(8) :: tmp
              t_1 = atan2((cos(phi1) * (sin(theta) * sin(delta))), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (sin(delta) * cos(phi1)))))))))
              t_2 = lambda1 + atan2((sin(theta) * delta), (1.0d0 - (phi1 * phi1)))
              if (t_1 <= (-5d-63)) then
                  tmp = t_2
              else if (t_1 <= 4d-79) then
                  tmp = lambda1
              else
                  tmp = t_2
              end if
              code = tmp
          end function
          
          public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
          	double t_1 = Math.atan2((Math.cos(phi1) * (Math.sin(theta) * Math.sin(delta))), (Math.cos(delta) - (Math.sin(phi1) * Math.sin(Math.asin(((Math.cos(delta) * Math.sin(phi1)) + (Math.cos(theta) * (Math.sin(delta) * Math.cos(phi1)))))))));
          	double t_2 = lambda1 + Math.atan2((Math.sin(theta) * delta), (1.0 - (phi1 * phi1)));
          	double tmp;
          	if (t_1 <= -5e-63) {
          		tmp = t_2;
          	} else if (t_1 <= 4e-79) {
          		tmp = lambda1;
          	} else {
          		tmp = t_2;
          	}
          	return tmp;
          }
          
          def code(lambda1, phi1, phi2, delta, theta):
          	t_1 = math.atan2((math.cos(phi1) * (math.sin(theta) * math.sin(delta))), (math.cos(delta) - (math.sin(phi1) * math.sin(math.asin(((math.cos(delta) * math.sin(phi1)) + (math.cos(theta) * (math.sin(delta) * math.cos(phi1)))))))))
          	t_2 = lambda1 + math.atan2((math.sin(theta) * delta), (1.0 - (phi1 * phi1)))
          	tmp = 0
          	if t_1 <= -5e-63:
          		tmp = t_2
          	elif t_1 <= 4e-79:
          		tmp = lambda1
          	else:
          		tmp = t_2
          	return tmp
          
          function code(lambda1, phi1, phi2, delta, theta)
          	t_1 = atan(Float64(cos(phi1) * Float64(sin(theta) * sin(delta))), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(cos(delta) * sin(phi1)) + Float64(cos(theta) * Float64(sin(delta) * cos(phi1)))))))))
          	t_2 = Float64(lambda1 + atan(Float64(sin(theta) * delta), Float64(1.0 - Float64(phi1 * phi1))))
          	tmp = 0.0
          	if (t_1 <= -5e-63)
          		tmp = t_2;
          	elseif (t_1 <= 4e-79)
          		tmp = lambda1;
          	else
          		tmp = t_2;
          	end
          	return tmp
          end
          
          function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
          	t_1 = atan2((cos(phi1) * (sin(theta) * sin(delta))), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (sin(delta) * cos(phi1)))))))));
          	t_2 = lambda1 + atan2((sin(theta) * delta), (1.0 - (phi1 * phi1)));
          	tmp = 0.0;
          	if (t_1 <= -5e-63)
          		tmp = t_2;
          	elseif (t_1 <= 4e-79)
          		tmp = lambda1;
          	else
          		tmp = t_2;
          	end
          	tmp_2 = tmp;
          end
          
          code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[theta], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * delta), $MachinePrecision] / N[(1.0 - N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-63], t$95$2, If[LessEqual[t$95$1, 4e-79], lambda1, t$95$2]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_1 := \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)}\\
          t_2 := \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{1 - \phi_1 \cdot \phi_1}\\
          \mathbf{if}\;t\_1 \leq -5 \cdot 10^{-63}:\\
          \;\;\;\;t\_2\\
          
          \mathbf{elif}\;t\_1 \leq 4 \cdot 10^{-79}:\\
          \;\;\;\;\lambda_1\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_2\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < -5.0000000000000002e-63 or 4e-79 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta))))))))

            1. Initial program 99.7%

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

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

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\phi_1 \cdot \left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) + \cos delta}} \]
              2. *-commutativeN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) - \cos theta \cdot \sin delta\right) \cdot \phi_1} + \cos delta} \]
              3. sub-negN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(-1 \cdot \left(\phi_1 \cdot \cos delta\right) + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
              4. mul-1-negN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\color{blue}{\left(\mathsf{neg}\left(\phi_1 \cdot \cos delta\right)\right)} + \left(\mathsf{neg}\left(\cos theta \cdot \sin delta\right)\right)\right) \cdot \phi_1 + \cos delta} \]
              5. distribute-neg-outN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right)\right)\right)} \cdot \phi_1 + \cos delta} \]
              6. distribute-lft-neg-outN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\mathsf{neg}\left(\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \phi_1\right)\right)} + \cos delta} \]
              7. distribute-rgt-neg-inN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \left(\mathsf{neg}\left(\phi_1\right)\right)} + \cos delta} \]
              8. mul-1-negN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta\right) \cdot \color{blue}{\left(-1 \cdot \phi_1\right)} + \cos delta} \]
              9. accelerator-lowering-fma.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{fma}\left(\phi_1 \cdot \cos delta + \cos theta \cdot \sin delta, -1 \cdot \phi_1, \cos delta\right)}} \]
            5. Simplified78.2%

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

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 + -1 \cdot {\phi_1}^{2}}} \]
            7. Step-by-step derivation
              1. mul-1-negN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 + \color{blue}{\left(\mathsf{neg}\left({\phi_1}^{2}\right)\right)}} \]
              2. unsub-negN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
              3. --lowering--.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\phi_1}^{2}}} \]
              4. unpow2N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
              5. *-lowering-*.f6467.3

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{1 - \color{blue}{\phi_1 \cdot \phi_1}} \]
            8. Simplified67.3%

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

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
            10. Step-by-step derivation
              1. *-lowering-*.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
              2. sin-lowering-sin.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta} \cdot \sin theta}{1 - \phi_1 \cdot \phi_1} \]
              3. sin-lowering-sin.f6460.1

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{1 - \phi_1 \cdot \phi_1} \]
            11. Simplified60.1%

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
            12. Taylor expanded in delta around 0

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
            13. Step-by-step derivation
              1. *-lowering-*.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]
              2. sin-lowering-sin.f6460.0

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{delta \cdot \color{blue}{\sin theta}}{1 - \phi_1 \cdot \phi_1} \]
            14. Simplified60.0%

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot \sin theta}}{1 - \phi_1 \cdot \phi_1} \]

            if -5.0000000000000002e-63 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < 4e-79

            1. Initial program 99.8%

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

              \[\leadsto \color{blue}{\lambda_1} \]
            4. Step-by-step derivation
              1. Simplified87.7%

                \[\leadsto \color{blue}{\lambda_1} \]
            5. Recombined 2 regimes into one program.
            6. Final simplification73.9%

              \[\leadsto \begin{array}{l} \mathbf{if}\;\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)} \leq -5 \cdot 10^{-63}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{1 - \phi_1 \cdot \phi_1}\\ \mathbf{elif}\;\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\right)} \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\lambda_1\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{1 - \phi_1 \cdot \phi_1}\\ \end{array} \]
            7. Add Preprocessing

            Alternative 7: 99.8% accurate, 1.3× speedup?

            \[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\mathsf{fma}\left(\sin delta \cdot \left(-\sin \phi_1\right), \cos \phi_1 \cdot \cos theta, \mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right) \cdot \cos delta\right)} \end{array} \]
            (FPCore (lambda1 phi1 phi2 delta theta)
             :precision binary64
             (+
              lambda1
              (atan2
               (* (cos phi1) (* (sin theta) (sin delta)))
               (fma
                (* (sin delta) (- (sin phi1)))
                (* (cos phi1) (cos theta))
                (* (fma (cos (+ phi1 phi1)) 0.5 0.5) (cos delta))))))
            double code(double lambda1, double phi1, double phi2, double delta, double theta) {
            	return lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), fma((sin(delta) * -sin(phi1)), (cos(phi1) * cos(theta)), (fma(cos((phi1 + phi1)), 0.5, 0.5) * cos(delta))));
            }
            
            function code(lambda1, phi1, phi2, delta, theta)
            	return Float64(lambda1 + atan(Float64(cos(phi1) * Float64(sin(theta) * sin(delta))), fma(Float64(sin(delta) * Float64(-sin(phi1))), Float64(cos(phi1) * cos(theta)), Float64(fma(cos(Float64(phi1 + phi1)), 0.5, 0.5) * cos(delta)))))
            end
            
            code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[delta], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[theta], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\mathsf{fma}\left(\sin delta \cdot \left(-\sin \phi_1\right), \cos \phi_1 \cdot \cos theta, \mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right) \cdot \cos delta\right)}
            \end{array}
            
            Derivation
            1. Initial program 99.8%

              \[\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)} \]
            2. Add Preprocessing
            3. Applied egg-rr99.8%

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{fma}\left(\left(-\sin \phi_1\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(-\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \phi_1\right)\right) \cdot \cos delta\right) + \cos delta\right)}} \]
            4. Step-by-step derivation
              1. distribute-lft-neg-inN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \color{blue}{\left(\mathsf{neg}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right)\right) \cdot \cos delta} + \cos delta\right)} \]
              2. distribute-lft1-inN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \color{blue}{\left(\left(\mathsf{neg}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right)\right) + 1\right) \cdot \cos delta}\right)} \]
              3. *-lowering-*.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \color{blue}{\left(\left(\mathsf{neg}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right)\right) + 1\right) \cdot \cos delta}\right)} \]
              4. +-lowering-+.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \color{blue}{\left(\left(\mathsf{neg}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right)\right) + 1\right)} \cdot \cos delta\right)} \]
              5. neg-lowering-neg.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\color{blue}{\left(\mathsf{neg}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right)\right)} + 1\right) \cdot \cos delta\right)} \]
              6. sub-negN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\color{blue}{\left(\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right)\right)}\right)\right) + 1\right) \cdot \cos delta\right)} \]
              7. +-commutativeN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right) + \frac{1}{2}\right)}\right)\right) + 1\right) \cdot \cos delta\right)} \]
              8. *-commutativeN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(\color{blue}{\cos \left(2 \cdot \phi_1\right) \cdot \frac{1}{2}}\right)\right) + \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta\right)} \]
              9. distribute-rgt-neg-inN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\left(\color{blue}{\cos \left(2 \cdot \phi_1\right) \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} + \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta\right)} \]
              10. accelerator-lowering-fma.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\color{blue}{\mathsf{fma}\left(\cos \left(2 \cdot \phi_1\right), \mathsf{neg}\left(\frac{1}{2}\right), \frac{1}{2}\right)}\right)\right) + 1\right) \cdot \cos delta\right)} \]
              11. cos-2N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\mathsf{fma}\left(\color{blue}{\cos \phi_1 \cdot \cos \phi_1 - \sin \phi_1 \cdot \sin \phi_1}, \mathsf{neg}\left(\frac{1}{2}\right), \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta\right)} \]
              12. cos-sumN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\mathsf{fma}\left(\color{blue}{\cos \left(\phi_1 + \phi_1\right)}, \mathsf{neg}\left(\frac{1}{2}\right), \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta\right)} \]
              13. cos-lowering-cos.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\mathsf{fma}\left(\color{blue}{\cos \left(\phi_1 + \phi_1\right)}, \mathsf{neg}\left(\frac{1}{2}\right), \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta\right)} \]
              14. +-lowering-+.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\mathsf{fma}\left(\cos \color{blue}{\left(\phi_1 + \phi_1\right)}, \mathsf{neg}\left(\frac{1}{2}\right), \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta\right)} \]
              15. metadata-evalN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\mathsf{neg}\left(\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), \color{blue}{\frac{-1}{2}}, \frac{1}{2}\right)\right)\right) + 1\right) \cdot \cos delta\right)} \]
              16. cos-lowering-cos.f6499.8

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(-\sin \phi_1\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(-\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), -0.5, 0.5\right)\right) + 1\right) \cdot \color{blue}{\cos delta}\right)} \]
            5. Applied egg-rr99.8%

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(-\sin \phi_1\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \color{blue}{\left(\left(-\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), -0.5, 0.5\right)\right) + 1\right) \cdot \cos delta}\right)} \]
            6. Step-by-step derivation
              1. distribute-neg-inN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\color{blue}{\left(\left(\mathsf{neg}\left(\cos \left(\phi_1 + \phi_1\right) \cdot \frac{-1}{2}\right)\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)} + 1\right) \cdot \cos delta\right)} \]
              2. metadata-evalN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\left(\left(\mathsf{neg}\left(\cos \left(\phi_1 + \phi_1\right) \cdot \frac{-1}{2}\right)\right) + \color{blue}{\frac{-1}{2}}\right) + 1\right) \cdot \cos delta\right)} \]
              3. associate-+l+N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \color{blue}{\left(\left(\mathsf{neg}\left(\cos \left(\phi_1 + \phi_1\right) \cdot \frac{-1}{2}\right)\right) + \left(\frac{-1}{2} + 1\right)\right)} \cdot \cos delta\right)} \]
              4. distribute-rgt-neg-inN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\color{blue}{\cos \left(\phi_1 + \phi_1\right) \cdot \left(\mathsf{neg}\left(\frac{-1}{2}\right)\right)} + \left(\frac{-1}{2} + 1\right)\right) \cdot \cos delta\right)} \]
              5. metadata-evalN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\cos \left(\phi_1 + \phi_1\right) \cdot \color{blue}{\frac{1}{2}} + \left(\frac{-1}{2} + 1\right)\right) \cdot \cos delta\right)} \]
              6. metadata-evalN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \left(\cos \left(\phi_1 + \phi_1\right) \cdot \frac{1}{2} + \color{blue}{\frac{1}{2}}\right) \cdot \cos delta\right)} \]
              7. accelerator-lowering-fma.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \color{blue}{\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), \frac{1}{2}, \frac{1}{2}\right)} \cdot \cos delta\right)} \]
              8. cos-lowering-cos.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\sin \phi_1\right)\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \mathsf{fma}\left(\color{blue}{\cos \left(\phi_1 + \phi_1\right)}, \frac{1}{2}, \frac{1}{2}\right) \cdot \cos delta\right)} \]
              9. +-lowering-+.f6499.8

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(-\sin \phi_1\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \mathsf{fma}\left(\cos \color{blue}{\left(\phi_1 + \phi_1\right)}, 0.5, 0.5\right) \cdot \cos delta\right)} \]
            7. Applied egg-rr99.8%

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\left(-\sin \phi_1\right) \cdot \sin delta, \cos \phi_1 \cdot \cos theta, \color{blue}{\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right)} \cdot \cos delta\right)} \]
            8. Final simplification99.8%

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\mathsf{fma}\left(\sin delta \cdot \left(-\sin \phi_1\right), \cos \phi_1 \cdot \cos theta, \mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right) \cdot \cos delta\right)} \]
            9. Add Preprocessing

            Alternative 8: 94.3% accurate, 1.3× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_1 := \sin delta \cdot \cos \phi_1\\ \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot t\_1}{\mathsf{fma}\left(-\sin \phi_1, \mathsf{fma}\left(\cos delta, \sin \phi_1, t\_1\right), \cos delta\right)} \end{array} \end{array} \]
            (FPCore (lambda1 phi1 phi2 delta theta)
             :precision binary64
             (let* ((t_1 (* (sin delta) (cos phi1))))
               (+
                lambda1
                (atan2
                 (* (sin theta) t_1)
                 (fma (- (sin phi1)) (fma (cos delta) (sin phi1) t_1) (cos delta))))))
            double code(double lambda1, double phi1, double phi2, double delta, double theta) {
            	double t_1 = sin(delta) * cos(phi1);
            	return lambda1 + atan2((sin(theta) * t_1), fma(-sin(phi1), fma(cos(delta), sin(phi1), t_1), cos(delta)));
            }
            
            function code(lambda1, phi1, phi2, delta, theta)
            	t_1 = Float64(sin(delta) * cos(phi1))
            	return Float64(lambda1 + atan(Float64(sin(theta) * t_1), fma(Float64(-sin(phi1)), fma(cos(delta), sin(phi1), t_1), cos(delta))))
            end
            
            code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * t$95$1), $MachinePrecision] / N[((-N[Sin[phi1], $MachinePrecision]) * N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + t$95$1), $MachinePrecision] + N[Cos[delta], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_1 := \sin delta \cdot \cos \phi_1\\
            \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot t\_1}{\mathsf{fma}\left(-\sin \phi_1, \mathsf{fma}\left(\cos delta, \sin \phi_1, t\_1\right), \cos delta\right)}
            \end{array}
            \end{array}
            
            Derivation
            1. Initial program 99.8%

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

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

                \[\leadsto \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos theta \cdot \sin delta\right)\right)} + \lambda_1} \]
              2. +-lowering-+.f64N/A

                \[\leadsto \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos theta \cdot \sin delta\right)\right)} + \lambda_1} \]
            5. Simplified99.8%

              \[\leadsto \color{blue}{\tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), -\sin \phi_1, \cos delta\right)} + \lambda_1} \]
            6. Step-by-step derivation
              1. associate-*r*N/A

                \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin delta \cdot \cos \phi_1\right) \cdot \sin theta}}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
              2. *-lowering-*.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin delta \cdot \cos \phi_1\right) \cdot \sin theta}}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
              3. *-commutativeN/A

                \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\cos \phi_1 \cdot \sin delta\right)} \cdot \sin theta}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
              4. *-lowering-*.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\cos \phi_1 \cdot \sin delta\right)} \cdot \sin theta}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
              5. cos-lowering-cos.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\cos \phi_1} \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
              6. sin-lowering-sin.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \color{blue}{\sin delta}\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
              7. sin-lowering-sin.f6499.8

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \color{blue}{\sin theta}}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), -\sin \phi_1, \cos delta\right)} + \lambda_1 \]
            7. Applied egg-rr99.8%

              \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), -\sin \phi_1, \cos delta\right)} + \lambda_1 \]
            8. Taylor expanded in theta around 0

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

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\color{blue}{-1 \cdot \left(\sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right)\right) + \cos delta}} + \lambda_1 \]
              2. associate-*r*N/A

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\color{blue}{\left(-1 \cdot \sin \phi_1\right) \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right)} + \cos delta} + \lambda_1 \]
              3. accelerator-lowering-fma.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\color{blue}{\mathsf{fma}\left(-1 \cdot \sin \phi_1, \cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta, \cos delta\right)}} + \lambda_1 \]
              4. mul-1-negN/A

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\sin \phi_1\right)}, \cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta, \cos delta\right)} + \lambda_1 \]
              5. neg-lowering-neg.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\sin \phi_1\right)}, \cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta, \cos delta\right)} + \lambda_1 \]
              6. sin-lowering-sin.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\sin \phi_1}\right), \cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta, \cos delta\right)} + \lambda_1 \]
              7. accelerator-lowering-fma.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \color{blue}{\mathsf{fma}\left(\cos delta, \sin \phi_1, \cos \phi_1 \cdot \sin delta\right)}, \cos delta\right)} + \lambda_1 \]
              8. cos-lowering-cos.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \mathsf{fma}\left(\color{blue}{\cos delta}, \sin \phi_1, \cos \phi_1 \cdot \sin delta\right), \cos delta\right)} + \lambda_1 \]
              9. sin-lowering-sin.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \mathsf{fma}\left(\cos delta, \color{blue}{\sin \phi_1}, \cos \phi_1 \cdot \sin delta\right), \cos delta\right)} + \lambda_1 \]
              10. *-lowering-*.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \mathsf{fma}\left(\cos delta, \sin \phi_1, \color{blue}{\cos \phi_1 \cdot \sin delta}\right), \cos delta\right)} + \lambda_1 \]
              11. cos-lowering-cos.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \mathsf{fma}\left(\cos delta, \sin \phi_1, \color{blue}{\cos \phi_1} \cdot \sin delta\right), \cos delta\right)} + \lambda_1 \]
              12. sin-lowering-sin.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \mathsf{fma}\left(\cos delta, \sin \phi_1, \cos \phi_1 \cdot \color{blue}{\sin delta}\right), \cos delta\right)} + \lambda_1 \]
              13. cos-lowering-cos.f6494.3

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(-\sin \phi_1, \mathsf{fma}\left(\cos delta, \sin \phi_1, \cos \phi_1 \cdot \sin delta\right), \color{blue}{\cos delta}\right)} + \lambda_1 \]
            10. Simplified94.3%

              \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\color{blue}{\mathsf{fma}\left(-\sin \phi_1, \mathsf{fma}\left(\cos delta, \sin \phi_1, \cos \phi_1 \cdot \sin delta\right), \cos delta\right)}} + \lambda_1 \]
            11. Final simplification94.3%

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(-\sin \phi_1, \mathsf{fma}\left(\cos delta, \sin \phi_1, \sin delta \cdot \cos \phi_1\right), \cos delta\right)} \]
            12. Add Preprocessing

            Alternative 9: 94.3% accurate, 1.3× speedup?

            \[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \phi_1, \sin delta, \cos delta \cdot \sin \phi_1\right), -\sin \phi_1, \cos delta\right)} \end{array} \]
            (FPCore (lambda1 phi1 phi2 delta theta)
             :precision binary64
             (+
              lambda1
              (atan2
               (* (sin delta) (* (sin theta) (cos phi1)))
               (fma
                (fma (cos phi1) (sin delta) (* (cos delta) (sin phi1)))
                (- (sin phi1))
                (cos delta)))))
            double code(double lambda1, double phi1, double phi2, double delta, double theta) {
            	return lambda1 + atan2((sin(delta) * (sin(theta) * cos(phi1))), fma(fma(cos(phi1), sin(delta), (cos(delta) * sin(phi1))), -sin(phi1), cos(delta)));
            }
            
            function code(lambda1, phi1, phi2, delta, theta)
            	return Float64(lambda1 + atan(Float64(sin(delta) * Float64(sin(theta) * cos(phi1))), fma(fma(cos(phi1), sin(delta), Float64(cos(delta) * sin(phi1))), Float64(-sin(phi1)), cos(delta))))
            end
            
            code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[Sin[delta], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision] + N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision]) + N[Cos[delta], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \phi_1, \sin delta, \cos delta \cdot \sin \phi_1\right), -\sin \phi_1, \cos delta\right)}
            \end{array}
            
            Derivation
            1. Initial program 99.8%

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

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

                \[\leadsto \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos theta \cdot \sin delta\right)\right)} + \lambda_1} \]
              2. +-lowering-+.f64N/A

                \[\leadsto \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos theta \cdot \sin delta\right)\right)} + \lambda_1} \]
            5. Simplified99.8%

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

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

                \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{-1 \cdot \left(\sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right)\right) + \cos delta}} + \lambda_1 \]
              2. mul-1-negN/A

                \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{\left(\mathsf{neg}\left(\sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right)\right)\right)} + \cos delta} + \lambda_1 \]
              3. *-commutativeN/A

                \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\left(\mathsf{neg}\left(\color{blue}{\left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right) \cdot \sin \phi_1}\right)\right) + \cos delta} + \lambda_1 \]
              4. distribute-rgt-neg-inN/A

                \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{\left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right) \cdot \left(\mathsf{neg}\left(\sin \phi_1\right)\right)} + \cos delta} + \lambda_1 \]
              5. mul-1-negN/A

                \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right) \cdot \color{blue}{\left(-1 \cdot \sin \phi_1\right)} + \cos delta} + \lambda_1 \]
              6. accelerator-lowering-fma.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{\mathsf{fma}\left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta, -1 \cdot \sin \phi_1, \cos delta\right)}} + \lambda_1 \]
            8. Simplified94.2%

              \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \phi_1, \sin delta, \sin \phi_1 \cdot \cos delta\right), -\sin \phi_1, \cos delta\right)}} + \lambda_1 \]
            9. Final simplification94.2%

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \phi_1, \sin delta, \cos delta \cdot \sin \phi_1\right), -\sin \phi_1, \cos delta\right)} \]
            10. Add Preprocessing

            Alternative 10: 94.3% accurate, 1.3× speedup?

            \[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\sin delta, \cos \phi_1, \cos delta \cdot \sin \phi_1\right)} \end{array} \]
            (FPCore (lambda1 phi1 phi2 delta theta)
             :precision binary64
             (+
              lambda1
              (atan2
               (* (cos phi1) (* (sin theta) (sin delta)))
               (-
                (cos delta)
                (* (sin phi1) (fma (sin delta) (cos phi1) (* (cos delta) (sin phi1))))))))
            double code(double lambda1, double phi1, double phi2, double delta, double theta) {
            	return lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), (cos(delta) - (sin(phi1) * fma(sin(delta), cos(phi1), (cos(delta) * sin(phi1))))));
            }
            
            function code(lambda1, phi1, phi2, delta, theta)
            	return Float64(lambda1 + atan(Float64(cos(phi1) * Float64(sin(theta) * sin(delta))), Float64(cos(delta) - Float64(sin(phi1) * fma(sin(delta), cos(phi1), Float64(cos(delta) * sin(phi1)))))))
            end
            
            code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\sin delta, \cos \phi_1, \cos delta \cdot \sin \phi_1\right)}
            \end{array}
            
            Derivation
            1. Initial program 99.8%

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

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right)}} \]
            4. Step-by-step derivation
              1. --lowering--.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right)}} \]
              2. cos-lowering-cos.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\cos delta} - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right)} \]
              3. *-lowering-*.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \color{blue}{\sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right)}} \]
              4. sin-lowering-sin.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \color{blue}{\sin \phi_1} \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right)} \]
              5. +-commutativeN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \color{blue}{\left(\cos \phi_1 \cdot \sin delta + \cos delta \cdot \sin \phi_1\right)}} \]
              6. *-commutativeN/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \left(\color{blue}{\sin delta \cdot \cos \phi_1} + \cos delta \cdot \sin \phi_1\right)} \]
              7. accelerator-lowering-fma.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \color{blue}{\mathsf{fma}\left(\sin delta, \cos \phi_1, \cos delta \cdot \sin \phi_1\right)}} \]
              8. sin-lowering-sin.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\color{blue}{\sin delta}, \cos \phi_1, \cos delta \cdot \sin \phi_1\right)} \]
              9. cos-lowering-cos.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\sin delta, \color{blue}{\cos \phi_1}, \cos delta \cdot \sin \phi_1\right)} \]
              10. *-lowering-*.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\sin delta, \cos \phi_1, \color{blue}{\cos delta \cdot \sin \phi_1}\right)} \]
              11. cos-lowering-cos.f64N/A

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\sin delta, \cos \phi_1, \color{blue}{\cos delta} \cdot \sin \phi_1\right)} \]
              12. sin-lowering-sin.f6494.2

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\sin delta, \cos \phi_1, \cos delta \cdot \color{blue}{\sin \phi_1}\right)} \]
            5. Simplified94.2%

              \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\sin delta, \cos \phi_1, \cos delta \cdot \sin \phi_1\right)}} \]
            6. Final simplification94.2%

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

            Alternative 11: 91.8% accurate, 1.4× speedup?

            \[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta, \sin \phi_1\right), -\sin \phi_1, \cos delta\right)} \end{array} \]
            (FPCore (lambda1 phi1 phi2 delta theta)
             :precision binary64
             (+
              lambda1
              (atan2
               (* (sin delta) (* (sin theta) (cos phi1)))
               (fma (fma (cos theta) (sin delta) (sin phi1)) (- (sin phi1)) (cos delta)))))
            double code(double lambda1, double phi1, double phi2, double delta, double theta) {
            	return lambda1 + atan2((sin(delta) * (sin(theta) * cos(phi1))), fma(fma(cos(theta), sin(delta), sin(phi1)), -sin(phi1), cos(delta)));
            }
            
            function code(lambda1, phi1, phi2, delta, theta)
            	return Float64(lambda1 + atan(Float64(sin(delta) * Float64(sin(theta) * cos(phi1))), fma(fma(cos(theta), sin(delta), sin(phi1)), Float64(-sin(phi1)), cos(delta))))
            end
            
            code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[Sin[delta], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision] + N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision]) + N[Cos[delta], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta, \sin \phi_1\right), -\sin \phi_1, \cos delta\right)}
            \end{array}
            
            Derivation
            1. Initial program 99.8%

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

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

                \[\leadsto \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos theta \cdot \sin delta\right)\right)} + \lambda_1} \]
              2. +-lowering-+.f64N/A

                \[\leadsto \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos theta \cdot \sin delta\right)\right)} + \lambda_1} \]
            5. Simplified99.8%

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

              \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \color{blue}{\sin \phi_1}\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
            7. Step-by-step derivation
              1. sin-lowering-sin.f6493.3

                \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \color{blue}{\sin \phi_1}\right), -\sin \phi_1, \cos delta\right)} + \lambda_1 \]
            8. Simplified93.3%

              \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \color{blue}{\sin \phi_1}\right), -\sin \phi_1, \cos delta\right)} + \lambda_1 \]
            9. Taylor expanded in phi1 around 0

              \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \color{blue}{1}, \sin \phi_1\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
            10. Step-by-step derivation
              1. Simplified93.3%

                \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \color{blue}{1}, \sin \phi_1\right), -\sin \phi_1, \cos delta\right)} + \lambda_1 \]
              2. Final simplification93.3%

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta, \sin \phi_1\right), -\sin \phi_1, \cos delta\right)} \]
              3. Add Preprocessing

              Alternative 12: 92.2% accurate, 1.4× speedup?

              \[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(-\sin \phi_1, \mathsf{fma}\left(\cos \phi_1, \sin delta, \sin \phi_1\right), \cos delta\right)} \end{array} \]
              (FPCore (lambda1 phi1 phi2 delta theta)
               :precision binary64
               (+
                lambda1
                (atan2
                 (* (sin delta) (* (sin theta) (cos phi1)))
                 (fma (- (sin phi1)) (fma (cos phi1) (sin delta) (sin phi1)) (cos delta)))))
              double code(double lambda1, double phi1, double phi2, double delta, double theta) {
              	return lambda1 + atan2((sin(delta) * (sin(theta) * cos(phi1))), fma(-sin(phi1), fma(cos(phi1), sin(delta), sin(phi1)), cos(delta)));
              }
              
              function code(lambda1, phi1, phi2, delta, theta)
              	return Float64(lambda1 + atan(Float64(sin(delta) * Float64(sin(theta) * cos(phi1))), fma(Float64(-sin(phi1)), fma(cos(phi1), sin(delta), sin(phi1)), cos(delta))))
              end
              
              code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[Sin[delta], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[((-N[Sin[phi1], $MachinePrecision]) * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision] + N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[Cos[delta], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(-\sin \phi_1, \mathsf{fma}\left(\cos \phi_1, \sin delta, \sin \phi_1\right), \cos delta\right)}
              \end{array}
              
              Derivation
              1. Initial program 99.8%

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

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

                  \[\leadsto \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos theta \cdot \sin delta\right)\right)} + \lambda_1} \]
                2. +-lowering-+.f64N/A

                  \[\leadsto \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos theta \cdot \sin delta\right)\right)} + \lambda_1} \]
              5. Simplified99.8%

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

                \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \color{blue}{\sin \phi_1}\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
              7. Step-by-step derivation
                1. sin-lowering-sin.f6493.3

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \color{blue}{\sin \phi_1}\right), -\sin \phi_1, \cos delta\right)} + \lambda_1 \]
              8. Simplified93.3%

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

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

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{-1 \cdot \left(\sin \phi_1 \cdot \left(\sin \phi_1 + \cos \phi_1 \cdot \sin delta\right)\right) + \cos delta}} + \lambda_1 \]
                2. associate-*r*N/A

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{\left(-1 \cdot \sin \phi_1\right) \cdot \left(\sin \phi_1 + \cos \phi_1 \cdot \sin delta\right)} + \cos delta} + \lambda_1 \]
                3. accelerator-lowering-fma.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{\mathsf{fma}\left(-1 \cdot \sin \phi_1, \sin \phi_1 + \cos \phi_1 \cdot \sin delta, \cos delta\right)}} + \lambda_1 \]
                4. mul-1-negN/A

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\sin \phi_1\right)}, \sin \phi_1 + \cos \phi_1 \cdot \sin delta, \cos delta\right)} + \lambda_1 \]
                5. neg-lowering-neg.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\sin \phi_1\right)}, \sin \phi_1 + \cos \phi_1 \cdot \sin delta, \cos delta\right)} + \lambda_1 \]
                6. sin-lowering-sin.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\sin \phi_1}\right), \sin \phi_1 + \cos \phi_1 \cdot \sin delta, \cos delta\right)} + \lambda_1 \]
                7. +-commutativeN/A

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \color{blue}{\cos \phi_1 \cdot \sin delta + \sin \phi_1}, \cos delta\right)} + \lambda_1 \]
                8. accelerator-lowering-fma.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \color{blue}{\mathsf{fma}\left(\cos \phi_1, \sin delta, \sin \phi_1\right)}, \cos delta\right)} + \lambda_1 \]
                9. cos-lowering-cos.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \mathsf{fma}\left(\color{blue}{\cos \phi_1}, \sin delta, \sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
                10. sin-lowering-sin.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \mathsf{fma}\left(\cos \phi_1, \color{blue}{\sin delta}, \sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
                11. sin-lowering-sin.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \mathsf{fma}\left(\cos \phi_1, \sin delta, \color{blue}{\sin \phi_1}\right), \cos delta\right)} + \lambda_1 \]
                12. cos-lowering-cos.f6493.1

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(-\sin \phi_1, \mathsf{fma}\left(\cos \phi_1, \sin delta, \sin \phi_1\right), \color{blue}{\cos delta}\right)} + \lambda_1 \]
              11. Simplified93.1%

                \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{\mathsf{fma}\left(-\sin \phi_1, \mathsf{fma}\left(\cos \phi_1, \sin delta, \sin \phi_1\right), \cos delta\right)}} + \lambda_1 \]
              12. Final simplification93.1%

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(-\sin \phi_1, \mathsf{fma}\left(\cos \phi_1, \sin delta, \sin \phi_1\right), \cos delta\right)} \]
              13. Add Preprocessing

              Alternative 13: 91.8% accurate, 1.8× speedup?

              \[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\sin \left(delta + \phi_1\right), -\sin \phi_1, \cos delta\right)} \end{array} \]
              (FPCore (lambda1 phi1 phi2 delta theta)
               :precision binary64
               (+
                lambda1
                (atan2
                 (* (sin theta) (* (sin delta) (cos phi1)))
                 (fma (sin (+ delta phi1)) (- (sin phi1)) (cos delta)))))
              double code(double lambda1, double phi1, double phi2, double delta, double theta) {
              	return lambda1 + atan2((sin(theta) * (sin(delta) * cos(phi1))), fma(sin((delta + phi1)), -sin(phi1), cos(delta)));
              }
              
              function code(lambda1, phi1, phi2, delta, theta)
              	return Float64(lambda1 + atan(Float64(sin(theta) * Float64(sin(delta) * cos(phi1))), fma(sin(Float64(delta + phi1)), Float64(-sin(phi1)), cos(delta))))
              end
              
              code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[N[(delta + phi1), $MachinePrecision]], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision]) + N[Cos[delta], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\sin \left(delta + \phi_1\right), -\sin \phi_1, \cos delta\right)}
              \end{array}
              
              Derivation
              1. Initial program 99.8%

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

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

                  \[\leadsto \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos theta \cdot \sin delta\right)\right)} + \lambda_1} \]
                2. +-lowering-+.f64N/A

                  \[\leadsto \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos theta \cdot \sin delta\right)\right)} + \lambda_1} \]
              5. Simplified99.8%

                \[\leadsto \color{blue}{\tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), -\sin \phi_1, \cos delta\right)} + \lambda_1} \]
              6. Step-by-step derivation
                1. associate-*r*N/A

                  \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin delta \cdot \cos \phi_1\right) \cdot \sin theta}}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
                2. *-lowering-*.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin delta \cdot \cos \phi_1\right) \cdot \sin theta}}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
                3. *-commutativeN/A

                  \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\cos \phi_1 \cdot \sin delta\right)} \cdot \sin theta}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
                4. *-lowering-*.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\cos \phi_1 \cdot \sin delta\right)} \cdot \sin theta}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
                5. cos-lowering-cos.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\cos \phi_1} \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
                6. sin-lowering-sin.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \color{blue}{\sin delta}\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
                7. sin-lowering-sin.f6499.8

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \color{blue}{\sin theta}}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), -\sin \phi_1, \cos delta\right)} + \lambda_1 \]
              7. Applied egg-rr99.8%

                \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), -\sin \phi_1, \cos delta\right)} + \lambda_1 \]
              8. Taylor expanded in theta around 0

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

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\color{blue}{-1 \cdot \left(\sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right)\right) + \cos delta}} + \lambda_1 \]
                2. associate-*r*N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\color{blue}{\left(-1 \cdot \sin \phi_1\right) \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right)} + \cos delta} + \lambda_1 \]
                3. accelerator-lowering-fma.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\color{blue}{\mathsf{fma}\left(-1 \cdot \sin \phi_1, \cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta, \cos delta\right)}} + \lambda_1 \]
                4. mul-1-negN/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\sin \phi_1\right)}, \cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta, \cos delta\right)} + \lambda_1 \]
                5. neg-lowering-neg.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\sin \phi_1\right)}, \cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta, \cos delta\right)} + \lambda_1 \]
                6. sin-lowering-sin.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\sin \phi_1}\right), \cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta, \cos delta\right)} + \lambda_1 \]
                7. accelerator-lowering-fma.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \color{blue}{\mathsf{fma}\left(\cos delta, \sin \phi_1, \cos \phi_1 \cdot \sin delta\right)}, \cos delta\right)} + \lambda_1 \]
                8. cos-lowering-cos.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \mathsf{fma}\left(\color{blue}{\cos delta}, \sin \phi_1, \cos \phi_1 \cdot \sin delta\right), \cos delta\right)} + \lambda_1 \]
                9. sin-lowering-sin.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \mathsf{fma}\left(\cos delta, \color{blue}{\sin \phi_1}, \cos \phi_1 \cdot \sin delta\right), \cos delta\right)} + \lambda_1 \]
                10. *-lowering-*.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \mathsf{fma}\left(\cos delta, \sin \phi_1, \color{blue}{\cos \phi_1 \cdot \sin delta}\right), \cos delta\right)} + \lambda_1 \]
                11. cos-lowering-cos.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \mathsf{fma}\left(\cos delta, \sin \phi_1, \color{blue}{\cos \phi_1} \cdot \sin delta\right), \cos delta\right)} + \lambda_1 \]
                12. sin-lowering-sin.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\mathsf{neg}\left(\sin \phi_1\right), \mathsf{fma}\left(\cos delta, \sin \phi_1, \cos \phi_1 \cdot \color{blue}{\sin delta}\right), \cos delta\right)} + \lambda_1 \]
                13. cos-lowering-cos.f6494.3

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(-\sin \phi_1, \mathsf{fma}\left(\cos delta, \sin \phi_1, \cos \phi_1 \cdot \sin delta\right), \color{blue}{\cos delta}\right)} + \lambda_1 \]
              10. Simplified94.3%

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\color{blue}{\mathsf{fma}\left(-\sin \phi_1, \mathsf{fma}\left(\cos delta, \sin \phi_1, \cos \phi_1 \cdot \sin delta\right), \cos delta\right)}} + \lambda_1 \]
              11. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\color{blue}{\left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta\right) \cdot \left(\mathsf{neg}\left(\sin \phi_1\right)\right)} + \cos delta} + \lambda_1 \]
                2. accelerator-lowering-fma.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\color{blue}{\mathsf{fma}\left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \sin delta, \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)}} + \lambda_1 \]
                3. *-commutativeN/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\color{blue}{\sin \phi_1 \cdot \cos delta} + \cos \phi_1 \cdot \sin delta, \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
                4. sin-sumN/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\color{blue}{\sin \left(\phi_1 + delta\right)}, \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
                5. sin-lowering-sin.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\color{blue}{\sin \left(\phi_1 + delta\right)}, \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
                6. +-lowering-+.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\sin \color{blue}{\left(\phi_1 + delta\right)}, \mathsf{neg}\left(\sin \phi_1\right), \cos delta\right)} + \lambda_1 \]
                7. neg-lowering-neg.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\sin \left(\phi_1 + delta\right), \color{blue}{\mathsf{neg}\left(\sin \phi_1\right)}, \cos delta\right)} + \lambda_1 \]
                8. sin-lowering-sin.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\sin \left(\phi_1 + delta\right), \mathsf{neg}\left(\color{blue}{\sin \phi_1}\right), \cos delta\right)} + \lambda_1 \]
                9. cos-lowering-cos.f6492.1

                  \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\mathsf{fma}\left(\sin \left(\phi_1 + delta\right), -\sin \phi_1, \color{blue}{\cos delta}\right)} + \lambda_1 \]
              12. Applied egg-rr92.1%

                \[\leadsto \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\color{blue}{\mathsf{fma}\left(\sin \left(\phi_1 + delta\right), -\sin \phi_1, \cos delta\right)}} + \lambda_1 \]
              13. Final simplification92.1%

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\sin \left(delta + \phi_1\right), -\sin \phi_1, \cos delta\right)} \]
              14. Add Preprocessing

              Alternative 14: 91.9% accurate, 1.9× speedup?

              \[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - {\sin \phi_1}^{2}} \end{array} \]
              (FPCore (lambda1 phi1 phi2 delta theta)
               :precision binary64
               (+
                lambda1
                (atan2
                 (* (cos phi1) (* (sin theta) (sin delta)))
                 (- (cos delta) (pow (sin phi1) 2.0)))))
              double code(double lambda1, double phi1, double phi2, double delta, double theta) {
              	return lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), (cos(delta) - pow(sin(phi1), 2.0)));
              }
              
              real(8) function code(lambda1, phi1, phi2, delta, theta)
                  real(8), intent (in) :: lambda1
                  real(8), intent (in) :: phi1
                  real(8), intent (in) :: phi2
                  real(8), intent (in) :: delta
                  real(8), intent (in) :: theta
                  code = lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), (cos(delta) - (sin(phi1) ** 2.0d0)))
              end function
              
              public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
              	return lambda1 + Math.atan2((Math.cos(phi1) * (Math.sin(theta) * Math.sin(delta))), (Math.cos(delta) - Math.pow(Math.sin(phi1), 2.0)));
              }
              
              def code(lambda1, phi1, phi2, delta, theta):
              	return lambda1 + math.atan2((math.cos(phi1) * (math.sin(theta) * math.sin(delta))), (math.cos(delta) - math.pow(math.sin(phi1), 2.0)))
              
              function code(lambda1, phi1, phi2, delta, theta)
              	return Float64(lambda1 + atan(Float64(cos(phi1) * Float64(sin(theta) * sin(delta))), Float64(cos(delta) - (sin(phi1) ^ 2.0))))
              end
              
              function tmp = code(lambda1, phi1, phi2, delta, theta)
              	tmp = lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), (cos(delta) - (sin(phi1) ^ 2.0)));
              end
              
              code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[Power[N[Sin[phi1], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              \lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - {\sin \phi_1}^{2}}
              \end{array}
              
              Derivation
              1. Initial program 99.8%

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

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \color{blue}{{\sin \phi_1}^{2}}} \]
              4. Step-by-step derivation
                1. pow-lowering-pow.f64N/A

                  \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \color{blue}{{\sin \phi_1}^{2}}} \]
                2. sin-lowering-sin.f6492.0

                  \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - {\color{blue}{\sin \phi_1}}^{2}} \]
              5. Simplified92.0%

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \color{blue}{{\sin \phi_1}^{2}}} \]
              6. Final simplification92.0%

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - {\sin \phi_1}^{2}} \]
              7. Add Preprocessing

              Alternative 15: 88.5% accurate, 2.2× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_1 \leq -1.3 \cdot 10^{+16}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{{\cos \phi_1}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta}\\ \end{array} \end{array} \]
              (FPCore (lambda1 phi1 phi2 delta theta)
               :precision binary64
               (if (<= phi1 -1.3e+16)
                 (+
                  lambda1
                  (atan2 (* (sin delta) (* (sin theta) (cos phi1))) (pow (cos phi1) 2.0)))
                 (+ lambda1 (atan2 (* (cos phi1) (* (sin theta) (sin delta))) (cos delta)))))
              double code(double lambda1, double phi1, double phi2, double delta, double theta) {
              	double tmp;
              	if (phi1 <= -1.3e+16) {
              		tmp = lambda1 + atan2((sin(delta) * (sin(theta) * cos(phi1))), pow(cos(phi1), 2.0));
              	} else {
              		tmp = lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), cos(delta));
              	}
              	return tmp;
              }
              
              real(8) function code(lambda1, phi1, phi2, delta, theta)
                  real(8), intent (in) :: lambda1
                  real(8), intent (in) :: phi1
                  real(8), intent (in) :: phi2
                  real(8), intent (in) :: delta
                  real(8), intent (in) :: theta
                  real(8) :: tmp
                  if (phi1 <= (-1.3d+16)) then
                      tmp = lambda1 + atan2((sin(delta) * (sin(theta) * cos(phi1))), (cos(phi1) ** 2.0d0))
                  else
                      tmp = lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), cos(delta))
                  end if
                  code = tmp
              end function
              
              public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
              	double tmp;
              	if (phi1 <= -1.3e+16) {
              		tmp = lambda1 + Math.atan2((Math.sin(delta) * (Math.sin(theta) * Math.cos(phi1))), Math.pow(Math.cos(phi1), 2.0));
              	} else {
              		tmp = lambda1 + Math.atan2((Math.cos(phi1) * (Math.sin(theta) * Math.sin(delta))), Math.cos(delta));
              	}
              	return tmp;
              }
              
              def code(lambda1, phi1, phi2, delta, theta):
              	tmp = 0
              	if phi1 <= -1.3e+16:
              		tmp = lambda1 + math.atan2((math.sin(delta) * (math.sin(theta) * math.cos(phi1))), math.pow(math.cos(phi1), 2.0))
              	else:
              		tmp = lambda1 + math.atan2((math.cos(phi1) * (math.sin(theta) * math.sin(delta))), math.cos(delta))
              	return tmp
              
              function code(lambda1, phi1, phi2, delta, theta)
              	tmp = 0.0
              	if (phi1 <= -1.3e+16)
              		tmp = Float64(lambda1 + atan(Float64(sin(delta) * Float64(sin(theta) * cos(phi1))), (cos(phi1) ^ 2.0)));
              	else
              		tmp = Float64(lambda1 + atan(Float64(cos(phi1) * Float64(sin(theta) * sin(delta))), cos(delta)));
              	end
              	return tmp
              end
              
              function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
              	tmp = 0.0;
              	if (phi1 <= -1.3e+16)
              		tmp = lambda1 + atan2((sin(delta) * (sin(theta) * cos(phi1))), (cos(phi1) ^ 2.0));
              	else
              		tmp = lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), cos(delta));
              	end
              	tmp_2 = tmp;
              end
              
              code[lambda1_, phi1_, phi2_, delta_, theta_] := If[LessEqual[phi1, -1.3e+16], N[(lambda1 + N[ArcTan[N[(N[Sin[delta], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[phi1], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;\phi_1 \leq -1.3 \cdot 10^{+16}:\\
              \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{{\cos \phi_1}^{2}}\\
              
              \mathbf{else}:\\
              \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if phi1 < -1.3e16

                1. Initial program 99.6%

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

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

                    \[\leadsto \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos theta \cdot \sin delta\right)\right)} + \lambda_1} \]
                  2. +-lowering-+.f64N/A

                    \[\leadsto \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos theta \cdot \sin delta\right)\right)} + \lambda_1} \]
                5. Simplified99.7%

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

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{1 + -1 \cdot {\sin \phi_1}^{2}}} + \lambda_1 \]
                7. Step-by-step derivation
                  1. mul-1-negN/A

                    \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{1 + \color{blue}{\left(\mathsf{neg}\left({\sin \phi_1}^{2}\right)\right)}} + \lambda_1 \]
                  2. unsub-negN/A

                    \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{1 - {\sin \phi_1}^{2}}} + \lambda_1 \]
                  3. unpow2N/A

                    \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{1 - \color{blue}{\sin \phi_1 \cdot \sin \phi_1}} + \lambda_1 \]
                  4. 1-sub-sinN/A

                    \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{\cos \phi_1 \cdot \cos \phi_1}} + \lambda_1 \]
                  5. unpow2N/A

                    \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{{\cos \phi_1}^{2}}} + \lambda_1 \]
                  6. pow-lowering-pow.f64N/A

                    \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{{\cos \phi_1}^{2}}} + \lambda_1 \]
                  7. cos-lowering-cos.f6484.5

                    \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{{\color{blue}{\cos \phi_1}}^{2}} + \lambda_1 \]
                8. Simplified84.5%

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

                if -1.3e16 < phi1

                1. Initial program 99.8%

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

                  \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\cos delta}} \]
                4. Step-by-step derivation
                  1. cos-lowering-cos.f6492.4

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\cos delta}} \]
                5. Simplified92.4%

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

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

              Alternative 16: 88.5% accurate, 2.5× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_1 \leq -3.5 \cdot 10^{+19}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{0.5 + \cos \left(\phi_1 + \phi_1\right) \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta}\\ \end{array} \end{array} \]
              (FPCore (lambda1 phi1 phi2 delta theta)
               :precision binary64
               (if (<= phi1 -3.5e+19)
                 (+
                  lambda1
                  (atan2
                   (* (sin theta) (* (sin delta) (cos phi1)))
                   (+ 0.5 (* (cos (+ phi1 phi1)) 0.5))))
                 (+ lambda1 (atan2 (* (cos phi1) (* (sin theta) (sin delta))) (cos delta)))))
              double code(double lambda1, double phi1, double phi2, double delta, double theta) {
              	double tmp;
              	if (phi1 <= -3.5e+19) {
              		tmp = lambda1 + atan2((sin(theta) * (sin(delta) * cos(phi1))), (0.5 + (cos((phi1 + phi1)) * 0.5)));
              	} else {
              		tmp = lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), cos(delta));
              	}
              	return tmp;
              }
              
              real(8) function code(lambda1, phi1, phi2, delta, theta)
                  real(8), intent (in) :: lambda1
                  real(8), intent (in) :: phi1
                  real(8), intent (in) :: phi2
                  real(8), intent (in) :: delta
                  real(8), intent (in) :: theta
                  real(8) :: tmp
                  if (phi1 <= (-3.5d+19)) then
                      tmp = lambda1 + atan2((sin(theta) * (sin(delta) * cos(phi1))), (0.5d0 + (cos((phi1 + phi1)) * 0.5d0)))
                  else
                      tmp = lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), cos(delta))
                  end if
                  code = tmp
              end function
              
              public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
              	double tmp;
              	if (phi1 <= -3.5e+19) {
              		tmp = lambda1 + Math.atan2((Math.sin(theta) * (Math.sin(delta) * Math.cos(phi1))), (0.5 + (Math.cos((phi1 + phi1)) * 0.5)));
              	} else {
              		tmp = lambda1 + Math.atan2((Math.cos(phi1) * (Math.sin(theta) * Math.sin(delta))), Math.cos(delta));
              	}
              	return tmp;
              }
              
              def code(lambda1, phi1, phi2, delta, theta):
              	tmp = 0
              	if phi1 <= -3.5e+19:
              		tmp = lambda1 + math.atan2((math.sin(theta) * (math.sin(delta) * math.cos(phi1))), (0.5 + (math.cos((phi1 + phi1)) * 0.5)))
              	else:
              		tmp = lambda1 + math.atan2((math.cos(phi1) * (math.sin(theta) * math.sin(delta))), math.cos(delta))
              	return tmp
              
              function code(lambda1, phi1, phi2, delta, theta)
              	tmp = 0.0
              	if (phi1 <= -3.5e+19)
              		tmp = Float64(lambda1 + atan(Float64(sin(theta) * Float64(sin(delta) * cos(phi1))), Float64(0.5 + Float64(cos(Float64(phi1 + phi1)) * 0.5))));
              	else
              		tmp = Float64(lambda1 + atan(Float64(cos(phi1) * Float64(sin(theta) * sin(delta))), cos(delta)));
              	end
              	return tmp
              end
              
              function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
              	tmp = 0.0;
              	if (phi1 <= -3.5e+19)
              		tmp = lambda1 + atan2((sin(theta) * (sin(delta) * cos(phi1))), (0.5 + (cos((phi1 + phi1)) * 0.5)));
              	else
              		tmp = lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), cos(delta));
              	end
              	tmp_2 = tmp;
              end
              
              code[lambda1_, phi1_, phi2_, delta_, theta_] := If[LessEqual[phi1, -3.5e+19], N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(0.5 + N[(N[Cos[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;\phi_1 \leq -3.5 \cdot 10^{+19}:\\
              \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{0.5 + \cos \left(\phi_1 + \phi_1\right) \cdot 0.5}\\
              
              \mathbf{else}:\\
              \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if phi1 < -3.5e19

                1. Initial program 99.6%

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

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{\cos delta \cdot \cos delta - \left(\sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)\right) \cdot \left(\sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)\right)}{\cos delta + \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}}} \]
                  2. /-lowering-/.f64N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{\cos delta \cdot \cos delta - \left(\sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)\right) \cdot \left(\sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)\right)}{\cos delta + \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}}} \]
                4. Applied egg-rr99.5%

                  \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{0.5 + \mathsf{fma}\left(0.5, \cos \left(delta + delta\right), -{\left(\sin \phi_1 \cdot \mathsf{fma}\left(\sin \phi_1, \cos delta, \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)\right)}^{2}\right)}{\mathsf{fma}\left(\sin \phi_1, \mathsf{fma}\left(\sin \phi_1, \cos delta, \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right), \cos delta\right)}}} \]
                5. Taylor expanded in delta around 0

                  \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1 - {\sin \phi_1}^{4}}{1 + {\sin \phi_1}^{2}}}} \]
                6. Step-by-step derivation
                  1. /-lowering-/.f64N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1 - {\sin \phi_1}^{4}}{1 + {\sin \phi_1}^{2}}}} \]
                  2. --lowering--.f64N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\frac{\color{blue}{1 - {\sin \phi_1}^{4}}}{1 + {\sin \phi_1}^{2}}} \]
                  3. pow-lowering-pow.f64N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\frac{1 - \color{blue}{{\sin \phi_1}^{4}}}{1 + {\sin \phi_1}^{2}}} \]
                  4. sin-lowering-sin.f64N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\frac{1 - {\color{blue}{\sin \phi_1}}^{4}}{1 + {\sin \phi_1}^{2}}} \]
                  5. +-lowering-+.f64N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\frac{1 - {\sin \phi_1}^{4}}{\color{blue}{1 + {\sin \phi_1}^{2}}}} \]
                  6. pow-lowering-pow.f64N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\frac{1 - {\sin \phi_1}^{4}}{1 + \color{blue}{{\sin \phi_1}^{2}}}} \]
                  7. sin-lowering-sin.f6484.3

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\frac{1 - {\sin \phi_1}^{4}}{1 + {\color{blue}{\sin \phi_1}}^{2}}} \]
                7. Simplified84.3%

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

                    \[\leadsto \color{blue}{\tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\frac{1 - {\sin \phi_1}^{4}}{1 + {\sin \phi_1}^{2}}} + \lambda_1} \]
                  2. +-lowering-+.f64N/A

                    \[\leadsto \color{blue}{\tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\frac{1 - {\sin \phi_1}^{4}}{1 + {\sin \phi_1}^{2}}} + \lambda_1} \]
                9. Applied egg-rr84.5%

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

                if -3.5e19 < phi1

                1. Initial program 99.8%

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

                  \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\cos delta}} \]
                4. Step-by-step derivation
                  1. cos-lowering-cos.f6492.4

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\cos delta}} \]
                5. Simplified92.4%

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

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

              Alternative 17: 88.5% accurate, 2.5× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_1 := \cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)\\ \mathbf{if}\;\phi_1 \leq -1.4 \cdot 10^{+18}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(0.5, \cos \left(\phi_1 \cdot 2\right), 0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos delta}\\ \end{array} \end{array} \]
              (FPCore (lambda1 phi1 phi2 delta theta)
               :precision binary64
               (let* ((t_1 (* (cos phi1) (* (sin theta) (sin delta)))))
                 (if (<= phi1 -1.4e+18)
                   (+ lambda1 (atan2 t_1 (fma 0.5 (cos (* phi1 2.0)) 0.5)))
                   (+ lambda1 (atan2 t_1 (cos delta))))))
              double code(double lambda1, double phi1, double phi2, double delta, double theta) {
              	double t_1 = cos(phi1) * (sin(theta) * sin(delta));
              	double tmp;
              	if (phi1 <= -1.4e+18) {
              		tmp = lambda1 + atan2(t_1, fma(0.5, cos((phi1 * 2.0)), 0.5));
              	} else {
              		tmp = lambda1 + atan2(t_1, cos(delta));
              	}
              	return tmp;
              }
              
              function code(lambda1, phi1, phi2, delta, theta)
              	t_1 = Float64(cos(phi1) * Float64(sin(theta) * sin(delta)))
              	tmp = 0.0
              	if (phi1 <= -1.4e+18)
              		tmp = Float64(lambda1 + atan(t_1, fma(0.5, cos(Float64(phi1 * 2.0)), 0.5)));
              	else
              		tmp = Float64(lambda1 + atan(t_1, cos(delta)));
              	end
              	return tmp
              end
              
              code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.4e+18], N[(lambda1 + N[ArcTan[t$95$1 / N[(0.5 * N[Cos[N[(phi1 * 2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_1 := \cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)\\
              \mathbf{if}\;\phi_1 \leq -1.4 \cdot 10^{+18}:\\
              \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(0.5, \cos \left(\phi_1 \cdot 2\right), 0.5\right)}\\
              
              \mathbf{else}:\\
              \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos delta}\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if phi1 < -1.4e18

                1. Initial program 99.6%

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

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \color{blue}{\left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
                  2. +-commutativeN/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \color{blue}{\left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta + \sin \phi_1 \cdot \cos delta\right)}} \]
                  3. distribute-lft-inN/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \color{blue}{\left(\sin \phi_1 \cdot \left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) + \sin \phi_1 \cdot \left(\sin \phi_1 \cdot \cos delta\right)\right)}} \]
                  4. associate-*r*N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \left(\color{blue}{\left(\sin \phi_1 \cdot \left(\cos \phi_1 \cdot \sin delta\right)\right) \cdot \cos theta} + \sin \phi_1 \cdot \left(\sin \phi_1 \cdot \cos delta\right)\right)} \]
                  5. accelerator-lowering-fma.f64N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \color{blue}{\mathsf{fma}\left(\sin \phi_1 \cdot \left(\cos \phi_1 \cdot \sin delta\right), \cos theta, \sin \phi_1 \cdot \left(\sin \phi_1 \cdot \cos delta\right)\right)}} \]
                  6. *-lowering-*.f64N/A

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

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \mathsf{fma}\left(\color{blue}{\sin \phi_1} \cdot \left(\cos \phi_1 \cdot \sin delta\right), \cos theta, \sin \phi_1 \cdot \left(\sin \phi_1 \cdot \cos delta\right)\right)} \]
                  8. *-lowering-*.f64N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \mathsf{fma}\left(\sin \phi_1 \cdot \color{blue}{\left(\cos \phi_1 \cdot \sin delta\right)}, \cos theta, \sin \phi_1 \cdot \left(\sin \phi_1 \cdot \cos delta\right)\right)} \]
                  9. cos-lowering-cos.f64N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \mathsf{fma}\left(\sin \phi_1 \cdot \left(\color{blue}{\cos \phi_1} \cdot \sin delta\right), \cos theta, \sin \phi_1 \cdot \left(\sin \phi_1 \cdot \cos delta\right)\right)} \]
                  10. sin-lowering-sin.f64N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \mathsf{fma}\left(\sin \phi_1 \cdot \left(\cos \phi_1 \cdot \color{blue}{\sin delta}\right), \cos theta, \sin \phi_1 \cdot \left(\sin \phi_1 \cdot \cos delta\right)\right)} \]
                  11. cos-lowering-cos.f64N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \mathsf{fma}\left(\sin \phi_1 \cdot \left(\cos \phi_1 \cdot \sin delta\right), \color{blue}{\cos theta}, \sin \phi_1 \cdot \left(\sin \phi_1 \cdot \cos delta\right)\right)} \]
                  12. associate-*r*N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \mathsf{fma}\left(\sin \phi_1 \cdot \left(\cos \phi_1 \cdot \sin delta\right), \cos theta, \color{blue}{\left(\sin \phi_1 \cdot \sin \phi_1\right) \cdot \cos delta}\right)} \]
                  13. *-lowering-*.f64N/A

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \mathsf{fma}\left(\sin \phi_1 \cdot \left(\cos \phi_1 \cdot \sin delta\right), \cos theta, \color{blue}{\left(\sin \phi_1 \cdot \sin \phi_1\right) \cdot \cos delta}\right)} \]
                4. Applied egg-rr99.8%

                  \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \color{blue}{\mathsf{fma}\left(\sin \phi_1 \cdot \left(\cos \phi_1 \cdot \sin delta\right), \cos theta, \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \phi_1\right)\right) \cdot \cos delta\right)}} \]
                5. Taylor expanded in delta around 0

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

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right) + \frac{1}{2}}} \]
                  2. accelerator-lowering-fma.f64N/A

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

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(\frac{1}{2}, \color{blue}{\cos \left(2 \cdot \phi_1\right)}, \frac{1}{2}\right)} \]
                  4. *-lowering-*.f6484.5

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(0.5, \cos \color{blue}{\left(2 \cdot \phi_1\right)}, 0.5\right)} \]
                7. Simplified84.5%

                  \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{fma}\left(0.5, \cos \left(2 \cdot \phi_1\right), 0.5\right)}} \]

                if -1.4e18 < phi1

                1. Initial program 99.8%

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

                  \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\cos delta}} \]
                4. Step-by-step derivation
                  1. cos-lowering-cos.f6492.4

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\cos delta}} \]
                5. Simplified92.4%

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

                \[\leadsto \begin{array}{l} \mathbf{if}\;\phi_1 \leq -1.4 \cdot 10^{+18}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\mathsf{fma}\left(0.5, \cos \left(\phi_1 \cdot 2\right), 0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta}\\ \end{array} \]
              5. Add Preprocessing

              Alternative 18: 87.9% accurate, 2.6× speedup?

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

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

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\cos delta}} \]
              4. Step-by-step derivation
                1. cos-lowering-cos.f6488.1

                  \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\cos delta}} \]
              5. Simplified88.1%

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\cos delta}} \]
              6. Final simplification88.1%

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

              Alternative 19: 85.6% accurate, 3.3× speedup?

              \[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \sin delta}{\cos delta} \end{array} \]
              (FPCore (lambda1 phi1 phi2 delta theta)
               :precision binary64
               (+ lambda1 (atan2 (* (sin theta) (sin delta)) (cos delta))))
              double code(double lambda1, double phi1, double phi2, double delta, double theta) {
              	return lambda1 + atan2((sin(theta) * sin(delta)), cos(delta));
              }
              
              real(8) function code(lambda1, phi1, phi2, delta, theta)
                  real(8), intent (in) :: lambda1
                  real(8), intent (in) :: phi1
                  real(8), intent (in) :: phi2
                  real(8), intent (in) :: delta
                  real(8), intent (in) :: theta
                  code = lambda1 + atan2((sin(theta) * sin(delta)), cos(delta))
              end function
              
              public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
              	return lambda1 + Math.atan2((Math.sin(theta) * Math.sin(delta)), Math.cos(delta));
              }
              
              def code(lambda1, phi1, phi2, delta, theta):
              	return lambda1 + math.atan2((math.sin(theta) * math.sin(delta)), math.cos(delta))
              
              function code(lambda1, phi1, phi2, delta, theta)
              	return Float64(lambda1 + atan(Float64(sin(theta) * sin(delta)), cos(delta)))
              end
              
              function tmp = code(lambda1, phi1, phi2, delta, theta)
              	tmp = lambda1 + atan2((sin(theta) * sin(delta)), cos(delta));
              end
              
              code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \sin delta}{\cos delta}
              \end{array}
              
              Derivation
              1. Initial program 99.8%

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

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

                  \[\leadsto \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos theta \cdot \sin delta\right)\right)} + \lambda_1} \]
                2. +-lowering-+.f64N/A

                  \[\leadsto \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\cos theta \cdot \sin delta\right)\right)} + \lambda_1} \]
              5. Simplified99.8%

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

                \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{\cos delta}} + \lambda_1 \]
              7. Step-by-step derivation
                1. cos-lowering-cos.f6488.1

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\color{blue}{\cos delta}} + \lambda_1 \]
              8. Simplified88.1%

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

                \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{\cos delta} + \lambda_1 \]
              10. Step-by-step derivation
                1. *-lowering-*.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{\cos delta} + \lambda_1 \]
                2. sin-lowering-sin.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin delta} \cdot \sin theta}{\cos delta} + \lambda_1 \]
                3. sin-lowering-sin.f6484.4

                  \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{\cos delta} + \lambda_1 \]
              11. Simplified84.4%

                \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin delta \cdot \sin theta}}{\cos delta} + \lambda_1 \]
              12. Final simplification84.4%

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \sin delta}{\cos delta} \]
              13. Add Preprocessing

              Alternative 20: 69.2% accurate, 1341.0× speedup?

              \[\begin{array}{l} \\ \lambda_1 \end{array} \]
              (FPCore (lambda1 phi1 phi2 delta theta) :precision binary64 lambda1)
              double code(double lambda1, double phi1, double phi2, double delta, double theta) {
              	return lambda1;
              }
              
              real(8) function code(lambda1, phi1, phi2, delta, theta)
                  real(8), intent (in) :: lambda1
                  real(8), intent (in) :: phi1
                  real(8), intent (in) :: phi2
                  real(8), intent (in) :: delta
                  real(8), intent (in) :: theta
                  code = lambda1
              end function
              
              public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
              	return lambda1;
              }
              
              def code(lambda1, phi1, phi2, delta, theta):
              	return lambda1
              
              function code(lambda1, phi1, phi2, delta, theta)
              	return lambda1
              end
              
              function tmp = code(lambda1, phi1, phi2, delta, theta)
              	tmp = lambda1;
              end
              
              code[lambda1_, phi1_, phi2_, delta_, theta_] := lambda1
              
              \begin{array}{l}
              
              \\
              \lambda_1
              \end{array}
              
              Derivation
              1. Initial program 99.8%

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

                \[\leadsto \color{blue}{\lambda_1} \]
              4. Step-by-step derivation
                1. Simplified68.8%

                  \[\leadsto \color{blue}{\lambda_1} \]
                2. Add Preprocessing

                Reproduce

                ?
                herbie shell --seed 2024204 
                (FPCore (lambda1 phi1 phi2 delta theta)
                  :name "Destination given bearing on a great circle"
                  :precision binary64
                  (+ lambda1 (atan2 (* (* (sin theta) (sin delta)) (cos phi1)) (- (cos delta) (* (sin phi1) (sin (asin (+ (* (sin phi1) (cos delta)) (* (* (cos phi1) (sin delta)) (cos theta))))))))))