Destination given bearing on a great circle

Percentage Accurate: 99.8% → 99.8%
Time: 18.4s
Alternatives: 13
Speedup: 1.3×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 alternatives:

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

Initial Program: 99.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.3× speedup?

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

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

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

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

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

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

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

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\cos delta - \sin \phi_1 \cdot \left(\sin \phi_1 \cdot \cos delta\right)\right) - \left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) \cdot \sin \phi_1}} \]
  4. 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(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) \cdot \sin \phi_1}} \]
  5. Step-by-step derivation
    1. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 95.9% accurate, 0.4× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_2}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \phi_1, \sin delta, t\_1\right), -\sin \phi_1, \cos delta\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))))))))) < -5e9

    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. Step-by-step derivation
      1. sin-asinN/A

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

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

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

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

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

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

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

    if -5e9 < (+.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.20000000000000001

    1. Initial program 99.8%

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

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

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

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

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\cos delta - \sin \phi_1 \cdot \left(\sin \phi_1 \cdot \cos delta\right)\right) - \left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) \cdot \sin \phi_1}} \]
    4. 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(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) \cdot \sin \phi_1}} \]
    5. Step-by-step derivation
      1. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.20000000000000001 < (+.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 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. +-commutativeN/A

        \[\leadsto \color{blue}{\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)} + \lambda_1} \]
      2. +-lowering-+.f64N/A

        \[\leadsto \color{blue}{\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)} + \lambda_1} \]
    4. Applied egg-rr99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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 -5000000000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \left(\left(\sin delta \cdot \cos \phi_1\right) \cdot \cos theta\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 -0.2:\\ \;\;\;\;\tan^{-1}_* \frac{\sin delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, \cos \left(\phi_1 \cdot -2\right), 0.5\right), \cos delta, \left(\cos \phi_1 \cdot \left(\sin delta \cdot \sin \phi_1\right)\right) \cdot \left(-\cos theta\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \phi_1, \sin delta, \cos delta \cdot \sin \phi_1\right), -\sin \phi_1, \cos delta\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 83.8% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_1 := \cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)\\
