Destination given bearing on a great circle

Percentage Accurate: 99.7% → 99.8%
Time: 19.2s
Alternatives: 17
Speedup: 1.4×

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 17 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(\cos \phi_1 \cdot \cos delta, \cos \phi_1, \left(\sin delta \cdot \cos theta\right) \cdot \frac{\sin \left(\phi_1 + \phi_1\right)}{-2}\right)} + \lambda_1 \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (+
  (atan2
   (* (sin theta) (* (sin delta) (cos phi1)))
   (fma
    (* (cos phi1) (cos delta))
    (cos phi1)
    (* (* (sin delta) (cos theta)) (/ (sin (+ phi1 phi1)) (- 2.0)))))
  lambda1))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	return atan2((sin(theta) * (sin(delta) * cos(phi1))), fma((cos(phi1) * cos(delta)), cos(phi1), ((sin(delta) * cos(theta)) * (sin((phi1 + phi1)) / -2.0)))) + lambda1;
}
function code(lambda1, phi1, phi2, delta, theta)
	return Float64(atan(Float64(sin(theta) * Float64(sin(delta) * cos(phi1))), fma(Float64(cos(phi1) * cos(delta)), cos(phi1), Float64(Float64(sin(delta) * cos(theta)) * Float64(sin(Float64(phi1 + phi1)) / Float64(-2.0))))) + 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[phi1], $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[(N[Sin[delta], $MachinePrecision] * N[Cos[theta], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] / (-2.0)), $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(\cos \phi_1 \cdot \cos delta, \cos \phi_1, \left(\sin delta \cdot \cos theta\right) \cdot \frac{\sin \left(\phi_1 + \phi_1\right)}{-2}\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. Step-by-step derivation
    1. lift--.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    2. lift-*.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    3. lift-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 \color{blue}{\sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    4. lift-asin.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 \sin \color{blue}{\sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    5. 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)}} \]
    6. lift-+.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}{\left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    7. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(1 + \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)}, \cos delta, \left(\sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right) \cdot \left(\mathsf{neg}\left(\sin \phi_1\right)\right)\right)} + \lambda_1 \]
    6. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.8% 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(\cos delta, \mathsf{fma}\left(0.5, \cos \left(\phi_1 \cdot -2\right), 0.5\right), \cos theta \cdot \left(\left(\sin delta \cdot \sin \phi_1\right) \cdot \left(-\cos \phi_1\right)\right)\right)} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (+
  lambda1
  (atan2
   (* (sin delta) (* (sin theta) (cos phi1)))
   (fma
    (cos delta)
    (fma 0.5 (cos (* phi1 -2.0)) 0.5)
    (* (cos theta) (* (* (sin delta) (sin phi1)) (- (cos phi1))))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	return lambda1 + atan2((sin(delta) * (sin(theta) * cos(phi1))), fma(cos(delta), fma(0.5, cos((phi1 * -2.0)), 0.5), (cos(theta) * ((sin(delta) * sin(phi1)) * -cos(phi1)))));
}
function code(lambda1, phi1, phi2, delta, theta)
	return Float64(lambda1 + atan(Float64(sin(delta) * Float64(sin(theta) * cos(phi1))), fma(cos(delta), fma(0.5, cos(Float64(phi1 * -2.0)), 0.5), Float64(cos(theta) * Float64(Float64(sin(delta) * sin(phi1)) * Float64(-cos(phi1)))))))
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[Cos[delta], $MachinePrecision] * N[(0.5 * N[Cos[N[(phi1 * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision] + N[(N[Cos[theta], $MachinePrecision] * N[(N[(N[Sin[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * (-N[Cos[phi1], $MachinePrecision])), $MachinePrecision]), $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(\cos delta, \mathsf{fma}\left(0.5, \cos \left(\phi_1 \cdot -2\right), 0.5\right), \cos theta \cdot \left(\left(\sin delta \cdot \sin \phi_1\right) \cdot \left(-\cos \phi_1\right)\right)\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. Step-by-step derivation
    1. lift--.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    2. lift-*.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    3. lift-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 \color{blue}{\sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    4. lift-asin.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 \sin \color{blue}{\sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    5. 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)}} \]
    6. lift-+.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}{\left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    7. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left({\cos \phi_1}^{2}, \cos delta, \cos theta \cdot \left(\frac{\sin \left(\phi_1 + \phi_1\right)}{2} \cdot \left(-\sin delta\right)\right)\right)} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (+
  lambda1
  (atan2
   (* (sin theta) (* (sin delta) (cos phi1)))
   (fma
    (pow (cos phi1) 2.0)
    (cos delta)
    (* (cos theta) (* (/ (sin (+ phi1 phi1)) 2.0) (- (sin delta))))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	return lambda1 + atan2((sin(theta) * (sin(delta) * cos(phi1))), fma(pow(cos(phi1), 2.0), cos(delta), (cos(theta) * ((sin((phi1 + phi1)) / 2.0) * -sin(delta)))));
}
function code(lambda1, phi1, phi2, delta, theta)
	return Float64(lambda1 + atan(Float64(sin(theta) * Float64(sin(delta) * cos(phi1))), fma((cos(phi1) ^ 2.0), cos(delta), Float64(cos(theta) * Float64(Float64(sin(Float64(phi1 + phi1)) / 2.0) * Float64(-sin(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[Power[N[Cos[phi1], $MachinePrecision], 2.0], $MachinePrecision] * N[Cos[delta], $MachinePrecision] + N[(N[Cos[theta], $MachinePrecision] * N[(N[(N[Sin[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] * (-N[Sin[delta], $MachinePrecision])), $MachinePrecision]), $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({\cos \phi_1}^{2}, \cos delta, \cos theta \cdot \left(\frac{\sin \left(\phi_1 + \phi_1\right)}{2} \cdot \left(-\sin delta\right)\right)\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. Step-by-step derivation
    1. lift--.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    2. lift-*.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    3. lift-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 \color{blue}{\sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    4. lift-asin.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 \sin \color{blue}{\sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    5. 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)}} \]
    6. lift-+.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}{\left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    7. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(1 + \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)}, \cos delta, \left(\sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right) \cdot \left(\mathsf{neg}\left(\sin \phi_1\right)\right)\right)} + \lambda_1 \]
    6. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \lambda_1 + \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, \left(\sin delta \cdot \cos theta\right) \cdot \frac{\sin \left(\phi_1 + \phi_1\right)}{-2}\right)} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (+
  lambda1
  (atan2
   (* (sin theta) (* (sin delta) (cos phi1)))
   (fma
    (fma (cos (+ phi1 phi1)) 0.5 0.5)
    (cos delta)
    (* (* (sin delta) (cos theta)) (/ (sin (+ phi1 phi1)) (- 2.0)))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	return lambda1 + atan2((sin(theta) * (sin(delta) * cos(phi1))), fma(fma(cos((phi1 + phi1)), 0.5, 0.5), cos(delta), ((sin(delta) * cos(theta)) * (sin((phi1 + phi1)) / -2.0))));
}
function code(lambda1, phi1, phi2, delta, theta)
	return Float64(lambda1 + 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) * cos(theta)) * Float64(sin(Float64(phi1 + phi1)) / Float64(-2.0))))))
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[(N[Cos[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision] * N[Cos[delta], $MachinePrecision] + N[(N[(N[Sin[delta], $MachinePrecision] * N[Cos[theta], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] / (-2.0)), $MachinePrecision]), $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(\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right), \cos delta, \left(\sin delta \cdot \cos theta\right) \cdot \frac{\sin \left(\phi_1 + \phi_1\right)}{-2}\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. Step-by-step derivation
    1. lift--.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    2. lift-*.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    3. lift-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 \color{blue}{\sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    4. lift-asin.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 \sin \color{blue}{\sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    5. 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)}} \]
    6. lift-+.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}{\left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    7. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(1 + \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)}, \cos delta, \left(\sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right) \cdot \left(\mathsf{neg}\left(\sin \phi_1\right)\right)\right)} + \lambda_1 \]
    6. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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), \frac{1}{2}, \frac{1}{2}\right), \cos delta, \color{blue}{\left(\sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right) \cdot \left(\mathsf{neg}\left(\sin \phi_1\right)\right)}\right)} + \lambda_1 \]
    15. lift-neg.f64N/A

      \[\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), \frac{1}{2}, \frac{1}{2}\right), \cos delta, \left(\sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin \phi_1\right)\right)}\right)} + \lambda_1 \]
    16. distribute-rgt-neg-outN/A

      \[\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), \frac{1}{2}, \frac{1}{2}\right), \cos delta, \color{blue}{\mathsf{neg}\left(\left(\sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right) \cdot \sin \phi_1\right)}\right)} + \lambda_1 \]
  10. Applied rewrites99.8%

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

    \[\leadsto \lambda_1 + \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, \left(\sin delta \cdot \cos theta\right) \cdot \frac{\sin \left(\phi_1 + \phi_1\right)}{-2}\right)} \]
  12. Add Preprocessing

