Destination given bearing on a great circle

Percentage Accurate: 99.8% → 99.8%
Time: 23.6s
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.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(\left(\sin delta \cdot \cos \phi_1\right) \cdot \cos theta + \cos delta \cdot \sin \phi_1\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 delta) (cos phi1)) (cos theta))
        (* (cos delta) (sin phi1))))))))))
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(delta) * cos(phi1)) * cos(theta)) + (cos(delta) * sin(phi1))))))));
}
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(delta) * cos(phi1)) * cos(theta)) + (cos(delta) * sin(phi1))))))))
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(delta) * Math.cos(phi1)) * Math.cos(theta)) + (Math.cos(delta) * Math.sin(phi1))))))));
}
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(delta) * math.cos(phi1)) * math.cos(theta)) + (math.cos(delta) * math.sin(phi1))))))))
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(Float64(sin(delta) * cos(phi1)) * cos(theta)) + Float64(cos(delta) * sin(phi1)))))))))
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(delta) * cos(phi1)) * cos(theta)) + (cos(delta) * sin(phi1))))))));
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[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[theta], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $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(\left(\sin delta \cdot \cos \phi_1\right) \cdot \cos theta + \cos delta \cdot \sin \phi_1\right)}
\end{array}
Derivation
  1. Initial program 99.8%

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

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

Alternative 2: 99.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\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
   (* (* (sin theta) (sin delta)) (cos phi1))
   (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(((sin(theta) * sin(delta)) * cos(phi1)), 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(Float64(sin(theta) * sin(delta)) * cos(phi1)), 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[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $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{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\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. 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(\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)} \]
  5. Step-by-step derivation
    1. sin-asin99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 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. +-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 \sin \sin^{-1} \color{blue}{\left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos \left(-theta\right) + \sin \phi_1 \cdot \cos delta\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(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in delta around inf 99.7%

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

    \[\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 5: 99.8% accurate, 1.2× 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 \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(Float64(sin(theta) * 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[(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[(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{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\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. 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 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(\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)} \]
  5. Taylor expanded in delta around inf 99.8%

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

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\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: 94.7% 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(t\_1 + \cos delta \cdot \sin \phi_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) (+ t_1 (* (cos delta) (sin phi1)))))))))
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) * (t_1 + (cos(delta) * sin(phi1))))));
}
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) * (t_1 + (cos(delta) * sin(phi1))))))
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) * (t_1 + (Math.cos(delta) * Math.sin(phi1))))));
}
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) * (t_1 + (math.cos(delta) * math.sin(phi1))))))
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(t_1 + Float64(cos(delta) * sin(phi1)))))))
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) * (t_1 + (cos(delta) * sin(phi1))))));
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[(t$95$1 + N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $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(t\_1 + \cos delta \cdot \sin \phi_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. +-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 \sin \sin^{-1} \color{blue}{\left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos \left(-theta\right) + \sin \phi_1 \cdot \cos delta\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(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in theta around 0 92.6%

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

    \[\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 delta \cdot \cos \phi_1 + \cos delta \cdot \sin \phi_1\right)} \]
  7. Add Preprocessing

Alternative 7: 94.7% accurate, 1.3× 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 \left(\sin delta \cdot \cos \phi_1 + \cos delta \cdot \sin \phi_1\right)} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (+
  lambda1
  (atan2
   (* (* (sin theta) (sin delta)) (cos phi1))
   (-
    (cos delta)
    (*
     (sin phi1)
     (+ (* (sin delta) (cos phi1)) (* (cos delta) (sin phi1))))))))
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(delta) * cos(phi1)) + (cos(delta) * sin(phi1))))));
}
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(delta) * cos(phi1)) + (cos(delta) * sin(phi1))))))
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(delta) * Math.cos(phi1)) + (Math.cos(delta) * Math.sin(phi1))))));
}
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(delta) * math.cos(phi1)) + (math.cos(delta) * math.sin(phi1))))))
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) * Float64(Float64(sin(delta) * cos(phi1)) + Float64(cos(delta) * sin(phi1)))))))
end
function tmp = code(lambda1, phi1, phi2, delta, theta)
	tmp = lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * ((sin(delta) * cos(phi1)) + (cos(delta) * sin(phi1))))));
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[(N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[delta], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\sqrt[3]{{\color{blue}{\left(\sin delta \cdot \sin theta\right)}}^{3}} \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)} \]
  4. Applied egg-rr94.3%

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\color{blue}{\sqrt[3]{{\left(\sin delta \cdot \sin theta\right)}^{3}}} \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)} \]
  5. Taylor expanded in theta around 0 87.1%

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

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

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

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

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

Alternative 8: 92.8% accurate, 1.4× 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 \left(\sin \phi_1 + \sin delta \cdot \cos \phi_1\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) (* (sin delta) (cos phi1))))))))
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) + (sin(delta) * cos(phi1))))));
}
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) + (sin(delta) * cos(phi1))))))
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.sin(delta) * Math.cos(phi1))))));
}
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.sin(delta) * math.cos(phi1))))))
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) * Float64(sin(phi1) + Float64(sin(delta) * cos(phi1)))))))
end
function tmp = code(lambda1, phi1, phi2, delta, theta)
	tmp = lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * (sin(phi1) + (sin(delta) * cos(phi1))))));
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[(N[Sin[phi1], $MachinePrecision] + N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $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 \left(\sin \phi_1 + \sin delta \cdot \cos \phi_1\right)}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)} \]
  2. 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 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(\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)} \]
  5. Step-by-step derivation
    1. sin-asin99.8%

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

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

    \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\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) + \color{blue}{\sin \phi_1}, -\sin \phi_1, \cos delta\right)} \]
  8. Taylor expanded in theta around 0 91.5%

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

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

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

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

