
(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))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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}
Herbie found 32 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))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 (* 0.5 lambda1)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (sin (* 0.5 phi1)))
(t_3 (* (- phi2) 0.5))
(t_4 (cos t_3))
(t_5 (* (cos (* 0.5 phi1)) (sin t_3)))
(t_6 (sin (* 0.5 lambda1)))
(t_7 (* (- lambda2) 0.5))
(t_8 (+ (* t_6 (cos t_7)) (* t_0 (sin t_7))))
(t_9 (* (cos phi1) (cos phi2)))
(t_10 (* (* t_9 t_1) t_1))
(t_11 (+ (pow (fma t_2 t_4 t_5) 2.0) t_10))
(t_12 (+ (pow (+ (* t_2 t_4) t_5) 2.0) t_10)))
(if (<= phi2 -2.8e-8)
(* R (* 2.0 (atan2 (sqrt t_12) (sqrt (- 1.0 t_12)))))
(if (<= phi2 6.8e-10)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* t_9 t_8) t_8)))
(sqrt
(-
1.0
(fma
(cos phi1)
(*
(cos phi2)
(pow
(fma (cos (* -0.5 lambda2)) t_6 (* t_0 (sin (* -0.5 lambda2))))
2.0))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))))))
(* R (* 2.0 (atan2 (sqrt t_11) (sqrt (- 1.0 t_11)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((0.5 * lambda1));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sin((0.5 * phi1));
double t_3 = -phi2 * 0.5;
double t_4 = cos(t_3);
double t_5 = cos((0.5 * phi1)) * sin(t_3);
double t_6 = sin((0.5 * lambda1));
double t_7 = -lambda2 * 0.5;
double t_8 = (t_6 * cos(t_7)) + (t_0 * sin(t_7));
double t_9 = cos(phi1) * cos(phi2);
double t_10 = (t_9 * t_1) * t_1;
double t_11 = pow(fma(t_2, t_4, t_5), 2.0) + t_10;
double t_12 = pow(((t_2 * t_4) + t_5), 2.0) + t_10;
double tmp;
if (phi2 <= -2.8e-8) {
tmp = R * (2.0 * atan2(sqrt(t_12), sqrt((1.0 - t_12))));
} else if (phi2 <= 6.8e-10) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_9 * t_8) * t_8))), sqrt((1.0 - fma(cos(phi1), (cos(phi2) * pow(fma(cos((-0.5 * lambda2)), t_6, (t_0 * sin((-0.5 * lambda2)))), 2.0)), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_11), sqrt((1.0 - t_11))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(0.5 * lambda1)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(0.5 * phi1)) t_3 = Float64(Float64(-phi2) * 0.5) t_4 = cos(t_3) t_5 = Float64(cos(Float64(0.5 * phi1)) * sin(t_3)) t_6 = sin(Float64(0.5 * lambda1)) t_7 = Float64(Float64(-lambda2) * 0.5) t_8 = Float64(Float64(t_6 * cos(t_7)) + Float64(t_0 * sin(t_7))) t_9 = Float64(cos(phi1) * cos(phi2)) t_10 = Float64(Float64(t_9 * t_1) * t_1) t_11 = Float64((fma(t_2, t_4, t_5) ^ 2.0) + t_10) t_12 = Float64((Float64(Float64(t_2 * t_4) + t_5) ^ 2.0) + t_10) tmp = 0.0 if (phi2 <= -2.8e-8) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_12), sqrt(Float64(1.0 - t_12))))); elseif (phi2 <= 6.8e-10) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(t_9 * t_8) * t_8))), sqrt(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * (fma(cos(Float64(-0.5 * lambda2)), t_6, Float64(t_0 * sin(Float64(-0.5 * lambda2)))) ^ 2.0)), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_11), sqrt(Float64(1.0 - t_11))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[((-phi2) * 0.5), $MachinePrecision]}, Block[{t$95$4 = N[Cos[t$95$3], $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[t$95$3], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[((-lambda2) * 0.5), $MachinePrecision]}, Block[{t$95$8 = N[(N[(t$95$6 * N[Cos[t$95$7], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Sin[t$95$7], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$9 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$10 = N[(N[(t$95$9 * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$11 = N[(N[Power[N[(t$95$2 * t$95$4 + t$95$5), $MachinePrecision], 2.0], $MachinePrecision] + t$95$10), $MachinePrecision]}, Block[{t$95$12 = N[(N[Power[N[(N[(t$95$2 * t$95$4), $MachinePrecision] + t$95$5), $MachinePrecision], 2.0], $MachinePrecision] + t$95$10), $MachinePrecision]}, If[LessEqual[phi2, -2.8e-8], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$12], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$12), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 6.8e-10], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(t$95$9 * t$95$8), $MachinePrecision] * t$95$8), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(N[Cos[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * t$95$6 + N[(t$95$0 * N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $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]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$11], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$11), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot \lambda_1\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sin \left(0.5 \cdot \phi_1\right)\\
t_3 := \left(-\phi_2\right) \cdot 0.5\\
t_4 := \cos t\_3\\
t_5 := \cos \left(0.5 \cdot \phi_1\right) \cdot \sin t\_3\\
t_6 := \sin \left(0.5 \cdot \lambda_1\right)\\
t_7 := \left(-\lambda_2\right) \cdot 0.5\\
t_8 := t\_6 \cdot \cos t\_7 + t\_0 \cdot \sin t\_7\\
t_9 := \cos \phi_1 \cdot \cos \phi_2\\
t_10 := \left(t\_9 \cdot t\_1\right) \cdot t\_1\\
t_11 := {\left(\mathsf{fma}\left(t\_2, t\_4, t\_5\right)\right)}^{2} + t\_10\\
t_12 := {\left(t\_2 \cdot t\_4 + t\_5\right)}^{2} + t\_10\\
\mathbf{if}\;\phi_2 \leq -2.8 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_12}}{\sqrt{1 - t\_12}}\right)\\
\mathbf{elif}\;\phi_2 \leq 6.8 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(t\_9 \cdot t\_8\right) \cdot t\_8}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\left(\mathsf{fma}\left(\cos \left(-0.5 \cdot \lambda_2\right), t\_6, t\_0 \cdot \sin \left(-0.5 \cdot \lambda_2\right)\right)\right)}^{2}, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_11}}{\sqrt{1 - t\_11}}\right)\\
\end{array}
\end{array}
if phi2 < -2.7999999999999999e-8Initial program 45.9%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites47.8%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites78.2%
if -2.7999999999999999e-8 < phi2 < 6.8000000000000003e-10Initial program 78.5%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites77.3%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites79.1%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites78.8%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites98.4%
Taylor expanded in lambda1 around inf
lower--.f64N/A
unpow2N/A
sqr-sin-a-revN/A
Applied rewrites98.5%
if 6.8000000000000003e-10 < phi2 Initial program 48.3%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
Applied rewrites50.0%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
Applied rewrites79.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (sin (* 0.5 phi1)))
(t_2 (* (- phi2) 0.5))
(t_3 (* (cos (* 0.5 phi1)) (sin t_2)))
(t_4 (* (* (* (cos phi1) (cos phi2)) t_0) t_0))
(t_5 (cos t_2))
(t_6 (+ (pow (fma t_1 t_5 t_3) 2.0) t_4))
(t_7 (+ (pow (+ (* t_1 t_5) t_3) 2.0) t_4))
(t_8
(pow
(fma
(cos (* -0.5 lambda2))
(sin (* 0.5 lambda1))
(* (cos (* 0.5 lambda1)) (sin (* -0.5 lambda2))))
2.0)))
(if (<= phi2 -2.8e-8)
(* R (* 2.0 (atan2 (sqrt t_7) (sqrt (- 1.0 t_7)))))
(if (<= phi2 6.8e-10)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (cos phi1) t_8)))
(sqrt
(-
1.0
(fma
(cos phi1)
(* (cos phi2) t_8)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))))))
(* R (* 2.0 (atan2 (sqrt t_6) (sqrt (- 1.0 t_6)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sin((0.5 * phi1));
double t_2 = -phi2 * 0.5;
double t_3 = cos((0.5 * phi1)) * sin(t_2);
double t_4 = ((cos(phi1) * cos(phi2)) * t_0) * t_0;
double t_5 = cos(t_2);
double t_6 = pow(fma(t_1, t_5, t_3), 2.0) + t_4;
double t_7 = pow(((t_1 * t_5) + t_3), 2.0) + t_4;
double t_8 = pow(fma(cos((-0.5 * lambda2)), sin((0.5 * lambda1)), (cos((0.5 * lambda1)) * sin((-0.5 * lambda2)))), 2.0);
double tmp;
if (phi2 <= -2.8e-8) {
tmp = R * (2.0 * atan2(sqrt(t_7), sqrt((1.0 - t_7))));
} else if (phi2 <= 6.8e-10) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi1) * t_8))), sqrt((1.0 - fma(cos(phi1), (cos(phi2) * t_8), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_6), sqrt((1.0 - t_6))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(0.5 * phi1)) t_2 = Float64(Float64(-phi2) * 0.5) t_3 = Float64(cos(Float64(0.5 * phi1)) * sin(t_2)) t_4 = Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0) t_5 = cos(t_2) t_6 = Float64((fma(t_1, t_5, t_3) ^ 2.0) + t_4) t_7 = Float64((Float64(Float64(t_1 * t_5) + t_3) ^ 2.0) + t_4) t_8 = fma(cos(Float64(-0.5 * lambda2)), sin(Float64(0.5 * lambda1)), Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(-0.5 * lambda2)))) ^ 2.0 tmp = 0.0 if (phi2 <= -2.8e-8) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_7), sqrt(Float64(1.0 - t_7))))); elseif (phi2 <= 6.8e-10) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi1) * t_8))), sqrt(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * t_8), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_6), sqrt(Float64(1.0 - t_6))))); 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[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[((-phi2) * 0.5), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[t$95$2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$5 = N[Cos[t$95$2], $MachinePrecision]}, Block[{t$95$6 = N[(N[Power[N[(t$95$1 * t$95$5 + t$95$3), $MachinePrecision], 2.0], $MachinePrecision] + t$95$4), $MachinePrecision]}, Block[{t$95$7 = N[(N[Power[N[(N[(t$95$1 * t$95$5), $MachinePrecision] + t$95$3), $MachinePrecision], 2.0], $MachinePrecision] + t$95$4), $MachinePrecision]}, Block[{t$95$8 = N[Power[N[(N[Cos[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi2, -2.8e-8], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$7], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$7), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 6.8e-10], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$8), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$8), $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]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$6], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$6), $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(0.5 \cdot \phi_1\right)\\
t_2 := \left(-\phi_2\right) \cdot 0.5\\
t_3 := \cos \left(0.5 \cdot \phi_1\right) \cdot \sin t\_2\\
t_4 := \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
t_5 := \cos t\_2\\
t_6 := {\left(\mathsf{fma}\left(t\_1, t\_5, t\_3\right)\right)}^{2} + t\_4\\
t_7 := {\left(t\_1 \cdot t\_5 + t\_3\right)}^{2} + t\_4\\
t_8 := {\left(\mathsf{fma}\left(\cos \left(-0.5 \cdot \lambda_2\right), \sin \left(0.5 \cdot \lambda_1\right), \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(-0.5 \cdot \lambda_2\right)\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -2.8 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_7}}{\sqrt{1 - t\_7}}\right)\\
\mathbf{elif}\;\phi_2 \leq 6.8 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_1 \cdot t\_8}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_8, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_6}}{\sqrt{1 - t\_6}}\right)\\
\end{array}
\end{array}
if phi2 < -2.7999999999999999e-8Initial program 45.9%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites47.8%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites78.2%
if -2.7999999999999999e-8 < phi2 < 6.8000000000000003e-10Initial program 78.5%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites77.3%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites79.1%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites78.8%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites98.4%
Taylor expanded in lambda1 around inf
lower--.f64N/A
unpow2N/A
sqr-sin-a-revN/A
Applied rewrites98.5%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
Applied rewrites98.5%
if 6.8000000000000003e-10 < phi2 Initial program 48.3%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
Applied rewrites50.0%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
Applied rewrites79.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(pow
(fma
(cos (* -0.5 lambda2))
(sin (* 0.5 lambda1))
(* (cos (* 0.5 lambda1)) (sin (* -0.5 lambda2))))
2.0))
(t_2 (* (- phi2) 0.5))
(t_3
(+
(pow
(fma (sin (* 0.5 phi1)) (cos t_2) (* (cos (* 0.5 phi1)) (sin t_2)))
2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0)))
(t_4 (* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- 1.0 t_3)))))))
(if (<= phi2 -2.8e-8)
t_4
(if (<= phi2 6.8e-10)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (cos phi1) t_1)))
(sqrt
(-
1.0
(fma
(cos phi1)
(* (cos phi2) t_1)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))))))
t_4))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(fma(cos((-0.5 * lambda2)), sin((0.5 * lambda1)), (cos((0.5 * lambda1)) * sin((-0.5 * lambda2)))), 2.0);
double t_2 = -phi2 * 0.5;
double t_3 = pow(fma(sin((0.5 * phi1)), cos(t_2), (cos((0.5 * phi1)) * sin(t_2))), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
double t_4 = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3))));
double tmp;
if (phi2 <= -2.8e-8) {
tmp = t_4;
} else if (phi2 <= 6.8e-10) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi1) * t_1))), sqrt((1.0 - fma(cos(phi1), (cos(phi2) * t_1), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))))));
} else {
tmp = t_4;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = fma(cos(Float64(-0.5 * lambda2)), sin(Float64(0.5 * lambda1)), Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(-0.5 * lambda2)))) ^ 2.0 t_2 = Float64(Float64(-phi2) * 0.5) t_3 = Float64((fma(sin(Float64(0.5 * phi1)), cos(t_2), Float64(cos(Float64(0.5 * phi1)) * sin(t_2))) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) t_4 = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_3))))) tmp = 0.0 if (phi2 <= -2.8e-8) tmp = t_4; elseif (phi2 <= 6.8e-10) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi1) * t_1))), sqrt(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * t_1), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))))))); else tmp = t_4; 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[Power[N[(N[Cos[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[((-phi2) * 0.5), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Cos[t$95$2], $MachinePrecision] + N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[t$95$2], $MachinePrecision]), $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]}, Block[{t$95$4 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.8e-8], t$95$4, If[LessEqual[phi2, 6.8e-10], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $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]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$4]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\mathsf{fma}\left(\cos \left(-0.5 \cdot \lambda_2\right), \sin \left(0.5 \cdot \lambda_1\right), \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(-0.5 \cdot \lambda_2\right)\right)\right)}^{2}\\
t_2 := \left(-\phi_2\right) \cdot 0.5\\
t_3 := {\left(\mathsf{fma}\left(\sin \left(0.5 \cdot \phi_1\right), \cos t\_2, \cos \left(0.5 \cdot \phi_1\right) \cdot \sin t\_2\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
t_4 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_3}}\right)\\
\mathbf{if}\;\phi_2 \leq -2.8 \cdot 10^{-8}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;\phi_2 \leq 6.8 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_1 \cdot t\_1}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_1, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
\end{array}
if phi2 < -2.7999999999999999e-8 or 6.8000000000000003e-10 < phi2 Initial program 47.1%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
Applied rewrites48.9%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
Applied rewrites79.0%
if -2.7999999999999999e-8 < phi2 < 6.8000000000000003e-10Initial program 78.5%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites77.3%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites79.1%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites78.8%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites98.4%
Taylor expanded in lambda1 around inf
lower--.f64N/A
unpow2N/A
sqr-sin-a-revN/A
Applied rewrites98.5%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
Applied rewrites98.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(fma
(cos (* -0.5 lambda2))
(sin (* 0.5 lambda1))
(* (cos (* 0.5 lambda1)) (sin (* -0.5 lambda2))))
2.0))
(t_1 (fma (cos phi2) t_0 (pow (sin (* -0.5 phi2)) 2.0)))
(t_2 (sqrt t_1))
(t_3
(sqrt
(-
1.0
(fma
(cos phi1)
(* (cos phi2) t_0)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2)))))))))))
(if (<= phi2 -3.1e-5)
(* R (* 2.0 (atan2 t_2 t_3)))
(if (<= phi2 4.8e-65)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (cos phi1) t_0)))
t_3)))
(* R (* 2.0 (atan2 t_2 (sqrt (- 1.0 t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(fma(cos((-0.5 * lambda2)), sin((0.5 * lambda1)), (cos((0.5 * lambda1)) * sin((-0.5 * lambda2)))), 2.0);
double t_1 = fma(cos(phi2), t_0, pow(sin((-0.5 * phi2)), 2.0));
double t_2 = sqrt(t_1);
double t_3 = sqrt((1.0 - fma(cos(phi1), (cos(phi2) * t_0), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))));
double tmp;
if (phi2 <= -3.1e-5) {
tmp = R * (2.0 * atan2(t_2, t_3));
} else if (phi2 <= 4.8e-65) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi1) * t_0))), t_3));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - t_1))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(cos(Float64(-0.5 * lambda2)), sin(Float64(0.5 * lambda1)), Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(-0.5 * lambda2)))) ^ 2.0 t_1 = fma(cos(phi2), t_0, (sin(Float64(-0.5 * phi2)) ^ 2.0)) t_2 = sqrt(t_1) t_3 = sqrt(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * t_0), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2))))))))) tmp = 0.0 if (phi2 <= -3.1e-5) tmp = Float64(R * Float64(2.0 * atan(t_2, t_3))); elseif (phi2 <= 4.8e-65) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi1) * t_0))), t_3))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - t_1))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[Cos[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $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]], $MachinePrecision]}, If[LessEqual[phi2, -3.1e-5], N[(R * N[(2.0 * N[ArcTan[t$95$2 / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 4.8e-65], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{fma}\left(\cos \left(-0.5 \cdot \lambda_2\right), \sin \left(0.5 \cdot \lambda_1\right), \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(-0.5 \cdot \lambda_2\right)\right)\right)}^{2}\\
t_1 := \mathsf{fma}\left(\cos \phi_2, t\_0, {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)\\
t_2 := \sqrt{t\_1}\\
t_3 := \sqrt{1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot 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_2 \leq -3.1 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{t\_3}\right)\\
\mathbf{elif}\;\phi_2 \leq 4.8 \cdot 10^{-65}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_1 \cdot t\_0}}{t\_3}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - t\_1}}\right)\\
\end{array}
\end{array}
if phi2 < -3.10000000000000014e-5Initial program 45.7%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites45.4%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites46.0%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites45.7%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites56.4%
Taylor expanded in lambda1 around inf
lower--.f64N/A
unpow2N/A
sqr-sin-a-revN/A
Applied rewrites56.5%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
Applied rewrites57.5%
if -3.10000000000000014e-5 < phi2 < 4.8000000000000003e-65Initial program 78.4%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites77.1%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites79.0%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites78.7%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites98.3%
Taylor expanded in lambda1 around inf
lower--.f64N/A
unpow2N/A
sqr-sin-a-revN/A
Applied rewrites98.4%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
Applied rewrites98.4%
if 4.8000000000000003e-65 < phi2 Initial program 52.9%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites52.4%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites53.2%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites52.9%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites64.3%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
Applied rewrites59.0%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
Applied rewrites59.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(fma
(cos (* -0.5 lambda2))
(sin (* 0.5 lambda1))
(* (cos (* 0.5 lambda1)) (sin (* -0.5 lambda2))))
2.0))
(t_1 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (cos phi1) t_0)))
(t_2 (fma (cos phi2) t_0 (pow (sin (* -0.5 phi2)) 2.0)))
(t_3 (sqrt t_2)))
(if (<= phi2 -1e-5)
(*
R
(*
2.0
(atan2
t_3
(sqrt
(-
1.0
(fma
(cos phi1)
(* (cos phi2) t_0)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))))))
(if (<= phi2 4.8e-65)
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))
(* R (* 2.0 (atan2 t_3 (sqrt (- 1.0 t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(fma(cos((-0.5 * lambda2)), sin((0.5 * lambda1)), (cos((0.5 * lambda1)) * sin((-0.5 * lambda2)))), 2.0);
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi1) * t_0);
double t_2 = fma(cos(phi2), t_0, pow(sin((-0.5 * phi2)), 2.0));
double t_3 = sqrt(t_2);
double tmp;
if (phi2 <= -1e-5) {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - fma(cos(phi1), (cos(phi2) * t_0), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))))));
} else if (phi2 <= 4.8e-65) {
tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - t_2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(cos(Float64(-0.5 * lambda2)), sin(Float64(0.5 * lambda1)), Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(-0.5 * lambda2)))) ^ 2.0 t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi1) * t_0)) t_2 = fma(cos(phi2), t_0, (sin(Float64(-0.5 * phi2)) ^ 2.0)) t_3 = sqrt(t_2) tmp = 0.0 if (phi2 <= -1e-5) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * t_0), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))))))); elseif (phi2 <= 4.8e-65) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - t_2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[Cos[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[t$95$2], $MachinePrecision]}, If[LessEqual[phi2, -1e-5], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $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]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 4.8e-65], 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], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{fma}\left(\cos \left(-0.5 \cdot \lambda_2\right), \sin \left(0.5 \cdot \lambda_1\right), \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(-0.5 \cdot \lambda_2\right)\right)\right)}^{2}\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_1 \cdot t\_0\\
t_2 := \mathsf{fma}\left(\cos \phi_2, t\_0, {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)\\
t_3 := \sqrt{t\_2}\\
\mathbf{if}\;\phi_2 \leq -1 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}\right)\\
\mathbf{elif}\;\phi_2 \leq 4.8 \cdot 10^{-65}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - t\_2}}\right)\\
\end{array}
\end{array}
if phi2 < -1.00000000000000008e-5Initial program 45.7%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites45.4%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites46.0%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites45.7%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites56.4%
Taylor expanded in lambda1 around inf
lower--.f64N/A
unpow2N/A
sqr-sin-a-revN/A
Applied rewrites56.5%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
Applied rewrites57.4%
if -1.00000000000000008e-5 < phi2 < 4.8000000000000003e-65Initial program 78.4%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites77.1%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites79.0%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites78.7%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites98.4%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lower-pow.f64N/A
Applied rewrites98.4%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lower-pow.f64N/A
Applied rewrites98.4%
if 4.8000000000000003e-65 < phi2 Initial program 52.9%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites52.4%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites53.2%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites52.9%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites64.3%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
Applied rewrites59.0%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
Applied rewrites59.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(fma
(cos (* -0.5 lambda2))
(sin (* 0.5 lambda1))
(* (cos (* 0.5 lambda1)) (sin (* -0.5 lambda2))))
2.0))
(t_1 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (cos phi1) t_0)))
(t_2 (fma (cos phi2) t_0 (pow (sin (* -0.5 phi2)) 2.0)))
(t_3 (* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))))
(if (<= phi2 -1e-5)
t_3
(if (<= phi2 4.8e-65)
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))
t_3))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(fma(cos((-0.5 * lambda2)), sin((0.5 * lambda1)), (cos((0.5 * lambda1)) * sin((-0.5 * lambda2)))), 2.0);
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi1) * t_0);
double t_2 = fma(cos(phi2), t_0, pow(sin((-0.5 * phi2)), 2.0));
double t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
double tmp;
if (phi2 <= -1e-5) {
tmp = t_3;
} else if (phi2 <= 4.8e-65) {
tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
} else {
tmp = t_3;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(cos(Float64(-0.5 * lambda2)), sin(Float64(0.5 * lambda1)), Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(-0.5 * lambda2)))) ^ 2.0 t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi1) * t_0)) t_2 = fma(cos(phi2), t_0, (sin(Float64(-0.5 * phi2)) ^ 2.0)) t_3 = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))) tmp = 0.0 if (phi2 <= -1e-5) tmp = t_3; elseif (phi2 <= 4.8e-65) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))); else tmp = t_3; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[Cos[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1e-5], t$95$3, If[LessEqual[phi2, 4.8e-65], 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], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{fma}\left(\cos \left(-0.5 \cdot \lambda_2\right), \sin \left(0.5 \cdot \lambda_1\right), \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(-0.5 \cdot \lambda_2\right)\right)\right)}^{2}\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_1 \cdot t\_0\\
t_2 := \mathsf{fma}\left(\cos \phi_2, t\_0, {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)\\
t_3 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{if}\;\phi_2 \leq -1 \cdot 10^{-5}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_2 \leq 4.8 \cdot 10^{-65}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if phi2 < -1.00000000000000008e-5 or 4.8000000000000003e-65 < phi2 Initial program 49.7%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites49.3%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites50.0%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites49.7%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites60.8%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
Applied rewrites58.2%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
Applied rewrites58.9%
if -1.00000000000000008e-5 < phi2 < 4.8000000000000003e-65Initial program 78.4%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites77.1%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites79.0%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites78.7%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites98.4%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lower-pow.f64N/A
Applied rewrites98.4%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lower-pow.f64N/A
Applied rewrites98.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(cos phi1)
(*
(cos phi2)
(pow
(fma
(cos (* -0.5 lambda2))
(sin (* 0.5 lambda1))
(* (cos (* 0.5 lambda1)) (sin (* -0.5 lambda2))))
2.0))
(pow (sin (* 0.5 (+ phi1 (* -1.0 phi2)))) 2.0))))
(* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma(cos(phi1), (cos(phi2) * pow(fma(cos((-0.5 * lambda2)), sin((0.5 * lambda1)), (cos((0.5 * lambda1)) * sin((-0.5 * lambda2)))), 2.0)), pow(sin((0.5 * (phi1 + (-1.0 * phi2)))), 2.0));
return R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(cos(phi1), Float64(cos(phi2) * (fma(cos(Float64(-0.5 * lambda2)), sin(Float64(0.5 * lambda1)), Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(-0.5 * lambda2)))) ^ 2.0)), (sin(Float64(0.5 * Float64(phi1 + Float64(-1.0 * phi2)))) ^ 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(N[Cos[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 + N[(-1.0 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\left(\mathsf{fma}\left(\cos \left(-0.5 \cdot \lambda_2\right), \sin \left(0.5 \cdot \lambda_1\right), \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(-0.5 \cdot \lambda_2\right)\right)\right)}^{2}, {\sin \left(0.5 \cdot \left(\phi_1 + -1 \cdot \phi_2\right)\right)}^{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 62.5%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites61.7%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites62.9%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites77.5%
Taylor expanded in phi2 around -inf
lower-fma.f64N/A
Applied rewrites77.6%
Taylor expanded in phi2 around -inf
lower-fma.f64N/A
Applied rewrites77.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(fma
(cos (* -0.5 lambda2))
(sin (* 0.5 lambda1))
(* (cos (* 0.5 lambda1)) (sin (* -0.5 lambda2))))
2.0))
(t_1 (fma (cos phi2) t_0 (pow (sin (* -0.5 phi2)) 2.0)))
(t_2 (fma (cos phi1) t_0 (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 phi1)))))))
(t_3 (* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))))
(if (<= phi1 -9.8e-8)
t_3
(if (<= phi1 16000.0)
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))
t_3))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(fma(cos((-0.5 * lambda2)), sin((0.5 * lambda1)), (cos((0.5 * lambda1)) * sin((-0.5 * lambda2)))), 2.0);
double t_1 = fma(cos(phi2), t_0, pow(sin((-0.5 * phi2)), 2.0));
double t_2 = fma(cos(phi1), t_0, (0.5 - (0.5 * cos((2.0 * (0.5 * phi1))))));
double t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
double tmp;
if (phi1 <= -9.8e-8) {
tmp = t_3;
} else if (phi1 <= 16000.0) {
tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
} else {
tmp = t_3;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(cos(Float64(-0.5 * lambda2)), sin(Float64(0.5 * lambda1)), Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(-0.5 * lambda2)))) ^ 2.0 t_1 = fma(cos(phi2), t_0, (sin(Float64(-0.5 * phi2)) ^ 2.0)) t_2 = fma(cos(phi1), t_0, Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * phi1)))))) t_3 = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))) tmp = 0.0 if (phi1 <= -9.8e-8) tmp = t_3; elseif (phi1 <= 16000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))); else tmp = t_3; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[Cos[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * t$95$0 + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -9.8e-8], t$95$3, If[LessEqual[phi1, 16000.0], 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], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{fma}\left(\cos \left(-0.5 \cdot \lambda_2\right), \sin \left(0.5 \cdot \lambda_1\right), \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(-0.5 \cdot \lambda_2\right)\right)\right)}^{2}\\
t_1 := \mathsf{fma}\left(\cos \phi_2, t\_0, {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)\\
t_2 := \mathsf{fma}\left(\cos \phi_1, t\_0, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \phi_1\right)\right)\right)\\
t_3 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{if}\;\phi_1 \leq -9.8 \cdot 10^{-8}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_1 \leq 16000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if phi1 < -9.8000000000000004e-8 or 16000 < phi1 Initial program 47.5%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites47.4%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites47.8%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites47.4%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites57.8%
Taylor expanded in phi2 around 0
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites58.5%
Taylor expanded in phi2 around 0
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites59.2%
if -9.8000000000000004e-8 < phi1 < 16000Initial program 77.7%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites76.3%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites78.3%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites78.1%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites97.7%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
Applied rewrites95.0%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
Applied rewrites95.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1
(fma
(cos phi1)
(pow
(fma
(cos (* -0.5 lambda2))
(sin (* 0.5 lambda1))
(* (cos (* 0.5 lambda1)) (sin (* -0.5 lambda2))))
2.0)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 phi1)))))))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3
(+
t_0
(*
(* (/ (+ (cos (+ phi2 phi1)) (cos (- phi2 phi1))) 2.0) t_2)
t_2))))
(if (<= phi2 -7200.0)
(* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- 1.0 t_3)))))
(if (<= phi2 7.2e-31)
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* (* (* (cos phi1) (cos phi2)) t_2) t_2)))
(sqrt
(-
1.0
(fma
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(cos phi2)
(- 0.5 (* 0.5 (cos (* 2.0 (* -0.5 phi2)))))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = fma(cos(phi1), pow(fma(cos((-0.5 * lambda2)), sin((0.5 * lambda1)), (cos((0.5 * lambda1)) * sin((-0.5 * lambda2)))), 2.0), (0.5 - (0.5 * cos((2.0 * (0.5 * phi1))))));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_0 + ((((cos((phi2 + phi1)) + cos((phi2 - phi1))) / 2.0) * t_2) * t_2);
double tmp;
if (phi2 <= -7200.0) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3))));
} else if (phi2 <= 7.2e-31) {
tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (((cos(phi1) * cos(phi2)) * t_2) * t_2))), sqrt((1.0 - fma((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))), cos(phi2), (0.5 - (0.5 * cos((2.0 * (-0.5 * phi2))))))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = fma(cos(phi1), (fma(cos(Float64(-0.5 * lambda2)), sin(Float64(0.5 * lambda1)), Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(-0.5 * lambda2)))) ^ 2.0), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * phi1)))))) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_0 + Float64(Float64(Float64(Float64(cos(Float64(phi2 + phi1)) + cos(Float64(phi2 - phi1))) / 2.0) * t_2) * t_2)) tmp = 0.0 if (phi2 <= -7200.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_3))))); elseif (phi2 <= 7.2e-31) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_2) * t_2))), sqrt(Float64(1.0 - fma(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))), cos(phi2), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(-0.5 * phi2))))))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[(N[Cos[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 + N[(N[(N[(N[(N[Cos[N[(phi2 + phi1), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -7200.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 7.2e-31], 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], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(-0.5 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \mathsf{fma}\left(\cos \phi_1, {\left(\mathsf{fma}\left(\cos \left(-0.5 \cdot \lambda_2\right), \sin \left(0.5 \cdot \lambda_1\right), \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(-0.5 \cdot \lambda_2\right)\right)\right)}^{2}, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \phi_1\right)\right)\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_0 + \left(\frac{\cos \left(\phi_2 + \phi_1\right) + \cos \left(\phi_2 - \phi_1\right)}{2} \cdot t\_2\right) \cdot t\_2\\
\mathbf{if}\;\phi_2 \leq -7200:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_3}}\right)\\
\mathbf{elif}\;\phi_2 \leq 7.2 \cdot 10^{-31}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right) \cdot t\_2}}{\sqrt{1 - \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), \cos \phi_2, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(-0.5 \cdot \phi_2\right)\right)\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -7200Initial program 45.4%
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
cos-multN/A
lower-/.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6446.5
Applied rewrites46.5%
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
cos-multN/A
lower-/.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6447.3
Applied rewrites47.3%
if -7200 < phi2 < 7.20000000000000007e-31Initial program 78.2%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites76.9%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites78.7%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites78.5%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
mult-flipN/A
negate-subN/A
mul-1-negN/A
metadata-evalN/A
*-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
sin-sumN/A
lower-+.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
Applied rewrites98.0%
Taylor expanded in phi2 around 0
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites92.4%
Taylor expanded in phi2 around 0
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites92.4%
if 7.20000000000000007e-31 < phi2 Initial program 50.3%
Taylor expanded in phi1 around 0
lower--.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites49.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(-
0.5
(*
0.5
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(*
(* (/ (+ (cos (+ phi2 phi1)) (cos (- phi2 phi1))) 2.0) t_1)
t_1))))
(if (<= lambda1 -1.4e+220)
(* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))
(* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((((cos((phi2 + phi1)) + cos((phi2 - phi1))) / 2.0) * t_1) * t_1);
double tmp;
if (lambda1 <= -1.4e+220) {
tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 - Float64(0.5 * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(Float64(cos(Float64(phi2 + phi1)) + cos(Float64(phi2 - phi1))) / 2.0) * t_1) * t_1)) tmp = 0.0 if (lambda1 <= -1.4e+220) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 - N[(0.5 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[(N[Cos[N[(phi2 + phi1), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -1.4e+220], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 - 0.5 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\frac{\cos \left(\phi_2 + \phi_1\right) + \cos \left(\phi_2 - \phi_1\right)}{2} \cdot t\_1\right) \cdot t\_1\\
\mathbf{if}\;\lambda_1 \leq -1.4 \cdot 10^{+220}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\end{array}
\end{array}
if lambda1 < -1.4e220Initial program 48.9%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites41.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.1%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6431.0
Applied rewrites31.0%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6430.6
Applied rewrites30.6%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6431.1
Applied rewrites31.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6441.1
Applied rewrites41.1%
if -1.4e220 < lambda1 Initial program 63.5%
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
cos-multN/A
lower-/.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6464.0
Applied rewrites64.0%
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
cos-multN/A
lower-/.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6464.4
Applied rewrites64.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(-
0.5
(*
0.5
(fma
(cos lambda1)
(cos lambda2)
(* (sin lambda1) (sin lambda2)))))))
(if (<= lambda1 -1.4e+220)
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0)))
(sqrt
(-
(-
1.0
(*
(*
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(cos phi2))
(cos phi1)))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = 0.5 - (0.5 * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))));
double tmp;
if (lambda1 <= -1.4e+220) {
tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0))), sqrt(((1.0 - (((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * cos(phi2)) * cos(phi1))) - (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2))))))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(0.5 - Float64(0.5 * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))) tmp = 0.0 if (lambda1 <= -1.4e+220) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0))), sqrt(Float64(Float64(1.0 - Float64(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))) * cos(phi2)) * cos(phi1))) - Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2))))))))))); 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[(0.5 - N[(0.5 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -1.4e+220], 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], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[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]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[(N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $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]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := 0.5 - 0.5 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -1.4 \cdot 10^{+220}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\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}}{\sqrt{\left(1 - \left(\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right) \cdot \cos \phi_2\right) \cdot \cos \phi_1\right) - \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -1.4e220Initial program 48.9%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites41.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.1%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6431.0
Applied rewrites31.0%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6430.6
Applied rewrites30.6%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6431.1
Applied rewrites31.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6441.1
Applied rewrites41.1%
if -1.4e220 < lambda1 Initial program 63.5%
Applied rewrites63.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* 0.5 (- lambda1 lambda2)))
(t_2
(+
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))
(* (* (- 0.5 (* 0.5 (cos (* 2.0 t_1)))) (cos phi2)) (cos phi1))))
(t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_4 (+ t_3 (* (* (sin t_1) (cos phi1)) t_0)))
(t_5 (+ t_3 (* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(if (<= (* 2.0 (atan2 (sqrt t_5) (sqrt (- 1.0 t_5)))) 0.28)
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- 1.0 t_4)))))
(* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = 0.5 * (lambda1 - lambda2);
double t_2 = (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))) + (((0.5 - (0.5 * cos((2.0 * t_1)))) * cos(phi2)) * cos(phi1));
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = t_3 + ((sin(t_1) * cos(phi1)) * t_0);
double t_5 = t_3 + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
double tmp;
if ((2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_5)))) <= 0.28) {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = 0.5d0 * (lambda1 - lambda2)
t_2 = (0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * (phi1 - phi2)))))) + (((0.5d0 - (0.5d0 * cos((2.0d0 * t_1)))) * cos(phi2)) * cos(phi1))
t_3 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_4 = t_3 + ((sin(t_1) * cos(phi1)) * t_0)
t_5 = t_3 + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
if ((2.0d0 * atan2(sqrt(t_5), sqrt((1.0d0 - t_5)))) <= 0.28d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - t_4))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 - t_2))))
end if
code = tmp
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 = 0.5 * (lambda1 - lambda2);
double t_2 = (0.5 - (0.5 * Math.cos((2.0 * (0.5 * (phi1 - phi2)))))) + (((0.5 - (0.5 * Math.cos((2.0 * t_1)))) * Math.cos(phi2)) * Math.cos(phi1));
double t_3 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = t_3 + ((Math.sin(t_1) * Math.cos(phi1)) * t_0);
double t_5 = t_3 + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
double tmp;
if ((2.0 * Math.atan2(Math.sqrt(t_5), Math.sqrt((1.0 - t_5)))) <= 0.28) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - t_4))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = 0.5 * (lambda1 - lambda2) t_2 = (0.5 - (0.5 * math.cos((2.0 * (0.5 * (phi1 - phi2)))))) + (((0.5 - (0.5 * math.cos((2.0 * t_1)))) * math.cos(phi2)) * math.cos(phi1)) t_3 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_4 = t_3 + ((math.sin(t_1) * math.cos(phi1)) * t_0) t_5 = t_3 + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) tmp = 0 if (2.0 * math.atan2(math.sqrt(t_5), math.sqrt((1.0 - t_5)))) <= 0.28: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - t_4)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(0.5 * Float64(lambda1 - lambda2)) t_2 = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))) + Float64(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_1)))) * cos(phi2)) * cos(phi1))) t_3 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_4 = Float64(t_3 + Float64(Float64(sin(t_1) * cos(phi1)) * t_0)) t_5 = Float64(t_3 + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) tmp = 0.0 if (Float64(2.0 * atan(sqrt(t_5), sqrt(Float64(1.0 - t_5)))) <= 0.28) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - t_4))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = 0.5 * (lambda1 - lambda2); t_2 = (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))) + (((0.5 - (0.5 * cos((2.0 * t_1)))) * cos(phi2)) * cos(phi1)); t_3 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_4 = t_3 + ((sin(t_1) * cos(phi1)) * t_0); t_5 = t_3 + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = 0.0; if ((2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_5)))) <= 0.28) tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4)))); else tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2)))); end tmp_2 = 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[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 + N[(N[(N[Sin[t$95$1], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$3 + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.28], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := 0.5 \cdot \left(\lambda_1 - \lambda_2\right)\\
t_2 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right) + \left(\left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_1\right)\right) \cdot \cos \phi_2\right) \cdot \cos \phi_1\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_4 := t\_3 + \left(\sin t\_1 \cdot \cos \phi_1\right) \cdot t\_0\\
t_5 := t\_3 + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
\mathbf{if}\;2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5}}{\sqrt{1 - t\_5}} \leq 0.28:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - t\_4}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) (atan2.f64 (sqrt.f64 (+.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)))))) (sqrt.f64 (-.f64 #s(literal 1 binary64) (+.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))))))))) < 0.28000000000000003Initial program 83.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6481.9
Applied rewrites81.9%
Taylor expanded in phi2 around 0
*-commutativeN/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6481.6
Applied rewrites81.6%
if 0.28000000000000003 < (*.f64 #s(literal 2 binary64) (atan2.f64 (sqrt.f64 (+.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)))))) (sqrt.f64 (-.f64 #s(literal 1 binary64) (+.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 60.0%
Applied rewrites60.0%
Applied rewrites60.1%
(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)))
(t_2 (sqrt t_1))
(t_3 (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))))))
(t_4
(+
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))
(* (* t_3 (cos phi2)) (cos phi1)))))
(if (<= (* 2.0 (atan2 t_2 (sqrt (- 1.0 t_1)))) 0.05)
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(fma t_3 (cos phi2) (- 0.5 (* 0.5 (cos (* 2.0 (* -0.5 phi2)))))))))))
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- 1.0 t_4))))))))
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);
double t_2 = sqrt(t_1);
double t_3 = 0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))));
double t_4 = (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))) + ((t_3 * cos(phi2)) * cos(phi1));
double tmp;
if ((2.0 * atan2(t_2, sqrt((1.0 - t_1)))) <= 0.05) {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - fma(t_3, cos(phi2), (0.5 - (0.5 * cos((2.0 * (-0.5 * phi2))))))))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4))));
}
return tmp;
}
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)) t_2 = sqrt(t_1) t_3 = Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))) t_4 = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))) + Float64(Float64(t_3 * cos(phi2)) * cos(phi1))) tmp = 0.0 if (Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - t_1)))) <= 0.05) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - fma(t_3, cos(phi2), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(-0.5 * phi2))))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - t_4))))); 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[(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]}, Block[{t$95$2 = N[Sqrt[t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$3 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.05], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$3 * N[Cos[phi2], $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(-0.5 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $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\\
t_2 := \sqrt{t\_1}\\
t_3 := 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\\
t_4 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right) + \left(t\_3 \cdot \cos \phi_2\right) \cdot \cos \phi_1\\
\mathbf{if}\;2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - t\_1}} \leq 0.05:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \mathsf{fma}\left(t\_3, \cos \phi_2, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(-0.5 \cdot \phi_2\right)\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - t\_4}}\right)\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) (atan2.f64 (sqrt.f64 (+.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)))))) (sqrt.f64 (-.f64 #s(literal 1 binary64) (+.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))))))))) < 0.050000000000000003Initial program 94.3%
Taylor expanded in phi1 around 0
lower--.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites92.5%
if 0.050000000000000003 < (*.f64 #s(literal 2 binary64) (atan2.f64 (sqrt.f64 (+.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)))))) (sqrt.f64 (-.f64 #s(literal 1 binary64) (+.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 60.1%
Applied rewrites60.1%
Applied rewrites60.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))))))
(t_1
(+
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))
(* (* t_0 (cos phi2)) (cos phi1))))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_2) t_2))))
(if (<= t_3 5e-7)
(*
R
(*
2.0
(atan2
(sqrt t_3)
(sqrt
(-
1.0
(fma t_0 (cos phi1) (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 phi1)))))))))))
(* 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 = 0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))));
double t_1 = (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))) + ((t_0 * cos(phi2)) * cos(phi1));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_2) * t_2);
double tmp;
if (t_3 <= 5e-7) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - fma(t_0, cos(phi1), (0.5 - (0.5 * cos((2.0 * (0.5 * phi1))))))))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - 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(lambda1 - lambda2)))))) t_1 = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))) + Float64(Float64(t_0 * cos(phi2)) * cos(phi1))) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_2) * t_2)) tmp = 0.0 if (t_3 <= 5e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - fma(t_0, cos(phi1), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * phi1))))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - 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[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = 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$2), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, 5e-7], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 * N[Cos[phi1], $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $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 := 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\\
t_1 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right) + \left(t\_0 \cdot \cos \phi_2\right) \cdot \cos \phi_1\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right) \cdot t\_2\\
\mathbf{if}\;t\_3 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - \mathsf{fma}\left(t\_0, \cos \phi_1, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \phi_1\right)\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\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))))) < 4.99999999999999977e-7Initial program 69.7%
Taylor expanded in phi2 around 0
lower--.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites69.3%
if 4.99999999999999977e-7 < (+.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 61.8%
Applied rewrites61.7%
Applied rewrites61.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))))))
(t_1
(fma
(cos phi2)
(- 0.5 (* 0.5 (cos (- lambda1 lambda2))))
(pow (sin (* -0.5 phi2)) 2.0)))
(t_2 (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
(if (<= phi2 -3.6e-6)
t_2
(if (<= phi2 3.8e-55)
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) t_0)
(pow (sin (* 0.5 (+ phi1 (* -1.0 phi2)))) 2.0)))
(sqrt
(-
1.0
(fma
t_0
(cos phi1)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 phi1)))))))))))
t_2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))));
double t_1 = fma(cos(phi2), (0.5 - (0.5 * cos((lambda1 - lambda2)))), pow(sin((-0.5 * phi2)), 2.0));
double t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
double tmp;
if (phi2 <= -3.6e-6) {
tmp = t_2;
} else if (phi2 <= 3.8e-55) {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi1), (cos(phi2) * t_0), pow(sin((0.5 * (phi1 + (-1.0 * phi2)))), 2.0))), sqrt((1.0 - fma(t_0, cos(phi1), (0.5 - (0.5 * cos((2.0 * (0.5 * phi1))))))))));
} else {
tmp = t_2;
}
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(lambda1 - lambda2)))))) t_1 = fma(cos(phi2), Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))), (sin(Float64(-0.5 * phi2)) ^ 2.0)) t_2 = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) tmp = 0.0 if (phi2 <= -3.6e-6) tmp = t_2; elseif (phi2 <= 3.8e-55) tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * t_0), (sin(Float64(0.5 * Float64(phi1 + Float64(-1.0 * phi2)))) ^ 2.0))), sqrt(Float64(1.0 - fma(t_0, cos(phi1), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * phi1))))))))))); else tmp = t_2; 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[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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]}, If[LessEqual[phi2, -3.6e-6], t$95$2, If[LessEqual[phi2, 3.8e-55], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 + N[(-1.0 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 * N[Cos[phi1], $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\\
t_1 := \mathsf{fma}\left(\cos \phi_2, 0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)\\
t_2 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{if}\;\phi_2 \leq -3.6 \cdot 10^{-6}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_2 \leq 3.8 \cdot 10^{-55}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, {\sin \left(0.5 \cdot \left(\phi_1 + -1 \cdot \phi_2\right)\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t\_0, \cos \phi_1, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \phi_1\right)\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi2 < -3.59999999999999984e-6 or 3.7999999999999997e-55 < phi2 Initial program 49.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites21.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites21.9%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites18.0%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites39.0%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-pow.f6440.5
Applied rewrites40.5%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-pow.f6448.4
Applied rewrites48.4%
if -3.59999999999999984e-6 < phi2 < 3.7999999999999997e-55Initial program 78.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.3%
Taylor expanded in phi2 around -inf
lower-sqrt.f64N/A
lower-fma.f64N/A
Applied rewrites73.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))))))
(t_1 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (cos phi2))))
(t_2 (+ (* t_0 (cos phi1)) (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 phi1)))))))
(t_3 (* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))))
(if (<= phi1 -1.4e-6)
t_3
(if (<= phi1 0.000155)
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))
t_3))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * cos(phi2));
double t_2 = (t_0 * cos(phi1)) + (0.5 - (0.5 * cos((2.0 * (0.5 * phi1)))));
double t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
double tmp;
if (phi1 <= -1.4e-6) {
tmp = t_3;
} else if (phi1 <= 0.000155) {
tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
} else {
tmp = t_3;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = 0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * (lambda1 - lambda2)))))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * cos(phi2))
t_2 = (t_0 * cos(phi1)) + (0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * phi1)))))
t_3 = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 - t_2))))
if (phi1 <= (-1.4d-6)) then
tmp = t_3
else if (phi1 <= 0.000155d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
else
tmp = t_3
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * Math.cos((2.0 * (0.5 * (lambda1 - lambda2)))));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * Math.cos(phi2));
double t_2 = (t_0 * Math.cos(phi1)) + (0.5 - (0.5 * Math.cos((2.0 * (0.5 * phi1)))));
double t_3 = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 - t_2))));
double tmp;
if (phi1 <= -1.4e-6) {
tmp = t_3;
} else if (phi1 <= 0.000155) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
} else {
tmp = t_3;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 0.5 - (0.5 * math.cos((2.0 * (0.5 * (lambda1 - lambda2))))) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * math.cos(phi2)) t_2 = (t_0 * math.cos(phi1)) + (0.5 - (0.5 * math.cos((2.0 * (0.5 * phi1))))) t_3 = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 - t_2)))) tmp = 0 if phi1 <= -1.4e-6: tmp = t_3 elif phi1 <= 0.000155: tmp = R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1)))) else: tmp = t_3 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(lambda1 - lambda2)))))) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * cos(phi2))) t_2 = Float64(Float64(t_0 * cos(phi1)) + Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * phi1)))))) t_3 = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))) tmp = 0.0 if (phi1 <= -1.4e-6) tmp = t_3; elseif (phi1 <= 0.000155) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))); else tmp = t_3; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = 0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2))))); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * cos(phi2)); t_2 = (t_0 * cos(phi1)) + (0.5 - (0.5 * cos((2.0 * (0.5 * phi1))))); t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2)))); tmp = 0.0; if (phi1 <= -1.4e-6) tmp = t_3; elseif (phi1 <= 0.000155) tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); else tmp = t_3; end tmp_2 = 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[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.4e-6], t$95$3, If[LessEqual[phi1, 0.000155], 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], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \cos \phi_2\\
t_2 := t\_0 \cdot \cos \phi_1 + \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \phi_1\right)\right)\right)\\
t_3 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{if}\;\phi_1 \leq -1.4 \cdot 10^{-6}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_1 \leq 0.000155:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if phi1 < -1.39999999999999994e-6 or 1.55e-4 < phi1 Initial program 47.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites48.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites49.1%
Applied rewrites49.0%
Applied rewrites49.0%
if -1.39999999999999994e-6 < phi1 < 1.55e-4Initial program 78.1%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites73.1%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites73.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(*
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(cos phi1))))
(t_1
(fma
(cos phi2)
(- 0.5 (* 0.5 (cos (- lambda1 lambda2))))
(pow (sin (* -0.5 phi2)) 2.0)))
(t_2 (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
(if (<= phi2 -2.95e-5)
t_2
(if (<= phi2 3.8e-55)
(* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))
t_2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * cos(phi1));
double t_1 = fma(cos(phi2), (0.5 - (0.5 * cos((lambda1 - lambda2)))), pow(sin((-0.5 * phi2)), 2.0));
double t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
double tmp;
if (phi2 <= -2.95e-5) {
tmp = t_2;
} else if (phi2 <= 3.8e-55) {
tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
} else {
tmp = t_2;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))) * cos(phi1))) t_1 = fma(cos(phi2), Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))), (sin(Float64(-0.5 * phi2)) ^ 2.0)) t_2 = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) tmp = 0.0 if (phi2 <= -2.95e-5) tmp = t_2; elseif (phi2 <= 3.8e-55) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))); else tmp = t_2; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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]}, If[LessEqual[phi2, -2.95e-5], t$95$2, If[LessEqual[phi2, 3.8e-55], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right) \cdot \cos \phi_1\\
t_1 := \mathsf{fma}\left(\cos \phi_2, 0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)\\
t_2 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{if}\;\phi_2 \leq -2.95 \cdot 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_2 \leq 3.8 \cdot 10^{-55}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi2 < -2.9499999999999999e-5 or 3.7999999999999997e-55 < phi2 Initial program 49.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites21.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites21.9%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites18.0%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites39.1%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-pow.f6440.5
Applied rewrites40.5%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-pow.f6448.4
Applied rewrites48.4%
if -2.9499999999999999e-5 < phi2 < 3.7999999999999997e-55Initial program 78.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites73.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites73.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(cos phi1)
(pow (sin (* 0.5 phi1)) 2.0)))
(t_1
(fma
(cos phi2)
(- 0.5 (* 0.5 (cos (- lambda1 lambda2))))
(pow (sin (* -0.5 phi2)) 2.0)))
(t_2 (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
(if (<= phi2 -6e-8)
t_2
(if (<= phi2 4.8e-65)
(* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))
t_2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))), cos(phi1), pow(sin((0.5 * phi1)), 2.0));
double t_1 = fma(cos(phi2), (0.5 - (0.5 * cos((lambda1 - lambda2)))), pow(sin((-0.5 * phi2)), 2.0));
double t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
double tmp;
if (phi2 <= -6e-8) {
tmp = t_2;
} else if (phi2 <= 4.8e-65) {
tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
} else {
tmp = t_2;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))), cos(phi1), (sin(Float64(0.5 * phi1)) ^ 2.0)) t_1 = fma(cos(phi2), Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))), (sin(Float64(-0.5 * phi2)) ^ 2.0)) t_2 = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) tmp = 0.0 if (phi2 <= -6e-8) tmp = t_2; elseif (phi2 <= 4.8e-65) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))); else tmp = t_2; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[Power[N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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]}, If[LessEqual[phi2, -6e-8], t$95$2, If[LessEqual[phi2, 4.8e-65], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), \cos \phi_1, {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)\\
t_1 := \mathsf{fma}\left(\cos \phi_2, 0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)\\
t_2 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{if}\;\phi_2 \leq -6 \cdot 10^{-8}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_2 \leq 4.8 \cdot 10^{-65}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi2 < -5.99999999999999946e-8 or 4.8000000000000003e-65 < phi2 Initial program 49.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites22.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites22.6%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites18.4%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites39.1%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-pow.f6440.5
Applied rewrites40.5%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-pow.f6448.4
Applied rewrites48.4%
if -5.99999999999999946e-8 < phi2 < 4.8000000000000003e-65Initial program 78.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.4%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
unpow2N/A
lower-pow.f64N/A
lift-sin.f64N/A
lift-*.f6470.8
Applied rewrites70.8%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
unpow2N/A
lower-pow.f64N/A
lift-sin.f64N/A
lift-*.f6470.7
Applied rewrites70.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_3
(+
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))
(* t_0 (cos phi1))))
(t_4 (+ t_2 t_0)))
(if (<= (+ t_2 (* (* (* (cos phi1) (cos phi2)) t_1) t_1)) 0.0004)
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- 1.0 t_4)))))
(* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- 1.0 t_3))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_3 = (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))) + (t_0 * cos(phi1));
double t_4 = t_2 + t_0;
double tmp;
if ((t_2 + (((cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.0004) {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = (0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * (lambda1 - lambda2)))))) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_3 = (0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * (phi1 - phi2)))))) + (t_0 * cos(phi1))
t_4 = t_2 + t_0
if ((t_2 + (((cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.0004d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - t_4))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - t_3))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (0.5 - (0.5 * Math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_3 = (0.5 - (0.5 * Math.cos((2.0 * (0.5 * (phi1 - phi2)))))) + (t_0 * Math.cos(phi1));
double t_4 = t_2 + t_0;
double tmp;
if ((t_2 + (((Math.cos(phi1) * Math.cos(phi2)) * t_1) * t_1)) <= 0.0004) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - t_4))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - t_3))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (0.5 - (0.5 * math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_3 = (0.5 - (0.5 * math.cos((2.0 * (0.5 * (phi1 - phi2)))))) + (t_0 * math.cos(phi1)) t_4 = t_2 + t_0 tmp = 0 if (t_2 + (((math.cos(phi1) * math.cos(phi2)) * t_1) * t_1)) <= 0.0004: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - t_4)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - t_3)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_3 = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))) + Float64(t_0 * cos(phi1))) t_4 = Float64(t_2 + t_0) tmp = 0.0 if (Float64(t_2 + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.0004) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - t_4))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_3))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_3 = (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))) + (t_0 * cos(phi1)); t_4 = t_2 + t_0; tmp = 0.0; if ((t_2 + (((cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.0004) tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4)))); else tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 + t$95$0), $MachinePrecision]}, If[LessEqual[N[(t$95$2 + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 0.0004], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right) \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_3 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right) + t\_0 \cdot \cos \phi_1\\
t_4 := t\_2 + t\_0\\
\mathbf{if}\;t\_2 + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) \cdot t\_1 \leq 0.0004:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - t\_4}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_3}}\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))))) < 4.00000000000000019e-4Initial program 70.3%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites46.5%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites46.5%
if 4.00000000000000019e-4 < (+.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 61.7%
Applied rewrites61.6%
Applied rewrites61.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(cos phi2)
(- 0.5 (* 0.5 (cos (- lambda1 lambda2))))
(pow (sin (* -0.5 phi2)) 2.0)))
(t_1
(+
(*
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(cos phi1))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 phi1)))))))
(t_2 (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
(if (<= phi1 -1.1e-16)
t_2
(if (<= phi1 16000.0)
(* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))
t_2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma(cos(phi2), (0.5 - (0.5 * cos((lambda1 - lambda2)))), pow(sin((-0.5 * phi2)), 2.0));
double t_1 = ((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * cos(phi1)) + (0.5 - (0.5 * cos((2.0 * (0.5 * phi1)))));
double t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
double tmp;
if (phi1 <= -1.1e-16) {
tmp = t_2;
} else if (phi1 <= 16000.0) {
tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
} else {
tmp = t_2;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(cos(phi2), Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))), (sin(Float64(-0.5 * phi2)) ^ 2.0)) t_1 = Float64(Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))) * cos(phi1)) + Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * phi1)))))) t_2 = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) tmp = 0.0 if (phi1 <= -1.1e-16) tmp = t_2; elseif (phi1 <= 16000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))); 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[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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]}, If[LessEqual[phi1, -1.1e-16], t$95$2, If[LessEqual[phi1, 16000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\cos \phi_2, 0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)\\
t_1 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right) \cdot \cos \phi_1 + \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \phi_1\right)\right)\right)\\
t_2 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{if}\;\phi_1 \leq -1.1 \cdot 10^{-16}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 16000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi1 < -1.1e-16 or 16000 < phi1 Initial program 47.9%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites48.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites48.9%
Applied rewrites48.9%
Applied rewrites48.8%
if -1.1e-16 < phi1 < 16000Initial program 77.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites37.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites36.7%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites42.5%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites70.6%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-pow.f6470.5
Applied rewrites70.5%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-pow.f6470.5
Applied rewrites70.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))))))
(t_1 (+ (* t_0 (cos phi1)) (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 phi1)))))))
(t_2 (fma t_0 (cos phi2) (- 0.5 (* 0.5 (cos (* 2.0 (* -0.5 phi2)))))))
(t_3 (* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))))
(if (<= phi2 -3.6e-6)
t_3
(if (<= phi2 4.8e-65)
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))
t_3))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))));
double t_1 = (t_0 * cos(phi1)) + (0.5 - (0.5 * cos((2.0 * (0.5 * phi1)))));
double t_2 = fma(t_0, cos(phi2), (0.5 - (0.5 * cos((2.0 * (-0.5 * phi2))))));
double t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
double tmp;
if (phi2 <= -3.6e-6) {
tmp = t_3;
} else if (phi2 <= 4.8e-65) {
tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
} else {
tmp = t_3;
}
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(lambda1 - lambda2)))))) t_1 = Float64(Float64(t_0 * cos(phi1)) + Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * phi1)))))) t_2 = fma(t_0, cos(phi2), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(-0.5 * phi2)))))) t_3 = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))) tmp = 0.0 if (phi2 <= -3.6e-6) tmp = t_3; elseif (phi2 <= 4.8e-65) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))); else tmp = t_3; 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[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[Cos[phi2], $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(-0.5 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -3.6e-6], t$95$3, If[LessEqual[phi2, 4.8e-65], 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], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\\
t_1 := t\_0 \cdot \cos \phi_1 + \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \phi_1\right)\right)\right)\\
t_2 := \mathsf{fma}\left(t\_0, \cos \phi_2, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(-0.5 \cdot \phi_2\right)\right)\right)\\
t_3 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{if}\;\phi_2 \leq -3.6 \cdot 10^{-6}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_2 \leq 4.8 \cdot 10^{-65}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if phi2 < -3.59999999999999984e-6 or 4.8000000000000003e-65 < phi2 Initial program 49.7%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.8%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites47.5%
if -3.59999999999999984e-6 < phi2 < 4.8000000000000003e-65Initial program 78.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.3%
Applied rewrites68.3%
Applied rewrites68.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))))))
(t_1 (fma t_0 (cos phi1) (- 0.5 (* 0.5 (cos phi1)))))
(t_2 (fma t_0 (cos phi2) (- 0.5 (* 0.5 (cos (* 2.0 (* -0.5 phi2)))))))
(t_3 (* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))))
(if (<= phi2 -3.6e-6)
t_3
(if (<= phi2 4.8e-65)
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))
t_3))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))));
double t_1 = fma(t_0, cos(phi1), (0.5 - (0.5 * cos(phi1))));
double t_2 = fma(t_0, cos(phi2), (0.5 - (0.5 * cos((2.0 * (-0.5 * phi2))))));
double t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
double tmp;
if (phi2 <= -3.6e-6) {
tmp = t_3;
} else if (phi2 <= 4.8e-65) {
tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
} else {
tmp = t_3;
}
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(lambda1 - lambda2)))))) t_1 = fma(t_0, cos(phi1), Float64(0.5 - Float64(0.5 * cos(phi1)))) t_2 = fma(t_0, cos(phi2), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(-0.5 * phi2)))))) t_3 = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))) tmp = 0.0 if (phi2 <= -3.6e-6) tmp = t_3; elseif (phi2 <= 4.8e-65) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))); else tmp = t_3; 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[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[Cos[phi1], $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[Cos[phi2], $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(-0.5 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -3.6e-6], t$95$3, If[LessEqual[phi2, 4.8e-65], 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], t$95$3]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\\
t_1 := \mathsf{fma}\left(t\_0, \cos \phi_1, 0.5 - 0.5 \cdot \cos \phi_1\right)\\
t_2 := \mathsf{fma}\left(t\_0, \cos \phi_2, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(-0.5 \cdot \phi_2\right)\right)\right)\\
t_3 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{if}\;\phi_2 \leq -3.6 \cdot 10^{-6}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_2 \leq 4.8 \cdot 10^{-65}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if phi2 < -3.59999999999999984e-6 or 4.8000000000000003e-65 < phi2 Initial program 49.7%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.8%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites47.5%
if -3.59999999999999984e-6 < phi2 < 4.8000000000000003e-65Initial program 78.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.3%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites68.3%
Taylor expanded in phi1 around 0
Applied rewrites68.3%
Taylor expanded in phi1 around 0
Applied rewrites68.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(cos phi1)
(- 0.5 (* 0.5 (cos phi1)))))
(t_1 (* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0))))))
(t_2 (/ (- lambda1 lambda2) 2.0))
(t_3
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi2) (* -0.5 lambda2)) (* -0.5 lambda2)))))
(if (<= t_2 -0.0005)
t_1
(if (<= t_2 5e-6)
(* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- 1.0 t_3)))))
t_1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))), cos(phi1), (0.5 - (0.5 * cos(phi1))));
double t_1 = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
double t_2 = (lambda1 - lambda2) / 2.0;
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi2) * (-0.5 * lambda2)) * (-0.5 * lambda2));
double tmp;
if (t_2 <= -0.0005) {
tmp = t_1;
} else if (t_2 <= 5e-6) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3))));
} else {
tmp = t_1;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))), cos(phi1), Float64(0.5 - Float64(0.5 * cos(phi1)))) t_1 = Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))) t_2 = Float64(Float64(lambda1 - lambda2) / 2.0) t_3 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi2) * Float64(-0.5 * lambda2)) * Float64(-0.5 * lambda2))) tmp = 0.0 if (t_2 <= -0.0005) tmp = t_1; elseif (t_2 <= 5e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_3))))); else tmp = t_1; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * lambda2), $MachinePrecision]), $MachinePrecision] * N[(-0.5 * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.0005], t$95$1, If[LessEqual[t$95$2, 5e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), \cos \phi_1, 0.5 - 0.5 \cdot \cos \phi_1\right)\\
t_1 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)\\
t_2 := \frac{\lambda_1 - \lambda_2}{2}\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_2 \cdot \left(-0.5 \cdot \lambda_2\right)\right) \cdot \left(-0.5 \cdot \lambda_2\right)\\
\mathbf{if}\;t\_2 \leq -0.0005:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)) < -5.0000000000000001e-4 or 5.00000000000000041e-6 < (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)) Initial program 57.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.3%
Taylor expanded in phi1 around 0
Applied rewrites46.3%
Taylor expanded in phi1 around 0
Applied rewrites46.3%
if -5.0000000000000001e-4 < (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)) < 5.00000000000000041e-6Initial program 78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda1 around 0
lift-*.f6472.4
Applied rewrites72.4%
Taylor expanded in lambda1 around 0
lift-*.f6472.6
Applied rewrites72.6%
Taylor expanded in lambda1 around 0
lift-*.f6472.6
Applied rewrites72.6%
Taylor expanded in lambda1 around 0
lift-*.f6472.6
Applied rewrites72.6%
Taylor expanded in phi1 around 0
lift-cos.f6472.6
Applied rewrites72.6%
Taylor expanded in phi1 around 0
lift-cos.f6472.6
Applied rewrites72.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(-
(+ 0.5 (* (cos phi1) (- 0.5 (* 0.5 (cos (- lambda1 lambda2))))))
(* 0.5 (cos phi1))))
(t_1 (* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0))))))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi2) (* -0.5 lambda2)) (* -0.5 lambda2)))))
(if (<= t_2 -0.0005)
t_1
(if (<= t_2 5e-6)
(* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- 1.0 t_3)))))
t_1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (0.5 + (cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2)))))) - (0.5 * cos(phi1));
double t_1 = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi2) * (-0.5 * lambda2)) * (-0.5 * lambda2));
double tmp;
if (t_2 <= -0.0005) {
tmp = t_1;
} else if (t_2 <= 5e-6) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3))));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = (0.5d0 + (cos(phi1) * (0.5d0 - (0.5d0 * cos((lambda1 - lambda2)))))) - (0.5d0 * cos(phi1))
t_1 = r * (2.0d0 * atan2(sqrt(t_0), sqrt((1.0d0 - t_0))))
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((cos(phi2) * ((-0.5d0) * lambda2)) * ((-0.5d0) * lambda2))
if (t_2 <= (-0.0005d0)) then
tmp = t_1
else if (t_2 <= 5d-6) then
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - t_3))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (0.5 + (Math.cos(phi1) * (0.5 - (0.5 * Math.cos((lambda1 - lambda2)))))) - (0.5 * Math.cos(phi1));
double t_1 = R * (2.0 * Math.atan2(Math.sqrt(t_0), Math.sqrt((1.0 - t_0))));
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((Math.cos(phi2) * (-0.5 * lambda2)) * (-0.5 * lambda2));
double tmp;
if (t_2 <= -0.0005) {
tmp = t_1;
} else if (t_2 <= 5e-6) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - t_3))));
} else {
tmp = t_1;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (0.5 + (math.cos(phi1) * (0.5 - (0.5 * math.cos((lambda1 - lambda2)))))) - (0.5 * math.cos(phi1)) t_1 = R * (2.0 * math.atan2(math.sqrt(t_0), math.sqrt((1.0 - t_0)))) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((math.cos(phi2) * (-0.5 * lambda2)) * (-0.5 * lambda2)) tmp = 0 if t_2 <= -0.0005: tmp = t_1 elif t_2 <= 5e-6: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - t_3)))) else: tmp = t_1 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))))) - Float64(0.5 * cos(phi1))) t_1 = Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi2) * Float64(-0.5 * lambda2)) * Float64(-0.5 * lambda2))) tmp = 0.0 if (t_2 <= -0.0005) tmp = t_1; elseif (t_2 <= 5e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_3))))); else tmp = t_1; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (0.5 + (cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2)))))) - (0.5 * cos(phi1)); t_1 = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0)))); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((cos(phi2) * (-0.5 * lambda2)) * (-0.5 * lambda2)); tmp = 0.0; if (t_2 <= -0.0005) tmp = t_1; elseif (t_2 <= 5e-6) tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3)))); else tmp = t_1; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * lambda2), $MachinePrecision]), $MachinePrecision] * N[(-0.5 * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.0005], t$95$1, If[LessEqual[t$95$2, 5e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 + \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right) - 0.5 \cdot \cos \phi_1\\
t_1 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_2 \cdot \left(-0.5 \cdot \lambda_2\right)\right) \cdot \left(-0.5 \cdot \lambda_2\right)\\
\mathbf{if}\;t\_2 \leq -0.0005:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -5.0000000000000001e-4 or 5.00000000000000041e-6 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 57.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.3%
Taylor expanded in lambda1 around inf
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-cos.f6446.3
Applied rewrites46.3%
Taylor expanded in lambda1 around inf
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift-cos.f6446.2
Applied rewrites46.2%
if -5.0000000000000001e-4 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 5.00000000000000041e-6Initial program 78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda1 around 0
lift-*.f6472.4
Applied rewrites72.4%
Taylor expanded in lambda1 around 0
lift-*.f6472.6
Applied rewrites72.6%
Taylor expanded in lambda1 around 0
lift-*.f6472.6
Applied rewrites72.6%
Taylor expanded in lambda1 around 0
lift-*.f6472.6
Applied rewrites72.6%
Taylor expanded in phi1 around 0
lift-cos.f6472.6
Applied rewrites72.6%
Taylor expanded in phi1 around 0
lift-cos.f6472.6
Applied rewrites72.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi2) (* -0.5 lambda2)) (* -0.5 lambda2))))
(t_1 (/ (- lambda1 lambda2) 2.0))
(t_2
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi1)
(*
(cos phi2)
(pow (sin (* 0.5 (+ lambda1 (* -1.0 lambda2)))) 2.0))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(sqrt (- 1.0 (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))))))))))
(if (<= t_1 -0.0005)
t_2
(if (<= t_1 5e-6)
(* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))
t_2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi2) * (-0.5 * lambda2)) * (-0.5 * lambda2));
double t_1 = (lambda1 - lambda2) / 2.0;
double t_2 = R * (2.0 * atan2(sqrt(fma(cos(phi1), (cos(phi2) * pow(sin((0.5 * (lambda1 + (-1.0 * lambda2)))), 2.0)), (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt((1.0 - (0.5 - (0.5 * cos((lambda1 - lambda2))))))));
double tmp;
if (t_1 <= -0.0005) {
tmp = t_2;
} else if (t_1 <= 5e-6) {
tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
} else {
tmp = t_2;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi2) * Float64(-0.5 * lambda2)) * Float64(-0.5 * lambda2))) t_1 = Float64(Float64(lambda1 - lambda2) / 2.0) t_2 = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 + Float64(-1.0 * lambda2)))) ^ 2.0)), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), sqrt(Float64(1.0 - Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))))))) tmp = 0.0 if (t_1 <= -0.0005) tmp = t_2; elseif (t_1 <= 5e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))); else tmp = t_2; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * lambda2), $MachinePrecision]), $MachinePrecision] * N[(-0.5 * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 + N[(-1.0 * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $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[(1.0 - N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.0005], t$95$2, If[LessEqual[t$95$1, 5e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_2 \cdot \left(-0.5 \cdot \lambda_2\right)\right) \cdot \left(-0.5 \cdot \lambda_2\right)\\
t_1 := \frac{\lambda_1 - \lambda_2}{2}\\
t_2 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 + -1 \cdot \lambda_2\right)\right)}^{2}, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{\sqrt{1 - \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}}\right)\\
\mathbf{if}\;t\_1 \leq -0.0005:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)) < -5.0000000000000001e-4 or 5.00000000000000041e-6 < (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)) Initial program 57.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.3%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6433.3
Applied rewrites33.3%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6432.8
Applied rewrites32.8%
Taylor expanded in lambda2 around -inf
lower-sqrt.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites33.3%
if -5.0000000000000001e-4 < (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)) < 5.00000000000000041e-6Initial program 78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda1 around 0
lift-*.f6472.4
Applied rewrites72.4%
Taylor expanded in lambda1 around 0
lift-*.f6472.6
Applied rewrites72.6%
Taylor expanded in lambda1 around 0
lift-*.f6472.6
Applied rewrites72.6%
Taylor expanded in lambda1 around 0
lift-*.f6472.6
Applied rewrites72.6%
Taylor expanded in phi1 around 0
lift-cos.f6472.6
Applied rewrites72.6%
Taylor expanded in phi1 around 0
lift-cos.f6472.6
Applied rewrites72.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (/ (- lambda1 lambda2) 2.0))
(t_1
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi1)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 phi1)))))))
(sqrt (- 1.0 (- 0.5 (* 0.5 (cos (- lambda1 lambda2))))))))))
(t_2
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi2) (* -0.5 lambda2)) (* -0.5 lambda2)))))
(if (<= t_0 -0.0005)
t_1
(if (<= t_0 5e-6)
(* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))
t_1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) / 2.0;
double t_1 = R * (2.0 * atan2(sqrt(fma(cos(phi1), (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))), (0.5 - (0.5 * cos((2.0 * (0.5 * phi1))))))), sqrt((1.0 - (0.5 - (0.5 * cos((lambda1 - lambda2))))))));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi2) * (-0.5 * lambda2)) * (-0.5 * lambda2));
double tmp;
if (t_0 <= -0.0005) {
tmp = t_1;
} else if (t_0 <= 5e-6) {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
} else {
tmp = t_1;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) / 2.0) t_1 = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), 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 * phi1))))))), sqrt(Float64(1.0 - Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))))))) t_2 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi2) * Float64(-0.5 * lambda2)) * Float64(-0.5 * lambda2))) tmp = 0.0 if (t_0 <= -0.0005) tmp = t_1; elseif (t_0 <= 5e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))); else tmp = t_1; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * lambda2), $MachinePrecision]), $MachinePrecision] * N[(-0.5 * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.0005], t$95$1, If[LessEqual[t$95$0, 5e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\lambda_1 - \lambda_2}{2}\\
t_1 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \phi_1\right)\right)\right)}}{\sqrt{1 - \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_2 \cdot \left(-0.5 \cdot \lambda_2\right)\right) \cdot \left(-0.5 \cdot \lambda_2\right)\\
\mathbf{if}\;t\_0 \leq -0.0005:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)) < -5.0000000000000001e-4 or 5.00000000000000041e-6 < (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)) Initial program 57.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.3%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6433.3
Applied rewrites33.3%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6432.8
Applied rewrites32.8%
Taylor expanded in phi2 around 0
lower-sqrt.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites33.4%
if -5.0000000000000001e-4 < (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)) < 5.00000000000000041e-6Initial program 78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6478.1
Applied rewrites78.1%
Taylor expanded in lambda1 around 0
lift-*.f6472.4
Applied rewrites72.4%
Taylor expanded in lambda1 around 0
lift-*.f6472.6
Applied rewrites72.6%
Taylor expanded in lambda1 around 0
lift-*.f6472.6
Applied rewrites72.6%
Taylor expanded in lambda1 around 0
lift-*.f6472.6
Applied rewrites72.6%
Taylor expanded in phi1 around 0
lift-cos.f6472.6
Applied rewrites72.6%
Taylor expanded in phi1 around 0
lift-cos.f6472.6
Applied rewrites72.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(- 0.5 (* 0.5 (cos lambda1)))
1.0
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 phi1))))))))
(if (<= phi1 2.7e+137)
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi2)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(pow (sin (* -0.5 phi2)) 2.0)))
(sqrt (- 1.0 (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))))))))
(* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma((0.5 - (0.5 * cos(lambda1))), 1.0, (0.5 - (0.5 * cos((2.0 * (0.5 * phi1))))));
double tmp;
if (phi1 <= 2.7e+137) {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi2), (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))), pow(sin((-0.5 * phi2)), 2.0))), sqrt((1.0 - (0.5 - (0.5 * cos((lambda1 - lambda2))))))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(Float64(0.5 - Float64(0.5 * cos(lambda1))), 1.0, Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * phi1)))))) tmp = 0.0 if (phi1 <= 2.7e+137) tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi2), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))), (sin(Float64(-0.5 * phi2)) ^ 2.0))), sqrt(Float64(1.0 - Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(0.5 - N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0 + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, 2.7e+137], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[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] + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \lambda_1, 1, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \phi_1\right)\right)\right)\\
\mathbf{if}\;\phi_1 \leq 2.7 \cdot 10^{+137}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)}}{\sqrt{1 - \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)\\
\end{array}
\end{array}
if phi1 < 2.70000000000000017e137Initial program 64.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites41.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites41.9%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6428.2
Applied rewrites28.2%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6427.9
Applied rewrites27.9%
Taylor expanded in phi1 around 0
unpow2N/A
sqr-sin-a-revN/A
lower-sqrt.f64N/A
Applied rewrites32.5%
if 2.70000000000000017e137 < phi1 Initial program 48.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites49.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites49.8%
Taylor expanded in lambda1 around inf
Applied rewrites40.6%
Taylor expanded in lambda1 around inf
Applied rewrites40.2%
Taylor expanded in phi1 around 0
Applied rewrites29.9%
Taylor expanded in phi1 around 0
Applied rewrites24.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi1)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 phi1)))))))
(sqrt (- 1.0 (- 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), (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))), (0.5 - (0.5 * cos((2.0 * (0.5 * phi1))))))), sqrt((1.0 - (0.5 - (0.5 * cos((lambda1 - lambda2))))))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), 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 * phi1))))))), sqrt(Float64(1.0 - Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \phi_1\right)\right)\right)}}{\sqrt{1 - \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}}\right)
\end{array}
Initial program 62.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.9%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6426.7
Applied rewrites26.7%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6426.3
Applied rewrites26.3%
Taylor expanded in phi2 around 0
lower-sqrt.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-fma.f64N/A
Applied rewrites28.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))))) (* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * cos((lambda1 - lambda2)));
return R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 = 0.5d0 - (0.5d0 * cos((lambda1 - lambda2)))
code = r * (2.0d0 * atan2(sqrt(t_0), sqrt((1.0d0 - t_0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * Math.cos((lambda1 - lambda2)));
return R * (2.0 * Math.atan2(Math.sqrt(t_0), Math.sqrt((1.0 - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 0.5 - (0.5 * math.cos((lambda1 - lambda2))) return R * (2.0 * math.atan2(math.sqrt(t_0), math.sqrt((1.0 - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))) return Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = 0.5 - (0.5 * cos((lambda1 - lambda2))); tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 62.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.9%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6426.7
Applied rewrites26.7%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6426.3
Applied rewrites26.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- 0.5 (* 0.5 (cos lambda1))))
(t_1 (- 0.5 (* 0.5 (cos lambda2))))
(t_2 (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
(if (<= lambda2 -1.7e-6)
t_2
(if (<= lambda2 4.6e+14)
(* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))
t_2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * cos(lambda1));
double t_1 = 0.5 - (0.5 * cos(lambda2));
double t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
double tmp;
if (lambda2 <= -1.7e-6) {
tmp = t_2;
} else if (lambda2 <= 4.6e+14) {
tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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
real(8) :: t_2
real(8) :: tmp
t_0 = 0.5d0 - (0.5d0 * cos(lambda1))
t_1 = 0.5d0 - (0.5d0 * cos(lambda2))
t_2 = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
if (lambda2 <= (-1.7d-6)) then
tmp = t_2
else if (lambda2 <= 4.6d+14) then
tmp = r * (2.0d0 * atan2(sqrt(t_0), sqrt((1.0d0 - t_0))))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * Math.cos(lambda1));
double t_1 = 0.5 - (0.5 * Math.cos(lambda2));
double t_2 = R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
double tmp;
if (lambda2 <= -1.7e-6) {
tmp = t_2;
} else if (lambda2 <= 4.6e+14) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_0), Math.sqrt((1.0 - t_0))));
} else {
tmp = t_2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 0.5 - (0.5 * math.cos(lambda1)) t_1 = 0.5 - (0.5 * math.cos(lambda2)) t_2 = R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1)))) tmp = 0 if lambda2 <= -1.7e-6: tmp = t_2 elif lambda2 <= 4.6e+14: tmp = R * (2.0 * math.atan2(math.sqrt(t_0), math.sqrt((1.0 - t_0)))) else: tmp = t_2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 - Float64(0.5 * cos(lambda1))) t_1 = Float64(0.5 - Float64(0.5 * cos(lambda2))) t_2 = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) tmp = 0.0 if (lambda2 <= -1.7e-6) tmp = t_2; elseif (lambda2 <= 4.6e+14) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))); else tmp = t_2; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = 0.5 - (0.5 * cos(lambda1)); t_1 = 0.5 - (0.5 * cos(lambda2)); t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); tmp = 0.0; if (lambda2 <= -1.7e-6) tmp = t_2; elseif (lambda2 <= 4.6e+14) tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0)))); else tmp = t_2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 - N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 - N[(0.5 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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]}, If[LessEqual[lambda2, -1.7e-6], t$95$2, If[LessEqual[lambda2, 4.6e+14], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 - 0.5 \cdot \cos \lambda_1\\
t_1 := 0.5 - 0.5 \cdot \cos \lambda_2\\
t_2 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{if}\;\lambda_2 \leq -1.7 \cdot 10^{-6}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_2 \leq 4.6 \cdot 10^{+14}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda2 < -1.70000000000000003e-6 or 4.6e14 < lambda2 Initial program 46.9%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites38.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites39.1%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6429.2
Applied rewrites29.2%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6428.8
Applied rewrites28.8%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6428.8
Applied rewrites28.8%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6428.7
Applied rewrites28.7%
if -1.70000000000000003e-6 < lambda2 < 4.6e14Initial program 76.9%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.5%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6424.3
Applied rewrites24.3%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6424.0
Applied rewrites24.0%
Taylor expanded in lambda1 around inf
Applied rewrites23.4%
Taylor expanded in lambda1 around inf
Applied rewrites23.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (- 0.5 (* 0.5 (cos lambda2))))) (* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * cos(lambda2));
return R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 = 0.5d0 - (0.5d0 * cos(lambda2))
code = r * (2.0d0 * atan2(sqrt(t_0), sqrt((1.0d0 - t_0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * Math.cos(lambda2));
return R * (2.0 * Math.atan2(Math.sqrt(t_0), Math.sqrt((1.0 - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 0.5 - (0.5 * math.cos(lambda2)) return R * (2.0 * math.atan2(math.sqrt(t_0), math.sqrt((1.0 - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 - Float64(0.5 * cos(lambda2))) return Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = 0.5 - (0.5 * cos(lambda2)); tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 - N[(0.5 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 - 0.5 \cdot \cos \lambda_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 62.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.9%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6426.7
Applied rewrites26.7%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6426.3
Applied rewrites26.3%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6416.8
Applied rewrites16.8%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6416.7
Applied rewrites16.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (- 0.5 (* 0.5 1.0)))) (* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * 1.0);
return R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 = 0.5d0 - (0.5d0 * 1.0d0)
code = r * (2.0d0 * atan2(sqrt(t_0), sqrt((1.0d0 - t_0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (0.5 * 1.0);
return R * (2.0 * Math.atan2(Math.sqrt(t_0), Math.sqrt((1.0 - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 0.5 - (0.5 * 1.0) return R * (2.0 * math.atan2(math.sqrt(t_0), math.sqrt((1.0 - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 - Float64(0.5 * 1.0)) return Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = 0.5 - (0.5 * 1.0); tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 - N[(0.5 * 1.0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 - 0.5 \cdot 1\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 62.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.9%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6426.7
Applied rewrites26.7%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6426.3
Applied rewrites26.3%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6416.8
Applied rewrites16.8%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6416.7
Applied rewrites16.7%
Taylor expanded in lambda2 around 0
Applied rewrites4.4%
Taylor expanded in lambda2 around 0
Applied rewrites4.4%
herbie shell --seed 2025120
(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))))))))))