Destination given bearing on a great circle

Percentage Accurate: 99.8% → 99.7%
Time: 19.6s
Alternatives: 21
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 21 alternatives:

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

Initial Program: 99.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := 0.5 \cdot \cos \left(\phi_1 + \phi_1\right)\\
t_2 := \mathsf{fma}\left(-\sin \phi_1, \cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\right), \cos delta\right)\\
\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\left({\left(\cos delta \cdot \left(0.5 - t\_1\right)\right)}^{2} - {t\_2}^{2}\right) \cdot \frac{1}{\cos delta \cdot \left(t\_1 - 0.5\right) - t\_2}} + \lambda_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 \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\sin \phi_1, \cos delta, \cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\right)\right), -\sin \phi_1, \cos delta\right)} + \lambda_1} \]
  4. Applied rewrites99.8%

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

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

Alternative 2: 96.5% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;t\_6 \leq -0.1:\\
\;\;\;\;\tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\cos theta, t\_3, t\_2\right), t\_1, \cos delta\right)}\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -2e3 < (+.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.10000000000000001

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \color{blue}{\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)} \]
      10. sub-negN/A

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

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

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

    if -0.10000000000000001 < (+.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.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}{\mathsf{fma}\left(\sin \phi_1 \cdot \cos delta, -\sin \phi_1, \mathsf{fma}\left(\cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\right), -\sin \phi_1, \cos delta\right)\right)}} \]
    4. Taylor expanded in theta around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\cos \left(\phi_1 + \phi_1\right), -0.5, 0.5\right)\\
t_2 := \mathsf{fma}\left(-\sin \phi_1, \cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\right), \cos delta\right)\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\frac{-1}{\mathsf{fma}\left(\cos delta, t\_1, t\_2\right)} \cdot \left({\left(\cos delta \cdot t\_1\right)}^{2} - {t\_2}^{2}\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 \color{blue}{\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\sin \phi_1, \cos delta, \cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\right)\right), -\sin \phi_1, \cos delta\right)} + \lambda_1} \]
  4. Applied rewrites99.8%

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

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

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

Alternative 4: 86.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \sin delta \cdot \sin theta\\ \mathbf{if}\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot t\_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\cos \phi_1 \cdot \sin delta\right)\right)} \leq 2.1:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{0.5 \cdot \left(\cos \left(theta - delta\right) - \cos \left(delta + theta\right)\right)}{\cos delta}\\ \end{array} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (let* ((t_1 (* (sin delta) (sin theta))))
   (if (<=
        (+
         lambda1
         (atan2
          (* (cos phi1) t_1)
          (-
           (cos delta)
           (*
            (sin phi1)
            (sin
             (asin
              (+
               (* (cos delta) (sin phi1))
               (* (cos theta) (* (cos phi1) (sin delta))))))))))
        2.1)
     (+ lambda1 (atan2 t_1 (cos delta)))
     (+
      lambda1
      (atan2
       (* 0.5 (- (cos (- theta delta)) (cos (+ delta theta))))
       (cos delta))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double t_1 = sin(delta) * sin(theta);
	double tmp;
	if ((lambda1 + atan2((cos(phi1) * t_1), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (cos(phi1) * sin(delta)))))))))) <= 2.1) {
		tmp = lambda1 + atan2(t_1, cos(delta));
	} else {
		tmp = lambda1 + atan2((0.5 * (cos((theta - delta)) - cos((delta + theta)))), cos(delta));
	}
	return tmp;
}
real(8) function code(lambda1, phi1, phi2, delta, theta)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8), intent (in) :: delta
    real(8), intent (in) :: theta
    real(8) :: t_1
    real(8) :: tmp
    t_1 = sin(delta) * sin(theta)
    if ((lambda1 + atan2((cos(phi1) * t_1), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (cos(phi1) * sin(delta)))))))))) <= 2.1d0) then
        tmp = lambda1 + atan2(t_1, cos(delta))
    else
        tmp = lambda1 + atan2((0.5d0 * (cos((theta - delta)) - cos((delta + theta)))), cos(delta))
    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(delta) * Math.sin(theta);
	double tmp;
	if ((lambda1 + Math.atan2((Math.cos(phi1) * t_1), (Math.cos(delta) - (Math.sin(phi1) * Math.sin(Math.asin(((Math.cos(delta) * Math.sin(phi1)) + (Math.cos(theta) * (Math.cos(phi1) * Math.sin(delta)))))))))) <= 2.1) {
		tmp = lambda1 + Math.atan2(t_1, Math.cos(delta));
	} else {
		tmp = lambda1 + Math.atan2((0.5 * (Math.cos((theta - delta)) - Math.cos((delta + theta)))), Math.cos(delta));
	}
	return tmp;
}
def code(lambda1, phi1, phi2, delta, theta):
	t_1 = math.sin(delta) * math.sin(theta)
	tmp = 0
	if (lambda1 + math.atan2((math.cos(phi1) * t_1), (math.cos(delta) - (math.sin(phi1) * math.sin(math.asin(((math.cos(delta) * math.sin(phi1)) + (math.cos(theta) * (math.cos(phi1) * math.sin(delta)))))))))) <= 2.1:
		tmp = lambda1 + math.atan2(t_1, math.cos(delta))
	else:
		tmp = lambda1 + math.atan2((0.5 * (math.cos((theta - delta)) - math.cos((delta + theta)))), math.cos(delta))
	return tmp