Alternative 9: 91.9% accurate, 1.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if delta < -5.4999999999999999e-6

    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. +-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 \sin \sin^{-1} \color{blue}{\left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos \left(-theta\right) + \sin \phi_1 \cdot \cos delta\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(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in phi1 around 0 85.9%

      \[\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 lambda1 around inf 86.0%

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

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

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

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

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

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

    if -5.4999999999999999e-6 < delta < 1.1e-32

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

      \[\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 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(\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)} \]
    5. Step-by-step derivation
      1. sin-asin99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.1e-32 < 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. +-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 \sin \sin^{-1} \color{blue}{\left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos \left(-theta\right) + \sin \phi_1 \cdot \cos delta\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(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in phi1 around 0 85.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. log1p-expm1-u85.6%

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

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

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

Alternative 10: 92.5% 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. +-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 \sin \sin^{-1} \color{blue}{\left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos \left(-theta\right) + \sin \phi_1 \cdot \cos delta\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(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in delta around 0 91.0%

    \[\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 simplification91.0%

    \[\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 11: 91.9% accurate, 2.5× speedup?

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

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

\mathbf{elif}\;delta \leq 1.1 \cdot 10^{-32}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\frac{1 + \cos \left(\phi_1 \cdot 2\right)}{2}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if delta < -4.0999999999999999e-7

    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. +-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 \sin \sin^{-1} \color{blue}{\left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos \left(-theta\right) + \sin \phi_1 \cdot \cos delta\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(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in phi1 around 0 85.9%

      \[\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 lambda1 around inf 86.0%

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

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

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

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

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

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

    if -4.0999999999999999e-7 < delta < 1.1e-32

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

      \[\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 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(\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)} \]
    5. Step-by-step derivation
      1. sin-asin99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.1e-32 < 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. +-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 \sin \sin^{-1} \color{blue}{\left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos \left(-theta\right) + \sin \phi_1 \cdot \cos delta\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(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in phi1 around 0 85.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 theta around 0 85.6%

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

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

Alternative 12: 91.9% accurate, 2.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if delta < -9.20000000000000001e-5 or 1.1e-32 < 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. +-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 \sin \sin^{-1} \color{blue}{\left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos \left(-theta\right) + \sin \phi_1 \cdot \cos delta\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(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in phi1 around 0 85.7%

      \[\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 theta around 0 85.7%

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

    if -9.20000000000000001e-5 < delta < 1.1e-32

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

      \[\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 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(\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)} \]
    5. Step-by-step derivation
      1. sin-asin99.8%

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

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

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

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

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

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

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

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

Alternative 13: 91.9% accurate, 2.5× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if delta < -2.79999999999999996e-5

    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. +-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 \sin \sin^{-1} \color{blue}{\left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos \left(-theta\right) + \sin \phi_1 \cdot \cos delta\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(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in phi1 around 0 85.9%

      \[\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 lambda1 around inf 86.0%

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

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

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

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

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

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

    if -2.79999999999999996e-5 < delta < 1.1e-32

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

      \[\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 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(\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)} \]
    5. Step-by-step derivation
      1. sin-asin99.8%

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

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

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

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

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

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

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

    if 1.1e-32 < 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. +-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 \sin \sin^{-1} \color{blue}{\left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos \left(-theta\right) + \sin \phi_1 \cdot \cos delta\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(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in phi1 around 0 85.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 theta around 0 85.6%

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

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

Alternative 14: 88.9% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\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(Float64(sin(theta) * 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[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\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. +-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 \sin \sin^{-1} \color{blue}{\left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos \left(-theta\right) + \sin \phi_1 \cdot \cos delta\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(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in phi1 around 0 86.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 theta around 0 86.6%

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

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

Alternative 15: 86.6% 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. +-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 \sin \sin^{-1} \color{blue}{\left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos \left(-theta\right) + \sin \phi_1 \cdot \cos delta\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(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in phi1 around 0 86.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 84.2%

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

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

Alternative 16: 72.8% accurate, 4.2× speedup?

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

\\
\lambda_1 + \tan^{-1}_* \frac{\sin theta \cdot delta}{1 - delta \cdot \left(\phi_1 \cdot \cos theta\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 79.4%

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

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

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

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

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

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

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

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

Alternative 17: 73.5% accurate, 4.3× speedup?

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

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

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

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

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

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

Alternative 18: 73.2% accurate, 6.4× speedup?

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

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

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

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

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

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

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

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

Alternative 19: 70.1% 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. +-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 \sin \sin^{-1} \color{blue}{\left(\left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos \left(-theta\right) + \sin \phi_1 \cdot \cos delta\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(\cos \phi_1, \sin delta \cdot \cos theta, \cos delta \cdot \sin \phi_1\right)\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in phi1 around 0 86.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 lambda1 around inf 67.9%

    \[\leadsto \color{blue}{\lambda_1} \]
  7. Final simplification67.9%

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

Reproduce

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