
(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]
x + \left(y - z\right) \cdot \left(t - x\right)
Herbie found 10 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]
x + \left(y - z\right) \cdot \left(t - x\right)
(FPCore (x y z t) :precision binary64 (fma (- z y) (- x t) x))
double code(double x, double y, double z, double t) {
return fma((z - y), (x - t), x);
}
function code(x, y, z, t) return fma(Float64(z - y), Float64(x - t), x) end
code[x_, y_, z_, t_] := N[(N[(z - y), $MachinePrecision] * N[(x - t), $MachinePrecision] + x), $MachinePrecision]
\mathsf{fma}\left(z - y, x - t, x\right)
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (- y z) t x))) (if (<= t -3.45e+46) t_1 (if (<= t 5.1e-30) (fma (- z y) x x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((y - z), t, x);
double tmp;
if (t <= -3.45e+46) {
tmp = t_1;
} else if (t <= 5.1e-30) {
tmp = fma((z - y), x, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(y - z), t, x) tmp = 0.0 if (t <= -3.45e+46) tmp = t_1; elseif (t <= 5.1e-30) tmp = fma(Float64(z - y), x, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] * t + x), $MachinePrecision]}, If[LessEqual[t, -3.45e+46], t$95$1, If[LessEqual[t, 5.1e-30], N[(N[(z - y), $MachinePrecision] * x + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(y - z, t, x\right)\\
\mathbf{if}\;t \leq -3.45 \cdot 10^{+46}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 5.1 \cdot 10^{-30}:\\
\;\;\;\;\mathsf{fma}\left(z - y, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if t < -3.4500000000000001e46 or 5.0999999999999997e-30 < t Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites64.8%
if -3.4500000000000001e46 < t < 5.0999999999999997e-30Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6456.3%
Applied rewrites56.3%
lift--.f64N/A
lift-*.f64N/A
sub-flipN/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-neg.f6455.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6455.4%
Applied rewrites55.4%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
distribute-rgt-outN/A
lift-neg.f64N/A
sub-flipN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6456.3%
Applied rewrites56.3%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (- t x)))) (if (<= y -2.1e+139) t_1 (if (<= y 420000000000.0) (fma z (- x t) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -2.1e+139) {
tmp = t_1;
} else if (y <= 420000000000.0) {
tmp = fma(z, (x - t), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) tmp = 0.0 if (y <= -2.1e+139) tmp = t_1; elseif (y <= 420000000000.0) tmp = fma(z, Float64(x - t), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.1e+139], t$95$1, If[LessEqual[y, 420000000000.0], N[(z * N[(x - t), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -2.1 \cdot 10^{+139}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 420000000000:\\
\;\;\;\;\mathsf{fma}\left(z, x - t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -2.0999999999999999e139 or 4.2e11 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites64.8%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6444.7%
Applied rewrites44.7%
if -2.0999999999999999e139 < y < 4.2e11Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites60.8%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* t (- y z)))) (if (<= t -4.4e+92) t_1 (if (<= t 4.4e+42) (fma (- z y) x x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = t * (y - z);
double tmp;
if (t <= -4.4e+92) {
tmp = t_1;
} else if (t <= 4.4e+42) {
tmp = fma((z - y), x, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(t * Float64(y - z)) tmp = 0.0 if (t <= -4.4e+92) tmp = t_1; elseif (t <= 4.4e+42) tmp = fma(Float64(z - y), x, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -4.4e+92], t$95$1, If[LessEqual[t, 4.4e+42], N[(N[(z - y), $MachinePrecision] * x + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := t \cdot \left(y - z\right)\\
\mathbf{if}\;t \leq -4.4 \cdot 10^{+92}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 4.4 \cdot 10^{+42}:\\
\;\;\;\;\mathsf{fma}\left(z - y, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if t < -4.3999999999999998e92 or 4.4000000000000003e42 < t Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites64.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6449.3%
Applied rewrites49.3%
if -4.3999999999999998e92 < t < 4.4000000000000003e42Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6456.3%
Applied rewrites56.3%
lift--.f64N/A
lift-*.f64N/A
sub-flipN/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-neg.f6455.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6455.4%
Applied rewrites55.4%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
distribute-rgt-outN/A
lift-neg.f64N/A
sub-flipN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6456.3%
Applied rewrites56.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (- x t))))
(if (<= z -2.05e-20)
t_1
(if (<= z 9.6e-133)
(+ x (* t y))
(if (<= z 2.5e+32) (* y (- t x)) t_1)))))double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double tmp;
if (z <= -2.05e-20) {
tmp = t_1;
} else if (z <= 9.6e-133) {
tmp = x + (t * y);
} else if (z <= 2.5e+32) {
tmp = y * (t - x);
} 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(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) :: t_1
real(8) :: tmp
t_1 = z * (x - t)
if (z <= (-2.05d-20)) then
tmp = t_1
else if (z <= 9.6d-133) then
tmp = x + (t * y)
else if (z <= 2.5d+32) then
tmp = y * (t - x)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double tmp;
if (z <= -2.05e-20) {
tmp = t_1;
} else if (z <= 9.6e-133) {
tmp = x + (t * y);
} else if (z <= 2.5e+32) {
tmp = y * (t - x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = z * (x - t) tmp = 0 if z <= -2.05e-20: tmp = t_1 elif z <= 9.6e-133: tmp = x + (t * y) elif z <= 2.5e+32: tmp = y * (t - x) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(z * Float64(x - t)) tmp = 0.0 if (z <= -2.05e-20) tmp = t_1; elseif (z <= 9.6e-133) tmp = Float64(x + Float64(t * y)); elseif (z <= 2.5e+32) tmp = Float64(y * Float64(t - x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = z * (x - t); tmp = 0.0; if (z <= -2.05e-20) tmp = t_1; elseif (z <= 9.6e-133) tmp = x + (t * y); elseif (z <= 2.5e+32) tmp = y * (t - x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.05e-20], t$95$1, If[LessEqual[z, 9.6e-133], N[(x + N[(t * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.5e+32], N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_1 := z \cdot \left(x - t\right)\\
\mathbf{if}\;z \leq -2.05 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 9.6 \cdot 10^{-133}:\\
\;\;\;\;x + t \cdot y\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{+32}:\\
\;\;\;\;y \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z < -2.05e-20 or 2.4999999999999999e32 < z Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6445.2%
Applied rewrites45.2%
if -2.05e-20 < z < 9.6e-133Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6460.3%
Applied rewrites60.3%
Taylor expanded in x around 0
lower-*.f6442.1%
Applied rewrites42.1%
if 9.6e-133 < z < 2.4999999999999999e32Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites64.8%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6444.7%
Applied rewrites44.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- t x))))
(if (<= y -7.2e+29)
t_1
(if (<= y 7.2e-218)
(fma z x x)
(if (<= y 420000000000.0) (* z (- x t)) t_1)))))double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -7.2e+29) {
tmp = t_1;
} else if (y <= 7.2e-218) {
tmp = fma(z, x, x);
} else if (y <= 420000000000.0) {
tmp = z * (x - t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) tmp = 0.0 if (y <= -7.2e+29) tmp = t_1; elseif (y <= 7.2e-218) tmp = fma(z, x, x); elseif (y <= 420000000000.0) tmp = Float64(z * Float64(x - t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7.2e+29], t$95$1, If[LessEqual[y, 7.2e-218], N[(z * x + x), $MachinePrecision], If[LessEqual[y, 420000000000.0], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -7.2 \cdot 10^{+29}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{-218}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{elif}\;y \leq 420000000000:\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -7.1999999999999995e29 or 4.2e11 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites64.8%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6444.7%
Applied rewrites44.7%
if -7.1999999999999995e29 < y < 7.2000000000000002e-218Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6456.3%
Applied rewrites56.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6437.9%
Applied rewrites37.9%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt1-inN/A
distribute-lft1-inN/A
lower-fma.f6438.0%
Applied rewrites38.0%
if 7.2000000000000002e-218 < y < 4.2e11Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6445.2%
Applied rewrites45.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (- t x)))) (if (<= y -7.2e+29) t_1 (if (<= y 420000000000.0) (fma z x x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -7.2e+29) {
tmp = t_1;
} else if (y <= 420000000000.0) {
tmp = fma(z, x, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) tmp = 0.0 if (y <= -7.2e+29) tmp = t_1; elseif (y <= 420000000000.0) tmp = fma(z, x, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7.2e+29], t$95$1, If[LessEqual[y, 420000000000.0], N[(z * x + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -7.2 \cdot 10^{+29}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 420000000000:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -7.1999999999999995e29 or 4.2e11 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites64.8%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6444.7%
Applied rewrites44.7%
if -7.1999999999999995e29 < y < 4.2e11Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6456.3%
Applied rewrites56.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6437.9%
Applied rewrites37.9%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt1-inN/A
distribute-lft1-inN/A
lower-fma.f6438.0%
Applied rewrites38.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* t (- y z)))) (if (<= t -4.4e+92) t_1 (if (<= t 4.4e+42) (fma z x x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = t * (y - z);
double tmp;
if (t <= -4.4e+92) {
tmp = t_1;
} else if (t <= 4.4e+42) {
tmp = fma(z, x, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(t * Float64(y - z)) tmp = 0.0 if (t <= -4.4e+92) tmp = t_1; elseif (t <= 4.4e+42) tmp = fma(z, x, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -4.4e+92], t$95$1, If[LessEqual[t, 4.4e+42], N[(z * x + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := t \cdot \left(y - z\right)\\
\mathbf{if}\;t \leq -4.4 \cdot 10^{+92}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 4.4 \cdot 10^{+42}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if t < -4.3999999999999998e92 or 4.4000000000000003e42 < t Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites64.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6449.3%
Applied rewrites49.3%
if -4.3999999999999998e92 < t < 4.4000000000000003e42Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6456.3%
Applied rewrites56.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6437.9%
Applied rewrites37.9%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt1-inN/A
distribute-lft1-inN/A
lower-fma.f6438.0%
Applied rewrites38.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- t) z))) (if (<= t -4.4e+92) t_1 (if (<= t 2.9e+151) (fma z x x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = -t * z;
double tmp;
if (t <= -4.4e+92) {
tmp = t_1;
} else if (t <= 2.9e+151) {
tmp = fma(z, x, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(-t) * z) tmp = 0.0 if (t <= -4.4e+92) tmp = t_1; elseif (t <= 2.9e+151) tmp = fma(z, x, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-t) * z), $MachinePrecision]}, If[LessEqual[t, -4.4e+92], t$95$1, If[LessEqual[t, 2.9e+151], N[(z * x + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \left(-t\right) \cdot z\\
\mathbf{if}\;t \leq -4.4 \cdot 10^{+92}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.9 \cdot 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if t < -4.3999999999999998e92 or 2.9000000000000002e151 < t Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6445.2%
Applied rewrites45.2%
Taylor expanded in x around 0
lower-*.f6427.2%
Applied rewrites27.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.2%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6427.2%
Applied rewrites27.2%
if -4.3999999999999998e92 < t < 2.9000000000000002e151Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6456.3%
Applied rewrites56.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6437.9%
Applied rewrites37.9%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt1-inN/A
distribute-lft1-inN/A
lower-fma.f6438.0%
Applied rewrites38.0%
(FPCore (x y z t) :precision binary64 (* (- t) z))
double code(double x, double y, double z, double t) {
return -t * 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 = -t * z
end function
public static double code(double x, double y, double z, double t) {
return -t * z;
}
def code(x, y, z, t): return -t * z
function code(x, y, z, t) return Float64(Float64(-t) * z) end
function tmp = code(x, y, z, t) tmp = -t * z; end
code[x_, y_, z_, t_] := N[((-t) * z), $MachinePrecision]
\left(-t\right) \cdot z
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6445.2%
Applied rewrites45.2%
Taylor expanded in x around 0
lower-*.f6427.2%
Applied rewrites27.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.2%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6427.2%
Applied rewrites27.2%
herbie shell --seed 2025205
(FPCore (x y z t)
:name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
:precision binary64
(+ x (* (- y z) (- t x))))