Destination given bearing on a great circle

Percentage Accurate: 99.8% → 99.9%
Time: 18.5s
Alternatives: 13
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 13 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.8% 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.9% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right), \cos delta, \left(\sin delta \cdot \cos \phi_1\right) \cdot \left(-\cos theta \cdot \sin \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) (cos phi1)) (- (* (cos theta) (sin 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) * cos(phi1)) * -(cos(theta) * sin(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) * cos(phi1)) * Float64(-Float64(cos(theta) * sin(phi1)))))))
end
code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision] * N[Cos[delta], $MachinePrecision] + N[(N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * (-N[(N[Cos[theta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\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 \phi_1\right) \cdot \left(-\cos theta \cdot \sin \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}{\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. sub-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 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(\cos delta, \mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right), \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
    (cos delta)
    (fma (cos (+ phi1 phi1)) 0.5 0.5)
    (* (* (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(cos(delta), fma(cos((phi1 + phi1)), 0.5, 0.5), ((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(cos(delta), fma(cos(Float64(phi1 + phi1)), 0.5, 0.5), 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[Cos[delta], $MachinePrecision] * N[(N[Cos[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] * 0.5 + 0.5), $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(\cos delta, \mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right), \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. sub-negN/A

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

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

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

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

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

Alternative 4: 94.6% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\cos delta \cdot \left(1 - \mathsf{fma}\left(-0.5, \cos \left(\phi_1 + \phi_1\right), 0.5\right)\right) - \sin delta \cdot \left(\cos \phi_1 \cdot \sin \phi_1\right)} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (+
  lambda1
  (atan2
   (* (sin theta) (* (sin delta) (cos phi1)))
   (-
    (* (cos delta) (- 1.0 (fma -0.5 (cos (+ phi1 phi1)) 0.5)))
    (* (sin delta) (* (cos phi1) (sin phi1)))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	return lambda1 + atan2((sin(theta) * (sin(delta) * cos(phi1))), ((cos(delta) * (1.0 - fma(-0.5, cos((phi1 + phi1)), 0.5))) - (sin(delta) * (cos(phi1) * sin(phi1)))));
}
function code(lambda1, phi1, phi2, delta, theta)
	return Float64(lambda1 + atan(Float64(sin(theta) * Float64(sin(delta) * cos(phi1))), Float64(Float64(cos(delta) * Float64(1.0 - fma(-0.5, cos(Float64(phi1 + phi1)), 0.5))) - Float64(sin(delta) * Float64(cos(phi1) * sin(phi1))))))
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[delta], $MachinePrecision] * N[(1.0 - N[(-0.5 * N[Cos[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[delta], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi1], $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)}{\cos delta \cdot \left(1 - \mathsf{fma}\left(-0.5, \cos \left(\phi_1 + \phi_1\right), 0.5\right)\right) - \sin delta \cdot \left(\cos \phi_1 \cdot \sin \phi_1\right)}
\end{array}
Derivation
  1. Initial program 99.8%

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

    \[\leadsto \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) - \color{blue}{\cos \phi_1 \cdot \left(\sin delta \cdot \sin \phi_1\right)}} \]
  6. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \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) - \color{blue}{\cos \phi_1 \cdot \left(\sin delta \cdot \sin \phi_1\right)}} \]
    2. lower-cos.f64N/A

      \[\leadsto \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) - \color{blue}{\cos \phi_1} \cdot \left(\sin delta \cdot \sin \phi_1\right)} \]
    3. lower-*.f64N/A

      \[\leadsto \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) - \cos \phi_1 \cdot \color{blue}{\left(\sin delta \cdot \sin \phi_1\right)}} \]
    4. lower-sin.f64N/A

      \[\leadsto \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) - \cos \phi_1 \cdot \left(\color{blue}{\sin delta} \cdot \sin \phi_1\right)} \]
    5. lower-sin.f6496.2

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

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

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

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

Alternative 5: 92.2% 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.f6492.6

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

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

    \[\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 6: 89.4% accurate, 2.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq 4.6 \cdot 10^{+89}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta}\\

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


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

    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.f6493.5

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

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

    if 4.5999999999999998e89 < phi1

    1. Initial program 99.4%

      \[\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}{\color{blue}{\left(1 + delta \cdot \left(-1 \cdot \left(delta \cdot \left(\frac{1}{2} + \frac{-1}{2} \cdot {\sin \phi_1}^{2}\right)\right) - \cos \phi_1 \cdot \left(\cos theta \cdot \sin \phi_1\right)\right)\right) - {\sin \phi_1}^{2}}} \]
    4. Applied rewrites80.9%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 89.4% accurate, 2.2× speedup?

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

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

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


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

    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.f6493.5

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

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

    if 4.5999999999999998e89 < phi1

    1. Initial program 99.4%

      \[\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.f6473.7

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

      \[\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 delta around 0

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{1 - {\sin \phi_1}^{2}}} \]
    7. Step-by-step derivation
      1. 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}} \]
      2. 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}} \]
      3. 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}}} \]
      4. 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}}} \]
      5. lower-cos.f6485.8

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

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

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

