Destination given bearing on a great circle

Percentage Accurate: 99.8% → 99.8%
Time: 18.5s
Alternatives: 14
Speedup: N/A×

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.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 90.9% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(\lambda_1, \frac{\tan^{-1}_* \frac{\sin delta \cdot \left(\cos \phi_1 \cdot \sin theta\right)}{\mathsf{fma}\left(0.5, \cos \left(\phi_1 \cdot 2\right), 0.5\right)}}{\lambda_1}, \lambda_1\right)\\

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


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

    1. Initial program 99.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. cos-lowering-cos.f6485.3

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

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

    if -2e-3 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < 2e-19

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 90.9% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-19}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(0.5, \cos \left(\phi_1 \cdot 2\right), 0.5\right)}\\

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


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

    1. Initial program 99.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. cos-lowering-cos.f6485.3

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

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

    if -2e-3 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < 2e-19

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.8% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 94.4% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 94.5% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 94.4% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 92.4% accurate, 1.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos delta - {\sin \phi_1}^{2}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if delta < -2.1e9

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.1e9 < 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 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. pow-lowering-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. sin-lowering-sin.f6493.8

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

      \[\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}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.6%

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

Alternative 9: 92.2% accurate, 1.9× speedup?

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

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

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

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

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

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

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

Alternative 10: 88.5% accurate, 2.6× speedup?

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

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

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

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

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

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

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

Alternative 11: 86.2% accurate, 3.3× speedup?

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

\\
\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \sin theta}{\cos delta}
\end{array}
Derivation
  1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 76.3% accurate, 4.3× speedup?

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

\\
\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \sin theta}{1}
\end{array}
Derivation
  1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 13: 73.6% accurate, 6.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 14: 70.3% accurate, 1341.0× speedup?

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

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

        \[\leadsto \color{blue}{\lambda_1} \]
      4. Step-by-step derivation
        1. Simplified69.3%

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

        Reproduce

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