
(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));
}
real(8) function code(x, y, z)
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}
Sampling outcomes in binary64 precision:
Herbie found 15 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));
}
real(8) function code(x, y, z)
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 (fma (- y x) 4.0 (fma (* z -6.0) (- y x) x)))
double code(double x, double y, double z) {
return fma((y - x), 4.0, fma((z * -6.0), (y - x), x));
}
function code(x, y, z) return fma(Float64(y - x), 4.0, fma(Float64(z * -6.0), Float64(y - x), x)) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * 4.0 + N[(N[(z * -6.0), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, 4, \mathsf{fma}\left(z \cdot -6, y - x, x\right)\right)
\end{array}
Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.7%
Final simplification99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (fma -6.0 z 4.0) y)))
(if (<= t_0 0.66666666666)
t_1
(if (<= t_0 0.6666666666666669)
(fma (- y x) 4.0 x)
(if (<= t_0 1e+252) (* (fma 6.0 z -3.0) x) t_1)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = fma(-6.0, z, 4.0) * y;
double tmp;
if (t_0 <= 0.66666666666) {
tmp = t_1;
} else if (t_0 <= 0.6666666666666669) {
tmp = fma((y - x), 4.0, x);
} else if (t_0 <= 1e+252) {
tmp = fma(6.0, z, -3.0) * x;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(fma(-6.0, z, 4.0) * y) tmp = 0.0 if (t_0 <= 0.66666666666) tmp = t_1; elseif (t_0 <= 0.6666666666666669) tmp = fma(Float64(y - x), 4.0, x); elseif (t_0 <= 1e+252) tmp = Float64(fma(6.0, z, -3.0) * 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[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, 0.66666666666], t$95$1, If[LessEqual[t$95$0, 0.6666666666666669], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], If[LessEqual[t$95$0, 1e+252], N[(N[(6.0 * z + -3.0), $MachinePrecision] * x), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{if}\;t\_0 \leq 0.66666666666:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.6666666666666669:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{elif}\;t\_0 \leq 10^{+252}:\\
\;\;\;\;\mathsf{fma}\left(6, z, -3\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 0.666666666659999962 or 1.0000000000000001e252 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f6464.2
Applied rewrites64.2%
if 0.666666666659999962 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 0.666666666666666852Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6499.7
Applied rewrites99.7%
if 0.666666666666666852 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1.0000000000000001e252Initial program 99.7%
Taylor expanded in x around inf
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
metadata-evalN/A
distribute-lft-neg-inN/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
associate-*r*N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
Applied rewrites64.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (fma -6.0 z 4.0) y)))
(if (<= t_0 0.66666666666)
t_1
(if (<= t_0 40000000.0)
(fma (- y x) 4.0 x)
(if (<= t_0 1e+252) (* (* z x) 6.0) t_1)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = fma(-6.0, z, 4.0) * y;
double tmp;
if (t_0 <= 0.66666666666) {
tmp = t_1;
} else if (t_0 <= 40000000.0) {
tmp = fma((y - x), 4.0, x);
} else if (t_0 <= 1e+252) {
tmp = (z * x) * 6.0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(fma(-6.0, z, 4.0) * y) tmp = 0.0 if (t_0 <= 0.66666666666) tmp = t_1; elseif (t_0 <= 40000000.0) tmp = fma(Float64(y - x), 4.0, x); elseif (t_0 <= 1e+252) tmp = Float64(Float64(z * x) * 6.0); 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[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, 0.66666666666], t$95$1, If[LessEqual[t$95$0, 40000000.0], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], If[LessEqual[t$95$0, 1e+252], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{if}\;t\_0 \leq 0.66666666666:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 40000000:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{elif}\;t\_0 \leq 10^{+252}:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 0.666666666659999962 or 1.0000000000000001e252 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f6464.2
Applied rewrites64.2%
if 0.666666666659999962 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 4e7Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6498.0
Applied rewrites98.0%
if 4e7 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1.0000000000000001e252Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
div-invN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites84.3%
metadata-evalN/A
lift-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6499.2
Applied rewrites99.2%
Taylor expanded in x around inf
Applied rewrites66.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* z y) -6.0)))
(if (<= t_0 -10000.0)
t_1
(if (<= t_0 40000000.0)
(fma (- y x) 4.0 x)
(if (<= t_0 1e+252) (* (* z x) 6.0) t_1)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = (z * y) * -6.0;
double tmp;
if (t_0 <= -10000.0) {
tmp = t_1;
} else if (t_0 <= 40000000.0) {
tmp = fma((y - x), 4.0, x);
} else if (t_0 <= 1e+252) {
tmp = (z * x) * 6.0;
} 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 * y) * -6.0) tmp = 0.0 if (t_0 <= -10000.0) tmp = t_1; elseif (t_0 <= 40000000.0) tmp = fma(Float64(y - x), 4.0, x); elseif (t_0 <= 1e+252) tmp = Float64(Float64(z * x) * 6.0); 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 * y), $MachinePrecision] * -6.0), $MachinePrecision]}, If[LessEqual[t$95$0, -10000.0], t$95$1, If[LessEqual[t$95$0, 40000000.0], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], If[LessEqual[t$95$0, 1e+252], N[(N[(z * x), $MachinePrecision] * 6.0), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(z \cdot y\right) \cdot -6\\
\mathbf{if}\;t\_0 \leq -10000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 40000000:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{elif}\;t\_0 \leq 10^{+252}:\\
\;\;\;\;\left(z \cdot x\right) \cdot 6\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4 or 1.0000000000000001e252 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
div-invN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites66.7%
metadata-evalN/A
lift-fma.f64N/A
Applied rewrites99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6498.4
Applied rewrites98.4%
Taylor expanded in x around 0
Applied rewrites60.4%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 4e7Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6496.9
Applied rewrites96.9%
if 4e7 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1.0000000000000001e252Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
div-invN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites84.3%
metadata-evalN/A
lift-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6499.2
Applied rewrites99.2%
Taylor expanded in x around inf
Applied rewrites66.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (<= t_0 -10000.0)
(* (* z -6.0) (- y x))
(if (<= t_0 1.0) (fma -3.0 x (* 4.0 y)) (fma (* (- x y) z) 6.0 x)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if (t_0 <= -10000.0) {
tmp = (z * -6.0) * (y - x);
} else if (t_0 <= 1.0) {
tmp = fma(-3.0, x, (4.0 * y));
} else {
tmp = fma(((x - y) * z), 6.0, x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_0 <= -10000.0) tmp = Float64(Float64(z * -6.0) * Float64(y - x)); elseif (t_0 <= 1.0) tmp = fma(-3.0, x, Float64(4.0 * y)); else tmp = fma(Float64(Float64(x - y) * z), 6.0, x); 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, -10000.0], N[(N[(z * -6.0), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x - y), $MachinePrecision] * z), $MachinePrecision] * 6.0 + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -10000:\\
\;\;\;\;\left(z \cdot -6\right) \cdot \left(y - x\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(x - y\right) \cdot z, 6, x\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
div-invN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites69.2%
metadata-evalN/A
lift-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6498.0
Applied rewrites98.0%
Applied rewrites98.1%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in z around 0
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6497.7
Applied rewrites97.7%
if 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
div-invN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites77.5%
metadata-evalN/A
lift-fma.f64N/A
Applied rewrites99.6%
lift--.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift--.f6499.8
Applied rewrites99.8%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
remove-double-negN/A
lower--.f6498.6
Applied rewrites98.6%
Final simplification98.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (<= t_0 -10000.0)
(* (* z -6.0) (- y x))
(if (<= t_0 1.0) (fma -3.0 x (* 4.0 y)) (* (* z (- y x)) -6.0)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if (t_0 <= -10000.0) {
tmp = (z * -6.0) * (y - x);
} else if (t_0 <= 1.0) {
tmp = fma(-3.0, x, (4.0 * y));
} else {
tmp = (z * (y - x)) * -6.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_0 <= -10000.0) tmp = Float64(Float64(z * -6.0) * Float64(y - x)); elseif (t_0 <= 1.0) tmp = fma(-3.0, x, Float64(4.0 * y)); else tmp = Float64(Float64(z * Float64(y - x)) * -6.0); 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, -10000.0], N[(N[(z * -6.0), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision] * -6.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -10000:\\
\;\;\;\;\left(z \cdot -6\right) \cdot \left(y - x\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(y - x\right)\right) \cdot -6\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
div-invN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites69.2%
metadata-evalN/A
lift-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6498.0
Applied rewrites98.0%
Applied rewrites98.1%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in z around 0
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6497.7
Applied rewrites97.7%
if 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
lower--.f6498.6
Applied rewrites98.6%
Final simplification98.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (<= t_0 -10000.0)
(* (* -6.0 (- y x)) z)
(if (<= t_0 1.0) (fma -3.0 x (* 4.0 y)) (* (* z (- y x)) -6.0)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if (t_0 <= -10000.0) {
tmp = (-6.0 * (y - x)) * z;
} else if (t_0 <= 1.0) {
tmp = fma(-3.0, x, (4.0 * y));
} else {
tmp = (z * (y - x)) * -6.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_0 <= -10000.0) tmp = Float64(Float64(-6.0 * Float64(y - x)) * z); elseif (t_0 <= 1.0) tmp = fma(-3.0, x, Float64(4.0 * y)); else tmp = Float64(Float64(z * Float64(y - x)) * -6.0); 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, -10000.0], N[(N[(-6.0 * N[(y - x), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision] * -6.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -10000:\\
\;\;\;\;\left(-6 \cdot \left(y - x\right)\right) \cdot z\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(y - x\right)\right) \cdot -6\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
div-invN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites69.2%
metadata-evalN/A
lift-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6498.0
Applied rewrites98.0%
Applied rewrites98.1%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in z around 0
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6497.7
Applied rewrites97.7%
if 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
lower--.f6498.6
Applied rewrites98.6%
Final simplification98.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* z (- y x)) -6.0))) (if (<= t_0 -10000.0) t_1 (if (<= t_0 1.0) (fma -3.0 x (* 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 * (y - x)) * -6.0;
double tmp;
if (t_0 <= -10000.0) {
tmp = t_1;
} else if (t_0 <= 1.0) {
tmp = fma(-3.0, x, (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 * Float64(y - x)) * -6.0) tmp = 0.0 if (t_0 <= -10000.0) tmp = t_1; elseif (t_0 <= 1.0) tmp = fma(-3.0, x, Float64(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 * N[(y - x), $MachinePrecision]), $MachinePrecision] * -6.0), $MachinePrecision]}, If[LessEqual[t$95$0, -10000.0], t$95$1, If[LessEqual[t$95$0, 1.0], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(z \cdot \left(y - x\right)\right) \cdot -6\\
\mathbf{if}\;t\_0 \leq -10000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4 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
lower--.f6498.3
Applied rewrites98.3%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in z around 0
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6497.7
Applied rewrites97.7%
Final simplification98.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* z x) 6.0)))
(if (<= t_0 -10000.0)
t_1
(if (<= t_0 40000000.0) (fma (- y x) 4.0 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 <= -10000.0) {
tmp = t_1;
} else if (t_0 <= 40000000.0) {
tmp = fma((y - x), 4.0, 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 <= -10000.0) tmp = t_1; elseif (t_0 <= 40000000.0) tmp = fma(Float64(y - x), 4.0, 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, -10000.0], t$95$1, If[LessEqual[t$95$0, 40000000.0], N[(N[(y - x), $MachinePrecision] * 4.0 + 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 -10000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 40000000:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4 or 4e7 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
div-invN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites72.9%
metadata-evalN/A
lift-fma.f64N/A
Applied rewrites99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6498.6
Applied rewrites98.6%
Taylor expanded in x around inf
Applied rewrites50.9%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 4e7Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6496.9
Applied rewrites96.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (fma -6.0 z 4.0) y)))
(if (<= z -1.65e+252)
t_0
(if (<= z -1.05e-19)
(* (fma 6.0 z -3.0) x)
(if (<= z 7.8e-19) (fma -3.0 x (* 4.0 y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = fma(-6.0, z, 4.0) * y;
double tmp;
if (z <= -1.65e+252) {
tmp = t_0;
} else if (z <= -1.05e-19) {
tmp = fma(6.0, z, -3.0) * x;
} else if (z <= 7.8e-19) {
tmp = fma(-3.0, x, (4.0 * y));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(fma(-6.0, z, 4.0) * y) tmp = 0.0 if (z <= -1.65e+252) tmp = t_0; elseif (z <= -1.05e-19) tmp = Float64(fma(6.0, z, -3.0) * x); elseif (z <= 7.8e-19) 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 * z + 4.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[z, -1.65e+252], t$95$0, If[LessEqual[z, -1.05e-19], N[(N[(6.0 * z + -3.0), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[z, 7.8e-19], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{if}\;z \leq -1.65 \cdot 10^{+252}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.05 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(6, z, -3\right) \cdot x\\
\mathbf{elif}\;z \leq 7.8 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.65e252 or 7.7999999999999999e-19 < z Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f6464.6
Applied rewrites64.6%
if -1.65e252 < z < -1.0499999999999999e-19Initial program 99.6%
Taylor expanded in x around inf
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
distribute-neg-inN/A
metadata-evalN/A
distribute-lft-neg-inN/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
associate-*r*N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
Applied rewrites65.9%
if -1.0499999999999999e-19 < z < 7.7999999999999999e-19Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in z around 0
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (if (<= y -2.7e+56) (* 4.0 y) (if (<= y 2.95e+54) (* -3.0 x) (* 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+56) {
tmp = 4.0 * y;
} else if (y <= 2.95e+54) {
tmp = -3.0 * x;
} else {
tmp = 4.0 * y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-2.7d+56)) then
tmp = 4.0d0 * y
else if (y <= 2.95d+54) 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 <= -2.7e+56) {
tmp = 4.0 * y;
} else if (y <= 2.95e+54) {
tmp = -3.0 * x;
} else {
tmp = 4.0 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.7e+56: tmp = 4.0 * y elif y <= 2.95e+54: tmp = -3.0 * x else: tmp = 4.0 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.7e+56) tmp = Float64(4.0 * y); elseif (y <= 2.95e+54) 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 <= -2.7e+56) tmp = 4.0 * y; elseif (y <= 2.95e+54) tmp = -3.0 * x; else tmp = 4.0 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.7e+56], N[(4.0 * y), $MachinePrecision], If[LessEqual[y, 2.95e+54], N[(-3.0 * x), $MachinePrecision], N[(4.0 * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+56}:\\
\;\;\;\;4 \cdot y\\
\mathbf{elif}\;y \leq 2.95 \cdot 10^{+54}:\\
\;\;\;\;-3 \cdot x\\
\mathbf{else}:\\
\;\;\;\;4 \cdot y\\
\end{array}
\end{array}
if y < -2.7000000000000001e56 or 2.9499999999999999e54 < y Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6455.6
Applied rewrites55.6%
Taylor expanded in x around 0
Applied rewrites46.5%
if -2.7000000000000001e56 < y < 2.9499999999999999e54Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6448.5
Applied rewrites48.5%
Taylor expanded in x around inf
Applied rewrites38.3%
(FPCore (x y z) :precision binary64 (fma (- y x) (* 6.0 (- 0.6666666666666666 z)) x))
double code(double x, double y, double z) {
return fma((y - x), (6.0 * (0.6666666666666666 - z)), x);
}
function code(x, y, z) return fma(Float64(y - x), Float64(6.0 * Float64(0.6666666666666666 - z)), x) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(6.0 * N[(0.6666666666666666 - z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, 6 \cdot \left(0.6666666666666666 - z\right), x\right)
\end{array}
Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
div-invN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites86.4%
metadata-evalN/A
lift-fma.f64N/A
Applied rewrites99.7%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (fma (* (- 0.6666666666666666 z) (- y x)) 6.0 x))
double code(double x, double y, double z) {
return fma(((0.6666666666666666 - z) * (y - x)), 6.0, x);
}
function code(x, y, z) return fma(Float64(Float64(0.6666666666666666 - z) * Float64(y - x)), 6.0, x) end
code[x_, y_, z_] := N[(N[(N[(0.6666666666666666 - z), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision] * 6.0 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(0.6666666666666666 - z\right) \cdot \left(y - x\right), 6, x\right)
\end{array}
Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.5
lift-/.f64N/A
metadata-eval99.5
Applied rewrites99.5%
(FPCore (x y z) :precision binary64 (fma (- y x) 4.0 x))
double code(double x, double y, double z) {
return fma((y - x), 4.0, x);
}
function code(x, y, z) return fma(Float64(y - x), 4.0, x) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, 4, x\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6451.2
Applied rewrites51.2%
(FPCore (x y z) :precision binary64 (* -3.0 x))
double code(double x, double y, double z) {
return -3.0 * x;
}
real(8) function code(x, y, z)
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
*-commutativeN/A
lower-fma.f64N/A
lower--.f6451.2
Applied rewrites51.2%
Taylor expanded in x around inf
Applied rewrites28.0%
herbie shell --seed 2024296
(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))))