Destination given bearing on a great circle

Percentage Accurate: 99.8% → 99.9%
Time: 19.8s
Alternatives: 20
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 20 alternatives:

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

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

\\
\tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left({\cos \phi_1}^{2}, \cos delta, \left(\sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right) \cdot \left(-\sin \phi_1\right)\right)} + \lambda_1
\end{array}
Derivation
  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. Applied egg-rr99.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}} \]
  4. Applied egg-rr99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 80.6% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{-14}:\\
\;\;\;\;t\_3\\

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

\mathbf{elif}\;t\_2 \leq 5:\\
\;\;\;\;t\_3\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{\cos delta}\\


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

    1. Initial program 100.0%

      \[\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.f64100.0

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -50 < (+.f64 lambda1 (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta))))))))) < -2e-14 or 0.050000000000000003 < (+.f64 lambda1 (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta))))))))) < 5

    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.f6463.9

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{\cos delta} \]
      5. lower-cos.f6453.8

        \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \sin theta}{\color{blue}{\cos delta}} \]
    11. Simplified53.8%

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

    if -2e-14 < (+.f64 lambda1 (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta))))))))) < 0.050000000000000003

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(delta, \left(delta \cdot delta\right) \cdot \mathsf{fma}\left(\color{blue}{delta \cdot delta}, \frac{1}{120}, \frac{-1}{6}\right), delta\right) \cdot \sin theta}{\cos delta} \]
      13. lower-*.f6466.4

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

Alternative 3: 96.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \sin delta \cdot \left(-\sin \phi_1\right)\\ t_2 := \cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)\\ t_3 := \sin delta \cdot \cos \phi_1\\ t_4 := \sin theta \cdot t\_3\\ t_5 := \lambda_1 + \tan^{-1}_* \frac{t\_2}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + t\_3 \cdot \cos theta\right)}\\ \mathbf{if}\;t\_5 \leq 0.05:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_4}{\mathsf{fma}\left(\cos \phi_1, t\_1, {\cos \phi_1}^{2} \cdot \cos delta\right)}\\ \mathbf{elif}\;t\_5 \leq 3.12:\\ \;\;\;\;\tan^{-1}_* \frac{t\_2}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, \cos \left(\phi_1 \cdot -2\right), 0.5\right), \cos delta, \cos \phi_1 \cdot \left(\cos theta \cdot t\_1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_4}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right), \cos delta, \cos \phi_1 \cdot t\_1\right)}\\ \end{array} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (let* ((t_1 (* (sin delta) (- (sin phi1))))
        (t_2 (* (cos phi1) (* (sin theta) (sin delta))))
        (t_3 (* (sin delta) (cos phi1)))
        (t_4 (* (sin theta) t_3))
        (t_5
         (+
          lambda1
          (atan2
           t_2
           (-
            (cos delta)
            (*
             (sin phi1)
             (sin
              (asin (+ (* (cos delta) (sin phi1)) (* t_3 (cos theta)))))))))))
   (if (<= t_5 0.05)
     (+
      lambda1
      (atan2 t_4 (fma (cos phi1) t_1 (* (pow (cos phi1) 2.0) (cos delta)))))
     (if (<= t_5 3.12)
       (atan2
        t_2
        (fma
         (fma 0.5 (cos (* phi1 -2.0)) 0.5)
         (cos delta)
         (* (cos phi1) (* (cos theta) t_1))))
       (+
        lambda1
        (atan2
         t_4
         (fma
          (fma (cos (+ phi1 phi1)) 0.5 0.5)
          (cos delta)
          (* (cos phi1) t_1))))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double t_1 = sin(delta) * -sin(phi1);
	double t_2 = cos(phi1) * (sin(theta) * sin(delta));
	double t_3 = sin(delta) * cos(phi1);
	double t_4 = sin(theta) * t_3;
	double t_5 = lambda1 + atan2(t_2, (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (t_3 * cos(theta))))))));
	double tmp;
	if (t_5 <= 0.05) {
		tmp = lambda1 + atan2(t_4, fma(cos(phi1), t_1, (pow(cos(phi1), 2.0) * cos(delta))));
	} else if (t_5 <= 3.12) {
		tmp = atan2(t_2, fma(fma(0.5, cos((phi1 * -2.0)), 0.5), cos(delta), (cos(phi1) * (cos(theta) * t_1))));
	} else {
		tmp = lambda1 + atan2(t_4, fma(fma(cos((phi1 + phi1)), 0.5, 0.5), cos(delta), (cos(phi1) * t_1)));
	}
	return tmp;
}
function code(lambda1, phi1, phi2, delta, theta)
	t_1 = Float64(sin(delta) * Float64(-sin(phi1)))
	t_2 = Float64(cos(phi1) * Float64(sin(theta) * sin(delta)))
	t_3 = Float64(sin(delta) * cos(phi1))
	t_4 = Float64(sin(theta) * t_3)
	t_5 = Float64(lambda1 + atan(t_2, Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(cos(delta) * sin(phi1)) + Float64(t_3 * cos(theta)))))))))
	tmp = 0.0
	if (t_5 <= 0.05)
		tmp = Float64(lambda1 + atan(t_4, fma(cos(phi1), t_1, Float64((cos(phi1) ^ 2.0) * cos(delta)))));
	elseif (t_5 <= 3.12)
		tmp = atan(t_2, fma(fma(0.5, cos(Float64(phi1 * -2.0)), 0.5), cos(delta), Float64(cos(phi1) * Float64(cos(theta) * t_1))));
	else
		tmp = Float64(lambda1 + atan(t_4, fma(fma(cos(Float64(phi1 + phi1)), 0.5, 0.5), cos(delta), Float64(cos(phi1) * t_1))));
	end
	return tmp
