Destination given bearing on a great circle

Percentage Accurate: 99.7% → 99.7%
Time: 13.8s
Alternatives: 17
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 alternatives:

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

Initial Program: 99.7% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \cos delta \cdot \sin \phi_1\\ t_2 := \mathsf{fma}\left(\cos theta \cdot \cos \phi_1, \sin delta, t\_1\right)\\ \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(t\_2, \left(0.5 - 0.5 \cdot \cos \left(\phi_1 + \phi_1\right)\right) \cdot t\_2, -{\cos delta}^{2}\right) \cdot \frac{-1}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, 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 (fma (* (cos theta) (cos phi1)) (sin delta) t_1)))
   (+
    lambda1
    (atan2
     (* (* (sin theta) (sin delta)) (cos phi1))
     (*
      (fma
       t_2
       (* (- 0.5 (* 0.5 (cos (+ phi1 phi1)))) t_2)
       (- (pow (cos delta) 2.0)))
      (/
       -1.0
       (fma
        (fma (cos theta) (* (sin delta) (cos phi1)) 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 = fma((cos(theta) * cos(phi1)), sin(delta), t_1);
	return lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (fma(t_2, ((0.5 - (0.5 * cos((phi1 + phi1)))) * t_2), -pow(cos(delta), 2.0)) * (-1.0 / fma(fma(cos(theta), (sin(delta) * cos(phi1)), t_1), sin(phi1), cos(delta)))));
}
function code(lambda1, phi1, phi2, delta, theta)
	t_1 = Float64(cos(delta) * sin(phi1))
	t_2 = fma(Float64(cos(theta) * cos(phi1)), sin(delta), t_1)
	return Float64(lambda1 + atan(Float64(Float64(sin(theta) * sin(delta)) * cos(phi1)), Float64(fma(t_2, Float64(Float64(0.5 - Float64(0.5 * cos(Float64(phi1 + phi1)))) * t_2), Float64(-(cos(delta) ^ 2.0))) * Float64(-1.0 / fma(fma(cos(theta), Float64(sin(delta) * cos(phi1)), t_1), sin(phi1), cos(delta))))))
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[(N[Cos[theta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[Sin[delta], $MachinePrecision] + t$95$1), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[(N[(t$95$2 * N[(N[(0.5 - N[(0.5 * N[Cos[N[(phi1 + phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] + (-N[Power[N[Cos[delta], $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision] * N[(-1.0 / N[(N[(N[Cos[theta], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[Cos[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \cos delta \cdot \sin \phi_1\\
t_2 := \mathsf{fma}\left(\cos theta \cdot \cos \phi_1, \sin delta, t\_1\right)\\
\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\mathsf{fma}\left(t\_2, \left(0.5 - 0.5 \cdot \cos \left(\phi_1 + \phi_1\right)\right) \cdot t\_2, -{\cos delta}^{2}\right) \cdot \frac{-1}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, t\_1\right), \sin \phi_1, \cos delta\right)}}
\end{array}
\end{array}
Derivation
  1. Initial program 99.8%

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

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

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

      \[\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 theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right) \cdot \sin \phi_1\right)}^{2} + \left(-{\cos delta}^{2}\right)\right)} \cdot \frac{1}{-\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, \sin delta \cdot \cos \phi_1, \cos delta \cdot \sin \phi_1\right), \sin \phi_1, \cos delta\right)}} \]
    3. lift-pow.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 2: 96.4% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 99.8%

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

          \[\leadsto \color{blue}{\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. flip-+N/A

          \[\leadsto \color{blue}{\frac{\lambda_1 \cdot \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)} \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 - \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. clear-numN/A

          \[\leadsto \color{blue}{\frac{1}{\frac{\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)}}{\lambda_1 \cdot \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)} \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)}}}} \]
      4. Applied rewrites99.8%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
      6. Step-by-step derivation
        1. lower-/.f644.0

          \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
      7. Applied rewrites4.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\tan^{-1}_* \frac{\left(\sin delta \cdot \sin theta\right) \cdot \cos \phi_1}{\cos delta - \mathsf{fma}\left(\cos theta \cdot \sin delta, \cos \phi_1, \sin \phi_1 \cdot \cos delta\right) \cdot \sin \phi_1}} \]
      11. Step-by-step derivation
        1. Applied rewrites99.7%

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

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

        1. Initial program 100.0%

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

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

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

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

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

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \color{blue}{\left(\cos theta \cdot \sin delta\right)}} \]
      12. Recombined 3 regimes into one program.
      13. Add Preprocessing

      Alternative 3: 96.4% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

        1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        1. Initial program 100.0%

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

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

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

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

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

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

      Alternative 4: 90.7% accurate, 0.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1\\ t_2 := \lambda_1 + \tan^{-1}_* \frac{t\_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)}\\ \mathbf{if}\;t\_2 \leq -0.4 \lor \neg \left(t\_2 \leq 5 \cdot 10^{-13}\right):\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \cos \phi_1\right) \cdot \sin delta}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{{\cos \phi_1}^{2}}\\ \end{array} \end{array} \]
      (FPCore (lambda1 phi1 phi2 delta theta)
       :precision binary64
       (let* ((t_1 (* (* (sin theta) (sin delta)) (cos phi1)))
              (t_2
               (+
                lambda1
                (atan2
                 t_1
                 (-
                  (cos delta)
                  (*
                   (sin phi1)
                   (sin
                    (asin
                     (+
                      (* (sin phi1) (cos delta))
                      (* (* (cos phi1) (sin delta)) (cos theta)))))))))))
         (if (or (<= t_2 -0.4) (not (<= t_2 5e-13)))
           (+ lambda1 (atan2 (* (* (sin theta) (cos phi1)) (sin delta)) (cos delta)))
           (+ lambda1 (atan2 t_1 (pow (cos phi1) 2.0))))))
      double code(double lambda1, double phi1, double phi2, double delta, double theta) {
      	double t_1 = (sin(theta) * sin(delta)) * cos(phi1);
      	double t_2 = lambda1 + atan2(t_1, (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))));
      	double tmp;
      	if ((t_2 <= -0.4) || !(t_2 <= 5e-13)) {
      		tmp = lambda1 + atan2(((sin(theta) * cos(phi1)) * sin(delta)), cos(delta));
      	} else {
      		tmp = lambda1 + atan2(t_1, pow(cos(phi1), 2.0));
      	}
      	return tmp;
      }
      
      real(8) function code(lambda1, phi1, phi2, delta, theta)
          real(8), intent (in) :: lambda1
          real(8), intent (in) :: phi1
          real(8), intent (in) :: phi2
          real(8), intent (in) :: delta
          real(8), intent (in) :: theta
          real(8) :: t_1
          real(8) :: t_2
          real(8) :: tmp
          t_1 = (sin(theta) * sin(delta)) * cos(phi1)
          t_2 = lambda1 + atan2(t_1, (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))))
          if ((t_2 <= (-0.4d0)) .or. (.not. (t_2 <= 5d-13))) then
              tmp = lambda1 + atan2(((sin(theta) * cos(phi1)) * sin(delta)), cos(delta))
          else
              tmp = lambda1 + atan2(t_1, (cos(phi1) ** 2.0d0))
          end if
          code = tmp
      end function
      
      public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
      	double t_1 = (Math.sin(theta) * Math.sin(delta)) * Math.cos(phi1);
      	double t_2 = lambda1 + Math.atan2(t_1, (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))))))));
      	double tmp;
      	if ((t_2 <= -0.4) || !(t_2 <= 5e-13)) {
      		tmp = lambda1 + Math.atan2(((Math.sin(theta) * Math.cos(phi1)) * Math.sin(delta)), Math.cos(delta));
      	} else {
      		tmp = lambda1 + Math.atan2(t_1, Math.pow(Math.cos(phi1), 2.0));
      	}
      	return tmp;
      }
      
      def code(lambda1, phi1, phi2, delta, theta):
      	t_1 = (math.sin(theta) * math.sin(delta)) * math.cos(phi1)
      	t_2 = lambda1 + math.atan2(t_1, (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))))))))
      	tmp = 0
      	if (t_2 <= -0.4) or not (t_2 <= 5e-13):
      		tmp = lambda1 + math.atan2(((math.sin(theta) * math.cos(phi1)) * math.sin(delta)), math.cos(delta))
      	else:
      		tmp = lambda1 + math.atan2(t_1, math.pow(math.cos(phi1), 2.0))
      	return tmp
      
      function code(lambda1, phi1, phi2, delta, theta)
      	t_1 = Float64(Float64(sin(theta) * sin(delta)) * cos(phi1))
      	t_2 = Float64(lambda1 + atan(t_1, Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(sin(phi1) * cos(delta)) + Float64(Float64(cos(phi1) * sin(delta)) * cos(theta)))))))))
      	tmp = 0.0
      	if ((t_2 <= -0.4) || !(t_2 <= 5e-13))
      		tmp = Float64(lambda1 + atan(Float64(Float64(sin(theta) * cos(phi1)) * sin(delta)), cos(delta)));
      	else
      		tmp = Float64(lambda1 + atan(t_1, (cos(phi1) ^ 2.0)));
      	end
      	return tmp
      end
      
      function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
      	t_1 = (sin(theta) * sin(delta)) * cos(phi1);
      	t_2 = lambda1 + atan2(t_1, (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))));
      	tmp = 0.0;
      	if ((t_2 <= -0.4) || ~((t_2 <= 5e-13)))
      		tmp = lambda1 + atan2(((sin(theta) * cos(phi1)) * sin(delta)), cos(delta));
      	else
      		tmp = lambda1 + atan2(t_1, (cos(phi1) ^ 2.0));
      	end
      	tmp_2 = tmp;
      end
      
      code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(lambda1 + N[ArcTan[t$95$1 / 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]}, If[Or[LessEqual[t$95$2, -0.4], N[Not[LessEqual[t$95$2, 5e-13]], $MachinePrecision]], N[(lambda1 + N[ArcTan[N[(N[(N[Sin[theta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[Power[N[Cos[phi1], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_1 := \left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1\\
      t_2 := \lambda_1 + \tan^{-1}_* \frac{t\_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)}\\
      \mathbf{if}\;t\_2 \leq -0.4 \lor \neg \left(t\_2 \leq 5 \cdot 10^{-13}\right):\\
      \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \cos \phi_1\right) \cdot \sin delta}{\cos delta}\\
      
      \mathbf{else}:\\
      \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{{\cos \phi_1}^{2}}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (+.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.40000000000000002 or 4.9999999999999999e-13 < (+.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.9%

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

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

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

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

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

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

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

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

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

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

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

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

        if -0.40000000000000002 < (+.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))))))))) < 4.9999999999999999e-13

        1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;\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)} \leq -0.4 \lor \neg \left(\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)} \leq 5 \cdot 10^{-13}\right):\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \cos \phi_1\right) \cdot \sin delta}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{{\cos \phi_1}^{2}}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 5: 99.7% accurate, 0.6× speedup?

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

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

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

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

      Alternative 6: 69.9% accurate, 0.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\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)} \leq 4 \cdot 10^{-127}:\\ \;\;\;\;{\left({\lambda_1}^{-1}\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(\left(\mathsf{fma}\left(-0.16666666666666666, delta \cdot delta, 1\right) \cdot \left(\mathsf{fma}\left(theta \cdot theta, -0.16666666666666666, 1\right) \cdot theta\right)\right) \cdot delta\right) \cdot \cos \phi_1}{\cos delta}\\ \end{array} \end{array} \]
      (FPCore (lambda1 phi1 phi2 delta theta)
       :precision binary64
       (if (<=
            (atan2
             (* (* (sin theta) (sin delta)) (cos phi1))
             (-
              (cos delta)
              (*
               (sin phi1)
               (sin
                (asin
                 (+
                  (* (sin phi1) (cos delta))
                  (* (* (cos phi1) (sin delta)) (cos theta))))))))
            4e-127)
         (pow (pow lambda1 -1.0) -1.0)
         (+
          lambda1
          (atan2
           (*
            (*
             (*
              (fma -0.16666666666666666 (* delta delta) 1.0)
              (* (fma (* theta theta) -0.16666666666666666 1.0) theta))
             delta)
            (cos phi1))
           (cos delta)))))
      double code(double lambda1, double phi1, double phi2, double delta, double theta) {
      	double tmp;
      	if (atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta)))))))) <= 4e-127) {
      		tmp = pow(pow(lambda1, -1.0), -1.0);
      	} else {
      		tmp = lambda1 + atan2((((fma(-0.16666666666666666, (delta * delta), 1.0) * (fma((theta * theta), -0.16666666666666666, 1.0) * theta)) * delta) * cos(phi1)), cos(delta));
      	}
      	return tmp;
      }
      
      function code(lambda1, phi1, phi2, delta, theta)
      	tmp = 0.0
      	if (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)))))))) <= 4e-127)
      		tmp = (lambda1 ^ -1.0) ^ -1.0;
      	else
      		tmp = Float64(lambda1 + atan(Float64(Float64(Float64(fma(-0.16666666666666666, Float64(delta * delta), 1.0) * Float64(fma(Float64(theta * theta), -0.16666666666666666, 1.0) * theta)) * delta) * cos(phi1)), cos(delta)));
      	end
      	return tmp
      end
      
      code[lambda1_, phi1_, phi2_, delta_, theta_] := If[LessEqual[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], 4e-127], N[Power[N[Power[lambda1, -1.0], $MachinePrecision], -1.0], $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[(N[(N[(-0.16666666666666666 * N[(delta * delta), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[(theta * theta), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * theta), $MachinePrecision]), $MachinePrecision] * delta), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\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)} \leq 4 \cdot 10^{-127}:\\
      \;\;\;\;{\left({\lambda_1}^{-1}\right)}^{-1}\\
      
      \mathbf{else}:\\
      \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(\left(\mathsf{fma}\left(-0.16666666666666666, delta \cdot delta, 1\right) \cdot \left(\mathsf{fma}\left(theta \cdot theta, -0.16666666666666666, 1\right) \cdot theta\right)\right) \cdot delta\right) \cdot \cos \phi_1}{\cos delta}\\
      
      
      \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)))))))) < 4.0000000000000001e-127

        1. Initial program 99.7%

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

            \[\leadsto \color{blue}{\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. flip-+N/A

            \[\leadsto \color{blue}{\frac{\lambda_1 \cdot \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)} \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 - \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. clear-numN/A

            \[\leadsto \color{blue}{\frac{1}{\frac{\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)}}{\lambda_1 \cdot \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)} \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)}}}} \]
        4. Applied rewrites99.6%

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

          \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
        6. Step-by-step derivation
          1. lower-/.f6478.7

            \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
        7. Applied rewrites78.7%

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

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

        1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;\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)} \leq 4 \cdot 10^{-127}:\\ \;\;\;\;{\left({\lambda_1}^{-1}\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(\left(\mathsf{fma}\left(-0.16666666666666666, delta \cdot delta, 1\right) \cdot \left(\mathsf{fma}\left(theta \cdot theta, -0.16666666666666666, 1\right) \cdot theta\right)\right) \cdot delta\right) \cdot \cos \phi_1}{\cos delta}\\ \end{array} \]
        13. Add Preprocessing

        Alternative 7: 70.2% accurate, 0.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\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)} \leq 4 \cdot 10^{-127}:\\ \;\;\;\;{\left({\lambda_1}^{-1}\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(\left(\mathsf{fma}\left(theta \cdot theta, -0.16666666666666666, 1\right) \cdot delta\right) \cdot theta\right) \cdot \cos \phi_1}{\cos delta}\\ \end{array} \end{array} \]
        (FPCore (lambda1 phi1 phi2 delta theta)
         :precision binary64
         (if (<=
              (atan2
               (* (* (sin theta) (sin delta)) (cos phi1))
               (-
                (cos delta)
                (*
                 (sin phi1)
                 (sin
                  (asin
                   (+
                    (* (sin phi1) (cos delta))
                    (* (* (cos phi1) (sin delta)) (cos theta))))))))
              4e-127)
           (pow (pow lambda1 -1.0) -1.0)
           (+
            lambda1
            (atan2
             (*
              (* (* (fma (* theta theta) -0.16666666666666666 1.0) delta) theta)
              (cos phi1))
             (cos delta)))))
        double code(double lambda1, double phi1, double phi2, double delta, double theta) {
        	double tmp;
        	if (atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta)))))))) <= 4e-127) {
        		tmp = pow(pow(lambda1, -1.0), -1.0);
        	} else {
        		tmp = lambda1 + atan2((((fma((theta * theta), -0.16666666666666666, 1.0) * delta) * theta) * cos(phi1)), cos(delta));
        	}
        	return tmp;
        }
        
        function code(lambda1, phi1, phi2, delta, theta)
        	tmp = 0.0
        	if (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)))))))) <= 4e-127)
        		tmp = (lambda1 ^ -1.0) ^ -1.0;
        	else
        		tmp = Float64(lambda1 + atan(Float64(Float64(Float64(fma(Float64(theta * theta), -0.16666666666666666, 1.0) * delta) * theta) * cos(phi1)), cos(delta)));
        	end
        	return tmp
        end
        
        code[lambda1_, phi1_, phi2_, delta_, theta_] := If[LessEqual[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], 4e-127], N[Power[N[Power[lambda1, -1.0], $MachinePrecision], -1.0], $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[(N[(N[(N[(theta * theta), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * delta), $MachinePrecision] * theta), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\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)} \leq 4 \cdot 10^{-127}:\\
        \;\;\;\;{\left({\lambda_1}^{-1}\right)}^{-1}\\
        
        \mathbf{else}:\\
        \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(\left(\mathsf{fma}\left(theta \cdot theta, -0.16666666666666666, 1\right) \cdot delta\right) \cdot theta\right) \cdot \cos \phi_1}{\cos delta}\\
        
        
        \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)))))))) < 4.0000000000000001e-127

          1. Initial program 99.7%

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

              \[\leadsto \color{blue}{\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. flip-+N/A

              \[\leadsto \color{blue}{\frac{\lambda_1 \cdot \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)} \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 - \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. clear-numN/A

              \[\leadsto \color{blue}{\frac{1}{\frac{\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)}}{\lambda_1 \cdot \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)} \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)}}}} \]
          4. Applied rewrites99.6%

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

            \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
          6. Step-by-step derivation
            1. lower-/.f6478.7

              \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
          7. Applied rewrites78.7%

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

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

          1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;\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)} \leq 4 \cdot 10^{-127}:\\ \;\;\;\;{\left({\lambda_1}^{-1}\right)}^{-1}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(\left(\mathsf{fma}\left(theta \cdot theta, -0.16666666666666666, 1\right) \cdot delta\right) \cdot theta\right) \cdot \cos \phi_1}{\cos delta}\\ \end{array} \]
          13. Add Preprocessing

          Alternative 8: 99.7% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 9: 99.7% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 10: 99.7% accurate, 1.2× speedup?

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

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

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

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

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

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

          Alternative 11: 94.7% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 12: 92.2% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 13: 92.4% accurate, 1.9× 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}^{2}} \end{array} \]
          (FPCore (lambda1 phi1 phi2 delta theta)
           :precision binary64
           (+
            lambda1
            (atan2
             (* (* (sin theta) (sin delta)) (cos phi1))
             (- (cos delta) (pow (sin phi1) 2.0)))))
          double code(double lambda1, double phi1, double phi2, double delta, double theta) {
          	return lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - pow(sin(phi1), 2.0)));
          }
          
          real(8) function code(lambda1, phi1, phi2, delta, theta)
              real(8), intent (in) :: lambda1
              real(8), intent (in) :: phi1
              real(8), intent (in) :: phi2
              real(8), intent (in) :: delta
              real(8), intent (in) :: theta
              code = lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) ** 2.0d0)))
          end function
          
          public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
          	return lambda1 + Math.atan2(((Math.sin(theta) * Math.sin(delta)) * Math.cos(phi1)), (Math.cos(delta) - Math.pow(Math.sin(phi1), 2.0)));
          }
          
          def code(lambda1, phi1, phi2, delta, theta):
          	return lambda1 + math.atan2(((math.sin(theta) * math.sin(delta)) * math.cos(phi1)), (math.cos(delta) - math.pow(math.sin(phi1), 2.0)))
          
          function code(lambda1, phi1, phi2, delta, theta)
          	return Float64(lambda1 + atan(Float64(Float64(sin(theta) * sin(delta)) * cos(phi1)), Float64(cos(delta) - (sin(phi1) ^ 2.0))))
          end
          
          function tmp = code(lambda1, phi1, phi2, delta, theta)
          	tmp = lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) ^ 2.0)));
          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[Power[N[Sin[phi1], $MachinePrecision], 2.0], $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}^{2}}
          \end{array}
          
          Derivation
          1. Initial program 99.8%

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

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

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

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

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

          Alternative 14: 88.9% accurate, 2.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 15: 86.3% accurate, 3.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

          Alternative 16: 69.6% accurate, 6.6× speedup?

          \[\begin{array}{l} \\ {\left({\lambda_1}^{-1}\right)}^{-1} \end{array} \]
          (FPCore (lambda1 phi1 phi2 delta theta)
           :precision binary64
           (pow (pow lambda1 -1.0) -1.0))
          double code(double lambda1, double phi1, double phi2, double delta, double theta) {
          	return pow(pow(lambda1, -1.0), -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 ** (-1.0d0)) ** (-1.0d0)
          end function
          
          public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
          	return Math.pow(Math.pow(lambda1, -1.0), -1.0);
          }
          
          def code(lambda1, phi1, phi2, delta, theta):
          	return math.pow(math.pow(lambda1, -1.0), -1.0)
          
          function code(lambda1, phi1, phi2, delta, theta)
          	return (lambda1 ^ -1.0) ^ -1.0
          end
          
          function tmp = code(lambda1, phi1, phi2, delta, theta)
          	tmp = (lambda1 ^ -1.0) ^ -1.0;
          end
          
          code[lambda1_, phi1_, phi2_, delta_, theta_] := N[Power[N[Power[lambda1, -1.0], $MachinePrecision], -1.0], $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          {\left({\lambda_1}^{-1}\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. Step-by-step derivation
            1. lift-+.f64N/A

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

              \[\leadsto \color{blue}{\frac{\lambda_1 \cdot \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)} \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 - \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. clear-numN/A

              \[\leadsto \color{blue}{\frac{1}{\frac{\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)}}{\lambda_1 \cdot \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)} \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)}}}} \]
          4. Applied rewrites99.6%

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

            \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
          6. Step-by-step derivation
            1. lower-/.f6469.9

              \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
          7. Applied rewrites69.9%

            \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
          8. Final simplification69.9%

            \[\leadsto {\left({\lambda_1}^{-1}\right)}^{-1} \]
          9. Add Preprocessing

          Alternative 17: 2.3% accurate, 11.9× speedup?

          \[\begin{array}{l} \\ {\left(\frac{-1}{\lambda_1}\right)}^{-1} \end{array} \]
          (FPCore (lambda1 phi1 phi2 delta theta)
           :precision binary64
           (pow (/ -1.0 lambda1) -1.0))
          double code(double lambda1, double phi1, double phi2, double delta, double theta) {
          	return pow((-1.0 / lambda1), -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 = ((-1.0d0) / lambda1) ** (-1.0d0)
          end function
          
          public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
          	return Math.pow((-1.0 / lambda1), -1.0);
          }
          
          def code(lambda1, phi1, phi2, delta, theta):
          	return math.pow((-1.0 / lambda1), -1.0)
          
          function code(lambda1, phi1, phi2, delta, theta)
          	return Float64(-1.0 / lambda1) ^ -1.0
          end
          
          function tmp = code(lambda1, phi1, phi2, delta, theta)
          	tmp = (-1.0 / lambda1) ^ -1.0;
          end
          
          code[lambda1_, phi1_, phi2_, delta_, theta_] := N[Power[N[(-1.0 / lambda1), $MachinePrecision], -1.0], $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          {\left(\frac{-1}{\lambda_1}\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. Step-by-step derivation
            1. lift-+.f64N/A

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

              \[\leadsto \color{blue}{\frac{\lambda_1 \cdot \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)} \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 - \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. clear-numN/A

              \[\leadsto \color{blue}{\frac{1}{\frac{\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)}}{\lambda_1 \cdot \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)} \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)}}}} \]
          4. Applied rewrites99.6%

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

            \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
          6. Step-by-step derivation
            1. lower-/.f6469.9

              \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
          7. Applied rewrites69.9%

            \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
          8. Step-by-step derivation
            1. Applied rewrites23.1%

              \[\leadsto \frac{1}{{\left(\lambda_1 \cdot \lambda_1\right)}^{\color{blue}{-0.5}}} \]
            2. Taylor expanded in lambda1 around -inf

              \[\leadsto \frac{1}{\frac{-1}{\color{blue}{\lambda_1}}} \]
            3. Step-by-step derivation
              1. Applied rewrites2.1%

                \[\leadsto \frac{1}{\frac{-1}{\color{blue}{\lambda_1}}} \]
              2. Final simplification2.1%

                \[\leadsto {\left(\frac{-1}{\lambda_1}\right)}^{-1} \]
              3. Add Preprocessing

              Reproduce

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