Bearing on a great circle

Percentage Accurate: 79.1% → 99.7%
Time: 17.9s
Alternatives: 38
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (atan2
  (* (sin (- lambda1 lambda2)) (cos phi2))
  (-
   (* (cos phi1) (sin phi2))
   (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
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, lambda2, phi1, phi2)
use fmin_fmax_functions
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2):
	return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2)
	return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))
end
function tmp = code(lambda1, lambda2, phi1, phi2)
	tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

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

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 38 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: 79.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (atan2
  (* (sin (- lambda1 lambda2)) (cos phi2))
  (-
   (* (cos phi1) (sin phi2))
   (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
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, lambda2, phi1, phi2)
use fmin_fmax_functions
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2):
	return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2)
	return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))
end
function tmp = code(lambda1, lambda2, phi1, phi2)
	tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.7% accurate, 0.6× speedup?

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

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

    \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  2. Step-by-step derivation
    1. lift--.f64N/A

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

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. sin-diffN/A

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

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    5. mul-1-negN/A

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

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    7. mul-1-negN/A

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    8. lower-*.f64N/A

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    9. lower-sin.f64N/A

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    10. cos-negN/A

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

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

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

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    14. lower-sin.f6489.6

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  3. Applied rewrites89.6%

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

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

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \color{blue}{\cos \left(\lambda_1 - \lambda_2\right)}} \]
    3. cos-diffN/A

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

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

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

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

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

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \color{blue}{\sin \lambda_1} \cdot \sin \lambda_2\right)} \]
    9. lift-sin.f6499.7

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

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

Alternative 2: 94.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\ t_1 := \cos \phi_1 \cdot \sin \phi_2\\ t_2 := t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\ t_3 := \sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\\ \mathbf{if}\;\phi_2 \leq -0.0024:\\ \;\;\;\;\tan^{-1}_* \frac{t\_3 \cdot \cos \phi_2}{t\_2}\\ \mathbf{elif}\;\phi_2 \leq 0.001:\\ \;\;\;\;\tan^{-1}_* \frac{t\_3 \cdot t\_0}{t\_1 - \left(\sin \phi_1 \cdot t\_0\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_2}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (fma (* phi2 phi2) -0.5 1.0))
        (t_1 (* (cos phi1) (sin phi2)))
        (t_2 (- t_1 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
        (t_3
         (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))))
   (if (<= phi2 -0.0024)
     (atan2 (* t_3 (cos phi2)) t_2)
     (if (<= phi2 0.001)
       (atan2
        (* t_3 t_0)
        (-
         t_1
         (*
          (* (sin phi1) t_0)
          (fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
       (atan2
        (*
         (fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
         (cos phi2))
        t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = fma((phi2 * phi2), -0.5, 1.0);
	double t_1 = cos(phi1) * sin(phi2);
	double t_2 = t_1 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)));
	double t_3 = (sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2));
	double tmp;
	if (phi2 <= -0.0024) {
		tmp = atan2((t_3 * cos(phi2)), t_2);
	} else if (phi2 <= 0.001) {
		tmp = atan2((t_3 * t_0), (t_1 - ((sin(phi1) * t_0) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
	} else {
		tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), t_2);
	}
	return tmp;
}
function code(lambda1, lambda2, phi1, phi2)
	t_0 = fma(Float64(phi2 * phi2), -0.5, 1.0)
	t_1 = Float64(cos(phi1) * sin(phi2))
	t_2 = Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))
	t_3 = Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))
	tmp = 0.0
	if (phi2 <= -0.0024)
		tmp = atan(Float64(t_3 * cos(phi2)), t_2);
	elseif (phi2 <= 0.001)
		tmp = atan(Float64(t_3 * t_0), Float64(t_1 - Float64(Float64(sin(phi1) * t_0) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))));
	else
		tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), t_2);
	end
	return tmp
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.0024], N[ArcTan[N[(t$95$3 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi2, 0.001], N[ArcTan[N[(t$95$3 * t$95$0), $MachinePrecision] / N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_3 := \sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_2 \leq -0.0024:\\
\;\;\;\;\tan^{-1}_* \frac{t\_3 \cdot \cos \phi_2}{t\_2}\\

\mathbf{elif}\;\phi_2 \leq 0.001:\\
\;\;\;\;\tan^{-1}_* \frac{t\_3 \cdot t\_0}{t\_1 - \left(\sin \phi_1 \cdot t\_0\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\

\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if phi2 < -0.00239999999999999979

    1. Initial program 76.2%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6490.0

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. Applied rewrites90.0%

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

    if -0.00239999999999999979 < phi2 < 1e-3

    1. Initial program 81.6%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6489.4

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. Applied rewrites89.4%

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \color{blue}{\cos \left(\lambda_1 - \lambda_2\right)}} \]
      3. cos-diffN/A

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \color{blue}{\sin \lambda_1} \cdot \sin \lambda_2\right)} \]
      9. lift-sin.f6499.9

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
      5. lower-*.f6499.9

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
    8. Applied rewrites99.9%

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right)\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
      5. lower-*.f6499.9

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
    11. Applied rewrites99.9%

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \color{blue}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)} \]

    if 1e-3 < phi2

    1. Initial program 77.1%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6489.7

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

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. fp-cancel-sub-sign-invN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \color{blue}{\cos \lambda_2}, \left(\mathsf{neg}\left(\cos \lambda_1\right)\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      12. mul-1-negN/A

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\color{blue}{\cos \lambda_1}\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      17. lift-sin.f6489.7

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    5. Applied rewrites89.7%

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 89.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_1 \cdot \sin \phi_2\\ t_1 := \sin \phi_1 \cdot \cos \phi_2\\ t_2 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\ \mathbf{if}\;\lambda_2 \leq -2.1 \cdot 10^{-11}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;\lambda_2 \leq 8.4 \cdot 10^{+40}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* (cos phi1) (sin phi2)))
        (t_1 (* (sin phi1) (cos phi2)))
        (t_2
         (atan2
          (*
           (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
           (cos phi2))
          (- t_0 (* t_1 (cos lambda2))))))
   (if (<= lambda2 -2.1e-11)
     t_2
     (if (<= lambda2 8.4e+40)
       (atan2
        (* (sin (- lambda1 lambda2)) (cos phi2))
        (-
         t_0
         (*
          t_1
          (fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
       t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos(phi1) * sin(phi2);
	double t_1 = sin(phi1) * cos(phi2);
	double t_2 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))));
	double tmp;
	if (lambda2 <= -2.1e-11) {
		tmp = t_2;
	} else if (lambda2 <= 8.4e+40) {
		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(lambda1, lambda2, phi1, phi2)
	t_0 = Float64(cos(phi1) * sin(phi2))
	t_1 = Float64(sin(phi1) * cos(phi2))
	t_2 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda2))))
	tmp = 0.0
	if (lambda2 <= -2.1e-11)
		tmp = t_2;
	elseif (lambda2 <= 8.4e+40)
		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_1 * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))));
	else
		tmp = t_2;
	end
	return tmp
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -2.1e-11], t$95$2, If[LessEqual[lambda2, 8.4e+40], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
t_2 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{if}\;\lambda_2 \leq -2.1 \cdot 10^{-11}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;\lambda_2 \leq 8.4 \cdot 10^{+40}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if lambda2 < -2.0999999999999999e-11 or 8.4000000000000004e40 < lambda2

    1. Initial program 60.1%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6480.4

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. Applied rewrites80.4%

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    4. Taylor expanded in lambda1 around 0

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}} \]
    5. Step-by-step derivation
      1. cos-neg-revN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2} \]
      2. lift-cos.f6480.2

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2} \]
    6. Applied rewrites80.2%

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

    if -2.0999999999999999e-11 < lambda2 < 8.4000000000000004e40

    1. Initial program 96.8%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \color{blue}{\cos \left(\lambda_1 - \lambda_2\right)}} \]
      3. cos-diffN/A

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \color{blue}{\sin \lambda_1} \cdot \sin \lambda_2\right)} \]
      11. lower-sin.f6496.8

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right)} \]
    3. Applied rewrites96.8%

      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \color{blue}{\mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 89.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_1 \cdot \sin \phi_2\\ t_1 := \sin \phi_1 \cdot \cos \phi_2\\ t_2 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\ \mathbf{if}\;\lambda_2 \leq -2.1 \cdot 10^{-11}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;\lambda_2 \leq 6 \cdot 10^{-7}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \mathsf{fma}\left(\sin \lambda_1, \lambda_2, \cos \lambda_1\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* (cos phi1) (sin phi2)))
        (t_1 (* (sin phi1) (cos phi2)))
        (t_2
         (atan2
          (*
           (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
           (cos phi2))
          (- t_0 (* t_1 (cos lambda2))))))
   (if (<= lambda2 -2.1e-11)
     t_2
     (if (<= lambda2 6e-7)
       (atan2
        (* (sin (- lambda1 lambda2)) (cos phi2))
        (- t_0 (* t_1 (fma (sin lambda1) lambda2 (cos lambda1)))))
       t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos(phi1) * sin(phi2);
	double t_1 = sin(phi1) * cos(phi2);
	double t_2 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))));
	double tmp;
	if (lambda2 <= -2.1e-11) {
		tmp = t_2;
	} else if (lambda2 <= 6e-7) {
		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * fma(sin(lambda1), lambda2, cos(lambda1)))));
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(lambda1, lambda2, phi1, phi2)
	t_0 = Float64(cos(phi1) * sin(phi2))
	t_1 = Float64(sin(phi1) * cos(phi2))
	t_2 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda2))))
	tmp = 0.0
	if (lambda2 <= -2.1e-11)
		tmp = t_2;
	elseif (lambda2 <= 6e-7)
		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_1 * fma(sin(lambda1), lambda2, cos(lambda1)))));
	else
		tmp = t_2;
	end
	return tmp
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -2.1e-11], t$95$2, If[LessEqual[lambda2, 6e-7], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Sin[lambda1], $MachinePrecision] * lambda2 + N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
t_2 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{if}\;\lambda_2 \leq -2.1 \cdot 10^{-11}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;\lambda_2 \leq 6 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \mathsf{fma}\left(\sin \lambda_1, \lambda_2, \cos \lambda_1\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if lambda2 < -2.0999999999999999e-11 or 5.9999999999999997e-7 < lambda2

    1. Initial program 60.0%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6480.3

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. Applied rewrites80.3%

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    4. Taylor expanded in lambda1 around 0

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)}} \]
    5. Step-by-step derivation
      1. cos-neg-revN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2} \]
      2. lift-cos.f6480.0

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2} \]
    6. Applied rewrites80.0%

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

    if -2.0999999999999999e-11 < lambda2 < 5.9999999999999997e-7

    1. Initial program 99.6%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Taylor expanded in lambda2 around 0

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\sin \lambda_1, \lambda_2, \cos \lambda_1\right)} \]
      5. lower-cos.f6499.6

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\sin \lambda_1, \lambda_2, \cos \lambda_1\right)} \]
    4. Applied rewrites99.6%

      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \lambda_1, \lambda_2, \cos \lambda_1\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 89.5% accurate, 0.7× speedup?

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

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

    \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  2. Step-by-step derivation
    1. lift--.f64N/A

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

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. sin-diffN/A

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

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    5. mul-1-negN/A

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

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    7. mul-1-negN/A

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    8. lower-*.f64N/A

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    9. lower-sin.f64N/A

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    10. cos-negN/A

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

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

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

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    14. lower-sin.f6489.6

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  3. Applied rewrites89.6%

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

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

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

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

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

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

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

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    8. fp-cancel-sub-sign-invN/A

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

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

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

      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \color{blue}{\cos \lambda_2}, \left(\mathsf{neg}\left(\cos \lambda_1\right)\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    12. mul-1-negN/A

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

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

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

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

      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\color{blue}{\cos \lambda_1}\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    17. lift-sin.f6489.6

      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  5. Applied rewrites89.6%

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

Alternative 6: 88.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (atan2
  (*
   (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
   (cos phi2))
  (-
   (* (cos phi1) (sin phi2))
   (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
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, lambda2, phi1, phi2)
use fmin_fmax_functions
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2):
	return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2)
	return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))
end
function tmp = code(lambda1, lambda2, phi1, phi2)
	tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Derivation
  1. Initial program 79.1%

    \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  2. Step-by-step derivation
    1. lift--.f64N/A

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

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. sin-diffN/A

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

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    5. mul-1-negN/A

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

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    7. mul-1-negN/A

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    8. lower-*.f64N/A

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    9. lower-sin.f64N/A

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    10. cos-negN/A

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

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

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

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    14. lower-sin.f6489.6

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  3. Applied rewrites89.6%

    \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  4. Add Preprocessing

Alternative 7: 88.5% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_1 \cdot \sin \phi_2\\ t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\ t_2 := \tan^{-1}_* \frac{\left(\sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\ \mathbf{if}\;\phi_1 \leq -20:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;\phi_1 \leq 19:\\ \;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \sin \phi_1 \cdot t\_1}\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* (cos phi1) (sin phi2)))
        (t_1 (cos (- lambda1 lambda2)))
        (t_2
         (atan2
          (* (- (sin lambda1) (* (cos lambda1) (sin lambda2))) (cos phi2))
          (- t_0 (* (* (sin phi1) (cos phi2)) t_1)))))
   (if (<= phi1 -20.0)
     t_2
     (if (<= phi1 19.0)
       (atan2
        (*
         (fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
         (cos phi2))
        (- t_0 (* (sin phi1) t_1)))
       t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos(phi1) * sin(phi2);
	double t_1 = cos((lambda1 - lambda2));
	double t_2 = atan2(((sin(lambda1) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * t_1)));
	double tmp;
	if (phi1 <= -20.0) {
		tmp = t_2;
	} else if (phi1 <= 19.0) {
		tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (sin(phi1) * t_1)));
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(lambda1, lambda2, phi1, phi2)
	t_0 = Float64(cos(phi1) * sin(phi2))
	t_1 = cos(Float64(lambda1 - lambda2))
	t_2 = atan(Float64(Float64(sin(lambda1) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_1)))
	tmp = 0.0
	if (phi1 <= -20.0)
		tmp = t_2;
	elseif (phi1 <= 19.0)
		tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(sin(phi1) * t_1)));
	else
		tmp = t_2;
	end
	return tmp
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -20.0], t$95$2, If[LessEqual[phi1, 19.0], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \tan^{-1}_* \frac{\left(\sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\
\mathbf{if}\;\phi_1 \leq -20:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;\phi_1 \leq 19:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \sin \phi_1 \cdot t\_1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi1 < -20 or 19 < phi1

    1. Initial program 76.7%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6479.6

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

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    4. Taylor expanded in lambda2 around 0

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    5. Step-by-step derivation
      1. lift-sin.f6477.7

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    6. Applied rewrites77.7%

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

    if -20 < phi1 < 19

    1. Initial program 81.4%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6499.2

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. Applied rewrites99.2%

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \color{blue}{\cos \left(\lambda_1 - \lambda_2\right)}} \]
      3. cos-diffN/A

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \color{blue}{\sin \lambda_1} \cdot \sin \lambda_2\right)} \]
      9. lift-sin.f6499.8

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

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
      8. fp-cancel-sub-sign-invN/A

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \color{blue}{\left(-\cos \lambda_1\right)} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
      14. lift-cos.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\color{blue}{\cos \lambda_1}\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
      15. lift-sin.f6499.8

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

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

      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\sin \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}} \]
    9. Step-by-step derivation
      1. cos-diff-revN/A

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
      2. sin-+PI/2-revN/A

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
      3. cos-diff-revN/A

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      4. lower-*.f64N/A

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

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

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. lift--.f6498.7

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    10. Applied rewrites98.7%

      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 88.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_1 \cdot \sin \phi_2\\ t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\ t_2 := \cos \lambda_1 \cdot \sin \lambda_2\\ t_3 := \tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_2\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\ \mathbf{if}\;\phi_1 \leq -20:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;\phi_1 \leq 19:\\ \;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_2\right) \cdot \cos \phi_2}{t\_0 - \sin \phi_1 \cdot t\_1}\\ \mathbf{else}:\\ \;\;\;\;t\_3\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* (cos phi1) (sin phi2)))
        (t_1 (cos (- lambda1 lambda2)))
        (t_2 (* (cos lambda1) (sin lambda2)))
        (t_3
         (atan2
          (* (- (sin lambda1) t_2) (cos phi2))
          (- t_0 (* (* (sin phi1) (cos phi2)) t_1)))))
   (if (<= phi1 -20.0)
     t_3
     (if (<= phi1 19.0)
       (atan2
        (* (- (* (sin lambda1) (cos lambda2)) t_2) (cos phi2))
        (- t_0 (* (sin phi1) t_1)))
       t_3))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos(phi1) * sin(phi2);
	double t_1 = cos((lambda1 - lambda2));
	double t_2 = cos(lambda1) * sin(lambda2);
	double t_3 = atan2(((sin(lambda1) - t_2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * t_1)));
	double tmp;
	if (phi1 <= -20.0) {
		tmp = t_3;
	} else if (phi1 <= 19.0) {
		tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), (t_0 - (sin(phi1) * t_1)));
	} else {
		tmp = t_3;
	}
	return tmp;
}
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, lambda2, phi1, phi2)
use fmin_fmax_functions
    real(8), intent (in) :: lambda1
    real(8), intent (in) :: lambda2
    real(8), intent (in) :: phi1
    real(8), intent (in) :: phi2
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = cos(phi1) * sin(phi2)
    t_1 = cos((lambda1 - lambda2))
    t_2 = cos(lambda1) * sin(lambda2)
    t_3 = atan2(((sin(lambda1) - t_2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * t_1)))
    if (phi1 <= (-20.0d0)) then
        tmp = t_3
    else if (phi1 <= 19.0d0) then
        tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), (t_0 - (sin(phi1) * t_1)))
    else
        tmp = t_3
    end if
    code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = Math.cos(phi1) * Math.sin(phi2);
	double t_1 = Math.cos((lambda1 - lambda2));
	double t_2 = Math.cos(lambda1) * Math.sin(lambda2);
	double t_3 = Math.atan2(((Math.sin(lambda1) - t_2) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * t_1)));
	double tmp;
	if (phi1 <= -20.0) {
		tmp = t_3;
	} else if (phi1 <= 19.0) {
		tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - t_2) * Math.cos(phi2)), (t_0 - (Math.sin(phi1) * t_1)));
	} else {
		tmp = t_3;
	}
	return tmp;
}
def code(lambda1, lambda2, phi1, phi2):
	t_0 = math.cos(phi1) * math.sin(phi2)
	t_1 = math.cos((lambda1 - lambda2))
	t_2 = math.cos(lambda1) * math.sin(lambda2)
	t_3 = math.atan2(((math.sin(lambda1) - t_2) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * t_1)))
	tmp = 0
	if phi1 <= -20.0:
		tmp = t_3
	elif phi1 <= 19.0:
		tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - t_2) * math.cos(phi2)), (t_0 - (math.sin(phi1) * t_1)))
	else:
		tmp = t_3
	return tmp
function code(lambda1, lambda2, phi1, phi2)
	t_0 = Float64(cos(phi1) * sin(phi2))
	t_1 = cos(Float64(lambda1 - lambda2))
	t_2 = Float64(cos(lambda1) * sin(lambda2))
	t_3 = atan(Float64(Float64(sin(lambda1) - t_2) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_1)))
	tmp = 0.0
	if (phi1 <= -20.0)
		tmp = t_3;
	elseif (phi1 <= 19.0)
		tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), Float64(t_0 - Float64(sin(phi1) * t_1)));
	else
		tmp = t_3;
	end
	return tmp
