
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0))))) (* R (sqrt (+ (* t_0 t_0) (* (- phi1 phi2) (- phi1 phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0));
return R * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0d0))
code = r * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * Math.cos(((phi1 + phi2) / 2.0));
return R * Math.sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (lambda1 - lambda2) * math.cos(((phi1 + phi2) / 2.0)) return R * math.sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) * cos(Float64(Float64(phi1 + phi2) / 2.0))) return Float64(R * sqrt(Float64(Float64(t_0 * t_0) + Float64(Float64(phi1 - phi2) * Float64(phi1 - phi2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0)); tmp = R * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(N[(phi1 + phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(R * N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] + N[(N[(phi1 - phi2), $MachinePrecision] * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\\
R \cdot \sqrt{t\_0 \cdot t\_0 + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}
\end{array}
\end{array}
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0))))) (* R (sqrt (+ (* t_0 t_0) (* (- phi1 phi2) (- phi1 phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0));
return R * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0d0))
code = r * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * Math.cos(((phi1 + phi2) / 2.0));
return R * Math.sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (lambda1 - lambda2) * math.cos(((phi1 + phi2) / 2.0)) return R * math.sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) * cos(Float64(Float64(phi1 + phi2) / 2.0))) return Float64(R * sqrt(Float64(Float64(t_0 * t_0) + Float64(Float64(phi1 - phi2) * Float64(phi1 - phi2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0)); tmp = R * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(N[(phi1 + phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(R * N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] + N[(N[(phi1 - phi2), $MachinePrecision] * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\\
R \cdot \sqrt{t\_0 \cdot t\_0 + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (hypot (- phi1 phi2) (* (cos (/ (+ phi2 phi1) 2.0)) (- lambda1 lambda2))) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return hypot((phi1 - phi2), (cos(((phi2 + phi1) / 2.0)) * (lambda1 - lambda2))) * R;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.hypot((phi1 - phi2), (Math.cos(((phi2 + phi1) / 2.0)) * (lambda1 - lambda2))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.hypot((phi1 - phi2), (math.cos(((phi2 + phi1) / 2.0)) * (lambda1 - lambda2))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(hypot(Float64(phi1 - phi2), Float64(cos(Float64(Float64(phi2 + phi1) / 2.0)) * Float64(lambda1 - lambda2))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = hypot((phi1 - phi2), (cos(((phi2 + phi1) / 2.0)) * (lambda1 - lambda2))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[Sqrt[N[(phi1 - phi2), $MachinePrecision] ^ 2 + N[(N[Cos[N[(N[(phi2 + phi1), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{hypot}\left(\phi_1 - \phi_2, \cos \left(\frac{\phi_2 + \phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Initial program 59.9%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites96.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -1.68e-18) (* (hypot (- phi1 phi2) (* (cos (* 0.5 phi1)) (- lambda1 lambda2))) R) (* (hypot (- phi2) (* (cos (* 0.5 phi2)) (- lambda1 lambda2))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -1.68e-18) {
tmp = hypot((phi1 - phi2), (cos((0.5 * phi1)) * (lambda1 - lambda2))) * R;
} else {
tmp = hypot(-phi2, (cos((0.5 * phi2)) * (lambda1 - lambda2))) * R;
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -1.68e-18) {
tmp = Math.hypot((phi1 - phi2), (Math.cos((0.5 * phi1)) * (lambda1 - lambda2))) * R;
} else {
tmp = Math.hypot(-phi2, (Math.cos((0.5 * phi2)) * (lambda1 - lambda2))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -1.68e-18: tmp = math.hypot((phi1 - phi2), (math.cos((0.5 * phi1)) * (lambda1 - lambda2))) * R else: tmp = math.hypot(-phi2, (math.cos((0.5 * phi2)) * (lambda1 - lambda2))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -1.68e-18) tmp = Float64(hypot(Float64(phi1 - phi2), Float64(cos(Float64(0.5 * phi1)) * Float64(lambda1 - lambda2))) * R); else tmp = Float64(hypot(Float64(-phi2), Float64(cos(Float64(0.5 * phi2)) * Float64(lambda1 - lambda2))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -1.68e-18) tmp = hypot((phi1 - phi2), (cos((0.5 * phi1)) * (lambda1 - lambda2))) * R; else tmp = hypot(-phi2, (cos((0.5 * phi2)) * (lambda1 - lambda2))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -1.68e-18], N[(N[Sqrt[N[(phi1 - phi2), $MachinePrecision] ^ 2 + N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision], N[(N[Sqrt[(-phi2) ^ 2 + N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -1.68 \cdot 10^{-18}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_1 - \phi_2, \cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(-\phi_2, \cos \left(0.5 \cdot \phi_2\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -1.6799999999999999e-18Initial program 59.9%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites96.0%
Taylor expanded in phi1 around inf
lower-*.f6490.3
Applied rewrites90.3%
if -1.6799999999999999e-18 < phi1 Initial program 59.9%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites96.0%
Taylor expanded in phi1 around 0
lower-*.f6490.8
Applied rewrites90.8%
Taylor expanded in phi1 around 0
mul-1-negN/A
lift-neg.f6470.9
Applied rewrites70.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -2.2e+34) (* R (* phi1 (- (/ phi2 phi1) 1.0))) (* (hypot (- phi2) (* (cos (* 0.5 phi2)) (- lambda1 lambda2))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -2.2e+34) {
tmp = R * (phi1 * ((phi2 / phi1) - 1.0));
} else {
tmp = hypot(-phi2, (cos((0.5 * phi2)) * (lambda1 - lambda2))) * R;
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -2.2e+34) {
tmp = R * (phi1 * ((phi2 / phi1) - 1.0));
} else {
tmp = Math.hypot(-phi2, (Math.cos((0.5 * phi2)) * (lambda1 - lambda2))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -2.2e+34: tmp = R * (phi1 * ((phi2 / phi1) - 1.0)) else: tmp = math.hypot(-phi2, (math.cos((0.5 * phi2)) * (lambda1 - lambda2))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -2.2e+34) tmp = Float64(R * Float64(phi1 * Float64(Float64(phi2 / phi1) - 1.0))); else tmp = Float64(hypot(Float64(-phi2), Float64(cos(Float64(0.5 * phi2)) * Float64(lambda1 - lambda2))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -2.2e+34) tmp = R * (phi1 * ((phi2 / phi1) - 1.0)); else tmp = hypot(-phi2, (cos((0.5 * phi2)) * (lambda1 - lambda2))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -2.2e+34], N[(R * N[(phi1 * N[(N[(phi2 / phi1), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[(-phi2) ^ 2 + N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -2.2 \cdot 10^{+34}:\\
\;\;\;\;R \cdot \left(\phi_1 \cdot \left(\frac{\phi_2}{\phi_1} - 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(-\phi_2, \cos \left(0.5 \cdot \phi_2\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -2.2000000000000002e34Initial program 59.9%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites96.0%
Taylor expanded in phi1 around 0
lower-*.f6490.8
Applied rewrites90.8%
Taylor expanded in phi1 around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
associate-*r/N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6429.0
Applied rewrites29.0%
Taylor expanded in R around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6427.1
Applied rewrites27.1%
if -2.2000000000000002e34 < phi1 Initial program 59.9%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites96.0%
Taylor expanded in phi1 around 0
lower-*.f6490.8
Applied rewrites90.8%
Taylor expanded in phi1 around 0
mul-1-negN/A
lift-neg.f6470.9
Applied rewrites70.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sqrt (+ 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (+ phi2 phi1)))))))))
(if (<= lambda2 -5.5e-87)
(- (* (* t_0 lambda1) R))
(if (<= lambda2 6.5e+77)
(fma -1.0 (* R phi1) (* R phi2))
(* R (* t_0 lambda2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt((0.5 + (0.5 * cos((2.0 * (0.5 * (phi2 + phi1)))))));
double tmp;
if (lambda2 <= -5.5e-87) {
tmp = -((t_0 * lambda1) * R);
} else if (lambda2 <= 6.5e+77) {
tmp = fma(-1.0, (R * phi1), (R * phi2));
} else {
tmp = R * (t_0 * lambda2);
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64(0.5 + Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi2 + phi1))))))) tmp = 0.0 if (lambda2 <= -5.5e-87) tmp = Float64(-Float64(Float64(t_0 * lambda1) * R)); elseif (lambda2 <= 6.5e+77) tmp = fma(-1.0, Float64(R * phi1), Float64(R * phi2)); else tmp = Float64(R * Float64(t_0 * lambda2)); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[(0.5 + N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi2 + phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -5.5e-87], (-N[(N[(t$95$0 * lambda1), $MachinePrecision] * R), $MachinePrecision]), If[LessEqual[lambda2, 6.5e+77], N[(-1.0 * N[(R * phi1), $MachinePrecision] + N[(R * phi2), $MachinePrecision]), $MachinePrecision], N[(R * N[(t$95$0 * lambda2), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{0.5 + 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)}\\
\mathbf{if}\;\lambda_2 \leq -5.5 \cdot 10^{-87}:\\
\;\;\;\;-\left(t\_0 \cdot \lambda_1\right) \cdot R\\
\mathbf{elif}\;\lambda_2 \leq 6.5 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(-1, R \cdot \phi_1, R \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(t\_0 \cdot \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < -5.5000000000000004e-87Initial program 59.9%
Taylor expanded in lambda1 around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites16.3%
if -5.5000000000000004e-87 < lambda2 < 6.5e77Initial program 59.9%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6429.5
Applied rewrites29.5%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6428.7
Applied rewrites28.7%
if 6.5e77 < lambda2 Initial program 59.9%
Taylor expanded in lambda2 around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
unpow2N/A
sqr-cos-aN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6416.9
Applied rewrites16.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda2 -3.05e-49)
(* R (sqrt (* (* lambda1 lambda1) (- 0.5 (* -0.5 (cos phi1))))))
(if (<= lambda2 6.5e+77)
(fma -1.0 (* R phi1) (* R phi2))
(*
R
(*
(sqrt (+ 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (+ phi2 phi1)))))))
lambda2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= -3.05e-49) {
tmp = R * sqrt(((lambda1 * lambda1) * (0.5 - (-0.5 * cos(phi1)))));
} else if (lambda2 <= 6.5e+77) {
tmp = fma(-1.0, (R * phi1), (R * phi2));
} else {
tmp = R * (sqrt((0.5 + (0.5 * cos((2.0 * (0.5 * (phi2 + phi1))))))) * lambda2);
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= -3.05e-49) tmp = Float64(R * sqrt(Float64(Float64(lambda1 * lambda1) * Float64(0.5 - Float64(-0.5 * cos(phi1)))))); elseif (lambda2 <= 6.5e+77) tmp = fma(-1.0, Float64(R * phi1), Float64(R * phi2)); else tmp = Float64(R * Float64(sqrt(Float64(0.5 + Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi2 + phi1))))))) * lambda2)); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, -3.05e-49], N[(R * N[Sqrt[N[(N[(lambda1 * lambda1), $MachinePrecision] * N[(0.5 - N[(-0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 6.5e+77], N[(-1.0 * N[(R * phi1), $MachinePrecision] + N[(R * phi2), $MachinePrecision]), $MachinePrecision], N[(R * N[(N[Sqrt[N[(0.5 + N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi2 + phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * lambda2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -3.05 \cdot 10^{-49}:\\
\;\;\;\;R \cdot \sqrt{\left(\lambda_1 \cdot \lambda_1\right) \cdot \left(0.5 - -0.5 \cdot \cos \phi_1\right)}\\
\mathbf{elif}\;\lambda_2 \leq 6.5 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(-1, R \cdot \phi_1, R \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\sqrt{0.5 + 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right)\right)} \cdot \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < -3.04999999999999982e-49Initial program 59.9%
Taylor expanded in phi2 around 0
lower-fma.f64N/A
unpow2N/A
sqr-cos-aN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift--.f64N/A
lift--.f64N/A
unpow2N/A
lower-*.f6448.8
Applied rewrites48.8%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f6422.7
Applied rewrites22.7%
if -3.04999999999999982e-49 < lambda2 < 6.5e77Initial program 59.9%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6429.5
Applied rewrites29.5%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6428.7
Applied rewrites28.7%
if 6.5e77 < lambda2 Initial program 59.9%
Taylor expanded in lambda2 around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
unpow2N/A
sqr-cos-aN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6416.9
Applied rewrites16.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -4.2e-298)
(* R (- phi1))
(if (<= phi2 1.95e+33)
(* R (sqrt (* (- lambda1 lambda2) (- lambda1 lambda2))))
(* R (* (+ (/ (- phi1) phi2) 1.0) phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -4.2e-298) {
tmp = R * -phi1;
} else if (phi2 <= 1.95e+33) {
tmp = R * sqrt(((lambda1 - lambda2) * (lambda1 - lambda2)));
} else {
tmp = R * (((-phi1 / phi2) + 1.0) * phi2);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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) :: tmp
if (phi2 <= (-4.2d-298)) then
tmp = r * -phi1
else if (phi2 <= 1.95d+33) then
tmp = r * sqrt(((lambda1 - lambda2) * (lambda1 - lambda2)))
else
tmp = r * (((-phi1 / phi2) + 1.0d0) * phi2)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -4.2e-298) {
tmp = R * -phi1;
} else if (phi2 <= 1.95e+33) {
tmp = R * Math.sqrt(((lambda1 - lambda2) * (lambda1 - lambda2)));
} else {
tmp = R * (((-phi1 / phi2) + 1.0) * phi2);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -4.2e-298: tmp = R * -phi1 elif phi2 <= 1.95e+33: tmp = R * math.sqrt(((lambda1 - lambda2) * (lambda1 - lambda2))) else: tmp = R * (((-phi1 / phi2) + 1.0) * phi2) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -4.2e-298) tmp = Float64(R * Float64(-phi1)); elseif (phi2 <= 1.95e+33) tmp = Float64(R * sqrt(Float64(Float64(lambda1 - lambda2) * Float64(lambda1 - lambda2)))); else tmp = Float64(R * Float64(Float64(Float64(Float64(-phi1) / phi2) + 1.0) * phi2)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -4.2e-298) tmp = R * -phi1; elseif (phi2 <= 1.95e+33) tmp = R * sqrt(((lambda1 - lambda2) * (lambda1 - lambda2))); else tmp = R * (((-phi1 / phi2) + 1.0) * phi2); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -4.2e-298], N[(R * (-phi1)), $MachinePrecision], If[LessEqual[phi2, 1.95e+33], N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(N[(N[((-phi1) / phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -4.2 \cdot 10^{-298}:\\
\;\;\;\;R \cdot \left(-\phi_1\right)\\
\mathbf{elif}\;\phi_2 \leq 1.95 \cdot 10^{+33}:\\
\;\;\;\;R \cdot \sqrt{\left(\lambda_1 - \lambda_2\right) \cdot \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\left(\frac{-\phi_1}{\phi_2} + 1\right) \cdot \phi_2\right)\\
\end{array}
\end{array}
if phi2 < -4.2000000000000001e-298Initial program 59.9%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f6417.7
Applied rewrites17.7%
if -4.2000000000000001e-298 < phi2 < 1.9500000000000001e33Initial program 59.9%
Taylor expanded in phi2 around 0
lower-fma.f64N/A
unpow2N/A
sqr-cos-aN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift--.f64N/A
lift--.f64N/A
unpow2N/A
lower-*.f6448.8
Applied rewrites48.8%
Taylor expanded in phi1 around 0
pow2N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f6435.8
Applied rewrites35.8%
if 1.9500000000000001e33 < phi2 Initial program 59.9%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6427.2
Applied rewrites27.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -4.2e-298)
(* R (- phi1))
(if (<= phi2 1.95e+33)
(* R (sqrt (* (- lambda1 lambda2) (- lambda1 lambda2))))
(* (+ (/ (- (* phi1 R)) phi2) R) phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -4.2e-298) {
tmp = R * -phi1;
} else if (phi2 <= 1.95e+33) {
tmp = R * sqrt(((lambda1 - lambda2) * (lambda1 - lambda2)));
} else {
tmp = ((-(phi1 * R) / phi2) + R) * phi2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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) :: tmp
if (phi2 <= (-4.2d-298)) then
tmp = r * -phi1
else if (phi2 <= 1.95d+33) then
tmp = r * sqrt(((lambda1 - lambda2) * (lambda1 - lambda2)))
else
tmp = ((-(phi1 * r) / phi2) + r) * phi2
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -4.2e-298) {
tmp = R * -phi1;
} else if (phi2 <= 1.95e+33) {
tmp = R * Math.sqrt(((lambda1 - lambda2) * (lambda1 - lambda2)));
} else {
tmp = ((-(phi1 * R) / phi2) + R) * phi2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -4.2e-298: tmp = R * -phi1 elif phi2 <= 1.95e+33: tmp = R * math.sqrt(((lambda1 - lambda2) * (lambda1 - lambda2))) else: tmp = ((-(phi1 * R) / phi2) + R) * phi2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -4.2e-298) tmp = Float64(R * Float64(-phi1)); elseif (phi2 <= 1.95e+33) tmp = Float64(R * sqrt(Float64(Float64(lambda1 - lambda2) * Float64(lambda1 - lambda2)))); else tmp = Float64(Float64(Float64(Float64(-Float64(phi1 * R)) / phi2) + R) * phi2); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -4.2e-298) tmp = R * -phi1; elseif (phi2 <= 1.95e+33) tmp = R * sqrt(((lambda1 - lambda2) * (lambda1 - lambda2))); else tmp = ((-(phi1 * R) / phi2) + R) * phi2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -4.2e-298], N[(R * (-phi1)), $MachinePrecision], If[LessEqual[phi2, 1.95e+33], N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[((-N[(phi1 * R), $MachinePrecision]) / phi2), $MachinePrecision] + R), $MachinePrecision] * phi2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -4.2 \cdot 10^{-298}:\\
\;\;\;\;R \cdot \left(-\phi_1\right)\\
\mathbf{elif}\;\phi_2 \leq 1.95 \cdot 10^{+33}:\\
\;\;\;\;R \cdot \sqrt{\left(\lambda_1 - \lambda_2\right) \cdot \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{-\phi_1 \cdot R}{\phi_2} + R\right) \cdot \phi_2\\
\end{array}
\end{array}
if phi2 < -4.2000000000000001e-298Initial program 59.9%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f6417.7
Applied rewrites17.7%
if -4.2000000000000001e-298 < phi2 < 1.9500000000000001e33Initial program 59.9%
Taylor expanded in phi2 around 0
lower-fma.f64N/A
unpow2N/A
sqr-cos-aN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift--.f64N/A
lift--.f64N/A
unpow2N/A
lower-*.f6448.8
Applied rewrites48.8%
Taylor expanded in phi1 around 0
pow2N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f6435.8
Applied rewrites35.8%
if 1.9500000000000001e33 < phi2 Initial program 59.9%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6429.5
Applied rewrites29.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -4.2e-298)
(* R (- phi1))
(if (<= phi2 1.95e+33)
(* R (sqrt (* (- lambda1 lambda2) (- lambda1 lambda2))))
(fma -1.0 (* R phi1) (* R phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -4.2e-298) {
tmp = R * -phi1;
} else if (phi2 <= 1.95e+33) {
tmp = R * sqrt(((lambda1 - lambda2) * (lambda1 - lambda2)));
} else {
tmp = fma(-1.0, (R * phi1), (R * phi2));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -4.2e-298) tmp = Float64(R * Float64(-phi1)); elseif (phi2 <= 1.95e+33) tmp = Float64(R * sqrt(Float64(Float64(lambda1 - lambda2) * Float64(lambda1 - lambda2)))); else tmp = fma(-1.0, Float64(R * phi1), Float64(R * phi2)); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -4.2e-298], N[(R * (-phi1)), $MachinePrecision], If[LessEqual[phi2, 1.95e+33], N[(R * N[Sqrt[N[(N[(lambda1 - lambda2), $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(R * phi1), $MachinePrecision] + N[(R * phi2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -4.2 \cdot 10^{-298}:\\
\;\;\;\;R \cdot \left(-\phi_1\right)\\
\mathbf{elif}\;\phi_2 \leq 1.95 \cdot 10^{+33}:\\
\;\;\;\;R \cdot \sqrt{\left(\lambda_1 - \lambda_2\right) \cdot \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, R \cdot \phi_1, R \cdot \phi_2\right)\\
\end{array}
\end{array}
if phi2 < -4.2000000000000001e-298Initial program 59.9%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f6417.7
Applied rewrites17.7%
if -4.2000000000000001e-298 < phi2 < 1.9500000000000001e33Initial program 59.9%
Taylor expanded in phi2 around 0
lower-fma.f64N/A
unpow2N/A
sqr-cos-aN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift--.f64N/A
lift--.f64N/A
unpow2N/A
lower-*.f6448.8
Applied rewrites48.8%
Taylor expanded in phi1 around 0
pow2N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f6435.8
Applied rewrites35.8%
if 1.9500000000000001e33 < phi2 Initial program 59.9%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6429.5
Applied rewrites29.5%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6428.7
Applied rewrites28.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 2.4e+146) (fma -1.0 (* R phi1) (* R phi2)) (* R (* (sqrt (+ 0.5 0.5)) lambda2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 2.4e+146) {
tmp = fma(-1.0, (R * phi1), (R * phi2));
} else {
tmp = R * (sqrt((0.5 + 0.5)) * lambda2);
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 2.4e+146) tmp = fma(-1.0, Float64(R * phi1), Float64(R * phi2)); else tmp = Float64(R * Float64(sqrt(Float64(0.5 + 0.5)) * lambda2)); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 2.4e+146], N[(-1.0 * N[(R * phi1), $MachinePrecision] + N[(R * phi2), $MachinePrecision]), $MachinePrecision], N[(R * N[(N[Sqrt[N[(0.5 + 0.5), $MachinePrecision]], $MachinePrecision] * lambda2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 2.4 \cdot 10^{+146}:\\
\;\;\;\;\mathsf{fma}\left(-1, R \cdot \phi_1, R \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\sqrt{0.5 + 0.5} \cdot \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < 2.4000000000000002e146Initial program 59.9%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6429.5
Applied rewrites29.5%
Taylor expanded in phi1 around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6428.7
Applied rewrites28.7%
if 2.4000000000000002e146 < lambda2 Initial program 59.9%
Taylor expanded in lambda2 around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
unpow2N/A
sqr-cos-aN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6416.9
Applied rewrites16.9%
Taylor expanded in phi2 around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f6414.1
Applied rewrites14.1%
Taylor expanded in phi1 around 0
Applied rewrites14.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 2.8e-242) (* R (- phi1)) (if (<= phi2 6e+37) (* R (* (sqrt (+ 0.5 0.5)) lambda2)) (* phi2 R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 2.8e-242) {
tmp = R * -phi1;
} else if (phi2 <= 6e+37) {
tmp = R * (sqrt((0.5 + 0.5)) * lambda2);
} else {
tmp = phi2 * R;
}
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) :: tmp
if (phi2 <= 2.8d-242) then
tmp = r * -phi1
else if (phi2 <= 6d+37) then
tmp = r * (sqrt((0.5d0 + 0.5d0)) * lambda2)
else
tmp = phi2 * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 2.8e-242) {
tmp = R * -phi1;
} else if (phi2 <= 6e+37) {
tmp = R * (Math.sqrt((0.5 + 0.5)) * lambda2);
} else {
tmp = phi2 * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 2.8e-242: tmp = R * -phi1 elif phi2 <= 6e+37: tmp = R * (math.sqrt((0.5 + 0.5)) * lambda2) else: tmp = phi2 * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 2.8e-242) tmp = Float64(R * Float64(-phi1)); elseif (phi2 <= 6e+37) tmp = Float64(R * Float64(sqrt(Float64(0.5 + 0.5)) * lambda2)); else tmp = Float64(phi2 * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 2.8e-242) tmp = R * -phi1; elseif (phi2 <= 6e+37) tmp = R * (sqrt((0.5 + 0.5)) * lambda2); else tmp = phi2 * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 2.8e-242], N[(R * (-phi1)), $MachinePrecision], If[LessEqual[phi2, 6e+37], N[(R * N[(N[Sqrt[N[(0.5 + 0.5), $MachinePrecision]], $MachinePrecision] * lambda2), $MachinePrecision]), $MachinePrecision], N[(phi2 * R), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 2.8 \cdot 10^{-242}:\\
\;\;\;\;R \cdot \left(-\phi_1\right)\\
\mathbf{elif}\;\phi_2 \leq 6 \cdot 10^{+37}:\\
\;\;\;\;R \cdot \left(\sqrt{0.5 + 0.5} \cdot \lambda_2\right)\\
\mathbf{else}:\\
\;\;\;\;\phi_2 \cdot R\\
\end{array}
\end{array}
if phi2 < 2.79999999999999983e-242Initial program 59.9%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f6417.7
Applied rewrites17.7%
if 2.79999999999999983e-242 < phi2 < 6.00000000000000043e37Initial program 59.9%
Taylor expanded in lambda2 around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
unpow2N/A
sqr-cos-aN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6416.9
Applied rewrites16.9%
Taylor expanded in phi2 around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f6414.1
Applied rewrites14.1%
Taylor expanded in phi1 around 0
Applied rewrites14.3%
if 6.00000000000000043e37 < phi2 Initial program 59.9%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f6417.3
Applied rewrites17.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -5.8e-22) (* R (- phi1)) (* phi2 R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -5.8e-22) {
tmp = R * -phi1;
} else {
tmp = phi2 * R;
}
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) :: tmp
if (phi1 <= (-5.8d-22)) then
tmp = r * -phi1
else
tmp = phi2 * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -5.8e-22) {
tmp = R * -phi1;
} else {
tmp = phi2 * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -5.8e-22: tmp = R * -phi1 else: tmp = phi2 * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -5.8e-22) tmp = Float64(R * Float64(-phi1)); else tmp = Float64(phi2 * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -5.8e-22) tmp = R * -phi1; else tmp = phi2 * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -5.8e-22], N[(R * (-phi1)), $MachinePrecision], N[(phi2 * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -5.8 \cdot 10^{-22}:\\
\;\;\;\;R \cdot \left(-\phi_1\right)\\
\mathbf{else}:\\
\;\;\;\;\phi_2 \cdot R\\
\end{array}
\end{array}
if phi1 < -5.8000000000000003e-22Initial program 59.9%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f6417.7
Applied rewrites17.7%
if -5.8000000000000003e-22 < phi1 Initial program 59.9%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f6417.3
Applied rewrites17.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 -6.6e-305) (- (* phi2 R)) (* phi2 R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -6.6e-305) {
tmp = -(phi2 * R);
} else {
tmp = phi2 * R;
}
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) :: tmp
if (phi2 <= (-6.6d-305)) then
tmp = -(phi2 * r)
else
tmp = phi2 * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -6.6e-305) {
tmp = -(phi2 * R);
} else {
tmp = phi2 * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -6.6e-305: tmp = -(phi2 * R) else: tmp = phi2 * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -6.6e-305) tmp = Float64(-Float64(phi2 * R)); else tmp = Float64(phi2 * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -6.6e-305) tmp = -(phi2 * R); else tmp = phi2 * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -6.6e-305], (-N[(phi2 * R), $MachinePrecision]), N[(phi2 * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -6.6 \cdot 10^{-305}:\\
\;\;\;\;-\phi_2 \cdot R\\
\mathbf{else}:\\
\;\;\;\;\phi_2 \cdot R\\
\end{array}
\end{array}
if phi2 < -6.59999999999999965e-305Initial program 59.9%
Taylor expanded in phi2 around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6417.9
Applied rewrites17.9%
if -6.59999999999999965e-305 < phi2 Initial program 59.9%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f6417.3
Applied rewrites17.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* phi2 R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return phi2 * R;
}
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
code = phi2 * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return phi2 * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return phi2 * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(phi2 * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = phi2 * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(phi2 * R), $MachinePrecision]
\begin{array}{l}
\\
\phi_2 \cdot R
\end{array}
Initial program 59.9%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f6417.3
Applied rewrites17.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* phi1 R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return phi1 * R;
}
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
code = phi1 * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return phi1 * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return phi1 * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(phi1 * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = phi1 * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(phi1 * R), $MachinePrecision]
\begin{array}{l}
\\
\phi_1 \cdot R
\end{array}
Initial program 59.9%
Taylor expanded in phi1 around inf
*-commutativeN/A
lower-*.f6417.5
Applied rewrites17.5%
herbie shell --seed 2025138
(FPCore (R lambda1 lambda2 phi1 phi2)
:name "Equirectangular approximation to distance on a great circle"
:precision binary64
(* R (sqrt (+ (* (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0))) (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0)))) (* (- phi1 phi2) (- phi1 phi2))))))