function code(lambda1, phi1, phi2, delta, theta)
	t_1 = Float64(sin(delta) * sin(theta))
	tmp = 0.0
	if (Float64(lambda1 + atan(Float64(cos(phi1) * t_1), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(cos(delta) * sin(phi1)) + Float64(cos(theta) * Float64(cos(phi1) * sin(delta)))))))))) <= 2.1)
		tmp = Float64(lambda1 + atan(t_1, cos(delta)));
	else
		tmp = Float64(lambda1 + atan(Float64(0.5 * Float64(cos(Float64(theta - delta)) - cos(Float64(delta + theta)))), cos(delta)));
	end
	return tmp
end
function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
	t_1 = sin(delta) * sin(theta);
	tmp = 0.0;
	if ((lambda1 + atan2((cos(phi1) * t_1), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (cos(phi1) * sin(delta)))))))))) <= 2.1)
		tmp = lambda1 + atan2(t_1, cos(delta));
	else
		tmp = lambda1 + atan2((0.5 * (cos((theta - delta)) - cos((delta + theta)))), cos(delta));
	end
	tmp_2 = tmp;
end
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(N[Sin[delta], $MachinePrecision] * N[Sin[theta], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(lambda1 + N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[theta], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.1], N[(lambda1 + N[ArcTan[t$95$1 / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(0.5 * N[(N[Cos[N[(theta - delta), $MachinePrecision]], $MachinePrecision] - N[Cos[N[(delta + theta), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\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))))))))) < 2.10000000000000009

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 86.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \sin delta \cdot \sin theta\\ \mathbf{if}\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot t\_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\cos \phi_1 \cdot \sin delta\right)\right)} \leq 2.6:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot theta\right)}{\cos delta}\\ \end{array} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (let* ((t_1 (* (sin delta) (sin theta))))
   (if (<=
        (+
         lambda1
         (atan2
          (* (cos phi1) t_1)
          (-
           (cos delta)
           (*
            (sin phi1)
            (sin
             (asin
              (+
               (* (cos delta) (sin phi1))
               (* (cos theta) (* (cos phi1) (sin delta))))))))))
        2.6)
     (+ lambda1 (atan2 t_1 (cos delta)))
     (+ lambda1 (atan2 (* (sin delta) (* (cos phi1) theta)) (cos delta))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double t_1 = sin(delta) * sin(theta);
	double tmp;
	if ((lambda1 + atan2((cos(phi1) * t_1), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (cos(phi1) * sin(delta)))))))))) <= 2.6) {
		tmp = lambda1 + atan2(t_1, cos(delta));
	} else {
		tmp = lambda1 + atan2((sin(delta) * (cos(phi1) * theta)), cos(delta));
	}
	return tmp;
}
real(8) function code(lambda1, phi1, phi2, delta, theta)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8), intent (in) :: delta
    real(8), intent (in) :: theta
    real(8) :: t_1
    real(8) :: tmp
    t_1 = sin(delta) * sin(theta)
    if ((lambda1 + atan2((cos(phi1) * t_1), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (cos(phi1) * sin(delta)))))))))) <= 2.6d0) then
        tmp = lambda1 + atan2(t_1, cos(delta))
    else
        tmp = lambda1 + atan2((sin(delta) * (cos(phi1) * theta)), cos(delta))
    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(delta) * Math.sin(theta);
	double tmp;
	if ((lambda1 + Math.atan2((Math.cos(phi1) * t_1), (Math.cos(delta) - (Math.sin(phi1) * Math.sin(Math.asin(((Math.cos(delta) * Math.sin(phi1)) + (Math.cos(theta) * (Math.cos(phi1) * Math.sin(delta)))))))))) <= 2.6) {
		tmp = lambda1 + Math.atan2(t_1, Math.cos(delta));
	} else {
		tmp = lambda1 + Math.atan2((Math.sin(delta) * (Math.cos(phi1) * theta)), Math.cos(delta));
	}
	return tmp;
}
def code(lambda1, phi1, phi2, delta, theta):
	t_1 = math.sin(delta) * math.sin(theta)
	tmp = 0
	if (lambda1 + math.atan2((math.cos(phi1) * t_1), (math.cos(delta) - (math.sin(phi1) * math.sin(math.asin(((math.cos(delta) * math.sin(phi1)) + (math.cos(theta) * (math.cos(phi1) * math.sin(delta)))))))))) <= 2.6:
		tmp = lambda1 + math.atan2(t_1, math.cos(delta))
	else:
		tmp = lambda1 + math.atan2((math.sin(delta) * (math.cos(phi1) * theta)), math.cos(delta))
	return tmp