end
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(N[Sin[delta], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sin[theta], $MachinePrecision] * t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(lambda1 + N[ArcTan[t$95$2 / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(t$95$3 * N[Cos[theta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, 0.05], N[(lambda1 + N[ArcTan[t$95$4 / N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + N[(N[Power[N[Cos[phi1], $MachinePrecision], 2.0], $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 3.12], N[ArcTan[t$95$2 / N[(N[(0.5 * N[Cos[N[(phi1 * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision] * N[Cos[delta], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[theta], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$4 / N[(N[(N[Cos[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] * 0.5 + 0.5), $MachinePrecision] * N[Cos[delta], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \sin delta \cdot \left(-\sin \phi_1\right)\\
t_2 := \cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)\\
t_3 := \sin delta \cdot \cos \phi_1\\
t_4 := \sin theta \cdot t\_3\\
t_5 := \lambda_1 + \tan^{-1}_* \frac{t\_2}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + t\_3 \cdot \cos theta\right)}\\
\mathbf{if}\;t\_5 \leq 0.05:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_4}{\mathsf{fma}\left(\cos \phi_1, t\_1, {\cos \phi_1}^{2} \cdot \cos delta\right)}\\

\mathbf{elif}\;t\_5 \leq 3.12:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, \cos \left(\phi_1 \cdot -2\right), 0.5\right), \cos delta, \cos \phi_1 \cdot \left(\cos theta \cdot t\_1\right)\right)}\\

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


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

    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. Applied egg-rr99.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}} \]
    4. Applied egg-rr99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 98.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. Applied egg-rr99.5%

      \[\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}} \]
    4. Applied egg-rr99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 100.0%

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

      \[\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}} \]
    4. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.8% accurate, 1.3× speedup?

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

\\
\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), 0.5, 0.5\right), \cos delta, \left(\sin delta \cdot \left(\cos \phi_1 \cdot \cos theta\right)\right) \cdot \left(-\sin \phi_1\right)\right)}
\end{array}
Derivation
  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. Applied egg-rr99.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}} \]
  4. Applied egg-rr99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 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)}{\cos delta \cdot \mathsf{fma}\left(0.5, \cos \left(\phi_1 + \phi_1\right), 0.5\right) - \sin \phi_1 \cdot \left(\cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\right)\right)} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (+
  lambda1
  (atan2
   (* (cos phi1) (* (sin theta) (sin delta)))
   (-
    (* (cos delta) (fma 0.5 (cos (+ phi1 phi1)) 0.5))
    (* (sin phi1) (* (cos phi1) (* (sin delta) (cos theta))))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	return lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), ((cos(delta) * fma(0.5, cos((phi1 + phi1)), 0.5)) - (sin(phi1) * (cos(phi1) * (sin(delta) * cos(theta))))));
}
function code(lambda1, phi1, phi2, delta, theta)
	return Float64(lambda1 + atan(Float64(cos(phi1) * Float64(sin(theta) * sin(delta))), Float64(Float64(cos(delta) * fma(0.5, cos(Float64(phi1 + phi1)), 0.5)) - Float64(sin(phi1) * Float64(cos(phi1) * Float64(sin(delta) * cos(theta)))))))
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[delta], $MachinePrecision] * N[(0.5 * N[Cos[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[theta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta \cdot \mathsf{fma}\left(0.5, \cos \left(\phi_1 + \phi_1\right), 0.5\right) - \sin \phi_1 \cdot \left(\cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\right)\right)}
\end{array}
Derivation
  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. Applied egg-rr99.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}} \]
  4. 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}{\left(\cos delta - \left(\frac{1}{2} - \frac{1}{2} \cdot \cos \color{blue}{\left(2 \cdot \phi_1\right)}\right) \cdot \cos delta\right) - \left(\cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\right)\right) \cdot \sin \phi_1} \]
    2. lift-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 \color{blue}{\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} \]
    3. lift-*.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} - \color{blue}{\frac{1}{2} \cdot \cos \left(2 \cdot \phi_1\right)}\right) \cdot \cos delta\right) - \left(\cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\right)\right) \cdot \sin \phi_1} \]
    4. sub-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 94.4% accurate, 1.3× speedup?

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

