Midpoint on a great circle

Percentage Accurate: 98.6% → 98.6%
Time: 9.7s
Alternatives: 16
Speedup: 1.0×

Specification

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

\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \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 16 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: 98.6% accurate, 1.0× speedup?

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

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

Alternative 1: 98.6% accurate, 1.0× speedup?

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

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

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

Alternative 2: 98.5% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t\_4 \leq -0.02:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{\mathsf{fma}\left(t\_3, \cos \phi_2, \cos \phi_1\right)}\\

\mathbf{elif}\;t\_4 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(-0.5, \lambda_2, \lambda_1\right), \lambda_2, 1\right)}\\

\mathbf{elif}\;t\_4 \leq 5:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_5 \cdot t\_0}{1 + t\_5 \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -5

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

    if -5 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -0.0200000000000000004

    1. Initial program 98.6%

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2 + \cos \color{blue}{\phi_1}} \]
      9. lower-fma.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), \color{blue}{\cos \phi_2}, \cos \phi_1\right)} \]
      10. 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), \cos \color{blue}{\phi_2}, \cos \phi_1\right)} \]
      11. lift--.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), \cos \phi_2, \cos \phi_1\right)} \]
      12. 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), \cos \phi_2, \cos \phi_1\right)} \]
      13. lift-cos.f6442.0

        \[\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), \cos \phi_2, \cos \phi_1\right)} \]
    4. Applied rewrites42.0%

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

    if -0.0200000000000000004 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < 4.99999999999999977e-7

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999977e-7 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < 5

    1. Initial program 98.6%

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2 + \cos \color{blue}{\phi_1}} \]
      9. lower-fma.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), \color{blue}{\cos \phi_2}, \cos \phi_1\right)} \]
      10. 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), \cos \color{blue}{\phi_2}, \cos \phi_1\right)} \]
      11. lift--.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), \cos \phi_2, \cos \phi_1\right)} \]
      12. 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), \cos \phi_2, \cos \phi_1\right)} \]
      13. lift-cos.f6442.0

        \[\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), \cos \phi_2, \cos \phi_1\right)} \]
    4. Applied rewrites42.0%

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

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

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

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

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

    if 5 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2))))))

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1} + \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
    11. Step-by-step derivation
      1. sin-+PI/2-rev61.4

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

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

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

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

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

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
      8. lift-/.f6461.4

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
    12. Applied rewrites61.4%

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

Alternative 3: 97.7% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if lambda2 < -1.9999999999999999e-7 or 1.00000000000000004e-25 < lambda2

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

    if -1.9999999999999999e-7 < lambda2 < 1.00000000000000004e-25

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