function code(lambda1, phi1, phi2, delta, theta)
	t_1 = Float64(sin(delta) * sin(theta))
	tmp = 0.0
	if (Float64(lambda1 + atan(Float64(cos(phi1) * t_1), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(cos(delta) * sin(phi1)) + Float64(cos(theta) * Float64(cos(phi1) * sin(delta)))))))))) <= 2.6)
		tmp = Float64(lambda1 + atan(t_1, cos(delta)));
	else
		tmp = Float64(lambda1 + atan(Float64(sin(delta) * Float64(cos(phi1) * theta)), cos(delta)));
	end
	return tmp
end
function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
	t_1 = sin(delta) * sin(theta);
	tmp = 0.0;
	if ((lambda1 + atan2((cos(phi1) * t_1), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (cos(phi1) * sin(delta)))))))))) <= 2.6)
		tmp = lambda1 + atan2(t_1, cos(delta));
	else
		tmp = lambda1 + atan2((sin(delta) * (cos(phi1) * theta)), cos(delta));
	end
	tmp_2 = tmp;
end
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(N[Sin[delta], $MachinePrecision] * N[Sin[theta], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(lambda1 + N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[theta], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.6], N[(lambda1 + N[ArcTan[t$95$1 / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Sin[delta], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * theta), $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\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))))))))) < 2.60000000000000009

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 78.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \sin delta \cdot \sin theta\\ \mathbf{if}\;\tan^{-1}_* \frac{\cos \phi_1 \cdot t\_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\cos delta \cdot \sin \phi_1 + \cos theta \cdot \left(\cos \phi_1 \cdot \sin delta\right)\right)} \leq -5 \cdot 10^{-48}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot theta}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{1}\\ \end{array} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (let* ((t_1 (* (sin delta) (sin theta))))
   (if (<=
        (atan2
         (* (cos phi1) t_1)
         (-
          (cos delta)
          (*
           (sin phi1)
           (sin
            (asin
             (+
              (* (cos delta) (sin phi1))
              (* (cos theta) (* (cos phi1) (sin delta)))))))))
        -5e-48)
     (+ lambda1 (atan2 (* (sin delta) theta) (cos delta)))
     (+ lambda1 (atan2 t_1 1.0)))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double t_1 = sin(delta) * sin(theta);
	double tmp;
	if (atan2((cos(phi1) * t_1), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (cos(phi1) * sin(delta))))))))) <= -5e-48) {
		tmp = lambda1 + atan2((sin(delta) * theta), cos(delta));
	} else {
		tmp = lambda1 + atan2(t_1, 1.0);
	}
	return tmp;
}
real(8) function code(lambda1, phi1, phi2, delta, theta)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8), intent (in) :: delta
    real(8), intent (in) :: theta
    real(8) :: t_1
    real(8) :: tmp
    t_1 = sin(delta) * sin(theta)
    if (atan2((cos(phi1) * t_1), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (cos(phi1) * sin(delta))))))))) <= (-5d-48)) then
        tmp = lambda1 + atan2((sin(delta) * theta), cos(delta))
    else
        tmp = lambda1 + atan2(t_1, 1.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(delta) * Math.sin(theta);
	double tmp;
	if (Math.atan2((Math.cos(phi1) * t_1), (Math.cos(delta) - (Math.sin(phi1) * Math.sin(Math.asin(((Math.cos(delta) * Math.sin(phi1)) + (Math.cos(theta) * (Math.cos(phi1) * Math.sin(delta))))))))) <= -5e-48) {
		tmp = lambda1 + Math.atan2((Math.sin(delta) * theta), Math.cos(delta));
	} else {
		tmp = lambda1 + Math.atan2(t_1, 1.0);
	}
	return tmp;
}
def code(lambda1, phi1, phi2, delta, theta):
	t_1 = math.sin(delta) * math.sin(theta)
	tmp = 0
	if math.atan2((math.cos(phi1) * t_1), (math.cos(delta) - (math.sin(phi1) * math.sin(math.asin(((math.cos(delta) * math.sin(phi1)) + (math.cos(theta) * (math.cos(phi1) * math.sin(delta))))))))) <= -5e-48:
		tmp = lambda1 + math.atan2((math.sin(delta) * theta), math.cos(delta))
	else:
		tmp = lambda1 + math.atan2(t_1, 1.0)
	return tmp