end
function tmp_2 = code(lambda1, lambda2, phi1, phi2)
	t_0 = cos(phi1) * sin(phi2);
	t_1 = cos((lambda1 - lambda2));
	t_2 = cos(lambda1) * sin(lambda2);
	t_3 = atan2(((sin(lambda1) - t_2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * t_1)));
	tmp = 0.0;
	if (phi1 <= -20.0)
		tmp = t_3;
	elseif (phi1 <= 19.0)
		tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), (t_0 - (sin(phi1) * t_1)));
	else
		tmp = t_3;
	end
	tmp_2 = tmp;
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$2), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -20.0], t$95$3, If[LessEqual[phi1, 19.0], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_3 := \tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_2\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\
\mathbf{if}\;\phi_1 \leq -20:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;\phi_1 \leq 19:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_2\right) \cdot \cos \phi_2}{t\_0 - \sin \phi_1 \cdot t\_1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi1 < -20 or 19 < phi1

    1. Initial program 76.7%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6479.6

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

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    4. Taylor expanded in lambda2 around 0

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    5. Step-by-step derivation
      1. lift-sin.f6477.7

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    6. Applied rewrites77.7%

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

    if -20 < phi1 < 19

    1. Initial program 81.4%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6499.2

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. Applied rewrites99.2%

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    4. Taylor expanded in phi2 around 0

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\sin \phi_1} \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    5. Step-by-step derivation
      1. lift-sin.f6498.7

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    6. Applied rewrites98.7%

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\sin \phi_1} \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 88.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\ t_1 := \tan^{-1}_* \frac{\left(\sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\ \mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-5}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\phi_1 \leq 19:\\ \;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - 1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (cos (- lambda1 lambda2)))
        (t_1
         (atan2
          (* (- (sin lambda1) (* (cos lambda1) (sin lambda2))) (cos phi2))
          (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))))
   (if (<= phi1 -1.55e-5)
     t_1
     (if (<= phi1 19.0)
       (atan2
        (*
         (fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
         (cos phi2))
        (- (sin phi2) (* 1.0 (* phi1 (* (cos phi2) t_0)))))
       t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos((lambda1 - lambda2));
	double t_1 = atan2(((sin(lambda1) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)));
	double tmp;
	if (phi1 <= -1.55e-5) {
		tmp = t_1;
	} else if (phi1 <= 19.0) {
		tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (1.0 * (phi1 * (cos(phi2) * t_0)))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(lambda1, lambda2, phi1, phi2)
	t_0 = cos(Float64(lambda1 - lambda2))
	t_1 = atan(Float64(Float64(sin(lambda1) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0)))
	tmp = 0.0
	if (phi1 <= -1.55e-5)
		tmp = t_1;
	elseif (phi1 <= 19.0)
		tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(1.0 * Float64(phi1 * Float64(cos(phi2) * t_0)))));
	else
		tmp = t_1;
	end
	return tmp
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.55e-5], t$95$1, If[LessEqual[phi1, 19.0], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(1.0 * N[(phi1 * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{\left(\sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-5}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;\phi_1 \leq 19:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - 1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi1 < -1.55000000000000007e-5 or 19 < phi1

    1. Initial program 76.7%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6479.6

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

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    4. Taylor expanded in lambda2 around 0

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    5. Step-by-step derivation
      1. lift-sin.f6477.7

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    6. Applied rewrites77.7%

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

    if -1.55000000000000007e-5 < phi1 < 19

    1. Initial program 81.5%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6499.4

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. Applied rewrites99.4%

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \color{blue}{\cos \left(\lambda_1 - \lambda_2\right)}} \]
      3. cos-diffN/A

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \color{blue}{\sin \lambda_1} \cdot \sin \lambda_2\right)} \]
      9. lift-sin.f6499.8

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

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
      8. fp-cancel-sub-sign-invN/A

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \color{blue}{\left(-\cos \lambda_1\right)} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
      14. lift-cos.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\color{blue}{\cos \lambda_1}\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
      15. lift-sin.f6499.8

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

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

      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2 + -1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)}} \]
    9. Step-by-step derivation
      1. cos-diff-revN/A

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 + -1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)} \]
      2. sin-+PI/2-revN/A

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 + -1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right) \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)}} \]
      4. cos-diff-revN/A

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\mathsf{neg}\left(-1\right)\right) \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)} \]
      5. lower--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)} \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)} \]
    10. Applied rewrites99.1%

      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2 - 1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 88.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \phi_1 \cdot \cos \phi_2\\ t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-5}:\\ \;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot t\_1}\\ \mathbf{elif}\;\phi_1 \leq 19:\\ \;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - 1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot t\_1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-t\_0\right) \cdot t\_1\right)}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* (sin phi1) (cos phi2))) (t_1 (cos (- lambda1 lambda2))))
   (if (<= phi1 -1.55e-5)
     (atan2
      (* (- (sin lambda1) (sin lambda2)) (cos phi2))
      (- (* (cos phi1) (sin phi2)) (* t_0 t_1)))
     (if (<= phi1 19.0)
       (atan2
        (*
         (fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
         (cos phi2))
        (- (sin phi2) (* 1.0 (* phi1 (* (cos phi2) t_1)))))
       (atan2
        (* (sin (- lambda1 lambda2)) (cos phi2))
        (fma (sin phi2) (cos phi1) (* (- t_0) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin(phi1) * cos(phi2);
	double t_1 = cos((lambda1 - lambda2));
	double tmp;
	if (phi1 <= -1.55e-5) {
		tmp = atan2(((sin(lambda1) - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (t_0 * t_1)));
	} else if (phi1 <= 19.0) {
		tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (1.0 * (phi1 * (cos(phi2) * t_1)))));
	} else {
		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (-t_0 * t_1)));
	}
	return tmp;
}
function code(lambda1, lambda2, phi1, phi2)
	t_0 = Float64(sin(phi1) * cos(phi2))
	t_1 = cos(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (phi1 <= -1.55e-5)
		tmp = atan(Float64(Float64(sin(lambda1) - sin(lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_0 * t_1)));
	elseif (phi1 <= 19.0)
		tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(1.0 * Float64(phi1 * Float64(cos(phi2) * t_1)))));
	else
		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-t_0) * t_1)));
	end
	return tmp
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.55e-5], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 19.0], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(1.0 * N[(phi1 * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-t$95$0) * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot t\_1}\\

\mathbf{elif}\;\phi_1 \leq 19:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - 1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot t\_1\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-t\_0\right) \cdot t\_1\right)}\\


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

    1. Initial program 76.0%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6479.0

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. Applied rewrites79.0%

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    4. Taylor expanded in lambda2 around 0

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    5. Step-by-step derivation
      1. lift-sin.f6477.0

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    6. Applied rewrites77.0%

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    7. Taylor expanded in lambda1 around 0

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 - \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    8. Step-by-step derivation
      1. lift-sin.f6476.0

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 - \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    9. Applied rewrites76.0%

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

    if -1.55000000000000007e-5 < phi1 < 19

    1. Initial program 81.5%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6499.4

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. Applied rewrites99.4%

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \color{blue}{\cos \left(\lambda_1 - \lambda_2\right)}} \]
      3. cos-diffN/A

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \color{blue}{\sin \lambda_1} \cdot \sin \lambda_2\right)} \]
      9. lift-sin.f6499.8

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

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
      8. fp-cancel-sub-sign-invN/A

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \color{blue}{\left(-\cos \lambda_1\right)} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
      14. lift-cos.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\color{blue}{\cos \lambda_1}\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)} \]
      15. lift-sin.f6499.8

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

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

      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2 + -1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)}} \]
    9. Step-by-step derivation
      1. cos-diff-revN/A

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 + -1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)} \]
      2. sin-+PI/2-revN/A

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 + -1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right) \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)}} \]
      4. cos-diff-revN/A

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\mathsf{neg}\left(-1\right)\right) \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)} \]
      5. lower--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)} \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)} \]
    10. Applied rewrites99.1%

      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2 - 1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}} \]

    if 19 < phi1

    1. Initial program 77.3%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \color{blue}{\cos \left(\lambda_1 - \lambda_2\right)}} \]
      11. fp-cancel-sub-sign-invN/A

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \color{blue}{\left(\mathsf{neg}\left(\sin \phi_1 \cdot \cos \phi_2\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\right)} \]
    3. Applied rewrites77.3%

      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 11: 88.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \phi_1 \cdot \cos \phi_2\\ t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-5}:\\ \;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot t\_1}\\ \mathbf{elif}\;\phi_1 \leq 19:\\ \;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\left(-\left(\cos \phi_2 \cdot \phi_1\right) \cdot t\_1\right) + \sin \phi_2}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-t\_0\right) \cdot t\_1\right)}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* (sin phi1) (cos phi2))) (t_1 (cos (- lambda1 lambda2))))
   (if (<= phi1 -1.55e-5)
     (atan2
      (* (- (sin lambda1) (sin lambda2)) (cos phi2))
      (- (* (cos phi1) (sin phi2)) (* t_0 t_1)))
     (if (<= phi1 19.0)
       (atan2
        (*
         (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
         (cos phi2))
        (+ (- (* (* (cos phi2) phi1) t_1)) (sin phi2)))
       (atan2
        (* (sin (- lambda1 lambda2)) (cos phi2))
        (fma (sin phi2) (cos phi1) (* (- t_0) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin(phi1) * cos(phi2);
	double t_1 = cos((lambda1 - lambda2));
	double tmp;
	if (phi1 <= -1.55e-5) {
		tmp = atan2(((sin(lambda1) - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (t_0 * t_1)));
	} else if (phi1 <= 19.0) {
		tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (-((cos(phi2) * phi1) * t_1) + sin(phi2)));
	} else {
		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (-t_0 * t_1)));
	}
	return tmp;
}
function code(lambda1, lambda2, phi1, phi2)
	t_0 = Float64(sin(phi1) * cos(phi2))
	t_1 = cos(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (phi1 <= -1.55e-5)
		tmp = atan(Float64(Float64(sin(lambda1) - sin(lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_0 * t_1)));
	elseif (phi1 <= 19.0)
		tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(-Float64(Float64(cos(phi2) * phi1) * t_1)) + sin(phi2)));
	else
		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-t_0) * t_1)));
	end
	return tmp
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.55e-5], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 19.0], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[((-N[(N[(N[Cos[phi2], $MachinePrecision] * phi1), $MachinePrecision] * t$95$1), $MachinePrecision]) + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-t$95$0) * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot t\_1}\\

\mathbf{elif}\;\phi_1 \leq 19:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\left(-\left(\cos \phi_2 \cdot \phi_1\right) \cdot t\_1\right) + \sin \phi_2}\\

\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-t\_0\right) \cdot t\_1\right)}\\


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

    1. Initial program 76.0%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6479.0

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. Applied rewrites79.0%

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    4. Taylor expanded in lambda2 around 0

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    5. Step-by-step derivation
      1. lift-sin.f6477.0

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    6. Applied rewrites77.0%

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    7. Taylor expanded in lambda1 around 0

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 - \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    8. Step-by-step derivation
      1. lift-sin.f6476.0

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 - \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    9. Applied rewrites76.0%

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

    if -1.55000000000000007e-5 < phi1 < 19

    1. Initial program 81.5%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6499.4

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. Applied rewrites99.4%

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\left(-\left(\phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) + \sin \phi_2} \]
      7. *-commutativeN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\left(-\left(\cos \phi_2 \cdot \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) + \sin \phi_2} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\left(-\left(\cos \phi_2 \cdot \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) + \sin \phi_2} \]
      9. lift-cos.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\left(-\left(\cos \phi_2 \cdot \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) + \sin \phi_2} \]
      10. lift-cos.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\left(-\left(\cos \phi_2 \cdot \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) + \sin \phi_2} \]
      11. lift--.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\left(-\left(\cos \phi_2 \cdot \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) + \sin \phi_2} \]
      12. lift-sin.f6499.1

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\left(-\left(\cos \phi_2 \cdot \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) + \sin \phi_2} \]
    6. Applied rewrites99.1%

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

    if 19 < phi1

    1. Initial program 77.3%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \color{blue}{\cos \left(\lambda_1 - \lambda_2\right)}} \]
      11. fp-cancel-sub-sign-invN/A

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \color{blue}{\left(\mathsf{neg}\left(\sin \phi_1 \cdot \cos \phi_2\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\right)} \]
    3. Applied rewrites77.3%

      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 12: 86.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \phi_1 \cdot \cos \phi_2\\ t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-5}:\\ \;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot t\_1}\\ \mathbf{elif}\;\phi_1 \leq 19:\\ \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-t\_0\right) \cdot t\_1\right)}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (* (sin phi1) (cos phi2))) (t_1 (cos (- lambda1 lambda2))))
   (if (<= phi1 -1.55e-5)
     (atan2
      (* (- (sin lambda1) (sin lambda2)) (cos phi2))
      (- (* (cos phi1) (sin phi2)) (* t_0 t_1)))
     (if (<= phi1 19.0)
       (atan2
        (*
         (cos phi2)
         (- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
        (sin phi2))
       (atan2
        (* (sin (- lambda1 lambda2)) (cos phi2))
        (fma (sin phi2) (cos phi1) (* (- t_0) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = sin(phi1) * cos(phi2);
	double t_1 = cos((lambda1 - lambda2));
	double tmp;
	if (phi1 <= -1.55e-5) {
		tmp = atan2(((sin(lambda1) - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (t_0 * t_1)));
	} else if (phi1 <= 19.0) {
		tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
	} else {
		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (-t_0 * t_1)));
	}
	return tmp;
}
function code(lambda1, lambda2, phi1, phi2)
	t_0 = Float64(sin(phi1) * cos(phi2))
	t_1 = cos(Float64(lambda1 - lambda2))
	tmp = 0.0
	if (phi1 <= -1.55e-5)
		tmp = atan(Float64(Float64(sin(lambda1) - sin(lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_0 * t_1)));
	elseif (phi1 <= 19.0)
		tmp = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), sin(phi2));
	else
		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-t_0) * t_1)));
	end
	return tmp
end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.55e-5], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 19.0], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-t$95$0) * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot t\_1}\\

\mathbf{elif}\;\phi_1 \leq 19:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\

