
(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 9 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 (* y (- t x))))
(if (<= y -8.2e+30)
t_1
(if (<= y 0.00027) (fma z (- x t) x) (+ x t_1)))))double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double tmp;
if (y <= -8.2e+30) {
tmp = t_1;
} else if (y <= 0.00027) {
tmp = fma(z, (x - t), x);
} else {
tmp = x + t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) tmp = 0.0 if (y <= -8.2e+30) tmp = t_1; elseif (y <= 0.00027) tmp = fma(z, Float64(x - t), x); else tmp = Float64(x + 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, -8.2e+30], t$95$1, If[LessEqual[y, 0.00027], N[(z * N[(x - t), $MachinePrecision] + x), $MachinePrecision], N[(x + t$95$1), $MachinePrecision]]]]
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -8.2 \cdot 10^{+30}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 0.00027:\\
\;\;\;\;\mathsf{fma}\left(z, x - t, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + t\_1\\
\end{array}
if y < -8.2000000000000001e30Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f6463.8%
Applied rewrites63.8%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6445.8%
Applied rewrites45.8%
if -8.2000000000000001e30 < y < 2.7e-4Initial 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 rewrites59.5%
if 2.7e-4 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6461.4%
Applied rewrites61.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (- t x)))) (if (<= y -8.2e+30) t_1 (if (<= y 0.00027) (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 <= -8.2e+30) {
tmp = t_1;
} else if (y <= 0.00027) {
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 <= -8.2e+30) tmp = t_1; elseif (y <= 0.00027) 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, -8.2e+30], t$95$1, If[LessEqual[y, 0.00027], 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 -8.2 \cdot 10^{+30}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 0.00027:\\
\;\;\;\;\mathsf{fma}\left(z, x - t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -8.2000000000000001e30 or 2.7e-4 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f6463.8%
Applied rewrites63.8%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6445.8%
Applied rewrites45.8%
if -8.2000000000000001e30 < y < 2.7e-4Initial 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 rewrites59.5%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (- z y) x x))) (if (<= x -7.5e-46) t_1 (if (<= x 1.7e+22) (* t (- y z)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((z - y), x, x);
double tmp;
if (x <= -7.5e-46) {
tmp = t_1;
} else if (x <= 1.7e+22) {
tmp = t * (y - z);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(z - y), x, x) tmp = 0.0 if (x <= -7.5e-46) tmp = t_1; elseif (x <= 1.7e+22) tmp = Float64(t * Float64(y - z)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z - y), $MachinePrecision] * x + x), $MachinePrecision]}, If[LessEqual[x, -7.5e-46], t$95$1, If[LessEqual[x, 1.7e+22], N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(z - y, x, x\right)\\
\mathbf{if}\;x \leq -7.5 \cdot 10^{-46}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{+22}:\\
\;\;\;\;t \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if x < -7.5000000000000003e-46 or 1.7e22 < x 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 t around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6455.5%
Applied rewrites55.5%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f6455.5%
Applied rewrites55.5%
if -7.5000000000000003e-46 < x < 1.7e22Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f6463.8%
Applied rewrites63.8%
lift-fma.f64N/A
lift-fma.f64N/A
associate-+r+N/A
*-commutativeN/A
distribute-rgt-outN/A
lift-neg.f64N/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-fma.f6464.9%
Applied rewrites64.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6449.5%
Applied rewrites49.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- t x))) (t_2 (* t (- y z))))
(if (<= y -4.6e+31)
t_1
(if (<= y -7.1e-78)
t_2
(if (<= y -7.8e-130)
(fma z x x)
(if (<= y 9.8e-290)
(* z (- x t))
(if (<= y 3.5e-114)
(fma z x x)
(if (<= y 8.5e-5) t_2 t_1))))))))double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double t_2 = t * (y - z);
double tmp;
if (y <= -4.6e+31) {
tmp = t_1;
} else if (y <= -7.1e-78) {
tmp = t_2;
} else if (y <= -7.8e-130) {
tmp = fma(z, x, x);
} else if (y <= 9.8e-290) {
tmp = z * (x - t);
} else if (y <= 3.5e-114) {
tmp = fma(z, x, x);
} else if (y <= 8.5e-5) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) t_2 = Float64(t * Float64(y - z)) tmp = 0.0 if (y <= -4.6e+31) tmp = t_1; elseif (y <= -7.1e-78) tmp = t_2; elseif (y <= -7.8e-130) tmp = fma(z, x, x); elseif (y <= 9.8e-290) tmp = Float64(z * Float64(x - t)); elseif (y <= 3.5e-114) tmp = fma(z, x, x); elseif (y <= 8.5e-5) tmp = t_2; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.6e+31], t$95$1, If[LessEqual[y, -7.1e-78], t$95$2, If[LessEqual[y, -7.8e-130], N[(z * x + x), $MachinePrecision], If[LessEqual[y, 9.8e-290], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.5e-114], N[(z * x + x), $MachinePrecision], If[LessEqual[y, 8.5e-5], t$95$2, t$95$1]]]]]]]]
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
t_2 := t \cdot \left(y - z\right)\\
\mathbf{if}\;y \leq -4.6 \cdot 10^{+31}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -7.1 \cdot 10^{-78}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq -7.8 \cdot 10^{-130}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{elif}\;y \leq 9.8 \cdot 10^{-290}:\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-114}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -4.5999999999999999e31 or 8.5000000000000006e-5 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f6463.8%
Applied rewrites63.8%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6445.8%
Applied rewrites45.8%
if -4.5999999999999999e31 < y < -7.1000000000000002e-78 or 3.5e-114 < y < 8.5000000000000006e-5Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f6463.8%
Applied rewrites63.8%
lift-fma.f64N/A
lift-fma.f64N/A
associate-+r+N/A
*-commutativeN/A
distribute-rgt-outN/A
lift-neg.f64N/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-fma.f6464.9%
Applied rewrites64.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6449.5%
Applied rewrites49.5%
if -7.1000000000000002e-78 < y < -7.8000000000000002e-130 or 9.8000000000000002e-290 < y < 3.5e-114Initial 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--.f6455.5%
Applied rewrites55.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6437.2%
Applied rewrites37.2%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f6437.2%
Applied rewrites37.2%
if -7.8000000000000002e-130 < y < 9.8000000000000002e-290Initial 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--.f6444.0%
Applied rewrites44.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- t x))) (t_2 (* t (- y z))))
(if (<= y -4.6e+31)
t_1
(if (<= y -7.1e-78)
t_2
(if (<= y 3.5e-114) (fma z x x) (if (<= y 8.5e-5) t_2 t_1))))))double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double t_2 = t * (y - z);
double tmp;
if (y <= -4.6e+31) {
tmp = t_1;
} else if (y <= -7.1e-78) {
tmp = t_2;
} else if (y <= 3.5e-114) {
tmp = fma(z, x, x);
} else if (y <= 8.5e-5) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) t_2 = Float64(t * Float64(y - z)) tmp = 0.0 if (y <= -4.6e+31) tmp = t_1; elseif (y <= -7.1e-78) tmp = t_2; elseif (y <= 3.5e-114) tmp = fma(z, x, x); elseif (y <= 8.5e-5) tmp = t_2; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.6e+31], t$95$1, If[LessEqual[y, -7.1e-78], t$95$2, If[LessEqual[y, 3.5e-114], N[(z * x + x), $MachinePrecision], If[LessEqual[y, 8.5e-5], t$95$2, t$95$1]]]]]]
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
t_2 := t \cdot \left(y - z\right)\\
\mathbf{if}\;y \leq -4.6 \cdot 10^{+31}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -7.1 \cdot 10^{-78}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-114}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -4.5999999999999999e31 or 8.5000000000000006e-5 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f6463.8%
Applied rewrites63.8%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6445.8%
Applied rewrites45.8%
if -4.5999999999999999e31 < y < -7.1000000000000002e-78 or 3.5e-114 < y < 8.5000000000000006e-5Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f6463.8%
Applied rewrites63.8%
lift-fma.f64N/A
lift-fma.f64N/A
associate-+r+N/A
*-commutativeN/A
distribute-rgt-outN/A
lift-neg.f64N/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-fma.f6464.9%
Applied rewrites64.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6449.5%
Applied rewrites49.5%
if -7.1000000000000002e-78 < y < 3.5e-114Initial 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--.f6455.5%
Applied rewrites55.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6437.2%
Applied rewrites37.2%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f6437.2%
Applied rewrites37.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (- t x)))) (if (<= y -8.2e+30) t_1 (if (<= y 0.00027) (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 <= -8.2e+30) {
tmp = t_1;
} else if (y <= 0.00027) {
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 <= -8.2e+30) tmp = t_1; elseif (y <= 0.00027) 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, -8.2e+30], t$95$1, If[LessEqual[y, 0.00027], N[(z * x + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -8.2 \cdot 10^{+30}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 0.00027:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -8.2000000000000001e30 or 2.7e-4 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f6463.8%
Applied rewrites63.8%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6445.8%
Applied rewrites45.8%
if -8.2000000000000001e30 < y < 2.7e-4Initial 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--.f6455.5%
Applied rewrites55.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6437.2%
Applied rewrites37.2%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f6437.2%
Applied rewrites37.2%
(FPCore (x y z t) :precision binary64 (fma z x x))
double code(double x, double y, double z, double t) {
return fma(z, x, x);
}
function code(x, y, z, t) return fma(z, x, x) end
code[x_, y_, z_, t_] := N[(z * x + x), $MachinePrecision]
\mathsf{fma}\left(z, x, 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%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6455.5%
Applied rewrites55.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6437.2%
Applied rewrites37.2%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f6437.2%
Applied rewrites37.2%
(FPCore (x y z t) :precision binary64 (* x z))
double code(double x, double y, double z, double t) {
return x * 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 * z
end function
public static double code(double x, double y, double z, double t) {
return x * z;
}
def code(x, y, z, t): return x * z
function code(x, y, z, t) return Float64(x * z) end
function tmp = code(x, y, z, t) tmp = x * z; end
code[x_, y_, z_, t_] := N[(x * z), $MachinePrecision]
x \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--.f6444.0%
Applied rewrites44.0%
Taylor expanded in x around inf
lower-*.f6421.8%
Applied rewrites21.8%
herbie shell --seed 2025212
(FPCore (x y z t)
:name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
:precision binary64
(+ x (* (- y z) (- t x))))