Destination given bearing on a great circle

Percentage Accurate: 99.8% → 99.8%
Time: 20.0s
Alternatives: 2
Speedup: N/A×

Specification

?
\[\begin{array}{l} \\ \lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (+
  lambda1
  (atan2
   (* (* (sin theta) (sin delta)) (cos phi1))
   (-
    (cos delta)
    (*
     (sin phi1)
     (sin
      (asin
       (+
        (* (sin phi1) (cos delta))
        (* (* (cos phi1) (sin delta)) (cos theta))))))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	return lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(lambda1, phi1, phi2, delta, theta)
use fmin_fmax_functions
    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 2 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))))))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(lambda1, phi1, phi2, delta, theta)
use fmin_fmax_functions
    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, N/A× speedup?

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

\\
\begin{array}{l}
t_1 := {\cos delta}^{2}\\
t_2 := -1 \cdot t\_1\\
t_3 := \cos \phi_1 \cdot \sin delta\\
t_4 := \sin \phi_1 \cdot \mathsf{fma}\left(\sin \phi_1, \cos delta, t\_3 \cdot \cos theta\right)\\
t_5 := \mathsf{fma}\left(t\_4, t\_4, \cos delta \cdot t\_4\right)\\
\lambda_1 + \tan^{-1}_* \frac{t\_3 \cdot \sin theta}{\frac{t\_1 \cdot \cos delta - {t\_4}^{3}}{\frac{\mathsf{fma}\left({t\_1}^{2}, t\_1, {t\_5}^{3}\right)}{\mathsf{fma}\left(t\_2, t\_2, t\_5 \cdot t\_5 - t\_1 \cdot t\_5\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. Add Preprocessing
  3. Step-by-step derivation
    1. lift-*.f64N/A

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

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

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\color{blue}{\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)} \]
    4. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \cos \phi_1 \cdot \sin delta\\ \lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot \sin theta}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + t\_1 \cdot \cos theta\right)} \end{array} \end{array} \]
(FPCore (lambda1 phi1 phi2 delta theta)
 :precision binary64
 (let* ((t_1 (* (cos phi1) (sin delta))))
   (+
    lambda1
    (atan2
     (* t_1 (sin theta))
     (-
      (cos delta)
      (*
       (sin phi1)
       (sin (asin (+ (* (sin phi1) (cos delta)) (* t_1 (cos theta)))))))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double t_1 = cos(phi1) * sin(delta);
	return lambda1 + atan2((t_1 * sin(theta)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + (t_1 * cos(theta))))))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(lambda1, phi1, phi2, delta, theta)
use fmin_fmax_functions
    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 = cos(phi1) * sin(delta)
    code = lambda1 + atan2((t_1 * sin(theta)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + (t_1 * cos(theta))))))))
end function
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
	double t_1 = Math.cos(phi1) * Math.sin(delta);
	return lambda1 + Math.atan2((t_1 * Math.sin(theta)), (Math.cos(delta) - (Math.sin(phi1) * Math.sin(Math.asin(((Math.sin(phi1) * Math.cos(delta)) + (t_1 * Math.cos(theta))))))));
}
def code(lambda1, phi1, phi2, delta, theta):
	t_1 = math.cos(phi1) * math.sin(delta)
	return lambda1 + math.atan2((t_1 * math.sin(theta)), (math.cos(delta) - (math.sin(phi1) * math.sin(math.asin(((math.sin(phi1) * math.cos(delta)) + (t_1 * math.cos(theta))))))))
function code(lambda1, phi1, phi2, delta, theta)
	t_1 = Float64(cos(phi1) * sin(delta))
	return Float64(lambda1 + atan(Float64(t_1 * sin(theta)), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(sin(phi1) * cos(delta)) + Float64(t_1 * cos(theta)))))))))
end
function tmp = code(lambda1, phi1, phi2, delta, theta)
	t_1 = cos(phi1) * sin(delta);
	tmp = lambda1 + atan2((t_1 * sin(theta)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + (t_1 * cos(theta))))))));
end
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(t$95$1 * N[Sin[theta], $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[(t$95$1 * N[Cos[theta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \cos \phi_1 \cdot \sin delta\\
\lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot \sin theta}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + t\_1 \cdot \cos theta\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. Add Preprocessing
  3. Step-by-step derivation
    1. lift-*.f64N/A

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

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

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\left(\color{blue}{\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)} \]
    4. lift-sin.f64N/A

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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