Alternative 4: 97.6% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\ t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\ t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\ t_3 := \cos \phi_2 \cdot t\_2\\ t_4 := \lambda_1 + \tan^{-1}_* \frac{t\_3}{\cos \phi_1 + \cos \phi_2 \cdot t\_1}\\ t_5 := t\_2 \cdot \cos \phi_2\\ \mathbf{if}\;t\_4 \leq -5:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_3}{\mathsf{fma}\left(t\_1, \cos \phi_2, 1\right)}\\ \mathbf{elif}\;t\_4 \leq -0.02:\\ \;\;\;\;\tan^{-1}_* \frac{t\_5}{\mathsf{fma}\left(t\_1, \cos \phi_2, \cos \phi_1\right)}\\ \mathbf{elif}\;t\_4 \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_3}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(-0.5, \lambda_2, \lambda_1\right), \lambda_2, 1\right)}\\ \mathbf{elif}\;t\_4 \leq 5:\\ \;\;\;\;\tan^{-1}_* \frac{t\_5}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot t\_2}{1 + t\_0 \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (fma (* phi2 phi2) -0.5 1.0))
        (t_1 (cos (- lambda1 lambda2)))
        (t_2 (sin (- lambda1 lambda2)))
        (t_3 (* (cos phi2) t_2))
        (t_4 (+ lambda1 (atan2 t_3 (+ (cos phi1) (* (cos phi2) t_1)))))
        (t_5 (* t_2 (cos phi2))))
   (if (<= t_4 -5.0)
     (+ lambda1 (atan2 t_3 (fma t_1 (cos phi2) 1.0)))
     (if (<= t_4 -0.02)
       (atan2 t_5 (fma t_1 (cos phi2) (cos phi1)))
       (if (<= t_4 5e-7)
         (+
          lambda1
          (atan2
           t_3
           (+
            (cos phi1)
            (* (cos phi2) (fma (fma -0.5 lambda2 lambda1) lambda2 1.0)))))
         (if (<= t_4 5.0)
           (atan2 t_5 (fma (cos lambda2) (cos phi2) (cos phi1)))
           (+
            lambda1
            (atan2
             (* t_0 t_2)
             (+
              1.0
              (* t_0 (sin (+ (- (- lambda1 lambda2)) (/ PI 2.0)))))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = fma((phi2 * phi2), -0.5, 1.0);
	double t_1 = cos((lambda1 - lambda2));
	double t_2 = sin((lambda1 - lambda2));
	double t_3 = cos(phi2) * t_2;
	double t_4 = lambda1 + atan2(t_3, (cos(phi1) + (cos(phi2) * t_1)));
	double t_5 = t_2 * cos(phi2);
	double tmp;
	if (t_4 <= -5.0) {
		tmp = lambda1 + atan2(t_3, fma(t_1, cos(phi2), 1.0));
	} else if (t_4 <= -0.02) {
		tmp = atan2(t_5, fma(t_1, cos(phi2), cos(phi1)));
	} else if (t_4 <= 5e-7) {
		tmp = lambda1 + atan2(t_3, (cos(phi1) + (cos(phi2) * fma(fma(-0.5, lambda2, lambda1), lambda2, 1.0))));
	} else if (t_4 <= 5.0) {
		tmp = atan2(t_5, fma(cos(lambda2), cos(phi2), cos(phi1)));
	} else {
		tmp = lambda1 + atan2((t_0 * t_2), (1.0 + (t_0 * sin((-(lambda1 - lambda2) + (((double) M_PI) / 2.0))))));
	}
	return tmp;
}
function code(lambda1, lambda2, phi1, phi2)
	t_0 = fma(Float64(phi2 * phi2), -0.5, 1.0)
	t_1 = cos(Float64(lambda1 - lambda2))
	t_2 = sin(Float64(lambda1 - lambda2))
	t_3 = Float64(cos(phi2) * t_2)
	t_4 = Float64(lambda1 + atan(t_3, Float64(cos(phi1) + Float64(cos(phi2) * t_1))))
	t_5 = Float64(t_2 * cos(phi2))
	tmp = 0.0
	if (t_4 <= -5.0)
		tmp = Float64(lambda1 + atan(t_3, fma(t_1, cos(phi2), 1.0)));
	elseif (t_4 <= -0.02)
		tmp = atan(t_5, fma(t_1, cos(phi2), cos(phi1)));
	elseif (t_4 <= 5e-7)
		tmp = Float64(lambda1 + atan(t_3, Float64(cos(phi1) + Float64(cos(phi2) * fma(fma(-0.5, lambda2, lambda1), lambda2, 1.0)))));
	elseif (t_4 <= 5.0)
		tmp = atan(t_5, fma(cos(lambda2), cos(phi2), cos(phi1)));
	else
		tmp = Float64(lambda1 + atan(Float64(t_0 * t_2), Float64(1.0 + Float64(t_0 * sin(Float64(Float64(-Float64(lambda1 - lambda2)) + Float64(pi / 2.0)))))));
	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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(lambda1 + N[ArcTan[t$95$3 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$2 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -5.0], N[(lambda1 + N[ArcTan[t$95$3 / N[(t$95$1 * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, -0.02], N[ArcTan[t$95$5 / N[(t$95$1 * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$4, 5e-7], N[(lambda1 + N[ArcTan[t$95$3 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(-0.5 * lambda2 + lambda1), $MachinePrecision] * lambda2 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 5.0], N[ArcTan[t$95$5 / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(lambda1 + N[ArcTan[N[(t$95$0 * t$95$2), $MachinePrecision] / N[(1.0 + N[(t$95$0 * N[Sin[N[((-N[(lambda1 - lambda2), $MachinePrecision]) + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_4 \leq -0.02:\\
\;\;\;\;\tan^{-1}_* \frac{t\_5}{\mathsf{fma}\left(t\_1, \cos \phi_2, \cos \phi_1\right)}\\

\mathbf{elif}\;t\_4 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_3}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(-0.5, \lambda_2, \lambda_1\right), \lambda_2, 1\right)}\\

\mathbf{elif}\;t\_4 \leq 5:\\
\;\;\;\;\tan^{-1}_* \frac{t\_5}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot t\_2}{1 + t\_0 \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -5

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

    if -5 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -0.0200000000000000004

    1. Initial program 98.6%

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2 + \cos \color{blue}{\phi_1}} \]
      9. lower-fma.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), \color{blue}{\cos \phi_2}, \cos \phi_1\right)} \]
      10. 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), \cos \color{blue}{\phi_2}, \cos \phi_1\right)} \]
      11. lift--.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), \cos \phi_2, \cos \phi_1\right)} \]
      12. 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), \cos \phi_2, \cos \phi_1\right)} \]
      13. lift-cos.f6442.0

        \[\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), \cos \phi_2, \cos \phi_1\right)} \]
    4. Applied rewrites42.0%

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

    if -0.0200000000000000004 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < 4.99999999999999977e-7

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999977e-7 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < 5

    1. Initial program 98.6%

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2 + \cos \color{blue}{\phi_1}} \]
      9. lower-fma.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), \color{blue}{\cos \phi_2}, \cos \phi_1\right)} \]
      10. 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), \cos \color{blue}{\phi_2}, \cos \phi_1\right)} \]
      11. lift--.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), \cos \phi_2, \cos \phi_1\right)} \]
      12. 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), \cos \phi_2, \cos \phi_1\right)} \]
      13. lift-cos.f6442.0

        \[\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), \cos \phi_2, \cos \phi_1\right)} \]
    4. Applied rewrites42.0%

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

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

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

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

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

    if 5 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2))))))

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1} + \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
    11. Step-by-step derivation
      1. sin-+PI/2-rev61.4

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

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

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

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

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

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
      8. lift-/.f6461.4

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
    12. Applied rewrites61.4%

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

