Destination given bearing on a great circle

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

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

Initial Program: 99.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.1× speedup?

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

\\
\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\left(\cos delta - {\sin \phi_1}^{2} \cdot \cos delta\right) - \left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) \cdot \sin \phi_1} + \lambda_1
\end{array}
Derivation
  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--.f64N/A

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

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

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

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

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

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

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

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

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

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

Alternative 2: 75.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin delta \cdot \sin theta\right)}{\cos delta - \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right) \cdot \sin \phi_1} \leq -2 \cdot 10^{-64}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin delta \cdot theta}{\cos delta} + \lambda_1\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\frac{1}{2} \cdot \color{blue}{\left(\cos \left(\mathsf{neg}\left(delta\right)\right) - \cos delta\right)}}{\cos delta} \]
        3. Step-by-step derivation
          1. Applied rewrites87.1%

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{0}{\cos delta} \]
        4. Recombined 2 regimes into one program.
        5. Final simplification82.8%

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

        Alternative 3: 99.8% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

        Alternative 4: 99.8% accurate, 1.2× speedup?

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

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

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

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

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

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

        Alternative 5: 94.6% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \mathsf{fma}\left(\sin \phi_1, \cos delta, \sin delta \cdot \cos \phi_1\right) \cdot \color{blue}{\sin \phi_1}} \]
        5. Applied rewrites96.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(\sin \phi_1, \cos delta, \sin delta \cdot \cos \phi_1\right) \cdot \sin \phi_1}} \]
        6. Final simplification96.8%

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

        Alternative 6: 92.3% accurate, 1.9× speedup?

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

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

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

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

        Alternative 7: 89.0% accurate, 2.6× speedup?

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

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

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

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

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

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

        Alternative 8: 86.6% accurate, 3.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 9: 80.8% accurate, 4.0× speedup?

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

          1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if -4.3e18 < delta < 1.65e-10

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

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

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

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

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

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

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

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

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

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

            Alternative 10: 80.9% accurate, 4.0× speedup?

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

              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.f6489.4

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

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

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

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

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

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

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

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

                if -0.55000000000000004 < theta < 4.29999999999999989e-4

                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.f6494.5

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

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

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

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

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

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

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

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

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

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

                  if 4.29999999999999989e-4 < 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.f6489.5

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 11: 80.9% accurate, 4.2× speedup?

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

                    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

                      if -0.55000000000000004 < theta < 4.29999999999999989e-4

                      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.f6494.5

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

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

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

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

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

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

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

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

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

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

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

                      Alternative 12: 72.6% accurate, 6.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\frac{1}{2} \cdot \color{blue}{\left(\cos \left(\mathsf{neg}\left(delta\right)\right) - \cos delta\right)}}{\cos delta} \]
                        3. Step-by-step derivation
                          1. Applied rewrites79.7%

                            \[\leadsto \lambda_1 + \tan^{-1}_* \frac{0}{\cos delta} \]
                          2. Final simplification79.7%

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

                          Alternative 13: 69.8% accurate, 58.3× speedup?

                          \[\begin{array}{l} \\ \frac{1}{\frac{1}{\lambda_1}} \end{array} \]
                          (FPCore (lambda1 phi1 phi2 delta theta)
                           :precision binary64
                           (/ 1.0 (/ 1.0 lambda1)))
                          double code(double lambda1, double phi1, double phi2, double delta, double theta) {
                          	return 1.0 / (1.0 / lambda1);
                          }
                          
                          real(8) function code(lambda1, phi1, phi2, delta, theta)
                              real(8), intent (in) :: lambda1
                              real(8), intent (in) :: phi1
                              real(8), intent (in) :: phi2
                              real(8), intent (in) :: delta
                              real(8), intent (in) :: theta
                              code = 1.0d0 / (1.0d0 / lambda1)
                          end function
                          
                          public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
                          	return 1.0 / (1.0 / lambda1);
                          }
                          
                          def code(lambda1, phi1, phi2, delta, theta):
                          	return 1.0 / (1.0 / lambda1)
                          
                          function code(lambda1, phi1, phi2, delta, theta)
                          	return Float64(1.0 / Float64(1.0 / lambda1))
                          end
                          
                          function tmp = code(lambda1, phi1, phi2, delta, theta)
                          	tmp = 1.0 / (1.0 / lambda1);
                          end
                          
                          code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(1.0 / N[(1.0 / lambda1), $MachinePrecision]), $MachinePrecision]
                          
                          \begin{array}{l}
                          
                          \\
                          \frac{1}{\frac{1}{\lambda_1}}
                          \end{array}
                          
                          Derivation
                          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-+.f64N/A

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

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

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

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

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

                            \[\leadsto \frac{1}{\color{blue}{\frac{1}{\lambda_1}}} \]
                          8. Add Preprocessing

                          Reproduce

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