\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-t\_0\right) \cdot t\_1\right)}\\


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

    1. Initial program 76.0%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      3. sin-diffN/A

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      5. mul-1-negN/A

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

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \left(-1 \cdot \lambda_2\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      7. mul-1-negN/A

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1 \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right)} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      9. lower-sin.f64N/A

        \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} \cdot \cos \left(\mathsf{neg}\left(\lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      10. cos-negN/A

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      14. lower-sin.f6479.0

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    3. Applied rewrites79.0%

      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    4. Taylor expanded in lambda2 around 0

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    5. Step-by-step derivation
      1. lift-sin.f6477.0

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    6. Applied rewrites77.0%

      \[\leadsto \tan^{-1}_* \frac{\left(\color{blue}{\sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    7. Taylor expanded in lambda1 around 0

      \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 - \color{blue}{\sin \lambda_2}\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    8. Step-by-step derivation
      1. lift-sin.f6476.0

        \[\leadsto \tan^{-1}_* \frac{\left(\sin \lambda_1 - \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    9. Applied rewrites76.0%

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

    if -1.55000000000000007e-5 < phi1 < 19

    1. Initial program 81.5%

      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
    2. Taylor expanded in phi1 around 0

      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
    3. Step-by-step derivation
      1. lift-sin.f6477.7

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
    4. Applied rewrites77.7%

      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
    5. Taylor expanded in phi2 around 0

      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
    6. Step-by-step derivation
      1. Applied rewrites48.9%

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
      2. Taylor expanded in lambda1 around 0

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \lambda_1 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right)\right)\right)} \cdot 1}{\sin \phi_2} \]
      3. Step-by-step derivation
        1. sin-diff-revN/A

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

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

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

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

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

          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
        7. associate-*r*N/A

          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\left(\frac{-1}{2} \cdot \lambda_1\right) \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
        8. metadata-evalN/A

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

          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
        10. metadata-evalN/A

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

          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
        12. sin-negN/A

          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
        13. lower-neg.f64N/A

          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
        14. lift-sin.f64N/A

          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
        15. lift-cos.f64N/A

          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
        16. sin-negN/A

          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\sin \phi_2} \]
      4. Applied rewrites42.9%

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

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

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

          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\color{blue}{\cos \lambda_2 \cdot \sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
        3. lower--.f64N/A

          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1 \cdot \sin \lambda_2}\right)}{\sin \phi_2} \]
        4. lower-*.f64N/A

          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
        5. lift-cos.f64N/A

          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \color{blue}{\lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
        6. lift-sin.f64N/A

          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
        7. lift-cos.f64N/A

          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \color{blue}{\lambda_2}\right)}{\sin \phi_2} \]
        8. lift-sin.f64N/A

          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
        9. lift-*.f6495.6

          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right)}{\sin \phi_2} \]
      7. Applied rewrites95.6%

        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\sin \phi_2} \]

      if 19 < phi1

      1. Initial program 77.3%

        \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      2. Step-by-step derivation
        1. lift--.f64N/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \color{blue}{\cos \left(\lambda_1 - \lambda_2\right)}} \]
        11. fp-cancel-sub-sign-invN/A

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

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

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

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

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

          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \color{blue}{\left(\mathsf{neg}\left(\sin \phi_1 \cdot \cos \phi_2\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\right)} \]
      3. Applied rewrites77.3%

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}} \]
    7. Recombined 3 regimes into one program.
    8. Add Preprocessing

    Alternative 13: 86.3% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \phi_1 \cdot \cos \phi_2\\ t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\ t_2 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\ \mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-5}:\\ \;\;\;\;\tan^{-1}_* \frac{t\_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot t\_1}\\ \mathbf{elif}\;\phi_1 \leq 19:\\ \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{t\_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-t\_0\right) \cdot t\_1\right)}\\ \end{array} \end{array} \]
    (FPCore (lambda1 lambda2 phi1 phi2)
     :precision binary64
     (let* ((t_0 (* (sin phi1) (cos phi2)))
            (t_1 (cos (- lambda1 lambda2)))
            (t_2 (* (sin (- lambda1 lambda2)) (cos phi2))))
       (if (<= phi1 -1.55e-5)
         (atan2 t_2 (- (* (cos phi1) (sin phi2)) (* t_0 t_1)))
         (if (<= phi1 19.0)
           (atan2
            (*
             (cos phi2)
             (- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
            (sin phi2))
           (atan2 t_2 (fma (sin phi2) (cos phi1) (* (- t_0) t_1)))))))
    double code(double lambda1, double lambda2, double phi1, double phi2) {
    	double t_0 = sin(phi1) * cos(phi2);
    	double t_1 = cos((lambda1 - lambda2));
    	double t_2 = sin((lambda1 - lambda2)) * cos(phi2);
    	double tmp;
    	if (phi1 <= -1.55e-5) {
    		tmp = atan2(t_2, ((cos(phi1) * sin(phi2)) - (t_0 * t_1)));
    	} else if (phi1 <= 19.0) {
    		tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
    	} else {
    		tmp = atan2(t_2, fma(sin(phi2), cos(phi1), (-t_0 * t_1)));
    	}
    	return tmp;
    }
    
    function code(lambda1, lambda2, phi1, phi2)
    	t_0 = Float64(sin(phi1) * cos(phi2))
    	t_1 = cos(Float64(lambda1 - lambda2))
    	t_2 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2))
    	tmp = 0.0
    	if (phi1 <= -1.55e-5)
    		tmp = atan(t_2, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_0 * t_1)));
    	elseif (phi1 <= 19.0)
    		tmp = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), sin(phi2));
    	else
    		tmp = atan(t_2, fma(sin(phi2), cos(phi1), Float64(Float64(-t_0) * t_1)));
    	end
    	return tmp
    end
    
    code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.55e-5], N[ArcTan[t$95$2 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 19.0], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-t$95$0) * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \sin \phi_1 \cdot \cos \phi_2\\
    t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
    t_2 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
    \mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-5}:\\
    \;\;\;\;\tan^{-1}_* \frac{t\_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot t\_1}\\
    
    \mathbf{elif}\;\phi_1 \leq 19:\\
    \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\
    
    \mathbf{else}:\\
    \;\;\;\;\tan^{-1}_* \frac{t\_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-t\_0\right) \cdot t\_1\right)}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if phi1 < -1.55000000000000007e-5

      1. Initial program 76.0%

        \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]

      if -1.55000000000000007e-5 < phi1 < 19

      1. Initial program 81.5%

        \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      2. Taylor expanded in phi1 around 0

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
      3. Step-by-step derivation
        1. lift-sin.f6477.7

          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
      4. Applied rewrites77.7%

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
      5. Taylor expanded in phi2 around 0

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
      6. Step-by-step derivation
        1. Applied rewrites48.9%

          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
        2. Taylor expanded in lambda1 around 0

          \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \lambda_1 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right)\right)\right)} \cdot 1}{\sin \phi_2} \]
        3. Step-by-step derivation
          1. sin-diff-revN/A

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

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

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

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

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

            \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
          7. associate-*r*N/A

            \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\left(\frac{-1}{2} \cdot \lambda_1\right) \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
          8. metadata-evalN/A

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

            \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
          10. metadata-evalN/A

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

            \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
          12. sin-negN/A

            \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
          13. lower-neg.f64N/A

            \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
          14. lift-sin.f64N/A

            \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
          15. lift-cos.f64N/A

            \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
          16. sin-negN/A

            \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\sin \phi_2} \]
        4. Applied rewrites42.9%

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

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

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

            \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\color{blue}{\cos \lambda_2 \cdot \sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
          3. lower--.f64N/A

            \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1 \cdot \sin \lambda_2}\right)}{\sin \phi_2} \]
          4. lower-*.f64N/A

            \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
          5. lift-cos.f64N/A

            \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \color{blue}{\lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
          6. lift-sin.f64N/A

            \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
          7. lift-cos.f64N/A

            \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \color{blue}{\lambda_2}\right)}{\sin \phi_2} \]
          8. lift-sin.f64N/A

            \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
          9. lift-*.f6495.6

            \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right)}{\sin \phi_2} \]
        7. Applied rewrites95.6%

          \[\leadsto \tan^{-1}_* \frac{\color{blue}{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\sin \phi_2} \]

        if 19 < phi1

        1. Initial program 77.3%

          \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
        2. Step-by-step derivation
          1. lift--.f64N/A

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

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

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

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

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

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

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

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

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

            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \color{blue}{\cos \left(\lambda_1 - \lambda_2\right)}} \]
          11. fp-cancel-sub-sign-invN/A

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

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

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

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

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

            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \color{blue}{\left(\mathsf{neg}\left(\sin \phi_1 \cdot \cos \phi_2\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\right)} \]
        3. Applied rewrites77.3%

          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}} \]
      7. Recombined 3 regimes into one program.
      8. Add Preprocessing

      Alternative 14: 86.3% accurate, 1.0× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\ \mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-5}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\phi_1 \leq 19:\\ \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (lambda1 lambda2 phi1 phi2)
       :precision binary64
       (let* ((t_0
               (atan2
                (* (sin (- lambda1 lambda2)) (cos phi2))
                (-
                 (* (cos phi1) (sin phi2))
                 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
         (if (<= phi1 -1.55e-5)
           t_0
           (if (<= phi1 19.0)
             (atan2
              (*
               (cos phi2)
               (- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
              (sin phi2))
             t_0))))
      double code(double lambda1, double lambda2, double phi1, double phi2) {
      	double t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
      	double tmp;
      	if (phi1 <= -1.55e-5) {
      		tmp = t_0;
      	} else if (phi1 <= 19.0) {
      		tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      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, lambda2, phi1, phi2)
      use fmin_fmax_functions
          real(8), intent (in) :: lambda1
          real(8), intent (in) :: lambda2
          real(8), intent (in) :: phi1
          real(8), intent (in) :: phi2
          real(8) :: t_0
          real(8) :: tmp
          t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
          if (phi1 <= (-1.55d-5)) then
              tmp = t_0
          else if (phi1 <= 19.0d0) then
              tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2))
          else
              tmp = t_0
          end if
          code = tmp
      end function
      
      public static double code(double lambda1, double lambda2, double phi1, double phi2) {
      	double t_0 = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
      	double tmp;
      	if (phi1 <= -1.55e-5) {
      		tmp = t_0;
      	} else if (phi1 <= 19.0) {
      		tmp = Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2)))), Math.sin(phi2));
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(lambda1, lambda2, phi1, phi2):
      	t_0 = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
      	tmp = 0
      	if phi1 <= -1.55e-5:
      		tmp = t_0
      	elif phi1 <= 19.0:
      		tmp = math.atan2((math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2)))), math.sin(phi2))
      	else:
      		tmp = t_0
      	return tmp
      
      function code(lambda1, lambda2, phi1, phi2)
      	t_0 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))
      	tmp = 0.0
      	if (phi1 <= -1.55e-5)
      		tmp = t_0;
      	elseif (phi1 <= 19.0)
      		tmp = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), sin(phi2));
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(lambda1, lambda2, phi1, phi2)
      	t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
      	tmp = 0.0;
      	if (phi1 <= -1.55e-5)
      		tmp = t_0;
      	elseif (phi1 <= 19.0)
      		tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
      	else
      		tmp = t_0;
      	end
      	tmp_2 = tmp;
      end
      
      code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.55e-5], t$95$0, If[LessEqual[phi1, 19.0], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
      \mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-5}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;\phi_1 \leq 19:\\
      \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if phi1 < -1.55000000000000007e-5 or 19 < phi1

        1. Initial program 76.7%

          \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]

        if -1.55000000000000007e-5 < phi1 < 19

        1. Initial program 81.5%

          \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
        2. Taylor expanded in phi1 around 0

          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
        3. Step-by-step derivation
          1. lift-sin.f6477.7

            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
        4. Applied rewrites77.7%

          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
        5. Taylor expanded in phi2 around 0

          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
        6. Step-by-step derivation
          1. Applied rewrites48.9%

            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
          2. Taylor expanded in lambda1 around 0

            \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \lambda_1 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right)\right)\right)} \cdot 1}{\sin \phi_2} \]
          3. Step-by-step derivation
            1. sin-diff-revN/A

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

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

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

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

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

              \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
            7. associate-*r*N/A

              \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\left(\frac{-1}{2} \cdot \lambda_1\right) \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
            8. metadata-evalN/A

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

              \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
            10. metadata-evalN/A

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

              \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
            12. sin-negN/A

              \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
            13. lower-neg.f64N/A

              \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
            14. lift-sin.f64N/A

              \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
            15. lift-cos.f64N/A

              \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
            16. sin-negN/A

              \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\sin \phi_2} \]
          4. Applied rewrites42.9%

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

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

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

              \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\color{blue}{\cos \lambda_2 \cdot \sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
            3. lower--.f64N/A

              \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1 \cdot \sin \lambda_2}\right)}{\sin \phi_2} \]
            4. lower-*.f64N/A

              \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
            5. lift-cos.f64N/A

              \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \color{blue}{\lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
            6. lift-sin.f64N/A

              \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
            7. lift-cos.f64N/A

              \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \color{blue}{\lambda_2}\right)}{\sin \phi_2} \]
            8. lift-sin.f64N/A

              \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
            9. lift-*.f6495.6

              \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right)}{\sin \phi_2} \]
          7. Applied rewrites95.6%

            \[\leadsto \tan^{-1}_* \frac{\color{blue}{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\sin \phi_2} \]
        7. Recombined 2 regimes into one program.
        8. Add Preprocessing

        Alternative 15: 78.6% accurate, 1.0× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_1 \cdot \sin \phi_2\\ \mathbf{if}\;\lambda_2 \leq -1.9 \cdot 10^{+27}:\\ \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\ \mathbf{elif}\;\lambda_2 \leq 0.0033:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\ \end{array} \end{array} \]
        (FPCore (lambda1 lambda2 phi1 phi2)
         :precision binary64
         (let* ((t_0 (* (cos phi1) (sin phi2))))
           (if (<= lambda2 -1.9e+27)
             (atan2
              (*
               (cos phi2)
               (- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
              (sin phi2))
             (if (<= lambda2 0.0033)
               (atan2
                (* (sin (- lambda1 lambda2)) (cos phi2))
                (- t_0 (* (* (cos lambda1) (cos phi2)) (sin phi1))))
               (atan2
                (* (sin (- lambda2)) (cos phi2))
                (- t_0 (* (* (cos lambda2) (sin phi1)) (cos phi2))))))))
        double code(double lambda1, double lambda2, double phi1, double phi2) {
        	double t_0 = cos(phi1) * sin(phi2);
        	double tmp;
        	if (lambda2 <= -1.9e+27) {
        		tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
        	} else if (lambda2 <= 0.0033) {
        		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1))));
        	} else {
        		tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
        	}
        	return tmp;
        }
        
        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, lambda2, phi1, phi2)
        use fmin_fmax_functions
            real(8), intent (in) :: lambda1
            real(8), intent (in) :: lambda2
            real(8), intent (in) :: phi1
            real(8), intent (in) :: phi2
            real(8) :: t_0
            real(8) :: tmp
            t_0 = cos(phi1) * sin(phi2)
            if (lambda2 <= (-1.9d+27)) then
                tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2))
            else if (lambda2 <= 0.0033d0) then
                tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1))))
            else
                tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
            end if
            code = tmp
        end function
        
        public static double code(double lambda1, double lambda2, double phi1, double phi2) {
        	double t_0 = Math.cos(phi1) * Math.sin(phi2);
        	double tmp;
        	if (lambda2 <= -1.9e+27) {
        		tmp = Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2)))), Math.sin(phi2));
        	} else if (lambda2 <= 0.0033) {
        		tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((Math.cos(lambda1) * Math.cos(phi2)) * Math.sin(phi1))));
        	} else {
        		tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
        	}
        	return tmp;
        }
        
        def code(lambda1, lambda2, phi1, phi2):
        	t_0 = math.cos(phi1) * math.sin(phi2)
        	tmp = 0
        	if lambda2 <= -1.9e+27:
        		tmp = math.atan2((math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2)))), math.sin(phi2))
        	elif lambda2 <= 0.0033:
        		tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((math.cos(lambda1) * math.cos(phi2)) * math.sin(phi1))))
        	else:
        		tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2))))
        	return tmp
        
        function code(lambda1, lambda2, phi1, phi2)
        	t_0 = Float64(cos(phi1) * sin(phi2))
        	tmp = 0.0
        	if (lambda2 <= -1.9e+27)
        		tmp = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), sin(phi2));
        	elseif (lambda2 <= 0.0033)
        		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(lambda1) * cos(phi2)) * sin(phi1))));
        	else
        		tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2))));
        	end
        	return tmp
        end
        
        function tmp_2 = code(lambda1, lambda2, phi1, phi2)
        	t_0 = cos(phi1) * sin(phi2);
        	tmp = 0.0;
        	if (lambda2 <= -1.9e+27)
        		tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
        	elseif (lambda2 <= 0.0033)
        		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1))));
        	else
        		tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
        	end
        	tmp_2 = tmp;
        end
        
        code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -1.9e+27], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 0.0033], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \cos \phi_1 \cdot \sin \phi_2\\
        \mathbf{if}\;\lambda_2 \leq -1.9 \cdot 10^{+27}:\\
        \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\
        
        \mathbf{elif}\;\lambda_2 \leq 0.0033:\\
        \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
        
        \mathbf{else}:\\
        \;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if lambda2 < -1.90000000000000011e27

          1. Initial program 60.6%

            \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
          2. Taylor expanded in phi1 around 0

            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
          3. Step-by-step derivation
            1. lift-sin.f6440.2

              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
          4. Applied rewrites40.2%

            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
          5. Taylor expanded in phi2 around 0

            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
          6. Step-by-step derivation
            1. Applied rewrites27.9%

              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
            2. Taylor expanded in lambda1 around 0

              \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \lambda_1 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right)\right)\right)} \cdot 1}{\sin \phi_2} \]
            3. Step-by-step derivation
              1. sin-diff-revN/A

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

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

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

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

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

                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
              7. associate-*r*N/A

                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\left(\frac{-1}{2} \cdot \lambda_1\right) \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
              8. metadata-evalN/A

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

                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
              10. metadata-evalN/A

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

                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
              12. sin-negN/A

                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
              13. lower-neg.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
              14. lift-sin.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
              15. lift-cos.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
              16. sin-negN/A

                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\sin \phi_2} \]
            4. Applied rewrites28.9%

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

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

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

                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\color{blue}{\cos \lambda_2 \cdot \sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
              3. lower--.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1 \cdot \sin \lambda_2}\right)}{\sin \phi_2} \]
              4. lower-*.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
              5. lift-cos.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \color{blue}{\lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
              6. lift-sin.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
              7. lift-cos.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \color{blue}{\lambda_2}\right)}{\sin \phi_2} \]
              8. lift-sin.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
              9. lift-*.f6460.3

                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right)}{\sin \phi_2} \]
            7. Applied rewrites60.3%

              \[\leadsto \tan^{-1}_* \frac{\color{blue}{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\sin \phi_2} \]

            if -1.90000000000000011e27 < lambda2 < 0.0033

            1. Initial program 97.4%

              \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
            2. Taylor expanded in lambda2 around 0

              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}} \]
            3. Step-by-step derivation
              1. associate-*r*N/A

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

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

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

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot \sin \phi_1} \]
              5. lift-cos.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot \sin \phi_1} \]
              6. lift-sin.f6496.6

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot \sin \phi_1} \]
            4. Applied rewrites96.6%

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

            if 0.0033 < lambda2

            1. Initial program 58.4%

              \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
            2. Taylor expanded in lambda1 around 0

              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\cos \phi_2 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right)}} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

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

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right) \cdot \color{blue}{\cos \phi_2}} \]
              3. lower-*.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right) \cdot \cos \color{blue}{\phi_2}} \]
              4. cos-negN/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
              5. lower-cos.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
              6. lift-sin.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
              7. lift-cos.f6458.3

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
            4. Applied rewrites58.3%

              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}} \]
            5. Taylor expanded in lambda1 around 0

              \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\left(-1 \cdot \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
            6. Step-by-step derivation
              1. mul-1-negN/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
              2. lower-neg.f6458.6

                \[\leadsto \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
            7. Applied rewrites58.6%

              \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\left(-\lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
          7. Recombined 3 regimes into one program.
          8. Add Preprocessing

          Alternative 16: 73.2% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \lambda_2 \cdot \sin \phi_1\\ t_1 := \cos \phi_1 \cdot \sin \phi_2\\ \mathbf{if}\;\lambda_1 \leq -1.12 \cdot 10^{-10}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\ \mathbf{elif}\;\lambda_1 \leq 9 \cdot 10^{-187}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_1 - t\_0 \cdot \cos \phi_2}\\ \mathbf{elif}\;\lambda_1 \leq 2.9 \cdot 10^{-13}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_1 - t\_0}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\ \end{array} \end{array} \]
          (FPCore (lambda1 lambda2 phi1 phi2)
           :precision binary64
           (let* ((t_0 (* (cos lambda2) (sin phi1))) (t_1 (* (cos phi1) (sin phi2))))
             (if (<= lambda1 -1.12e-10)
               (atan2
                (* (sin lambda1) (cos phi2))
                (- t_1 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
               (if (<= lambda1 9e-187)
                 (atan2 (* (sin (- lambda2)) (cos phi2)) (- t_1 (* t_0 (cos phi2))))
                 (if (<= lambda1 2.9e-13)
                   (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- t_1 t_0))
                   (atan2
                    (*
                     (cos phi2)
                     (- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
                    (sin phi2)))))))
          double code(double lambda1, double lambda2, double phi1, double phi2) {
          	double t_0 = cos(lambda2) * sin(phi1);
          	double t_1 = cos(phi1) * sin(phi2);
          	double tmp;
          	if (lambda1 <= -1.12e-10) {
          		tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
          	} else if (lambda1 <= 9e-187) {
          		tmp = atan2((sin(-lambda2) * cos(phi2)), (t_1 - (t_0 * cos(phi2))));
          	} else if (lambda1 <= 2.9e-13) {
          		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - t_0));
          	} else {
          		tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
          	}
          	return tmp;
          }
          
          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, lambda2, phi1, phi2)
          use fmin_fmax_functions
              real(8), intent (in) :: lambda1
              real(8), intent (in) :: lambda2
              real(8), intent (in) :: phi1
              real(8), intent (in) :: phi2
              real(8) :: t_0
              real(8) :: t_1
              real(8) :: tmp
              t_0 = cos(lambda2) * sin(phi1)
              t_1 = cos(phi1) * sin(phi2)
              if (lambda1 <= (-1.12d-10)) then
                  tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
              else if (lambda1 <= 9d-187) then
                  tmp = atan2((sin(-lambda2) * cos(phi2)), (t_1 - (t_0 * cos(phi2))))
              else if (lambda1 <= 2.9d-13) then
                  tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - t_0))
              else
                  tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2))
              end if
              code = tmp
          end function
          
          public static double code(double lambda1, double lambda2, double phi1, double phi2) {
          	double t_0 = Math.cos(lambda2) * Math.sin(phi1);
          	double t_1 = Math.cos(phi1) * Math.sin(phi2);
          	double tmp;
          	if (lambda1 <= -1.12e-10) {
          		tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_1 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
          	} else if (lambda1 <= 9e-187) {
          		tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_1 - (t_0 * Math.cos(phi2))));
          	} else if (lambda1 <= 2.9e-13) {
          		tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_1 - t_0));
          	} else {
          		tmp = Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2)))), Math.sin(phi2));
          	}
          	return tmp;
          }
          
          def code(lambda1, lambda2, phi1, phi2):
          	t_0 = math.cos(lambda2) * math.sin(phi1)
          	t_1 = math.cos(phi1) * math.sin(phi2)
          	tmp = 0
          	if lambda1 <= -1.12e-10:
          		tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_1 - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
          	elif lambda1 <= 9e-187:
          		tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_1 - (t_0 * math.cos(phi2))))
          	elif lambda1 <= 2.9e-13:
          		tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_1 - t_0))
          	else:
          		tmp = math.atan2((math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2)))), math.sin(phi2))
          	return tmp
          
          function code(lambda1, lambda2, phi1, phi2)
          	t_0 = Float64(cos(lambda2) * sin(phi1))
          	t_1 = Float64(cos(phi1) * sin(phi2))
          	tmp = 0.0
          	if (lambda1 <= -1.12e-10)
          		tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))));
          	elseif (lambda1 <= 9e-187)
          		tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_1 - Float64(t_0 * cos(phi2))));
          	elseif (lambda1 <= 2.9e-13)
          		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_1 - t_0));
          	else
          		tmp = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), sin(phi2));
          	end
          	return tmp
          end
          
          function tmp_2 = code(lambda1, lambda2, phi1, phi2)
          	t_0 = cos(lambda2) * sin(phi1);
          	t_1 = cos(phi1) * sin(phi2);
          	tmp = 0.0;
          	if (lambda1 <= -1.12e-10)
          		tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
          	elseif (lambda1 <= 9e-187)
          		tmp = atan2((sin(-lambda2) * cos(phi2)), (t_1 - (t_0 * cos(phi2))));
          	elseif (lambda1 <= 2.9e-13)
          		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - t_0));
          	else
          		tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
          	end
          	tmp_2 = tmp;
          end
          
          code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -1.12e-10], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 9e-187], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 2.9e-13], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - t$95$0), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \cos \lambda_2 \cdot \sin \phi_1\\
          t_1 := \cos \phi_1 \cdot \sin \phi_2\\
          \mathbf{if}\;\lambda_1 \leq -1.12 \cdot 10^{-10}:\\
          \;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
          
          \mathbf{elif}\;\lambda_1 \leq 9 \cdot 10^{-187}:\\
          \;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_1 - t\_0 \cdot \cos \phi_2}\\
          
          \mathbf{elif}\;\lambda_1 \leq 2.9 \cdot 10^{-13}:\\
          \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_1 - t\_0}\\
          
          \mathbf{else}:\\
          \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 4 regimes
          2. if lambda1 < -1.12e-10

            1. Initial program 58.7%

              \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
            2. Taylor expanded in lambda2 around 0

              \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \lambda_1} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
            3. Step-by-step derivation
              1. lower-sin.f6458.2

                \[\leadsto \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
            4. Applied rewrites58.2%

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

            if -1.12e-10 < lambda1 < 8.9999999999999996e-187

            1. Initial program 99.7%

              \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
            2. Taylor expanded in lambda1 around 0

              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\cos \phi_2 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right)}} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

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

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right) \cdot \color{blue}{\cos \phi_2}} \]
              3. lower-*.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right) \cdot \cos \color{blue}{\phi_2}} \]
              4. cos-negN/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
              5. lower-cos.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
              6. lift-sin.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
              7. lift-cos.f6499.7

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
            4. Applied rewrites99.7%

              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}} \]
            5. Taylor expanded in lambda1 around 0

              \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\left(-1 \cdot \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
            6. Step-by-step derivation
              1. mul-1-negN/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
              2. lower-neg.f6485.0

                \[\leadsto \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
            7. Applied rewrites85.0%

              \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\left(-\lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]

            if 8.9999999999999996e-187 < lambda1 < 2.8999999999999998e-13

            1. Initial program 99.7%

              \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
            2. Taylor expanded in lambda1 around 0

              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\cos \phi_2 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right)}} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

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

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right) \cdot \color{blue}{\cos \phi_2}} \]
              3. lower-*.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right) \cdot \cos \color{blue}{\phi_2}} \]
              4. cos-negN/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
              5. lower-cos.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
              6. lift-sin.f64N/A

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
              7. lift-cos.f6499.7

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
            4. Applied rewrites99.7%

              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}} \]
            5. Taylor expanded in phi2 around 0

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

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

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \cos \lambda_2 \cdot \sin \phi_1} \]
              3. lift-*.f6483.1

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \cos \lambda_2 \cdot \sin \phi_1} \]
            7. Applied rewrites83.1%

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

            if 2.8999999999999998e-13 < lambda1

            1. Initial program 59.7%

              \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
            2. Taylor expanded in phi1 around 0

              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
            3. Step-by-step derivation
              1. lift-sin.f6440.7

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
            4. Applied rewrites40.7%

              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
            5. Taylor expanded in phi2 around 0

              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
            6. Step-by-step derivation
              1. Applied rewrites28.9%

                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
              2. Taylor expanded in lambda1 around 0

                \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \lambda_1 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right)\right)\right)} \cdot 1}{\sin \phi_2} \]
              3. Step-by-step derivation
                1. sin-diff-revN/A

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

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

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

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

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

                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                7. associate-*r*N/A

                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\left(\frac{-1}{2} \cdot \lambda_1\right) \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                8. metadata-evalN/A

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

                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                10. metadata-evalN/A

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

                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                12. sin-negN/A

                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                13. lower-neg.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                14. lift-sin.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                15. lift-cos.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                16. sin-negN/A

                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\sin \phi_2} \]
              4. Applied rewrites21.7%

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

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

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

                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\color{blue}{\cos \lambda_2 \cdot \sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                3. lower--.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1 \cdot \sin \lambda_2}\right)}{\sin \phi_2} \]
                4. lower-*.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                5. lift-cos.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \color{blue}{\lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                6. lift-sin.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                7. lift-cos.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \color{blue}{\lambda_2}\right)}{\sin \phi_2} \]
                8. lift-sin.f64N/A

                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                9. lift-*.f6460.5

                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right)}{\sin \phi_2} \]
              7. Applied rewrites60.5%

                \[\leadsto \tan^{-1}_* \frac{\color{blue}{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\sin \phi_2} \]
            7. Recombined 4 regimes into one program.
            8. Add Preprocessing

            Alternative 17: 71.7% accurate, 1.0× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \lambda_2 \cdot \sin \phi_1\\ t_1 := \cos \phi_1 \cdot \sin \phi_2\\ \mathbf{if}\;\lambda_1 \leq -1.12 \cdot 10^{-10}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1}\\ \mathbf{elif}\;\lambda_1 \leq 9 \cdot 10^{-187}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_1 - t\_0 \cdot \cos \phi_2}\\ \mathbf{elif}\;\lambda_1 \leq 2.9 \cdot 10^{-13}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_1 - t\_0}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\ \end{array} \end{array} \]
            (FPCore (lambda1 lambda2 phi1 phi2)
             :precision binary64
             (let* ((t_0 (* (cos lambda2) (sin phi1))) (t_1 (* (cos phi1) (sin phi2))))
               (if (<= lambda1 -1.12e-10)
                 (atan2
                  (* (sin lambda1) (cos phi2))
                  (- t_1 (* (* (sin phi1) (cos phi2)) (cos lambda1))))
                 (if (<= lambda1 9e-187)
                   (atan2 (* (sin (- lambda2)) (cos phi2)) (- t_1 (* t_0 (cos phi2))))
                   (if (<= lambda1 2.9e-13)
                     (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- t_1 t_0))
                     (atan2
                      (*
                       (cos phi2)
                       (- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
                      (sin phi2)))))))
            double code(double lambda1, double lambda2, double phi1, double phi2) {
            	double t_0 = cos(lambda2) * sin(phi1);
            	double t_1 = cos(phi1) * sin(phi2);
            	double tmp;
            	if (lambda1 <= -1.12e-10) {
            		tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - ((sin(phi1) * cos(phi2)) * cos(lambda1))));
            	} else if (lambda1 <= 9e-187) {
            		tmp = atan2((sin(-lambda2) * cos(phi2)), (t_1 - (t_0 * cos(phi2))));
            	} else if (lambda1 <= 2.9e-13) {
            		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - t_0));
            	} else {
            		tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
            	}
            	return tmp;
            }
            
            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, lambda2, phi1, phi2)
            use fmin_fmax_functions
                real(8), intent (in) :: lambda1
                real(8), intent (in) :: lambda2
                real(8), intent (in) :: phi1
                real(8), intent (in) :: phi2
                real(8) :: t_0
                real(8) :: t_1
                real(8) :: tmp
                t_0 = cos(lambda2) * sin(phi1)
                t_1 = cos(phi1) * sin(phi2)
                if (lambda1 <= (-1.12d-10)) then
                    tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - ((sin(phi1) * cos(phi2)) * cos(lambda1))))
                else if (lambda1 <= 9d-187) then
                    tmp = atan2((sin(-lambda2) * cos(phi2)), (t_1 - (t_0 * cos(phi2))))
                else if (lambda1 <= 2.9d-13) then
                    tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - t_0))
                else
                    tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2))
                end if
                code = tmp
            end function
            
            public static double code(double lambda1, double lambda2, double phi1, double phi2) {
            	double t_0 = Math.cos(lambda2) * Math.sin(phi1);
            	double t_1 = Math.cos(phi1) * Math.sin(phi2);
            	double tmp;
            	if (lambda1 <= -1.12e-10) {
            		tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_1 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
            	} else if (lambda1 <= 9e-187) {
            		tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_1 - (t_0 * Math.cos(phi2))));
            	} else if (lambda1 <= 2.9e-13) {
            		tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_1 - t_0));
            	} else {
            		tmp = Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2)))), Math.sin(phi2));
            	}
            	return tmp;
            }
            
            def code(lambda1, lambda2, phi1, phi2):
            	t_0 = math.cos(lambda2) * math.sin(phi1)
            	t_1 = math.cos(phi1) * math.sin(phi2)
            	tmp = 0
            	if lambda1 <= -1.12e-10:
            		tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_1 - ((math.sin(phi1) * math.cos(phi2)) * math.cos(lambda1))))
            	elif lambda1 <= 9e-187:
            		tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_1 - (t_0 * math.cos(phi2))))
            	elif lambda1 <= 2.9e-13:
            		tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_1 - t_0))
            	else:
            		tmp = math.atan2((math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2)))), math.sin(phi2))
            	return tmp
            
            function code(lambda1, lambda2, phi1, phi2)
            	t_0 = Float64(cos(lambda2) * sin(phi1))
            	t_1 = Float64(cos(phi1) * sin(phi2))
            	tmp = 0.0
            	if (lambda1 <= -1.12e-10)
            		tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda1))));
            	elseif (lambda1 <= 9e-187)
            		tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_1 - Float64(t_0 * cos(phi2))));
            	elseif (lambda1 <= 2.9e-13)
            		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_1 - t_0));
            	else
            		tmp = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), sin(phi2));
            	end
            	return tmp
            end
            
            function tmp_2 = code(lambda1, lambda2, phi1, phi2)
            	t_0 = cos(lambda2) * sin(phi1);
            	t_1 = cos(phi1) * sin(phi2);
            	tmp = 0.0;
            	if (lambda1 <= -1.12e-10)
            		tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - ((sin(phi1) * cos(phi2)) * cos(lambda1))));
            	elseif (lambda1 <= 9e-187)
            		tmp = atan2((sin(-lambda2) * cos(phi2)), (t_1 - (t_0 * cos(phi2))));
            	elseif (lambda1 <= 2.9e-13)
            		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - t_0));
            	else
            		tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
            	end
            	tmp_2 = tmp;
            end
            
            code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -1.12e-10], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 9e-187], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 2.9e-13], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - t$95$0), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := \cos \lambda_2 \cdot \sin \phi_1\\
            t_1 := \cos \phi_1 \cdot \sin \phi_2\\
            \mathbf{if}\;\lambda_1 \leq -1.12 \cdot 10^{-10}:\\
            \;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1}\\
            
            \mathbf{elif}\;\lambda_1 \leq 9 \cdot 10^{-187}:\\
            \;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_1 - t\_0 \cdot \cos \phi_2}\\
            
            \mathbf{elif}\;\lambda_1 \leq 2.9 \cdot 10^{-13}:\\
            \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_1 - t\_0}\\
            
            \mathbf{else}:\\
            \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 4 regimes
            2. if lambda1 < -1.12e-10

              1. Initial program 58.7%

                \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
              2. Taylor expanded in lambda1 around inf

                \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\lambda_1} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
              3. Step-by-step derivation
                1. Applied rewrites58.2%

                  \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\lambda_1} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                2. Taylor expanded in lambda1 around inf

                  \[\leadsto \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \color{blue}{\lambda_1}} \]
                3. Step-by-step derivation
                  1. Applied rewrites58.2%

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

                  if -1.12e-10 < lambda1 < 8.9999999999999996e-187

                  1. Initial program 99.7%

                    \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                  2. Taylor expanded in lambda1 around 0

                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\cos \phi_2 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right)}} \]
                  3. Step-by-step derivation
                    1. *-commutativeN/A

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

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right) \cdot \color{blue}{\cos \phi_2}} \]
                    3. lower-*.f64N/A

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right) \cdot \cos \color{blue}{\phi_2}} \]
                    4. cos-negN/A

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                    5. lower-cos.f64N/A

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                    6. lift-sin.f64N/A

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                    7. lift-cos.f6499.7

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                  4. Applied rewrites99.7%

                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}} \]
                  5. Taylor expanded in lambda1 around 0

                    \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\left(-1 \cdot \lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                  6. Step-by-step derivation
                    1. mul-1-negN/A

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                    2. lower-neg.f6485.0

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                  7. Applied rewrites85.0%

                    \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\left(-\lambda_2\right)} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]

                  if 8.9999999999999996e-187 < lambda1 < 2.8999999999999998e-13

                  1. Initial program 99.7%

                    \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                  2. Taylor expanded in lambda1 around 0

                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\cos \phi_2 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right)}} \]
                  3. Step-by-step derivation
                    1. *-commutativeN/A

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

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right) \cdot \color{blue}{\cos \phi_2}} \]
                    3. lower-*.f64N/A

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right) \cdot \cos \color{blue}{\phi_2}} \]
                    4. cos-negN/A

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                    5. lower-cos.f64N/A

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                    6. lift-sin.f64N/A

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                    7. lift-cos.f6499.7

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                  4. Applied rewrites99.7%

                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}} \]
                  5. Taylor expanded in phi2 around 0

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

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

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \cos \lambda_2 \cdot \sin \phi_1} \]
                    3. lift-*.f6483.1

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \cos \lambda_2 \cdot \sin \phi_1} \]
                  7. Applied rewrites83.1%

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

                  if 2.8999999999999998e-13 < lambda1

                  1. Initial program 59.7%

                    \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                  2. Taylor expanded in phi1 around 0

                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                  3. Step-by-step derivation
                    1. lift-sin.f6440.7

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                  4. Applied rewrites40.7%

                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                  5. Taylor expanded in phi2 around 0

                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                  6. Step-by-step derivation
                    1. Applied rewrites28.9%

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                    2. Taylor expanded in lambda1 around 0

                      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \lambda_1 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right)\right)\right)} \cdot 1}{\sin \phi_2} \]
                    3. Step-by-step derivation
                      1. sin-diff-revN/A

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

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

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

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

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

                        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                      7. associate-*r*N/A

                        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\left(\frac{-1}{2} \cdot \lambda_1\right) \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                      8. metadata-evalN/A

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

                        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                      10. metadata-evalN/A

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

                        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                      12. sin-negN/A

                        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                      13. lower-neg.f64N/A

                        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                      14. lift-sin.f64N/A

                        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                      15. lift-cos.f64N/A

                        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                      16. sin-negN/A

                        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\sin \phi_2} \]
                    4. Applied rewrites21.7%

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

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

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

                        \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\color{blue}{\cos \lambda_2 \cdot \sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                      3. lower--.f64N/A

                        \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1 \cdot \sin \lambda_2}\right)}{\sin \phi_2} \]
                      4. lower-*.f64N/A

                        \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                      5. lift-cos.f64N/A

                        \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \color{blue}{\lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                      6. lift-sin.f64N/A

                        \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                      7. lift-cos.f64N/A

                        \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \color{blue}{\lambda_2}\right)}{\sin \phi_2} \]
                      8. lift-sin.f64N/A

                        \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                      9. lift-*.f6460.5

                        \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right)}{\sin \phi_2} \]
                    7. Applied rewrites60.5%

                      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\sin \phi_2} \]
                  7. Recombined 4 regimes into one program.
                  8. Add Preprocessing

                  Alternative 18: 71.7% accurate, 1.0× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\ t_1 := \cos \phi_1 \cdot \sin \phi_2\\ \mathbf{if}\;\lambda_2 \leq -1.2 \cdot 10^{-72}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\lambda_2 \leq 2.15 \cdot 10^{-156}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1}\\ \mathbf{elif}\;\lambda_2 \leq 1.3 \cdot 10^{+122}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_1 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                  (FPCore (lambda1 lambda2 phi1 phi2)
                   :precision binary64
                   (let* ((t_0
                           (atan2
                            (*
                             (cos phi2)
                             (- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
                            (sin phi2)))
                          (t_1 (* (cos phi1) (sin phi2))))
                     (if (<= lambda2 -1.2e-72)
                       t_0
                       (if (<= lambda2 2.15e-156)
                         (atan2
                          (* (sin lambda1) (cos phi2))
                          (- t_1 (* (* (sin phi1) (cos phi2)) (cos lambda1))))
                         (if (<= lambda2 1.3e+122)
                           (atan2
                            (* (sin (- lambda1 lambda2)) (cos phi2))
                            (- t_1 (* (sin phi1) (cos (- lambda1 lambda2)))))
                           t_0)))))
                  double code(double lambda1, double lambda2, double phi1, double phi2) {
                  	double t_0 = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
                  	double t_1 = cos(phi1) * sin(phi2);
                  	double tmp;
                  	if (lambda2 <= -1.2e-72) {
                  		tmp = t_0;
                  	} else if (lambda2 <= 2.15e-156) {
                  		tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - ((sin(phi1) * cos(phi2)) * cos(lambda1))));
                  	} else if (lambda2 <= 1.3e+122) {
                  		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - (sin(phi1) * cos((lambda1 - lambda2)))));
                  	} else {
                  		tmp = t_0;
                  	}
                  	return tmp;
                  }
                  
                  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, lambda2, phi1, phi2)
                  use fmin_fmax_functions
                      real(8), intent (in) :: lambda1
                      real(8), intent (in) :: lambda2
                      real(8), intent (in) :: phi1
                      real(8), intent (in) :: phi2
                      real(8) :: t_0
                      real(8) :: t_1
                      real(8) :: tmp
                      t_0 = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2))
                      t_1 = cos(phi1) * sin(phi2)
                      if (lambda2 <= (-1.2d-72)) then
                          tmp = t_0
                      else if (lambda2 <= 2.15d-156) then
                          tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - ((sin(phi1) * cos(phi2)) * cos(lambda1))))
                      else if (lambda2 <= 1.3d+122) then
                          tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - (sin(phi1) * cos((lambda1 - lambda2)))))
                      else
                          tmp = t_0
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double lambda1, double lambda2, double phi1, double phi2) {
                  	double t_0 = Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2)))), Math.sin(phi2));
                  	double t_1 = Math.cos(phi1) * Math.sin(phi2);
                  	double tmp;
                  	if (lambda2 <= -1.2e-72) {
                  		tmp = t_0;
                  	} else if (lambda2 <= 2.15e-156) {
                  		tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_1 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
                  	} else if (lambda2 <= 1.3e+122) {
                  		tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_1 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
                  	} else {
                  		tmp = t_0;
                  	}
                  	return tmp;
                  }
                  
                  def code(lambda1, lambda2, phi1, phi2):
                  	t_0 = math.atan2((math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2)))), math.sin(phi2))
                  	t_1 = math.cos(phi1) * math.sin(phi2)
                  	tmp = 0
                  	if lambda2 <= -1.2e-72:
                  		tmp = t_0
                  	elif lambda2 <= 2.15e-156:
                  		tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_1 - ((math.sin(phi1) * math.cos(phi2)) * math.cos(lambda1))))
                  	elif lambda2 <= 1.3e+122:
                  		tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_1 - (math.sin(phi1) * math.cos((lambda1 - lambda2)))))
                  	else:
                  		tmp = t_0
                  	return tmp
                  
                  function code(lambda1, lambda2, phi1, phi2)
                  	t_0 = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), sin(phi2))
                  	t_1 = Float64(cos(phi1) * sin(phi2))
                  	tmp = 0.0
                  	if (lambda2 <= -1.2e-72)
                  		tmp = t_0;
                  	elseif (lambda2 <= 2.15e-156)
                  		tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda1))));
                  	elseif (lambda2 <= 1.3e+122)
                  		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_1 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))));
                  	else
                  		tmp = t_0;
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(lambda1, lambda2, phi1, phi2)
                  	t_0 = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
                  	t_1 = cos(phi1) * sin(phi2);
                  	tmp = 0.0;
                  	if (lambda2 <= -1.2e-72)
                  		tmp = t_0;
                  	elseif (lambda2 <= 2.15e-156)
                  		tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - ((sin(phi1) * cos(phi2)) * cos(lambda1))));
                  	elseif (lambda2 <= 1.3e+122)
                  		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_1 - (sin(phi1) * cos((lambda1 - lambda2)))));
                  	else
                  		tmp = t_0;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -1.2e-72], t$95$0, If[LessEqual[lambda2, 2.15e-156], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 1.3e+122], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\
                  t_1 := \cos \phi_1 \cdot \sin \phi_2\\
                  \mathbf{if}\;\lambda_2 \leq -1.2 \cdot 10^{-72}:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{elif}\;\lambda_2 \leq 2.15 \cdot 10^{-156}:\\
                  \;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1}\\
                  
                  \mathbf{elif}\;\lambda_2 \leq 1.3 \cdot 10^{+122}:\\
                  \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_1 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_0\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if lambda2 < -1.2e-72 or 1.30000000000000004e122 < lambda2

                    1. Initial program 64.5%

                      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                    2. Taylor expanded in phi1 around 0

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                    3. Step-by-step derivation
                      1. lift-sin.f6441.8

                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                    4. Applied rewrites41.8%

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                    5. Taylor expanded in phi2 around 0

                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                    6. Step-by-step derivation
                      1. Applied rewrites29.0%

                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                      2. Taylor expanded in lambda1 around 0

                        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \lambda_1 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right)\right)\right)} \cdot 1}{\sin \phi_2} \]
                      3. Step-by-step derivation
                        1. sin-diff-revN/A

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

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

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

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

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

                          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                        7. associate-*r*N/A

                          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\left(\frac{-1}{2} \cdot \lambda_1\right) \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                        8. metadata-evalN/A

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

                          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                        10. metadata-evalN/A

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

                          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                        12. sin-negN/A

                          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                        13. lower-neg.f64N/A

                          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                        14. lift-sin.f64N/A

                          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                        15. lift-cos.f64N/A

                          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                        16. sin-negN/A

                          \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\sin \phi_2} \]
                      4. Applied rewrites28.1%

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

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

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

                          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\color{blue}{\cos \lambda_2 \cdot \sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                        3. lower--.f64N/A

                          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1 \cdot \sin \lambda_2}\right)}{\sin \phi_2} \]
                        4. lower-*.f64N/A

                          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                        5. lift-cos.f64N/A

                          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \color{blue}{\lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                        6. lift-sin.f64N/A

                          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                        7. lift-cos.f64N/A

                          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \color{blue}{\lambda_2}\right)}{\sin \phi_2} \]
                        8. lift-sin.f64N/A

                          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                        9. lift-*.f6459.4

                          \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right)}{\sin \phi_2} \]
                      7. Applied rewrites59.4%

                        \[\leadsto \tan^{-1}_* \frac{\color{blue}{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\sin \phi_2} \]

                      if -1.2e-72 < lambda2 < 2.14999999999999989e-156

                      1. Initial program 99.8%

                        \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                      2. Taylor expanded in lambda1 around inf

                        \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\lambda_1} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                      3. Step-by-step derivation
                        1. Applied rewrites86.5%

                          \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\lambda_1} \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                        2. Taylor expanded in lambda1 around inf

                          \[\leadsto \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \color{blue}{\lambda_1}} \]
                        3. Step-by-step derivation
                          1. Applied rewrites86.5%

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

                          if 2.14999999999999989e-156 < lambda2 < 1.30000000000000004e122

                          1. Initial program 80.1%

                            \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                          2. Taylor expanded in phi2 around 0

                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\sin \phi_1} \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                          3. Step-by-step derivation
                            1. lift-sin.f6467.0

                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                          4. Applied rewrites67.0%

                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\sin \phi_1} \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                        4. Recombined 3 regimes into one program.
                        5. Add Preprocessing

                        Alternative 19: 71.3% accurate, 1.1× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\ t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\ \mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-5}:\\ \;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t\_0}\\ \mathbf{elif}\;\phi_1 \leq 19:\\ \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\ \end{array} \end{array} \]
                        (FPCore (lambda1 lambda2 phi1 phi2)
                         :precision binary64
                         (let* ((t_0 (cos (- lambda1 lambda2)))
                                (t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
                           (if (<= phi1 -1.55e-5)
                             (atan2 t_1 (- (* (cos phi1) (sin phi2)) (* (sin phi1) t_0)))
                             (if (<= phi1 19.0)
                               (atan2
                                (*
                                 (cos phi2)
                                 (- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
                                (sin phi2))
                               (atan2 t_1 (- (sin phi2) (* (* (sin phi1) (cos phi2)) t_0)))))))
                        double code(double lambda1, double lambda2, double phi1, double phi2) {
                        	double t_0 = cos((lambda1 - lambda2));
                        	double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
                        	double tmp;
                        	if (phi1 <= -1.55e-5) {
                        		tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)));
                        	} else if (phi1 <= 19.0) {
                        		tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
                        	} else {
                        		tmp = atan2(t_1, (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)));
                        	}
                        	return tmp;
                        }
                        
                        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, lambda2, phi1, phi2)
                        use fmin_fmax_functions
                            real(8), intent (in) :: lambda1
                            real(8), intent (in) :: lambda2
                            real(8), intent (in) :: phi1
                            real(8), intent (in) :: phi2
                            real(8) :: t_0
                            real(8) :: t_1
                            real(8) :: tmp
                            t_0 = cos((lambda1 - lambda2))
                            t_1 = sin((lambda1 - lambda2)) * cos(phi2)
                            if (phi1 <= (-1.55d-5)) then
                                tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)))
                            else if (phi1 <= 19.0d0) then
                                tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2))
                            else
                                tmp = atan2(t_1, (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)))
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double lambda1, double lambda2, double phi1, double phi2) {
                        	double t_0 = Math.cos((lambda1 - lambda2));
                        	double t_1 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
                        	double tmp;
                        	if (phi1 <= -1.55e-5) {
                        		tmp = Math.atan2(t_1, ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * t_0)));
                        	} else if (phi1 <= 19.0) {
                        		tmp = Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2)))), Math.sin(phi2));
                        	} else {
                        		tmp = Math.atan2(t_1, (Math.sin(phi2) - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
                        	}
                        	return tmp;
                        }
                        
                        def code(lambda1, lambda2, phi1, phi2):
                        	t_0 = math.cos((lambda1 - lambda2))
                        	t_1 = math.sin((lambda1 - lambda2)) * math.cos(phi2)
                        	tmp = 0
                        	if phi1 <= -1.55e-5:
                        		tmp = math.atan2(t_1, ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * t_0)))
                        	elif phi1 <= 19.0:
                        		tmp = math.atan2((math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2)))), math.sin(phi2))
                        	else:
                        		tmp = math.atan2(t_1, (math.sin(phi2) - ((math.sin(phi1) * math.cos(phi2)) * t_0)))
                        	return tmp
                        
                        function code(lambda1, lambda2, phi1, phi2)
                        	t_0 = cos(Float64(lambda1 - lambda2))
                        	t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2))
                        	tmp = 0.0
                        	if (phi1 <= -1.55e-5)
                        		tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * t_0)));
                        	elseif (phi1 <= 19.0)
                        		tmp = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), sin(phi2));
                        	else
                        		tmp = atan(t_1, Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0)));
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(lambda1, lambda2, phi1, phi2)
                        	t_0 = cos((lambda1 - lambda2));
                        	t_1 = sin((lambda1 - lambda2)) * cos(phi2);
                        	tmp = 0.0;
                        	if (phi1 <= -1.55e-5)
                        		tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)));
                        	elseif (phi1 <= 19.0)
                        		tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
                        	else
                        		tmp = atan2(t_1, (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)));
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.55e-5], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 19.0], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
                        t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
                        \mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-5}:\\
                        \;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
                        
                        \mathbf{elif}\;\phi_1 \leq 19:\\
                        \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 3 regimes
                        2. if phi1 < -1.55000000000000007e-5

                          1. Initial program 76.0%

                            \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                          2. Taylor expanded in phi2 around 0

                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\sin \phi_1} \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                          3. Step-by-step derivation
                            1. lift-sin.f6450.5

                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                          4. Applied rewrites50.5%

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

                          if -1.55000000000000007e-5 < phi1 < 19

                          1. Initial program 81.5%

                            \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                          2. Taylor expanded in phi1 around 0

                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                          3. Step-by-step derivation
                            1. lift-sin.f6477.7

                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                          4. Applied rewrites77.7%

                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                          5. Taylor expanded in phi2 around 0

                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                          6. Step-by-step derivation
                            1. Applied rewrites48.9%

                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                            2. Taylor expanded in lambda1 around 0

                              \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \lambda_1 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right)\right)\right)} \cdot 1}{\sin \phi_2} \]
                            3. Step-by-step derivation
                              1. sin-diff-revN/A

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

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

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

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

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

                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                              7. associate-*r*N/A

                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\left(\frac{-1}{2} \cdot \lambda_1\right) \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                              8. metadata-evalN/A

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

                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                              10. metadata-evalN/A

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

                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                              12. sin-negN/A

                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                              13. lower-neg.f64N/A

                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                              14. lift-sin.f64N/A

                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                              15. lift-cos.f64N/A

                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                              16. sin-negN/A

                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\sin \phi_2} \]
                            4. Applied rewrites42.9%

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

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

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

                                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\color{blue}{\cos \lambda_2 \cdot \sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                              3. lower--.f64N/A

                                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1 \cdot \sin \lambda_2}\right)}{\sin \phi_2} \]
                              4. lower-*.f64N/A

                                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                              5. lift-cos.f64N/A

                                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \color{blue}{\lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                              6. lift-sin.f64N/A

                                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                              7. lift-cos.f64N/A

                                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \color{blue}{\lambda_2}\right)}{\sin \phi_2} \]
                              8. lift-sin.f64N/A

                                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                              9. lift-*.f6495.6

                                \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right)}{\sin \phi_2} \]
                            7. Applied rewrites95.6%

                              \[\leadsto \tan^{-1}_* \frac{\color{blue}{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\sin \phi_2} \]

                            if 19 < phi1

                            1. Initial program 77.3%

                              \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                            2. Taylor expanded in phi1 around 0

                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2} - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                            3. Step-by-step derivation
                              1. lift-sin.f6449.9

                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                            4. Applied rewrites49.9%

                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2} - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                          7. Recombined 3 regimes into one program.
                          8. Add Preprocessing

                          Alternative 20: 70.6% accurate, 1.1× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\ \mathbf{if}\;\lambda_2 \leq -2 \cdot 10^{+27}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\lambda_2 \leq 1.3 \cdot 10^{+122}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                          (FPCore (lambda1 lambda2 phi1 phi2)
                           :precision binary64
                           (let* ((t_0
                                   (atan2
                                    (*
                                     (cos phi2)
                                     (- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
                                    (sin phi2))))
                             (if (<= lambda2 -2e+27)
                               t_0
                               (if (<= lambda2 1.3e+122)
                                 (atan2
                                  (* (sin (- lambda1 lambda2)) (cos phi2))
                                  (- (sin phi2) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
                                 t_0))))
                          double code(double lambda1, double lambda2, double phi1, double phi2) {
                          	double t_0 = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
                          	double tmp;
                          	if (lambda2 <= -2e+27) {
                          		tmp = t_0;
                          	} else if (lambda2 <= 1.3e+122) {
                          		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
                          	} else {
                          		tmp = t_0;
                          	}
                          	return tmp;
                          }
                          
                          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, lambda2, phi1, phi2)
                          use fmin_fmax_functions
                              real(8), intent (in) :: lambda1
                              real(8), intent (in) :: lambda2
                              real(8), intent (in) :: phi1
                              real(8), intent (in) :: phi2
                              real(8) :: t_0
                              real(8) :: tmp
                              t_0 = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2))
                              if (lambda2 <= (-2d+27)) then
                                  tmp = t_0
                              else if (lambda2 <= 1.3d+122) then
                                  tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
                              else
                                  tmp = t_0
                              end if
                              code = tmp
                          end function
                          
                          public static double code(double lambda1, double lambda2, double phi1, double phi2) {
                          	double t_0 = Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2)))), Math.sin(phi2));
                          	double tmp;
                          	if (lambda2 <= -2e+27) {
                          		tmp = t_0;
                          	} else if (lambda2 <= 1.3e+122) {
                          		tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
                          	} else {
                          		tmp = t_0;
                          	}
                          	return tmp;
                          }
                          
                          def code(lambda1, lambda2, phi1, phi2):
                          	t_0 = math.atan2((math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2)))), math.sin(phi2))
                          	tmp = 0
                          	if lambda2 <= -2e+27:
                          		tmp = t_0
                          	elif lambda2 <= 1.3e+122:
                          		tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
                          	else:
                          		tmp = t_0
                          	return tmp
                          
                          function code(lambda1, lambda2, phi1, phi2)
                          	t_0 = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), sin(phi2))
                          	tmp = 0.0
                          	if (lambda2 <= -2e+27)
                          		tmp = t_0;
                          	elseif (lambda2 <= 1.3e+122)
                          		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))));
                          	else
                          		tmp = t_0;
                          	end
                          	return tmp
                          end
                          
                          function tmp_2 = code(lambda1, lambda2, phi1, phi2)
                          	t_0 = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
                          	tmp = 0.0;
                          	if (lambda2 <= -2e+27)
                          		tmp = t_0;
                          	elseif (lambda2 <= 1.3e+122)
                          		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
                          	else
                          		tmp = t_0;
                          	end
                          	tmp_2 = tmp;
                          end
                          
                          code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -2e+27], t$95$0, If[LessEqual[lambda2, 1.3e+122], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          t_0 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\
                          \mathbf{if}\;\lambda_2 \leq -2 \cdot 10^{+27}:\\
                          \;\;\;\;t\_0\\
                          
                          \mathbf{elif}\;\lambda_2 \leq 1.3 \cdot 10^{+122}:\\
                          \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;t\_0\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if lambda2 < -2e27 or 1.30000000000000004e122 < lambda2

                            1. Initial program 59.9%

                              \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                            2. Taylor expanded in phi1 around 0

                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                            3. Step-by-step derivation
                              1. lift-sin.f6439.9

                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                            4. Applied rewrites39.9%

                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                            5. Taylor expanded in phi2 around 0

                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                            6. Step-by-step derivation
                              1. Applied rewrites27.8%

                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                              2. Taylor expanded in lambda1 around 0

                                \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \lambda_1 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right)\right)\right)} \cdot 1}{\sin \phi_2} \]
                              3. Step-by-step derivation
                                1. sin-diff-revN/A

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

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

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

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

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

                                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                7. associate-*r*N/A

                                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\left(\frac{-1}{2} \cdot \lambda_1\right) \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                8. metadata-evalN/A

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

                                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                10. metadata-evalN/A

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

                                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                12. sin-negN/A

                                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                13. lower-neg.f64N/A

                                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                14. lift-sin.f64N/A

                                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                15. lift-cos.f64N/A

                                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                16. sin-negN/A

                                  \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\sin \phi_2} \]
                              4. Applied rewrites28.1%

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

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

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

                                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\color{blue}{\cos \lambda_2 \cdot \sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                3. lower--.f64N/A

                                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1 \cdot \sin \lambda_2}\right)}{\sin \phi_2} \]
                                4. lower-*.f64N/A

                                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                5. lift-cos.f64N/A

                                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \color{blue}{\lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                6. lift-sin.f64N/A

                                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                7. lift-cos.f64N/A

                                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \color{blue}{\lambda_2}\right)}{\sin \phi_2} \]
                                8. lift-sin.f64N/A

                                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                9. lift-*.f6460.3

                                  \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right)}{\sin \phi_2} \]
                              7. Applied rewrites60.3%

                                \[\leadsto \tan^{-1}_* \frac{\color{blue}{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\sin \phi_2} \]

                              if -2e27 < lambda2 < 1.30000000000000004e122

                              1. Initial program 90.9%

                                \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                              2. Taylor expanded in phi1 around 0

                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2} - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                              3. Step-by-step derivation
                                1. lift-sin.f6476.0

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                              4. Applied rewrites76.0%

                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2} - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                            7. Recombined 2 regimes into one program.
                            8. Add Preprocessing

                            Alternative 21: 70.0% accurate, 1.1× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \phi_1 \cdot \sin \phi_2\\ t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\ t_2 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\ \mathbf{if}\;\phi_2 \leq -0.0029:\\ \;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{t\_0 - \sin \phi_1 \cdot \cos \phi_2}\\ \mathbf{elif}\;\phi_2 \leq 0.021:\\ \;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot t\_2}{t\_0 - \left(\sin \phi_1 \cdot t\_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\ \end{array} \end{array} \]
                            (FPCore (lambda1 lambda2 phi1 phi2)
                             :precision binary64
                             (let* ((t_0 (* (cos phi1) (sin phi2)))
                                    (t_1 (sin (- lambda1 lambda2)))
                                    (t_2 (fma (* phi2 phi2) -0.5 1.0)))
                               (if (<= phi2 -0.0029)
                                 (atan2 (* t_1 (cos phi2)) (- t_0 (* (sin phi1) (cos phi2))))
                                 (if (<= phi2 0.021)
                                   (atan2
                                    (* t_1 t_2)
                                    (- t_0 (* (* (sin phi1) t_2) (cos (- lambda1 lambda2)))))
                                   (atan2
                                    (*
                                     (cos phi2)
                                     (- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
                                    (sin phi2))))))
                            double code(double lambda1, double lambda2, double phi1, double phi2) {
                            	double t_0 = cos(phi1) * sin(phi2);
                            	double t_1 = sin((lambda1 - lambda2));
                            	double t_2 = fma((phi2 * phi2), -0.5, 1.0);
                            	double tmp;
                            	if (phi2 <= -0.0029) {
                            		tmp = atan2((t_1 * cos(phi2)), (t_0 - (sin(phi1) * cos(phi2))));
                            	} else if (phi2 <= 0.021) {
                            		tmp = atan2((t_1 * t_2), (t_0 - ((sin(phi1) * t_2) * cos((lambda1 - lambda2)))));
                            	} else {
                            		tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
                            	}
                            	return tmp;
                            }
                            
                            function code(lambda1, lambda2, phi1, phi2)
                            	t_0 = Float64(cos(phi1) * sin(phi2))
                            	t_1 = sin(Float64(lambda1 - lambda2))
                            	t_2 = fma(Float64(phi2 * phi2), -0.5, 1.0)
                            	tmp = 0.0
                            	if (phi2 <= -0.0029)
                            		tmp = atan(Float64(t_1 * cos(phi2)), Float64(t_0 - Float64(sin(phi1) * cos(phi2))));
                            	elseif (phi2 <= 0.021)
                            		tmp = atan(Float64(t_1 * t_2), Float64(t_0 - Float64(Float64(sin(phi1) * t_2) * cos(Float64(lambda1 - lambda2)))));
                            	else
                            		tmp = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), sin(phi2));
                            	end
                            	return tmp
                            end
                            
                            code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, If[LessEqual[phi2, -0.0029], N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 0.021], N[ArcTan[N[(t$95$1 * t$95$2), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]]]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            t_0 := \cos \phi_1 \cdot \sin \phi_2\\
                            t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
                            t_2 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
                            \mathbf{if}\;\phi_2 \leq -0.0029:\\
                            \;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{t\_0 - \sin \phi_1 \cdot \cos \phi_2}\\
                            
                            \mathbf{elif}\;\phi_2 \leq 0.021:\\
                            \;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot t\_2}{t\_0 - \left(\sin \phi_1 \cdot t\_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 3 regimes
                            2. if phi2 < -0.0029

                              1. Initial program 76.2%

                                \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                              2. Taylor expanded in lambda1 around 0

                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\cos \phi_2 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right)}} \]
                              3. Step-by-step derivation
                                1. *-commutativeN/A

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

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right) \cdot \color{blue}{\cos \phi_2}} \]
                                3. lower-*.f64N/A

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \sin \phi_1\right) \cdot \cos \color{blue}{\phi_2}} \]
                                4. cos-negN/A

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                                5. lower-cos.f64N/A

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                                6. lift-sin.f64N/A

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                                7. lift-cos.f6466.5

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2} \]
                              4. Applied rewrites66.5%

                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \color{blue}{\left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}} \]
                              5. Taylor expanded in lambda2 around 0

                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \color{blue}{\phi_2}} \]
                              6. Step-by-step derivation
                                1. lift-sin.f6457.5

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \phi_2} \]
                              7. Applied rewrites57.5%

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

                              if -0.0029 < phi2 < 0.0210000000000000013

                              1. Initial program 81.6%

                                \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                              2. Taylor expanded in phi2 around 0

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

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

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

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

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                5. lower-*.f6481.5

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                              4. Applied rewrites81.5%

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

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

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

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

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

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                5. lower-*.f6481.5

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                              7. Applied rewrites81.5%

                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \color{blue}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]

                              if 0.0210000000000000013 < phi2

                              1. Initial program 77.1%

                                \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                              2. Taylor expanded in phi1 around 0

                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                              3. Step-by-step derivation
                                1. lift-sin.f6450.0

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                              4. Applied rewrites50.0%

                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                              5. Taylor expanded in phi2 around 0

                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                              6. Step-by-step derivation
                                1. Applied rewrites14.8%

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                2. Taylor expanded in lambda1 around 0

                                  \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \lambda_1 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right)\right)\right)} \cdot 1}{\sin \phi_2} \]
                                3. Step-by-step derivation
                                  1. sin-diff-revN/A

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

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

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

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

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

                                    \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                  7. associate-*r*N/A

                                    \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\left(\frac{-1}{2} \cdot \lambda_1\right) \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                  8. metadata-evalN/A

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

                                    \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                  10. metadata-evalN/A

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

                                    \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                  12. sin-negN/A

                                    \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                  13. lower-neg.f64N/A

                                    \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                  14. lift-sin.f64N/A

                                    \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                  15. lift-cos.f64N/A

                                    \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                  16. sin-negN/A

                                    \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\sin \phi_2} \]
                                4. Applied rewrites14.0%

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

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

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

                                    \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\color{blue}{\cos \lambda_2 \cdot \sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                  3. lower--.f64N/A

                                    \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1 \cdot \sin \lambda_2}\right)}{\sin \phi_2} \]
                                  4. lower-*.f64N/A

                                    \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                  5. lift-cos.f64N/A

                                    \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \color{blue}{\lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                  6. lift-sin.f64N/A

                                    \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                  7. lift-cos.f64N/A

                                    \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \color{blue}{\lambda_2}\right)}{\sin \phi_2} \]
                                  8. lift-sin.f64N/A

                                    \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                  9. lift-*.f6462.3

                                    \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right)}{\sin \phi_2} \]
                                7. Applied rewrites62.3%

                                  \[\leadsto \tan^{-1}_* \frac{\color{blue}{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\sin \phi_2} \]
                              7. Recombined 3 regimes into one program.
                              8. Add Preprocessing

                              Alternative 22: 69.7% accurate, 1.1× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\ t_1 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\ t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_1 \leq -9 \cdot 10^{-5}:\\ \;\;\;\;\tan^{-1}_* \frac{t\_2 \cdot \cos \phi_2}{-t\_0 \cdot \sin \phi_1}\\ \mathbf{elif}\;\phi_1 \leq 19:\\ \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{t\_2 \cdot t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot t\_1\right) \cdot t\_0}\\ \end{array} \end{array} \]
                              (FPCore (lambda1 lambda2 phi1 phi2)
                               :precision binary64
                               (let* ((t_0 (cos (- lambda1 lambda2)))
                                      (t_1 (fma (* phi2 phi2) -0.5 1.0))
                                      (t_2 (sin (- lambda1 lambda2))))
                                 (if (<= phi1 -9e-5)
                                   (atan2 (* t_2 (cos phi2)) (- (* t_0 (sin phi1))))
                                   (if (<= phi1 19.0)
                                     (atan2
                                      (*
                                       (cos phi2)
                                       (- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
                                      (sin phi2))
                                     (atan2
                                      (* t_2 t_1)
                                      (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) t_1) t_0)))))))
                              double code(double lambda1, double lambda2, double phi1, double phi2) {
                              	double t_0 = cos((lambda1 - lambda2));
                              	double t_1 = fma((phi2 * phi2), -0.5, 1.0);
                              	double t_2 = sin((lambda1 - lambda2));
                              	double tmp;
                              	if (phi1 <= -9e-5) {
                              		tmp = atan2((t_2 * cos(phi2)), -(t_0 * sin(phi1)));
                              	} else if (phi1 <= 19.0) {
                              		tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), sin(phi2));
                              	} else {
                              		tmp = atan2((t_2 * t_1), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * t_1) * t_0)));
                              	}
                              	return tmp;
                              }
                              
                              function code(lambda1, lambda2, phi1, phi2)
                              	t_0 = cos(Float64(lambda1 - lambda2))
                              	t_1 = fma(Float64(phi2 * phi2), -0.5, 1.0)
                              	t_2 = sin(Float64(lambda1 - lambda2))
                              	tmp = 0.0
                              	if (phi1 <= -9e-5)
                              		tmp = atan(Float64(t_2 * cos(phi2)), Float64(-Float64(t_0 * sin(phi1))));
                              	elseif (phi1 <= 19.0)
                              		tmp = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), sin(phi2));
                              	else
                              		tmp = atan(Float64(t_2 * t_1), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * t_1) * t_0)));
                              	end
                              	return tmp
                              end
                              
                              code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -9e-5], N[ArcTan[N[(t$95$2 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / (-N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision])], $MachinePrecision], If[LessEqual[phi1, 19.0], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$2 * t$95$1), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
                              t_1 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
                              t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
                              \mathbf{if}\;\phi_1 \leq -9 \cdot 10^{-5}:\\
                              \;\;\;\;\tan^{-1}_* \frac{t\_2 \cdot \cos \phi_2}{-t\_0 \cdot \sin \phi_1}\\
                              
                              \mathbf{elif}\;\phi_1 \leq 19:\\
                              \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2}\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\tan^{-1}_* \frac{t\_2 \cdot t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot t\_1\right) \cdot t\_0}\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 3 regimes
                              2. if phi1 < -9.00000000000000057e-5

                                1. Initial program 76.0%

                                  \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                2. Taylor expanded in phi2 around 0

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{-1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)}} \]
                                3. Step-by-step derivation
                                  1. mul-1-negN/A

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{neg}\left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)} \]
                                  2. lower-neg.f64N/A

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{-\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1} \]
                                  3. lower-*.f64N/A

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{-\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1} \]
                                  4. lift-cos.f64N/A

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{-\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1} \]
                                  5. lift--.f64N/A

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{-\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1} \]
                                  6. lift-sin.f6447.8

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{-\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1} \]
                                4. Applied rewrites47.8%

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

                                if -9.00000000000000057e-5 < phi1 < 19

                                1. Initial program 81.5%

                                  \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                2. Taylor expanded in phi1 around 0

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                3. Step-by-step derivation
                                  1. lift-sin.f6477.7

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                4. Applied rewrites77.7%

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                5. Taylor expanded in phi2 around 0

                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                6. Step-by-step derivation
                                  1. Applied rewrites48.9%

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                  2. Taylor expanded in lambda1 around 0

                                    \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \lambda_1 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right)\right)\right)} \cdot 1}{\sin \phi_2} \]
                                  3. Step-by-step derivation
                                    1. sin-diff-revN/A

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

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

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

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

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

                                      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                    7. associate-*r*N/A

                                      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\left(\frac{-1}{2} \cdot \lambda_1\right) \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                    8. metadata-evalN/A

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

                                      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                    10. metadata-evalN/A

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

                                      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                    12. sin-negN/A

                                      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                    13. lower-neg.f64N/A

                                      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                    14. lift-sin.f64N/A

                                      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                    15. lift-cos.f64N/A

                                      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                    16. sin-negN/A

                                      \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\sin \phi_2} \]
                                  4. Applied rewrites42.9%

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

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

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

                                      \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\color{blue}{\cos \lambda_2 \cdot \sin \lambda_1} - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                    3. lower--.f64N/A

                                      \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1 \cdot \sin \lambda_2}\right)}{\sin \phi_2} \]
                                    4. lower-*.f64N/A

                                      \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \color{blue}{\cos \lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                    5. lift-cos.f64N/A

                                      \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \color{blue}{\lambda_1} \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                    6. lift-sin.f64N/A

                                      \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                    7. lift-cos.f64N/A

                                      \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \color{blue}{\lambda_2}\right)}{\sin \phi_2} \]
                                    8. lift-sin.f64N/A

                                      \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2} \]
                                    9. lift-*.f6495.6

                                      \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \color{blue}{\sin \lambda_2}\right)}{\sin \phi_2} \]
                                  7. Applied rewrites95.6%

                                    \[\leadsto \tan^{-1}_* \frac{\color{blue}{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}}{\sin \phi_2} \]

                                  if 19 < phi1

                                  1. Initial program 77.3%

                                    \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                  2. Taylor expanded in phi2 around 0

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

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

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

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

                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                    5. lower-*.f6443.5

                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                  4. Applied rewrites43.5%

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

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

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

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

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

                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                    5. lower-*.f6444.7

                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                  7. Applied rewrites44.7%

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \color{blue}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                7. Recombined 3 regimes into one program.
                                8. Add Preprocessing

                                Alternative 23: 65.2% accurate, 1.2× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\ t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\ t_2 := \tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{\sin \phi_2}\\ \mathbf{if}\;\phi_2 \leq -0.0029:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;\phi_2 \leq 0.042:\\ \;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot t\_0}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot t\_0\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
                                (FPCore (lambda1 lambda2 phi1 phi2)
                                 :precision binary64
                                 (let* ((t_0 (fma (* phi2 phi2) -0.5 1.0))
                                        (t_1 (sin (- lambda1 lambda2)))
                                        (t_2 (atan2 (* t_1 (cos phi2)) (sin phi2))))
                                   (if (<= phi2 -0.0029)
                                     t_2
                                     (if (<= phi2 0.042)
                                       (atan2
                                        (* t_1 t_0)
                                        (-
                                         (* (cos phi1) (sin phi2))
                                         (* (* (sin phi1) t_0) (cos (- lambda1 lambda2)))))
                                       t_2))))
                                double code(double lambda1, double lambda2, double phi1, double phi2) {
                                	double t_0 = fma((phi2 * phi2), -0.5, 1.0);
                                	double t_1 = sin((lambda1 - lambda2));
                                	double t_2 = atan2((t_1 * cos(phi2)), sin(phi2));
                                	double tmp;
                                	if (phi2 <= -0.0029) {
                                		tmp = t_2;
                                	} else if (phi2 <= 0.042) {
                                		tmp = atan2((t_1 * t_0), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * t_0) * cos((lambda1 - lambda2)))));
                                	} else {
                                		tmp = t_2;
                                	}
                                	return tmp;
                                }
                                
                                function code(lambda1, lambda2, phi1, phi2)
                                	t_0 = fma(Float64(phi2 * phi2), -0.5, 1.0)
                                	t_1 = sin(Float64(lambda1 - lambda2))
                                	t_2 = atan(Float64(t_1 * cos(phi2)), sin(phi2))
                                	tmp = 0.0
                                	if (phi2 <= -0.0029)
                                		tmp = t_2;
                                	elseif (phi2 <= 0.042)
                                		tmp = atan(Float64(t_1 * t_0), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * t_0) * cos(Float64(lambda1 - lambda2)))));
                                	else
                                		tmp = t_2;
                                	end
                                	return tmp
                                end
                                
                                code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.0029], t$95$2, If[LessEqual[phi2, 0.042], N[ArcTan[N[(t$95$1 * t$95$0), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
                                t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
                                t_2 := \tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{\sin \phi_2}\\
                                \mathbf{if}\;\phi_2 \leq -0.0029:\\
                                \;\;\;\;t\_2\\
                                
                                \mathbf{elif}\;\phi_2 \leq 0.042:\\
                                \;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot t\_0}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot t\_0\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;t\_2\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if phi2 < -0.0029 or 0.0420000000000000026 < phi2

                                  1. Initial program 76.7%

                                    \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                  2. Taylor expanded in phi1 around 0

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                  3. Step-by-step derivation
                                    1. lift-sin.f6449.0

                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                  4. Applied rewrites49.0%

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]

                                  if -0.0029 < phi2 < 0.0420000000000000026

                                  1. Initial program 81.6%

                                    \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                  2. Taylor expanded in phi2 around 0

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

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

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

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

                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                    5. lower-*.f6481.5

                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                  4. Applied rewrites81.5%

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

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

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

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

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

                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                    5. lower-*.f6481.5

                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                  7. Applied rewrites81.5%

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \color{blue}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                3. Recombined 2 regimes into one program.
                                4. Add Preprocessing

                                Alternative 24: 65.1% accurate, 1.5× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\ t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\ \mathbf{if}\;\phi_2 \leq -0.0175:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\phi_2 \leq 0.013:\\ \;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot 1}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
                                (FPCore (lambda1 lambda2 phi1 phi2)
                                 :precision binary64
                                 (let* ((t_0 (sin (- lambda1 lambda2)))
                                        (t_1 (atan2 (* t_0 (cos phi2)) (sin phi2))))
                                   (if (<= phi2 -0.0175)
                                     t_1
                                     (if (<= phi2 0.013)
                                       (atan2
                                        (* t_0 1.0)
                                        (- (* phi2 (cos phi1)) (* (cos (- lambda1 lambda2)) (sin phi1))))
                                       t_1))))
                                double code(double lambda1, double lambda2, double phi1, double phi2) {
                                	double t_0 = sin((lambda1 - lambda2));
                                	double t_1 = atan2((t_0 * cos(phi2)), sin(phi2));
                                	double tmp;
                                	if (phi2 <= -0.0175) {
                                		tmp = t_1;
                                	} else if (phi2 <= 0.013) {
                                		tmp = atan2((t_0 * 1.0), ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1))));
                                	} else {
                                		tmp = t_1;
                                	}
                                	return tmp;
                                }
                                
                                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, lambda2, phi1, phi2)
                                use fmin_fmax_functions
                                    real(8), intent (in) :: lambda1
                                    real(8), intent (in) :: lambda2
                                    real(8), intent (in) :: phi1
                                    real(8), intent (in) :: phi2
                                    real(8) :: t_0
                                    real(8) :: t_1
                                    real(8) :: tmp
                                    t_0 = sin((lambda1 - lambda2))
                                    t_1 = atan2((t_0 * cos(phi2)), sin(phi2))
                                    if (phi2 <= (-0.0175d0)) then
                                        tmp = t_1
                                    else if (phi2 <= 0.013d0) then
                                        tmp = atan2((t_0 * 1.0d0), ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1))))
                                    else
                                        tmp = t_1
                                    end if
                                    code = tmp
                                end function
                                
                                public static double code(double lambda1, double lambda2, double phi1, double phi2) {
                                	double t_0 = Math.sin((lambda1 - lambda2));
                                	double t_1 = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
                                	double tmp;
                                	if (phi2 <= -0.0175) {
                                		tmp = t_1;
                                	} else if (phi2 <= 0.013) {
                                		tmp = Math.atan2((t_0 * 1.0), ((phi2 * Math.cos(phi1)) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
                                	} else {
                                		tmp = t_1;
                                	}
                                	return tmp;
                                }
                                
                                def code(lambda1, lambda2, phi1, phi2):
                                	t_0 = math.sin((lambda1 - lambda2))
                                	t_1 = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2))
                                	tmp = 0
                                	if phi2 <= -0.0175:
                                		tmp = t_1
                                	elif phi2 <= 0.013:
                                		tmp = math.atan2((t_0 * 1.0), ((phi2 * math.cos(phi1)) - (math.cos((lambda1 - lambda2)) * math.sin(phi1))))
                                	else:
                                		tmp = t_1
                                	return tmp
                                
                                function code(lambda1, lambda2, phi1, phi2)
                                	t_0 = sin(Float64(lambda1 - lambda2))
                                	t_1 = atan(Float64(t_0 * cos(phi2)), sin(phi2))
                                	tmp = 0.0
                                	if (phi2 <= -0.0175)
                                		tmp = t_1;
                                	elseif (phi2 <= 0.013)
                                		tmp = atan(Float64(t_0 * 1.0), Float64(Float64(phi2 * cos(phi1)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1))));
                                	else
                                		tmp = t_1;
                                	end
                                	return tmp
                                end
                                
                                function tmp_2 = code(lambda1, lambda2, phi1, phi2)
                                	t_0 = sin((lambda1 - lambda2));
                                	t_1 = atan2((t_0 * cos(phi2)), sin(phi2));
                                	tmp = 0.0;
                                	if (phi2 <= -0.0175)
                                		tmp = t_1;
                                	elseif (phi2 <= 0.013)
                                		tmp = atan2((t_0 * 1.0), ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1))));
                                	else
                                		tmp = t_1;
                                	end
                                	tmp_2 = tmp;
                                end
                                
                                code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.0175], t$95$1, If[LessEqual[phi2, 0.013], N[ArcTan[N[(t$95$0 * 1.0), $MachinePrecision] / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
                                t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
                                \mathbf{if}\;\phi_2 \leq -0.0175:\\
                                \;\;\;\;t\_1\\
                                
                                \mathbf{elif}\;\phi_2 \leq 0.013:\\
                                \;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot 1}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;t\_1\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if phi2 < -0.017500000000000002 or 0.0129999999999999994 < phi2

                                  1. Initial program 76.7%

                                    \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                  2. Taylor expanded in phi1 around 0

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                  3. Step-by-step derivation
                                    1. lift-sin.f6449.0

                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                  4. Applied rewrites49.0%

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]

                                  if -0.017500000000000002 < phi2 < 0.0129999999999999994

                                  1. Initial program 81.6%

                                    \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                  2. Taylor expanded in phi1 around 0

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                  3. Step-by-step derivation
                                    1. lift-sin.f6449.5

                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                  4. Applied rewrites49.5%

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                  5. Taylor expanded in phi2 around 0

                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                  6. Step-by-step derivation
                                    1. Applied rewrites49.3%

                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                    2. Taylor expanded in phi2 around 0

                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2} \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites49.3%

                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2} \]
                                      2. Taylor expanded in phi2 around 0

                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\color{blue}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}} \]
                                      3. Step-by-step derivation
                                        1. sin-+PI/2-revN/A

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1} \]
                                        2. lower--.f64N/A

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

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

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1} \]
                                        5. lower-*.f64N/A

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

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

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1} \]
                                        8. lift-sin.f6481.4

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1} \]
                                      4. Applied rewrites81.4%

                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\color{blue}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}} \]
                                    4. Recombined 2 regimes into one program.
                                    5. Add Preprocessing

                                    Alternative 25: 64.6% accurate, 1.6× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\ t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\ t_2 := \tan^{-1}_* \frac{t\_1}{-t\_0 \cdot \sin \phi_1}\\ \mathbf{if}\;\phi_1 \leq -0.039:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;\phi_1 \leq 19:\\ \;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(-t\_0, \phi_1, \sin \phi_2\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
                                    (FPCore (lambda1 lambda2 phi1 phi2)
                                     :precision binary64
                                     (let* ((t_0 (cos (- lambda1 lambda2)))
                                            (t_1 (* (sin (- lambda1 lambda2)) (cos phi2)))
                                            (t_2 (atan2 t_1 (- (* t_0 (sin phi1))))))
                                       (if (<= phi1 -0.039)
                                         t_2
                                         (if (<= phi1 19.0) (atan2 t_1 (fma (- t_0) phi1 (sin phi2))) t_2))))
                                    double code(double lambda1, double lambda2, double phi1, double phi2) {
                                    	double t_0 = cos((lambda1 - lambda2));
                                    	double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
                                    	double t_2 = atan2(t_1, -(t_0 * sin(phi1)));
                                    	double tmp;
                                    	if (phi1 <= -0.039) {
                                    		tmp = t_2;
                                    	} else if (phi1 <= 19.0) {
                                    		tmp = atan2(t_1, fma(-t_0, phi1, sin(phi2)));
                                    	} else {
                                    		tmp = t_2;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    function code(lambda1, lambda2, phi1, phi2)
                                    	t_0 = cos(Float64(lambda1 - lambda2))
                                    	t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2))
                                    	t_2 = atan(t_1, Float64(-Float64(t_0 * sin(phi1))))
                                    	tmp = 0.0
                                    	if (phi1 <= -0.039)
                                    		tmp = t_2;
                                    	elseif (phi1 <= 19.0)
                                    		tmp = atan(t_1, fma(Float64(-t_0), phi1, sin(phi2)));
                                    	else
                                    		tmp = t_2;
                                    	end
                                    	return tmp
                                    end
                                    
                                    code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[t$95$1 / (-N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision])], $MachinePrecision]}, If[LessEqual[phi1, -0.039], t$95$2, If[LessEqual[phi1, 19.0], N[ArcTan[t$95$1 / N[((-t$95$0) * phi1 + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    \begin{array}{l}
                                    t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
                                    t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
                                    t_2 := \tan^{-1}_* \frac{t\_1}{-t\_0 \cdot \sin \phi_1}\\
                                    \mathbf{if}\;\phi_1 \leq -0.039:\\
                                    \;\;\;\;t\_2\\
                                    
                                    \mathbf{elif}\;\phi_1 \leq 19:\\
                                    \;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(-t\_0, \phi_1, \sin \phi_2\right)}\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;t\_2\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if phi1 < -0.0389999999999999999 or 19 < phi1

                                      1. Initial program 76.7%

                                        \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                      2. Taylor expanded in phi2 around 0

                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{-1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)}} \]
                                      3. Step-by-step derivation
                                        1. mul-1-negN/A

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{neg}\left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)} \]
                                        2. lower-neg.f64N/A

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{-\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1} \]
                                        3. lower-*.f64N/A

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{-\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1} \]
                                        4. lift-cos.f64N/A

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{-\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1} \]
                                        5. lift--.f64N/A

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{-\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1} \]
                                        6. lift-sin.f6447.7

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{-\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1} \]
                                      4. Applied rewrites47.7%

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

                                      if -0.0389999999999999999 < phi1 < 19

                                      1. Initial program 81.4%

                                        \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                      2. Taylor expanded in phi1 around 0

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

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

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

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\frac{-1}{2} \cdot \left(\phi_1 \cdot \sin \phi_2\right) - \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right), \color{blue}{\phi_1}, \sin \phi_2\right)} \]
                                      4. Applied rewrites81.1%

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

                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-1 \cdot \cos \left(\lambda_1 - \lambda_2\right), \phi_1, \sin \phi_2\right)} \]
                                      6. Step-by-step derivation
                                        1. mul-1-negN/A

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

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-\cos \left(\lambda_1 - \lambda_2\right), \phi_1, \sin \phi_2\right)} \]
                                        3. lift-cos.f64N/A

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-\cos \left(\lambda_1 - \lambda_2\right), \phi_1, \sin \phi_2\right)} \]
                                        4. lift--.f6480.8

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-\cos \left(\lambda_1 - \lambda_2\right), \phi_1, \sin \phi_2\right)} \]
                                      7. Applied rewrites80.8%

                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-\cos \left(\lambda_1 - \lambda_2\right), \phi_1, \sin \phi_2\right)} \]
                                    3. Recombined 2 regimes into one program.
                                    4. Add Preprocessing

                                    Alternative 26: 63.5% accurate, 1.9× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\ t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\ \mathbf{if}\;\phi_2 \leq -0.003:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\phi_2 \leq 6.2 \cdot 10^{-15}:\\ \;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot 1}{-1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
                                    (FPCore (lambda1 lambda2 phi1 phi2)
                                     :precision binary64
                                     (let* ((t_0 (sin (- lambda1 lambda2)))
                                            (t_1 (atan2 (* t_0 (cos phi2)) (sin phi2))))
                                       (if (<= phi2 -0.003)
                                         t_1
                                         (if (<= phi2 6.2e-15)
                                           (atan2 (* t_0 1.0) (* -1.0 (* (cos (- lambda1 lambda2)) (sin phi1))))
                                           t_1))))
                                    double code(double lambda1, double lambda2, double phi1, double phi2) {
                                    	double t_0 = sin((lambda1 - lambda2));
                                    	double t_1 = atan2((t_0 * cos(phi2)), sin(phi2));
                                    	double tmp;
                                    	if (phi2 <= -0.003) {
                                    		tmp = t_1;
                                    	} else if (phi2 <= 6.2e-15) {
                                    		tmp = atan2((t_0 * 1.0), (-1.0 * (cos((lambda1 - lambda2)) * sin(phi1))));
                                    	} else {
                                    		tmp = t_1;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    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, lambda2, phi1, phi2)
                                    use fmin_fmax_functions
                                        real(8), intent (in) :: lambda1
                                        real(8), intent (in) :: lambda2
                                        real(8), intent (in) :: phi1
                                        real(8), intent (in) :: phi2
                                        real(8) :: t_0
                                        real(8) :: t_1
                                        real(8) :: tmp
                                        t_0 = sin((lambda1 - lambda2))
                                        t_1 = atan2((t_0 * cos(phi2)), sin(phi2))
                                        if (phi2 <= (-0.003d0)) then
                                            tmp = t_1
                                        else if (phi2 <= 6.2d-15) then
                                            tmp = atan2((t_0 * 1.0d0), ((-1.0d0) * (cos((lambda1 - lambda2)) * sin(phi1))))
                                        else
                                            tmp = t_1
                                        end if
                                        code = tmp
                                    end function
                                    
                                    public static double code(double lambda1, double lambda2, double phi1, double phi2) {
                                    	double t_0 = Math.sin((lambda1 - lambda2));
                                    	double t_1 = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
                                    	double tmp;
                                    	if (phi2 <= -0.003) {
                                    		tmp = t_1;
                                    	} else if (phi2 <= 6.2e-15) {
                                    		tmp = Math.atan2((t_0 * 1.0), (-1.0 * (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
                                    	} else {
                                    		tmp = t_1;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    def code(lambda1, lambda2, phi1, phi2):
                                    	t_0 = math.sin((lambda1 - lambda2))
                                    	t_1 = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2))
                                    	tmp = 0
                                    	if phi2 <= -0.003:
                                    		tmp = t_1
                                    	elif phi2 <= 6.2e-15:
                                    		tmp = math.atan2((t_0 * 1.0), (-1.0 * (math.cos((lambda1 - lambda2)) * math.sin(phi1))))
                                    	else:
                                    		tmp = t_1
                                    	return tmp
                                    
                                    function code(lambda1, lambda2, phi1, phi2)
                                    	t_0 = sin(Float64(lambda1 - lambda2))
                                    	t_1 = atan(Float64(t_0 * cos(phi2)), sin(phi2))
                                    	tmp = 0.0
                                    	if (phi2 <= -0.003)
                                    		tmp = t_1;
                                    	elseif (phi2 <= 6.2e-15)
                                    		tmp = atan(Float64(t_0 * 1.0), Float64(-1.0 * Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1))));
                                    	else
                                    		tmp = t_1;
                                    	end
                                    	return tmp
                                    end
                                    
                                    function tmp_2 = code(lambda1, lambda2, phi1, phi2)
                                    	t_0 = sin((lambda1 - lambda2));
                                    	t_1 = atan2((t_0 * cos(phi2)), sin(phi2));
                                    	tmp = 0.0;
                                    	if (phi2 <= -0.003)
                                    		tmp = t_1;
                                    	elseif (phi2 <= 6.2e-15)
                                    		tmp = atan2((t_0 * 1.0), (-1.0 * (cos((lambda1 - lambda2)) * sin(phi1))));
                                    	else
                                    		tmp = t_1;
                                    	end
                                    	tmp_2 = tmp;
                                    end
                                    
                                    code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.003], t$95$1, If[LessEqual[phi2, 6.2e-15], N[ArcTan[N[(t$95$0 * 1.0), $MachinePrecision] / N[(-1.0 * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    \begin{array}{l}
                                    t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
                                    t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
                                    \mathbf{if}\;\phi_2 \leq -0.003:\\
                                    \;\;\;\;t\_1\\
                                    
                                    \mathbf{elif}\;\phi_2 \leq 6.2 \cdot 10^{-15}:\\
                                    \;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot 1}{-1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)}\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;t\_1\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if phi2 < -0.0030000000000000001 or 6.1999999999999998e-15 < phi2

                                      1. Initial program 76.7%

                                        \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                      2. Taylor expanded in phi1 around 0

                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                      3. Step-by-step derivation
                                        1. lift-sin.f6449.1

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                      4. Applied rewrites49.1%

                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]

                                      if -0.0030000000000000001 < phi2 < 6.1999999999999998e-15

                                      1. Initial program 81.6%

                                        \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                      2. Taylor expanded in phi1 around 0

                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                      3. Step-by-step derivation
                                        1. lift-sin.f6449.4

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                      4. Applied rewrites49.4%

                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                      5. Taylor expanded in phi2 around 0

                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                      6. Step-by-step derivation
                                        1. Applied rewrites49.4%

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                        2. Taylor expanded in phi2 around 0

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2} \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites49.4%

                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2} \]
                                          2. Taylor expanded in phi2 around 0

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

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

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

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

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

                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{-1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)} \]
                                            6. lift-sin.f6478.5

                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{-1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)} \]
                                          4. Applied rewrites78.5%

                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\color{blue}{-1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)}} \]
                                        4. Recombined 2 regimes into one program.
                                        5. Add Preprocessing

                                        Alternative 27: 49.2% accurate, 2.2× speedup?

                                        \[\begin{array}{l} \\ \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \end{array} \]
                                        (FPCore (lambda1 lambda2 phi1 phi2)
                                         :precision binary64
                                         (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (sin phi2)))
                                        double code(double lambda1, double lambda2, double phi1, double phi2) {
                                        	return atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2));
                                        }
                                        
                                        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, lambda2, phi1, phi2)
                                        use fmin_fmax_functions
                                            real(8), intent (in) :: lambda1
                                            real(8), intent (in) :: lambda2
                                            real(8), intent (in) :: phi1
                                            real(8), intent (in) :: phi2
                                            code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2))
                                        end function
                                        
                                        public static double code(double lambda1, double lambda2, double phi1, double phi2) {
                                        	return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), Math.sin(phi2));
                                        }
                                        
                                        def code(lambda1, lambda2, phi1, phi2):
                                        	return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), math.sin(phi2))
                                        
                                        function code(lambda1, lambda2, phi1, phi2)
                                        	return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), sin(phi2))
                                        end
                                        
                                        function tmp = code(lambda1, lambda2, phi1, phi2)
                                        	tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2));
                                        end
                                        
                                        code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
                                        
                                        \begin{array}{l}
                                        
                                        \\
                                        \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}
                                        \end{array}
                                        
                                        Derivation
                                        1. Initial program 79.1%

                                          \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                        2. Taylor expanded in phi1 around 0

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                        3. Step-by-step derivation
                                          1. lift-sin.f6449.2

                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                        4. Applied rewrites49.2%

                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                        5. Add Preprocessing

                                        Alternative 28: 44.4% accurate, 2.1× speedup?

                                        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\ \mathbf{if}\;\lambda_1 \leq -1.3:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\lambda_1 \leq 1.55 \cdot 10^{-40}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                                        (FPCore (lambda1 lambda2 phi1 phi2)
                                         :precision binary64
                                         (let* ((t_0 (atan2 (* (sin lambda1) (cos phi2)) (sin phi2))))
                                           (if (<= lambda1 -1.3)
                                             t_0
                                             (if (<= lambda1 1.55e-40)
                                               (atan2 (* (sin (- lambda2)) (cos phi2)) (sin phi2))
                                               t_0))))
                                        double code(double lambda1, double lambda2, double phi1, double phi2) {
                                        	double t_0 = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
                                        	double tmp;
                                        	if (lambda1 <= -1.3) {
                                        		tmp = t_0;
                                        	} else if (lambda1 <= 1.55e-40) {
                                        		tmp = atan2((sin(-lambda2) * cos(phi2)), sin(phi2));
                                        	} else {
                                        		tmp = t_0;
                                        	}
                                        	return tmp;
                                        }
                                        
                                        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, lambda2, phi1, phi2)
                                        use fmin_fmax_functions
                                            real(8), intent (in) :: lambda1
                                            real(8), intent (in) :: lambda2
                                            real(8), intent (in) :: phi1
                                            real(8), intent (in) :: phi2
                                            real(8) :: t_0
                                            real(8) :: tmp
                                            t_0 = atan2((sin(lambda1) * cos(phi2)), sin(phi2))
                                            if (lambda1 <= (-1.3d0)) then
                                                tmp = t_0
                                            else if (lambda1 <= 1.55d-40) then
                                                tmp = atan2((sin(-lambda2) * cos(phi2)), sin(phi2))
                                            else
                                                tmp = t_0
                                            end if
                                            code = tmp
                                        end function
                                        
                                        public static double code(double lambda1, double lambda2, double phi1, double phi2) {
                                        	double t_0 = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), Math.sin(phi2));
                                        	double tmp;
                                        	if (lambda1 <= -1.3) {
                                        		tmp = t_0;
                                        	} else if (lambda1 <= 1.55e-40) {
                                        		tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), Math.sin(phi2));
                                        	} else {
                                        		tmp = t_0;
                                        	}
                                        	return tmp;
                                        }
                                        
                                        def code(lambda1, lambda2, phi1, phi2):
                                        	t_0 = math.atan2((math.sin(lambda1) * math.cos(phi2)), math.sin(phi2))
                                        	tmp = 0
                                        	if lambda1 <= -1.3:
                                        		tmp = t_0
                                        	elif lambda1 <= 1.55e-40:
                                        		tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), math.sin(phi2))
                                        	else:
                                        		tmp = t_0
                                        	return tmp
                                        
                                        function code(lambda1, lambda2, phi1, phi2)
                                        	t_0 = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2))
                                        	tmp = 0.0
                                        	if (lambda1 <= -1.3)
                                        		tmp = t_0;
                                        	elseif (lambda1 <= 1.55e-40)
                                        		tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), sin(phi2));
                                        	else
                                        		tmp = t_0;
                                        	end
                                        	return tmp
                                        end
                                        
                                        function tmp_2 = code(lambda1, lambda2, phi1, phi2)
                                        	t_0 = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
                                        	tmp = 0.0;
                                        	if (lambda1 <= -1.3)
                                        		tmp = t_0;
                                        	elseif (lambda1 <= 1.55e-40)
                                        		tmp = atan2((sin(-lambda2) * cos(phi2)), sin(phi2));
                                        	else
                                        		tmp = t_0;
                                        	end
                                        	tmp_2 = tmp;
                                        end
                                        
                                        code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -1.3], t$95$0, If[LessEqual[lambda1, 1.55e-40], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
                                        
                                        \begin{array}{l}
                                        
                                        \\
                                        \begin{array}{l}
                                        t_0 := \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
                                        \mathbf{if}\;\lambda_1 \leq -1.3:\\
                                        \;\;\;\;t\_0\\
                                        
                                        \mathbf{elif}\;\lambda_1 \leq 1.55 \cdot 10^{-40}:\\
                                        \;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
                                        
                                        \mathbf{else}:\\
                                        \;\;\;\;t\_0\\
                                        
                                        
                                        \end{array}
                                        \end{array}
                                        
                                        Derivation
                                        1. Split input into 2 regimes
                                        2. if lambda1 < -1.30000000000000004 or 1.55000000000000005e-40 < lambda1

                                          1. Initial program 60.5%

                                            \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                          2. Taylor expanded in phi1 around 0

                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                          3. Step-by-step derivation
                                            1. lift-sin.f6440.7

                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                          4. Applied rewrites40.7%

                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                          5. Taylor expanded in lambda1 around inf

                                            \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\lambda_1} \cdot \cos \phi_2}{\sin \phi_2} \]
                                          6. Step-by-step derivation
                                            1. Applied rewrites39.4%

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

                                            if -1.30000000000000004 < lambda1 < 1.55000000000000005e-40

                                            1. Initial program 99.3%

                                              \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                            2. Taylor expanded in phi1 around 0

                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                            3. Step-by-step derivation
                                              1. lift-sin.f6458.5

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                            4. Applied rewrites58.5%

                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                            5. Taylor expanded in lambda1 around 0

                                              \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\left(-1 \cdot \lambda_2\right)} \cdot \cos \phi_2}{\sin \phi_2} \]
                                            6. Step-by-step derivation
                                              1. mul-1-negN/A

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                              2. lower-neg.f6449.8

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                            7. Applied rewrites49.8%

                                              \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\left(-\lambda_2\right)} \cdot \cos \phi_2}{\sin \phi_2} \]
                                          7. Recombined 2 regimes into one program.
                                          8. Add Preprocessing

                                          Alternative 29: 38.7% accurate, 2.2× speedup?

                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq 1.75 \cdot 10^{+16}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.008333333333333333 - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\ \end{array} \end{array} \]
                                          (FPCore (lambda1 lambda2 phi1 phi2)
                                           :precision binary64
                                           (if (<= phi2 1.75e+16)
                                             (atan2
                                              (* (sin (- lambda1 lambda2)) (cos phi2))
                                              (*
                                               (fma
                                                (- (* (* phi2 phi2) 0.008333333333333333) 0.16666666666666666)
                                                (* phi2 phi2)
                                                1.0)
                                               phi2))
                                             (atan2 (* (sin lambda1) (cos phi2)) (sin phi2))))
                                          double code(double lambda1, double lambda2, double phi1, double phi2) {
                                          	double tmp;
                                          	if (phi2 <= 1.75e+16) {
                                          		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (fma((((phi2 * phi2) * 0.008333333333333333) - 0.16666666666666666), (phi2 * phi2), 1.0) * phi2));
                                          	} else {
                                          		tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
                                          	}
                                          	return tmp;
                                          }
                                          
                                          function code(lambda1, lambda2, phi1, phi2)
                                          	tmp = 0.0
                                          	if (phi2 <= 1.75e+16)
                                          		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(fma(Float64(Float64(Float64(phi2 * phi2) * 0.008333333333333333) - 0.16666666666666666), Float64(phi2 * phi2), 1.0) * phi2));
                                          	else
                                          		tmp = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2));
                                          	end
                                          	return tmp
                                          end
                                          
                                          code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 1.75e+16], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * 0.008333333333333333), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          \begin{array}{l}
                                          \mathbf{if}\;\phi_2 \leq 1.75 \cdot 10^{+16}:\\
                                          \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.008333333333333333 - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2}\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
                                          
                                          
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 2 regimes
                                          2. if phi2 < 1.75e16

                                            1. Initial program 79.8%

                                              \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                            2. Taylor expanded in phi1 around 0

                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                            3. Step-by-step derivation
                                              1. lift-sin.f6449.0

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                            4. Applied rewrites49.0%

                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                            5. Taylor expanded in phi2 around 0

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

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(1 + {\phi_2}^{2} \cdot \left(\frac{1}{120} \cdot {\phi_2}^{2} - \frac{1}{6}\right)\right) \cdot \phi_2} \]
                                              2. lower-*.f64N/A

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(1 + {\phi_2}^{2} \cdot \left(\frac{1}{120} \cdot {\phi_2}^{2} - \frac{1}{6}\right)\right) \cdot \phi_2} \]
                                              3. +-commutativeN/A

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left({\phi_2}^{2} \cdot \left(\frac{1}{120} \cdot {\phi_2}^{2} - \frac{1}{6}\right) + 1\right) \cdot \phi_2} \]
                                              4. *-commutativeN/A

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(\left(\frac{1}{120} \cdot {\phi_2}^{2} - \frac{1}{6}\right) \cdot {\phi_2}^{2} + 1\right) \cdot \phi_2} \]
                                              5. lower-fma.f64N/A

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\frac{1}{120} \cdot {\phi_2}^{2} - \frac{1}{6}, {\phi_2}^{2}, 1\right) \cdot \phi_2} \]
                                              6. lower--.f64N/A

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\frac{1}{120} \cdot {\phi_2}^{2} - \frac{1}{6}, {\phi_2}^{2}, 1\right) \cdot \phi_2} \]
                                              7. *-commutativeN/A

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left({\phi_2}^{2} \cdot \frac{1}{120} - \frac{1}{6}, {\phi_2}^{2}, 1\right) \cdot \phi_2} \]
                                              8. lower-*.f64N/A

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left({\phi_2}^{2} \cdot \frac{1}{120} - \frac{1}{6}, {\phi_2}^{2}, 1\right) \cdot \phi_2} \]
                                              9. unpow2N/A

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot \frac{1}{120} - \frac{1}{6}, {\phi_2}^{2}, 1\right) \cdot \phi_2} \]
                                              10. lower-*.f64N/A

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot \frac{1}{120} - \frac{1}{6}, {\phi_2}^{2}, 1\right) \cdot \phi_2} \]
                                              11. unpow2N/A

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot \frac{1}{120} - \frac{1}{6}, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2} \]
                                              12. lower-*.f6441.1

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.008333333333333333 - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2} \]
                                            7. Applied rewrites41.1%

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

                                            if 1.75e16 < phi2

                                            1. Initial program 77.0%

                                              \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                            2. Taylor expanded in phi1 around 0

                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                            3. Step-by-step derivation
                                              1. lift-sin.f6450.0

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                            4. Applied rewrites50.0%

                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                            5. Taylor expanded in lambda1 around inf

                                              \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\lambda_1} \cdot \cos \phi_2}{\sin \phi_2} \]
                                            6. Step-by-step derivation
                                              1. Applied rewrites30.6%

                                                \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\lambda_1} \cdot \cos \phi_2}{\sin \phi_2} \]
                                            7. Recombined 2 regimes into one program.
                                            8. Add Preprocessing

                                            Alternative 30: 37.9% accurate, 2.2× speedup?

                                            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\ \mathbf{if}\;\phi_2 \leq -3.7:\\ \;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2}\\ \end{array} \end{array} \]
                                            (FPCore (lambda1 lambda2 phi1 phi2)
                                             :precision binary64
                                             (let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
                                               (if (<= phi2 -3.7)
                                                 (atan2 t_0 phi2)
                                                 (atan2
                                                  t_0
                                                  (*
                                                   (fma
                                                    (-
                                                     (*
                                                      (fma (* phi2 phi2) -0.0001984126984126984 0.008333333333333333)
                                                      (* phi2 phi2))
                                                     0.16666666666666666)
                                                    (* phi2 phi2)
                                                    1.0)
                                                   phi2)))))
                                            double code(double lambda1, double lambda2, double phi1, double phi2) {
                                            	double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
                                            	double tmp;
                                            	if (phi2 <= -3.7) {
                                            		tmp = atan2(t_0, phi2);
                                            	} else {
                                            		tmp = atan2(t_0, (fma(((fma((phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * (phi2 * phi2)) - 0.16666666666666666), (phi2 * phi2), 1.0) * phi2));
                                            	}
                                            	return tmp;
                                            }
                                            
                                            function code(lambda1, lambda2, phi1, phi2)
                                            	t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2))
                                            	tmp = 0.0
                                            	if (phi2 <= -3.7)
                                            		tmp = atan(t_0, phi2);
                                            	else
                                            		tmp = atan(t_0, Float64(fma(Float64(Float64(fma(Float64(phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * Float64(phi2 * phi2)) - 0.16666666666666666), Float64(phi2 * phi2), 1.0) * phi2));
                                            	end
                                            	return tmp
                                            end
                                            
                                            code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -3.7], N[ArcTan[t$95$0 / phi2], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]]
                                            
                                            \begin{array}{l}
                                            
                                            \\
                                            \begin{array}{l}
                                            t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
                                            \mathbf{if}\;\phi_2 \leq -3.7:\\
                                            \;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2}\\
                                            
                                            \mathbf{else}:\\
                                            \;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2}\\
                                            
                                            
                                            \end{array}
                                            \end{array}
                                            
                                            Derivation
                                            1. Split input into 2 regimes
                                            2. if phi2 < -3.7000000000000002

                                              1. Initial program 76.1%

                                                \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                              2. Taylor expanded in phi1 around 0

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                              3. Step-by-step derivation
                                                1. lift-sin.f6447.9

                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                              4. Applied rewrites47.9%

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                              5. Taylor expanded in phi2 around 0

                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2} \]
                                              6. Step-by-step derivation
                                                1. Applied rewrites26.1%

                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2} \]

                                                if -3.7000000000000002 < phi2

                                                1. Initial program 80.1%

                                                  \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                2. Taylor expanded in phi1 around 0

                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                3. Step-by-step derivation
                                                  1. lift-sin.f6449.7

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                4. Applied rewrites49.7%

                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                5. Taylor expanded in phi2 around 0

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

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(1 + {\phi_2}^{2} \cdot \left({\phi_2}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {\phi_2}^{2}\right) - \frac{1}{6}\right)\right) \cdot \phi_2} \]
                                                  2. lower-*.f64N/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(1 + {\phi_2}^{2} \cdot \left({\phi_2}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {\phi_2}^{2}\right) - \frac{1}{6}\right)\right) \cdot \phi_2} \]
                                                7. Applied rewrites41.9%

                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \color{blue}{\phi_2}} \]
                                              7. Recombined 2 regimes into one program.
                                              8. Add Preprocessing

                                              Alternative 31: 37.7% accurate, 2.4× speedup?

                                              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\ \mathbf{if}\;\phi_2 \leq 4400000000000:\\ \;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.008333333333333333 - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2}\\ \end{array} \end{array} \]
                                              (FPCore (lambda1 lambda2 phi1 phi2)
                                               :precision binary64
                                               (let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
                                                 (if (<= phi2 4400000000000.0)
                                                   (atan2
                                                    t_0
                                                    (*
                                                     (fma
                                                      (- (* (* phi2 phi2) 0.008333333333333333) 0.16666666666666666)
                                                      (* phi2 phi2)
                                                      1.0)
                                                     phi2))
                                                   (atan2 t_0 (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2)))))
                                              double code(double lambda1, double lambda2, double phi1, double phi2) {
                                              	double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
                                              	double tmp;
                                              	if (phi2 <= 4400000000000.0) {
                                              		tmp = atan2(t_0, (fma((((phi2 * phi2) * 0.008333333333333333) - 0.16666666666666666), (phi2 * phi2), 1.0) * phi2));
                                              	} else {
                                              		tmp = atan2(t_0, (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2));
                                              	}
                                              	return tmp;
                                              }
                                              
                                              function code(lambda1, lambda2, phi1, phi2)
                                              	t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2))
                                              	tmp = 0.0
                                              	if (phi2 <= 4400000000000.0)
                                              		tmp = atan(t_0, Float64(fma(Float64(Float64(Float64(phi2 * phi2) * 0.008333333333333333) - 0.16666666666666666), Float64(phi2 * phi2), 1.0) * phi2));
                                              	else
                                              		tmp = atan(t_0, Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2));
                                              	end
                                              	return tmp
                                              end
                                              
                                              code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 4400000000000.0], N[ArcTan[t$95$0 / N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * 0.008333333333333333), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]]
                                              
                                              \begin{array}{l}
                                              
                                              \\
                                              \begin{array}{l}
                                              t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
                                              \mathbf{if}\;\phi_2 \leq 4400000000000:\\
                                              \;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.008333333333333333 - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2}\\
                                              
                                              \mathbf{else}:\\
                                              \;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2}\\
                                              
                                              
                                              \end{array}
                                              \end{array}
                                              
                                              Derivation
                                              1. Split input into 2 regimes
                                              2. if phi2 < 4.4e12

                                                1. Initial program 79.8%

                                                  \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                2. Taylor expanded in phi1 around 0

                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                3. Step-by-step derivation
                                                  1. lift-sin.f6449.1

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                4. Applied rewrites49.1%

                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                5. Taylor expanded in phi2 around 0

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

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(1 + {\phi_2}^{2} \cdot \left(\frac{1}{120} \cdot {\phi_2}^{2} - \frac{1}{6}\right)\right) \cdot \phi_2} \]
                                                  2. lower-*.f64N/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(1 + {\phi_2}^{2} \cdot \left(\frac{1}{120} \cdot {\phi_2}^{2} - \frac{1}{6}\right)\right) \cdot \phi_2} \]
                                                  3. +-commutativeN/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left({\phi_2}^{2} \cdot \left(\frac{1}{120} \cdot {\phi_2}^{2} - \frac{1}{6}\right) + 1\right) \cdot \phi_2} \]
                                                  4. *-commutativeN/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(\left(\frac{1}{120} \cdot {\phi_2}^{2} - \frac{1}{6}\right) \cdot {\phi_2}^{2} + 1\right) \cdot \phi_2} \]
                                                  5. lower-fma.f64N/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\frac{1}{120} \cdot {\phi_2}^{2} - \frac{1}{6}, {\phi_2}^{2}, 1\right) \cdot \phi_2} \]
                                                  6. lower--.f64N/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\frac{1}{120} \cdot {\phi_2}^{2} - \frac{1}{6}, {\phi_2}^{2}, 1\right) \cdot \phi_2} \]
                                                  7. *-commutativeN/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left({\phi_2}^{2} \cdot \frac{1}{120} - \frac{1}{6}, {\phi_2}^{2}, 1\right) \cdot \phi_2} \]
                                                  8. lower-*.f64N/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left({\phi_2}^{2} \cdot \frac{1}{120} - \frac{1}{6}, {\phi_2}^{2}, 1\right) \cdot \phi_2} \]
                                                  9. unpow2N/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot \frac{1}{120} - \frac{1}{6}, {\phi_2}^{2}, 1\right) \cdot \phi_2} \]
                                                  10. lower-*.f64N/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot \frac{1}{120} - \frac{1}{6}, {\phi_2}^{2}, 1\right) \cdot \phi_2} \]
                                                  11. unpow2N/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot \frac{1}{120} - \frac{1}{6}, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2} \]
                                                  12. lower-*.f6441.2

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\left(\phi_2 \cdot \phi_2\right) \cdot 0.008333333333333333 - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2} \]
                                                7. Applied rewrites41.2%

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

                                                if 4.4e12 < phi2

                                                1. Initial program 76.9%

                                                  \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                2. Taylor expanded in phi1 around 0

                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                3. Step-by-step derivation
                                                  1. lift-sin.f6449.8

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                4. Applied rewrites49.8%

                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                5. Taylor expanded in phi2 around 0

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

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(1 + \frac{-1}{6} \cdot {\phi_2}^{2}\right) \cdot \phi_2} \]
                                                  2. lower-*.f64N/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(1 + \frac{-1}{6} \cdot {\phi_2}^{2}\right) \cdot \phi_2} \]
                                                  3. +-commutativeN/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(\frac{-1}{6} \cdot {\phi_2}^{2} + 1\right) \cdot \phi_2} \]
                                                  4. *-commutativeN/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left({\phi_2}^{2} \cdot \frac{-1}{6} + 1\right) \cdot \phi_2} \]
                                                  5. lower-fma.f64N/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left({\phi_2}^{2}, \frac{-1}{6}, 1\right) \cdot \phi_2} \]
                                                  6. unpow2N/A

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{6}, 1\right) \cdot \phi_2} \]
                                                  7. lower-*.f6426.2

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2} \]
                                                7. Applied rewrites26.2%

                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \color{blue}{\phi_2}} \]
                                              3. Recombined 2 regimes into one program.
                                              4. Add Preprocessing

                                              Alternative 32: 37.6% accurate, 2.6× speedup?

                                              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\ \mathbf{if}\;\phi_2 \leq 4400000000000:\\ \;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2}\\ \end{array} \end{array} \]
                                              (FPCore (lambda1 lambda2 phi1 phi2)
                                               :precision binary64
                                               (let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
                                                 (if (<= phi2 4400000000000.0)
                                                   (atan2 t_0 phi2)
                                                   (atan2 t_0 (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2)))))
                                              double code(double lambda1, double lambda2, double phi1, double phi2) {
                                              	double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
                                              	double tmp;
                                              	if (phi2 <= 4400000000000.0) {
                                              		tmp = atan2(t_0, phi2);
                                              	} else {
                                              		tmp = atan2(t_0, (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2));
                                              	}
                                              	return tmp;
                                              }
                                              
                                              function code(lambda1, lambda2, phi1, phi2)
                                              	t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2))
                                              	tmp = 0.0
                                              	if (phi2 <= 4400000000000.0)
                                              		tmp = atan(t_0, phi2);
                                              	else
                                              		tmp = atan(t_0, Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2));
                                              	end
                                              	return tmp
                                              end
                                              
                                              code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 4400000000000.0], N[ArcTan[t$95$0 / phi2], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]]
                                              
                                              \begin{array}{l}
                                              
                                              \\
                                              \begin{array}{l}
                                              t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
                                              \mathbf{if}\;\phi_2 \leq 4400000000000:\\
                                              \;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2}\\
                                              
                                              \mathbf{else}:\\
                                              \;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2}\\
                                              
                                              
                                              \end{array}
                                              \end{array}
                                              
                                              Derivation
                                              1. Split input into 2 regimes
                                              2. if phi2 < 4.4e12

                                                1. Initial program 79.8%

                                                  \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                2. Taylor expanded in phi1 around 0

                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                3. Step-by-step derivation
                                                  1. lift-sin.f6449.1

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                4. Applied rewrites49.1%

                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                5. Taylor expanded in phi2 around 0

                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2} \]
                                                6. Step-by-step derivation
                                                  1. Applied rewrites41.1%

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2} \]

                                                  if 4.4e12 < phi2

                                                  1. Initial program 76.9%

                                                    \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                  2. Taylor expanded in phi1 around 0

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                  3. Step-by-step derivation
                                                    1. lift-sin.f6449.8

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                  4. Applied rewrites49.8%

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                  5. Taylor expanded in phi2 around 0

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

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(1 + \frac{-1}{6} \cdot {\phi_2}^{2}\right) \cdot \phi_2} \]
                                                    2. lower-*.f64N/A

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(1 + \frac{-1}{6} \cdot {\phi_2}^{2}\right) \cdot \phi_2} \]
                                                    3. +-commutativeN/A

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(\frac{-1}{6} \cdot {\phi_2}^{2} + 1\right) \cdot \phi_2} \]
                                                    4. *-commutativeN/A

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left({\phi_2}^{2} \cdot \frac{-1}{6} + 1\right) \cdot \phi_2} \]
                                                    5. lower-fma.f64N/A

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left({\phi_2}^{2}, \frac{-1}{6}, 1\right) \cdot \phi_2} \]
                                                    6. unpow2N/A

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{6}, 1\right) \cdot \phi_2} \]
                                                    7. lower-*.f6426.2

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2} \]
                                                  7. Applied rewrites26.2%

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \color{blue}{\phi_2}} \]
                                                7. Recombined 2 regimes into one program.
                                                8. Add Preprocessing

                                                Alternative 33: 35.8% accurate, 2.9× speedup?

                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq 5.8 \cdot 10^{+26}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\ \end{array} \end{array} \]
                                                (FPCore (lambda1 lambda2 phi1 phi2)
                                                 :precision binary64
                                                 (if (<= phi2 5.8e+26)
                                                   (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) phi2)
                                                   (atan2 (* (- lambda2) (cos phi2)) (sin phi2))))
                                                double code(double lambda1, double lambda2, double phi1, double phi2) {
                                                	double tmp;
                                                	if (phi2 <= 5.8e+26) {
                                                		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2);
                                                	} else {
                                                		tmp = atan2((-lambda2 * cos(phi2)), sin(phi2));
                                                	}
                                                	return tmp;
                                                }
                                                
                                                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, lambda2, phi1, phi2)
                                                use fmin_fmax_functions
                                                    real(8), intent (in) :: lambda1
                                                    real(8), intent (in) :: lambda2
                                                    real(8), intent (in) :: phi1
                                                    real(8), intent (in) :: phi2
                                                    real(8) :: tmp
                                                    if (phi2 <= 5.8d+26) then
                                                        tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2)
                                                    else
                                                        tmp = atan2((-lambda2 * cos(phi2)), sin(phi2))
                                                    end if
                                                    code = tmp
                                                end function
                                                
                                                public static double code(double lambda1, double lambda2, double phi1, double phi2) {
                                                	double tmp;
                                                	if (phi2 <= 5.8e+26) {
                                                		tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), phi2);
                                                	} else {
                                                		tmp = Math.atan2((-lambda2 * Math.cos(phi2)), Math.sin(phi2));
                                                	}
                                                	return tmp;
                                                }
                                                
                                                def code(lambda1, lambda2, phi1, phi2):
                                                	tmp = 0
                                                	if phi2 <= 5.8e+26:
                                                		tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), phi2)
                                                	else:
                                                		tmp = math.atan2((-lambda2 * math.cos(phi2)), math.sin(phi2))
                                                	return tmp
                                                
                                                function code(lambda1, lambda2, phi1, phi2)
                                                	tmp = 0.0
                                                	if (phi2 <= 5.8e+26)
                                                		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), phi2);
                                                	else
                                                		tmp = atan(Float64(Float64(-lambda2) * cos(phi2)), sin(phi2));
                                                	end
                                                	return tmp
                                                end
                                                
                                                function tmp_2 = code(lambda1, lambda2, phi1, phi2)
                                                	tmp = 0.0;
                                                	if (phi2 <= 5.8e+26)
                                                		tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2);
                                                	else
                                                		tmp = atan2((-lambda2 * cos(phi2)), sin(phi2));
                                                	end
                                                	tmp_2 = tmp;
                                                end
                                                
                                                code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 5.8e+26], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[((-lambda2) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \begin{array}{l}
                                                \mathbf{if}\;\phi_2 \leq 5.8 \cdot 10^{+26}:\\
                                                \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2}\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;\tan^{-1}_* \frac{\left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
                                                
                                                
                                                \end{array}
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 2 regimes
                                                2. if phi2 < 5.8e26

                                                  1. Initial program 79.7%

                                                    \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                  2. Taylor expanded in phi1 around 0

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                  3. Step-by-step derivation
                                                    1. lift-sin.f6449.1

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                  4. Applied rewrites49.1%

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                  5. Taylor expanded in phi2 around 0

                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2} \]
                                                  6. Step-by-step derivation
                                                    1. Applied rewrites40.7%

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2} \]

                                                    if 5.8e26 < phi2

                                                    1. Initial program 77.0%

                                                      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                    2. Taylor expanded in phi1 around 0

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                    3. Step-by-step derivation
                                                      1. lift-sin.f6449.8

                                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                    4. Applied rewrites49.8%

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                    5. Taylor expanded in lambda2 around 0

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

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

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

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

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

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

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

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

                                                        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\lambda_2, \mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_2, \sin \lambda_1, -1 \cdot \cos \lambda_1\right), \sin \lambda_1\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                      9. mul-1-negN/A

                                                        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\lambda_2, \mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_2, \sin \lambda_1, \mathsf{neg}\left(\cos \lambda_1\right)\right), \sin \lambda_1\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                      10. lower-neg.f64N/A

                                                        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\lambda_2, \mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_2, \sin \lambda_1, -\cos \lambda_1\right), \sin \lambda_1\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                      11. lift-cos.f64N/A

                                                        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\lambda_2, \mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_2, \sin \lambda_1, -\cos \lambda_1\right), \sin \lambda_1\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                      12. lift-sin.f6437.3

                                                        \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\lambda_2, \mathsf{fma}\left(-0.5 \cdot \lambda_2, \sin \lambda_1, \color{blue}{-\cos \lambda_1}\right), \sin \lambda_1\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                    7. Applied rewrites37.3%

                                                      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\mathsf{fma}\left(\lambda_2, \mathsf{fma}\left(-0.5 \cdot \lambda_2, \sin \lambda_1, -\cos \lambda_1\right), \sin \lambda_1\right)} \cdot \cos \phi_2}{\sin \phi_2} \]
                                                    8. Taylor expanded in lambda1 around 0

                                                      \[\leadsto \tan^{-1}_* \frac{\left(-1 \cdot \color{blue}{\lambda_2}\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                    9. Step-by-step derivation
                                                      1. mul-1-negN/A

                                                        \[\leadsto \tan^{-1}_* \frac{\left(\mathsf{neg}\left(\lambda_2\right)\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                      2. lower-neg.f6418.9

                                                        \[\leadsto \tan^{-1}_* \frac{\left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                    10. Applied rewrites18.9%

                                                      \[\leadsto \tan^{-1}_* \frac{\left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                  7. Recombined 2 regimes into one program.
                                                  8. Add Preprocessing

                                                  Alternative 34: 32.0% accurate, 2.9× speedup?

                                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq -6 \cdot 10^{-119}:\\ \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{\phi_2}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2}\\ \end{array} \end{array} \]
                                                  (FPCore (lambda1 lambda2 phi1 phi2)
                                                   :precision binary64
                                                   (if (<= phi2 -6e-119)
                                                     (atan2 (* (cos phi2) (- (sin lambda2))) phi2)
                                                     (atan2
                                                      (* (sin (- lambda1 lambda2)) 1.0)
                                                      (*
                                                       (fma
                                                        (-
                                                         (*
                                                          (fma (* phi2 phi2) -0.0001984126984126984 0.008333333333333333)
                                                          (* phi2 phi2))
                                                         0.16666666666666666)
                                                        (* phi2 phi2)
                                                        1.0)
                                                       phi2))))
                                                  double code(double lambda1, double lambda2, double phi1, double phi2) {
                                                  	double tmp;
                                                  	if (phi2 <= -6e-119) {
                                                  		tmp = atan2((cos(phi2) * -sin(lambda2)), phi2);
                                                  	} else {
                                                  		tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (fma(((fma((phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * (phi2 * phi2)) - 0.16666666666666666), (phi2 * phi2), 1.0) * phi2));
                                                  	}
                                                  	return tmp;
                                                  }
                                                  
                                                  function code(lambda1, lambda2, phi1, phi2)
                                                  	tmp = 0.0
                                                  	if (phi2 <= -6e-119)
                                                  		tmp = atan(Float64(cos(phi2) * Float64(-sin(lambda2))), phi2);
                                                  	else
                                                  		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(fma(Float64(Float64(fma(Float64(phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * Float64(phi2 * phi2)) - 0.16666666666666666), Float64(phi2 * phi2), 1.0) * phi2));
                                                  	end
                                                  	return tmp
                                                  end
                                                  
                                                  code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -6e-119], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]
                                                  
                                                  \begin{array}{l}
                                                  
                                                  \\
                                                  \begin{array}{l}
                                                  \mathbf{if}\;\phi_2 \leq -6 \cdot 10^{-119}:\\
                                                  \;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{\phi_2}\\
                                                  
                                                  \mathbf{else}:\\
                                                  \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2}\\
                                                  
                                                  
                                                  \end{array}
                                                  \end{array}
                                                  
                                                  Derivation
                                                  1. Split input into 2 regimes
                                                  2. if phi2 < -6.0000000000000004e-119

                                                    1. Initial program 77.4%

                                                      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                    2. Taylor expanded in phi1 around 0

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                    3. Step-by-step derivation
                                                      1. lift-sin.f6449.5

                                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                    4. Applied rewrites49.5%

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                    5. Taylor expanded in phi2 around 0

                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                    6. Step-by-step derivation
                                                      1. Applied rewrites25.9%

                                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                      2. Taylor expanded in phi2 around 0

                                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2} \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites25.6%

                                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2} \]
                                                        2. Taylor expanded in lambda1 around 0

                                                          \[\leadsto \tan^{-1}_* \frac{\color{blue}{\cos \phi_2 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)}}{\phi_2} \]
                                                        3. Step-by-step derivation
                                                          1. sin-diff-revN/A

                                                            \[\leadsto \tan^{-1}_* \frac{\cos \color{blue}{\phi_2} \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)}{\phi_2} \]
                                                          2. sin-neg-revN/A

                                                            \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\mathsf{neg}\left(\sin \lambda_2\right)\right)}{\phi_2} \]
                                                          3. lower-*.f64N/A

                                                            \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \color{blue}{\left(\mathsf{neg}\left(\sin \lambda_2\right)\right)}}{\phi_2} \]
                                                          4. lift-cos.f64N/A

                                                            \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\mathsf{neg}\left(\color{blue}{\sin \lambda_2}\right)\right)}{\phi_2} \]
                                                          5. lift-sin.f64N/A

                                                            \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\mathsf{neg}\left(\sin \lambda_2\right)\right)}{\phi_2} \]
                                                          6. lift-neg.f6425.8

                                                            \[\leadsto \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{\phi_2} \]
                                                        4. Applied rewrites25.8%

                                                          \[\leadsto \tan^{-1}_* \frac{\color{blue}{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}}{\phi_2} \]

                                                        if -6.0000000000000004e-119 < phi2

                                                        1. Initial program 80.0%

                                                          \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                        2. Taylor expanded in phi1 around 0

                                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                        3. Step-by-step derivation
                                                          1. lift-sin.f6449.1

                                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                        4. Applied rewrites49.1%

                                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                        5. Taylor expanded in phi2 around 0

                                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                        6. Step-by-step derivation
                                                          1. Applied rewrites35.6%

                                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                          2. Taylor expanded in phi2 around 0

                                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2 \cdot \color{blue}{\left(1 + {\phi_2}^{2} \cdot \left({\phi_2}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {\phi_2}^{2}\right) - \frac{1}{6}\right)\right)}} \]
                                                          3. Step-by-step derivation
                                                            1. *-commutativeN/A

                                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\left(1 + {\phi_2}^{2} \cdot \left({\phi_2}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {\phi_2}^{2}\right) - \frac{1}{6}\right)\right) \cdot \phi_2} \]
                                                            2. lower-*.f64N/A

                                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\left(1 + {\phi_2}^{2} \cdot \left({\phi_2}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {\phi_2}^{2}\right) - \frac{1}{6}\right)\right) \cdot \phi_2} \]
                                                          4. Applied rewrites35.4%

                                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \color{blue}{\phi_2}} \]
                                                        7. Recombined 2 regimes into one program.
                                                        8. Add Preprocessing

                                                        Alternative 35: 31.6% accurate, 3.0× speedup?

                                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq -6 \cdot 10^{-119}:\\ \;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot 1}{\phi_2}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2}\\ \end{array} \end{array} \]
                                                        (FPCore (lambda1 lambda2 phi1 phi2)
                                                         :precision binary64
                                                         (if (<= phi2 -6e-119)
                                                           (atan2 (* (- (sin lambda2)) 1.0) phi2)
                                                           (atan2
                                                            (* (sin (- lambda1 lambda2)) 1.0)
                                                            (*
                                                             (fma
                                                              (-
                                                               (*
                                                                (fma (* phi2 phi2) -0.0001984126984126984 0.008333333333333333)
                                                                (* phi2 phi2))
                                                               0.16666666666666666)
                                                              (* phi2 phi2)
                                                              1.0)
                                                             phi2))))
                                                        double code(double lambda1, double lambda2, double phi1, double phi2) {
                                                        	double tmp;
                                                        	if (phi2 <= -6e-119) {
                                                        		tmp = atan2((-sin(lambda2) * 1.0), phi2);
                                                        	} else {
                                                        		tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (fma(((fma((phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * (phi2 * phi2)) - 0.16666666666666666), (phi2 * phi2), 1.0) * phi2));
                                                        	}
                                                        	return tmp;
                                                        }
                                                        
                                                        function code(lambda1, lambda2, phi1, phi2)
                                                        	tmp = 0.0
                                                        	if (phi2 <= -6e-119)
                                                        		tmp = atan(Float64(Float64(-sin(lambda2)) * 1.0), phi2);
                                                        	else
                                                        		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(fma(Float64(Float64(fma(Float64(phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * Float64(phi2 * phi2)) - 0.16666666666666666), Float64(phi2 * phi2), 1.0) * phi2));
                                                        	end
                                                        	return tmp
                                                        end
                                                        
                                                        code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -6e-119], N[ArcTan[N[((-N[Sin[lambda2], $MachinePrecision]) * 1.0), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]
                                                        
                                                        \begin{array}{l}
                                                        
                                                        \\
                                                        \begin{array}{l}
                                                        \mathbf{if}\;\phi_2 \leq -6 \cdot 10^{-119}:\\
                                                        \;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot 1}{\phi_2}\\
                                                        
                                                        \mathbf{else}:\\
                                                        \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2}\\
                                                        
                                                        
                                                        \end{array}
                                                        \end{array}
                                                        
                                                        Derivation
                                                        1. Split input into 2 regimes
                                                        2. if phi2 < -6.0000000000000004e-119

                                                          1. Initial program 77.4%

                                                            \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                          2. Taylor expanded in phi1 around 0

                                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                          3. Step-by-step derivation
                                                            1. lift-sin.f6449.5

                                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                          4. Applied rewrites49.5%

                                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                          5. Taylor expanded in phi2 around 0

                                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                          6. Step-by-step derivation
                                                            1. Applied rewrites25.9%

                                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                            2. Taylor expanded in phi2 around 0

                                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2} \]
                                                            3. Step-by-step derivation
                                                              1. Applied rewrites25.6%

                                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2} \]
                                                              2. Taylor expanded in lambda1 around 0

                                                                \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\mathsf{neg}\left(\lambda_2\right)\right)} \cdot 1}{\phi_2} \]
                                                              3. Step-by-step derivation
                                                                1. sin-diff-revN/A

                                                                  \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} \cdot 1}{\phi_2} \]
                                                                2. sin-neg-revN/A

                                                                  \[\leadsto \tan^{-1}_* \frac{\left(\mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\phi_2} \]
                                                                3. lift-sin.f64N/A

                                                                  \[\leadsto \tan^{-1}_* \frac{\left(\mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\phi_2} \]
                                                                4. lift-neg.f6421.6

                                                                  \[\leadsto \tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot 1}{\phi_2} \]
                                                              4. Applied rewrites21.6%

                                                                \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(-\sin \lambda_2\right)} \cdot 1}{\phi_2} \]

                                                              if -6.0000000000000004e-119 < phi2

                                                              1. Initial program 80.0%

                                                                \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                              2. Taylor expanded in phi1 around 0

                                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                              3. Step-by-step derivation
                                                                1. lift-sin.f6449.1

                                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                              4. Applied rewrites49.1%

                                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                              5. Taylor expanded in phi2 around 0

                                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                              6. Step-by-step derivation
                                                                1. Applied rewrites35.6%

                                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                                2. Taylor expanded in phi2 around 0

                                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2 \cdot \color{blue}{\left(1 + {\phi_2}^{2} \cdot \left({\phi_2}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {\phi_2}^{2}\right) - \frac{1}{6}\right)\right)}} \]
                                                                3. Step-by-step derivation
                                                                  1. *-commutativeN/A

                                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\left(1 + {\phi_2}^{2} \cdot \left({\phi_2}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {\phi_2}^{2}\right) - \frac{1}{6}\right)\right) \cdot \phi_2} \]
                                                                  2. lower-*.f64N/A

                                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\left(1 + {\phi_2}^{2} \cdot \left({\phi_2}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {\phi_2}^{2}\right) - \frac{1}{6}\right)\right) \cdot \phi_2} \]
                                                                4. Applied rewrites35.4%

                                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \color{blue}{\phi_2}} \]
                                                              7. Recombined 2 regimes into one program.
                                                              8. Add Preprocessing

                                                              Alternative 36: 30.6% accurate, 3.8× speedup?

                                                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq -6 \cdot 10^{-119}:\\ \;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot 1}{\phi_2}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2}\\ \end{array} \end{array} \]
                                                              (FPCore (lambda1 lambda2 phi1 phi2)
                                                               :precision binary64
                                                               (if (<= phi2 -6e-119)
                                                                 (atan2 (* (- (sin lambda2)) 1.0) phi2)
                                                                 (atan2
                                                                  (* (sin (- lambda1 lambda2)) 1.0)
                                                                  (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))))
                                                              double code(double lambda1, double lambda2, double phi1, double phi2) {
                                                              	double tmp;
                                                              	if (phi2 <= -6e-119) {
                                                              		tmp = atan2((-sin(lambda2) * 1.0), phi2);
                                                              	} else {
                                                              		tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2));
                                                              	}
                                                              	return tmp;
                                                              }
                                                              
                                                              function code(lambda1, lambda2, phi1, phi2)
                                                              	tmp = 0.0
                                                              	if (phi2 <= -6e-119)
                                                              		tmp = atan(Float64(Float64(-sin(lambda2)) * 1.0), phi2);
                                                              	else
                                                              		tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2));
                                                              	end
                                                              	return tmp
                                                              end
                                                              
                                                              code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -6e-119], N[ArcTan[N[((-N[Sin[lambda2], $MachinePrecision]) * 1.0), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]
                                                              
                                                              \begin{array}{l}
                                                              
                                                              \\
                                                              \begin{array}{l}
                                                              \mathbf{if}\;\phi_2 \leq -6 \cdot 10^{-119}:\\
                                                              \;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot 1}{\phi_2}\\
                                                              
                                                              \mathbf{else}:\\
                                                              \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2}\\
                                                              
                                                              
                                                              \end{array}
                                                              \end{array}
                                                              
                                                              Derivation
                                                              1. Split input into 2 regimes
                                                              2. if phi2 < -6.0000000000000004e-119

                                                                1. Initial program 77.4%

                                                                  \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                                2. Taylor expanded in phi1 around 0

                                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                                3. Step-by-step derivation
                                                                  1. lift-sin.f6449.5

                                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                                4. Applied rewrites49.5%

                                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                                5. Taylor expanded in phi2 around 0

                                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                                6. Step-by-step derivation
                                                                  1. Applied rewrites25.9%

                                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                                  2. Taylor expanded in phi2 around 0

                                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2} \]
                                                                  3. Step-by-step derivation
                                                                    1. Applied rewrites25.6%

                                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2} \]
                                                                    2. Taylor expanded in lambda1 around 0

                                                                      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\mathsf{neg}\left(\lambda_2\right)\right)} \cdot 1}{\phi_2} \]
                                                                    3. Step-by-step derivation
                                                                      1. sin-diff-revN/A

                                                                        \[\leadsto \tan^{-1}_* \frac{\sin \color{blue}{\left(\mathsf{neg}\left(\lambda_2\right)\right)} \cdot 1}{\phi_2} \]
                                                                      2. sin-neg-revN/A

                                                                        \[\leadsto \tan^{-1}_* \frac{\left(\mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\phi_2} \]
                                                                      3. lift-sin.f64N/A

                                                                        \[\leadsto \tan^{-1}_* \frac{\left(\mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\phi_2} \]
                                                                      4. lift-neg.f6421.6

                                                                        \[\leadsto \tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot 1}{\phi_2} \]
                                                                    4. Applied rewrites21.6%

                                                                      \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(-\sin \lambda_2\right)} \cdot 1}{\phi_2} \]

                                                                    if -6.0000000000000004e-119 < phi2

                                                                    1. Initial program 80.0%

                                                                      \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                                    2. Taylor expanded in phi1 around 0

                                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                                    3. Step-by-step derivation
                                                                      1. lift-sin.f6449.1

                                                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                                    4. Applied rewrites49.1%

                                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                                    5. Taylor expanded in phi2 around 0

                                                                      \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                                    6. Step-by-step derivation
                                                                      1. Applied rewrites35.6%

                                                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                                      2. Taylor expanded in phi2 around 0

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

                                                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\left(1 + \frac{-1}{6} \cdot {\phi_2}^{2}\right) \cdot \phi_2} \]
                                                                        2. lower-*.f64N/A

                                                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\left(1 + \frac{-1}{6} \cdot {\phi_2}^{2}\right) \cdot \phi_2} \]
                                                                        3. +-commutativeN/A

                                                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\left(\frac{-1}{6} \cdot {\phi_2}^{2} + 1\right) \cdot \phi_2} \]
                                                                        4. *-commutativeN/A

                                                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\left({\phi_2}^{2} \cdot \frac{-1}{6} + 1\right) \cdot \phi_2} \]
                                                                        5. lower-fma.f64N/A

                                                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left({\phi_2}^{2}, \frac{-1}{6}, 1\right) \cdot \phi_2} \]
                                                                        6. unpow2N/A

                                                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{6}, 1\right) \cdot \phi_2} \]
                                                                        7. lower-*.f6435.4

                                                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2} \]
                                                                      4. Applied rewrites35.4%

                                                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \color{blue}{\phi_2}} \]
                                                                    7. Recombined 2 regimes into one program.
                                                                    8. Add Preprocessing

                                                                    Alternative 37: 30.6% accurate, 4.7× speedup?

                                                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\phi_2 \leq 4500000000000:\\ \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2}\\ \mathbf{else}:\\ \;\;\;\;\tan^{-1}_* \frac{\lambda_1 \cdot 1}{\sin \phi_2}\\ \end{array} \end{array} \]
                                                                    (FPCore (lambda1 lambda2 phi1 phi2)
                                                                     :precision binary64
                                                                     (if (<= phi2 4500000000000.0)
                                                                       (atan2 (sin (- lambda1 lambda2)) phi2)
                                                                       (atan2 (* lambda1 1.0) (sin phi2))))
                                                                    double code(double lambda1, double lambda2, double phi1, double phi2) {
                                                                    	double tmp;
                                                                    	if (phi2 <= 4500000000000.0) {
                                                                    		tmp = atan2(sin((lambda1 - lambda2)), phi2);
                                                                    	} else {
                                                                    		tmp = atan2((lambda1 * 1.0), sin(phi2));
                                                                    	}
                                                                    	return tmp;
                                                                    }
                                                                    
                                                                    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, lambda2, phi1, phi2)
                                                                    use fmin_fmax_functions
                                                                        real(8), intent (in) :: lambda1
                                                                        real(8), intent (in) :: lambda2
                                                                        real(8), intent (in) :: phi1
                                                                        real(8), intent (in) :: phi2
                                                                        real(8) :: tmp
                                                                        if (phi2 <= 4500000000000.0d0) then
                                                                            tmp = atan2(sin((lambda1 - lambda2)), phi2)
                                                                        else
                                                                            tmp = atan2((lambda1 * 1.0d0), sin(phi2))
                                                                        end if
                                                                        code = tmp
                                                                    end function
                                                                    
                                                                    public static double code(double lambda1, double lambda2, double phi1, double phi2) {
                                                                    	double tmp;
                                                                    	if (phi2 <= 4500000000000.0) {
                                                                    		tmp = Math.atan2(Math.sin((lambda1 - lambda2)), phi2);
                                                                    	} else {
                                                                    		tmp = Math.atan2((lambda1 * 1.0), Math.sin(phi2));
                                                                    	}
                                                                    	return tmp;
                                                                    }
                                                                    
                                                                    def code(lambda1, lambda2, phi1, phi2):
                                                                    	tmp = 0
                                                                    	if phi2 <= 4500000000000.0:
                                                                    		tmp = math.atan2(math.sin((lambda1 - lambda2)), phi2)
                                                                    	else:
                                                                    		tmp = math.atan2((lambda1 * 1.0), math.sin(phi2))
                                                                    	return tmp
                                                                    
                                                                    function code(lambda1, lambda2, phi1, phi2)
                                                                    	tmp = 0.0
                                                                    	if (phi2 <= 4500000000000.0)
                                                                    		tmp = atan(sin(Float64(lambda1 - lambda2)), phi2);
                                                                    	else
                                                                    		tmp = atan(Float64(lambda1 * 1.0), sin(phi2));
                                                                    	end
                                                                    	return tmp
                                                                    end
                                                                    
                                                                    function tmp_2 = code(lambda1, lambda2, phi1, phi2)
                                                                    	tmp = 0.0;
                                                                    	if (phi2 <= 4500000000000.0)
                                                                    		tmp = atan2(sin((lambda1 - lambda2)), phi2);
                                                                    	else
                                                                    		tmp = atan2((lambda1 * 1.0), sin(phi2));
                                                                    	end
                                                                    	tmp_2 = tmp;
                                                                    end
                                                                    
                                                                    code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 4500000000000.0], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(lambda1 * 1.0), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
                                                                    
                                                                    \begin{array}{l}
                                                                    
                                                                    \\
                                                                    \begin{array}{l}
                                                                    \mathbf{if}\;\phi_2 \leq 4500000000000:\\
                                                                    \;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2}\\
                                                                    
                                                                    \mathbf{else}:\\
                                                                    \;\;\;\;\tan^{-1}_* \frac{\lambda_1 \cdot 1}{\sin \phi_2}\\
                                                                    
                                                                    
                                                                    \end{array}
                                                                    \end{array}
                                                                    
                                                                    Derivation
                                                                    1. Split input into 2 regimes
                                                                    2. if phi2 < 4.5e12

                                                                      1. Initial program 79.8%

                                                                        \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                                      2. Taylor expanded in phi1 around 0

                                                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                                      3. Step-by-step derivation
                                                                        1. lift-sin.f6449.1

                                                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                                      4. Applied rewrites49.1%

                                                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                                      5. Taylor expanded in phi2 around 0

                                                                        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                                      6. Step-by-step derivation
                                                                        1. Applied rewrites37.6%

                                                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                                        2. Taylor expanded in phi2 around 0

                                                                          \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2} \]
                                                                        3. Step-by-step derivation
                                                                          1. Applied rewrites37.3%

                                                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2} \]
                                                                          2. Taylor expanded in phi2 around 0

                                                                            \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\phi_2} \]
                                                                          3. Step-by-step derivation
                                                                            1. sin-diff-revN/A

                                                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\color{blue}{\lambda_1} - \lambda_2\right)}{\phi_2} \]
                                                                            2. lift-sin.f64N/A

                                                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2} \]
                                                                            3. lift--.f6437.3

                                                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2} \]
                                                                          4. Applied rewrites37.3%

                                                                            \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\phi_2} \]

                                                                          if 4.5e12 < phi2

                                                                          1. Initial program 76.9%

                                                                            \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                                          2. Taylor expanded in phi1 around 0

                                                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                                          3. Step-by-step derivation
                                                                            1. lift-sin.f6449.8

                                                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                                          4. Applied rewrites49.8%

                                                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                                          5. Taylor expanded in phi2 around 0

                                                                            \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                                          6. Step-by-step derivation
                                                                            1. Applied rewrites14.6%

                                                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                                            2. Taylor expanded in lambda1 around 0

                                                                              \[\leadsto \tan^{-1}_* \frac{\color{blue}{\left(\sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \lambda_1 \cdot \left(\cos \left(\mathsf{neg}\left(\lambda_2\right)\right) + \frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right)\right)\right)} \cdot 1}{\sin \phi_2} \]
                                                                            3. Step-by-step derivation
                                                                              1. sin-diff-revN/A

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

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

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

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

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

                                                                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\frac{-1}{2} \cdot \left(\lambda_1 \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                                                              7. associate-*r*N/A

                                                                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\left(\frac{-1}{2} \cdot \lambda_1\right) \cdot \sin \left(\mathsf{neg}\left(\lambda_2\right)\right) + \cos \lambda_2, \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                                                              8. metadata-evalN/A

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

                                                                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                                                              10. metadata-evalN/A

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

                                                                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                                                              12. sin-negN/A

                                                                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right), \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                                                              13. lower-neg.f64N/A

                                                                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                                                              14. lift-sin.f64N/A

                                                                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                                                              15. lift-cos.f64N/A

                                                                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \sin \left(\mathsf{neg}\left(\lambda_2\right)\right)\right) \cdot 1}{\sin \phi_2} \]
                                                                              16. sin-negN/A

                                                                                \[\leadsto \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{2} \cdot \lambda_1, -\sin \lambda_2, \cos \lambda_2\right), \lambda_1, \mathsf{neg}\left(\sin \lambda_2\right)\right) \cdot 1}{\sin \phi_2} \]
                                                                            4. Applied rewrites13.9%

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

                                                                              \[\leadsto \tan^{-1}_* \frac{\lambda_1 \cdot 1}{\sin \phi_2} \]
                                                                            6. Step-by-step derivation
                                                                              1. Applied rewrites12.9%

                                                                                \[\leadsto \tan^{-1}_* \frac{\lambda_1 \cdot 1}{\sin \phi_2} \]
                                                                            7. Recombined 2 regimes into one program.
                                                                            8. Add Preprocessing

                                                                            Alternative 38: 29.4% accurate, 5.1× speedup?

                                                                            \[\begin{array}{l} \\ \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2} \end{array} \]
                                                                            (FPCore (lambda1 lambda2 phi1 phi2)
                                                                             :precision binary64
                                                                             (atan2 (sin (- lambda1 lambda2)) phi2))
                                                                            double code(double lambda1, double lambda2, double phi1, double phi2) {
                                                                            	return atan2(sin((lambda1 - lambda2)), phi2);
                                                                            }
                                                                            
                                                                            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, lambda2, phi1, phi2)
                                                                            use fmin_fmax_functions
                                                                                real(8), intent (in) :: lambda1
                                                                                real(8), intent (in) :: lambda2
                                                                                real(8), intent (in) :: phi1
                                                                                real(8), intent (in) :: phi2
                                                                                code = atan2(sin((lambda1 - lambda2)), phi2)
                                                                            end function
                                                                            
                                                                            public static double code(double lambda1, double lambda2, double phi1, double phi2) {
                                                                            	return Math.atan2(Math.sin((lambda1 - lambda2)), phi2);
                                                                            }
                                                                            
                                                                            def code(lambda1, lambda2, phi1, phi2):
                                                                            	return math.atan2(math.sin((lambda1 - lambda2)), phi2)
                                                                            
                                                                            function code(lambda1, lambda2, phi1, phi2)
                                                                            	return atan(sin(Float64(lambda1 - lambda2)), phi2)
                                                                            end
                                                                            
                                                                            function tmp = code(lambda1, lambda2, phi1, phi2)
                                                                            	tmp = atan2(sin((lambda1 - lambda2)), phi2);
                                                                            end
                                                                            
                                                                            code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / phi2], $MachinePrecision]
                                                                            
                                                                            \begin{array}{l}
                                                                            
                                                                            \\
                                                                            \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2}
                                                                            \end{array}
                                                                            
                                                                            Derivation
                                                                            1. Initial program 79.1%

                                                                              \[\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
                                                                            2. Taylor expanded in phi1 around 0

                                                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                                            3. Step-by-step derivation
                                                                              1. lift-sin.f6449.2

                                                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2} \]
                                                                            4. Applied rewrites49.2%

                                                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\color{blue}{\sin \phi_2}} \]
                                                                            5. Taylor expanded in phi2 around 0

                                                                              \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                                            6. Step-by-step derivation
                                                                              1. Applied rewrites32.2%

                                                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \color{blue}{1}}{\sin \phi_2} \]
                                                                              2. Taylor expanded in phi2 around 0

                                                                                \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2} \]
                                                                              3. Step-by-step derivation
                                                                                1. Applied rewrites29.4%

                                                                                  \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2} \]
                                                                                2. Taylor expanded in phi2 around 0

                                                                                  \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\phi_2} \]
                                                                                3. Step-by-step derivation
                                                                                  1. sin-diff-revN/A

                                                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\color{blue}{\lambda_1} - \lambda_2\right)}{\phi_2} \]
                                                                                  2. lift-sin.f64N/A

                                                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2} \]
                                                                                  3. lift--.f6429.4

                                                                                    \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2} \]
                                                                                4. Applied rewrites29.4%

                                                                                  \[\leadsto \tan^{-1}_* \frac{\color{blue}{\sin \left(\lambda_1 - \lambda_2\right)}}{\phi_2} \]
                                                                                5. Add Preprocessing

                                                                                Reproduce

                                                                                ?
                                                                                herbie shell --seed 2025120 
                                                                                (FPCore (lambda1 lambda2 phi1 phi2)
                                                                                  :name "Bearing on a great circle"
                                                                                  :precision binary64
                                                                                  (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))