Alternative 5: 99.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\frac{\sin \left(\phi_1 + \phi_1\right)}{2} \cdot \left(-\sin delta\right), \cos theta, \cos delta \cdot \mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right)\right)} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (+
  lambda1
  (atan2
   (* (sin theta) (* (sin delta) (cos phi1)))
   (fma
    (* (/ (sin (+ phi1 phi1)) 2.0) (- (sin delta)))
    (cos theta)
    (* (cos delta) (fma (cos (+ phi1 phi1)) 0.5 0.5))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	return lambda1 + atan2((sin(theta) * (sin(delta) * cos(phi1))), fma(((sin((phi1 + phi1)) / 2.0) * -sin(delta)), cos(theta), (cos(delta) * fma(cos((phi1 + phi1)), 0.5, 0.5))));
}
function code(lambda1, phi1, phi2, delta, theta)
	return Float64(lambda1 + atan(Float64(sin(theta) * Float64(sin(delta) * cos(phi1))), fma(Float64(Float64(sin(Float64(phi1 + phi1)) / 2.0) * Float64(-sin(delta))), cos(theta), Float64(cos(delta) * fma(cos(Float64(phi1 + phi1)), 0.5, 0.5)))))
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[(N[(N[Sin[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] * (-N[Sin[delta], $MachinePrecision])), $MachinePrecision] * N[Cos[theta], $MachinePrecision] + N[(N[Cos[delta], $MachinePrecision] * N[(N[Cos[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision]), $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(\frac{\sin \left(\phi_1 + \phi_1\right)}{2} \cdot \left(-\sin delta\right), \cos theta, \cos delta \cdot \mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right)\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. Step-by-step derivation
    1. lift--.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    2. lift-*.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    3. lift-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 \color{blue}{\sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    4. lift-asin.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 \sin \color{blue}{\sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    5. 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)}} \]
    6. lift-+.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}{\left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    7. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(1 + \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)}, \cos delta, \left(\sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right) \cdot \left(\mathsf{neg}\left(\sin \phi_1\right)\right)\right)} + \lambda_1 \]
    6. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 94.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right), \cos delta, \left(\sin delta \cdot \sin \phi_1\right) \cdot \left(-\cos \phi_1\right)\right)} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (+
  lambda1
  (atan2
   (* (cos phi1) (* (sin theta) (sin delta)))
   (fma
    (fma (cos (+ phi1 phi1)) 0.5 0.5)
    (cos delta)
    (* (* (sin delta) (sin phi1)) (- (cos phi1)))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	return lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), fma(fma(cos((phi1 + phi1)), 0.5, 0.5), cos(delta), ((sin(delta) * sin(phi1)) * -cos(phi1))));
}
function code(lambda1, phi1, phi2, delta, theta)
	return Float64(lambda1 + atan(Float64(cos(phi1) * Float64(sin(theta) * sin(delta))), fma(fma(cos(Float64(phi1 + phi1)), 0.5, 0.5), cos(delta), Float64(Float64(sin(delta) * sin(phi1)) * Float64(-cos(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[(N[Cos[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision] * N[Cos[delta], $MachinePrecision] + N[(N[(N[Sin[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * (-N[Cos[phi1], $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(\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right), \cos delta, \left(\sin delta \cdot \sin \phi_1\right) \cdot \left(-\cos \phi_1\right)\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. Step-by-step derivation
    1. lift-*.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    2. lift-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 \color{blue}{\sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    3. lift-asin.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 \sin \color{blue}{\sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    4. 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)}} \]
    5. lift-+.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}{\left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
    6. distribute-rgt-inN/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \color{blue}{\left(\left(\sin \phi_1 \cdot \cos delta\right) \cdot \sin \phi_1 + \left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) \cdot \sin \phi_1\right)}} \]
    7. lift-*.f64N/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 \cos delta\right)} \cdot \sin \phi_1 + \left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) \cdot \sin \phi_1\right)} \]
    8. 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}{\sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1\right)} + \left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) \cdot \sin \phi_1\right)} \]
    9. *-commutativeN/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \left(\sin \phi_1 \cdot \color{blue}{\left(\sin \phi_1 \cdot \cos delta\right)} + \left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) \cdot \sin \phi_1\right)} \]
    10. 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 \sin \phi_1\right) \cdot \cos delta} + \left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) \cdot \sin \phi_1\right)} \]
    11. lower-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 \sin \phi_1, \cos delta, \left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) \cdot \sin \phi_1\right)}} \]
  4. Applied rewrites99.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(0.5 - 0.5 \cdot \cos \left(2 \cdot \phi_1\right), \cos delta, \left(\cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\right)\right) \cdot \sin \phi_1\right)}} \]
  5. 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 - \left(\cos delta \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right) + \cos \phi_1 \cdot \left(\sin delta \cdot \sin \phi_1\right)\right)}} \]
  6. Step-by-step derivation
    1. associate--r+N/A

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

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

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

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\cos delta + \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\right)} + \left(\mathsf{neg}\left(\cos \phi_1 \cdot \left(\sin delta \cdot \sin \phi_1\right)\right)\right)} \]
    5. distribute-rgt1-inN/A

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\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} + \left(\mathsf{neg}\left(\cos \phi_1 \cdot \left(\sin delta \cdot \sin \phi_1\right)\right)\right)} \]
    6. lower-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(\left(\mathsf{neg}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)\right)\right)\right) + 1, \cos delta, \mathsf{neg}\left(\cos \phi_1 \cdot \left(\sin delta \cdot \sin \phi_1\right)\right)\right)}} \]
  7. Applied rewrites94.8%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{fma}\left(\left(-\mathsf{fma}\left(\cos \left(2 \cdot \phi_1\right), -0.5, 0.5\right)\right) + 1, \cos delta, \left(\sin delta \cdot \sin \phi_1\right) \cdot \left(-\cos \phi_1\right)\right)}} \]
  8. Step-by-step derivation
    1. Applied rewrites94.9%

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

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

    Alternative 7: 92.5% 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. lower-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. lower-sin.f6491.7

        \[\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. Applied rewrites91.7%

      \[\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 simplification91.7%

      \[\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 8: 92.0% accurate, 2.1× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)\\ t_2 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{\frac{1}{\frac{1}{\cos delta}}}\\ \mathbf{if}\;delta \leq -10:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;delta \leq 3.5 \cdot 10^{-22}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{{\cos \phi_1}^{2}}\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
    (FPCore (lambda1 phi1 phi2 delta theta)
     :precision binary64
     (let* ((t_1 (* (cos phi1) (* (sin theta) (sin delta))))
            (t_2 (+ lambda1 (atan2 t_1 (/ 1.0 (/ 1.0 (cos delta)))))))
       (if (<= delta -10.0)
         t_2
         (if (<= delta 3.5e-22)
           (+ lambda1 (atan2 t_1 (pow (cos phi1) 2.0)))
           t_2))))
    double code(double lambda1, double phi1, double phi2, double delta, double theta) {
    	double t_1 = cos(phi1) * (sin(theta) * sin(delta));
    	double t_2 = lambda1 + atan2(t_1, (1.0 / (1.0 / cos(delta))));
    	double tmp;
    	if (delta <= -10.0) {
    		tmp = t_2;
    	} else if (delta <= 3.5e-22) {
    		tmp = lambda1 + atan2(t_1, pow(cos(phi1), 2.0));
    	} 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 = cos(phi1) * (sin(theta) * sin(delta))
        t_2 = lambda1 + atan2(t_1, (1.0d0 / (1.0d0 / cos(delta))))
        if (delta <= (-10.0d0)) then
            tmp = t_2
        else if (delta <= 3.5d-22) then
            tmp = lambda1 + atan2(t_1, (cos(phi1) ** 2.0d0))
        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.cos(phi1) * (Math.sin(theta) * Math.sin(delta));
    	double t_2 = lambda1 + Math.atan2(t_1, (1.0 / (1.0 / Math.cos(delta))));
    	double tmp;
    	if (delta <= -10.0) {
    		tmp = t_2;
    	} else if (delta <= 3.5e-22) {
    		tmp = lambda1 + Math.atan2(t_1, Math.pow(Math.cos(phi1), 2.0));
    	} else {
    		tmp = t_2;
    	}
    	return tmp;
    }
    
    def code(lambda1, phi1, phi2, delta, theta):
    	t_1 = math.cos(phi1) * (math.sin(theta) * math.sin(delta))
    	t_2 = lambda1 + math.atan2(t_1, (1.0 / (1.0 / math.cos(delta))))
    	tmp = 0
    	if delta <= -10.0:
    		tmp = t_2
    	elif delta <= 3.5e-22:
    		tmp = lambda1 + math.atan2(t_1, math.pow(math.cos(phi1), 2.0))
    	else:
    		tmp = t_2
    	return tmp
    
    function code(lambda1, phi1, phi2, delta, theta)
    	t_1 = Float64(cos(phi1) * Float64(sin(theta) * sin(delta)))
    	t_2 = Float64(lambda1 + atan(t_1, Float64(1.0 / Float64(1.0 / cos(delta)))))
    	tmp = 0.0
    	if (delta <= -10.0)
    		tmp = t_2;
    	elseif (delta <= 3.5e-22)
    		tmp = Float64(lambda1 + atan(t_1, (cos(phi1) ^ 2.0)));
    	else
    		tmp = t_2;
    	end
    	return tmp
    end
    
    function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
    	t_1 = cos(phi1) * (sin(theta) * sin(delta));
    	t_2 = lambda1 + atan2(t_1, (1.0 / (1.0 / cos(delta))));
    	tmp = 0.0;
    	if (delta <= -10.0)
    		tmp = t_2;
    	elseif (delta <= 3.5e-22)
    		tmp = lambda1 + atan2(t_1, (cos(phi1) ^ 2.0));
    	else
    		tmp = t_2;
    	end
    	tmp_2 = 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]}, Block[{t$95$2 = N[(lambda1 + N[ArcTan[t$95$1 / N[(1.0 / N[(1.0 / N[Cos[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[delta, -10.0], t$95$2, If[LessEqual[delta, 3.5e-22], N[(lambda1 + N[ArcTan[t$95$1 / N[Power[N[Cos[phi1], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)\\
    t_2 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{\frac{1}{\frac{1}{\cos delta}}}\\
    \mathbf{if}\;delta \leq -10:\\
    \;\;\;\;t\_2\\
    
    \mathbf{elif}\;delta \leq 3.5 \cdot 10^{-22}:\\
    \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{{\cos \phi_1}^{2}}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_2\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if delta < -10 or 3.50000000000000005e-22 < delta

      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. Step-by-step derivation
        1. lift--.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
        2. 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)}}} \]
        3. clear-numN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1}{\frac{\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)}{\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)}}}} \]
        4. lower-/.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1}{\frac{\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)}{\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)}}}} \]
      4. Applied rewrites99.8%

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

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

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

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

      if -10 < delta < 3.50000000000000005e-22

      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. Step-by-step derivation
        1. lift--.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
        2. 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)}}} \]
        3. clear-numN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1}{\frac{\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)}{\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)}}}} \]
        4. lower-/.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1}{\frac{\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)}{\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)}}}} \]
      4. Applied rewrites99.8%

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

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

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

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

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

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

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

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

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

    Alternative 9: 92.0% accurate, 2.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)\\ t_2 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{\frac{1}{\frac{1}{\cos delta}}}\\ \mathbf{if}\;delta \leq -10:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;delta \leq 3.5 \cdot 10^{-22}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
    (FPCore (lambda1 phi1 phi2 delta theta)
     :precision binary64
     (let* ((t_1 (* (cos phi1) (* (sin theta) (sin delta))))
            (t_2 (+ lambda1 (atan2 t_1 (/ 1.0 (/ 1.0 (cos delta)))))))
       (if (<= delta -10.0)
         t_2
         (if (<= delta 3.5e-22)
           (+ lambda1 (atan2 t_1 (fma (cos (+ phi1 phi1)) 0.5 0.5)))
           t_2))))
    double code(double lambda1, double phi1, double phi2, double delta, double theta) {
    	double t_1 = cos(phi1) * (sin(theta) * sin(delta));
    	double t_2 = lambda1 + atan2(t_1, (1.0 / (1.0 / cos(delta))));
    	double tmp;
    	if (delta <= -10.0) {
    		tmp = t_2;
    	} else if (delta <= 3.5e-22) {
    		tmp = lambda1 + atan2(t_1, fma(cos((phi1 + phi1)), 0.5, 0.5));
    	} else {
    		tmp = t_2;
    	}
    	return tmp;
    }
    
    function code(lambda1, phi1, phi2, delta, theta)
    	t_1 = Float64(cos(phi1) * Float64(sin(theta) * sin(delta)))
    	t_2 = Float64(lambda1 + atan(t_1, Float64(1.0 / Float64(1.0 / cos(delta)))))
    	tmp = 0.0
    	if (delta <= -10.0)
    		tmp = t_2;
    	elseif (delta <= 3.5e-22)
    		tmp = Float64(lambda1 + atan(t_1, fma(cos(Float64(phi1 + phi1)), 0.5, 0.5)));
    	else
    		tmp = t_2;
    	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]}, Block[{t$95$2 = N[(lambda1 + N[ArcTan[t$95$1 / N[(1.0 / N[(1.0 / N[Cos[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[delta, -10.0], t$95$2, If[LessEqual[delta, 3.5e-22], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)\\
    t_2 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{\frac{1}{\frac{1}{\cos delta}}}\\
    \mathbf{if}\;delta \leq -10:\\
    \;\;\;\;t\_2\\
    
    \mathbf{elif}\;delta \leq 3.5 \cdot 10^{-22}:\\
    \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_2\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if delta < -10 or 3.50000000000000005e-22 < delta

      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. Step-by-step derivation
        1. lift--.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
        2. 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)}}} \]
        3. clear-numN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1}{\frac{\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)}{\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)}}}} \]
        4. lower-/.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1}{\frac{\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)}{\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)}}}} \]
      4. Applied rewrites99.8%

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

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

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

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

      if -10 < delta < 3.50000000000000005e-22

      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. Step-by-step derivation
        1. lift--.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
        2. 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)}}} \]
        3. clear-numN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1}{\frac{\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)}{\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)}}}} \]
        4. lower-/.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1}{\frac{\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)}{\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)}}}} \]
      4. Applied rewrites99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 10: 92.0% accurate, 2.5× speedup?

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

      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}} \]
      4. Step-by-step derivation
        1. lower-cos.f6486.0

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

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

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

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

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

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

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

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

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

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

      if -10 < delta < 3.50000000000000005e-22

      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. Step-by-step derivation
        1. lift--.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
        2. 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)}}} \]
        3. clear-numN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1}{\frac{\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)}{\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)}}}} \]
        4. lower-/.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1}{\frac{\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)}{\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)}}}} \]
      4. Applied rewrites99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 11: 92.1% accurate, 2.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\cos delta}\\ \mathbf{if}\;delta \leq -10:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;delta \leq 3.5 \cdot 10^{-22}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot delta\right)}{{\cos \phi_1}^{2}}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (lambda1 phi1 phi2 delta theta)
     :precision binary64
     (let* ((t_1
             (+
              lambda1
              (atan2 (* (sin delta) (* (sin theta) (cos phi1))) (cos delta)))))
       (if (<= delta -10.0)
         t_1
         (if (<= delta 3.5e-22)
           (+
            lambda1
            (atan2 (* (cos phi1) (* (sin theta) delta)) (pow (cos phi1) 2.0)))
           t_1))))
    double code(double lambda1, double phi1, double phi2, double delta, double theta) {
    	double t_1 = lambda1 + atan2((sin(delta) * (sin(theta) * cos(phi1))), cos(delta));
    	double tmp;
    	if (delta <= -10.0) {
    		tmp = t_1;
    	} else if (delta <= 3.5e-22) {
    		tmp = lambda1 + atan2((cos(phi1) * (sin(theta) * delta)), pow(cos(phi1), 2.0));
    	} else {
    		tmp = 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) :: tmp
        t_1 = lambda1 + atan2((sin(delta) * (sin(theta) * cos(phi1))), cos(delta))
        if (delta <= (-10.0d0)) then
            tmp = t_1
        else if (delta <= 3.5d-22) then
            tmp = lambda1 + atan2((cos(phi1) * (sin(theta) * delta)), (cos(phi1) ** 2.0d0))
        else
            tmp = 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 = lambda1 + Math.atan2((Math.sin(delta) * (Math.sin(theta) * Math.cos(phi1))), Math.cos(delta));
    	double tmp;
    	if (delta <= -10.0) {
    		tmp = t_1;
    	} else if (delta <= 3.5e-22) {
    		tmp = lambda1 + Math.atan2((Math.cos(phi1) * (Math.sin(theta) * delta)), Math.pow(Math.cos(phi1), 2.0));
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    def code(lambda1, phi1, phi2, delta, theta):
    	t_1 = lambda1 + math.atan2((math.sin(delta) * (math.sin(theta) * math.cos(phi1))), math.cos(delta))
    	tmp = 0
    	if delta <= -10.0:
    		tmp = t_1
    	elif delta <= 3.5e-22:
    		tmp = lambda1 + math.atan2((math.cos(phi1) * (math.sin(theta) * delta)), math.pow(math.cos(phi1), 2.0))
    	else:
    		tmp = t_1
    	return tmp
    
    function code(lambda1, phi1, phi2, delta, theta)
    	t_1 = Float64(lambda1 + atan(Float64(sin(delta) * Float64(sin(theta) * cos(phi1))), cos(delta)))
    	tmp = 0.0
    	if (delta <= -10.0)
    		tmp = t_1;
    	elseif (delta <= 3.5e-22)
    		tmp = Float64(lambda1 + atan(Float64(cos(phi1) * Float64(sin(theta) * delta)), (cos(phi1) ^ 2.0)));
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
    	t_1 = lambda1 + atan2((sin(delta) * (sin(theta) * cos(phi1))), cos(delta));
    	tmp = 0.0;
    	if (delta <= -10.0)
    		tmp = t_1;
    	elseif (delta <= 3.5e-22)
    		tmp = lambda1 + atan2((cos(phi1) * (sin(theta) * delta)), (cos(phi1) ^ 2.0));
    	else
    		tmp = t_1;
    	end
    	tmp_2 = tmp;
    end
    
    code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(lambda1 + N[ArcTan[N[(N[Sin[delta], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[delta, -10.0], t$95$1, If[LessEqual[delta, 3.5e-22], N[(lambda1 + N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * delta), $MachinePrecision]), $MachinePrecision] / N[Power[N[Cos[phi1], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\cos delta}\\
    \mathbf{if}\;delta \leq -10:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;delta \leq 3.5 \cdot 10^{-22}:\\
    \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot delta\right)}{{\cos \phi_1}^{2}}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if delta < -10 or 3.50000000000000005e-22 < delta

      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}} \]
      4. Step-by-step derivation
        1. lower-cos.f6486.0

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

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

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

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

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

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

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

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

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

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

      if -10 < delta < 3.50000000000000005e-22

      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. Step-by-step derivation
        1. lift--.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 \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}} \]
        2. 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)}}} \]
        3. clear-numN/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1}{\frac{\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)}{\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)}}}} \]
        4. lower-/.f64N/A

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\frac{1}{\frac{\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)}{\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)}}}} \]
      4. Applied rewrites99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 12: 89.0% accurate, 2.6× speedup?

    \[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\cos delta} \end{array} \]
    (FPCore (lambda1 phi1 phi2 delta theta)
     :precision binary64
     (+ lambda1 (atan2 (* (sin delta) (* (sin theta) (cos phi1))) (cos delta))))
    double code(double lambda1, double phi1, double phi2, double delta, double theta) {
    	return lambda1 + atan2((sin(delta) * (sin(theta) * cos(phi1))), 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(delta) * (sin(theta) * cos(phi1))), cos(delta))
    end function
    
    public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
    	return lambda1 + Math.atan2((Math.sin(delta) * (Math.sin(theta) * Math.cos(phi1))), Math.cos(delta));
    }
    
    def code(lambda1, phi1, phi2, delta, theta):
    	return lambda1 + math.atan2((math.sin(delta) * (math.sin(theta) * math.cos(phi1))), math.cos(delta))
    
    function code(lambda1, phi1, phi2, delta, theta)
    	return Float64(lambda1 + atan(Float64(sin(delta) * Float64(sin(theta) * cos(phi1))), cos(delta)))
    end
    
    function tmp = code(lambda1, phi1, phi2, delta, theta)
    	tmp = lambda1 + atan2((sin(delta) * (sin(theta) * cos(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[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\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. lower-cos.f6488.0

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

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

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

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

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

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

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

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

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

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

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

    Alternative 13: 86.7% 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 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. lower-cos.f6488.0

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

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

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

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

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{\cos delta} \]
    8. Applied rewrites84.6%

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

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

    Alternative 14: 80.7% accurate, 4.0× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;delta \leq -1.16 \cdot 10^{-16}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \sin delta}{\cos delta}\\ \mathbf{elif}\;delta \leq 4.8:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{delta \cdot \left(\sin theta \cdot \mathsf{fma}\left(-0.16666666666666666, delta \cdot delta, 1\right)\right)}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \left(\sin delta \cdot \mathsf{fma}\left(-0.16666666666666666, theta \cdot theta, 1\right)\right)}{\cos delta}\\ \end{array} \end{array} \]
    (FPCore (lambda1 phi1 phi2 delta theta)
     :precision binary64
     (if (<= delta -1.16e-16)
       (+ lambda1 (atan2 (* theta (sin delta)) (cos delta)))
       (if (<= delta 4.8)
         (+
          lambda1
          (atan2
           (* delta (* (sin theta) (fma -0.16666666666666666 (* delta delta) 1.0)))
           (cos delta)))
         (+
          lambda1
          (atan2
           (* theta (* (sin delta) (fma -0.16666666666666666 (* theta theta) 1.0)))
           (cos delta))))))
    double code(double lambda1, double phi1, double phi2, double delta, double theta) {
    	double tmp;
    	if (delta <= -1.16e-16) {
    		tmp = lambda1 + atan2((theta * sin(delta)), cos(delta));
    	} else if (delta <= 4.8) {
    		tmp = lambda1 + atan2((delta * (sin(theta) * fma(-0.16666666666666666, (delta * delta), 1.0))), cos(delta));
    	} else {
    		tmp = lambda1 + atan2((theta * (sin(delta) * fma(-0.16666666666666666, (theta * theta), 1.0))), cos(delta));
    	}
    	return tmp;
    }
    
    function code(lambda1, phi1, phi2, delta, theta)
    	tmp = 0.0
    	if (delta <= -1.16e-16)
    		tmp = Float64(lambda1 + atan(Float64(theta * sin(delta)), cos(delta)));
    	elseif (delta <= 4.8)
    		tmp = Float64(lambda1 + atan(Float64(delta * Float64(sin(theta) * fma(-0.16666666666666666, Float64(delta * delta), 1.0))), cos(delta)));
    	else
    		tmp = Float64(lambda1 + atan(Float64(theta * Float64(sin(delta) * fma(-0.16666666666666666, Float64(theta * theta), 1.0))), cos(delta)));
    	end
    	return tmp
    end
    
    code[lambda1_, phi1_, phi2_, delta_, theta_] := If[LessEqual[delta, -1.16e-16], N[(lambda1 + N[ArcTan[N[(theta * N[Sin[delta], $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[delta, 4.8], N[(lambda1 + N[ArcTan[N[(delta * N[(N[Sin[theta], $MachinePrecision] * N[(-0.16666666666666666 * N[(delta * delta), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(theta * N[(N[Sin[delta], $MachinePrecision] * N[(-0.16666666666666666 * N[(theta * theta), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;delta \leq -1.16 \cdot 10^{-16}:\\
    \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \sin delta}{\cos delta}\\
    
    \mathbf{elif}\;delta \leq 4.8:\\
    \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{delta \cdot \left(\sin theta \cdot \mathsf{fma}\left(-0.16666666666666666, delta \cdot delta, 1\right)\right)}{\cos delta}\\
    
    \mathbf{else}:\\
    \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \left(\sin delta \cdot \mathsf{fma}\left(-0.16666666666666666, theta \cdot theta, 1\right)\right)}{\cos delta}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if delta < -1.1600000000000001e-16

      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. lower-cos.f6485.8

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

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

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

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

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

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

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{theta \cdot \color{blue}{\sin delta}}{\cos delta} \]
      10. Step-by-step derivation
        1. Applied rewrites72.6%

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

        if -1.1600000000000001e-16 < delta < 4.79999999999999982

        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}} \]
        4. Step-by-step derivation
          1. lower-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. Applied rewrites92.4%

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

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

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

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

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{\cos delta} \]
        8. Applied rewrites92.0%

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

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{delta \cdot \color{blue}{\left(\sin theta + \frac{-1}{6} \cdot \left({delta}^{2} \cdot \sin theta\right)\right)}}{\cos delta} \]
        10. Step-by-step derivation
          1. Applied rewrites91.4%

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

          if 4.79999999999999982 < delta

          1. Initial program 99.5%

            \[\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. lower-cos.f6483.0

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

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

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

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

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

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

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

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

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

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

          Alternative 15: 80.6% accurate, 4.0× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;theta \leq -7.6 \cdot 10^{+15}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{\cos delta}\\ \mathbf{elif}\;theta \leq 6.2 \cdot 10^{-23}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \sin delta}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{delta \cdot \left(\sin theta \cdot \mathsf{fma}\left(-0.16666666666666666, delta \cdot delta, 1\right)\right)}{\cos delta}\\ \end{array} \end{array} \]
          (FPCore (lambda1 phi1 phi2 delta theta)
           :precision binary64
           (if (<= theta -7.6e+15)
             (+ lambda1 (atan2 (* (sin theta) delta) (cos delta)))
             (if (<= theta 6.2e-23)
               (+ lambda1 (atan2 (* theta (sin delta)) (cos delta)))
               (+
                lambda1
                (atan2
                 (* delta (* (sin theta) (fma -0.16666666666666666 (* delta delta) 1.0)))
                 (cos delta))))))
          double code(double lambda1, double phi1, double phi2, double delta, double theta) {
          	double tmp;
          	if (theta <= -7.6e+15) {
          		tmp = lambda1 + atan2((sin(theta) * delta), cos(delta));
          	} else if (theta <= 6.2e-23) {
          		tmp = lambda1 + atan2((theta * sin(delta)), cos(delta));
          	} else {
          		tmp = lambda1 + atan2((delta * (sin(theta) * fma(-0.16666666666666666, (delta * delta), 1.0))), cos(delta));
          	}
          	return tmp;
          }
          
          function code(lambda1, phi1, phi2, delta, theta)
          	tmp = 0.0
          	if (theta <= -7.6e+15)
          		tmp = Float64(lambda1 + atan(Float64(sin(theta) * delta), cos(delta)));
          	elseif (theta <= 6.2e-23)
          		tmp = Float64(lambda1 + atan(Float64(theta * sin(delta)), cos(delta)));
          	else
          		tmp = Float64(lambda1 + atan(Float64(delta * Float64(sin(theta) * fma(-0.16666666666666666, Float64(delta * delta), 1.0))), cos(delta)));
          	end
          	return tmp
          end
          
          code[lambda1_, phi1_, phi2_, delta_, theta_] := If[LessEqual[theta, -7.6e+15], N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * delta), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[theta, 6.2e-23], N[(lambda1 + N[ArcTan[N[(theta * N[Sin[delta], $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(delta * N[(N[Sin[theta], $MachinePrecision] * N[(-0.16666666666666666 * N[(delta * delta), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;theta \leq -7.6 \cdot 10^{+15}:\\
          \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{\cos delta}\\
          
          \mathbf{elif}\;theta \leq 6.2 \cdot 10^{-23}:\\
          \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \sin delta}{\cos delta}\\
          
          \mathbf{else}:\\
          \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{delta \cdot \left(\sin theta \cdot \mathsf{fma}\left(-0.16666666666666666, delta \cdot delta, 1\right)\right)}{\cos delta}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if theta < -7.6e15

            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}} \]
            4. Step-by-step derivation
              1. lower-cos.f6480.5

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

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

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

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

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

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{\cos delta} \]
            8. Applied rewrites78.5%

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

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

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

              if -7.6e15 < theta < 6.1999999999999998e-23

              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}} \]
              4. Step-by-step derivation
                1. lower-cos.f6491.0

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

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

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

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

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

                  \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{\cos delta} \]
              8. Applied rewrites85.9%

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

                \[\leadsto \lambda_1 + \tan^{-1}_* \frac{theta \cdot \color{blue}{\sin delta}}{\cos delta} \]
              10. Step-by-step derivation
                1. Applied rewrites85.3%

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

                if 6.1999999999999998e-23 < theta

                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 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. lower-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. Applied rewrites88.1%

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

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

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

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

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{\cos delta} \]
                8. Applied rewrites86.6%

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

                  \[\leadsto \lambda_1 + \tan^{-1}_* \frac{delta \cdot \color{blue}{\left(\sin theta + \frac{-1}{6} \cdot \left({delta}^{2} \cdot \sin theta\right)\right)}}{\cos delta} \]
                10. Step-by-step derivation
                  1. Applied rewrites72.4%

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

                  \[\leadsto \begin{array}{l} \mathbf{if}\;theta \leq -7.6 \cdot 10^{+15}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{\cos delta}\\ \mathbf{elif}\;theta \leq 6.2 \cdot 10^{-23}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \sin delta}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{delta \cdot \left(\sin theta \cdot \mathsf{fma}\left(-0.16666666666666666, delta \cdot delta, 1\right)\right)}{\cos delta}\\ \end{array} \]
                13. Add Preprocessing

                Alternative 16: 80.6% accurate, 4.2× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} t_1 := \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{\cos delta}\\ \mathbf{if}\;theta \leq -7.6 \cdot 10^{+15}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;theta \leq 6.2 \cdot 10^{-23}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \sin delta}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
                (FPCore (lambda1 phi1 phi2 delta theta)
                 :precision binary64
                 (let* ((t_1 (+ lambda1 (atan2 (* (sin theta) delta) (cos delta)))))
                   (if (<= theta -7.6e+15)
                     t_1
                     (if (<= theta 6.2e-23)
                       (+ lambda1 (atan2 (* theta (sin delta)) (cos delta)))
                       t_1))))
                double code(double lambda1, double phi1, double phi2, double delta, double theta) {
                	double t_1 = lambda1 + atan2((sin(theta) * delta), cos(delta));
                	double tmp;
                	if (theta <= -7.6e+15) {
                		tmp = t_1;
                	} else if (theta <= 6.2e-23) {
                		tmp = lambda1 + atan2((theta * sin(delta)), cos(delta));
                	} else {
                		tmp = 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) :: tmp
                    t_1 = lambda1 + atan2((sin(theta) * delta), cos(delta))
                    if (theta <= (-7.6d+15)) then
                        tmp = t_1
                    else if (theta <= 6.2d-23) then
                        tmp = lambda1 + atan2((theta * sin(delta)), cos(delta))
                    else
                        tmp = 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 = lambda1 + Math.atan2((Math.sin(theta) * delta), Math.cos(delta));
                	double tmp;
                	if (theta <= -7.6e+15) {
                		tmp = t_1;
                	} else if (theta <= 6.2e-23) {
                		tmp = lambda1 + Math.atan2((theta * Math.sin(delta)), Math.cos(delta));
                	} else {
                		tmp = t_1;
                	}
                	return tmp;
                }
                
                def code(lambda1, phi1, phi2, delta, theta):
                	t_1 = lambda1 + math.atan2((math.sin(theta) * delta), math.cos(delta))
                	tmp = 0
                	if theta <= -7.6e+15:
                		tmp = t_1
                	elif theta <= 6.2e-23:
                		tmp = lambda1 + math.atan2((theta * math.sin(delta)), math.cos(delta))
                	else:
                		tmp = t_1
                	return tmp
                
                function code(lambda1, phi1, phi2, delta, theta)
                	t_1 = Float64(lambda1 + atan(Float64(sin(theta) * delta), cos(delta)))
                	tmp = 0.0
                	if (theta <= -7.6e+15)
                		tmp = t_1;
                	elseif (theta <= 6.2e-23)
                		tmp = Float64(lambda1 + atan(Float64(theta * sin(delta)), cos(delta)));
                	else
                		tmp = t_1;
                	end
                	return tmp
                end
                
                function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
                	t_1 = lambda1 + atan2((sin(theta) * delta), cos(delta));
                	tmp = 0.0;
                	if (theta <= -7.6e+15)
                		tmp = t_1;
                	elseif (theta <= 6.2e-23)
                		tmp = lambda1 + atan2((theta * sin(delta)), cos(delta));
                	else
                		tmp = t_1;
                	end
                	tmp_2 = tmp;
                end
                
                code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * delta), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[theta, -7.6e+15], t$95$1, If[LessEqual[theta, 6.2e-23], N[(lambda1 + N[ArcTan[N[(theta * N[Sin[delta], $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                t_1 := \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{\cos delta}\\
                \mathbf{if}\;theta \leq -7.6 \cdot 10^{+15}:\\
                \;\;\;\;t\_1\\
                
                \mathbf{elif}\;theta \leq 6.2 \cdot 10^{-23}:\\
                \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \sin delta}{\cos delta}\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_1\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if theta < -7.6e15 or 6.1999999999999998e-23 < theta

                  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 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. lower-cos.f6484.9

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

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

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

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

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

                      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{\cos delta} \]
                  8. Applied rewrites83.2%

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

                    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{delta \cdot \color{blue}{\sin theta}}{\cos delta} \]
                  10. Step-by-step derivation
                    1. Applied rewrites70.2%

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

                    if -7.6e15 < theta < 6.1999999999999998e-23

                    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}} \]
                    4. Step-by-step derivation
                      1. lower-cos.f6491.0

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

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

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

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

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

                        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{\cos delta} \]
                    8. Applied rewrites85.9%

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

                      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{theta \cdot \color{blue}{\sin delta}}{\cos delta} \]
                    10. Step-by-step derivation
                      1. Applied rewrites85.3%

                        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{theta}}{\cos delta} \]
                    11. Recombined 2 regimes into one program.
                    12. Final simplification77.9%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;theta \leq -7.6 \cdot 10^{+15}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{\cos delta}\\ \mathbf{elif}\;theta \leq 6.2 \cdot 10^{-23}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \sin delta}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{\cos delta}\\ \end{array} \]
                    13. Add Preprocessing

                    Alternative 17: 74.9% accurate, 4.3× speedup?

                    \[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{\cos delta} \end{array} \]
                    (FPCore (lambda1 phi1 phi2 delta theta)
                     :precision binary64
                     (+ lambda1 (atan2 (* (sin theta) delta) (cos delta))))
                    double code(double lambda1, double phi1, double phi2, double delta, double theta) {
                    	return lambda1 + atan2((sin(theta) * 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) * 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) * delta), Math.cos(delta));
                    }
                    
                    def code(lambda1, phi1, phi2, delta, theta):
                    	return lambda1 + math.atan2((math.sin(theta) * delta), math.cos(delta))
                    
                    function code(lambda1, phi1, phi2, delta, theta)
                    	return Float64(lambda1 + atan(Float64(sin(theta) * delta), cos(delta)))
                    end
                    
                    function tmp = code(lambda1, phi1, phi2, delta, theta)
                    	tmp = lambda1 + atan2((sin(theta) * delta), cos(delta));
                    end
                    
                    code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * delta), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
                    
                    \begin{array}{l}
                    
                    \\
                    \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot 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 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. lower-cos.f6488.0

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

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

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

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

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

                        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{\cos delta} \]
                    8. Applied rewrites84.6%

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

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

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

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

                      Reproduce

                      ?
                      herbie shell --seed 2024231 
                      (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))))))))))