Destination given bearing on a great circle

Percentage Accurate: 99.8% → 99.8%
Time: 15.8s
Alternatives: 19
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 19 alternatives:

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

Initial Program: 99.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 84.7% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t\_2 \leq -0.1:\\
\;\;\;\;t\_3\\

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

      \[\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 \left(\sin theta + \frac{-1}{6} \cdot \left({delta}^{2} \cdot \sin theta\right)\right)}}{\cos delta} \]
    10. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.14159280000000019 < (+.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 or 5.0000000000000001e-4 < (+.f64 lambda1 (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta))))))))) < 3.14159280000000019

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

    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))))))))) < 5.0000000000000001e-4

    1. Initial program 99.8%

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

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

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{\cos delta} \]
    8. Simplified84.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{\sin delta \cdot \sin theta}{\color{blue}{1}} \]
    10. Step-by-step derivation
      1. Simplified79.2%

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

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

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 3: 78.0% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -0.75 < (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.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.4

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 4: 87.1% accurate, 0.8× speedup?

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

      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.f6490.0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -3.10000000000000009 < (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.6

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

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

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

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

    Alternative 5: 94.6% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 6: 94.6% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 7: 92.1% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 8: 92.2% accurate, 1.9× speedup?

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

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

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

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

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

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

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

    Alternative 9: 91.9% accurate, 2.1× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)\\ \mathbf{if}\;delta \leq -12.6:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos delta}\\ \mathbf{elif}\;delta \leq 0.34:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{{\cos \phi_1}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\frac{1}{\frac{1}{\cos delta}}}\\ \end{array} \end{array} \]
    (FPCore (lambda1 phi1 phi2 delta theta)
     :precision binary64
     (let* ((t_1 (* (cos phi1) (* (sin theta) (sin delta)))))
       (if (<= delta -12.6)
         (+ lambda1 (atan2 t_1 (cos delta)))
         (if (<= delta 0.34)
           (+ lambda1 (atan2 t_1 (pow (cos phi1) 2.0)))
           (+ lambda1 (atan2 t_1 (/ 1.0 (/ 1.0 (cos delta)))))))))
    double code(double lambda1, double phi1, double phi2, double delta, double theta) {
    	double t_1 = cos(phi1) * (sin(theta) * sin(delta));
    	double tmp;
    	if (delta <= -12.6) {
    		tmp = lambda1 + atan2(t_1, cos(delta));
    	} else if (delta <= 0.34) {
    		tmp = lambda1 + atan2(t_1, pow(cos(phi1), 2.0));
    	} else {
    		tmp = lambda1 + atan2(t_1, (1.0 / (1.0 / 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 = cos(phi1) * (sin(theta) * sin(delta))
        if (delta <= (-12.6d0)) then
            tmp = lambda1 + atan2(t_1, cos(delta))
        else if (delta <= 0.34d0) then
            tmp = lambda1 + atan2(t_1, (cos(phi1) ** 2.0d0))
        else
            tmp = lambda1 + atan2(t_1, (1.0d0 / (1.0d0 / 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.cos(phi1) * (Math.sin(theta) * Math.sin(delta));
    	double tmp;
    	if (delta <= -12.6) {
    		tmp = lambda1 + Math.atan2(t_1, Math.cos(delta));
    	} else if (delta <= 0.34) {
    		tmp = lambda1 + Math.atan2(t_1, Math.pow(Math.cos(phi1), 2.0));
    	} else {
    		tmp = lambda1 + Math.atan2(t_1, (1.0 / (1.0 / Math.cos(delta))));
    	}
    	return tmp;
    }
    
    def code(lambda1, phi1, phi2, delta, theta):
    	t_1 = math.cos(phi1) * (math.sin(theta) * math.sin(delta))
    	tmp = 0
    	if delta <= -12.6:
    		tmp = lambda1 + math.atan2(t_1, math.cos(delta))
    	elif delta <= 0.34:
    		tmp = lambda1 + math.atan2(t_1, math.pow(math.cos(phi1), 2.0))
    	else:
    		tmp = lambda1 + math.atan2(t_1, (1.0 / (1.0 / math.cos(delta))))
    	return tmp
    
    function code(lambda1, phi1, phi2, delta, theta)
    	t_1 = Float64(cos(phi1) * Float64(sin(theta) * sin(delta)))
    	tmp = 0.0
    	if (delta <= -12.6)
    		tmp = Float64(lambda1 + atan(t_1, cos(delta)));
    	elseif (delta <= 0.34)
    		tmp = Float64(lambda1 + atan(t_1, (cos(phi1) ^ 2.0)));
    	else
    		tmp = Float64(lambda1 + atan(t_1, Float64(1.0 / Float64(1.0 / cos(delta)))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
    	t_1 = cos(phi1) * (sin(theta) * sin(delta));
    	tmp = 0.0;
    	if (delta <= -12.6)
    		tmp = lambda1 + atan2(t_1, cos(delta));
    	elseif (delta <= 0.34)
    		tmp = lambda1 + atan2(t_1, (cos(phi1) ^ 2.0));
    	else
    		tmp = lambda1 + atan2(t_1, (1.0 / (1.0 / cos(delta))));
    	end
    	tmp_2 = tmp;
    end
    
    code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[delta, -12.6], N[(lambda1 + N[ArcTan[t$95$1 / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[delta, 0.34], N[(lambda1 + N[ArcTan[t$95$1 / N[Power[N[Cos[phi1], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(1.0 / N[(1.0 / N[Cos[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)\\
    \mathbf{if}\;delta \leq -12.6:\\
    \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos delta}\\
    
    \mathbf{elif}\;delta \leq 0.34:\\
    \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{{\cos \phi_1}^{2}}\\
    
    \mathbf{else}:\\
    \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\frac{1}{\frac{1}{\cos delta}}}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if delta < -12.5999999999999996

      1. Initial program 99.9%

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

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

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

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

      if -12.5999999999999996 < delta < 0.340000000000000024

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 0.340000000000000024 < delta

      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. Applied egg-rr99.6%

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

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

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

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

    Alternative 10: 91.9% accurate, 2.4× speedup?

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

      1. Initial program 99.9%

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

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

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

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

      if -12.5999999999999996 < delta < 0.340000000000000024

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 0.340000000000000024 < delta

      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. Applied egg-rr99.6%

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

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

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

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

    Alternative 11: 91.9% accurate, 2.5× speedup?

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

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

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

      if -12.5999999999999996 < delta < 0.340000000000000024

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 12: 91.8% accurate, 2.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta}\\ \mathbf{if}\;delta \leq -3.9:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;delta \leq 0.34:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot delta\right)}{1 - {\sin \phi_1}^{2}}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (lambda1 phi1 phi2 delta theta)
     :precision binary64
     (let* ((t_1
             (+
              lambda1
              (atan2 (* (cos phi1) (* (sin theta) (sin delta))) (cos delta)))))
       (if (<= delta -3.9)
         t_1
         (if (<= delta 0.34)
           (+
            lambda1
            (atan2
             (* (cos phi1) (* (sin theta) delta))
             (- 1.0 (pow (sin phi1) 2.0))))
           t_1))))
    double code(double lambda1, double phi1, double phi2, double delta, double theta) {
    	double t_1 = lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), cos(delta));
    	double tmp;
    	if (delta <= -3.9) {
    		tmp = t_1;
    	} else if (delta <= 0.34) {
    		tmp = lambda1 + atan2((cos(phi1) * (sin(theta) * delta)), (1.0 - pow(sin(phi1), 2.0)));
    	} 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((cos(phi1) * (sin(theta) * sin(delta))), cos(delta))
        if (delta <= (-3.9d0)) then
            tmp = t_1
        else if (delta <= 0.34d0) then
            tmp = lambda1 + atan2((cos(phi1) * (sin(theta) * delta)), (1.0d0 - (sin(phi1) ** 2.0d0)))
        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((Math.cos(phi1) * (Math.sin(theta) * Math.sin(delta))), Math.cos(delta));
    	double tmp;
    	if (delta <= -3.9) {
    		tmp = t_1;
    	} else if (delta <= 0.34) {
    		tmp = lambda1 + Math.atan2((Math.cos(phi1) * (Math.sin(theta) * delta)), (1.0 - Math.pow(Math.sin(phi1), 2.0)));
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    def code(lambda1, phi1, phi2, delta, theta):
    	t_1 = lambda1 + math.atan2((math.cos(phi1) * (math.sin(theta) * math.sin(delta))), math.cos(delta))
    	tmp = 0
    	if delta <= -3.9:
    		tmp = t_1
    	elif delta <= 0.34:
    		tmp = lambda1 + math.atan2((math.cos(phi1) * (math.sin(theta) * delta)), (1.0 - math.pow(math.sin(phi1), 2.0)))
    	else:
    		tmp = t_1
    	return tmp
    
    function code(lambda1, phi1, phi2, delta, theta)
    	t_1 = Float64(lambda1 + atan(Float64(cos(phi1) * Float64(sin(theta) * sin(delta))), cos(delta)))
    	tmp = 0.0
    	if (delta <= -3.9)
    		tmp = t_1;
    	elseif (delta <= 0.34)
    		tmp = Float64(lambda1 + atan(Float64(cos(phi1) * Float64(sin(theta) * delta)), Float64(1.0 - (sin(phi1) ^ 2.0))));
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
    	t_1 = lambda1 + atan2((cos(phi1) * (sin(theta) * sin(delta))), cos(delta));
    	tmp = 0.0;
    	if (delta <= -3.9)
    		tmp = t_1;
    	elseif (delta <= 0.34)
    		tmp = lambda1 + atan2((cos(phi1) * (sin(theta) * delta)), (1.0 - (sin(phi1) ^ 2.0)));
    	else
    		tmp = t_1;
    	end
    	tmp_2 = tmp;
    end
    
    code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(lambda1 + N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[delta, -3.9], t$95$1, If[LessEqual[delta, 0.34], N[(lambda1 + N[ArcTan[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[theta], $MachinePrecision] * delta), $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[Power[N[Sin[phi1], $MachinePrecision], 2.0], $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 theta \cdot \sin delta\right)}{\cos delta}\\
    \mathbf{if}\;delta \leq -3.9:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;delta \leq 0.34:\\
    \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot delta\right)}{1 - {\sin \phi_1}^{2}}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if delta < -3.89999999999999991 or 0.340000000000000024 < 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.3

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

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

      if -3.89999999999999991 < delta < 0.340000000000000024

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

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

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

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

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

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

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

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

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

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

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

    Alternative 13: 88.7% accurate, 2.6× speedup?

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

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

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

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

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

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

    Alternative 14: 86.3% accurate, 3.3× speedup?

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

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

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

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

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

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

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

    Alternative 15: 80.5% accurate, 4.2× speedup?

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

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

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

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

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

        if -5.30000000000000028e42 < theta < 2.1499999999999999e-16

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

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

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

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\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.f6488.5

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

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

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

      Alternative 16: 80.0% accurate, 4.2× speedup?

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

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

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

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\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.8

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

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

        if -8.59999999999999951e28 < delta < 2.7999999999999999e-17

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

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

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \color{blue}{\sin theta}}{\cos delta} \]
        8. Simplified92.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.f6492.0

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

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

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

      Alternative 17: 74.9% accurate, 6.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 18: 73.5% accurate, 6.4× speedup?

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

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

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

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

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

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{delta \cdot \sin theta}{\color{blue}{1}} \]
      13. Step-by-step derivation
        1. Simplified73.0%

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

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

        Alternative 19: 67.4% accurate, 6.4× speedup?

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

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

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

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

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

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

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

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

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

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

        Reproduce

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