function code(lambda1, phi1, phi2, delta, theta)
	t_1 = Float64(sin(delta) * sin(theta))
	tmp = 0.0
	if (atan(Float64(cos(phi1) * t_1), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(cos(delta) * sin(phi1)) + Float64(cos(theta) * Float64(cos(phi1) * sin(delta))))))))) <= -5e-48)
		tmp = Float64(lambda1 + atan(Float64(sin(delta) * theta), cos(delta)));
	else
		tmp = Float64(lambda1 + atan(t_1, 1.0));
	end
	return tmp
end
function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
	t_1 = sin(delta) * sin(theta);
	tmp = 0.0;
	if (atan2((cos(phi1) * t_1), (cos(delta) - (sin(phi1) * sin(asin(((cos(delta) * sin(phi1)) + (cos(theta) * (cos(phi1) * sin(delta))))))))) <= -5e-48)
		tmp = lambda1 + atan2((sin(delta) * theta), cos(delta));
	else
		tmp = lambda1 + atan2(t_1, 1.0);
	end
	tmp_2 = tmp;
end
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(N[Sin[delta], $MachinePrecision] * N[Sin[theta], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[theta], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], -5e-48], N[(lambda1 + N[ArcTan[N[(N[Sin[delta], $MachinePrecision] * theta), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / 1.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\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.9999999999999999e-48

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.9999999999999999e-48 < (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.f6490.8

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

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

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

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

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

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

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

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

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

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

    Alternative 7: 99.8% accurate, 1.1× speedup?

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

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

    Alternative 8: 99.8% accurate, 1.2× speedup?

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

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

    Alternative 9: 94.2% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\mathsf{fma}\left(\cos delta \cdot \sin \phi_1, -\sin \phi_1, \cos delta\right)}\\ \mathbf{if}\;theta \leq -2.25 \cdot 10^{+27}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;theta \leq 5.9 \cdot 10^{-9}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot theta\right)}{\mathsf{fma}\left(1 - {\sin \phi_1}^{2}, \cos delta, -\sin \phi_1 \cdot \left(\cos \phi_1 \cdot \sin delta\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (lambda1 phi1 phi2 delta theta)
     :precision binary64
     (let* ((t_1
             (+
              lambda1
              (atan2
               (* (cos phi1) (* (sin delta) (sin theta)))
               (fma (* (cos delta) (sin phi1)) (- (sin phi1)) (cos delta))))))
       (if (<= theta -2.25e+27)
         t_1
         (if (<= theta 5.9e-9)
           (+
            lambda1
            (atan2
             (* (cos phi1) (* (sin delta) theta))
             (fma
              (- 1.0 (pow (sin phi1) 2.0))
              (cos delta)
              (- (* (sin phi1) (* (cos phi1) (sin delta)))))))
           t_1))))
    double code(double lambda1, double phi1, double phi2, double delta, double theta) {
    	double t_1 = lambda1 + atan2((cos(phi1) * (sin(delta) * sin(theta))), fma((cos(delta) * sin(phi1)), -sin(phi1), cos(delta)));
    	double tmp;
    	if (theta <= -2.25e+27) {
    		tmp = t_1;
    	} else if (theta <= 5.9e-9) {
    		tmp = lambda1 + atan2((cos(phi1) * (sin(delta) * theta)), fma((1.0 - pow(sin(phi1), 2.0)), cos(delta), -(sin(phi1) * (cos(phi1) * sin(delta)))));
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    function code(lambda1, phi1, phi2, delta, theta)
    	t_1 = Float64(lambda1 + atan(Float64(cos(phi1) * Float64(sin(delta) * sin(theta))), fma(Float64(cos(delta) * sin(phi1)), Float64(-sin(phi1)), cos(delta))))
    	tmp = 0.0
    	if (theta <= -2.25e+27)
    		tmp = t_1;
    	elseif (theta <= 5.9e-9)
    		tmp = Float64(lambda1 + atan(Float64(cos(phi1) * Float64(sin(delta) * theta)), fma(Float64(1.0 - (sin(phi1) ^ 2.0)), cos(delta), Float64(-Float64(sin(phi1) * Float64(cos(phi1) * sin(delta)))))));
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(lambda1 + N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Sin[theta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision]) + N[Cos[delta], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[theta, -2.25e+27], t$95$1, If[LessEqual[theta, 5.9e-9], N[(lambda1 + N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * theta), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - N[Power[N[Sin[phi1], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Cos[delta], $MachinePrecision] + (-N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\mathsf{fma}\left(\cos delta \cdot \sin \phi_1, -\sin \phi_1, \cos delta\right)}\\
    \mathbf{if}\;theta \leq -2.25 \cdot 10^{+27}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;theta \leq 5.9 \cdot 10^{-9}:\\
    \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot theta\right)}{\mathsf{fma}\left(1 - {\sin \phi_1}^{2}, \cos delta, -\sin \phi_1 \cdot \left(\cos \phi_1 \cdot \sin delta\right)\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if theta < -2.25e27 or 5.8999999999999999e-9 < 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. Applied rewrites99.7%

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

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

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

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

      if -2.25e27 < theta < 5.8999999999999999e-9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 10: 94.9% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 11: 92.3% accurate, 1.6× speedup?

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

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

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

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

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

    Alternative 12: 92.4% accurate, 1.9× speedup?

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

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

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

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

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

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

    Alternative 13: 92.4% accurate, 1.9× speedup?

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

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

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

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

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

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

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

    Alternative 14: 92.4% accurate, 2.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 15: 89.2% accurate, 2.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 16: 87.0% accurate, 3.3× speedup?

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

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

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

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

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

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

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

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

    Alternative 17: 79.3% accurate, 4.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 5.00000000000000015e39 < delta

      1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 18: 79.3% accurate, 4.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 7.0000000000000003e39 < delta

      1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 19: 80.8% accurate, 4.2× speedup?

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

      1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -2e-8 < theta < 1.7e7

      1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 20: 75.3% accurate, 4.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 21: 70.9% accurate, 1341.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
    10. Applied rewrites72.1%

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
    11. Step-by-step derivation
      1. remove-double-div72.3

        \[\leadsto \color{blue}{\lambda_1} \]
    12. Applied rewrites72.3%

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

    Reproduce

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