
(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 13 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 (<= (- y z) -5e+277) (* y t) (if (<= (- y z) -40.0) (* z x) (if (<= (- y z) 200000000000.0) x (* z x)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y - z) <= -5e+277) {
tmp = y * t;
} else if ((y - z) <= -40.0) {
tmp = z * x;
} else if ((y - z) <= 200000000000.0) {
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 ((y - z) <= (-5d+277)) then
tmp = y * t
else if ((y - z) <= (-40.0d0)) then
tmp = z * x
else if ((y - z) <= 200000000000.0d0) 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 ((y - z) <= -5e+277) {
tmp = y * t;
} else if ((y - z) <= -40.0) {
tmp = z * x;
} else if ((y - z) <= 200000000000.0) {
tmp = x;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y - z) <= -5e+277: tmp = y * t elif (y - z) <= -40.0: tmp = z * x elif (y - z) <= 200000000000.0: tmp = x else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(y - z) <= -5e+277) tmp = Float64(y * t); elseif (Float64(y - z) <= -40.0) tmp = Float64(z * x); elseif (Float64(y - z) <= 200000000000.0) tmp = x; else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y - z) <= -5e+277) tmp = y * t; elseif ((y - z) <= -40.0) tmp = z * x; elseif ((y - z) <= 200000000000.0) tmp = x; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(y - z), $MachinePrecision], -5e+277], N[(y * t), $MachinePrecision], If[LessEqual[N[(y - z), $MachinePrecision], -40.0], N[(z * x), $MachinePrecision], If[LessEqual[N[(y - z), $MachinePrecision], 200000000000.0], x, N[(z * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y - z \leq -5 \cdot 10^{+277}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y - z \leq -40:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;y - z \leq 200000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if (-.f64 y z) < -4.99999999999999982e277Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6454.6
Applied rewrites54.6%
Taylor expanded in y around inf
Applied rewrites31.2%
if -4.99999999999999982e277 < (-.f64 y z) < -40 or 2e11 < (-.f64 y 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--.f6452.5
Applied rewrites52.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6428.9
Applied rewrites28.9%
if -40 < (-.f64 y z) < 2e11Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.8
Applied rewrites78.8%
Taylor expanded in y around 0
Applied rewrites60.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- t x) y)))
(if (<= y -2.9e-19)
t_1
(if (<= y 3.2e-13) (fma z x x) (if (<= y 7.9e+117) (* (- y z) t) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = (t - x) * y;
double tmp;
if (y <= -2.9e-19) {
tmp = t_1;
} else if (y <= 3.2e-13) {
tmp = fma(z, x, x);
} else if (y <= 7.9e+117) {
tmp = (y - z) * t;
} 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.9e-19) tmp = t_1; elseif (y <= 3.2e-13) tmp = fma(z, x, x); elseif (y <= 7.9e+117) tmp = Float64(Float64(y - z) * t); 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.9e-19], t$95$1, If[LessEqual[y, 3.2e-13], N[(z * x + x), $MachinePrecision], If[LessEqual[y, 7.9e+117], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot y\\
\mathbf{if}\;y \leq -2.9 \cdot 10^{-19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{elif}\;y \leq 7.9 \cdot 10^{+117}:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -2.9e-19 or 7.90000000000000011e117 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6480.1
Applied rewrites80.1%
if -2.9e-19 < y < 3.2e-13Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6410.5
Applied rewrites10.5%
Taylor expanded in t around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f6459.8
Applied rewrites59.8%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6459.8
Applied rewrites59.8%
if 3.2e-13 < y < 7.90000000000000011e117Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6451.5
Applied rewrites51.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- t x) y)))
(if (<= y -2.9e-19)
t_1
(if (<= y 1.95e-7) (fma z x x) (if (<= y 2.4e+97) (* (- z) t) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = (t - x) * y;
double tmp;
if (y <= -2.9e-19) {
tmp = t_1;
} else if (y <= 1.95e-7) {
tmp = fma(z, x, x);
} else if (y <= 2.4e+97) {
tmp = -z * t;
} 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.9e-19) tmp = t_1; elseif (y <= 1.95e-7) tmp = fma(z, x, x); elseif (y <= 2.4e+97) tmp = Float64(Float64(-z) * t); 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.9e-19], t$95$1, If[LessEqual[y, 1.95e-7], N[(z * x + x), $MachinePrecision], If[LessEqual[y, 2.4e+97], N[((-z) * t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot y\\
\mathbf{if}\;y \leq -2.9 \cdot 10^{-19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+97}:\\
\;\;\;\;\left(-z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -2.9e-19 or 2.4e97 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6480.2
Applied rewrites80.2%
if -2.9e-19 < y < 1.95000000000000012e-7Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6410.7
Applied rewrites10.7%
Taylor expanded in t around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f6459.8
Applied rewrites59.8%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6459.6
Applied rewrites59.6%
if 1.95000000000000012e-7 < y < 2.4e97Initial program 99.9%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6441.7
Applied rewrites41.7%
Taylor expanded in x around 0
Applied rewrites22.6%
(FPCore (x y z t) :precision binary64 (if (<= y -2.9e-19) (* (- t x) y) (if (<= y 2.4e+97) (fma (- z) (- t x) x) (fma (- t x) y x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.9e-19) {
tmp = (t - x) * y;
} else if (y <= 2.4e+97) {
tmp = fma(-z, (t - x), x);
} else {
tmp = fma((t - x), y, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -2.9e-19) tmp = Float64(Float64(t - x) * y); elseif (y <= 2.4e+97) tmp = fma(Float64(-z), Float64(t - x), x); else tmp = fma(Float64(t - x), y, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.9e-19], N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 2.4e+97], N[((-z) * N[(t - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{-19}:\\
\;\;\;\;\left(t - x\right) \cdot y\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+97}:\\
\;\;\;\;\mathsf{fma}\left(-z, t - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\end{array}
\end{array}
if y < -2.9e-19Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6475.2
Applied rewrites75.2%
if -2.9e-19 < y < 2.4e97Initial 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.8
Applied rewrites83.8%
if 2.4e97 < y Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6487.8
Applied rewrites87.8%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- z) (- t x)))) (if (<= z -2700000000.0) t_1 (if (<= z 0.028) (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 <= -2700000000.0) {
tmp = t_1;
} else if (z <= 0.028) {
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 <= -2700000000.0) tmp = t_1; elseif (z <= 0.028) 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, -2700000000.0], t$95$1, If[LessEqual[z, 0.028], 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 -2700000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 0.028:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.7e9 or 0.0280000000000000006 < 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.6
Applied rewrites78.6%
if -2.7e9 < z < 0.0280000000000000006Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6489.4
Applied rewrites89.4%
(FPCore (x y z t) :precision binary64 (if (<= y -2.9e-19) (* (- t x) y) (if (<= y 2.4e+97) (fma t (- z) x) (fma (- t x) y x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.9e-19) {
tmp = (t - x) * y;
} else if (y <= 2.4e+97) {
tmp = fma(t, -z, x);
} else {
tmp = fma((t - x), y, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -2.9e-19) tmp = Float64(Float64(t - x) * y); elseif (y <= 2.4e+97) tmp = fma(t, Float64(-z), x); else tmp = fma(Float64(t - x), y, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.9e-19], N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 2.4e+97], N[(t * (-z) + x), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{-19}:\\
\;\;\;\;\left(t - x\right) \cdot y\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+97}:\\
\;\;\;\;\mathsf{fma}\left(t, -z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\end{array}
\end{array}
if y < -2.9e-19Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6475.2
Applied rewrites75.2%
if -2.9e-19 < y < 2.4e97Initial program 100.0%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt-outN/A
associate-*r*N/A
associate-+l+N/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
Applied rewrites99.6%
Taylor expanded in y around 0
Applied rewrites83.8%
Taylor expanded in x around 0
Applied rewrites60.3%
if 2.4e97 < y Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6487.8
Applied rewrites87.8%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- t x) y))) (if (<= y -2.9e-19) t_1 (if (<= y 2.4e+97) (fma t (- z) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (t - x) * y;
double tmp;
if (y <= -2.9e-19) {
tmp = t_1;
} else if (y <= 2.4e+97) {
tmp = fma(t, -z, 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.9e-19) tmp = t_1; elseif (y <= 2.4e+97) tmp = fma(t, Float64(-z), 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.9e-19], t$95$1, If[LessEqual[y, 2.4e+97], N[(t * (-z) + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot y\\
\mathbf{if}\;y \leq -2.9 \cdot 10^{-19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+97}:\\
\;\;\;\;\mathsf{fma}\left(t, -z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -2.9e-19 or 2.4e97 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6480.2
Applied rewrites80.2%
if -2.9e-19 < y < 2.4e97Initial program 100.0%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt-outN/A
associate-*r*N/A
associate-+l+N/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
Applied rewrites99.6%
Taylor expanded in y around 0
Applied rewrites83.8%
Taylor expanded in x around 0
Applied rewrites60.3%
(FPCore (x y z t) :precision binary64 (if (<= z -4.15e-16) (fma z x x) (if (<= z 0.028) (fma t y x) (* (- z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.15e-16) {
tmp = fma(z, x, x);
} else if (z <= 0.028) {
tmp = fma(t, y, x);
} else {
tmp = -z * t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -4.15e-16) tmp = fma(z, x, x); elseif (z <= 0.028) tmp = fma(t, y, x); else tmp = Float64(Float64(-z) * t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -4.15e-16], N[(z * x + x), $MachinePrecision], If[LessEqual[z, 0.028], N[(t * y + x), $MachinePrecision], N[((-z) * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.15 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{elif}\;z \leq 0.028:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) \cdot t\\
\end{array}
\end{array}
if z < -4.14999999999999989e-16Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6431.4
Applied rewrites31.4%
Taylor expanded in t around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f6454.3
Applied rewrites54.3%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6441.6
Applied rewrites41.6%
if -4.14999999999999989e-16 < z < 0.0280000000000000006Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6490.9
Applied rewrites90.9%
Taylor expanded in x around 0
Applied rewrites67.5%
if 0.0280000000000000006 < 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%
Taylor expanded in x around 0
Applied rewrites39.8%
(FPCore (x y z t) :precision binary64 (if (<= z -4.15e-16) (fma z x x) (if (<= z 3.3e-19) (fma t y x) (fma z x x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.15e-16) {
tmp = fma(z, x, x);
} else if (z <= 3.3e-19) {
tmp = fma(t, y, x);
} else {
tmp = fma(z, x, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -4.15e-16) tmp = fma(z, x, x); elseif (z <= 3.3e-19) tmp = fma(t, y, x); else tmp = fma(z, x, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -4.15e-16], N[(z * x + x), $MachinePrecision], If[LessEqual[z, 3.3e-19], N[(t * y + x), $MachinePrecision], N[(z * x + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.15 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\end{array}
\end{array}
if z < -4.14999999999999989e-16 or 3.2999999999999998e-19 < z Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6431.7
Applied rewrites31.7%
Taylor expanded in t around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f6454.2
Applied rewrites54.2%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6442.4
Applied rewrites42.4%
if -4.14999999999999989e-16 < z < 3.2999999999999998e-19Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6491.6
Applied rewrites91.6%
Taylor expanded in x around 0
Applied rewrites68.0%
(FPCore (x y z t) :precision binary64 (if (<= y -5.8e+159) (* y t) (if (<= y 8.8e+98) (fma z x x) (* y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.8e+159) {
tmp = y * t;
} else if (y <= 8.8e+98) {
tmp = fma(z, x, x);
} else {
tmp = y * t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -5.8e+159) tmp = Float64(y * t); elseif (y <= 8.8e+98) tmp = fma(z, x, x); else tmp = Float64(y * t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -5.8e+159], N[(y * t), $MachinePrecision], If[LessEqual[y, 8.8e+98], N[(z * x + x), $MachinePrecision], N[(y * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+159}:\\
\;\;\;\;y \cdot t\\
\mathbf{elif}\;y \leq 8.8 \cdot 10^{+98}:\\
\;\;\;\;\mathsf{fma}\left(z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot t\\
\end{array}
\end{array}
if y < -5.80000000000000029e159 or 8.80000000000000034e98 < y Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6455.7
Applied rewrites55.7%
Taylor expanded in y around inf
Applied rewrites49.9%
if -5.80000000000000029e159 < y < 8.80000000000000034e98Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6427.2
Applied rewrites27.2%
Taylor expanded in t around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift--.f6457.2
Applied rewrites57.2%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6448.1
Applied rewrites48.1%
(FPCore (x y z t) :precision binary64 (if (<= z -2.35e+33) (* z x) (if (<= z 1.0) x (* z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.35e+33) {
tmp = z * x;
} else if (z <= 1.0) {
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 <= (-2.35d+33)) then
tmp = z * x
else if (z <= 1.0d0) 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 <= -2.35e+33) {
tmp = z * x;
} else if (z <= 1.0) {
tmp = x;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.35e+33: tmp = z * x elif z <= 1.0: tmp = x else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.35e+33) tmp = Float64(z * x); elseif (z <= 1.0) tmp = x; else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -2.35e+33) tmp = z * x; elseif (z <= 1.0) tmp = x; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.35e+33], N[(z * x), $MachinePrecision], If[LessEqual[z, 1.0], x, N[(z * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.35 \cdot 10^{+33}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -2.3499999999999999e33 or 1 < 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--.f6479.8
Applied rewrites79.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6444.0
Applied rewrites44.0%
if -2.3499999999999999e33 < z < 1Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6488.0
Applied rewrites88.0%
Taylor expanded in y around 0
Applied rewrites31.0%
(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.8
Applied rewrites60.8%
Taylor expanded in y around 0
Applied rewrites17.9%
(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 2025095
(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))))