
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y - z) * (t - x))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
def code(x, y, z, t): return x + ((y - z) * (t - x))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - z) * Float64(t - x))) end
function tmp = code(x, y, z, t) tmp = x + ((y - z) * (t - x)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y - z) * (t - x))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
def code(x, y, z, t): return x + ((y - z) * (t - x))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - z) * Float64(t - x))) end
function tmp = code(x, y, z, t) tmp = x + ((y - z) * (t - x)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y - z) * (t - x))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
def code(x, y, z, t): return x + ((y - z) * (t - x))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - z) * Float64(t - x))) end
function tmp = code(x, y, z, t) tmp = x + ((y - z) * (t - x)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}
Initial program 100.0%
(FPCore (x y z t)
:precision binary64
(if (<= z -520.0)
(* z x)
(if (<= z -2.7e-146)
x
(if (<= z -8e-249)
(* y t)
(if (<= z 1.25e-137) x (if (<= z 2800000000000.0) (* y t) (* z x)))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -520.0) {
tmp = z * x;
} else if (z <= -2.7e-146) {
tmp = x;
} else if (z <= -8e-249) {
tmp = y * t;
} else if (z <= 1.25e-137) {
tmp = x;
} else if (z <= 2800000000000.0) {
tmp = y * t;
} else {
tmp = z * x;
}
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-520.0d0)) then
tmp = z * x
else if (z <= (-2.7d-146)) then
tmp = x
else if (z <= (-8d-249)) then
tmp = y * t
else if (z <= 1.25d-137) then
tmp = x
else if (z <= 2800000000000.0d0) then
tmp = y * t
else
tmp = z * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -520.0) {
tmp = z * x;
} else if (z <= -2.7e-146) {
tmp = x;
} else if (z <= -8e-249) {
tmp = y * t;
} else if (z <= 1.25e-137) {
tmp = x;
} else if (z <= 2800000000000.0) {
tmp = y * t;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -520.0: tmp = z * x elif z <= -2.7e-146: tmp = x elif z <= -8e-249: tmp = y * t elif z <= 1.25e-137: tmp = x elif z <= 2800000000000.0: tmp = y * t else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -520.0) tmp = Float64(z * x); elseif (z <= -2.7e-146) tmp = x; elseif (z <= -8e-249) tmp = Float64(y * t); elseif (z <= 1.25e-137) tmp = x; elseif (z <= 2800000000000.0) tmp = Float64(y * t); else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -520.0) tmp = z * x; elseif (z <= -2.7e-146) tmp = x; elseif (z <= -8e-249) tmp = y * t; elseif (z <= 1.25e-137) tmp = x; elseif (z <= 2800000000000.0) tmp = y * t; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -520.0], N[(z * x), $MachinePrecision], If[LessEqual[z, -2.7e-146], x, If[LessEqual[z, -8e-249], N[(y * t), $MachinePrecision], If[LessEqual[z, 1.25e-137], x, If[LessEqual[z, 2800000000000.0], N[(y * t), $MachinePrecision], N[(z * x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -520:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq -2.7 \cdot 10^{-146}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq -8 \cdot 10^{-249}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{-137}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 2800000000000:\\
\;\;\;\;y \cdot t\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -520 or 2.8e12 < z Initial program 100.0%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6478.8
Applied rewrites78.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6442.0
Applied rewrites42.0%
if -520 < z < -2.69999999999999995e-146 or -8.00000000000000043e-249 < z < 1.25e-137Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6491.3
Applied rewrites91.3%
Taylor expanded in y around 0
Applied rewrites33.9%
if -2.69999999999999995e-146 < z < -8.00000000000000043e-249 or 1.25e-137 < z < 2.8e12Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6447.2
Applied rewrites47.2%
Taylor expanded in y around inf
Applied rewrites34.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (- t x) y x)))
(if (<= y -7.1e-25)
t_1
(if (<= y 1.2e-119)
(fma (- z) t x)
(if (<= y 2.05e+79) (fma z x x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = fma((t - x), y, x);
double tmp;
if (y <= -7.1e-25) {
tmp = t_1;
} else if (y <= 1.2e-119) {
tmp = fma(-z, t, x);
} else if (y <= 2.05e+79) {
tmp = fma(z, x, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(t - x), y, x) tmp = 0.0 if (y <= -7.1e-25) tmp = t_1; elseif (y <= 1.2e-119) tmp = fma(Float64(-z), t, x); elseif (y <= 2.05e+79) tmp = fma(z, x, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[y, -7.1e-25], t$95$1, If[LessEqual[y, 1.2e-119], N[((-z) * t + x), $MachinePrecision], If[LessEqual[y, 2.05e+79], N[(z * x + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{if}\;y \leq -7.1 \cdot 10^{-25}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-119}:\\
\;\;\;\;\mathsf{fma}\left(-z, t, x\right)\\
\mathbf{elif}\;y \leq 2.05 \cdot 10^{+79}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -7.1000000000000001e-25 or 2.05e79 < y Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6480.0
Applied rewrites80.0%
if -7.1000000000000001e-25 < y < 1.20000000000000004e-119Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6492.8
Applied rewrites92.8%
Taylor expanded in x around 0
Applied rewrites69.3%
if 1.20000000000000004e-119 < y < 2.05e79Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6468.5
Applied rewrites68.5%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6442.8
Applied rewrites42.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- t x) y)))
(if (<= y -2.05e-29)
t_1
(if (<= y 1.2e-119)
(fma (- z) t x)
(if (<= y 2.05e+79) (fma z x x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = (t - x) * y;
double tmp;
if (y <= -2.05e-29) {
tmp = t_1;
} else if (y <= 1.2e-119) {
tmp = fma(-z, t, x);
} else if (y <= 2.05e+79) {
tmp = fma(z, x, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(t - x) * y) tmp = 0.0 if (y <= -2.05e-29) tmp = t_1; elseif (y <= 1.2e-119) tmp = fma(Float64(-z), t, x); elseif (y <= 2.05e+79) tmp = fma(z, x, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -2.05e-29], t$95$1, If[LessEqual[y, 1.2e-119], N[((-z) * t + x), $MachinePrecision], If[LessEqual[y, 2.05e+79], N[(z * x + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot y\\
\mathbf{if}\;y \leq -2.05 \cdot 10^{-29}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-119}:\\
\;\;\;\;\mathsf{fma}\left(-z, t, x\right)\\
\mathbf{elif}\;y \leq 2.05 \cdot 10^{+79}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -2.0499999999999999e-29 or 2.05e79 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6477.8
Applied rewrites77.8%
if -2.0499999999999999e-29 < y < 1.20000000000000004e-119Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6493.0
Applied rewrites93.0%
Taylor expanded in x around 0
Applied rewrites69.7%
if 1.20000000000000004e-119 < y < 2.05e79Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6468.5
Applied rewrites68.5%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6442.8
Applied rewrites42.8%
(FPCore (x y z t)
:precision binary64
(if (<= z -3.6e+91)
(* z x)
(if (<= z 4.4e-16)
(fma t y x)
(if (<= z 1.65e+93) (fma z x x) (* (- z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.6e+91) {
tmp = z * x;
} else if (z <= 4.4e-16) {
tmp = fma(t, y, x);
} else if (z <= 1.65e+93) {
tmp = fma(z, x, x);
} else {
tmp = -z * t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -3.6e+91) tmp = Float64(z * x); elseif (z <= 4.4e-16) tmp = fma(t, y, x); elseif (z <= 1.65e+93) tmp = fma(z, x, x); else tmp = Float64(Float64(-z) * t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.6e+91], N[(z * x), $MachinePrecision], If[LessEqual[z, 4.4e-16], N[(t * y + x), $MachinePrecision], If[LessEqual[z, 1.65e+93], N[(z * x + x), $MachinePrecision], N[((-z) * t), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6 \cdot 10^{+91}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq 4.4 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{+93}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) \cdot t\\
\end{array}
\end{array}
if z < -3.6e91Initial program 100.0%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6486.5
Applied rewrites86.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6446.5
Applied rewrites46.5%
if -3.6e91 < z < 4.40000000000000001e-16Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6484.7
Applied rewrites84.7%
Taylor expanded in x around 0
Applied rewrites60.9%
if 4.40000000000000001e-16 < z < 1.65000000000000004e93Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6460.1
Applied rewrites60.1%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6430.1
Applied rewrites30.1%
if 1.65000000000000004e93 < z Initial program 100.0%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6486.3
Applied rewrites86.3%
Taylor expanded in x around 0
Applied rewrites46.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (- z) (- t x) x))) (if (<= z -4.8e-10) t_1 (if (<= z 0.78) (fma (- t x) y x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(-z, (t - x), x);
double tmp;
if (z <= -4.8e-10) {
tmp = t_1;
} else if (z <= 0.78) {
tmp = fma((t - x), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(-z), Float64(t - x), x) tmp = 0.0 if (z <= -4.8e-10) tmp = t_1; elseif (z <= 0.78) tmp = fma(Float64(t - x), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-z) * N[(t - x), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -4.8e-10], t$95$1, If[LessEqual[z, 0.78], N[(N[(t - x), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(-z, t - x, x\right)\\
\mathbf{if}\;z \leq -4.8 \cdot 10^{-10}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 0.78:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.8e-10 or 0.78000000000000003 < z Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6477.9
Applied rewrites77.9%
if -4.8e-10 < z < 0.78000000000000003Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6490.5
Applied rewrites90.5%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- z) (- t x)))) (if (<= z -5e-10) t_1 (if (<= z 2700000000000.0) (fma (- t x) y x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = -z * (t - x);
double tmp;
if (z <= -5e-10) {
tmp = t_1;
} else if (z <= 2700000000000.0) {
tmp = fma((t - x), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(-z) * Float64(t - x)) tmp = 0.0 if (z <= -5e-10) tmp = t_1; elseif (z <= 2700000000000.0) tmp = fma(Float64(t - x), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-z) * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5e-10], t$95$1, If[LessEqual[z, 2700000000000.0], N[(N[(t - x), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-z\right) \cdot \left(t - x\right)\\
\mathbf{if}\;z \leq -5 \cdot 10^{-10}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2700000000000:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -5.00000000000000031e-10 or 2.7e12 < z Initial program 100.0%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6477.5
Applied rewrites77.5%
if -5.00000000000000031e-10 < z < 2.7e12Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6489.5
Applied rewrites89.5%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- t x) y))) (if (<= y -8.8e-25) t_1 (if (<= y 2.05e+79) (fma z x x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (t - x) * y;
double tmp;
if (y <= -8.8e-25) {
tmp = t_1;
} else if (y <= 2.05e+79) {
tmp = fma(z, x, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(t - x) * y) tmp = 0.0 if (y <= -8.8e-25) tmp = t_1; elseif (y <= 2.05e+79) tmp = fma(z, x, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -8.8e-25], t$95$1, If[LessEqual[y, 2.05e+79], N[(z * x + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot y\\
\mathbf{if}\;y \leq -8.8 \cdot 10^{-25}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.05 \cdot 10^{+79}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -8.8000000000000008e-25 or 2.05e79 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6478.5
Applied rewrites78.5%
if -8.8000000000000008e-25 < y < 2.05e79Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6485.4
Applied rewrites85.4%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6454.2
Applied rewrites54.2%
(FPCore (x y z t) :precision binary64 (if (<= z -3.6e+91) (* z x) (if (<= z 4.4e-16) (fma t y x) (fma z x x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.6e+91) {
tmp = z * x;
} else if (z <= 4.4e-16) {
tmp = fma(t, y, x);
} else {
tmp = fma(z, x, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -3.6e+91) tmp = Float64(z * x); elseif (z <= 4.4e-16) tmp = fma(t, y, x); else tmp = fma(z, x, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.6e+91], N[(z * x), $MachinePrecision], If[LessEqual[z, 4.4e-16], N[(t * y + x), $MachinePrecision], N[(z * x + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6 \cdot 10^{+91}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq 4.4 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\end{array}
\end{array}
if z < -3.6e91Initial program 100.0%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6486.5
Applied rewrites86.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6446.5
Applied rewrites46.5%
if -3.6e91 < z < 4.40000000000000001e-16Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6484.7
Applied rewrites84.7%
Taylor expanded in x around 0
Applied rewrites60.9%
if 4.40000000000000001e-16 < z Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6477.2
Applied rewrites77.2%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6441.7
Applied rewrites41.7%
(FPCore (x y z t) :precision binary64 (if (<= y -7.5e+38) (* y t) (if (<= y 2.25e+79) (fma z x x) (* y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -7.5e+38) {
tmp = y * t;
} else if (y <= 2.25e+79) {
tmp = fma(z, x, x);
} else {
tmp = y * t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -7.5e+38) tmp = Float64(y * t); elseif (y <= 2.25e+79) tmp = fma(z, x, x); else tmp = Float64(y * t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -7.5e+38], N[(y * t), $MachinePrecision], If[LessEqual[y, 2.25e+79], N[(z * x + x), $MachinePrecision], N[(y * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{+38}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{+79}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if y < -7.4999999999999999e38 or 2.24999999999999997e79 < y Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6452.6
Applied rewrites52.6%
Taylor expanded in y around inf
Applied rewrites43.9%
if -7.4999999999999999e38 < y < 2.24999999999999997e79Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6483.0
Applied rewrites83.0%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6452.6
Applied rewrites52.6%
(FPCore (x y z t) :precision binary64 (if (<= z -520.0) (* z x) (if (<= z 4.4e-16) x (* z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -520.0) {
tmp = z * x;
} else if (z <= 4.4e-16) {
tmp = x;
} else {
tmp = z * x;
}
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-520.0d0)) then
tmp = z * x
else if (z <= 4.4d-16) then
tmp = x
else
tmp = z * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -520.0) {
tmp = z * x;
} else if (z <= 4.4e-16) {
tmp = x;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -520.0: tmp = z * x elif z <= 4.4e-16: tmp = x else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -520.0) tmp = Float64(z * x); elseif (z <= 4.4e-16) tmp = x; else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -520.0) tmp = z * x; elseif (z <= 4.4e-16) tmp = x; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -520.0], N[(z * x), $MachinePrecision], If[LessEqual[z, 4.4e-16], x, N[(z * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -520:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq 4.4 \cdot 10^{-16}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -520 or 4.40000000000000001e-16 < z Initial program 100.0%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6476.7
Applied rewrites76.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6440.5
Applied rewrites40.5%
if -520 < z < 4.40000000000000001e-16Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6490.5
Applied rewrites90.5%
Taylor expanded in y around 0
Applied rewrites33.3%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6460.1
Applied rewrites60.1%
Taylor expanded in y around 0
Applied rewrites17.7%
(FPCore (x y z t) :precision binary64 (+ x (+ (* t (- y z)) (* (- x) (- y z)))))
double code(double x, double y, double z, double t) {
return x + ((t * (y - z)) + (-x * (y - z)));
}
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((t * (y - z)) + (-x * (y - z)))
end function
public static double code(double x, double y, double z, double t) {
return x + ((t * (y - z)) + (-x * (y - z)));
}
def code(x, y, z, t): return x + ((t * (y - z)) + (-x * (y - z)))
function code(x, y, z, t) return Float64(x + Float64(Float64(t * Float64(y - z)) + Float64(Float64(-x) * Float64(y - z)))) end
function tmp = code(x, y, z, t) tmp = x + ((t * (y - z)) + (-x * (y - z))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision] + N[((-x) * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(t \cdot \left(y - z\right) + \left(-x\right) \cdot \left(y - z\right)\right)
\end{array}
herbie shell --seed 2025089
(FPCore (x y z t)
:name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
:precision binary64
:alt
(! :herbie-platform default (+ x (+ (* t (- y z)) (* (- x) (- y z)))))
(+ x (* (- y z) (- t x))))