Destination given bearing on a great circle

Percentage Accurate: 99.8% → 99.7%
Time: 24.1s
Alternatives: 19
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 19 alternatives:

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

Initial Program: 99.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\cos delta, \sin \phi_1, \cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\right)\right)\\
t_2 := \sin \phi_1 \cdot t\_1\\
\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\frac{1}{\frac{{\cos delta}^{2} + t\_2 \cdot \mathsf{fma}\left(t\_1, \sin \phi_1, \cos delta\right)}{{\cos delta}^{3} - {t\_2}^{3}}}}
\end{array}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)} \]
  2. Step-by-step derivation
    1. associate-*l*99.8%

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.8% accurate, 1.1× speedup?

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

\\
\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\sin \phi_1, \cos delta, \cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\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. Step-by-step derivation
    1. associate-*l*99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.8% accurate, 1.2× speedup?

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

\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_1 \cdot \left(\sin theta \cdot \sin delta\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\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. Step-by-step derivation
    1. associate-*l*99.8%

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

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

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

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

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

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

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

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

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

Alternative 5: 99.8% accurate, 1.2× speedup?

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

\\
\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\cos delta - \sin \phi_1 \cdot \left(\cos delta \cdot \sin \phi_1 + \cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\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. Step-by-step derivation
    1. associate-*l*99.8%

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

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

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

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

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

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

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

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

Alternative 6: 92.6% accurate, 1.3× speedup?

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

\\
\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\cos delta - \sin \phi_1 \cdot \left(\sin \phi_1 + \cos \phi_1 \cdot \left(\sin delta \cdot \cos theta\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. Step-by-step derivation
    1. associate-*l*99.8%

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

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

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

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

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

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

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

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

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

Alternative 7: 94.5% accurate, 1.3× speedup?

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

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

    \[\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)} \]
  2. Step-by-step derivation
    1. associate-*l*99.8%

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

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

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

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

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

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

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

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

Alternative 8: 92.2% accurate, 1.6× speedup?

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

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

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

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

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

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

Alternative 9: 92.2% accurate, 1.9× speedup?

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

\\
\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\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. Step-by-step derivation
    1. associate-*l*99.8%

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

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

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

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

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

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

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

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

Alternative 10: 91.7% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\\ \mathbf{if}\;delta \leq -6 \cdot 10^{-6} \lor \neg \left(delta \leq 2.7 \cdot 10^{-21}\right):\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{{\cos \phi_1}^{2}}\\ \end{array} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (let* ((t_1 (* (sin theta) (* (sin delta) (cos phi1)))))
   (if (or (<= delta -6e-6) (not (<= delta 2.7e-21)))
     (+ lambda1 (atan2 t_1 (cos delta)))
     (+ lambda1 (atan2 t_1 (pow (cos phi1) 2.0))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double t_1 = sin(theta) * (sin(delta) * cos(phi1));
	double tmp;
	if ((delta <= -6e-6) || !(delta <= 2.7e-21)) {
		tmp = lambda1 + atan2(t_1, cos(delta));
	} else {
		tmp = lambda1 + atan2(t_1, pow(cos(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 = sin(theta) * (sin(delta) * cos(phi1))
    if ((delta <= (-6d-6)) .or. (.not. (delta <= 2.7d-21))) then
        tmp = lambda1 + atan2(t_1, cos(delta))
    else
        tmp = lambda1 + atan2(t_1, (cos(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.sin(theta) * (Math.sin(delta) * Math.cos(phi1));
	double tmp;
	if ((delta <= -6e-6) || !(delta <= 2.7e-21)) {
		tmp = lambda1 + Math.atan2(t_1, Math.cos(delta));
	} else {
		tmp = lambda1 + Math.atan2(t_1, Math.pow(Math.cos(phi1), 2.0));
	}
	return tmp;
}
def code(lambda1, phi1, phi2, delta, theta):
	t_1 = math.sin(theta) * (math.sin(delta) * math.cos(phi1))
	tmp = 0
	if (delta <= -6e-6) or not (delta <= 2.7e-21):
		tmp = lambda1 + math.atan2(t_1, math.cos(delta))
	else:
		tmp = lambda1 + math.atan2(t_1, math.pow(math.cos(phi1), 2.0))
	return tmp
function code(lambda1, phi1, phi2, delta, theta)
	t_1 = Float64(sin(theta) * Float64(sin(delta) * cos(phi1)))
	tmp = 0.0
	if ((delta <= -6e-6) || !(delta <= 2.7e-21))
		tmp = Float64(lambda1 + atan(t_1, cos(delta)));
	else
		tmp = Float64(lambda1 + atan(t_1, (cos(phi1) ^ 2.0)));
	end
	return tmp
end
function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
	t_1 = sin(theta) * (sin(delta) * cos(phi1));
	tmp = 0.0;
	if ((delta <= -6e-6) || ~((delta <= 2.7e-21)))
		tmp = lambda1 + atan2(t_1, cos(delta));
	else
		tmp = lambda1 + atan2(t_1, (cos(phi1) ^ 2.0));
	end
	tmp_2 = tmp;
end
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(N[Sin[theta], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[delta, -6e-6], N[Not[LessEqual[delta, 2.7e-21]], $MachinePrecision]], N[(lambda1 + N[ArcTan[t$95$1 / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[Power[N[Cos[phi1], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if delta < -6.0000000000000002e-6 or 2.7000000000000001e-21 < 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. Step-by-step derivation
      1. associate-*l*99.8%

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

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

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

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

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

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

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

    if -6.0000000000000002e-6 < delta < 2.7000000000000001e-21

    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. Step-by-step derivation
      1. associate-*l*99.8%

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

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

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

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

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

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

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\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}}} \]
    6. Taylor expanded in delta around 0 99.4%

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

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

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

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

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

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

Alternative 11: 91.7% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)\\ \mathbf{if}\;delta \leq -1.45 \cdot 10^{-6} \lor \neg \left(delta \leq 2.7 \cdot 10^{-21}\right):\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\frac{1 + \cos \left(\phi_1 \cdot 2\right)}{2}}\\ \end{array} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (let* ((t_1 (* (sin theta) (* (sin delta) (cos phi1)))))
   (if (or (<= delta -1.45e-6) (not (<= delta 2.7e-21)))
     (+ lambda1 (atan2 t_1 (cos delta)))
     (+ lambda1 (atan2 t_1 (/ (+ 1.0 (cos (* phi1 2.0))) 2.0))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double t_1 = sin(theta) * (sin(delta) * cos(phi1));
	double tmp;
	if ((delta <= -1.45e-6) || !(delta <= 2.7e-21)) {
		tmp = lambda1 + atan2(t_1, cos(delta));
	} else {
		tmp = lambda1 + atan2(t_1, ((1.0 + cos((phi1 * 2.0))) / 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 = sin(theta) * (sin(delta) * cos(phi1))
    if ((delta <= (-1.45d-6)) .or. (.not. (delta <= 2.7d-21))) then
        tmp = lambda1 + atan2(t_1, cos(delta))
    else
        tmp = lambda1 + atan2(t_1, ((1.0d0 + cos((phi1 * 2.0d0))) / 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.sin(theta) * (Math.sin(delta) * Math.cos(phi1));
	double tmp;
	if ((delta <= -1.45e-6) || !(delta <= 2.7e-21)) {
		tmp = lambda1 + Math.atan2(t_1, Math.cos(delta));
	} else {
		tmp = lambda1 + Math.atan2(t_1, ((1.0 + Math.cos((phi1 * 2.0))) / 2.0));
	}
	return tmp;
}
def code(lambda1, phi1, phi2, delta, theta):
	t_1 = math.sin(theta) * (math.sin(delta) * math.cos(phi1))
	tmp = 0
	if (delta <= -1.45e-6) or not (delta <= 2.7e-21):
		tmp = lambda1 + math.atan2(t_1, math.cos(delta))
	else:
		tmp = lambda1 + math.atan2(t_1, ((1.0 + math.cos((phi1 * 2.0))) / 2.0))
	return tmp
function code(lambda1, phi1, phi2, delta, theta)
	t_1 = Float64(sin(theta) * Float64(sin(delta) * cos(phi1)))
	tmp = 0.0
	if ((delta <= -1.45e-6) || !(delta <= 2.7e-21))
		tmp = Float64(lambda1 + atan(t_1, cos(delta)));
	else
		tmp = Float64(lambda1 + atan(t_1, Float64(Float64(1.0 + cos(Float64(phi1 * 2.0))) / 2.0)));
	end
	return tmp
end
function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
	t_1 = sin(theta) * (sin(delta) * cos(phi1));
	tmp = 0.0;
	if ((delta <= -1.45e-6) || ~((delta <= 2.7e-21)))
		tmp = lambda1 + atan2(t_1, cos(delta));
	else
		tmp = lambda1 + atan2(t_1, ((1.0 + cos((phi1 * 2.0))) / 2.0));
	end
	tmp_2 = tmp;
end
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(N[Sin[theta], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[delta, -1.45e-6], N[Not[LessEqual[delta, 2.7e-21]], $MachinePrecision]], N[(lambda1 + N[ArcTan[t$95$1 / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[(1.0 + N[Cos[N[(phi1 * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\frac{1 + \cos \left(\phi_1 \cdot 2\right)}{2}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if delta < -1.4500000000000001e-6 or 2.7000000000000001e-21 < 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. Step-by-step derivation
      1. associate-*l*99.8%

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

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

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

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

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

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

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

    if -1.4500000000000001e-6 < delta < 2.7000000000000001e-21

    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. Step-by-step derivation
      1. associate-*l*99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 91.7% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;delta \leq -9.5 \cdot 10^{-7} \lor \neg \left(delta \leq 2.6 \cdot 10^{-21}\right):\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{delta \cdot \left(\sin theta \cdot \cos \phi_1\right)}{1 - {\sin \phi_1}^{2}}\\ \end{array} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (if (or (<= delta -9.5e-7) (not (<= delta 2.6e-21)))
   (+ lambda1 (atan2 (* (sin theta) (* (sin delta) (cos phi1))) (cos delta)))
   (+
    lambda1
    (atan2
     (* delta (* (sin theta) (cos phi1)))
     (- 1.0 (pow (sin phi1) 2.0))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double tmp;
	if ((delta <= -9.5e-7) || !(delta <= 2.6e-21)) {
		tmp = lambda1 + atan2((sin(theta) * (sin(delta) * cos(phi1))), cos(delta));
	} else {
		tmp = lambda1 + atan2((delta * (sin(theta) * cos(phi1))), (1.0 - 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) :: tmp
    if ((delta <= (-9.5d-7)) .or. (.not. (delta <= 2.6d-21))) then
        tmp = lambda1 + atan2((sin(theta) * (sin(delta) * cos(phi1))), cos(delta))
    else
        tmp = lambda1 + atan2((delta * (sin(theta) * cos(phi1))), (1.0d0 - (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 tmp;
	if ((delta <= -9.5e-7) || !(delta <= 2.6e-21)) {
		tmp = lambda1 + Math.atan2((Math.sin(theta) * (Math.sin(delta) * Math.cos(phi1))), Math.cos(delta));
	} else {
		tmp = lambda1 + Math.atan2((delta * (Math.sin(theta) * Math.cos(phi1))), (1.0 - Math.pow(Math.sin(phi1), 2.0)));
	}
	return tmp;
}
def code(lambda1, phi1, phi2, delta, theta):
	tmp = 0
	if (delta <= -9.5e-7) or not (delta <= 2.6e-21):
		tmp = lambda1 + math.atan2((math.sin(theta) * (math.sin(delta) * math.cos(phi1))), math.cos(delta))
	else:
		tmp = lambda1 + math.atan2((delta * (math.sin(theta) * math.cos(phi1))), (1.0 - math.pow(math.sin(phi1), 2.0)))
	return tmp
function code(lambda1, phi1, phi2, delta, theta)
	tmp = 0.0
	if ((delta <= -9.5e-7) || !(delta <= 2.6e-21))
		tmp = Float64(lambda1 + atan(Float64(sin(theta) * Float64(sin(delta) * cos(phi1))), cos(delta)));
	else
		tmp = Float64(lambda1 + atan(Float64(delta * Float64(sin(theta) * cos(phi1))), Float64(1.0 - (sin(phi1) ^ 2.0))));
	end
	return tmp
end
function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
	tmp = 0.0;
	if ((delta <= -9.5e-7) || ~((delta <= 2.6e-21)))
		tmp = lambda1 + atan2((sin(theta) * (sin(delta) * cos(phi1))), cos(delta));
	else
		tmp = lambda1 + atan2((delta * (sin(theta) * cos(phi1))), (1.0 - (sin(phi1) ^ 2.0)));
	end
	tmp_2 = tmp;
end
code[lambda1_, phi1_, phi2_, delta_, theta_] := If[Or[LessEqual[delta, -9.5e-7], N[Not[LessEqual[delta, 2.6e-21]], $MachinePrecision]], N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(delta * N[(N[Sin[theta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[Power[N[Sin[phi1], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;delta \leq -9.5 \cdot 10^{-7} \lor \neg \left(delta \leq 2.6 \cdot 10^{-21}\right):\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\cos delta}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if delta < -9.5000000000000001e-7 or 2.60000000000000017e-21 < 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. Step-by-step derivation
      1. associate-*l*99.8%

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

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

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

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

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

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

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

    if -9.5000000000000001e-7 < delta < 2.60000000000000017e-21

    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. Step-by-step derivation
      1. associate-*l*99.8%

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

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

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

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

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

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

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

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

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

Alternative 13: 88.5% accurate, 2.6× speedup?

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

\\
\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\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. Step-by-step derivation
    1. associate-*l*99.8%

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

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

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

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

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

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

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

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

Alternative 14: 78.5% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;delta \leq -2.9 \cdot 10^{-9}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \sin delta}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot \mathsf{log1p}\left(delta\right)}{\cos delta}\\ \end{array} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (if (<= delta -2.9e-9)
   (+ lambda1 (atan2 (* theta (sin delta)) (cos delta)))
   (+ lambda1 (atan2 (* (sin theta) (log1p delta)) (cos delta)))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double tmp;
	if (delta <= -2.9e-9) {
		tmp = lambda1 + atan2((theta * sin(delta)), cos(delta));
	} else {
		tmp = lambda1 + atan2((sin(theta) * log1p(delta)), cos(delta));
	}
	return tmp;
}
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double tmp;
	if (delta <= -2.9e-9) {
		tmp = lambda1 + Math.atan2((theta * Math.sin(delta)), Math.cos(delta));
	} else {
		tmp = lambda1 + Math.atan2((Math.sin(theta) * Math.log1p(delta)), Math.cos(delta));
	}
	return tmp;
}
def code(lambda1, phi1, phi2, delta, theta):
	tmp = 0
	if delta <= -2.9e-9:
		tmp = lambda1 + math.atan2((theta * math.sin(delta)), math.cos(delta))
	else:
		tmp = lambda1 + math.atan2((math.sin(theta) * math.log1p(delta)), math.cos(delta))
	return tmp
function code(lambda1, phi1, phi2, delta, theta)
	tmp = 0.0
	if (delta <= -2.9e-9)
		tmp = Float64(lambda1 + atan(Float64(theta * sin(delta)), cos(delta)));
	else
		tmp = Float64(lambda1 + atan(Float64(sin(theta) * log1p(delta)), cos(delta)));
	end
	return tmp
end
code[lambda1_, phi1_, phi2_, delta_, theta_] := If[LessEqual[delta, -2.9e-9], N[(lambda1 + N[ArcTan[N[(theta * N[Sin[delta], $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * N[Log[1 + delta], $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;delta \leq -2.9 \cdot 10^{-9}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \sin delta}{\cos delta}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if delta < -2.89999999999999991e-9

    1. Initial program 99.8%

      \[\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)} \]
    2. Step-by-step derivation
      1. associate-*l*99.8%

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

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

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

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

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

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

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

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

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

    if -2.89999999999999991e-9 < 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. Step-by-step derivation
      1. associate-*l*99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 86.0% accurate, 3.2× speedup?

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

\\
\lambda_1 \cdot \left(1 + \frac{\tan^{-1}_* \frac{\sin theta \cdot \sin delta}{\cos delta}}{\lambda_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. Step-by-step derivation
    1. associate-*l*99.8%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 86.0% accurate, 3.3× speedup?

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

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

    \[\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)} \]
  2. Step-by-step derivation
    1. associate-*l*99.8%

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

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

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

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

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

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

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

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

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

Alternative 17: 80.3% accurate, 4.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;theta \leq -0.0016 \lor \neg \left(theta \leq 340000\right):\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{\cos delta}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{theta \cdot \sin delta}{\cos delta}\\ \end{array} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (if (or (<= theta -0.0016) (not (<= theta 340000.0)))
   (+ lambda1 (atan2 (* (sin theta) delta) (cos delta)))
   (+ lambda1 (atan2 (* theta (sin delta)) (cos delta)))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double tmp;
	if ((theta <= -0.0016) || !(theta <= 340000.0)) {
		tmp = lambda1 + atan2((sin(theta) * delta), cos(delta));
	} else {
		tmp = lambda1 + atan2((theta * sin(delta)), cos(delta));
	}
	return tmp;
}
real(8) function code(lambda1, phi1, phi2, delta, theta)
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8), intent (in) :: delta
    real(8), intent (in) :: theta
    real(8) :: tmp
    if ((theta <= (-0.0016d0)) .or. (.not. (theta <= 340000.0d0))) then
        tmp = lambda1 + atan2((sin(theta) * delta), cos(delta))
    else
        tmp = lambda1 + atan2((theta * sin(delta)), cos(delta))
    end if
    code = tmp
end function
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double tmp;
	if ((theta <= -0.0016) || !(theta <= 340000.0)) {
		tmp = lambda1 + Math.atan2((Math.sin(theta) * delta), Math.cos(delta));
	} else {
		tmp = lambda1 + Math.atan2((theta * Math.sin(delta)), Math.cos(delta));
	}
	return tmp;
}
def code(lambda1, phi1, phi2, delta, theta):
	tmp = 0
	if (theta <= -0.0016) or not (theta <= 340000.0):
		tmp = lambda1 + math.atan2((math.sin(theta) * delta), math.cos(delta))
	else:
		tmp = lambda1 + math.atan2((theta * math.sin(delta)), math.cos(delta))
	return tmp
function code(lambda1, phi1, phi2, delta, theta)
	tmp = 0.0
	if ((theta <= -0.0016) || !(theta <= 340000.0))
		tmp = Float64(lambda1 + atan(Float64(sin(theta) * delta), cos(delta)));
	else
		tmp = Float64(lambda1 + atan(Float64(theta * sin(delta)), cos(delta)));
	end
	return tmp
end
function tmp_2 = code(lambda1, phi1, phi2, delta, theta)
	tmp = 0.0;
	if ((theta <= -0.0016) || ~((theta <= 340000.0)))
		tmp = lambda1 + atan2((sin(theta) * delta), cos(delta));
	else
		tmp = lambda1 + atan2((theta * sin(delta)), cos(delta));
	end
	tmp_2 = tmp;
end
code[lambda1_, phi1_, phi2_, delta_, theta_] := If[Or[LessEqual[theta, -0.0016], N[Not[LessEqual[theta, 340000.0]], $MachinePrecision]], N[(lambda1 + N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * delta), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(theta * N[Sin[delta], $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;theta \leq -0.0016 \lor \neg \left(theta \leq 340000\right):\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{\cos delta}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if theta < -0.00160000000000000008 or 3.4e5 < theta

    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. Step-by-step derivation
      1. associate-*l*99.6%

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

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

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

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

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

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

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

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

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

    if -0.00160000000000000008 < theta < 3.4e5

    1. Initial program 99.9%

      \[\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)} \]
    2. Step-by-step derivation
      1. associate-*l*99.9%

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

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

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

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

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

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

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

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

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

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

Alternative 18: 73.0% accurate, 4.3× speedup?

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

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

    \[\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)} \]
  2. Step-by-step derivation
    1. associate-*l*99.8%

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

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

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

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

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

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

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

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

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

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

Alternative 19: 69.9% accurate, 1320.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. Step-by-step derivation
    1. associate-*l*99.8%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\lambda_1} \]
  8. Final simplification74.3%

    \[\leadsto \lambda_1 \]
  9. Add Preprocessing

Reproduce

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