Alternative 5: 97.6% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\ t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\ t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\ t_3 := \cos \phi_2 \cdot t\_2\\ t_4 := \lambda_1 + \tan^{-1}_* \frac{t\_3}{\cos \phi_1 + \cos \phi_2 \cdot t\_1}\\ t_5 := \tan^{-1}_* \frac{t\_2 \cdot \cos \phi_2}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\ \mathbf{if}\;t\_4 \leq -5:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_3}{\mathsf{fma}\left(t\_1, \cos \phi_2, 1\right)}\\ \mathbf{elif}\;t\_4 \leq -0.02:\\ \;\;\;\;t\_5\\ \mathbf{elif}\;t\_4 \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_3}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(-0.5, \lambda_2, \lambda_1\right), \lambda_2, 1\right)}\\ \mathbf{elif}\;t\_4 \leq 5:\\ \;\;\;\;t\_5\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot t\_2}{1 + t\_0 \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (fma (* phi2 phi2) -0.5 1.0))
        (t_1 (cos (- lambda1 lambda2)))
        (t_2 (sin (- lambda1 lambda2)))
        (t_3 (* (cos phi2) t_2))
        (t_4 (+ lambda1 (atan2 t_3 (+ (cos phi1) (* (cos phi2) t_1)))))
        (t_5
         (atan2 (* t_2 (cos phi2)) (fma (cos lambda2) (cos phi2) (cos phi1)))))
   (if (<= t_4 -5.0)
     (+ lambda1 (atan2 t_3 (fma t_1 (cos phi2) 1.0)))
     (if (<= t_4 -0.02)
       t_5
       (if (<= t_4 5e-7)
         (+
          lambda1
          (atan2
           t_3
           (+
            (cos phi1)
            (* (cos phi2) (fma (fma -0.5 lambda2 lambda1) lambda2 1.0)))))
         (if (<= t_4 5.0)
           t_5
           (+
            lambda1
            (atan2
             (* t_0 t_2)
             (+
              1.0
              (* t_0 (sin (+ (- (- lambda1 lambda2)) (/ PI 2.0)))))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = fma((phi2 * phi2), -0.5, 1.0);
	double t_1 = cos((lambda1 - lambda2));
	double t_2 = sin((lambda1 - lambda2));
	double t_3 = cos(phi2) * t_2;
	double t_4 = lambda1 + atan2(t_3, (cos(phi1) + (cos(phi2) * t_1)));
	double t_5 = atan2((t_2 * cos(phi2)), fma(cos(lambda2), cos(phi2), cos(phi1)));
	double tmp;
	if (t_4 <= -5.0) {
		tmp = lambda1 + atan2(t_3, fma(t_1, cos(phi2), 1.0));
	} else if (t_4 <= -0.02) {
		tmp = t_5;
	} else if (t_4 <= 5e-7) {
		tmp = lambda1 + atan2(t_3, (cos(phi1) + (cos(phi2) * fma(fma(-0.5, lambda2, lambda1), lambda2, 1.0))));
	} else if (t_4 <= 5.0) {
		tmp = t_5;
	} else {
		tmp = lambda1 + atan2((t_0 * t_2), (1.0 + (t_0 * sin((-(lambda1 - lambda2) + (((double) M_PI) / 2.0))))));
	}
	return tmp;
}
function code(lambda1, lambda2, phi1, phi2)
	t_0 = fma(Float64(phi2 * phi2), -0.5, 1.0)
	t_1 = cos(Float64(lambda1 - lambda2))
	t_2 = sin(Float64(lambda1 - lambda2))
	t_3 = Float64(cos(phi2) * t_2)
	t_4 = Float64(lambda1 + atan(t_3, Float64(cos(phi1) + Float64(cos(phi2) * t_1))))
	t_5 = atan(Float64(t_2 * cos(phi2)), fma(cos(lambda2), cos(phi2), cos(phi1)))
	tmp = 0.0
	if (t_4 <= -5.0)
		tmp = Float64(lambda1 + atan(t_3, fma(t_1, cos(phi2), 1.0)));
	elseif (t_4 <= -0.02)
		tmp = t_5;
	elseif (t_4 <= 5e-7)
		tmp = Float64(lambda1 + atan(t_3, Float64(cos(phi1) + Float64(cos(phi2) * fma(fma(-0.5, lambda2, lambda1), lambda2, 1.0)))));
	elseif (t_4 <= 5.0)
		tmp = t_5;
	else
		tmp = Float64(lambda1 + atan(Float64(t_0 * t_2), Float64(1.0 + Float64(t_0 * sin(Float64(Float64(-Float64(lambda1 - lambda2)) + Float64(pi / 2.0)))))));
	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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(lambda1 + N[ArcTan[t$95$3 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[ArcTan[N[(t$95$2 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$4, -5.0], N[(lambda1 + N[ArcTan[t$95$3 / N[(t$95$1 * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, -0.02], t$95$5, If[LessEqual[t$95$4, 5e-7], N[(lambda1 + N[ArcTan[t$95$3 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(-0.5 * lambda2 + lambda1), $MachinePrecision] * lambda2 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 5.0], t$95$5, N[(lambda1 + N[ArcTan[N[(t$95$0 * t$95$2), $MachinePrecision] / N[(1.0 + N[(t$95$0 * N[Sin[N[((-N[(lambda1 - lambda2), $MachinePrecision]) + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_4 \leq -0.02:\\
\;\;\;\;t\_5\\

\mathbf{elif}\;t\_4 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_3}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\mathsf{fma}\left(-0.5, \lambda_2, \lambda_1\right), \lambda_2, 1\right)}\\

\mathbf{elif}\;t\_4 \leq 5:\\
\;\;\;\;t\_5\\

\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot t\_2}{1 + t\_0 \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -5

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

    if -5 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -0.0200000000000000004 or 4.99999999999999977e-7 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < 5

    1. Initial program 98.6%

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

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

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

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

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

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

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

        \[\leadsto \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2 + \cos \color{blue}{\phi_1}} \]
      9. lower-fma.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), \color{blue}{\cos \phi_2}, \cos \phi_1\right)} \]
      10. 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), \cos \color{blue}{\phi_2}, \cos \phi_1\right)} \]
      11. lift--.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), \cos \phi_2, \cos \phi_1\right)} \]
      12. 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), \cos \phi_2, \cos \phi_1\right)} \]
      13. lift-cos.f6442.0

        \[\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), \cos \phi_2, \cos \phi_1\right)} \]
    4. Applied rewrites42.0%

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

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

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

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

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

    if -0.0200000000000000004 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < 4.99999999999999977e-7

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2))))))

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1} + \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
    11. Step-by-step derivation
      1. sin-+PI/2-rev61.4

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

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

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

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

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

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
      8. lift-/.f6461.4

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
    12. Applied rewrites61.4%

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

Alternative 6: 87.8% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.001388888888888889, 0.041666666666666664\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.5, \phi_2 \cdot \phi_2, 1\right)\\
\mathbf{if}\;\phi_2 \leq 0.45:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot t\_0}{\cos \phi_1 + t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\

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


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

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{720}, \frac{1}{24}\right) \cdot \left(\phi_2 \cdot \phi_2\right) - \frac{1}{2}, \phi_2 \cdot \color{blue}{\phi_2}, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)} \]
      15. lower-*.f6475.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.450000000000000011 < phi2

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 86.4% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 phi2) < 0.99950000000000006

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.99950000000000006 < (cos.f64 phi2)

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 81.8% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.23499999999999999 < phi2

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

