
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 24 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi2 -0.5)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (* t_1 (* t_2 t_1)))
(t_4 (fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2))))
(t_5 (sin (* phi2 -0.5)))
(t_6 (cos (* phi1 0.5)))
(t_7 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_8 (sin (* phi1 0.5)))
(t_9
(pow (- (* t_8 (cos (* phi2 0.5))) (* (sin (* phi2 0.5)) t_6)) 2.0)))
(if (<= phi2 -2.4e-14)
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) t_7)
(pow (fma t_5 t_6 (* t_0 t_8)) 2.0)))
(sqrt (- 1.0 (fma t_2 t_7 t_9)))))
(if (<= phi2 0.145)
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (- 0.5 (* 0.5 t_4)))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(sqrt (+ 0.5 (* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 t_4))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (fma t_8 t_0 (* t_5 t_6)) 2.0) t_3))
(sqrt (- 1.0 (+ t_3 t_9))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 * -0.5));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * cos(phi2);
double t_3 = t_1 * (t_2 * t_1);
double t_4 = fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2)));
double t_5 = sin((phi2 * -0.5));
double t_6 = cos((phi1 * 0.5));
double t_7 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_8 = sin((phi1 * 0.5));
double t_9 = pow(((t_8 * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * t_6)), 2.0);
double tmp;
if (phi2 <= -2.4e-14) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * t_7), pow(fma(t_5, t_6, (t_0 * t_8)), 2.0))), sqrt((1.0 - fma(t_2, t_7, t_9))));
} else if (phi2 <= 0.145) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (0.5 - (0.5 * t_4))), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * t_4)))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(fma(t_8, t_0, (t_5 * t_6)), 2.0) + t_3)), sqrt((1.0 - (t_3 + t_9)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * -0.5)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = Float64(t_1 * Float64(t_2 * t_1)) t_4 = fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2))) t_5 = sin(Float64(phi2 * -0.5)) t_6 = cos(Float64(phi1 * 0.5)) t_7 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_8 = sin(Float64(phi1 * 0.5)) t_9 = Float64(Float64(t_8 * cos(Float64(phi2 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * t_6)) ^ 2.0 tmp = 0.0 if (phi2 <= -2.4e-14) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * t_7), (fma(t_5, t_6, Float64(t_0 * t_8)) ^ 2.0))), sqrt(Float64(1.0 - fma(t_2, t_7, t_9))))); elseif (phi2 <= 0.145) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * t_4))), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * t_4)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((fma(t_8, t_0, Float64(t_5 * t_6)) ^ 2.0) + t_3)), sqrt(Float64(1.0 - Float64(t_3 + t_9)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$8 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$9 = N[Power[N[(N[(t$95$8 * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$6), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi2, -2.4e-14], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$7), $MachinePrecision] + N[Power[N[(t$95$5 * t$95$6 + N[(t$95$0 * t$95$8), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 * t$95$7 + t$95$9), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.145], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(t$95$8 * t$95$0 + N[(t$95$5 * t$95$6), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 + t$95$9), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_2 \cdot -0.5\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := t\_1 \cdot \left(t\_2 \cdot t\_1\right)\\
t_4 := \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)\\
t_5 := \sin \left(\phi_2 \cdot -0.5\right)\\
t_6 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_7 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_8 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_9 := {\left(t\_8 \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot t\_6\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -2.4 \cdot 10^{-14}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_7, {\left(\mathsf{fma}\left(t\_5, t\_6, t\_0 \cdot t\_8\right)\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t\_2, t\_7, t\_9\right)}}\\
\mathbf{elif}\;\phi_2 \leq 0.145:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot t\_4\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot t\_4\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(t\_8, t\_0, t\_5 \cdot t\_6\right)\right)}^{2} + t\_3}}{\sqrt{1 - \left(t\_3 + t\_9\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -2.4e-14Initial program 55.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6456.1
Applied rewrites56.1%
lift-sin.f64N/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
metadata-evalN/A
lift--.f64N/A
distribute-rgt-out--N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lift-*.f64N/A
sin-sumN/A
lift-sin.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.0%
Taylor expanded in lambda1 around -inf
Applied rewrites82.1%
if -2.4e-14 < phi2 < 0.14499999999999999Initial program 73.7%
Applied rewrites64.6%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6464.6
Applied rewrites64.6%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6465.1
Applied rewrites65.1%
Applied rewrites89.4%
if 0.14499999999999999 < phi2 Initial program 40.8%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6442.8
Applied rewrites42.8%
lift-sin.f64N/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
metadata-evalN/A
lift--.f64N/A
distribute-rgt-out--N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lift-*.f64N/A
sin-sumN/A
lift-sin.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites77.1%
Final simplification84.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2))))
(t_1 (cos (* phi1 0.5)))
(t_2 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_3 (sin (* phi1 0.5)))
(t_4
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) t_2)
(pow
(fma (sin (* phi2 -0.5)) t_1 (* (cos (* phi2 -0.5)) t_3))
2.0)))
(sqrt
(-
1.0
(fma
(* (cos phi1) (cos phi2))
t_2
(pow
(- (* t_3 (cos (* phi2 0.5))) (* (sin (* phi2 0.5)) t_1))
2.0))))))))
(if (<= phi2 -2.4e-14)
t_4
(if (<= phi2 0.145)
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (- 0.5 (* 0.5 t_0)))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(sqrt (+ 0.5 (* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 t_0))))))))
t_4))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2)));
double t_1 = cos((phi1 * 0.5));
double t_2 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_3 = sin((phi1 * 0.5));
double t_4 = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * t_2), pow(fma(sin((phi2 * -0.5)), t_1, (cos((phi2 * -0.5)) * t_3)), 2.0))), sqrt((1.0 - fma((cos(phi1) * cos(phi2)), t_2, pow(((t_3 * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * t_1)), 2.0)))));
double tmp;
if (phi2 <= -2.4e-14) {
tmp = t_4;
} else if (phi2 <= 0.145) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (0.5 - (0.5 * t_0))), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * t_0)))))));
} else {
tmp = t_4;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2))) t_1 = cos(Float64(phi1 * 0.5)) t_2 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_3 = sin(Float64(phi1 * 0.5)) t_4 = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * t_2), (fma(sin(Float64(phi2 * -0.5)), t_1, Float64(cos(Float64(phi2 * -0.5)) * t_3)) ^ 2.0))), sqrt(Float64(1.0 - fma(Float64(cos(phi1) * cos(phi2)), t_2, (Float64(Float64(t_3 * cos(Float64(phi2 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * t_1)) ^ 2.0)))))) tmp = 0.0 if (phi2 <= -2.4e-14) tmp = t_4; elseif (phi2 <= 0.145) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * t_0))), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * t_0)))))))); else tmp = t_4; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] * t$95$1 + N[(N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2 + N[Power[N[(N[(t$95$3 * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.4e-14], t$95$4, If[LessEqual[phi2, 0.145], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$4]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_3 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_4 := \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_2, {\left(\mathsf{fma}\left(\sin \left(\phi_2 \cdot -0.5\right), t\_1, \cos \left(\phi_2 \cdot -0.5\right) \cdot t\_3\right)\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, t\_2, {\left(t\_3 \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot t\_1\right)}^{2}\right)}}\\
\mathbf{if}\;\phi_2 \leq -2.4 \cdot 10^{-14}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;\phi_2 \leq 0.145:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot t\_0\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot t\_0\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
\end{array}
if phi2 < -2.4e-14 or 0.14499999999999999 < phi2 Initial program 47.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6449.5
Applied rewrites49.5%
lift-sin.f64N/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
metadata-evalN/A
lift--.f64N/A
distribute-rgt-out--N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lift-*.f64N/A
sin-sumN/A
lift-sin.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites79.6%
Taylor expanded in lambda1 around -inf
Applied rewrites79.6%
if -2.4e-14 < phi2 < 0.14499999999999999Initial program 73.7%
Applied rewrites64.6%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6464.6
Applied rewrites64.6%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6465.1
Applied rewrites65.1%
Applied rewrites89.4%
Final simplification84.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* 0.5 (cos (* 2.0 lambda2))))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos lambda1) (cos lambda2)))
(t_3 (* 0.5 (cos (* 2.0 lambda1))))
(t_4
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(*
(cos phi2)
(- 0.5 (* 0.5 (fma (sin lambda2) (sin lambda1) t_2))))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(sqrt
(+
0.5
(*
(cos phi1)
(+
0.5
(-
(*
-0.5
(/
(- (* (- 0.5 t_0) (- 0.5 t_3)) (* (+ 0.5 t_3) (+ 0.5 t_0)))
(- t_2 (* (sin lambda2) (sin lambda1)))))
0.5))))))))
(t_5 (* t_1 (* (* (cos phi1) (cos phi2)) t_1))))
(if (<= lambda2 -1.15e+108)
t_4
(if (<= lambda2 3e+48)
(*
R
(*
2.0
(atan2
(sqrt (+ t_5 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
1.0
(+
t_5
(pow
(-
(* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0)))))))
t_4))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * cos((2.0 * lambda2));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(lambda1) * cos(lambda2);
double t_3 = 0.5 * cos((2.0 * lambda1));
double t_4 = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (0.5 - (0.5 * fma(sin(lambda2), sin(lambda1), t_2)))), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt((0.5 + (cos(phi1) * (0.5 + ((-0.5 * ((((0.5 - t_0) * (0.5 - t_3)) - ((0.5 + t_3) * (0.5 + t_0))) / (t_2 - (sin(lambda2) * sin(lambda1))))) - 0.5))))));
double t_5 = t_1 * ((cos(phi1) * cos(phi2)) * t_1);
double tmp;
if (lambda2 <= -1.15e+108) {
tmp = t_4;
} else if (lambda2 <= 3e+48) {
tmp = R * (2.0 * atan2(sqrt((t_5 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (t_5 + pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0))))));
} else {
tmp = t_4;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 * cos(Float64(2.0 * lambda2))) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(lambda1) * cos(lambda2)) t_3 = Float64(0.5 * cos(Float64(2.0 * lambda1))) t_4 = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * fma(sin(lambda2), sin(lambda1), t_2)))), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 + Float64(Float64(-0.5 * Float64(Float64(Float64(Float64(0.5 - t_0) * Float64(0.5 - t_3)) - Float64(Float64(0.5 + t_3) * Float64(0.5 + t_0))) / Float64(t_2 - Float64(sin(lambda2) * sin(lambda1))))) - 0.5))))))) t_5 = Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) tmp = 0.0 if (lambda2 <= -1.15e+108) tmp = t_4; elseif (lambda2 <= 3e+48) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_5 + (Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0))))))); else tmp = t_4; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 * N[Cos[N[(2.0 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(0.5 * N[Cos[N[(2.0 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 + N[(N[(-0.5 * N[(N[(N[(N[(0.5 - t$95$0), $MachinePrecision] * N[(0.5 - t$95$3), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 + t$95$3), $MachinePrecision] * N[(0.5 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -1.15e+108], t$95$4, If[LessEqual[lambda2, 3e+48], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$5 + N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$4]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos \left(2 \cdot \lambda_2\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \lambda_1 \cdot \cos \lambda_2\\
t_3 := 0.5 \cdot \cos \left(2 \cdot \lambda_1\right)\\
t_4 := \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, t\_2\right)\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 + \left(-0.5 \cdot \frac{\left(0.5 - t\_0\right) \cdot \left(0.5 - t\_3\right) - \left(0.5 + t\_3\right) \cdot \left(0.5 + t\_0\right)}{t\_2 - \sin \lambda_2 \cdot \sin \lambda_1} - 0.5\right)\right)}}\\
t_5 := t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right)\\
\mathbf{if}\;\lambda_2 \leq -1.15 \cdot 10^{+108}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;\lambda_2 \leq 3 \cdot 10^{+48}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(t\_5 + {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
\end{array}
if lambda2 < -1.1499999999999999e108 or 3e48 < lambda2 Initial program 43.9%
Applied rewrites43.9%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6438.9
Applied rewrites38.9%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6439.6
Applied rewrites39.6%
Applied rewrites65.6%
if -1.1499999999999999e108 < lambda2 < 3e48Initial program 70.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6471.0
Applied rewrites71.0%
Final simplification69.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_2 (fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2))))
(t_3
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (- 0.5 (* 0.5 t_2)))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(sqrt (+ 0.5 (* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 t_2))))))))))
(if (<= lambda2 -1.15e+108)
t_3
(if (<= lambda2 3e+48)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
1.0
(+
t_1
(pow
(-
(* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0)))))))
t_3))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2)));
double t_3 = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (0.5 - (0.5 * t_2))), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * t_2)))))));
double tmp;
if (lambda2 <= -1.15e+108) {
tmp = t_3;
} else if (lambda2 <= 3e+48) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (t_1 + pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0))))));
} else {
tmp = t_3;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_2 = fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2))) t_3 = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * t_2))), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * t_2)))))))) tmp = 0.0 if (lambda2 <= -1.15e+108) tmp = t_3; elseif (lambda2 <= 3e+48) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_1 + (Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0))))))); else tmp = t_3; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -1.15e+108], t$95$3, If[LessEqual[lambda2, 3e+48], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
t_2 := \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)\\
t_3 := \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot t\_2\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot t\_2\right)\right)}}\\
\mathbf{if}\;\lambda_2 \leq -1.15 \cdot 10^{+108}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\lambda_2 \leq 3 \cdot 10^{+48}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(t\_1 + {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if lambda2 < -1.1499999999999999e108 or 3e48 < lambda2 Initial program 43.9%
Applied rewrites43.9%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6438.9
Applied rewrites38.9%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6439.6
Applied rewrites39.6%
Applied rewrites65.5%
if -1.1499999999999999e108 < lambda2 < 3e48Initial program 70.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6471.0
Applied rewrites71.0%
Final simplification68.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (cos (- phi1 phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (cos (- lambda1 lambda2)))
(t_4 (fma -0.5 t_3 0.5)))
(if (<= (+ (* t_2 (* t_0 t_2)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)) 1e-25)
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (fma -0.5 (cos lambda1) 0.5))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
(sqrt (+ 0.5 (* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 t_3))))))))
(*
(* R 2.0)
(atan2
(sqrt (fma t_0 t_4 (fma -0.5 t_1 0.5)))
(sqrt (fma (* (cos phi1) (- (cos phi2))) t_4 (fma 0.5 t_1 0.5))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((phi1 - phi2));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = cos((lambda1 - lambda2));
double t_4 = fma(-0.5, t_3, 0.5);
double tmp;
if (((t_2 * (t_0 * t_2)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)) <= 1e-25) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), pow(sin((0.5 * (phi1 - phi2))), 2.0))), sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * t_3)))))));
} else {
tmp = (R * 2.0) * atan2(sqrt(fma(t_0, t_4, fma(-0.5, t_1, 0.5))), sqrt(fma((cos(phi1) * -cos(phi2)), t_4, fma(0.5, t_1, 0.5))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(phi1 - phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = cos(Float64(lambda1 - lambda2)) t_4 = fma(-0.5, t_3, 0.5) tmp = 0.0 if (Float64(Float64(t_2 * Float64(t_0 * t_2)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) <= 1e-25) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))), sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * t_3)))))))); else tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(t_0, t_4, fma(-0.5, t_1, 0.5))), sqrt(fma(Float64(cos(phi1) * Float64(-cos(phi2))), t_4, fma(0.5, t_1, 0.5))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(-0.5 * t$95$3 + 0.5), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$2 * N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 1e-25], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * N[Cos[lambda1], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(t$95$0 * t$95$4 + N[(-0.5 * t$95$1 + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision])), $MachinePrecision] * t$95$4 + N[(0.5 * t$95$1 + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\phi_1 - \phi_2\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_4 := \mathsf{fma}\left(-0.5, t\_3, 0.5\right)\\
\mathbf{if}\;t\_2 \cdot \left(t\_0 \cdot t\_2\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} \leq 10^{-25}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \mathsf{fma}\left(-0.5, \cos \lambda_1, 0.5\right), {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot t\_3\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t\_0, t\_4, \mathsf{fma}\left(-0.5, t\_1, 0.5\right)\right)}}{\sqrt{\mathsf{fma}\left(\cos \phi_1 \cdot \left(-\cos \phi_2\right), t\_4, \mathsf{fma}\left(0.5, t\_1, 0.5\right)\right)}}\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) < 1.00000000000000004e-25Initial program 73.1%
Applied rewrites3.0%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f643.0
Applied rewrites3.0%
Taylor expanded in lambda2 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f644.7
Applied rewrites4.7%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
sqr-sin-aN/A
lift-*.f64N/A
metadata-evalN/A
div-invN/A
lift-/.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
metadata-evalN/A
div-invN/A
lift-/.f64N/A
lift-sin.f64N/A
Applied rewrites50.7%
if 1.00000000000000004e-25 < (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) Initial program 59.3%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6460.2
Applied rewrites60.2%
lift-sin.f64N/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
metadata-evalN/A
lift--.f64N/A
distribute-rgt-out--N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lift-*.f64N/A
sin-sumN/A
lift-sin.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites76.0%
Applied rewrites58.8%
Final simplification58.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2))))
(t_2
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (- 0.5 (* 0.5 t_1)))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(sqrt (+ 0.5 (* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 t_1)))))))))
(t_3 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= lambda2 -1.15e+108)
t_2
(if (<= lambda2 3e+48)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(fma
(sin (* phi1 0.5))
(cos (* phi2 -0.5))
(* (sin (* phi2 -0.5)) (cos (* phi1 0.5))))
2.0)
(* t_3 (* t_0 t_3))))
(sqrt
(fma
(cos (- phi1 phi2))
0.5
(- 0.5 (* t_0 (fma -0.5 (cos (- lambda1 lambda2)) 0.5))))))))
t_2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2)));
double t_2 = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (0.5 - (0.5 * t_1))), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * t_1)))))));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= -1.15e+108) {
tmp = t_2;
} else if (lambda2 <= 3e+48) {
tmp = R * (2.0 * atan2(sqrt((pow(fma(sin((phi1 * 0.5)), cos((phi2 * -0.5)), (sin((phi2 * -0.5)) * cos((phi1 * 0.5)))), 2.0) + (t_3 * (t_0 * t_3)))), sqrt(fma(cos((phi1 - phi2)), 0.5, (0.5 - (t_0 * fma(-0.5, cos((lambda1 - lambda2)), 0.5)))))));
} else {
tmp = t_2;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2))) t_2 = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * t_1))), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * t_1)))))))) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (lambda2 <= -1.15e+108) tmp = t_2; elseif (lambda2 <= 3e+48) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((fma(sin(Float64(phi1 * 0.5)), cos(Float64(phi2 * -0.5)), Float64(sin(Float64(phi2 * -0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0) + Float64(t_3 * Float64(t_0 * t_3)))), sqrt(fma(cos(Float64(phi1 - phi2)), 0.5, Float64(0.5 - Float64(t_0 * fma(-0.5, cos(Float64(lambda1 - lambda2)), 0.5)))))))); else tmp = t_2; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -1.15e+108], t$95$2, If[LessEqual[lambda2, 3e+48], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$3 * N[(t$95$0 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] * 0.5 + N[(0.5 - N[(t$95$0 * N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)\\
t_2 := \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot t\_1\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot t\_1\right)\right)}}\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_2 \leq -1.15 \cdot 10^{+108}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_2 \leq 3 \cdot 10^{+48}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\sin \left(\phi_1 \cdot 0.5\right), \cos \left(\phi_2 \cdot -0.5\right), \sin \left(\phi_2 \cdot -0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)\right)}^{2} + t\_3 \cdot \left(t\_0 \cdot t\_3\right)}}{\sqrt{\mathsf{fma}\left(\cos \left(\phi_1 - \phi_2\right), 0.5, 0.5 - t\_0 \cdot \mathsf{fma}\left(-0.5, \cos \left(\lambda_1 - \lambda_2\right), 0.5\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda2 < -1.1499999999999999e108 or 3e48 < lambda2 Initial program 43.9%
Applied rewrites43.9%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6438.9
Applied rewrites38.9%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6439.6
Applied rewrites39.6%
Applied rewrites65.5%
if -1.1499999999999999e108 < lambda2 < 3e48Initial program 70.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6471.0
Applied rewrites71.0%
lift-sin.f64N/A
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
metadata-evalN/A
lift--.f64N/A
distribute-rgt-out--N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lift-*.f64N/A
sin-sumN/A
lift-sin.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.4%
Applied rewrites70.9%
Final simplification68.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2))))
(t_3
(*
(* R 2.0)
(atan2
(sqrt
(fma (cos phi1) (* (cos phi2) (- 0.5 (* 0.5 t_2))) (- 0.5 t_0)))
(sqrt (+ 0.5 (* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 t_2))))))))))
(if (<= lambda2 -1.15e+108)
t_3
(if (<= lambda2 3e+48)
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (* (* (cos phi1) (cos phi2)) t_1))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(+
(+
(*
(cos phi1)
(*
(cos phi2)
(- (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))) 0.5)))
1.0)
(- t_0 0.5))))))
t_3))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * cos((2.0 * (0.5 * (phi1 - phi2))));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2)));
double t_3 = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (0.5 - (0.5 * t_2))), (0.5 - t_0))), sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * t_2)))))));
double tmp;
if (lambda2 <= -1.15e+108) {
tmp = t_3;
} else if (lambda2 <= 3e+48) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((((cos(phi1) * (cos(phi2) * ((0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2))))) - 0.5))) + 1.0) + (t_0 - 0.5)))));
} else {
tmp = t_3;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2))))) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2))) t_3 = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * t_2))), Float64(0.5 - t_0))), sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * t_2)))))))) tmp = 0.0 if (lambda2 <= -1.15e+108) tmp = t_3; elseif (lambda2 <= 3e+48) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2))))) - 0.5))) + 1.0) + Float64(t_0 - 0.5)))))); else tmp = t_3; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -1.15e+108], t$95$3, If[LessEqual[lambda2, 3e+48], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] + N[(t$95$0 - 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)\\
t_3 := \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot t\_2\right), 0.5 - t\_0\right)}}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot t\_2\right)\right)}}\\
\mathbf{if}\;\lambda_2 \leq -1.15 \cdot 10^{+108}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\lambda_2 \leq 3 \cdot 10^{+48}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right) - 0.5\right)\right) + 1\right) + \left(t\_0 - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if lambda2 < -1.1499999999999999e108 or 3e48 < lambda2 Initial program 43.9%
Applied rewrites43.9%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6438.9
Applied rewrites38.9%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6439.6
Applied rewrites39.6%
Applied rewrites65.5%
if -1.1499999999999999e108 < lambda2 < 3e48Initial program 70.0%
Applied rewrites70.2%
Final simplification68.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(+
(+
(*
(cos phi1)
(*
(cos phi2)
(- (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))) 0.5)))
1.0)
(- (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))) 0.5))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((((cos(phi1) * (cos(phi2) * ((0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2))))) - 0.5))) + 1.0) + ((0.5 * cos((2.0 * (0.5 * (phi1 - phi2))))) - 0.5)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((((cos(phi1) * (cos(phi2) * ((0.5d0 * cos((2.0d0 * (0.5d0 * (lambda1 - lambda2))))) - 0.5d0))) + 1.0d0) + ((0.5d0 * cos((2.0d0 * (0.5d0 * (phi1 - phi2))))) - 0.5d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((((Math.cos(phi1) * (Math.cos(phi2) * ((0.5 * Math.cos((2.0 * (0.5 * (lambda1 - lambda2))))) - 0.5))) + 1.0) + ((0.5 * Math.cos((2.0 * (0.5 * (phi1 - phi2))))) - 0.5)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((((math.cos(phi1) * (math.cos(phi2) * ((0.5 * math.cos((2.0 * (0.5 * (lambda1 - lambda2))))) - 0.5))) + 1.0) + ((0.5 * math.cos((2.0 * (0.5 * (phi1 - phi2))))) - 0.5)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2))))) - 0.5))) + 1.0) + Float64(Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2))))) - 0.5)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((((cos(phi1) * (cos(phi2) * ((0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2))))) - 0.5))) + 1.0) + ((0.5 * cos((2.0 * (0.5 * (phi1 - phi2))))) - 0.5))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] + N[(N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right) - 0.5\right)\right) + 1\right) + \left(0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right) - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 60.1%
Applied rewrites60.2%
Final simplification60.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(fma
(* (- (cos phi1)) (fma (cos (- lambda1 lambda2)) -0.5 0.5))
(cos phi2)
(fma 0.5 (cos (- phi1 phi2)) 0.5))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(fma((-cos(phi1) * fma(cos((lambda1 - lambda2)), -0.5, 0.5)), cos(phi2), fma(0.5, cos((phi1 - phi2)), 0.5)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(fma(Float64(Float64(-cos(phi1)) * fma(cos(Float64(lambda1 - lambda2)), -0.5, 0.5)), cos(phi2), fma(0.5, cos(Float64(phi1 - phi2)), 0.5)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[((-N[Cos[phi1], $MachinePrecision]) * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * -0.5 + 0.5), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[(0.5 * N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\mathsf{fma}\left(\left(-\cos \phi_1\right) \cdot \mathsf{fma}\left(\cos \left(\lambda_1 - \lambda_2\right), -0.5, 0.5\right), \cos \phi_2, \mathsf{fma}\left(0.5, \cos \left(\phi_1 - \phi_2\right), 0.5\right)\right)}}\right)
\end{array}
\end{array}
Initial program 60.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6460.9
Applied rewrites60.9%
Applied rewrites60.2%
Final simplification60.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(t_1 (* 0.5 (- phi1 phi2))))
(*
(* R 2.0)
(atan2
(sqrt (fma (cos phi1) (* (cos phi2) (- 0.5 t_0)) (pow (sin t_1) 2.0)))
(sqrt
(+
(+ 0.5 (* 0.5 (cos (* 2.0 t_1))))
(* (cos phi1) (* (cos phi2) (- t_0 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2))));
double t_1 = 0.5 * (phi1 - phi2);
return (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (0.5 - t_0)), pow(sin(t_1), 2.0))), sqrt(((0.5 + (0.5 * cos((2.0 * t_1)))) + (cos(phi1) * (cos(phi2) * (t_0 - 0.5))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2))))) t_1 = Float64(0.5 * Float64(phi1 - phi2)) return Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - t_0)), (sin(t_1) ^ 2.0))), sqrt(Float64(Float64(0.5 + Float64(0.5 * cos(Float64(2.0 * t_1)))) + Float64(cos(phi1) * Float64(cos(phi2) * Float64(t_0 - 0.5))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]}, N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[t$95$1], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + N[(0.5 * N[Cos[N[(2.0 * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\\
t_1 := 0.5 \cdot \left(\phi_1 - \phi_2\right)\\
\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - t\_0\right), {\sin t\_1}^{2}\right)}}{\sqrt{\left(0.5 + 0.5 \cdot \cos \left(2 \cdot t\_1\right)\right) + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(t\_0 - 0.5\right)\right)}}
\end{array}
\end{array}
Initial program 60.1%
Applied rewrites55.5%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
sqr-sin-aN/A
lift-*.f64N/A
metadata-evalN/A
div-invN/A
lift-/.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
metadata-evalN/A
div-invN/A
lift-/.f64N/A
lift-sin.f64N/A
unpow2N/A
lift-pow.f6458.2
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lift-*.f6458.2
Applied rewrites58.2%
Final simplification58.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2)))))))
(t_2 (* 0.5 (- lambda1 lambda2)))
(t_3
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (- 0.5 (* 0.5 (cos (* 2.0 t_2)))))
t_1))
(sqrt (fma (cos phi2) (- 0.5 (fma -0.5 t_0 0.5)) 0.5))))))
(if (<= phi2 -2.35e+24)
t_3
(if (<= phi2 1.9e-5)
(*
(* R 2.0)
(atan2
(sqrt (fma (cos phi1) (* (cos phi2) (pow (sin t_2) 2.0)) t_1))
(sqrt (+ 0.5 (* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 t_0))))))))
t_3))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = 0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))));
double t_2 = 0.5 * (lambda1 - lambda2);
double t_3 = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (0.5 - (0.5 * cos((2.0 * t_2))))), t_1)), sqrt(fma(cos(phi2), (0.5 - fma(-0.5, t_0, 0.5)), 0.5)));
double tmp;
if (phi2 <= -2.35e+24) {
tmp = t_3;
} else if (phi2 <= 1.9e-5) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * pow(sin(t_2), 2.0)), t_1)), sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * t_0)))))));
} else {
tmp = t_3;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))) t_2 = Float64(0.5 * Float64(lambda1 - lambda2)) t_3 = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_2))))), t_1)), sqrt(fma(cos(phi2), Float64(0.5 - fma(-0.5, t_0, 0.5)), 0.5)))) tmp = 0.0 if (phi2 <= -2.35e+24) tmp = t_3; elseif (phi2 <= 1.9e-5) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * (sin(t_2) ^ 2.0)), t_1)), sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * t_0)))))))); else tmp = t_3; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(-0.5 * t$95$0 + 0.5), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.35e+24], t$95$3, If[LessEqual[phi2, 1.9e-5], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[t$95$2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\\
t_2 := 0.5 \cdot \left(\lambda_1 - \lambda_2\right)\\
t_3 := \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_2\right)\right), t\_1\right)}}{\sqrt{\mathsf{fma}\left(\cos \phi_2, 0.5 - \mathsf{fma}\left(-0.5, t\_0, 0.5\right), 0.5\right)}}\\
\mathbf{if}\;\phi_2 \leq -2.35 \cdot 10^{+24}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_2 \leq 1.9 \cdot 10^{-5}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\sin t\_2}^{2}, t\_1\right)}}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot t\_0\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if phi2 < -2.35e24 or 1.9000000000000001e-5 < phi2 Initial program 47.5%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6420.5
Applied rewrites20.5%
Taylor expanded in phi1 around 0
associate--l+N/A
+-commutativeN/A
cos-negN/A
*-commutativeN/A
distribute-lft-out--N/A
lower-fma.f64N/A
Applied rewrites47.9%
if -2.35e24 < phi2 < 1.9000000000000001e-5Initial program 73.1%
Applied rewrites63.6%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6463.4
Applied rewrites63.4%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
sqr-sin-aN/A
lift-*.f64N/A
metadata-evalN/A
div-invN/A
lift-/.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
metadata-evalN/A
div-invN/A
lift-/.f64N/A
Applied rewrites67.7%
Final simplification57.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(cos phi2)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (sqrt (+ 0.5 (* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 t_1)))))))
(t_3 (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(if (<= phi1 -0.029)
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(*
(cos phi2)
(- 0.5 (* 0.5 (cos (/ 2.0 (/ 2.0 (- lambda1 lambda2)))))))
t_3))
t_2))
(if (<= phi1 0.23)
(*
(* R 2.0)
(atan2
(sqrt (fma (cos phi1) t_0 t_3))
(sqrt (fma (cos phi2) (- 0.5 (fma -0.5 t_1 0.5)) 0.5))))
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
t_0
(- 0.5 (* 0.5 (cos (fma (/ phi2 phi1) (- phi1) phi1))))))
t_2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2))))));
double t_1 = cos((lambda1 - lambda2));
double t_2 = sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * t_1))))));
double t_3 = 0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))));
double tmp;
if (phi1 <= -0.029) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (0.5 - (0.5 * cos((2.0 / (2.0 / (lambda1 - lambda2))))))), t_3)), t_2);
} else if (phi1 <= 0.23) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), t_0, t_3)), sqrt(fma(cos(phi2), (0.5 - fma(-0.5, t_1, 0.5)), 0.5)));
} else {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), t_0, (0.5 - (0.5 * cos(fma((phi2 / phi1), -phi1, phi1)))))), t_2);
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2))))))) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * t_1)))))) t_3 = Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))) tmp = 0.0 if (phi1 <= -0.029) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 / Float64(2.0 / Float64(lambda1 - lambda2))))))), t_3)), t_2)); elseif (phi1 <= 0.23) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), t_0, t_3)), sqrt(fma(cos(phi2), Float64(0.5 - fma(-0.5, t_1, 0.5)), 0.5)))); else tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), t_0, Float64(0.5 - Float64(0.5 * cos(fma(Float64(phi2 / phi1), Float64(-phi1), phi1)))))), t_2)); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.029], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 / N[(2.0 / N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.23], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$0 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(-0.5 * t$95$1 + 0.5), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$0 + N[(0.5 - N[(0.5 * N[Cos[N[(N[(phi2 / phi1), $MachinePrecision] * (-phi1) + phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot t\_1\right)\right)}\\
t_3 := 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\\
\mathbf{if}\;\phi_1 \leq -0.029:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(\frac{2}{\frac{2}{\lambda_1 - \lambda_2}}\right)\right), t\_3\right)}}{t\_2}\\
\mathbf{elif}\;\phi_1 \leq 0.23:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_0, t\_3\right)}}{\sqrt{\mathsf{fma}\left(\cos \phi_2, 0.5 - \mathsf{fma}\left(-0.5, t\_1, 0.5\right), 0.5\right)}}\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_0, 0.5 - 0.5 \cdot \cos \left(\mathsf{fma}\left(\frac{\phi_2}{\phi_1}, -\phi_1, \phi_1\right)\right)\right)}}{t\_2}\\
\end{array}
\end{array}
if phi1 < -0.0290000000000000015Initial program 44.4%
Applied rewrites44.5%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6444.8
Applied rewrites44.8%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
metadata-evalN/A
div-invN/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6444.8
Applied rewrites44.8%
if -0.0290000000000000015 < phi1 < 0.23000000000000001Initial program 73.3%
Applied rewrites64.4%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6438.0
Applied rewrites38.0%
Taylor expanded in phi1 around 0
associate--l+N/A
+-commutativeN/A
cos-negN/A
*-commutativeN/A
distribute-lft-out--N/A
lower-fma.f64N/A
Applied rewrites64.5%
if 0.23000000000000001 < phi1 Initial program 46.1%
Applied rewrites46.3%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6446.5
Applied rewrites46.5%
Taylor expanded in phi1 around inf
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
associate-*l*N/A
*-lft-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6446.7
Applied rewrites46.7%
Final simplification55.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(cos phi2)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (sqrt (+ 0.5 (* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 t_1)))))))
(t_3
(sqrt
(fma
(cos phi1)
t_0
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))))
(if (<= phi1 -0.029)
(* (* R 2.0) (atan2 t_3 t_2))
(if (<= phi1 0.23)
(*
(* R 2.0)
(atan2 t_3 (sqrt (fma (cos phi2) (- 0.5 (fma -0.5 t_1 0.5)) 0.5))))
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
t_0
(- 0.5 (* 0.5 (cos (fma (/ phi2 phi1) (- phi1) phi1))))))
t_2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2))))));
double t_1 = cos((lambda1 - lambda2));
double t_2 = sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * t_1))))));
double t_3 = sqrt(fma(cos(phi1), t_0, (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2))))))));
double tmp;
if (phi1 <= -0.029) {
tmp = (R * 2.0) * atan2(t_3, t_2);
} else if (phi1 <= 0.23) {
tmp = (R * 2.0) * atan2(t_3, sqrt(fma(cos(phi2), (0.5 - fma(-0.5, t_1, 0.5)), 0.5)));
} else {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), t_0, (0.5 - (0.5 * cos(fma((phi2 / phi1), -phi1, phi1)))))), t_2);
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2))))))) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * t_1)))))) t_3 = sqrt(fma(cos(phi1), t_0, Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))) tmp = 0.0 if (phi1 <= -0.029) tmp = Float64(Float64(R * 2.0) * atan(t_3, t_2)); elseif (phi1 <= 0.23) tmp = Float64(Float64(R * 2.0) * atan(t_3, sqrt(fma(cos(phi2), Float64(0.5 - fma(-0.5, t_1, 0.5)), 0.5)))); else tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), t_0, Float64(0.5 - Float64(0.5 * cos(fma(Float64(phi2 / phi1), Float64(-phi1), phi1)))))), t_2)); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$0 + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.029], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[t$95$3 / t$95$2], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.23], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[t$95$3 / N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(-0.5 * t$95$1 + 0.5), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$0 + N[(0.5 - N[(0.5 * N[Cos[N[(N[(phi2 / phi1), $MachinePrecision] * (-phi1) + phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot t\_1\right)\right)}\\
t_3 := \sqrt{\mathsf{fma}\left(\cos \phi_1, t\_0, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}\\
\mathbf{if}\;\phi_1 \leq -0.029:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_3}{t\_2}\\
\mathbf{elif}\;\phi_1 \leq 0.23:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{\mathsf{fma}\left(\cos \phi_2, 0.5 - \mathsf{fma}\left(-0.5, t\_1, 0.5\right), 0.5\right)}}\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_0, 0.5 - 0.5 \cdot \cos \left(\mathsf{fma}\left(\frac{\phi_2}{\phi_1}, -\phi_1, \phi_1\right)\right)\right)}}{t\_2}\\
\end{array}
\end{array}
if phi1 < -0.0290000000000000015Initial program 44.4%
Applied rewrites44.5%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6444.8
Applied rewrites44.8%
if -0.0290000000000000015 < phi1 < 0.23000000000000001Initial program 73.3%
Applied rewrites64.4%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6438.0
Applied rewrites38.0%
Taylor expanded in phi1 around 0
associate--l+N/A
+-commutativeN/A
cos-negN/A
*-commutativeN/A
distribute-lft-out--N/A
lower-fma.f64N/A
Applied rewrites64.5%
if 0.23000000000000001 < phi1 Initial program 46.1%
Applied rewrites46.3%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6446.5
Applied rewrites46.5%
Taylor expanded in phi1 around inf
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
associate-*l*N/A
*-lft-identityN/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6446.7
Applied rewrites46.7%
Final simplification55.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1
(sqrt
(fma
(cos phi1)
(*
(cos phi2)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))))))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2)))))))))
(t_2
(*
(* R 2.0)
(atan2
t_1
(sqrt (+ 0.5 (* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 t_0))))))))))
(if (<= phi1 -0.029)
t_2
(if (<= phi1 0.23)
(*
(* R 2.0)
(atan2 t_1 (sqrt (fma (cos phi2) (- 0.5 (fma -0.5 t_0 0.5)) 0.5))))
t_2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sqrt(fma(cos(phi1), (cos(phi2) * (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2))))))), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2))))))));
double t_2 = (R * 2.0) * atan2(t_1, sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * t_0)))))));
double tmp;
if (phi1 <= -0.029) {
tmp = t_2;
} else if (phi1 <= 0.23) {
tmp = (R * 2.0) * atan2(t_1, sqrt(fma(cos(phi2), (0.5 - fma(-0.5, t_0, 0.5)), 0.5)));
} else {
tmp = t_2;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2))))))), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))) t_2 = Float64(Float64(R * 2.0) * atan(t_1, sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * t_0)))))))) tmp = 0.0 if (phi1 <= -0.029) tmp = t_2; elseif (phi1 <= 0.23) tmp = Float64(Float64(R * 2.0) * atan(t_1, sqrt(fma(cos(phi2), Float64(0.5 - fma(-0.5, t_0, 0.5)), 0.5)))); else tmp = t_2; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[t$95$1 / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.029], t$95$2, If[LessEqual[phi1, 0.23], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[t$95$1 / N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(-0.5 * t$95$0 + 0.5), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}\\
t_2 := \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot t\_0\right)\right)}}\\
\mathbf{if}\;\phi_1 \leq -0.029:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 0.23:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{\mathsf{fma}\left(\cos \phi_2, 0.5 - \mathsf{fma}\left(-0.5, t\_0, 0.5\right), 0.5\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi1 < -0.0290000000000000015 or 0.23000000000000001 < phi1 Initial program 45.4%
Applied rewrites45.5%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.7
Applied rewrites45.7%
if -0.0290000000000000015 < phi1 < 0.23000000000000001Initial program 73.3%
Applied rewrites64.4%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6438.0
Applied rewrites38.0%
Taylor expanded in phi1 around 0
associate--l+N/A
+-commutativeN/A
cos-negN/A
*-commutativeN/A
distribute-lft-out--N/A
lower-fma.f64N/A
Applied rewrites64.5%
Final simplification55.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(cos phi2)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))))
(t_1 (cos (- lambda1 lambda2)))
(t_2
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
t_0
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(sqrt (fma (cos phi2) (- 0.5 (fma -0.5 t_1 0.5)) 0.5))))))
(if (<= phi2 -2.35e+24)
t_2
(if (<= phi2 1.85e-5)
(*
(* R 2.0)
(atan2
(sqrt (fma (cos phi1) t_0 (- 0.5 (* 0.5 (cos phi1)))))
(sqrt (+ 0.5 (* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 t_1))))))))
t_2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2))))));
double t_1 = cos((lambda1 - lambda2));
double t_2 = (R * 2.0) * atan2(sqrt(fma(cos(phi1), t_0, (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt(fma(cos(phi2), (0.5 - fma(-0.5, t_1, 0.5)), 0.5)));
double tmp;
if (phi2 <= -2.35e+24) {
tmp = t_2;
} else if (phi2 <= 1.85e-5) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), t_0, (0.5 - (0.5 * cos(phi1))))), sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * t_1)))))));
} else {
tmp = t_2;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2))))))) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), t_0, Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), sqrt(fma(cos(phi2), Float64(0.5 - fma(-0.5, t_1, 0.5)), 0.5)))) tmp = 0.0 if (phi2 <= -2.35e+24) tmp = t_2; elseif (phi2 <= 1.85e-5) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), t_0, Float64(0.5 - Float64(0.5 * cos(phi1))))), sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * t_1)))))))); else tmp = t_2; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$0 + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(-0.5 * t$95$1 + 0.5), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.35e+24], t$95$2, If[LessEqual[phi2, 1.85e-5], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$0 + N[(0.5 - N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_0, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{\sqrt{\mathsf{fma}\left(\cos \phi_2, 0.5 - \mathsf{fma}\left(-0.5, t\_1, 0.5\right), 0.5\right)}}\\
\mathbf{if}\;\phi_2 \leq -2.35 \cdot 10^{+24}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_2 \leq 1.85 \cdot 10^{-5}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_0, 0.5 - 0.5 \cdot \cos \phi_1\right)}}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot t\_1\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi2 < -2.35e24 or 1.84999999999999991e-5 < phi2 Initial program 47.5%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6420.5
Applied rewrites20.5%
Taylor expanded in phi1 around 0
associate--l+N/A
+-commutativeN/A
cos-negN/A
*-commutativeN/A
distribute-lft-out--N/A
lower-fma.f64N/A
Applied rewrites47.9%
if -2.35e24 < phi2 < 1.84999999999999991e-5Initial program 73.1%
Applied rewrites63.6%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6463.4
Applied rewrites63.4%
Taylor expanded in phi2 around 0
lower-cos.f6463.4
Applied rewrites63.4%
Final simplification55.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(sqrt
(+
0.5
(* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 (cos (- lambda1 lambda2)))))))))
(t_1
(*
(cos phi2)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))))))))
(if (<= phi2 -3.2e+24)
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (fma -0.5 (cos lambda1) 0.5))
(- 0.5 (* 0.5 (cos phi2)))))
t_0))
(if (<= phi2 115000.0)
(*
(* R 2.0)
(atan2 (sqrt (fma (cos phi1) t_1 (- 0.5 (* 0.5 (cos phi1))))) t_0))
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
t_1
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(sqrt (+ 0.5 (* (cos phi1) (* 0.5 (cos lambda2)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * cos((lambda1 - lambda2))))))));
double t_1 = cos(phi2) * (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2))))));
double tmp;
if (phi2 <= -3.2e+24) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), (0.5 - (0.5 * cos(phi2))))), t_0);
} else if (phi2 <= 115000.0) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), t_1, (0.5 - (0.5 * cos(phi1))))), t_0);
} else {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), t_1, (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt((0.5 + (cos(phi1) * (0.5 * cos(lambda2))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))) t_1 = Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2))))))) tmp = 0.0 if (phi2 <= -3.2e+24) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), Float64(0.5 - Float64(0.5 * cos(phi2))))), t_0)); elseif (phi2 <= 115000.0) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), t_1, Float64(0.5 - Float64(0.5 * cos(phi1))))), t_0)); else tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), t_1, Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 * cos(lambda2))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -3.2e+24], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * N[Cos[lambda1], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 115000.0], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + N[(0.5 - N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}\\
t_1 := \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\\
\mathbf{if}\;\phi_2 \leq -3.2 \cdot 10^{+24}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \mathsf{fma}\left(-0.5, \cos \lambda_1, 0.5\right), 0.5 - 0.5 \cdot \cos \phi_2\right)}}{t\_0}\\
\mathbf{elif}\;\phi_2 \leq 115000:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_1, 0.5 - 0.5 \cdot \cos \phi_1\right)}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_1, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 \cdot \cos \lambda_2\right)}}\\
\end{array}
\end{array}
if phi2 < -3.1999999999999997e24Initial program 55.2%
Applied rewrites55.4%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6420.6
Applied rewrites20.6%
Taylor expanded in lambda2 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f6421.0
Applied rewrites21.0%
Taylor expanded in phi1 around 0
cos-negN/A
lower-cos.f6421.6
Applied rewrites21.6%
if -3.1999999999999997e24 < phi2 < 115000Initial program 71.9%
Applied rewrites62.6%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6462.4
Applied rewrites62.4%
Taylor expanded in phi2 around 0
lower-cos.f6462.4
Applied rewrites62.4%
if 115000 < phi2 Initial program 41.4%
Applied rewrites41.5%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6420.5
Applied rewrites20.5%
Taylor expanded in lambda1 around 0
Applied rewrites20.7%
Final simplification41.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(sqrt
(+
0.5
(*
(cos phi1)
(- 0.5 (+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))))))))
(if (<= phi2 -3.2e+24)
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (fma -0.5 (cos lambda1) 0.5))
(- 0.5 (* 0.5 (cos phi2)))))
t_0))
(if (<= phi2 0.2)
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(*
(cos phi2)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))))))
(- 0.5 (* 0.5 (cos phi1)))))
t_0))
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (fma -0.5 (cos lambda2) 0.5))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * cos((lambda1 - lambda2))))))));
double tmp;
if (phi2 <= -3.2e+24) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), (0.5 - (0.5 * cos(phi2))))), t_0);
} else if (phi2 <= 0.2) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2))))))), (0.5 - (0.5 * cos(phi1))))), t_0);
} else {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * fma(-0.5, cos(lambda2), 0.5)), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), t_0);
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))) tmp = 0.0 if (phi2 <= -3.2e+24) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), Float64(0.5 - Float64(0.5 * cos(phi2))))), t_0)); elseif (phi2 <= 0.2) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2))))))), Float64(0.5 - Float64(0.5 * cos(phi1))))), t_0)); else tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * fma(-0.5, cos(lambda2), 0.5)), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), t_0)); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -3.2e+24], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * N[Cos[lambda1], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.2], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * N[Cos[lambda2], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}\\
\mathbf{if}\;\phi_2 \leq -3.2 \cdot 10^{+24}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \mathsf{fma}\left(-0.5, \cos \lambda_1, 0.5\right), 0.5 - 0.5 \cdot \cos \phi_2\right)}}{t\_0}\\
\mathbf{elif}\;\phi_2 \leq 0.2:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right), 0.5 - 0.5 \cdot \cos \phi_1\right)}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \mathsf{fma}\left(-0.5, \cos \lambda_2, 0.5\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{t\_0}\\
\end{array}
\end{array}
if phi2 < -3.1999999999999997e24Initial program 55.2%
Applied rewrites55.4%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6420.6
Applied rewrites20.6%
Taylor expanded in lambda2 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f6421.0
Applied rewrites21.0%
Taylor expanded in phi1 around 0
cos-negN/A
lower-cos.f6421.6
Applied rewrites21.6%
if -3.1999999999999997e24 < phi2 < 0.20000000000000001Initial program 72.3%
Applied rewrites62.9%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6462.8
Applied rewrites62.8%
Taylor expanded in phi2 around 0
lower-cos.f6462.7
Applied rewrites62.7%
if 0.20000000000000001 < phi2 Initial program 41.0%
Applied rewrites41.2%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6420.4
Applied rewrites20.4%
Taylor expanded in lambda1 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f6420.6
Applied rewrites20.6%
Final simplification41.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2)))))))
(t_1
(*
(* R 2.0)
(atan2
(sqrt
(fma (cos phi1) (* (cos phi2) (fma -0.5 (cos lambda2) 0.5)) t_0))
(sqrt
(+
0.5
(*
(cos phi1)
(- 0.5 (+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))))))))))
(if (<= lambda2 -2.9e-5)
t_1
(if (<= lambda2 3.6e+17)
(*
(* R 2.0)
(atan2
(sqrt
(fma (cos phi1) (* (cos phi2) (fma -0.5 (cos lambda1) 0.5)) t_0))
(sqrt (fma (* 0.5 (cos lambda1)) (cos phi1) 0.5))))
t_1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))));
double t_1 = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * fma(-0.5, cos(lambda2), 0.5)), t_0)), sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * cos((lambda1 - lambda2)))))))));
double tmp;
if (lambda2 <= -2.9e-5) {
tmp = t_1;
} else if (lambda2 <= 3.6e+17) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), t_0)), sqrt(fma((0.5 * cos(lambda1)), cos(phi1), 0.5)));
} else {
tmp = t_1;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))) t_1 = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * fma(-0.5, cos(lambda2), 0.5)), t_0)), sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))))) tmp = 0.0 if (lambda2 <= -2.9e-5) tmp = t_1; elseif (lambda2 <= 3.6e+17) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), t_0)), sqrt(fma(Float64(0.5 * cos(lambda1)), cos(phi1), 0.5)))); else tmp = t_1; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * N[Cos[lambda2], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -2.9e-5], t$95$1, If[LessEqual[lambda2, 3.6e+17], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * N[Cos[lambda1], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\\
t_1 := \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \mathsf{fma}\left(-0.5, \cos \lambda_2, 0.5\right), t\_0\right)}}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}}\\
\mathbf{if}\;\lambda_2 \leq -2.9 \cdot 10^{-5}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 3.6 \cdot 10^{+17}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \mathsf{fma}\left(-0.5, \cos \lambda_1, 0.5\right), t\_0\right)}}{\sqrt{\mathsf{fma}\left(0.5 \cdot \cos \lambda_1, \cos \phi_1, 0.5\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda2 < -2.9e-5 or 3.6e17 < lambda2 Initial program 47.2%
Applied rewrites46.9%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6438.6
Applied rewrites38.6%
Taylor expanded in lambda1 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f6438.9
Applied rewrites38.9%
if -2.9e-5 < lambda2 < 3.6e17Initial program 72.4%
Applied rewrites63.6%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6444.5
Applied rewrites44.5%
Taylor expanded in lambda2 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f6444.3
Applied rewrites44.3%
Taylor expanded in lambda2 around 0
Applied rewrites44.3%
Final simplification41.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (fma -0.5 (cos lambda1) 0.5))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(sqrt
(+
0.5
(* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 (cos (- lambda1 lambda2)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * cos((lambda1 - lambda2)))))))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * N[Cos[lambda1], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \mathsf{fma}\left(-0.5, \cos \lambda_1, 0.5\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}}
\end{array}
Initial program 60.1%
Applied rewrites55.5%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6441.6
Applied rewrites41.6%
Taylor expanded in lambda2 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f6431.3
Applied rewrites31.3%
Final simplification31.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (fma -0.5 (cos lambda1) 0.5)))
(t_1
(sqrt
(+
0.5
(*
(cos phi1)
(- 0.5 (+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))))))))
(if (<= phi2 -3.2e+24)
(*
(* R 2.0)
(atan2 (sqrt (fma (cos phi1) t_0 (- 0.5 (* 0.5 (cos phi2))))) t_1))
(*
(* R 2.0)
(atan2 (sqrt (fma (cos phi1) t_0 (- 0.5 (* 0.5 (cos phi1))))) t_1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * fma(-0.5, cos(lambda1), 0.5);
double t_1 = sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * cos((lambda1 - lambda2))))))));
double tmp;
if (phi2 <= -3.2e+24) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), t_0, (0.5 - (0.5 * cos(phi2))))), t_1);
} else {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), t_0, (0.5 - (0.5 * cos(phi1))))), t_1);
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * fma(-0.5, cos(lambda1), 0.5)) t_1 = sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))) tmp = 0.0 if (phi2 <= -3.2e+24) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), t_0, Float64(0.5 - Float64(0.5 * cos(phi2))))), t_1)); else tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), t_0, Float64(0.5 - Float64(0.5 * cos(phi1))))), t_1)); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * N[Cos[lambda1], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -3.2e+24], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$0 + N[(0.5 - N[(0.5 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$0 + N[(0.5 - N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \mathsf{fma}\left(-0.5, \cos \lambda_1, 0.5\right)\\
t_1 := \sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}\\
\mathbf{if}\;\phi_2 \leq -3.2 \cdot 10^{+24}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_0, 0.5 - 0.5 \cdot \cos \phi_2\right)}}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_0, 0.5 - 0.5 \cdot \cos \phi_1\right)}}{t\_1}\\
\end{array}
\end{array}
if phi2 < -3.1999999999999997e24Initial program 55.2%
Applied rewrites55.4%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6420.6
Applied rewrites20.6%
Taylor expanded in lambda2 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f6421.0
Applied rewrites21.0%
Taylor expanded in phi1 around 0
cos-negN/A
lower-cos.f6421.6
Applied rewrites21.6%
if -3.1999999999999997e24 < phi2 Initial program 61.7%
Applied rewrites55.5%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6448.4
Applied rewrites48.4%
Taylor expanded in lambda2 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f6434.7
Applied rewrites34.7%
Taylor expanded in phi2 around 0
lower-cos.f6432.6
Applied rewrites32.6%
Final simplification29.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi2) (fma -0.5 (cos lambda1) 0.5))))
(if (<= phi2 -2.35e+24)
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
t_1
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(sqrt (fma 0.5 t_0 0.5))))
(*
(* R 2.0)
(atan2
(sqrt (fma (cos phi1) t_1 (- 0.5 (* 0.5 (cos phi1)))))
(sqrt (+ 0.5 (* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 t_0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi2) * fma(-0.5, cos(lambda1), 0.5);
double tmp;
if (phi2 <= -2.35e+24) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), t_1, (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt(fma(0.5, t_0, 0.5)));
} else {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), t_1, (0.5 - (0.5 * cos(phi1))))), sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * t_0)))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * fma(-0.5, cos(lambda1), 0.5)) tmp = 0.0 if (phi2 <= -2.35e+24) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), t_1, Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), sqrt(fma(0.5, t_0, 0.5)))); else tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), t_1, Float64(0.5 - Float64(0.5 * cos(phi1))))), sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * t_0)))))))); end return tmp end
code[R_, 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[(-0.5 * N[Cos[lambda1], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.35e+24], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 * t$95$0 + 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + N[(0.5 - N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 \mathsf{fma}\left(-0.5, \cos \lambda_1, 0.5\right)\\
\mathbf{if}\;\phi_2 \leq -2.35 \cdot 10^{+24}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_1, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{\sqrt{\mathsf{fma}\left(0.5, t\_0, 0.5\right)}}\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_1, 0.5 - 0.5 \cdot \cos \phi_1\right)}}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot t\_0\right)\right)}}\\
\end{array}
\end{array}
if phi2 < -2.35e24Initial program 55.2%
Applied rewrites55.4%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6420.6
Applied rewrites20.6%
Taylor expanded in lambda2 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f6421.0
Applied rewrites21.0%
Taylor expanded in phi1 around 0
Applied rewrites20.9%
if -2.35e24 < phi2 Initial program 61.7%
Applied rewrites55.5%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6448.4
Applied rewrites48.4%
Taylor expanded in lambda2 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f6434.7
Applied rewrites34.7%
Taylor expanded in phi2 around 0
lower-cos.f6432.6
Applied rewrites32.6%
Final simplification29.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (fma -0.5 (cos lambda1) 0.5))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(sqrt (fma (* 0.5 (cos lambda1)) (cos phi1) 0.5)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt(fma((0.5 * cos(lambda1)), cos(phi1), 0.5)));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), sqrt(fma(Float64(0.5 * cos(lambda1)), cos(phi1), 0.5)))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * N[Cos[lambda1], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \mathsf{fma}\left(-0.5, \cos \lambda_1, 0.5\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{\sqrt{\mathsf{fma}\left(0.5 \cdot \cos \lambda_1, \cos \phi_1, 0.5\right)}}
\end{array}
Initial program 60.1%
Applied rewrites55.5%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6441.6
Applied rewrites41.6%
Taylor expanded in lambda2 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f6431.3
Applied rewrites31.3%
Taylor expanded in lambda2 around 0
Applied rewrites31.1%
Final simplification31.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2)))))))
(t_2
(*
(* R 2.0)
(atan2
(sqrt
(fma (cos phi1) (* (cos phi2) (fma -0.5 (cos lambda1) 0.5)) t_1))
(sqrt (fma 0.5 t_0 0.5))))))
(if (<= lambda1 -6.2e-13)
t_2
(if (<= lambda1 0.1)
(*
(* R 2.0)
(atan2
(sqrt
(fma (cos phi1) (* (cos phi2) (* 0.25 (* lambda1 lambda1))) t_1))
(sqrt (+ 0.5 (* (cos phi1) (- 0.5 (+ 0.5 (* -0.5 t_0))))))))
t_2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = 0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))));
double t_2 = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), t_1)), sqrt(fma(0.5, t_0, 0.5)));
double tmp;
if (lambda1 <= -6.2e-13) {
tmp = t_2;
} else if (lambda1 <= 0.1) {
tmp = (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (0.25 * (lambda1 * lambda1))), t_1)), sqrt((0.5 + (cos(phi1) * (0.5 - (0.5 + (-0.5 * t_0)))))));
} else {
tmp = t_2;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))) t_2 = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), t_1)), sqrt(fma(0.5, t_0, 0.5)))) tmp = 0.0 if (lambda1 <= -6.2e-13) tmp = t_2; elseif (lambda1 <= 0.1) tmp = Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(0.25 * Float64(lambda1 * lambda1))), t_1)), sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 + Float64(-0.5 * t_0)))))))); else tmp = t_2; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * N[Cos[lambda1], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 * t$95$0 + 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -6.2e-13], t$95$2, If[LessEqual[lambda1, 0.1], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.25 * N[(lambda1 * lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 + N[(-0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\\
t_2 := \left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \mathsf{fma}\left(-0.5, \cos \lambda_1, 0.5\right), t\_1\right)}}{\sqrt{\mathsf{fma}\left(0.5, t\_0, 0.5\right)}}\\
\mathbf{if}\;\lambda_1 \leq -6.2 \cdot 10^{-13}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_1 \leq 0.1:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.25 \cdot \left(\lambda_1 \cdot \lambda_1\right)\right), t\_1\right)}}{\sqrt{0.5 + \cos \phi_1 \cdot \left(0.5 - \left(0.5 + -0.5 \cdot t\_0\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda1 < -6.1999999999999998e-13 or 0.10000000000000001 < lambda1 Initial program 45.4%
Applied rewrites45.3%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6435.6
Applied rewrites35.6%
Taylor expanded in lambda2 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f6435.2
Applied rewrites35.2%
Taylor expanded in phi1 around 0
Applied rewrites28.6%
if -6.1999999999999998e-13 < lambda1 < 0.10000000000000001Initial program 78.5%
Applied rewrites68.2%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6449.2
Applied rewrites49.2%
Taylor expanded in lambda2 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f6426.5
Applied rewrites26.5%
Taylor expanded in lambda1 around 0
Applied rewrites29.3%
Final simplification28.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(* R 2.0)
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (fma -0.5 (cos lambda1) 0.5))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(sqrt (fma 0.5 (cos (- lambda1 lambda2)) 0.5)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return (R * 2.0) * atan2(sqrt(fma(cos(phi1), (cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt(fma(0.5, cos((lambda1 - lambda2)), 0.5)));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(Float64(R * 2.0) * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * fma(-0.5, cos(lambda1), 0.5)), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), sqrt(fma(0.5, cos(Float64(lambda1 - lambda2)), 0.5)))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * N[Cos[lambda1], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \mathsf{fma}\left(-0.5, \cos \lambda_1, 0.5\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{\sqrt{\mathsf{fma}\left(0.5, \cos \left(\lambda_1 - \lambda_2\right), 0.5\right)}}
\end{array}
Initial program 60.1%
Applied rewrites55.5%
Taylor expanded in phi2 around 0
associate--l+N/A
lower-+.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
sub-negN/A
lower-+.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6441.6
Applied rewrites41.6%
Taylor expanded in lambda2 around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f6431.3
Applied rewrites31.3%
Taylor expanded in phi1 around 0
Applied rewrites23.2%
Final simplification23.2%
herbie shell --seed 2024232
(FPCore (R lambda1 lambda2 phi1 phi2)
:name "Distance on a great circle"
:precision binary64
(* R (* 2.0 (atan2 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))) (sqrt (- 1.0 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))))))))