
(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 33 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 phi1) (cos phi2)))
(t_1
(* (cos phi2) (pow (sin (* 0.5 (+ lambda1 (* -1.0 lambda2)))) 2.0)))
(t_2
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0)))))
(t_3 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* t_0 t_2) t_2)))
(t_4
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* 0.5 phi1)))
(* (cos (* 0.5 phi1)) (sin (* 0.5 phi2))))
2.0))
(t_5 (sin (/ (- lambda1 lambda2) 2.0)))
(t_6
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* (* t_0 t_5) t_5))))
(if (<= phi1 -4.1e+23)
(*
R
(*
2.0
(atan2
(sqrt (fma (cos phi1) t_1 t_4))
(sqrt
(-
1.0
(fma
(fma (sin phi1) (cos (/ PI 2.0)) (* (cos phi1) (sin (/ PI 2.0))))
t_1
t_4))))))
(if (<= phi1 2.5e-16)
(* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- 1.0 t_3)))))
(* 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 = cos(phi1) * cos(phi2);
double t_1 = cos(phi2) * pow(sin((0.5 * (lambda1 + (-1.0 * lambda2)))), 2.0);
double t_2 = (sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)));
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_0 * t_2) * t_2);
double t_4 = pow(((cos((0.5 * phi2)) * sin((0.5 * phi1))) - (cos((0.5 * phi1)) * sin((0.5 * phi2)))), 2.0);
double t_5 = sin(((lambda1 - lambda2) / 2.0));
double t_6 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + ((t_0 * t_5) * t_5);
double tmp;
if (phi1 <= -4.1e+23) {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi1), t_1, t_4)), sqrt((1.0 - fma(fma(sin(phi1), cos((((double) M_PI) / 2.0)), (cos(phi1) * sin((((double) M_PI) / 2.0)))), t_1, t_4)))));
} else if (phi1 <= 2.5e-16) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3))));
} 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 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 + Float64(-1.0 * lambda2)))) ^ 2.0)) t_2 = Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) t_3 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(t_0 * t_2) * t_2)) t_4 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(0.5 * phi1))) - Float64(cos(Float64(0.5 * phi1)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_5 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_6 = Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(Float64(t_0 * t_5) * t_5)) tmp = 0.0 if (phi1 <= -4.1e+23) tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), t_1, t_4)), sqrt(Float64(1.0 - fma(fma(sin(phi1), cos(Float64(pi / 2.0)), Float64(cos(phi1) * sin(Float64(pi / 2.0)))), t_1, t_4)))))); elseif (phi1 <= 2.5e-16) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_3))))); 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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, Block[{t$95$2 = N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $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[(t$95$0 * t$95$2), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(t$95$0 * t$95$5), $MachinePrecision] * t$95$5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -4.1e+23], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(Pi / 2.0), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Sin[N[(Pi / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1 + t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.5e-16], 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], 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 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 + -1 \cdot \lambda_2\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(t\_0 \cdot t\_2\right) \cdot t\_2\\
t_4 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_5 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_6 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + \left(t\_0 \cdot t\_5\right) \cdot t\_5\\
\mathbf{if}\;\phi_1 \leq -4.1 \cdot 10^{+23}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_1, t\_4\right)}}{\sqrt{1 - \mathsf{fma}\left(\mathsf{fma}\left(\sin \phi_1, \cos \left(\frac{\pi}{2}\right), \cos \phi_1 \cdot \sin \left(\frac{\pi}{2}\right)\right), t\_1, t\_4\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 2.5 \cdot 10^{-16}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_6}}{\sqrt{1 - t\_6}}\right)\\
\end{array}
\end{array}
if phi1 < -4.09999999999999996e23Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in lambda2 around -inf
Applied rewrites77.9%
Taylor expanded in lambda2 around -inf
Applied rewrites77.9%
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sumN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower-sin.f6477.9
Applied rewrites77.9%
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sumN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower-sin.f6477.9
Applied rewrites77.9%
sin-+PI/2-rev77.9
Applied rewrites77.9%
if -4.09999999999999996e23 < phi1 < 2.5000000000000002e-16Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6460.7
Applied rewrites60.7%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.1
Applied rewrites62.1%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6461.9
Applied rewrites61.9%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6476.9
Applied rewrites76.9%
if 2.5000000000000002e-16 < phi1 Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* 0.5 phi1)))
(* (cos (* 0.5 phi1)) (sin (* 0.5 phi2))))
2.0))
(t_1
(* (cos phi2) (pow (sin (* 0.5 (+ lambda1 (* -1.0 lambda2)))) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (fma (cos phi1) t_1 t_0))
(sqrt
(-
1.0
(fma
(fma (sin phi1) (cos (/ PI 2.0)) (* (cos phi1) (sin (/ PI 2.0))))
t_1
t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((0.5 * phi1))) - (cos((0.5 * phi1)) * sin((0.5 * phi2)))), 2.0);
double t_1 = cos(phi2) * pow(sin((0.5 * (lambda1 + (-1.0 * lambda2)))), 2.0);
return R * (2.0 * atan2(sqrt(fma(cos(phi1), t_1, t_0)), sqrt((1.0 - fma(fma(sin(phi1), cos((((double) M_PI) / 2.0)), (cos(phi1) * sin((((double) M_PI) / 2.0)))), t_1, t_0)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(0.5 * phi1))) - Float64(cos(Float64(0.5 * phi1)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_1 = Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 + Float64(-1.0 * lambda2)))) ^ 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), t_1, t_0)), sqrt(Float64(1.0 - fma(fma(sin(phi1), cos(Float64(pi / 2.0)), Float64(cos(phi1) * sin(Float64(pi / 2.0)))), t_1, t_0)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = 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[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(Pi / 2.0), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Sin[N[(Pi / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1 + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_1 := \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 + -1 \cdot \lambda_2\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_1, t\_0\right)}}{\sqrt{1 - \mathsf{fma}\left(\mathsf{fma}\left(\sin \phi_1, \cos \left(\frac{\pi}{2}\right), \cos \phi_1 \cdot \sin \left(\frac{\pi}{2}\right)\right), t\_1, t\_0\right)}}\right)
\end{array}
\end{array}
Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in lambda2 around -inf
Applied rewrites77.9%
Taylor expanded in lambda2 around -inf
Applied rewrites77.9%
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sumN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower-sin.f6477.9
Applied rewrites77.9%
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sumN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower-sin.f6477.9
Applied rewrites77.9%
sin-+PI/2-rev77.9
Applied rewrites77.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 (+ lambda1 (* -1.0 lambda2)))) 2.0))
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* 0.5 phi1)))
(* (cos (* 0.5 phi1)) (sin (* 0.5 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(sin((0.5 * (lambda1 + (-1.0 * lambda2)))), 2.0)), pow(((cos((0.5 * phi2)) * sin((0.5 * phi1))) - (cos((0.5 * phi1)) * sin((0.5 * 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) * (sin(Float64(0.5 * Float64(lambda1 + Float64(-1.0 * lambda2)))) ^ 2.0)), (Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(0.5 * phi1))) - Float64(cos(Float64(0.5 * phi1)) * sin(Float64(0.5 * 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[Sin[N[(0.5 * N[(lambda1 + N[(-1.0 * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * 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 {\sin \left(0.5 \cdot \left(\lambda_1 + -1 \cdot \lambda_2\right)\right)}^{2}, {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \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 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in lambda2 around -inf
Applied rewrites77.9%
Taylor expanded in lambda2 around -inf
Applied rewrites77.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_1
(+ t_0 (* (cos phi1) (* (cos phi2) (- 0.5 (* 0.5 (cos lambda2)))))))
(t_2
(+ t_0 (* (cos phi1) (* (cos phi2) (- 0.5 (* 0.5 (cos lambda1)))))))
(t_3 (* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))))
(if (<= lambda1 -7500000.0)
t_3
(if (<= lambda1 3.65e-6)
(* 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(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_1 = t_0 + (cos(phi1) * (cos(phi2) * (0.5 - (0.5 * cos(lambda2)))));
double t_2 = t_0 + (cos(phi1) * (cos(phi2) * (0.5 - (0.5 * cos(lambda1)))));
double t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
double tmp;
if (lambda1 <= -7500000.0) {
tmp = t_3;
} else if (lambda1 <= 3.65e-6) {
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 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_1 = t_0 + (cos(phi1) * (cos(phi2) * (0.5d0 - (0.5d0 * cos(lambda2)))))
t_2 = t_0 + (cos(phi1) * (cos(phi2) * (0.5d0 - (0.5d0 * cos(lambda1)))))
t_3 = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 - t_2))))
if (lambda1 <= (-7500000.0d0)) then
tmp = t_3
else if (lambda1 <= 3.65d-6) 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 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_1 = t_0 + (Math.cos(phi1) * (Math.cos(phi2) * (0.5 - (0.5 * Math.cos(lambda2)))));
double t_2 = t_0 + (Math.cos(phi1) * (Math.cos(phi2) * (0.5 - (0.5 * Math.cos(lambda1)))));
double t_3 = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 - t_2))));
double tmp;
if (lambda1 <= -7500000.0) {
tmp = t_3;
} else if (lambda1 <= 3.65e-6) {
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 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_1 = t_0 + (math.cos(phi1) * (math.cos(phi2) * (0.5 - (0.5 * math.cos(lambda2))))) t_2 = t_0 + (math.cos(phi1) * (math.cos(phi2) * (0.5 - (0.5 * math.cos(lambda1))))) t_3 = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 - t_2)))) tmp = 0 if lambda1 <= -7500000.0: tmp = t_3 elif lambda1 <= 3.65e-6: 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(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(lambda2)))))) t_2 = Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(lambda1)))))) t_3 = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))) tmp = 0.0 if (lambda1 <= -7500000.0) tmp = t_3; elseif (lambda1 <= 3.65e-6) 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 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_1 = t_0 + (cos(phi1) * (cos(phi2) * (0.5 - (0.5 * cos(lambda2))))); t_2 = t_0 + (cos(phi1) * (cos(phi2) * (0.5 - (0.5 * cos(lambda1))))); t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2)))); tmp = 0.0; if (lambda1 <= -7500000.0) tmp = t_3; elseif (lambda1 <= 3.65e-6) 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[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[lambda1], $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[lambda1, -7500000.0], t$95$3, If[LessEqual[lambda1, 3.65e-6], 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(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_1 := t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \lambda_2\right)\right)\\
t_2 := t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \lambda_1\right)\right)\\
t_3 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{if}\;\lambda_1 \leq -7500000:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\lambda_1 \leq 3.65 \cdot 10^{-6}:\\
\;\;\;\;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 lambda1 < -7.5e6 or 3.65000000000000021e-6 < lambda1 Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6475.3
Applied rewrites75.3%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6475.4
Applied rewrites75.4%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6455.7
Applied rewrites55.7%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6455.3
Applied rewrites55.3%
if -7.5e6 < lambda1 < 3.65000000000000021e-6Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6475.3
Applied rewrites75.3%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6475.4
Applied rewrites75.4%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6455.6
Applied rewrites55.6%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6455.2
Applied rewrites55.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(cos phi1)
(*
(cos phi2)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))))))
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* 0.5 phi1)))
(* (cos (* 0.5 phi1)) (sin (* 0.5 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) * (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2))))))), pow(((cos((0.5 * phi2)) * sin((0.5 * phi1))) - (cos((0.5 * phi1)) * sin((0.5 * 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) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2))))))), (Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(0.5 * phi1))) - Float64(cos(Float64(0.5 * phi1)) * sin(Float64(0.5 * 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[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * 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(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right), {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \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 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in lambda1 around inf
Applied rewrites75.3%
Taylor expanded in lambda1 around inf
Applied rewrites75.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(*
(cos phi1)
(* (cos phi2) (- 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 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (cos(phi1) * (cos(phi2) * (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 = (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + (cos(phi1) * (cos(phi2) * (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 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + (Math.cos(phi1) * (Math.cos(phi2) * (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 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + (math.cos(phi1) * (math.cos(phi2) * (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((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(cos(phi1) * Float64(cos(phi2) * 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 = (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + (cos(phi1) * (cos(phi2) * (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[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $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 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6475.3
Applied rewrites75.3%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6475.4
Applied rewrites75.4%
Taylor expanded in lambda1 around 0
lift--.f6475.4
Applied rewrites75.4%
Taylor expanded in lambda1 around 0
lift--.f6475.4
Applied rewrites75.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (* (cos phi1) (cos phi2)) t_0) t_0))
(t_2
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_3
(+ t_2 (* (cos phi1) (* (cos phi2) (- 0.5 (* 0.5 (cos lambda1))))))))
(if (<= lambda2 -0.38)
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (pow (sin (* -0.5 lambda2)) 2.0))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
(sqrt
(-
1.0
(fma
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 (+ lambda1 (* -1.0 lambda2)))) 2.0))
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* 0.5 phi1)))
(* (cos (* 0.5 phi1)) (sin (* 0.5 phi2))))
2.0)))))))
(if (<= lambda2 4.5e-8)
(* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- 1.0 t_3)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 t_1))
(sqrt (- 1.0 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.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 = ((cos(phi1) * cos(phi2)) * t_0) * t_0;
double t_2 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_3 = t_2 + (cos(phi1) * (cos(phi2) * (0.5 - (0.5 * cos(lambda1)))));
double tmp;
if (lambda2 <= -0.38) {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi1), (cos(phi2) * pow(sin((-0.5 * lambda2)), 2.0)), pow(sin((0.5 * (phi1 - phi2))), 2.0))), sqrt((1.0 - fma(cos(phi1), (cos(phi2) * pow(sin((0.5 * (lambda1 + (-1.0 * lambda2)))), 2.0)), pow(((cos((0.5 * phi2)) * sin((0.5 * phi1))) - (cos((0.5 * phi1)) * sin((0.5 * phi2)))), 2.0))))));
} else if (lambda2 <= 4.5e-8) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + t_1)), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0) t_2 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_3 = Float64(t_2 + Float64(cos(phi1) * Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(lambda1)))))) tmp = 0.0 if (lambda2 <= -0.38) tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * (sin(Float64(-0.5 * lambda2)) ^ 2.0)), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))), sqrt(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 + Float64(-1.0 * lambda2)))) ^ 2.0)), (Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(0.5 * phi1))) - Float64(cos(Float64(0.5 * phi1)) * sin(Float64(0.5 * phi2)))) ^ 2.0))))))); elseif (lambda2 <= 4.5e-8) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + t_1)), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)))))); 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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -0.38], 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 * lambda2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - 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[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 4.5e-8], 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], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $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 := \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
t_2 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_3 := t\_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \lambda_1\right)\right)\\
\mathbf{if}\;\lambda_2 \leq -0.38:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \lambda_2\right)}^{2}, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}{\sqrt{1 - \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}, {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(0.5 \cdot \phi_1\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right)\\
\mathbf{elif}\;\lambda_2 \leq 4.5 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + t\_1}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -0.38Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in lambda2 around -inf
Applied rewrites77.9%
Taylor expanded in lambda2 around -inf
Applied rewrites77.9%
Taylor expanded in lambda1 around 0
Applied rewrites46.8%
if -0.38 < lambda2 < 4.49999999999999993e-8Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6475.3
Applied rewrites75.3%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6475.4
Applied rewrites75.4%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6455.7
Applied rewrites55.7%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6455.3
Applied rewrites55.3%
if 4.49999999999999993e-8 < lambda2 Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Applied rewrites62.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_1 (/ (- lambda1 lambda2) 2.0))
(t_2 (sin t_1))
(t_3 (* (* (* (cos phi1) (cos phi2)) t_2) t_2))
(t_4 (+ t_0 t_3))
(t_5 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_3))
(t_6 (+ t_0 (* (cos phi1) (- 0.5 (* 0.5 (cos (- lambda1 lambda2))))))))
(if (<= t_1 -2e-9)
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- 1.0 t_5)))))
(if (<= t_1 20000000000.0)
(* R (* 2.0 (atan2 (sqrt t_6) (sqrt (- 1.0 t_6)))))
(* R (* 2.0 (atan2 (sqrt t_5) (sqrt (- 1.0 t_4)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_1 = (lambda1 - lambda2) / 2.0;
double t_2 = sin(t_1);
double t_3 = ((cos(phi1) * cos(phi2)) * t_2) * t_2;
double t_4 = t_0 + t_3;
double t_5 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_3;
double t_6 = t_0 + (cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2)))));
double tmp;
if (t_1 <= -2e-9) {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_5))));
} else if (t_1 <= 20000000000.0) {
tmp = R * (2.0 * atan2(sqrt(t_6), sqrt((1.0 - t_6))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_4))));
}
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) :: t_6
real(8) :: tmp
t_0 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_1 = (lambda1 - lambda2) / 2.0d0
t_2 = sin(t_1)
t_3 = ((cos(phi1) * cos(phi2)) * t_2) * t_2
t_4 = t_0 + t_3
t_5 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_3
t_6 = t_0 + (cos(phi1) * (0.5d0 - (0.5d0 * cos((lambda1 - lambda2)))))
if (t_1 <= (-2d-9)) then
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - t_5))))
else if (t_1 <= 20000000000.0d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_6), sqrt((1.0d0 - t_6))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_5), sqrt((1.0d0 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_1 = (lambda1 - lambda2) / 2.0;
double t_2 = Math.sin(t_1);
double t_3 = ((Math.cos(phi1) * Math.cos(phi2)) * t_2) * t_2;
double t_4 = t_0 + t_3;
double t_5 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_3;
double t_6 = t_0 + (Math.cos(phi1) * (0.5 - (0.5 * Math.cos((lambda1 - lambda2)))));
double tmp;
if (t_1 <= -2e-9) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - t_5))));
} else if (t_1 <= 20000000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_6), Math.sqrt((1.0 - t_6))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_5), Math.sqrt((1.0 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_1 = (lambda1 - lambda2) / 2.0 t_2 = math.sin(t_1) t_3 = ((math.cos(phi1) * math.cos(phi2)) * t_2) * t_2 t_4 = t_0 + t_3 t_5 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_3 t_6 = t_0 + (math.cos(phi1) * (0.5 - (0.5 * math.cos((lambda1 - lambda2))))) tmp = 0 if t_1 <= -2e-9: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - t_5)))) elif t_1 <= 20000000000.0: tmp = R * (2.0 * math.atan2(math.sqrt(t_6), math.sqrt((1.0 - t_6)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_5), math.sqrt((1.0 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = Float64(Float64(lambda1 - lambda2) / 2.0) t_2 = sin(t_1) t_3 = Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_2) * t_2) t_4 = Float64(t_0 + t_3) t_5 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_3) t_6 = Float64(t_0 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))))) tmp = 0.0 if (t_1 <= -2e-9) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - t_5))))); elseif (t_1 <= 20000000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_6), sqrt(Float64(1.0 - t_6))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_5), sqrt(Float64(1.0 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_1 = (lambda1 - lambda2) / 2.0; t_2 = sin(t_1); t_3 = ((cos(phi1) * cos(phi2)) * t_2) * t_2; t_4 = t_0 + t_3; t_5 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_3; t_6 = t_0 + (cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2))))); tmp = 0.0; if (t_1 <= -2e-9) tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_5)))); elseif (t_1 <= 20000000000.0) tmp = R * (2.0 * atan2(sqrt(t_6), sqrt((1.0 - t_6)))); else tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_4)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$2 = N[Sin[t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$0 + t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-9], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 20000000000.0], 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], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_1 := \frac{\lambda_1 - \lambda_2}{2}\\
t_2 := \sin t\_1\\
t_3 := \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right) \cdot t\_2\\
t_4 := t\_0 + t\_3\\
t_5 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_3\\
t_6 := t\_0 + \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - t\_5}}\right)\\
\mathbf{elif}\;t\_1 \leq 20000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_6}}{\sqrt{1 - t\_6}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5}}{\sqrt{1 - t\_4}}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)) < -2.00000000000000012e-9Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Applied rewrites62.6%
if -2.00000000000000012e-9 < (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)) < 2e10Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6475.3
Applied rewrites75.3%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6475.4
Applied rewrites75.4%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6456.5
Applied rewrites56.5%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6453.5
Applied rewrites53.5%
if 2e10 < (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)) Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Applied rewrites62.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_1
(+
t_0
(*
(cos phi2)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))))))))
(t_2 (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1))))))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* (* (* (cos phi1) (cos phi2)) t_3) t_3)))
(if (<= phi2 -4.5e+16)
t_2
(if (<= phi2 1.65e-7)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_4))
(sqrt (- 1.0 (+ t_0 t_4))))))
t_2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_1 = t_0 + (cos(phi2) * (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))));
double t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = ((cos(phi1) * cos(phi2)) * t_3) * t_3;
double tmp;
if (phi2 <= -4.5e+16) {
tmp = t_2;
} else if (phi2 <= 1.65e-7) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_4)), sqrt((1.0 - (t_0 + t_4)))));
} 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) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_1 = t_0 + (cos(phi2) * (0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * (lambda1 - lambda2)))))))
t_2 = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = ((cos(phi1) * cos(phi2)) * t_3) * t_3
if (phi2 <= (-4.5d+16)) then
tmp = t_2
else if (phi2 <= 1.65d-7) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_4)), sqrt((1.0d0 - (t_0 + t_4)))))
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 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_1 = t_0 + (Math.cos(phi2) * (0.5 - (0.5 * Math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))));
double t_2 = R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = ((Math.cos(phi1) * Math.cos(phi2)) * t_3) * t_3;
double tmp;
if (phi2 <= -4.5e+16) {
tmp = t_2;
} else if (phi2 <= 1.65e-7) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_4)), Math.sqrt((1.0 - (t_0 + t_4)))));
} else {
tmp = t_2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_1 = t_0 + (math.cos(phi2) * (0.5 - (0.5 * math.cos((2.0 * (0.5 * (lambda1 - lambda2))))))) t_2 = R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1)))) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = ((math.cos(phi1) * math.cos(phi2)) * t_3) * t_3 tmp = 0 if phi2 <= -4.5e+16: tmp = t_2 elif phi2 <= 1.65e-7: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_4)), math.sqrt((1.0 - (t_0 + t_4))))) else: tmp = t_2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = Float64(t_0 + Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))))) t_2 = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_3) * t_3) tmp = 0.0 if (phi2 <= -4.5e+16) tmp = t_2; elseif (phi2 <= 1.65e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_4)), sqrt(Float64(1.0 - Float64(t_0 + t_4)))))); else tmp = t_2; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_1 = t_0 + (cos(phi2) * (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2))))))); t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = ((cos(phi1) * cos(phi2)) * t_3) * t_3; tmp = 0.0; if (phi2 <= -4.5e+16) tmp = t_2; elseif (phi2 <= 1.65e-7) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_4)), sqrt((1.0 - (t_0 + t_4))))); else tmp = t_2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision] * t$95$3), $MachinePrecision]}, If[LessEqual[phi2, -4.5e+16], t$95$2, If[LessEqual[phi2, 1.65e-7], 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] + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_1 := t\_0 + \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\\
t_2 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_3\right) \cdot t\_3\\
\mathbf{if}\;\phi_2 \leq -4.5 \cdot 10^{+16}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_2 \leq 1.65 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_4}}{\sqrt{1 - \left(t\_0 + t\_4\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi2 < -4.5e16 or 1.6500000000000001e-7 < phi2 Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in phi1 around 0
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6455.8
Applied rewrites55.8%
Taylor expanded in phi1 around 0
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6452.4
Applied rewrites52.4%
if -4.5e16 < phi2 < 1.6500000000000001e-7Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Applied rewrites62.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (/ (- phi1 phi2) 2.0))
(t_1 (/ (- lambda1 lambda2) 2.0))
(t_2
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(*
(cos phi2)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))))))))
(t_3 (* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2))))))
(t_4 (sin t_1)))
(if (<= phi2 -3.1e+16)
t_3
(if (<= phi2 1.65e-7)
(*
R
(*
2.0
(atan2
(sqrt
(+ (pow (sin t_0) 2.0) (* (* (* (cos phi1) (cos phi2)) t_4) t_4)))
(sqrt
(-
(- 1.0 (- 0.5 (* 0.5 (cos (* 2.0 t_0)))))
(*
(* (cos phi2) (cos phi1))
(- 0.5 (* 0.5 (cos (* 2.0 t_1))))))))))
t_3))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (phi1 - phi2) / 2.0;
double t_1 = (lambda1 - lambda2) / 2.0;
double t_2 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (cos(phi2) * (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))));
double t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
double t_4 = sin(t_1);
double tmp;
if (phi2 <= -3.1e+16) {
tmp = t_3;
} else if (phi2 <= 1.65e-7) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(t_0), 2.0) + (((cos(phi1) * cos(phi2)) * t_4) * t_4))), sqrt(((1.0 - (0.5 - (0.5 * cos((2.0 * t_0))))) - ((cos(phi2) * cos(phi1)) * (0.5 - (0.5 * cos((2.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) :: t_4
real(8) :: tmp
t_0 = (phi1 - phi2) / 2.0d0
t_1 = (lambda1 - lambda2) / 2.0d0
t_2 = (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + (cos(phi2) * (0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * (lambda1 - lambda2)))))))
t_3 = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 - t_2))))
t_4 = sin(t_1)
if (phi2 <= (-3.1d+16)) then
tmp = t_3
else if (phi2 <= 1.65d-7) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(t_0) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_4) * t_4))), sqrt(((1.0d0 - (0.5d0 - (0.5d0 * cos((2.0d0 * t_0))))) - ((cos(phi2) * cos(phi1)) * (0.5d0 - (0.5d0 * cos((2.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 = (phi1 - phi2) / 2.0;
double t_1 = (lambda1 - lambda2) / 2.0;
double t_2 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + (Math.cos(phi2) * (0.5 - (0.5 * Math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))));
double t_3 = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 - t_2))));
double t_4 = Math.sin(t_1);
double tmp;
if (phi2 <= -3.1e+16) {
tmp = t_3;
} else if (phi2 <= 1.65e-7) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(t_0), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_4) * t_4))), Math.sqrt(((1.0 - (0.5 - (0.5 * Math.cos((2.0 * t_0))))) - ((Math.cos(phi2) * Math.cos(phi1)) * (0.5 - (0.5 * Math.cos((2.0 * t_1)))))))));
} else {
tmp = t_3;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (phi1 - phi2) / 2.0 t_1 = (lambda1 - lambda2) / 2.0 t_2 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + (math.cos(phi2) * (0.5 - (0.5 * math.cos((2.0 * (0.5 * (lambda1 - lambda2))))))) t_3 = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 - t_2)))) t_4 = math.sin(t_1) tmp = 0 if phi2 <= -3.1e+16: tmp = t_3 elif phi2 <= 1.65e-7: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(t_0), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_4) * t_4))), math.sqrt(((1.0 - (0.5 - (0.5 * math.cos((2.0 * t_0))))) - ((math.cos(phi2) * math.cos(phi1)) * (0.5 - (0.5 * math.cos((2.0 * t_1))))))))) else: tmp = t_3 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(phi1 - phi2) / 2.0) t_1 = Float64(Float64(lambda1 - lambda2) / 2.0) t_2 = Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))))) t_3 = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))) t_4 = sin(t_1) tmp = 0.0 if (phi2 <= -3.1e+16) tmp = t_3; elseif (phi2 <= 1.65e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(t_0) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_4) * t_4))), sqrt(Float64(Float64(1.0 - Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_0))))) - Float64(Float64(cos(phi2) * cos(phi1)) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_1)))))))))); else tmp = t_3; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (phi1 - phi2) / 2.0; t_1 = (lambda1 - lambda2) / 2.0; t_2 = (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + (cos(phi2) * (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2))))))); t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2)))); t_4 = sin(t_1); tmp = 0.0; if (phi2 <= -3.1e+16) tmp = t_3; elseif (phi2 <= 1.65e-7) tmp = R * (2.0 * atan2(sqrt(((sin(t_0) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_4) * t_4))), sqrt(((1.0 - (0.5 - (0.5 * cos((2.0 * t_0))))) - ((cos(phi2) * cos(phi1)) * (0.5 - (0.5 * cos((2.0 * t_1))))))))); else tmp = t_3; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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]}, Block[{t$95$4 = N[Sin[t$95$1], $MachinePrecision]}, If[LessEqual[phi2, -3.1e+16], t$95$3, If[LessEqual[phi2, 1.65e-7], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[t$95$0], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$4), $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\phi_1 - \phi_2}{2}\\
t_1 := \frac{\lambda_1 - \lambda_2}{2}\\
t_2 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\\
t_3 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
t_4 := \sin t\_1\\
\mathbf{if}\;\phi_2 \leq -3.1 \cdot 10^{+16}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_2 \leq 1.65 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin t\_0}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_4\right) \cdot t\_4}}{\sqrt{\left(1 - \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_0\right)\right)\right) - \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_1\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if phi2 < -3.1e16 or 1.6500000000000001e-7 < phi2 Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in phi1 around 0
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6455.8
Applied rewrites55.8%
Taylor expanded in phi1 around 0
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6452.4
Applied rewrites52.4%
if -3.1e16 < phi2 < 1.6500000000000001e-7Initial program 61.6%
Applied rewrites61.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* (cos phi1) (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))))))
(t_2 (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
(if (<= phi1 -8.6e-6)
t_2
(if (<= phi1 480000000.0)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0)))
(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)))))))))))
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 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2)))));
double t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
double tmp;
if (phi1 <= -8.6e-6) {
tmp = t_2;
} else if (phi1 <= 480000000.0) {
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 - fma((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))), cos(phi2), (0.5 - (0.5 * cos((2.0 * (-0.5 * phi2))))))))));
} else {
tmp = t_2;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))))) t_2 = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) tmp = 0.0 if (phi1 <= -8.6e-6) tmp = t_2; elseif (phi1 <= 480000000.0) 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(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))))))))))); else tmp = t_2; 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[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $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, -8.6e-6], t$95$2, If[LessEqual[phi1, 480000000.0], 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[(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], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\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 -8.6 \cdot 10^{-6}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 480000000:\\
\;\;\;\;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{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)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi1 < -8.60000000000000067e-6 or 4.8e8 < phi1 Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6475.3
Applied rewrites75.3%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-a-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6475.4
Applied rewrites75.4%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6456.5
Applied rewrites56.5%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6453.5
Applied rewrites53.5%
if -8.60000000000000067e-6 < phi1 < 4.8e8Initial program 61.6%
Taylor expanded in phi1 around 0
lower--.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites48.4%
(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))))))
(t_2
(fma
(cos phi2)
(pow (sin (* 0.5 (+ lambda1 (* -1.0 lambda2)))) 2.0)
(pow (sin (* 0.5 phi2)) 2.0)))
(t_3 (+ (* t_0 (cos phi1)) t_1)))
(if (<= phi1 -1e-12)
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) t_0)
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
(sqrt (- 1.0 (fma t_0 (cos phi1) t_1))))))
(if (<= phi1 1.6)
(* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))
(* 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)))));
double t_1 = 0.5 - (0.5 * cos((2.0 * (0.5 * phi1))));
double t_2 = fma(cos(phi2), pow(sin((0.5 * (lambda1 + (-1.0 * lambda2)))), 2.0), pow(sin((0.5 * phi2)), 2.0));
double t_3 = (t_0 * cos(phi1)) + t_1;
double tmp;
if (phi1 <= -1e-12) {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi1), (cos(phi2) * t_0), pow(sin((0.5 * (phi1 - phi2))), 2.0))), sqrt((1.0 - fma(t_0, cos(phi1), t_1)))));
} else if (phi1 <= 1.6) {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - 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(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * phi1))))) t_2 = fma(cos(phi2), (sin(Float64(0.5 * Float64(lambda1 + Float64(-1.0 * lambda2)))) ^ 2.0), (sin(Float64(0.5 * phi2)) ^ 2.0)) t_3 = Float64(Float64(t_0 * cos(phi1)) + t_1) tmp = 0.0 if (phi1 <= -1e-12) tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * t_0), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))), sqrt(Float64(1.0 - fma(t_0, cos(phi1), t_1)))))); elseif (phi1 <= 1.6) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - 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[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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] + N[Power[N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$0 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[LessEqual[phi1, -1e-12], 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 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 * N[Cos[phi1], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.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], 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 := 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\\
t_1 := 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \phi_1\right)\right)\\
t_2 := \mathsf{fma}\left(\cos \phi_2, {\sin \left(0.5 \cdot \left(\lambda_1 + -1 \cdot \lambda_2\right)\right)}^{2}, {\sin \left(0.5 \cdot \phi_2\right)}^{2}\right)\\
t_3 := t\_0 \cdot \cos \phi_1 + t\_1\\
\mathbf{if}\;\phi_1 \leq -1 \cdot 10^{-12}:\\
\;\;\;\;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 - \phi_2\right)\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t\_0, \cos \phi_1, t\_1\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 1.6:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_3}}\right)\\
\end{array}
\end{array}
if phi1 < -9.9999999999999998e-13Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Taylor expanded in lambda1 around inf
lower-sqrt.f64N/A
lower-fma.f64N/A
Applied rewrites46.3%
if -9.9999999999999998e-13 < phi1 < 1.6000000000000001Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in lambda2 around -inf
Applied rewrites77.9%
Taylor expanded in lambda2 around -inf
Applied rewrites77.9%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lower-pow.f64N/A
lift-sin.f64N/A
lift-*.f6447.0
Applied rewrites47.0%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lower-pow.f64N/A
lift-sin.f64N/A
lift-*.f6446.2
Applied rewrites46.2%
if 1.6000000000000001 < phi1 Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Applied rewrites42.9%
Applied rewrites42.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(cos phi2)
(pow (sin (* 0.5 (+ lambda1 (* -1.0 lambda2)))) 2.0)
(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
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))) (cos phi1)))))
(if (<= phi1 -9.5e-13)
(* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))
(if (<= phi1 1.6)
(* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.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 = fma(cos(phi2), pow(sin((0.5 * (lambda1 + (-1.0 * lambda2)))), 2.0), 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 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((0.5 - (0.5 * cos((lambda1 - lambda2)))) * cos(phi1));
double tmp;
if (phi1 <= -9.5e-13) {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
} else if (phi1 <= 1.6) {
tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
} 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 = fma(cos(phi2), (sin(Float64(0.5 * Float64(lambda1 + Float64(-1.0 * lambda2)))) ^ 2.0), (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((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))) * cos(phi1))) tmp = 0.0 if (phi1 <= -9.5e-13) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))); elseif (phi1 <= 1.6) 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_1), sqrt(Float64(1.0 - t_1))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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] + 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[(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[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -9.5e-13], 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.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], 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 := \mathsf{fma}\left(\cos \phi_2, {\sin \left(0.5 \cdot \left(\lambda_1 + -1 \cdot \lambda_2\right)\right)}^{2}, {\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 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot \cos \phi_1\\
\mathbf{if}\;\phi_1 \leq -9.5 \cdot 10^{-13}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{elif}\;\phi_1 \leq 1.6:\\
\;\;\;\;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\_1}}{\sqrt{1 - t\_1}}\right)\\
\end{array}
\end{array}
if phi1 < -9.49999999999999991e-13Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6450.5
Applied rewrites50.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6448.6
Applied rewrites48.6%
Taylor expanded in lambda1 around 0
lift--.f6448.6
Applied rewrites48.6%
Taylor expanded in lambda1 around 0
lift--.f6448.6
Applied rewrites48.6%
if -9.49999999999999991e-13 < phi1 < 1.6000000000000001Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in lambda2 around -inf
Applied rewrites77.9%
Taylor expanded in lambda2 around -inf
Applied rewrites77.9%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lower-pow.f64N/A
lift-sin.f64N/A
lift-*.f6447.0
Applied rewrites47.0%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lift-cos.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-pow.f64N/A
lower-pow.f64N/A
lift-sin.f64N/A
lift-*.f6446.2
Applied rewrites46.2%
if 1.6000000000000001 < phi1 Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Applied rewrites42.9%
Applied rewrites42.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (/ (- lambda1 lambda2) 2.0))
(t_1 (sin t_0))
(t_2 (/ (- phi1 phi2) 2.0))
(t_3 (pow (sin t_2) 2.0))
(t_4
(+
(- 0.5 (* 0.5 (cos (* 2.0 t_2))))
(* (* (cos phi2) (cos phi1)) (- 0.5 (* 0.5 (cos (* 2.0 t_0)))))))
(t_5 (+ t_3 (* (* (sin (* 0.5 (- lambda1 lambda2))) (cos phi2)) t_1))))
(if (<= (+ t_3 (* (* (* (cos phi1) (cos phi2)) t_1) t_1)) 0.005)
(* R (* 2.0 (atan2 (sqrt t_5) (sqrt (- 1.0 t_5)))))
(* 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 = (lambda1 - lambda2) / 2.0;
double t_1 = sin(t_0);
double t_2 = (phi1 - phi2) / 2.0;
double t_3 = pow(sin(t_2), 2.0);
double t_4 = (0.5 - (0.5 * cos((2.0 * t_2)))) + ((cos(phi2) * cos(phi1)) * (0.5 - (0.5 * cos((2.0 * t_0)))));
double t_5 = t_3 + ((sin((0.5 * (lambda1 - lambda2))) * cos(phi2)) * t_1);
double tmp;
if ((t_3 + (((cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.005) {
tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_5))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4))));
}
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 = (lambda1 - lambda2) / 2.0d0
t_1 = sin(t_0)
t_2 = (phi1 - phi2) / 2.0d0
t_3 = sin(t_2) ** 2.0d0
t_4 = (0.5d0 - (0.5d0 * cos((2.0d0 * t_2)))) + ((cos(phi2) * cos(phi1)) * (0.5d0 - (0.5d0 * cos((2.0d0 * t_0)))))
t_5 = t_3 + ((sin((0.5d0 * (lambda1 - lambda2))) * cos(phi2)) * t_1)
if ((t_3 + (((cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.005d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_5), sqrt((1.0d0 - t_5))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) / 2.0;
double t_1 = Math.sin(t_0);
double t_2 = (phi1 - phi2) / 2.0;
double t_3 = Math.pow(Math.sin(t_2), 2.0);
double t_4 = (0.5 - (0.5 * Math.cos((2.0 * t_2)))) + ((Math.cos(phi2) * Math.cos(phi1)) * (0.5 - (0.5 * Math.cos((2.0 * t_0)))));
double t_5 = t_3 + ((Math.sin((0.5 * (lambda1 - lambda2))) * Math.cos(phi2)) * t_1);
double tmp;
if ((t_3 + (((Math.cos(phi1) * Math.cos(phi2)) * t_1) * t_1)) <= 0.005) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_5), Math.sqrt((1.0 - t_5))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (lambda1 - lambda2) / 2.0 t_1 = math.sin(t_0) t_2 = (phi1 - phi2) / 2.0 t_3 = math.pow(math.sin(t_2), 2.0) t_4 = (0.5 - (0.5 * math.cos((2.0 * t_2)))) + ((math.cos(phi2) * math.cos(phi1)) * (0.5 - (0.5 * math.cos((2.0 * t_0))))) t_5 = t_3 + ((math.sin((0.5 * (lambda1 - lambda2))) * math.cos(phi2)) * t_1) tmp = 0 if (t_3 + (((math.cos(phi1) * math.cos(phi2)) * t_1) * t_1)) <= 0.005: tmp = R * (2.0 * math.atan2(math.sqrt(t_5), math.sqrt((1.0 - t_5)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) / 2.0) t_1 = sin(t_0) t_2 = Float64(Float64(phi1 - phi2) / 2.0) t_3 = sin(t_2) ^ 2.0 t_4 = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_2)))) + Float64(Float64(cos(phi2) * cos(phi1)) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_0)))))) t_5 = Float64(t_3 + Float64(Float64(sin(Float64(0.5 * Float64(lambda1 - lambda2))) * cos(phi2)) * t_1)) tmp = 0.0 if (Float64(t_3 + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.005) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_5), sqrt(Float64(1.0 - t_5))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (lambda1 - lambda2) / 2.0; t_1 = sin(t_0); t_2 = (phi1 - phi2) / 2.0; t_3 = sin(t_2) ^ 2.0; t_4 = (0.5 - (0.5 * cos((2.0 * t_2)))) + ((cos(phi2) * cos(phi1)) * (0.5 - (0.5 * cos((2.0 * t_0))))); t_5 = t_3 + ((sin((0.5 * (lambda1 - lambda2))) * cos(phi2)) * t_1); tmp = 0.0; if ((t_3 + (((cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.005) tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_5)))); else tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4)))); end tmp_2 = 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[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[t$95$2], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$3 + N[(N[(N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$3 + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 0.005], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $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 := \frac{\lambda_1 - \lambda_2}{2}\\
t_1 := \sin t\_0\\
t_2 := \frac{\phi_1 - \phi_2}{2}\\
t_3 := {\sin t\_2}^{2}\\
t_4 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_2\right)\right) + \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_0\right)\right)\\
t_5 := t\_3 + \left(\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \cos \phi_2\right) \cdot t\_1\\
\mathbf{if}\;t\_3 + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) \cdot t\_1 \leq 0.005:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5}}{\sqrt{1 - t\_5}}\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 (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.0050000000000000001Initial program 61.6%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6452.4
Applied rewrites52.4%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6450.2
Applied rewrites50.2%
if 0.0050000000000000001 < (+.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.6%
Applied rewrites56.7%
Applied rewrites56.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (/ (- lambda1 lambda2) 2.0))
(t_1 (sin t_0))
(t_2 (/ (- phi1 phi2) 2.0))
(t_3 (pow (sin t_2) 2.0))
(t_4
(+
(- 0.5 (* 0.5 (cos (* 2.0 t_2))))
(* (* (cos phi2) (cos phi1)) (- 0.5 (* 0.5 (cos (* 2.0 t_0)))))))
(t_5 (+ t_3 (* (* (sin (* 0.5 (- lambda1 lambda2))) (cos phi1)) t_1))))
(if (<= (+ t_3 (* (* (* (cos phi1) (cos phi2)) t_1) t_1)) 0.01)
(* R (* 2.0 (atan2 (sqrt t_5) (sqrt (- 1.0 t_5)))))
(* 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 = (lambda1 - lambda2) / 2.0;
double t_1 = sin(t_0);
double t_2 = (phi1 - phi2) / 2.0;
double t_3 = pow(sin(t_2), 2.0);
double t_4 = (0.5 - (0.5 * cos((2.0 * t_2)))) + ((cos(phi2) * cos(phi1)) * (0.5 - (0.5 * cos((2.0 * t_0)))));
double t_5 = t_3 + ((sin((0.5 * (lambda1 - lambda2))) * cos(phi1)) * t_1);
double tmp;
if ((t_3 + (((cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.01) {
tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_5))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4))));
}
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 = (lambda1 - lambda2) / 2.0d0
t_1 = sin(t_0)
t_2 = (phi1 - phi2) / 2.0d0
t_3 = sin(t_2) ** 2.0d0
t_4 = (0.5d0 - (0.5d0 * cos((2.0d0 * t_2)))) + ((cos(phi2) * cos(phi1)) * (0.5d0 - (0.5d0 * cos((2.0d0 * t_0)))))
t_5 = t_3 + ((sin((0.5d0 * (lambda1 - lambda2))) * cos(phi1)) * t_1)
if ((t_3 + (((cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.01d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_5), sqrt((1.0d0 - t_5))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) / 2.0;
double t_1 = Math.sin(t_0);
double t_2 = (phi1 - phi2) / 2.0;
double t_3 = Math.pow(Math.sin(t_2), 2.0);
double t_4 = (0.5 - (0.5 * Math.cos((2.0 * t_2)))) + ((Math.cos(phi2) * Math.cos(phi1)) * (0.5 - (0.5 * Math.cos((2.0 * t_0)))));
double t_5 = t_3 + ((Math.sin((0.5 * (lambda1 - lambda2))) * Math.cos(phi1)) * t_1);
double tmp;
if ((t_3 + (((Math.cos(phi1) * Math.cos(phi2)) * t_1) * t_1)) <= 0.01) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_5), Math.sqrt((1.0 - t_5))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (lambda1 - lambda2) / 2.0 t_1 = math.sin(t_0) t_2 = (phi1 - phi2) / 2.0 t_3 = math.pow(math.sin(t_2), 2.0) t_4 = (0.5 - (0.5 * math.cos((2.0 * t_2)))) + ((math.cos(phi2) * math.cos(phi1)) * (0.5 - (0.5 * math.cos((2.0 * t_0))))) t_5 = t_3 + ((math.sin((0.5 * (lambda1 - lambda2))) * math.cos(phi1)) * t_1) tmp = 0 if (t_3 + (((math.cos(phi1) * math.cos(phi2)) * t_1) * t_1)) <= 0.01: tmp = R * (2.0 * math.atan2(math.sqrt(t_5), math.sqrt((1.0 - t_5)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) / 2.0) t_1 = sin(t_0) t_2 = Float64(Float64(phi1 - phi2) / 2.0) t_3 = sin(t_2) ^ 2.0 t_4 = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_2)))) + Float64(Float64(cos(phi2) * cos(phi1)) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_0)))))) t_5 = Float64(t_3 + Float64(Float64(sin(Float64(0.5 * Float64(lambda1 - lambda2))) * cos(phi1)) * t_1)) tmp = 0.0 if (Float64(t_3 + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.01) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_5), sqrt(Float64(1.0 - t_5))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (lambda1 - lambda2) / 2.0; t_1 = sin(t_0); t_2 = (phi1 - phi2) / 2.0; t_3 = sin(t_2) ^ 2.0; t_4 = (0.5 - (0.5 * cos((2.0 * t_2)))) + ((cos(phi2) * cos(phi1)) * (0.5 - (0.5 * cos((2.0 * t_0))))); t_5 = t_3 + ((sin((0.5 * (lambda1 - lambda2))) * cos(phi1)) * t_1); tmp = 0.0; if ((t_3 + (((cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.01) tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_5)))); else tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4)))); end tmp_2 = 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[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[t$95$2], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$3 + N[(N[(N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$3 + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 0.01], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $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 := \frac{\lambda_1 - \lambda_2}{2}\\
t_1 := \sin t\_0\\
t_2 := \frac{\phi_1 - \phi_2}{2}\\
t_3 := {\sin t\_2}^{2}\\
t_4 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_2\right)\right) + \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_0\right)\right)\\
t_5 := t\_3 + \left(\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \cos \phi_1\right) \cdot t\_1\\
\mathbf{if}\;t\_3 + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) \cdot t\_1 \leq 0.01:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5}}{\sqrt{1 - t\_5}}\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 (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.0100000000000000002Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6453.1
Applied rewrites53.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6451.2
Applied rewrites51.2%
if 0.0100000000000000002 < (+.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.6%
Applied rewrites56.7%
Applied rewrites56.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (/ (- lambda1 lambda2) 2.0))
(t_1 (sin t_0))
(t_2 (/ (- phi1 phi2) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin t_2) 2.0) (* (* (* (cos phi1) (cos phi2)) t_1) t_1)))
(sqrt
(-
(- 1.0 (- 0.5 (* 0.5 (cos (* 2.0 t_2)))))
(* (* (cos phi2) (cos phi1)) (- 0.5 (* 0.5 (cos (* 2.0 t_0))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) / 2.0;
double t_1 = sin(t_0);
double t_2 = (phi1 - phi2) / 2.0;
return R * (2.0 * atan2(sqrt((pow(sin(t_2), 2.0) + (((cos(phi1) * cos(phi2)) * t_1) * t_1))), sqrt(((1.0 - (0.5 - (0.5 * cos((2.0 * t_2))))) - ((cos(phi2) * cos(phi1)) * (0.5 - (0.5 * cos((2.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
real(8) :: t_1
real(8) :: t_2
t_0 = (lambda1 - lambda2) / 2.0d0
t_1 = sin(t_0)
t_2 = (phi1 - phi2) / 2.0d0
code = r * (2.0d0 * atan2(sqrt(((sin(t_2) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_1) * t_1))), sqrt(((1.0d0 - (0.5d0 - (0.5d0 * cos((2.0d0 * t_2))))) - ((cos(phi2) * cos(phi1)) * (0.5d0 - (0.5d0 * cos((2.0d0 * t_0)))))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) / 2.0;
double t_1 = Math.sin(t_0);
double t_2 = (phi1 - phi2) / 2.0;
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(t_2), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_1) * t_1))), Math.sqrt(((1.0 - (0.5 - (0.5 * Math.cos((2.0 * t_2))))) - ((Math.cos(phi2) * Math.cos(phi1)) * (0.5 - (0.5 * Math.cos((2.0 * t_0)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (lambda1 - lambda2) / 2.0 t_1 = math.sin(t_0) t_2 = (phi1 - phi2) / 2.0 return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(t_2), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_1) * t_1))), math.sqrt(((1.0 - (0.5 - (0.5 * math.cos((2.0 * t_2))))) - ((math.cos(phi2) * math.cos(phi1)) * (0.5 - (0.5 * math.cos((2.0 * t_0)))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) / 2.0) t_1 = sin(t_0) t_2 = Float64(Float64(phi1 - phi2) / 2.0) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(t_2) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_1) * t_1))), sqrt(Float64(Float64(1.0 - Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_2))))) - Float64(Float64(cos(phi2) * cos(phi1)) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_0)))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = (lambda1 - lambda2) / 2.0; t_1 = sin(t_0); t_2 = (phi1 - phi2) / 2.0; tmp = R * (2.0 * atan2(sqrt(((sin(t_2) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_1) * t_1))), sqrt(((1.0 - (0.5 - (0.5 * cos((2.0 * t_2))))) - ((cos(phi2) * cos(phi1)) * (0.5 - (0.5 * cos((2.0 * t_0))))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$1 = N[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[t$95$2], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\lambda_1 - \lambda_2}{2}\\
t_1 := \sin t\_0\\
t_2 := \frac{\phi_1 - \phi_2}{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin t\_2}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) \cdot t\_1}}{\sqrt{\left(1 - \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_2\right)\right)\right) - \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_0\right)\right)}}\right)
\end{array}
\end{array}
Initial program 61.6%
Applied rewrites61.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (/ (- lambda1 lambda2) 2.0))
(t_1 (sin t_0))
(t_2 (/ (- phi1 phi2) 2.0))
(t_3
(+
(- 0.5 (* 0.5 (cos (* 2.0 t_2))))
(* (* (cos phi2) (cos phi1)) (- 0.5 (* 0.5 (cos (* 2.0 t_0)))))))
(t_4
(+ (pow (sin t_2) 2.0) (* (* (* (cos phi1) (cos phi2)) t_1) t_1))))
(if (<= t_4 0.01)
(*
R
(*
2.0
(atan2
(sqrt t_4)
(sqrt
(-
1.0
(fma
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(cos phi1)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 phi1)))))))))))
(* 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 = (lambda1 - lambda2) / 2.0;
double t_1 = sin(t_0);
double t_2 = (phi1 - phi2) / 2.0;
double t_3 = (0.5 - (0.5 * cos((2.0 * t_2)))) + ((cos(phi2) * cos(phi1)) * (0.5 - (0.5 * cos((2.0 * t_0)))));
double t_4 = pow(sin(t_2), 2.0) + (((cos(phi1) * cos(phi2)) * t_1) * t_1);
double tmp;
if (t_4 <= 0.01) {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - fma((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))), cos(phi1), (0.5 - (0.5 * cos((2.0 * (0.5 * phi1))))))))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) / 2.0) t_1 = sin(t_0) t_2 = Float64(Float64(phi1 - phi2) / 2.0) t_3 = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_2)))) + Float64(Float64(cos(phi2) * cos(phi1)) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_0)))))) t_4 = Float64((sin(t_2) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_1) * t_1)) tmp = 0.0 if (t_4 <= 0.01) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.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(Float64(2.0 * Float64(0.5 * phi1))))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_3))))); 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[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Power[N[Sin[t$95$2], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, 0.01], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $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[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$3], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\lambda_1 - \lambda_2}{2}\\
t_1 := \sin t\_0\\
t_2 := \frac{\phi_1 - \phi_2}{2}\\
t_3 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_2\right)\right) + \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_0\right)\right)\\
t_4 := {\sin t\_2}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) \cdot t\_1\\
\mathbf{if}\;t\_4 \leq 0.01:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\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_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\_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))))) < 0.0100000000000000002Initial program 61.6%
Taylor expanded in phi2 around 0
lower--.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites48.9%
if 0.0100000000000000002 < (+.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.6%
Applied rewrites56.7%
Applied rewrites56.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (/ (- lambda1 lambda2) 2.0))
(t_1 (sin t_0))
(t_2 (/ (- phi1 phi2) 2.0))
(t_3 (+ (pow (sin t_2) 2.0) (* (* (* (cos phi1) (cos phi2)) t_1) t_1)))
(t_4
(+
(- 0.5 (* 0.5 (cos (* 2.0 t_2))))
(* (* (cos phi2) (cos phi1)) (- 0.5 (* 0.5 (cos (* 2.0 t_0))))))))
(if (<= t_3 5e-6)
(*
R
(*
2.0
(atan2 (sqrt t_3) (sqrt (+ 0.5 (* 0.5 (cos (- lambda1 lambda2))))))))
(* 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 = (lambda1 - lambda2) / 2.0;
double t_1 = sin(t_0);
double t_2 = (phi1 - phi2) / 2.0;
double t_3 = pow(sin(t_2), 2.0) + (((cos(phi1) * cos(phi2)) * t_1) * t_1);
double t_4 = (0.5 - (0.5 * cos((2.0 * t_2)))) + ((cos(phi2) * cos(phi1)) * (0.5 - (0.5 * cos((2.0 * t_0)))));
double tmp;
if (t_3 <= 5e-6) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((0.5 + (0.5 * cos((lambda1 - lambda2)))))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4))));
}
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 = (lambda1 - lambda2) / 2.0d0
t_1 = sin(t_0)
t_2 = (phi1 - phi2) / 2.0d0
t_3 = (sin(t_2) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_1) * t_1)
t_4 = (0.5d0 - (0.5d0 * cos((2.0d0 * t_2)))) + ((cos(phi2) * cos(phi1)) * (0.5d0 - (0.5d0 * cos((2.0d0 * t_0)))))
if (t_3 <= 5d-6) then
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((0.5d0 + (0.5d0 * cos((lambda1 - lambda2)))))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) / 2.0;
double t_1 = Math.sin(t_0);
double t_2 = (phi1 - phi2) / 2.0;
double t_3 = Math.pow(Math.sin(t_2), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_1) * t_1);
double t_4 = (0.5 - (0.5 * Math.cos((2.0 * t_2)))) + ((Math.cos(phi2) * Math.cos(phi1)) * (0.5 - (0.5 * Math.cos((2.0 * t_0)))));
double tmp;
if (t_3 <= 5e-6) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((0.5 + (0.5 * Math.cos((lambda1 - lambda2)))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (lambda1 - lambda2) / 2.0 t_1 = math.sin(t_0) t_2 = (phi1 - phi2) / 2.0 t_3 = math.pow(math.sin(t_2), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_1) * t_1) t_4 = (0.5 - (0.5 * math.cos((2.0 * t_2)))) + ((math.cos(phi2) * math.cos(phi1)) * (0.5 - (0.5 * math.cos((2.0 * t_0))))) tmp = 0 if t_3 <= 5e-6: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((0.5 + (0.5 * math.cos((lambda1 - lambda2))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) / 2.0) t_1 = sin(t_0) t_2 = Float64(Float64(phi1 - phi2) / 2.0) t_3 = Float64((sin(t_2) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_1) * t_1)) t_4 = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_2)))) + Float64(Float64(cos(phi2) * cos(phi1)) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_0)))))) tmp = 0.0 if (t_3 <= 5e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(0.5 + Float64(0.5 * cos(Float64(lambda1 - lambda2)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (lambda1 - lambda2) / 2.0; t_1 = sin(t_0); t_2 = (phi1 - phi2) / 2.0; t_3 = (sin(t_2) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_1) * t_1); t_4 = (0.5 - (0.5 * cos((2.0 * t_2)))) + ((cos(phi2) * cos(phi1)) * (0.5 - (0.5 * cos((2.0 * t_0))))); tmp = 0.0; if (t_3 <= 5e-6) tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((0.5 + (0.5 * cos((lambda1 - lambda2))))))); else tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4)))); end tmp_2 = 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[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[N[Sin[t$95$2], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, 5e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(0.5 * N[Cos[N[(lambda1 - lambda2), $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 := \frac{\lambda_1 - \lambda_2}{2}\\
t_1 := \sin t\_0\\
t_2 := \frac{\phi_1 - \phi_2}{2}\\
t_3 := {\sin t\_2}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) \cdot t\_1\\
t_4 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_2\right)\right) + \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_0\right)\right)\\
\mathbf{if}\;t\_3 \leq 5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\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 (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))))) < 5.00000000000000041e-6Initial program 61.6%
Taylor expanded in phi1 around 0
Applied rewrites45.1%
Taylor expanded in phi2 around 0
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6435.1
Applied rewrites35.1%
if 5.00000000000000041e-6 < (+.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.6%
Applied rewrites56.7%
Applied rewrites56.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* 0.5 (- lambda1 lambda2)))
(t_1 (- 0.5 (* 0.5 (cos (* 2.0 t_0)))))
(t_2 (fma (cos phi2) t_1 (pow (sin (* 0.5 phi2)) 2.0)))
(t_3
(fma
(pow (sin t_0) 2.0)
(cos phi1)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 phi1)))))))
(t_4 (fma t_1 (cos phi2) (- 0.5 (* 0.5 (cos (* 2.0 (* -0.5 phi2))))))))
(if (<= phi2 -1.5e-80)
(* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))
(if (<= phi2 2.35e-5)
(* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- 1.0 t_3)))))
(* 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 = 0.5 * (lambda1 - lambda2);
double t_1 = 0.5 - (0.5 * cos((2.0 * t_0)));
double t_2 = fma(cos(phi2), t_1, pow(sin((0.5 * phi2)), 2.0));
double t_3 = fma(pow(sin(t_0), 2.0), cos(phi1), (0.5 - (0.5 * cos((2.0 * (0.5 * phi1))))));
double t_4 = fma(t_1, cos(phi2), (0.5 - (0.5 * cos((2.0 * (-0.5 * phi2))))));
double tmp;
if (phi2 <= -1.5e-80) {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
} else if (phi2 <= 2.35e-5) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3))));
} 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 = Float64(0.5 * Float64(lambda1 - lambda2)) t_1 = Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_0)))) t_2 = fma(cos(phi2), t_1, (sin(Float64(0.5 * phi2)) ^ 2.0)) t_3 = fma((sin(t_0) ^ 2.0), cos(phi1), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * phi1)))))) t_4 = fma(t_1, cos(phi2), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(-0.5 * phi2)))))) tmp = 0.0 if (phi2 <= -1.5e-80) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))); elseif (phi2 <= 2.35e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_3))))); 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[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1 + N[Power[N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[N[Sin[t$95$0], $MachinePrecision], 2.0], $MachinePrecision] * 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]}, Block[{t$95$4 = N[(t$95$1 * 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]}, If[LessEqual[phi2, -1.5e-80], 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, 2.35e-5], 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], 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 := 0.5 \cdot \left(\lambda_1 - \lambda_2\right)\\
t_1 := 0.5 - 0.5 \cdot \cos \left(2 \cdot t\_0\right)\\
t_2 := \mathsf{fma}\left(\cos \phi_2, t\_1, {\sin \left(0.5 \cdot \phi_2\right)}^{2}\right)\\
t_3 := \mathsf{fma}\left({\sin t\_0}^{2}, \cos \phi_1, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \phi_1\right)\right)\right)\\
t_4 := \mathsf{fma}\left(t\_1, \cos \phi_2, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(-0.5 \cdot \phi_2\right)\right)\right)\\
\mathbf{if}\;\phi_2 \leq -1.5 \cdot 10^{-80}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{elif}\;\phi_2 \leq 2.35 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - t\_4}}\right)\\
\end{array}
\end{array}
if phi2 < -1.50000000000000004e-80Initial program 61.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6462.6
Applied rewrites62.6%
lift-sin.f64N/A
lift--.f64N/A
lift-/.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
Taylor expanded in phi1 around 0
lift-/.f64N/A
lift-/.f64N/A
sin-diff-revN/A
lift-/.f64N/A
div-subN/A
Applied rewrites44.4%
Taylor expanded in phi1 around 0
lift-/.f64N/A
lift-/.f64N/A
sin-diff-revN/A
lift-/.f64N/A
div-subN/A
Applied rewrites43.6%
if -1.50000000000000004e-80 < phi2 < 2.34999999999999986e-5Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
sqr-sin-a-revN/A
unpow2N/A
lower-pow.f64N/A
lower-sin.f64N/A
lift--.f64N/A
lift-*.f6445.6
Applied rewrites45.6%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
sqr-sin-a-revN/A
unpow2N/A
lower-pow.f64N/A
lower-sin.f64N/A
lift--.f64N/A
lift-*.f6445.6
Applied rewrites45.6%
if 2.34999999999999986e-5 < phi2 Initial program 61.6%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.2%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (/ (- lambda1 lambda2) 2.0))
(t_1 (sin t_0))
(t_2 (/ (- phi1 phi2) 2.0))
(t_3 (+ (pow (sin t_2) 2.0) (* (* (* (cos phi1) (cos phi2)) t_1) t_1)))
(t_4
(fma
(* (cos phi2) (cos phi1))
(- 0.5 (* 0.5 (cos (* 2.0 t_0))))
(- 0.5 (* 0.5 (cos (* 2.0 t_2)))))))
(if (<= t_3 5e-6)
(*
R
(*
2.0
(atan2 (sqrt t_3) (sqrt (+ 0.5 (* 0.5 (cos (- lambda1 lambda2))))))))
(* (* (atan2 (sqrt t_4) (sqrt (- 1.0 t_4))) 2.0) R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) / 2.0;
double t_1 = sin(t_0);
double t_2 = (phi1 - phi2) / 2.0;
double t_3 = pow(sin(t_2), 2.0) + (((cos(phi1) * cos(phi2)) * t_1) * t_1);
double t_4 = fma((cos(phi2) * cos(phi1)), (0.5 - (0.5 * cos((2.0 * t_0)))), (0.5 - (0.5 * cos((2.0 * t_2)))));
double tmp;
if (t_3 <= 5e-6) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((0.5 + (0.5 * cos((lambda1 - lambda2)))))));
} else {
tmp = (atan2(sqrt(t_4), sqrt((1.0 - t_4))) * 2.0) * R;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) / 2.0) t_1 = sin(t_0) t_2 = Float64(Float64(phi1 - phi2) / 2.0) t_3 = Float64((sin(t_2) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_1) * t_1)) t_4 = fma(Float64(cos(phi2) * cos(phi1)), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_0)))), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_2))))) tmp = 0.0 if (t_3 <= 5e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(0.5 + Float64(0.5 * cos(Float64(lambda1 - lambda2)))))))); else tmp = Float64(Float64(atan(sqrt(t_4), sqrt(Float64(1.0 - t_4))) * 2.0) * R); 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[Sin[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[N[Sin[t$95$2], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, 5e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision] * R), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\lambda_1 - \lambda_2}{2}\\
t_1 := \sin t\_0\\
t_2 := \frac{\phi_1 - \phi_2}{2}\\
t_3 := {\sin t\_2}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) \cdot t\_1\\
t_4 := \mathsf{fma}\left(\cos \phi_2 \cdot \cos \phi_1, 0.5 - 0.5 \cdot \cos \left(2 \cdot t\_0\right), 0.5 - 0.5 \cdot \cos \left(2 \cdot t\_2\right)\right)\\
\mathbf{if}\;t\_3 \leq 5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{0.5 + 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - t\_4}} \cdot 2\right) \cdot R\\
\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))))) < 5.00000000000000041e-6Initial program 61.6%
Taylor expanded in phi1 around 0
Applied rewrites45.1%
Taylor expanded in phi2 around 0
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift--.f6435.1
Applied rewrites35.1%
if 5.00000000000000041e-6 < (+.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.6%
Applied rewrites56.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))) (cos phi1))))
(t_1
(fma
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(cos phi2)
(- 0.5 (* 0.5 (cos (* 2.0 (* -0.5 phi2)))))))
(t_2 (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
(if (<= phi2 -0.00017)
t_2
(if (<= phi2 0.000125)
(* 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((lambda1 - lambda2)))) * cos(phi1));
double t_1 = 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 t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
double tmp;
if (phi2 <= -0.00017) {
tmp = t_2;
} else if (phi2 <= 0.000125) {
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(lambda1 - lambda2)))) * cos(phi1))) t_1 = 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)))))) t_2 = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) tmp = 0.0 if (phi2 <= -0.00017) tmp = t_2; elseif (phi2 <= 0.000125) 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[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, 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, -0.00017], t$95$2, If[LessEqual[phi2, 0.000125], 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(\lambda_1 - \lambda_2\right)\right) \cdot \cos \phi_1\\
t_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)\\
t_2 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{if}\;\phi_2 \leq -0.00017:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_2 \leq 0.000125:\\
\;\;\;\;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 < -1.7e-4 or 1.25e-4 < phi2 Initial program 61.6%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.2%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.5%
if -1.7e-4 < phi2 < 1.25e-4Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6450.5
Applied rewrites50.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6448.6
Applied rewrites48.6%
Taylor expanded in lambda1 around 0
lift--.f6448.6
Applied rewrites48.6%
Taylor expanded in lambda1 around 0
lift--.f6448.6
Applied rewrites48.6%
(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 -7.8e-7)
t_3
(if (<= phi2 2.1e-5)
(* 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 <= -7.8e-7) {
tmp = t_3;
} else if (phi2 <= 2.1e-5) {
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 <= -7.8e-7) tmp = t_3; elseif (phi2 <= 2.1e-5) 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, -7.8e-7], t$95$3, If[LessEqual[phi2, 2.1e-5], 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 -7.8 \cdot 10^{-7}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_2 \leq 2.1 \cdot 10^{-5}:\\
\;\;\;\;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 < -7.80000000000000049e-7 or 2.09999999999999988e-5 < phi2 Initial program 61.6%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.2%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.5%
if -7.80000000000000049e-7 < phi2 < 2.09999999999999988e-5Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Applied rewrites42.9%
Applied rewrites42.9%
(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 -7.8e-7)
t_3
(if (<= phi2 2.1e-5)
(* 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 <= -7.8e-7) {
tmp = t_3;
} else if (phi2 <= 2.1e-5) {
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 <= -7.8e-7) tmp = t_3; elseif (phi2 <= 2.1e-5) 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, -7.8e-7], t$95$3, If[LessEqual[phi2, 2.1e-5], 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 -7.8 \cdot 10^{-7}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_2 \leq 2.1 \cdot 10^{-5}:\\
\;\;\;\;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 < -7.80000000000000049e-7 or 2.09999999999999988e-5 < phi2 Initial program 61.6%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.2%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.5%
if -7.80000000000000049e-7 < phi2 < 2.09999999999999988e-5Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
(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 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 1.0)))
(t_4 (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
(if (<= t_2 -0.04)
t_4
(if (<= t_2 0.02)
(* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- 1.0 t_3)))))
t_4))))
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 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * 1.0);
double t_4 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
double tmp;
if (t_2 <= -0.04) {
tmp = t_4;
} else if (t_2 <= 0.02) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3))));
} else {
tmp = t_4;
}
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 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * 1.0)) t_4 = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) tmp = 0.0 if (t_2 <= -0.04) tmp = t_4; elseif (t_2 <= 0.02) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_3))))); else tmp = t_4; 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[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[(t$95$0 * 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = 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[t$95$2, -0.04], t$95$4, If[LessEqual[t$95$2, 0.02], 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$4]]]]]]]
\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 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot 1\\
t_4 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{if}\;t\_2 \leq -0.04:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_2 \leq 0.02:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.0400000000000000008 or 0.0200000000000000004 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lift-cos.f6442.9
Applied rewrites42.9%
if -0.0400000000000000008 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.0200000000000000004Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6450.5
Applied rewrites50.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6448.6
Applied rewrites48.6%
Taylor expanded in phi1 around 0
sin-+PI/2-rev39.8
Applied rewrites39.8%
Taylor expanded in phi1 around 0
sin-+PI/2-rev35.8
Applied rewrites35.8%
(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)
(* (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))))) 1.0))))
(if (<= t_2 -0.04)
t_1
(if (<= t_2 0.02)
(* 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) + ((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * 1.0);
double tmp;
if (t_2 <= -0.04) {
tmp = t_1;
} else if (t_2 <= 0.02) {
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) + ((0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * (lambda1 - lambda2)))))) * 1.0d0)
if (t_2 <= (-0.04d0)) then
tmp = t_1
else if (t_2 <= 0.02d0) 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) + ((0.5 - (0.5 * Math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * 1.0);
double tmp;
if (t_2 <= -0.04) {
tmp = t_1;
} else if (t_2 <= 0.02) {
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) + ((0.5 - (0.5 * math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * 1.0) tmp = 0 if t_2 <= -0.04: tmp = t_1 elif t_2 <= 0.02: 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(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))) * 1.0)) tmp = 0.0 if (t_2 <= -0.04) tmp = t_1; elseif (t_2 <= 0.02) 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) + ((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * 1.0); tmp = 0.0; if (t_2 <= -0.04) tmp = t_1; elseif (t_2 <= 0.02) 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[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.04], t$95$1, If[LessEqual[t$95$2, 0.02], 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(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right) \cdot 1\\
\mathbf{if}\;t\_2 \leq -0.04:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 0.02:\\
\;\;\;\;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))) < -0.0400000000000000008 or 0.0200000000000000004 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
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.f6442.9
Applied rewrites42.9%
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.f6442.8
Applied rewrites42.8%
if -0.0400000000000000008 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.0200000000000000004Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6450.5
Applied rewrites50.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6448.6
Applied rewrites48.6%
Taylor expanded in phi1 around 0
sin-+PI/2-rev39.8
Applied rewrites39.8%
Taylor expanded in phi1 around 0
sin-+PI/2-rev35.8
Applied rewrites35.8%
(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)))))) 1.0)))
(t_1
(-
(+ 0.5 (* (cos phi1) (- 0.5 (* 0.5 (cos lambda2)))))
(* 0.5 (cos phi1))))
(t_2 (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
(if (<= lambda2 -2.7e-6)
t_2
(if (<= lambda2 0.035)
(* 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)))))) * 1.0);
double t_1 = (0.5 + (cos(phi1) * (0.5 - (0.5 * cos(lambda2))))) - (0.5 * cos(phi1));
double t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
double tmp;
if (lambda2 <= -2.7e-6) {
tmp = t_2;
} else if (lambda2 <= 0.035) {
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 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * (lambda1 - lambda2)))))) * 1.0d0)
t_1 = (0.5d0 + (cos(phi1) * (0.5d0 - (0.5d0 * cos(lambda2))))) - (0.5d0 * cos(phi1))
t_2 = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
if (lambda2 <= (-2.7d-6)) then
tmp = t_2
else if (lambda2 <= 0.035d0) 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 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((0.5 - (0.5 * Math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * 1.0);
double t_1 = (0.5 + (Math.cos(phi1) * (0.5 - (0.5 * Math.cos(lambda2))))) - (0.5 * Math.cos(phi1));
double t_2 = R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
double tmp;
if (lambda2 <= -2.7e-6) {
tmp = t_2;
} else if (lambda2 <= 0.035) {
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 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((0.5 - (0.5 * math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * 1.0) t_1 = (0.5 + (math.cos(phi1) * (0.5 - (0.5 * math.cos(lambda2))))) - (0.5 * math.cos(phi1)) t_2 = R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1)))) tmp = 0 if lambda2 <= -2.7e-6: tmp = t_2 elif lambda2 <= 0.035: 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((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)))))) * 1.0)) t_1 = Float64(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(lambda2))))) - Float64(0.5 * cos(phi1))) t_2 = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) tmp = 0.0 if (lambda2 <= -2.7e-6) tmp = t_2; elseif (lambda2 <= 0.035) 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 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * 1.0); t_1 = (0.5 + (cos(phi1) * (0.5 - (0.5 * cos(lambda2))))) - (0.5 * cos(phi1)); t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); tmp = 0.0; if (lambda2 <= -2.7e-6) tmp = t_2; elseif (lambda2 <= 0.035) 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[(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] * 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[Cos[phi1], $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, -2.7e-6], t$95$2, If[LessEqual[lambda2, 0.035], 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 1\\
t_1 := \left(0.5 + \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \lambda_2\right)\right) - 0.5 \cdot \cos \phi_1\\
t_2 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{if}\;\lambda_2 \leq -2.7 \cdot 10^{-6}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_2 \leq 0.035:\\
\;\;\;\;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 < -2.69999999999999998e-6 or 0.035000000000000003 < lambda2 Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Taylor expanded in lambda1 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lift-cos.f6431.2
Applied rewrites31.2%
Taylor expanded in lambda1 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lift-cos.f6431.0
Applied rewrites31.0%
if -2.69999999999999998e-6 < lambda2 < 0.035000000000000003Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6450.5
Applied rewrites50.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6448.6
Applied rewrites48.6%
Taylor expanded in phi1 around 0
sin-+PI/2-rev39.8
Applied rewrites39.8%
Taylor expanded in phi1 around 0
sin-+PI/2-rev35.8
Applied rewrites35.8%
(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)))))) 1.0)))
(t_1
(-
(+ 0.5 (* (cos phi1) (- 0.5 (* 0.5 (cos lambda1)))))
(* 0.5 (cos phi1))))
(t_2 (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
(if (<= phi1 -8.5e+43)
t_2
(if (<= phi1 1.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) + ((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * 1.0);
double t_1 = (0.5 + (cos(phi1) * (0.5 - (0.5 * cos(lambda1))))) - (0.5 * cos(phi1));
double t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
double tmp;
if (phi1 <= -8.5e+43) {
tmp = t_2;
} else if (phi1 <= 1.6) {
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 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * (lambda1 - lambda2)))))) * 1.0d0)
t_1 = (0.5d0 + (cos(phi1) * (0.5d0 - (0.5d0 * cos(lambda1))))) - (0.5d0 * cos(phi1))
t_2 = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
if (phi1 <= (-8.5d+43)) then
tmp = t_2
else if (phi1 <= 1.6d0) 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 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((0.5 - (0.5 * Math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * 1.0);
double t_1 = (0.5 + (Math.cos(phi1) * (0.5 - (0.5 * Math.cos(lambda1))))) - (0.5 * Math.cos(phi1));
double t_2 = R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
double tmp;
if (phi1 <= -8.5e+43) {
tmp = t_2;
} else if (phi1 <= 1.6) {
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 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((0.5 - (0.5 * math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * 1.0) t_1 = (0.5 + (math.cos(phi1) * (0.5 - (0.5 * math.cos(lambda1))))) - (0.5 * math.cos(phi1)) t_2 = R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1)))) tmp = 0 if phi1 <= -8.5e+43: tmp = t_2 elif phi1 <= 1.6: 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((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)))))) * 1.0)) t_1 = Float64(Float64(0.5 + Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(lambda1))))) - Float64(0.5 * cos(phi1))) t_2 = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) tmp = 0.0 if (phi1 <= -8.5e+43) tmp = t_2; elseif (phi1 <= 1.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
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * 1.0); t_1 = (0.5 + (cos(phi1) * (0.5 - (0.5 * cos(lambda1))))) - (0.5 * cos(phi1)); t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); tmp = 0.0; if (phi1 <= -8.5e+43) tmp = t_2; elseif (phi1 <= 1.6) 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[(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] * 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[Cos[phi1], $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, -8.5e+43], t$95$2, If[LessEqual[phi1, 1.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(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right) \cdot 1\\
t_1 := \left(0.5 + \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \lambda_1\right)\right) - 0.5 \cdot \cos \phi_1\\
t_2 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{if}\;\phi_1 \leq -8.5 \cdot 10^{+43}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 1.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 phi1 < -8.5e43 or 1.6000000000000001 < phi1 Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Taylor expanded in lambda2 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-cos.f6431.2
Applied rewrites31.2%
Taylor expanded in lambda2 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lift-cos.f6431.0
Applied rewrites31.0%
if -8.5e43 < phi1 < 1.6000000000000001Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6450.5
Applied rewrites50.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6448.6
Applied rewrites48.6%
Taylor expanded in phi1 around 0
sin-+PI/2-rev39.8
Applied rewrites39.8%
Taylor expanded in phi1 around 0
sin-+PI/2-rev35.8
Applied rewrites35.8%
(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 1.0))))
(if (<= phi1 1.72e-15)
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))
(*
R
(*
2.0
(atan2
(sqrt (fma t_0 (cos phi1) (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 phi1)))))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))))
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 * 1.0);
double tmp;
if (phi1 <= 1.72e-15) {
tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(t_0, cos(phi1), (0.5 - (0.5 * cos((2.0 * (0.5 * phi1))))))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
}
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 * 1.0)) tmp = 0.0 if (phi1 <= 1.72e-15) 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(fma(t_0, cos(phi1), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * phi1))))))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, 1.72e-15], 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[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] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $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 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot 1\\
\mathbf{if}\;\phi_1 \leq 1.72 \cdot 10^{-15}:\\
\;\;\;\;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{\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)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < 1.7199999999999999e-15Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6450.5
Applied rewrites50.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f6448.6
Applied rewrites48.6%
Taylor expanded in phi1 around 0
sin-+PI/2-rev39.8
Applied rewrites39.8%
Taylor expanded in phi1 around 0
sin-+PI/2-rev35.8
Applied rewrites35.8%
if 1.7199999999999999e-15 < phi1 Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Taylor expanded in lambda2 around 0
lower--.f64N/A
lower-fma.f64N/A
Applied rewrites33.2%
Taylor expanded in lambda1 around 0
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-pow.f6424.0
Applied rewrites24.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* 0.5 (- lambda1 lambda2)))
(t_1
(*
R
(*
2.0
(atan2
(sqrt
(fma
(- 0.5 (* 0.5 (cos (* 2.0 t_0))))
(cos phi1)
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 phi1)))))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))
(t_2
(fma
(pow (sin t_0) 2.0)
(+ 1.0 (* -0.5 (* phi1 phi1)))
(* 0.25 (* phi1 phi1)))))
(if (<= phi1 -0.0215)
t_1
(if (<= phi1 1.72e-15)
(* 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 = 0.5 * (lambda1 - lambda2);
double t_1 = R * (2.0 * atan2(sqrt(fma((0.5 - (0.5 * cos((2.0 * t_0)))), cos(phi1), (0.5 - (0.5 * cos((2.0 * (0.5 * phi1))))))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
double t_2 = fma(pow(sin(t_0), 2.0), (1.0 + (-0.5 * (phi1 * phi1))), (0.25 * (phi1 * phi1)));
double tmp;
if (phi1 <= -0.0215) {
tmp = t_1;
} else if (phi1 <= 1.72e-15) {
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(0.5 * Float64(lambda1 - lambda2)) t_1 = Float64(R * Float64(2.0 * atan(sqrt(fma(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_0)))), cos(phi1), Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * phi1))))))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))) t_2 = fma((sin(t_0) ^ 2.0), Float64(1.0 + Float64(-0.5 * Float64(phi1 * phi1))), Float64(0.25 * Float64(phi1 * phi1))) tmp = 0.0 if (phi1 <= -0.0215) tmp = t_1; elseif (phi1 <= 1.72e-15) 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[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 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] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[Sin[t$95$0], $MachinePrecision], 2.0], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.25 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.0215], t$95$1, If[LessEqual[phi1, 1.72e-15], 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 := 0.5 \cdot \left(\lambda_1 - \lambda_2\right)\\
t_1 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_0\right), \cos \phi_1, 0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \phi_1\right)\right)\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
t_2 := \mathsf{fma}\left({\sin t\_0}^{2}, 1 + -0.5 \cdot \left(\phi_1 \cdot \phi_1\right), 0.25 \cdot \left(\phi_1 \cdot \phi_1\right)\right)\\
\mathbf{if}\;\phi_1 \leq -0.0215:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 1.72 \cdot 10^{-15}:\\
\;\;\;\;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 phi1 < -0.021499999999999998 or 1.7199999999999999e-15 < phi1 Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Taylor expanded in lambda2 around 0
lower--.f64N/A
lower-fma.f64N/A
Applied rewrites33.2%
Taylor expanded in lambda1 around 0
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-pow.f6424.0
Applied rewrites24.0%
if -0.021499999999999998 < phi1 < 1.7199999999999999e-15Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Taylor expanded in phi1 around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6429.4
Applied rewrites29.4%
Taylor expanded in phi1 around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6419.8
Applied rewrites19.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6419.8
Applied rewrites19.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6419.8
Applied rewrites19.8%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
sqr-sin-a-revN/A
unpow2N/A
lower-pow.f64N/A
lower-sin.f64N/A
lift--.f64N/A
lift-*.f6422.5
Applied rewrites22.5%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
sqr-sin-a-revN/A
unpow2N/A
lower-pow.f64N/A
lower-sin.f64N/A
lift--.f64N/A
lift-*.f6422.5
Applied rewrites22.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)
(+ 1.0 (* -0.5 (* phi1 phi1)))
(* 0.25 (* phi1 phi1)))))
(* 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(pow(sin((0.5 * (lambda1 - lambda2))), 2.0), (1.0 + (-0.5 * (phi1 * phi1))), (0.25 * (phi1 * phi1)));
return R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma((sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0), Float64(1.0 + Float64(-0.5 * Float64(phi1 * phi1))), Float64(0.25 * Float64(phi1 * phi1))) 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[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.25 * N[(phi1 * phi1), $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({\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, 1 + -0.5 \cdot \left(\phi_1 \cdot \phi_1\right), 0.25 \cdot \left(\phi_1 \cdot \phi_1\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Taylor expanded in phi1 around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6429.4
Applied rewrites29.4%
Taylor expanded in phi1 around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6419.8
Applied rewrites19.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6419.8
Applied rewrites19.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6419.8
Applied rewrites19.8%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
sqr-sin-a-revN/A
unpow2N/A
lower-pow.f64N/A
lower-sin.f64N/A
lift--.f64N/A
lift-*.f6422.5
Applied rewrites22.5%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
sqr-sin-a-revN/A
unpow2N/A
lower-pow.f64N/A
lower-sin.f64N/A
lift--.f64N/A
lift-*.f6422.5
Applied rewrites22.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (+ 1.0 (* -0.5 (* phi1 phi1))))
(t_1 (* 0.25 (* phi1 phi1)))
(t_2 (fma (- 0.5 (* 0.5 (cos lambda2))) t_0 t_1))
(t_3 (fma (- 0.5 (* 0.5 (cos lambda1))) t_0 t_1))
(t_4 (* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- 1.0 t_3)))))))
(if (<= lambda1 -0.112)
t_4
(if (<= lambda1 8.2e-7)
(* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))
t_4))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 1.0 + (-0.5 * (phi1 * phi1));
double t_1 = 0.25 * (phi1 * phi1);
double t_2 = fma((0.5 - (0.5 * cos(lambda2))), t_0, t_1);
double t_3 = fma((0.5 - (0.5 * cos(lambda1))), t_0, t_1);
double t_4 = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3))));
double tmp;
if (lambda1 <= -0.112) {
tmp = t_4;
} else if (lambda1 <= 8.2e-7) {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
} else {
tmp = t_4;
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(1.0 + Float64(-0.5 * Float64(phi1 * phi1))) t_1 = Float64(0.25 * Float64(phi1 * phi1)) t_2 = fma(Float64(0.5 - Float64(0.5 * cos(lambda2))), t_0, t_1) t_3 = fma(Float64(0.5 - Float64(0.5 * cos(lambda1))), t_0, t_1) t_4 = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_3))))) tmp = 0.0 if (lambda1 <= -0.112) tmp = t_4; elseif (lambda1 <= 8.2e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))); else tmp = t_4; end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.25 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(0.5 - N[(0.5 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0 + t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(0.5 - N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0 + t$95$1), $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[lambda1, -0.112], t$95$4, If[LessEqual[lambda1, 8.2e-7], 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$4]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + -0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\\
t_1 := 0.25 \cdot \left(\phi_1 \cdot \phi_1\right)\\
t_2 := \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \lambda_2, t\_0, t\_1\right)\\
t_3 := \mathsf{fma}\left(0.5 - 0.5 \cdot \cos \lambda_1, t\_0, t\_1\right)\\
t_4 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_3}}\right)\\
\mathbf{if}\;\lambda_1 \leq -0.112:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;\lambda_1 \leq 8.2 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
\end{array}
if lambda1 < -0.112000000000000002 or 8.1999999999999998e-7 < lambda1 Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Taylor expanded in phi1 around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6429.4
Applied rewrites29.4%
Taylor expanded in phi1 around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6419.8
Applied rewrites19.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6419.8
Applied rewrites19.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6419.8
Applied rewrites19.8%
Taylor expanded in lambda2 around 0
lower-cos.f6414.0
Applied rewrites14.0%
Taylor expanded in lambda2 around 0
lower-cos.f6413.1
Applied rewrites13.1%
if -0.112000000000000002 < lambda1 < 8.1999999999999998e-7Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Taylor expanded in phi1 around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6429.4
Applied rewrites29.4%
Taylor expanded in phi1 around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6419.8
Applied rewrites19.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6419.8
Applied rewrites19.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6419.8
Applied rewrites19.8%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6413.8
Applied rewrites13.8%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6413.0
Applied rewrites13.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(- 0.5 (* 0.5 (cos (- lambda1 lambda2))))
(+ 1.0 (* -0.5 (* phi1 phi1)))
(* 0.25 (* phi1 phi1)))))
(* 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 - lambda2)))), (1.0 + (-0.5 * (phi1 * phi1))), (0.25 * (phi1 * phi1)));
return R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))), Float64(1.0 + Float64(-0.5 * Float64(phi1 * phi1))), Float64(0.25 * Float64(phi1 * phi1))) 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[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.25 * N[(phi1 * phi1), $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 \left(\lambda_1 - \lambda_2\right), 1 + -0.5 \cdot \left(\phi_1 \cdot \phi_1\right), 0.25 \cdot \left(\phi_1 \cdot \phi_1\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Taylor expanded in phi1 around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6429.4
Applied rewrites29.4%
Taylor expanded in phi1 around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6419.8
Applied rewrites19.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6419.8
Applied rewrites19.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6419.8
Applied rewrites19.8%
Taylor expanded in lambda1 around 0
lift--.f6419.8
Applied rewrites19.8%
Taylor expanded in lambda1 around 0
lift--.f6419.8
Applied rewrites19.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(- 0.5 (* 0.5 (cos lambda1)))
(+ 1.0 (* -0.5 (* phi1 phi1)))
(* 0.25 (* phi1 phi1)))))
(* 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 * (phi1 * phi1))), (0.25 * (phi1 * phi1)));
return R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(Float64(0.5 - Float64(0.5 * cos(lambda1))), Float64(1.0 + Float64(-0.5 * Float64(phi1 * phi1))), Float64(0.25 * Float64(phi1 * phi1))) 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[(0.5 - N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.25 * N[(phi1 * phi1), $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 \cdot \left(\phi_1 \cdot \phi_1\right), 0.25 \cdot \left(\phi_1 \cdot \phi_1\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 61.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-cos.f64N/A
unpow2N/A
sqr-sin-aN/A
Applied rewrites42.9%
Taylor expanded in phi1 around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6429.4
Applied rewrites29.4%
Taylor expanded in phi1 around 0
lower-*.f64N/A
unpow2N/A
lower-*.f6419.8
Applied rewrites19.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6419.8
Applied rewrites19.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6419.8
Applied rewrites19.8%
Taylor expanded in lambda2 around 0
lower-cos.f6414.0
Applied rewrites14.0%
Taylor expanded in lambda2 around 0
lower-cos.f6413.1
Applied rewrites13.1%
herbie shell --seed 2025138
(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))))))))))