Alternative 9: 81.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\ t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\cos \phi_2 \leq 0.87:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(t\_0, \cos \phi_2, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{t\_0 + \cos \phi_1}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (cos (- lambda1 lambda2)))
        (t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
   (if (<= (cos phi2) 0.87)
     (+ lambda1 (atan2 t_1 (fma t_0 (cos phi2) 1.0)))
     (+ lambda1 (atan2 t_1 (+ t_0 (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = cos((lambda1 - lambda2));
	double t_1 = cos(phi2) * sin((lambda1 - lambda2));
	double tmp;
	if (cos(phi2) <= 0.87) {
		tmp = lambda1 + atan2(t_1, fma(t_0, cos(phi2), 1.0));
	} else {
		tmp = lambda1 + atan2(t_1, (t_0 + cos(phi1)));
	}
	return tmp;
}
function code(lambda1, lambda2, phi1, phi2)
	t_0 = cos(Float64(lambda1 - lambda2))
	t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2)))
	tmp = 0.0
	if (cos(phi2) <= 0.87)
		tmp = Float64(lambda1 + atan(t_1, fma(t_0, cos(phi2), 1.0)));
	else
		tmp = Float64(lambda1 + atan(t_1, Float64(t_0 + cos(phi1))));
	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[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.87], N[(lambda1 + N[ArcTan[t$95$1 / N[(t$95$0 * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(t$95$0 + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.87:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(t\_0, \cos \phi_2, 1\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 phi2) < 0.869999999999999996

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

    if 0.869999999999999996 < (cos.f64 phi2)

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

Alternative 10: 78.1% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 11: 76.3% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 75.2% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 66.0% 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 := t\_0 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\cos \phi_1 \leq 0.99:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{1 + t\_0 \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\left(\phi_1 \cdot \phi_1\right) \cdot 0.041666666666666664 - 0.5, \phi_1 \cdot \phi_1, 1\right) + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (fma (* phi2 phi2) -0.5 1.0))
        (t_1 (* t_0 (sin (- lambda1 lambda2)))))
   (if (<= (cos phi1) 0.99)
     (+
      lambda1
      (atan2 t_1 (+ 1.0 (* t_0 (sin (+ (- (- lambda1 lambda2)) (/ PI 2.0)))))))
     (+
      lambda1
      (atan2
       t_1
       (+
        (fma (- (* (* phi1 phi1) 0.041666666666666664) 0.5) (* phi1 phi1) 1.0)
        (* t_0 (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = fma((phi2 * phi2), -0.5, 1.0);
	double t_1 = t_0 * sin((lambda1 - lambda2));
	double tmp;
	if (cos(phi1) <= 0.99) {
		tmp = lambda1 + atan2(t_1, (1.0 + (t_0 * sin((-(lambda1 - lambda2) + (((double) M_PI) / 2.0))))));
	} else {
		tmp = lambda1 + atan2(t_1, (fma((((phi1 * phi1) * 0.041666666666666664) - 0.5), (phi1 * phi1), 1.0) + (t_0 * cos((lambda1 - lambda2)))));
	}
	return tmp;
}
function code(lambda1, lambda2, phi1, phi2)
	t_0 = fma(Float64(phi2 * phi2), -0.5, 1.0)
	t_1 = Float64(t_0 * sin(Float64(lambda1 - lambda2)))
	tmp = 0.0
	if (cos(phi1) <= 0.99)
		tmp = Float64(lambda1 + atan(t_1, Float64(1.0 + Float64(t_0 * sin(Float64(Float64(-Float64(lambda1 - lambda2)) + Float64(pi / 2.0)))))));
	else
		tmp = Float64(lambda1 + atan(t_1, Float64(fma(Float64(Float64(Float64(phi1 * phi1) * 0.041666666666666664) - 0.5), Float64(phi1 * phi1), 1.0) + Float64(t_0 * cos(Float64(lambda1 - lambda2))))));
	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[(t$95$0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.99], N[(lambda1 + N[ArcTan[t$95$1 / N[(1.0 + N[(t$95$0 * N[Sin[N[((-N[(lambda1 - lambda2), $MachinePrecision]) + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
t_1 := t\_0 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.99:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{1 + t\_0 \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 phi1) < 0.98999999999999999

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1} + \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
    11. Step-by-step derivation
      1. sin-+PI/2-rev61.4

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

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

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

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

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

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
      8. lift-/.f6461.4

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
    12. Applied rewrites61.4%

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

    if 0.98999999999999999 < (cos.f64 phi1)

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 64.9% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\ t_1 := t\_0 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\ \mathbf{if}\;\phi_1 \leq 9 \cdot 10^{-22}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(-0.5, \phi_1 \cdot \phi_1, 1\right) + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\ \mathbf{else}:\\ \;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{1 + t\_0 \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)}\\ \end{array} \end{array} \]
(FPCore (lambda1 lambda2 phi1 phi2)
 :precision binary64
 (let* ((t_0 (fma (* phi2 phi2) -0.5 1.0))
        (t_1 (* t_0 (sin (- lambda1 lambda2)))))
   (if (<= phi1 9e-22)
     (+
      lambda1
      (atan2
       t_1
       (+ (fma -0.5 (* phi1 phi1) 1.0) (* t_0 (cos (- lambda1 lambda2))))))
     (+
      lambda1
      (atan2
       t_1
       (+ 1.0 (* t_0 (sin (+ (- (- lambda1 lambda2)) (/ PI 2.0))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
	double t_0 = fma((phi2 * phi2), -0.5, 1.0);
	double t_1 = t_0 * sin((lambda1 - lambda2));
	double tmp;
	if (phi1 <= 9e-22) {
		tmp = lambda1 + atan2(t_1, (fma(-0.5, (phi1 * phi1), 1.0) + (t_0 * cos((lambda1 - lambda2)))));
	} else {
		tmp = lambda1 + atan2(t_1, (1.0 + (t_0 * sin((-(lambda1 - lambda2) + (((double) M_PI) / 2.0))))));
	}
	return tmp;
}
function code(lambda1, lambda2, phi1, phi2)
	t_0 = fma(Float64(phi2 * phi2), -0.5, 1.0)
	t_1 = Float64(t_0 * sin(Float64(lambda1 - lambda2)))
	tmp = 0.0
	if (phi1 <= 9e-22)
		tmp = Float64(lambda1 + atan(t_1, Float64(fma(-0.5, Float64(phi1 * phi1), 1.0) + Float64(t_0 * cos(Float64(lambda1 - lambda2))))));
	else
		tmp = Float64(lambda1 + atan(t_1, Float64(1.0 + Float64(t_0 * sin(Float64(Float64(-Float64(lambda1 - lambda2)) + Float64(pi / 2.0)))))));
	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[(t$95$0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, 9e-22], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[(-0.5 * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(1.0 + N[(t$95$0 * N[Sin[N[((-N[(lambda1 - lambda2), $MachinePrecision]) + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if phi1 < 8.99999999999999973e-22

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 8.99999999999999973e-22 < phi1

      1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1} + \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
      11. Step-by-step derivation
        1. sin-+PI/2-rev61.4

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

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

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

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

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

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

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
        8. lift-/.f6461.4

          \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
      12. Applied rewrites61.4%

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

    Alternative 15: 61.4% accurate, 1.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\ \lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + t\_0 \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \end{array} \end{array} \]
    (FPCore (lambda1 lambda2 phi1 phi2)
     :precision binary64
     (let* ((t_0 (fma (* phi2 phi2) -0.5 1.0)))
       (+
        lambda1
        (atan2
         (* t_0 (sin (- lambda1 lambda2)))
         (+ 1.0 (* t_0 (sin (+ (- (- lambda1 lambda2)) (/ PI 2.0)))))))))
    double code(double lambda1, double lambda2, double phi1, double phi2) {
    	double t_0 = fma((phi2 * phi2), -0.5, 1.0);
    	return lambda1 + atan2((t_0 * sin((lambda1 - lambda2))), (1.0 + (t_0 * sin((-(lambda1 - lambda2) + (((double) M_PI) / 2.0))))));
    }
    
    function code(lambda1, lambda2, phi1, phi2)
    	t_0 = fma(Float64(phi2 * phi2), -0.5, 1.0)
    	return Float64(lambda1 + atan(Float64(t_0 * sin(Float64(lambda1 - lambda2))), Float64(1.0 + Float64(t_0 * sin(Float64(Float64(-Float64(lambda1 - lambda2)) + Float64(pi / 2.0)))))))
    end
    
    code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(t$95$0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(t$95$0 * N[Sin[N[((-N[(lambda1 - lambda2), $MachinePrecision]) + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
    \lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + t\_0 \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)}
    \end{array}
    \end{array}
    
    Derivation
    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1} + \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
    11. Step-by-step derivation
      1. sin-+PI/2-rev61.4

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

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

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

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

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

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

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \mathsf{fma}\left(\phi_2 \cdot \phi_2, \frac{-1}{2}, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
      8. lift-/.f6461.4

        \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
    12. Applied rewrites61.4%

      \[\leadsto \lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\color{blue}{1} + \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\left(-\left(\lambda_1 - \lambda_2\right)\right) + \frac{\pi}{2}\right)} \]
    13. Add Preprocessing

    Alternative 16: 52.1% accurate, 48.6× speedup?

    \[\begin{array}{l} \\ 1 \cdot \lambda_1 \end{array} \]
    (FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (* 1.0 lambda1))
    double code(double lambda1, double lambda2, double phi1, double phi2) {
    	return 1.0 * lambda1;
    }
    
    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 = 1.0d0 * lambda1
    end function
    
    public static double code(double lambda1, double lambda2, double phi1, double phi2) {
    	return 1.0 * lambda1;
    }
    
    def code(lambda1, lambda2, phi1, phi2):
    	return 1.0 * lambda1
    
    function code(lambda1, lambda2, phi1, phi2)
    	return Float64(1.0 * lambda1)
    end
    
    function tmp = code(lambda1, lambda2, phi1, phi2)
    	tmp = 1.0 * lambda1;
    end
    
    code[lambda1_, lambda2_, phi1_, phi2_] := N[(1.0 * lambda1), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    1 \cdot \lambda_1
    \end{array}
    
    Derivation
    1. Initial program 98.6%

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

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

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

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

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

      \[\leadsto 1 \cdot \lambda_1 \]
    6. Step-by-step derivation
      1. Applied rewrites52.1%

        \[\leadsto 1 \cdot \lambda_1 \]
      2. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2025141 
      (FPCore (lambda1 lambda2 phi1 phi2)
        :name "Midpoint on a great circle"
        :precision binary64
        (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))