
(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 (fma (- y z) (- t x) x))
double code(double x, double y, double z, double t) {
return fma((y - z), (t - x), x);
}
function code(x, y, z, t) return fma(Float64(y - z), Float64(t - x), x) end
code[x_, y_, z_, t_] := N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - z, t - x, x\right)
\end{array}
Initial program 100.0%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift--.f64100.0
Applied rewrites100.0%
(FPCore (x y z t)
:precision binary64
(if (<= (- y z) -4e+164)
(* t y)
(if (<= (- y z) -2e+34)
(* z x)
(if (<= (- y z) 5e-40) x (if (<= (- y z) 4e+101) (* t y) (* z x))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y - z) <= -4e+164) {
tmp = t * y;
} else if ((y - z) <= -2e+34) {
tmp = z * x;
} else if ((y - z) <= 5e-40) {
tmp = x;
} else if ((y - z) <= 4e+101) {
tmp = t * y;
} 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) <= (-4d+164)) then
tmp = t * y
else if ((y - z) <= (-2d+34)) then
tmp = z * x
else if ((y - z) <= 5d-40) then
tmp = x
else if ((y - z) <= 4d+101) then
tmp = t * y
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) <= -4e+164) {
tmp = t * y;
} else if ((y - z) <= -2e+34) {
tmp = z * x;
} else if ((y - z) <= 5e-40) {
tmp = x;
} else if ((y - z) <= 4e+101) {
tmp = t * y;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y - z) <= -4e+164: tmp = t * y elif (y - z) <= -2e+34: tmp = z * x elif (y - z) <= 5e-40: tmp = x elif (y - z) <= 4e+101: tmp = t * y else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(y - z) <= -4e+164) tmp = Float64(t * y); elseif (Float64(y - z) <= -2e+34) tmp = Float64(z * x); elseif (Float64(y - z) <= 5e-40) tmp = x; elseif (Float64(y - z) <= 4e+101) tmp = Float64(t * y); else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y - z) <= -4e+164) tmp = t * y; elseif ((y - z) <= -2e+34) tmp = z * x; elseif ((y - z) <= 5e-40) tmp = x; elseif ((y - z) <= 4e+101) tmp = t * y; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(y - z), $MachinePrecision], -4e+164], N[(t * y), $MachinePrecision], If[LessEqual[N[(y - z), $MachinePrecision], -2e+34], N[(z * x), $MachinePrecision], If[LessEqual[N[(y - z), $MachinePrecision], 5e-40], x, If[LessEqual[N[(y - z), $MachinePrecision], 4e+101], N[(t * y), $MachinePrecision], N[(z * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y - z \leq -4 \cdot 10^{+164}:\\
\;\;\;\;t \cdot y\\
\mathbf{elif}\;y - z \leq -2 \cdot 10^{+34}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;y - z \leq 5 \cdot 10^{-40}:\\
\;\;\;\;x\\
\mathbf{elif}\;y - z \leq 4 \cdot 10^{+101}:\\
\;\;\;\;t \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if (-.f64 y z) < -4e164 or 4.99999999999999965e-40 < (-.f64 y z) < 3.9999999999999999e101Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6450.4
Applied rewrites50.4%
Taylor expanded in x around 0
Applied rewrites27.9%
if -4e164 < (-.f64 y z) < -1.99999999999999989e34 or 3.9999999999999999e101 < (-.f64 y 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--.f6452.8
Applied rewrites52.8%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f6428.8
Applied rewrites28.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6428.7
Applied rewrites28.7%
if -1.99999999999999989e34 < (-.f64 y z) < 4.99999999999999965e-40Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.2
Applied rewrites78.2%
Taylor expanded in y around 0
Applied rewrites59.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- y z) t)))
(if (<= z -3.3e+146)
t_1
(if (<= z -5.5e+105)
(* z x)
(if (<= z -0.0132)
t_1
(if (<= z 1.32e+119) (fma (- t x) y x) (* z x)))))))
double code(double x, double y, double z, double t) {
double t_1 = (y - z) * t;
double tmp;
if (z <= -3.3e+146) {
tmp = t_1;
} else if (z <= -5.5e+105) {
tmp = z * x;
} else if (z <= -0.0132) {
tmp = t_1;
} else if (z <= 1.32e+119) {
tmp = fma((t - x), y, x);
} else {
tmp = z * x;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(y - z) * t) tmp = 0.0 if (z <= -3.3e+146) tmp = t_1; elseif (z <= -5.5e+105) tmp = Float64(z * x); elseif (z <= -0.0132) tmp = t_1; elseif (z <= 1.32e+119) tmp = fma(Float64(t - x), y, x); else tmp = Float64(z * x); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[z, -3.3e+146], t$95$1, If[LessEqual[z, -5.5e+105], N[(z * x), $MachinePrecision], If[LessEqual[z, -0.0132], t$95$1, If[LessEqual[z, 1.32e+119], N[(N[(t - x), $MachinePrecision] * y + x), $MachinePrecision], N[(z * x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(y - z\right) \cdot t\\
\mathbf{if}\;z \leq -3.3 \cdot 10^{+146}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -5.5 \cdot 10^{+105}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq -0.0132:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.32 \cdot 10^{+119}:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -3.30000000000000016e146 or -5.49999999999999979e105 < z < -0.0132Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6453.8
Applied rewrites53.8%
if -3.30000000000000016e146 < z < -5.49999999999999979e105 or 1.32e119 < 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--.f6485.8
Applied rewrites85.8%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f6446.0
Applied rewrites46.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6446.0
Applied rewrites46.0%
if -0.0132 < z < 1.32e119Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6483.0
Applied rewrites83.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- t x) y)) (t_2 (* (- y z) t)))
(if (<= y -3e+88)
t_1
(if (<= y -5.2e-15)
t_2
(if (<= y 1.08e-89) (fma x z x) (if (<= y 0.000116) t_2 t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = (t - x) * y;
double t_2 = (y - z) * t;
double tmp;
if (y <= -3e+88) {
tmp = t_1;
} else if (y <= -5.2e-15) {
tmp = t_2;
} else if (y <= 1.08e-89) {
tmp = fma(x, z, x);
} else if (y <= 0.000116) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(t - x) * y) t_2 = Float64(Float64(y - z) * t) tmp = 0.0 if (y <= -3e+88) tmp = t_1; elseif (y <= -5.2e-15) tmp = t_2; elseif (y <= 1.08e-89) tmp = fma(x, z, x); elseif (y <= 0.000116) tmp = t_2; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[y, -3e+88], t$95$1, If[LessEqual[y, -5.2e-15], t$95$2, If[LessEqual[y, 1.08e-89], N[(x * z + x), $MachinePrecision], If[LessEqual[y, 0.000116], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot y\\
t_2 := \left(y - z\right) \cdot t\\
\mathbf{if}\;y \leq -3 \cdot 10^{+88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -5.2 \cdot 10^{-15}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 1.08 \cdot 10^{-89}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{elif}\;y \leq 0.000116:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -3.00000000000000005e88 or 1.16e-4 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6480.9
Applied rewrites80.9%
if -3.00000000000000005e88 < y < -5.20000000000000009e-15 or 1.07999999999999999e-89 < y < 1.16e-4Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6451.0
Applied rewrites51.0%
if -5.20000000000000009e-15 < y < 1.07999999999999999e-89Initial 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.1
Applied rewrites93.1%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f6459.7
Applied rewrites59.7%
(FPCore (x y z t) :precision binary64 (if (<= z -2e+147) (* (- t) z) (if (<= z -0.058) (fma x z x) (if (<= z 5e+60) (fma t y x) (* z x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2e+147) {
tmp = -t * z;
} else if (z <= -0.058) {
tmp = fma(x, z, x);
} else if (z <= 5e+60) {
tmp = fma(t, y, x);
} else {
tmp = z * x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -2e+147) tmp = Float64(Float64(-t) * z); elseif (z <= -0.058) tmp = fma(x, z, x); elseif (z <= 5e+60) tmp = fma(t, y, x); else tmp = Float64(z * x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -2e+147], N[((-t) * z), $MachinePrecision], If[LessEqual[z, -0.058], N[(x * z + x), $MachinePrecision], If[LessEqual[z, 5e+60], N[(t * y + x), $MachinePrecision], N[(z * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+147}:\\
\;\;\;\;\left(-t\right) \cdot z\\
\mathbf{elif}\;z \leq -0.058:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{elif}\;z \leq 5 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -2e147Initial 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--.f6490.0
Applied rewrites90.0%
Taylor expanded in x around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6449.3
Applied rewrites49.3%
if -2e147 < z < -0.0580000000000000029Initial 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--.f6467.4
Applied rewrites67.4%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f6433.0
Applied rewrites33.0%
if -0.0580000000000000029 < z < 4.99999999999999975e60Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6486.9
Applied rewrites86.9%
Taylor expanded in x around 0
Applied rewrites62.6%
if 4.99999999999999975e60 < 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--.f6482.0
Applied rewrites82.0%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f6444.6
Applied rewrites44.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6444.6
Applied rewrites44.6%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (- z) (- t x) x))) (if (<= z -2e-7) t_1 (if (<= z 4.2e+51) (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 <= -2e-7) {
tmp = t_1;
} else if (z <= 4.2e+51) {
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 <= -2e-7) tmp = t_1; elseif (z <= 4.2e+51) 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, -2e-7], t$95$1, If[LessEqual[z, 4.2e+51], 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 -2 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+51}:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.9999999999999999e-7 or 4.2000000000000002e51 < 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--.f6479.8
Applied rewrites79.8%
if -1.9999999999999999e-7 < z < 4.2000000000000002e51Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6487.6
Applied rewrites87.6%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- z) (- t x)))) (if (<= z -3200000000000.0) t_1 (if (<= z 4.2e+51) (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 <= -3200000000000.0) {
tmp = t_1;
} else if (z <= 4.2e+51) {
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 <= -3200000000000.0) tmp = t_1; elseif (z <= 4.2e+51) 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, -3200000000000.0], t$95$1, If[LessEqual[z, 4.2e+51], 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 -3200000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+51}:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.2e12 or 4.2000000000000002e51 < 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--.f6480.7
Applied rewrites80.7%
if -3.2e12 < z < 4.2000000000000002e51Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6486.4
Applied rewrites86.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- t x) y))) (if (<= y -2.8e+66) t_1 (if (<= y 3.9e-28) (fma (- z) t x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (t - x) * y;
double tmp;
if (y <= -2.8e+66) {
tmp = t_1;
} else if (y <= 3.9e-28) {
tmp = fma(-z, t, 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.8e+66) tmp = t_1; elseif (y <= 3.9e-28) tmp = fma(Float64(-z), t, 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.8e+66], t$95$1, If[LessEqual[y, 3.9e-28], N[((-z) * t + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot y\\
\mathbf{if}\;y \leq -2.8 \cdot 10^{+66}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{-28}:\\
\;\;\;\;\mathsf{fma}\left(-z, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -2.8000000000000001e66 or 3.89999999999999999e-28 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6478.3
Applied rewrites78.3%
if -2.8000000000000001e66 < y < 3.89999999999999999e-28Initial 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--.f6487.2
Applied rewrites87.2%
Taylor expanded in x around 0
Applied rewrites64.1%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- t x) y))) (if (<= y -4.5e-13) t_1 (if (<= y 5.4) (fma x z x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (t - x) * y;
double tmp;
if (y <= -4.5e-13) {
tmp = t_1;
} else if (y <= 5.4) {
tmp = fma(x, 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 <= -4.5e-13) tmp = t_1; elseif (y <= 5.4) tmp = fma(x, 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, -4.5e-13], t$95$1, If[LessEqual[y, 5.4], N[(x * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot y\\
\mathbf{if}\;y \leq -4.5 \cdot 10^{-13}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 5.4:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -4.5e-13 or 5.4000000000000004 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6477.7
Applied rewrites77.7%
if -4.5e-13 < y < 5.4000000000000004Initial 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--.f6491.2
Applied rewrites91.2%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f6458.5
Applied rewrites58.5%
(FPCore (x y z t) :precision binary64 (if (<= z -0.058) (fma x z x) (if (<= z 5e+60) (fma t y x) (* z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.058) {
tmp = fma(x, z, x);
} else if (z <= 5e+60) {
tmp = fma(t, y, x);
} else {
tmp = z * x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -0.058) tmp = fma(x, z, x); elseif (z <= 5e+60) tmp = fma(t, y, x); else tmp = Float64(z * x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -0.058], N[(x * z + x), $MachinePrecision], If[LessEqual[z, 5e+60], N[(t * y + x), $MachinePrecision], N[(z * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.058:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{elif}\;z \leq 5 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -0.0580000000000000029Initial 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--.f6479.4
Applied rewrites79.4%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f6441.4
Applied rewrites41.4%
if -0.0580000000000000029 < z < 4.99999999999999975e60Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6486.9
Applied rewrites86.9%
Taylor expanded in x around 0
Applied rewrites62.6%
if 4.99999999999999975e60 < 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--.f6482.0
Applied rewrites82.0%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f6444.6
Applied rewrites44.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6444.6
Applied rewrites44.6%
(FPCore (x y z t) :precision binary64 (if (<= t -3.5e+80) (* t y) (if (<= t 7.9e+80) (fma x z x) (* t y))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -3.5e+80) {
tmp = t * y;
} else if (t <= 7.9e+80) {
tmp = fma(x, z, x);
} else {
tmp = t * y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (t <= -3.5e+80) tmp = Float64(t * y); elseif (t <= 7.9e+80) tmp = fma(x, z, x); else tmp = Float64(t * y); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[t, -3.5e+80], N[(t * y), $MachinePrecision], If[LessEqual[t, 7.9e+80], N[(x * z + x), $MachinePrecision], N[(t * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.5 \cdot 10^{+80}:\\
\;\;\;\;t \cdot y\\
\mathbf{elif}\;t \leq 7.9 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot y\\
\end{array}
\end{array}
if t < -3.49999999999999994e80 or 7.89999999999999999e80 < t Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6448.9
Applied rewrites48.9%
Taylor expanded in x around 0
Applied rewrites43.3%
if -3.49999999999999994e80 < t < 7.89999999999999999e80Initial 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--.f6461.1
Applied rewrites61.1%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f6447.3
Applied rewrites47.3%
(FPCore (x y z t) :precision binary64 (if (<= z -1.0) (* z x) (if (<= z 1.15e+17) x (* z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.0) {
tmp = z * x;
} else if (z <= 1.15e+17) {
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 <= (-1.0d0)) then
tmp = z * x
else if (z <= 1.15d+17) 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 <= -1.0) {
tmp = z * x;
} else if (z <= 1.15e+17) {
tmp = x;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.0: tmp = z * x elif z <= 1.15e+17: tmp = x else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.0) tmp = Float64(z * x); elseif (z <= 1.15e+17) tmp = x; else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.0) tmp = z * x; elseif (z <= 1.15e+17) tmp = x; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.0], N[(z * x), $MachinePrecision], If[LessEqual[z, 1.15e+17], x, N[(z * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{+17}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -1 or 1.15e17 < 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--.f6478.7
Applied rewrites78.7%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f6441.8
Applied rewrites41.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6441.5
Applied rewrites41.5%
if -1 < z < 1.15e17Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6489.2
Applied rewrites89.2%
Taylor expanded in y around 0
Applied rewrites32.7%
(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.7
Applied rewrites60.7%
Taylor expanded in y around 0
Applied rewrites18.2%
(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 2025091
(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))))