Alternative 8: 88.8% accurate, 2.6× speedup?

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

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

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

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

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

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

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

Alternative 9: 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.f6490.1

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

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

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

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

Alternative 10: 80.7% accurate, 3.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \sin delta}{\mathsf{fma}\left(delta, delta \cdot \mathsf{fma}\left(\phi_1 \cdot \phi_1, 0.5, -0.5\right), 1\right)}\\ \mathbf{if}\;theta \leq -1 \cdot 10^{-17}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;theta \leq 2020000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \left(\sin delta \cdot \mathsf{fma}\left(-0.16666666666666666, theta \cdot theta, 1\right)\right)}{\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) (sin delta))
           (fma delta (* delta (fma (* phi1 phi1) 0.5 -0.5)) 1.0)))))
   (if (<= theta -1e-17)
     t_1
     (if (<= theta 2020000.0)
       (+
        lambda1
        (atan2
         (*
          theta
          (* (sin delta) (fma -0.16666666666666666 (* theta theta) 1.0)))
         (cos delta)))
       t_1))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double t_1 = lambda1 + atan2((sin(theta) * sin(delta)), fma(delta, (delta * fma((phi1 * phi1), 0.5, -0.5)), 1.0));
	double tmp;
	if (theta <= -1e-17) {
		tmp = t_1;
	} else if (theta <= 2020000.0) {
		tmp = lambda1 + atan2((theta * (sin(delta) * fma(-0.16666666666666666, (theta * theta), 1.0))), cos(delta));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(lambda1, phi1, phi2, delta, theta)
	t_1 = Float64(lambda1 + atan(Float64(sin(theta) * sin(delta)), fma(delta, Float64(delta * fma(Float64(phi1 * phi1), 0.5, -0.5)), 1.0)))
	tmp = 0.0
	if (theta <= -1e-17)
		tmp = t_1;
	elseif (theta <= 2020000.0)
		tmp = Float64(lambda1 + atan(Float64(theta * Float64(sin(delta) * fma(-0.16666666666666666, Float64(theta * theta), 1.0))), cos(delta)));
	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[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] / N[(delta * N[(delta * N[(N[(phi1 * phi1), $MachinePrecision] * 0.5 + -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[theta, -1e-17], t$95$1, If[LessEqual[theta, 2020000.0], 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], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \sin delta}{\mathsf{fma}\left(delta, delta \cdot \mathsf{fma}\left(\phi_1 \cdot \phi_1, 0.5, -0.5\right), 1\right)}\\
\mathbf{if}\;theta \leq -1 \cdot 10^{-17}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;theta \leq 2020000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \left(\sin delta \cdot \mathsf{fma}\left(-0.16666666666666666, theta \cdot theta, 1\right)\right)}{\cos delta}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if theta < -1.00000000000000007e-17 or 2.02e6 < theta

    1. Initial program 99.7%

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

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

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\mathsf{fma}\left(delta, delta \cdot \mathsf{fma}\left({\sin \phi_1}^{2}, 0.5, -0.5\right), \cos \phi_1 \cdot \mathsf{fma}\left(delta, \cos theta \cdot \left(-\sin \phi_1\right), \cos \phi_1\right)\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}{\mathsf{fma}\left(delta, delta \cdot \mathsf{fma}\left({\sin \phi_1}^{2}, \frac{1}{2}, \frac{-1}{2}\right), 1\right)} \]
    6. Step-by-step derivation
      1. Applied rewrites75.8%

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

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

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

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

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

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

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

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

        if -1.00000000000000007e-17 < theta < 2.02e6

        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.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.f6489.4

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{\cos delta} \]
        8. Applied rewrites89.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}{\left(\sin delta + \frac{-1}{6} \cdot \left({theta}^{2} \cdot \sin delta\right)\right)}}{\cos delta} \]
        10. Step-by-step derivation
          1. Applied rewrites89.5%

            \[\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 2 regimes into one program.
        12. Final simplification82.3%

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

        Alternative 11: 80.6% accurate, 4.0× speedup?

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

          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.f6476.3

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

            \[\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.f6474.2

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

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

              \[\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} \]

            if -2.04999999999999996e63 < delta < 3.2000000000000002

            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.f6494.4

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

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

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

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

              if 3.2000000000000002 < delta

              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.4

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

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

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

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

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

              Alternative 12: 80.7% accurate, 4.2× speedup?

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

                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.1

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

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

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

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

                  if -4.00000000000000017e36 < delta < 3.2000000000000002

                  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.f6494.5

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

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

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

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

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

                  Alternative 13: 74.6% 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.f6490.1

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

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

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

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

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

                    Reproduce

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