Destination given bearing on a great circle

Percentage Accurate: 99.7% → 99.8%
Time: 17.3s
Alternatives: 14
Speedup: 1.4×

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 14 alternatives:

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

Initial Program: 99.7% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.7% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.7% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.7% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 94.4% accurate, 1.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 92.0% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

Alternative 7: 91.5% accurate, 2.1× speedup?

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

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

\mathbf{elif}\;delta \leq 9 \cdot 10^{-7}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{{\cos \phi_1}^{2}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if delta < -6.0000000000000002e-6 or 8.99999999999999959e-7 < delta

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.0000000000000002e-6 < delta < 8.99999999999999959e-7

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

    Alternative 8: 88.1% accurate, 2.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 9: 85.7% accurate, 3.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

    Alternative 10: 79.8% accurate, 3.7× speedup?

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

      1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

        if -1.1e6 < delta < 3.10000000000000009

        1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

          if 3.10000000000000009 < 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.f6482.2

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

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

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

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

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

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

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

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

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

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

          Alternative 11: 79.7% accurate, 4.0× speedup?

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

            1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

              if -8.5e9 < delta < 0.0779999999999999999

              1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

                  if 0.0779999999999999999 < 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.f6482.2

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

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

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

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

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

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

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

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

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

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

                  Alternative 12: 79.7% accurate, 4.0× speedup?

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

                    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

                      if -8.5e9 < delta < 0.0779999999999999999

                      1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

                        Alternative 13: 79.6% accurate, 4.2× speedup?

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

                          1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

                            if -9.39999999999999972e-4 < theta < 8.00000000000000029e-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.f6495.2

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

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

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

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

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

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

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

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

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

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

                            Alternative 14: 73.8% accurate, 4.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

                              Reproduce

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