
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + (((y - x) * 6.0d0) * ((2.0d0 / 3.0d0) - z))
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
def code(x, y, z): return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z))
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(Float64(2.0 / 3.0) - z))) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * ((2.0 / 3.0) - z)); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + (((y - x) * 6.0d0) * ((2.0d0 / 3.0d0) - z))
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
def code(x, y, z): return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z))
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(Float64(2.0 / 3.0) - z))) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * ((2.0 / 3.0) - z)); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\end{array}
(FPCore (x y z) :precision binary64 (+ x (* (- y x) (fma -6.0 z 4.0))))
double code(double x, double y, double z) {
return x + ((y - x) * fma(-6.0, z, 4.0));
}
function code(x, y, z) return Float64(x + Float64(Float64(y - x) * fma(-6.0, z, 4.0))) end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(-6.0 * z + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - x\right) \cdot \mathsf{fma}\left(-6, z, 4\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (<= t_0 -100000.0)
(* (* z x) 6.0)
(if (<= t_0 20.0)
(fma -3.0 x (* 4.0 y))
(if (<= t_0 2e+142) (* (fma -6.0 z 4.0) y) (* (- x) (* -6.0 z)))))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if (t_0 <= -100000.0) {
tmp = (z * x) * 6.0;
} else if (t_0 <= 20.0) {
tmp = fma(-3.0, x, (4.0 * y));
} else if (t_0 <= 2e+142) {
tmp = fma(-6.0, z, 4.0) * y;
} else {
tmp = -x * (-6.0 * z);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_0 <= -100000.0) tmp = Float64(Float64(z * x) * 6.0); elseif (t_0 <= 20.0) tmp = fma(-3.0, x, Float64(4.0 * y)); elseif (t_0 <= 2e+142) tmp = Float64(fma(-6.0, z, 4.0) * y); else tmp = Float64(Float64(-x) * Float64(-6.0 * z)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -100000.0], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision], If[LessEqual[t$95$0, 20.0], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+142], N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision], N[((-x) * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -100000:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\mathbf{elif}\;t\_0 \leq 20:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+142}:\\
\;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot \left(-6 \cdot z\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e5Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6498.7
Applied rewrites98.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6451.7
Applied rewrites51.7%
if -1e5 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 20Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6496.8
Applied rewrites96.8%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6496.9
Applied rewrites96.9%
if 20 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 2.0000000000000001e142Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.6
Applied rewrites99.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6453.6
Applied rewrites53.6%
if 2.0000000000000001e142 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in x around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
lower-fma.f6451.5
Applied rewrites51.5%
Taylor expanded in z around inf
lift-*.f6451.5
Applied rewrites51.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* z x) 6.0)))
(if (<= t_0 -100000.0)
t_1
(if (<= t_0 20.0)
(fma -3.0 x (* 4.0 y))
(if (<= t_0 2e+142) (* (fma -6.0 z 4.0) y) t_1)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = (z * x) * 6.0;
double tmp;
if (t_0 <= -100000.0) {
tmp = t_1;
} else if (t_0 <= 20.0) {
tmp = fma(-3.0, x, (4.0 * y));
} else if (t_0 <= 2e+142) {
tmp = fma(-6.0, z, 4.0) * y;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(Float64(z * x) * 6.0) tmp = 0.0 if (t_0 <= -100000.0) tmp = t_1; elseif (t_0 <= 20.0) tmp = fma(-3.0, x, Float64(4.0 * y)); elseif (t_0 <= 2e+142) tmp = Float64(fma(-6.0, z, 4.0) * y); else tmp = t_1; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]}, If[LessEqual[t$95$0, -100000.0], t$95$1, If[LessEqual[t$95$0, 20.0], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+142], N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(z \cdot x\right) \cdot 6\\
\mathbf{if}\;t\_0 \leq -100000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 20:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+142}:\\
\;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e5 or 2.0000000000000001e142 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.1
Applied rewrites99.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
if -1e5 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 20Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6496.8
Applied rewrites96.8%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6496.9
Applied rewrites96.9%
if 20 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 2.0000000000000001e142Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.6
Applied rewrites99.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6453.6
Applied rewrites53.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* z x) 6.0)))
(if (<= t_0 -100000.0)
t_1
(if (<= t_0 20.0)
(fma -3.0 x (* 4.0 y))
(if (<= t_0 2e+142) (* (* y -6.0) z) t_1)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = (z * x) * 6.0;
double tmp;
if (t_0 <= -100000.0) {
tmp = t_1;
} else if (t_0 <= 20.0) {
tmp = fma(-3.0, x, (4.0 * y));
} else if (t_0 <= 2e+142) {
tmp = (y * -6.0) * z;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(Float64(z * x) * 6.0) tmp = 0.0 if (t_0 <= -100000.0) tmp = t_1; elseif (t_0 <= 20.0) tmp = fma(-3.0, x, Float64(4.0 * y)); elseif (t_0 <= 2e+142) tmp = Float64(Float64(y * -6.0) * z); else tmp = t_1; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]}, If[LessEqual[t$95$0, -100000.0], t$95$1, If[LessEqual[t$95$0, 20.0], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+142], N[(N[(y * -6.0), $MachinePrecision] * z), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(z \cdot x\right) \cdot 6\\
\mathbf{if}\;t\_0 \leq -100000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 20:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+142}:\\
\;\;\;\;\left(y \cdot -6\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e5 or 2.0000000000000001e142 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.1
Applied rewrites99.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
if -1e5 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 20Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6496.8
Applied rewrites96.8%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6496.9
Applied rewrites96.9%
if 20 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 2.0000000000000001e142Initial program 99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6495.4
Applied rewrites95.4%
Taylor expanded in x around 0
Applied rewrites51.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6451.8
Applied rewrites51.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6451.8
Applied rewrites51.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* z x) 6.0)))
(if (<= t_0 -100000.0)
t_1
(if (<= t_0 20.0)
(fma 4.0 (- y x) x)
(if (<= t_0 2e+142) (* (* y -6.0) z) t_1)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = (z * x) * 6.0;
double tmp;
if (t_0 <= -100000.0) {
tmp = t_1;
} else if (t_0 <= 20.0) {
tmp = fma(4.0, (y - x), x);
} else if (t_0 <= 2e+142) {
tmp = (y * -6.0) * z;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(Float64(z * x) * 6.0) tmp = 0.0 if (t_0 <= -100000.0) tmp = t_1; elseif (t_0 <= 20.0) tmp = fma(4.0, Float64(y - x), x); elseif (t_0 <= 2e+142) tmp = Float64(Float64(y * -6.0) * z); else tmp = t_1; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]}, If[LessEqual[t$95$0, -100000.0], t$95$1, If[LessEqual[t$95$0, 20.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$0, 2e+142], N[(N[(y * -6.0), $MachinePrecision] * z), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(z \cdot x\right) \cdot 6\\
\mathbf{if}\;t\_0 \leq -100000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 20:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+142}:\\
\;\;\;\;\left(y \cdot -6\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e5 or 2.0000000000000001e142 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.1
Applied rewrites99.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
if -1e5 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 20Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6496.8
Applied rewrites96.8%
if 20 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 2.0000000000000001e142Initial program 99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6495.4
Applied rewrites95.4%
Taylor expanded in x around 0
Applied rewrites51.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6451.8
Applied rewrites51.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6451.8
Applied rewrites51.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* z x) 6.0)))
(if (<= t_0 -100000.0)
t_1
(if (<= t_0 20.0)
(fma 4.0 (- y x) x)
(if (<= t_0 2e+142) (* y (* -6.0 z)) t_1)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = (z * x) * 6.0;
double tmp;
if (t_0 <= -100000.0) {
tmp = t_1;
} else if (t_0 <= 20.0) {
tmp = fma(4.0, (y - x), x);
} else if (t_0 <= 2e+142) {
tmp = y * (-6.0 * z);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(Float64(z * x) * 6.0) tmp = 0.0 if (t_0 <= -100000.0) tmp = t_1; elseif (t_0 <= 20.0) tmp = fma(4.0, Float64(y - x), x); elseif (t_0 <= 2e+142) tmp = Float64(y * Float64(-6.0 * z)); else tmp = t_1; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]}, If[LessEqual[t$95$0, -100000.0], t$95$1, If[LessEqual[t$95$0, 20.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$0, 2e+142], N[(y * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(z \cdot x\right) \cdot 6\\
\mathbf{if}\;t\_0 \leq -100000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 20:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+142}:\\
\;\;\;\;y \cdot \left(-6 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e5 or 2.0000000000000001e142 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.1
Applied rewrites99.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
if -1e5 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 20Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6496.8
Applied rewrites96.8%
if 20 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 2.0000000000000001e142Initial program 99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6495.4
Applied rewrites95.4%
Taylor expanded in x around 0
Applied rewrites51.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6451.8
Applied rewrites51.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* z x) 6.0))) (if (<= t_0 -100000.0) t_1 (if (<= t_0 1.0) (fma 4.0 (- y x) x) t_1))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = (z * x) * 6.0;
double tmp;
if (t_0 <= -100000.0) {
tmp = t_1;
} else if (t_0 <= 1.0) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(Float64(z * x) * 6.0) tmp = 0.0 if (t_0 <= -100000.0) tmp = t_1; elseif (t_0 <= 1.0) tmp = fma(4.0, Float64(y - x), x); else tmp = t_1; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision]}, If[LessEqual[t$95$0, -100000.0], t$95$1, If[LessEqual[t$95$0, 1.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(z \cdot x\right) \cdot 6\\
\mathbf{if}\;t\_0 \leq -100000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e5 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6498.0
Applied rewrites98.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6450.3
Applied rewrites50.3%
if -1e5 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.0
Applied rewrites97.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- x) (fma -6.0 z 3.0))))
(if (<= z -1.8e+142)
t_0
(if (<= z -14.5)
(* (fma -6.0 z 4.0) y)
(if (<= z 4.5e-16) (fma -3.0 x (* 4.0 y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = -x * fma(-6.0, z, 3.0);
double tmp;
if (z <= -1.8e+142) {
tmp = t_0;
} else if (z <= -14.5) {
tmp = fma(-6.0, z, 4.0) * y;
} else if (z <= 4.5e-16) {
tmp = fma(-3.0, x, (4.0 * y));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(-x) * fma(-6.0, z, 3.0)) tmp = 0.0 if (z <= -1.8e+142) tmp = t_0; elseif (z <= -14.5) tmp = Float64(fma(-6.0, z, 4.0) * y); elseif (z <= 4.5e-16) tmp = fma(-3.0, x, Float64(4.0 * y)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[((-x) * N[(-6.0 * z + 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.8e+142], t$95$0, If[LessEqual[z, -14.5], N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[z, 4.5e-16], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-x\right) \cdot \mathsf{fma}\left(-6, z, 3\right)\\
\mathbf{if}\;z \leq -1.8 \cdot 10^{+142}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -14.5:\\
\;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.8000000000000001e142 or 4.5000000000000002e-16 < z Initial program 99.7%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in x around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
lower-fma.f6451.8
Applied rewrites51.8%
if -1.8000000000000001e142 < z < -14.5Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.6
Applied rewrites99.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lift-fma.f6453.6
Applied rewrites53.6%
if -14.5 < z < 4.5000000000000002e-16Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6498.5
Applied rewrites98.5%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6498.6
Applied rewrites98.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (* -6.0 (- y x)) z))) (if (<= z -0.58) t_0 (if (<= z 0.6) (fma -3.0 x (* 4.0 y)) t_0))))
double code(double x, double y, double z) {
double t_0 = (-6.0 * (y - x)) * z;
double tmp;
if (z <= -0.58) {
tmp = t_0;
} else if (z <= 0.6) {
tmp = fma(-3.0, x, (4.0 * y));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(-6.0 * Float64(y - x)) * z) tmp = 0.0 if (z <= -0.58) tmp = t_0; elseif (z <= 0.6) tmp = fma(-3.0, x, Float64(4.0 * y)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-6.0 * N[(y - x), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -0.58], t$95$0, If[LessEqual[z, 0.6], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-6 \cdot \left(y - x\right)\right) \cdot z\\
\mathbf{if}\;z \leq -0.58:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.6:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.57999999999999996 or 0.599999999999999978 < z Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6497.6
Applied rewrites97.6%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lower-*.f6497.6
Applied rewrites97.6%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f6497.6
Applied rewrites97.6%
if -0.57999999999999996 < z < 0.599999999999999978Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6497.6
Applied rewrites97.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6497.7
Applied rewrites97.7%
(FPCore (x y z) :precision binary64 (if (<= y -1.95e-79) (* 4.0 y) (if (<= y 1.25e-7) (* -3.0 x) (* 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.95e-79) {
tmp = 4.0 * y;
} else if (y <= 1.25e-7) {
tmp = -3.0 * x;
} else {
tmp = 4.0 * y;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.95d-79)) then
tmp = 4.0d0 * y
else if (y <= 1.25d-7) then
tmp = (-3.0d0) * x
else
tmp = 4.0d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.95e-79) {
tmp = 4.0 * y;
} else if (y <= 1.25e-7) {
tmp = -3.0 * x;
} else {
tmp = 4.0 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.95e-79: tmp = 4.0 * y elif y <= 1.25e-7: tmp = -3.0 * x else: tmp = 4.0 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.95e-79) tmp = Float64(4.0 * y); elseif (y <= 1.25e-7) tmp = Float64(-3.0 * x); else tmp = Float64(4.0 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.95e-79) tmp = 4.0 * y; elseif (y <= 1.25e-7) tmp = -3.0 * x; else tmp = 4.0 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.95e-79], N[(4.0 * y), $MachinePrecision], If[LessEqual[y, 1.25e-7], N[(-3.0 * x), $MachinePrecision], N[(4.0 * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{-79}:\\
\;\;\;\;4 \cdot y\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{-7}:\\
\;\;\;\;-3 \cdot x\\
\mathbf{else}:\\
\;\;\;\;4 \cdot y\\
\end{array}
\end{array}
if y < -1.95000000000000003e-79 or 1.24999999999999994e-7 < y Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.0
Applied rewrites51.0%
Taylor expanded in x around 0
lower-*.f6436.6
Applied rewrites36.6%
if -1.95000000000000003e-79 < y < 1.24999999999999994e-7Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6450.9
Applied rewrites50.9%
Taylor expanded in x around inf
lower-*.f6440.2
Applied rewrites40.2%
(FPCore (x y z) :precision binary64 (fma (- y x) (fma -6.0 z 4.0) x))
double code(double x, double y, double z) {
return fma((y - x), fma(-6.0, z, 4.0), x);
}
function code(x, y, z) return fma(Float64(y - x), fma(-6.0, z, 4.0), x) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(-6.0 * z + 4.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, \mathsf{fma}\left(-6, z, 4\right), x\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lift--.f64N/A
lower-fma.f6499.7
Applied rewrites99.7%
(FPCore (x y z) :precision binary64 (fma 4.0 (- y x) x))
double code(double x, double y, double z) {
return fma(4.0, (y - x), x);
}
function code(x, y, z) return fma(4.0, Float64(y - x), x) end
code[x_, y_, z_] := N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4, y - x, x\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.0
Applied rewrites51.0%
(FPCore (x y z) :precision binary64 (* -3.0 x))
double code(double x, double y, double z) {
return -3.0 * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (-3.0d0) * x
end function
public static double code(double x, double y, double z) {
return -3.0 * x;
}
def code(x, y, z): return -3.0 * x
function code(x, y, z) return Float64(-3.0 * x) end
function tmp = code(x, y, z) tmp = -3.0 * x; end
code[x_, y_, z_] := N[(-3.0 * x), $MachinePrecision]
\begin{array}{l}
\\
-3 \cdot x
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6451.0
Applied rewrites51.0%
Taylor expanded in x around inf
lower-*.f6426.5
Applied rewrites26.5%
herbie shell --seed 2025093
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, D"
:precision binary64
(+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))