t_2 := \tan^{-1}_* \frac{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 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(-0.5, delta \cdot delta, 1\right)}\\
\mathbf{if}\;t\_2 \leq -1.5:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_2 \leq 0.9:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < -1.5 or 0.900000000000000022 < (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 delta around 0

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

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

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

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

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

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

    if -1.5 < (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.900000000000000022

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 4: 74.0% accurate, 0.4× speedup?

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

      1. Initial program 99.7%

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

          \[\leadsto \color{blue}{\frac{{\lambda_1}^{3} + {\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)}}^{3}}{\lambda_1 \cdot \lambda_1 + \left(\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)} \cdot \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)} - \lambda_1 \cdot \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)}\right)}} \]
      4. Applied egg-rr99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -5.0000000000000001e-60 < (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)))))))) < 1e-135

      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 lambda1 around inf

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

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

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

      Alternative 5: 74.5% accurate, 0.4× speedup?

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

        1. Initial program 99.7%

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

            \[\leadsto \color{blue}{\frac{{\lambda_1}^{3} + {\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)}}^{3}}{\lambda_1 \cdot \lambda_1 + \left(\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)} \cdot \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)} - \lambda_1 \cdot \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)}\right)}} \]
        4. Applied egg-rr99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if -5.0000000000000001e-60 < (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)))))))) < 1e-135

        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 lambda1 around inf

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

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

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

        Alternative 6: 94.6% accurate, 1.3× speedup?

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

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

            \[\leadsto \color{blue}{\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)} + \lambda_1} \]
          2. +-lowering-+.f64N/A

            \[\leadsto \color{blue}{\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)} + \lambda_1} \]
        4. Applied egg-rr99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 7: 94.6% accurate, 1.4× speedup?

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

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

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

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

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

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

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\color{blue}{\left(\cos delta - \sin \phi_1 \cdot \left(\sin \phi_1 \cdot \cos delta\right)\right) - \left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) \cdot \sin \phi_1}} \]
        4. 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(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) \cdot \sin \phi_1}} \]
        5. Step-by-step derivation
          1. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 8: 92.0% accurate, 2.1× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_1 := \cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)\\ t_2 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos delta}\\ \mathbf{if}\;delta \leq -7000000:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;delta \leq 8.8 \cdot 10^{-5}:\\ \;\;\;\;\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 -7000000.0)
             t_2
             (if (<= delta 8.8e-5) (+ 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 <= -7000000.0) {
        		tmp = t_2;
        	} else if (delta <= 8.8e-5) {
        		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 <= (-7000000.0d0)) then
                tmp = t_2
            else if (delta <= 8.8d-5) 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 <= -7000000.0) {
        		tmp = t_2;
        	} else if (delta <= 8.8e-5) {
        		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 <= -7000000.0:
        		tmp = t_2
        	elif delta <= 8.8e-5:
        		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 <= -7000000.0)
        		tmp = t_2;
        	elseif (delta <= 8.8e-5)
        		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 <= -7000000.0)
        		tmp = t_2;
        	elseif (delta <= 8.8e-5)
        		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, -7000000.0], t$95$2, If[LessEqual[delta, 8.8e-5], 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 -7000000:\\
        \;\;\;\;t\_2\\
        
        \mathbf{elif}\;delta \leq 8.8 \cdot 10^{-5}:\\
        \;\;\;\;\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 < -7e6 or 8.7999999999999998e-5 < delta

          1. Initial program 99.9%

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

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

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

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

          if -7e6 < delta < 8.7999999999999998e-5

          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. +-commutativeN/A

              \[\leadsto \color{blue}{\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)} + \lambda_1} \]
            2. +-lowering-+.f64N/A

              \[\leadsto \color{blue}{\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)} + \lambda_1} \]
          4. Applied egg-rr99.8%

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;delta \leq -7000000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta}\\ \mathbf{elif}\;delta \leq 8.8 \cdot 10^{-5}:\\ \;\;\;\;\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 9: 92.4% accurate, 2.1× speedup?

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

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

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

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

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

          \[\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. Step-by-step derivation
          1. +-commutativeN/A

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

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

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

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

        Alternative 10: 91.9% 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 -7000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;delta \leq 0.000135:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(0.5, \cos \left(\phi_1 + \phi_1\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 -7000000.0)
             t_1
             (if (<= delta 0.000135)
               (+
                lambda1
                (atan2
                 (* (sin theta) (* (sin delta) (cos phi1)))
                 (fma 0.5 (cos (+ phi1 phi1)) 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 <= -7000000.0) {
        		tmp = t_1;
        	} else if (delta <= 0.000135) {
        		tmp = lambda1 + atan2((sin(theta) * (sin(delta) * cos(phi1))), fma(0.5, cos((phi1 + phi1)), 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 <= -7000000.0)
        		tmp = t_1;
        	elseif (delta <= 0.000135)
        		tmp = Float64(lambda1 + atan(Float64(sin(theta) * Float64(sin(delta) * cos(phi1))), fma(0.5, cos(Float64(phi1 + phi1)), 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, -7000000.0], t$95$1, If[LessEqual[delta, 0.000135], N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(0.5 * N[Cos[N[(phi1 + phi1), $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 -7000000:\\
        \;\;\;\;t\_1\\
        
        \mathbf{elif}\;delta \leq 0.000135:\\
        \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(0.5, \cos \left(\phi_1 + \phi_1\right), 0.5\right)}\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_1\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if delta < -7e6 or 1.35000000000000002e-4 < delta

          1. Initial program 99.9%

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

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

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

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

          if -7e6 < delta < 1.35000000000000002e-4

          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. flip3-+N/A

              \[\leadsto \color{blue}{\frac{{\lambda_1}^{3} + {\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)}}^{3}}{\lambda_1 \cdot \lambda_1 + \left(\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)} \cdot \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)} - \lambda_1 \cdot \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)}\right)}} \]
          4. Applied egg-rr99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\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 simplification90.5%

          \[\leadsto \begin{array}{l} \mathbf{if}\;delta \leq -7000000:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta}\\ \mathbf{elif}\;delta \leq 0.000135:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\mathsf{fma}\left(0.5, \cos \left(\phi_1 + \phi_1\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: 89.0% accurate, 2.6× speedup?

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

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

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

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

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

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

        Alternative 12: 77.6% accurate, 3.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 13: 70.5% accurate, 1341.0× speedup?

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

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

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

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

            Reproduce

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