\\
\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\cos \phi_1, \sin delta \cdot \left(-\sin \phi_1\right), {\cos \phi_1}^{2} \cdot \cos delta\right)}
\end{array}
Derivation
  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. Applied egg-rr99.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}} \]
  4. Applied egg-rr99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 94.3% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 92.1% 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.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}{\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.f6490.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. Simplified90.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 simplification90.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 9: 91.1% accurate, 2.1× speedup?

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

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

\mathbf{elif}\;delta \leq 1.25 \cdot 10^{-27}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{{\cos \phi_1}^{2}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if delta < -4.09999999999999996e23 or 1.25e-27 < 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.f6483.5

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

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

    if -4.09999999999999996e23 < delta < 1.25e-27

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 91.0% accurate, 2.5× speedup?

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

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

\mathbf{elif}\;delta \leq 1.25 \cdot 10^{-27}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(0.5, \cos \left(\phi_1 \cdot 2\right), 0.5\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if delta < -4.09999999999999996e23 or 1.25e-27 < 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.f6483.5

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

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

    if -4.09999999999999996e23 < delta < 1.25e-27

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 91.0% accurate, 2.5× speedup?

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

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

\mathbf{elif}\;delta \leq 1.25 \cdot 10^{-27}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(0.5, \cos \left(\phi_1 \cdot 2\right), 0.5\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if delta < -4.09999999999999996e23 or 1.25e-27 < 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.f6483.5

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

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

    if -4.09999999999999996e23 < delta < 1.25e-27

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 91.5% accurate, 2.5× speedup?

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

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

\mathbf{elif}\;delta \leq 5 \cdot 10^{-29}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(0.5, \cos \left(\phi_1 \cdot 2\right), 0.5\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if delta < -2.14999999999999995e-4 or 4.99999999999999986e-29 < delta

    1. Initial program 99.7%

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

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

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

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

    if -2.14999999999999995e-4 < delta < 4.99999999999999986e-29

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 88.9% accurate, 3.1× speedup?

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

\\
\begin{array}{l}
t_1 := \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \sin delta}{\cos delta}\\
\mathbf{if}\;delta \leq -4.1 \cdot 10^{+23}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;delta \leq 1.25 \cdot 10^{-27}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(0.5, \cos \left(\phi_1 \cdot 2\right), 0.5\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if delta < -4.09999999999999996e23 or 1.25e-27 < 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.f6483.5

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

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

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

    if -4.09999999999999996e23 < delta < 1.25e-27

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 85.3% accurate, 3.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq 1350000000000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \sin delta}{\cos delta}\\

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


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

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

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

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

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

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

    if 1.35e12 < phi1

    1. Initial program 99.3%

      \[\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-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 86.2% 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.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.f6485.7

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

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

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

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

Alternative 16: 80.7% accurate, 3.8× speedup?

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

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

\mathbf{elif}\;delta \leq 4.5 \cdot 10^{-22}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{\cos delta}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if delta < -9.5e6

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.5e6 < delta < 4.49999999999999987e-22

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

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

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

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

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

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

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

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

    if 4.49999999999999987e-22 < 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.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 17: 80.7% accurate, 4.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;delta \leq -15000000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \mathsf{fma}\left(theta, -0.16666666666666666 \cdot \left(theta \cdot theta\right), theta\right)}{\cos delta}\\ \mathbf{elif}\;delta \leq 4.5 \cdot 10^{-22}:\\ \;\;\;\;\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 -15000000.0)
   (+
    lambda1
    (atan2
     (* (sin delta) (fma theta (* -0.16666666666666666 (* theta theta)) theta))
     (cos delta)))
   (if (<= delta 4.5e-22)
     (+ 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 <= -15000000.0) {
		tmp = lambda1 + atan2((sin(delta) * fma(theta, (-0.16666666666666666 * (theta * theta)), theta)), cos(delta));
	} else if (delta <= 4.5e-22) {
		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 <= -15000000.0)
		tmp = Float64(lambda1 + atan(Float64(sin(delta) * fma(theta, Float64(-0.16666666666666666 * Float64(theta * theta)), theta)), cos(delta)));
	elseif (delta <= 4.5e-22)
		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, -15000000.0], N[(lambda1 + N[ArcTan[N[(N[Sin[delta], $MachinePrecision] * N[(theta * N[(-0.16666666666666666 * N[(theta * theta), $MachinePrecision]), $MachinePrecision] + theta), $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[delta, 4.5e-22], 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 -15000000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \mathsf{fma}\left(theta, -0.16666666666666666 \cdot \left(theta \cdot theta\right), theta\right)}{\cos delta}\\

\mathbf{elif}\;delta \leq 4.5 \cdot 10^{-22}:\\
\;\;\;\;\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 < -1.5e7

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.5e7 < delta < 4.49999999999999987e-22

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

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

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

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

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

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

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

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

    if 4.49999999999999987e-22 < 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.7

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;delta \leq -15000000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \mathsf{fma}\left(theta, -0.16666666666666666 \cdot \left(theta \cdot theta\right), theta\right)}{\cos delta}\\ \mathbf{elif}\;delta \leq 4.5 \cdot 10^{-22}:\\ \;\;\;\;\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} \]
  5. Add Preprocessing

Alternative 18: 77.9% accurate, 4.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;delta \leq 4.5 \cdot 10^{-22}:\\ \;\;\;\;\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 4.5e-22)
   (+ 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 <= 4.5e-22) {
		tmp = lambda1 + atan2((sin(theta) * delta), cos(delta));
	} else {
		tmp = lambda1 + atan2((theta * sin(delta)), cos(delta));
	}
	return tmp;
}
real(8) function code(lambda1, phi1, phi2, delta, theta)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8), intent (in) :: delta
    real(8), intent (in) :: theta
    real(8) :: tmp
    if (delta <= 4.5d-22) then
        tmp = lambda1 + atan2((sin(theta) * delta), cos(delta))
    else
        tmp = lambda1 + atan2((theta * sin(delta)), cos(delta))
    end if
    code = tmp
end function
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double tmp;
	if (delta <= 4.5e-22) {
		tmp = lambda1 + Math.atan2((Math.sin(theta) * delta), Math.cos(delta));
	} else {
		tmp = lambda1 + Math.atan2((theta * Math.sin(delta)), Math.cos(delta));
	}
	return tmp;
}
def code(lambda1, phi1, phi2, delta, theta):
	tmp = 0
	if delta <= 4.5e-22:
		tmp = lambda1 + math.atan2((math.sin(theta) * delta), math.cos(delta))
	else:
		tmp = lambda1 + math.atan2((theta * math.sin(delta)), math.cos(delta))
	return tmp
function code(lambda1, phi1, phi2, delta, theta)
	tmp = 0.0
	if (delta <= 4.5e-22)
		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
function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
	tmp = 0.0;
	if (delta <= 4.5e-22)
		tmp = lambda1 + atan2((sin(theta) * delta), cos(delta));
	else
		tmp = lambda1 + atan2((theta * sin(delta)), cos(delta));
	end
	tmp_2 = tmp;
end
code[lambda1_, phi1_, phi2_, delta_, theta_] := If[LessEqual[delta, 4.5e-22], 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 4.5 \cdot 10^{-22}:\\
\;\;\;\;\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 2 regimes
  2. if delta < 4.49999999999999987e-22

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

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

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

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

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

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

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

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

    if 4.49999999999999987e-22 < 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.7

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;delta \leq 4.5 \cdot 10^{-22}:\\ \;\;\;\;\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} \]
  5. Add Preprocessing

Alternative 19: 75.0% 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.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.f6485.7

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

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

    \[\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{\color{blue}{delta \cdot \sin theta}}{\cos delta} \]
  10. Step-by-step derivation
    1. lower-*.f64N/A

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

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

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

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

Alternative 20: 67.7% accurate, 6.4× speedup?

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

\\
\lambda_1 + \tan^{-1}_* \frac{theta \cdot delta}{\cos delta}
\end{array}
Derivation
  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.f6485.7

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

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

    \[\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{\color{blue}{delta \cdot \sin theta}}{\cos delta} \]
  10. Step-by-step derivation
    1. lower-*.f64N/A

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

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

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

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{delta \cdot theta}}{\cos delta} \]
  13. Step-by-step derivation
    1. lower-*.f6466.1

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

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

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

Reproduce

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