
(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 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));
}
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 (fma -6.0 z 4.0) (- y x) x))
double code(double x, double y, double z) {
return fma(fma(-6.0, z, 4.0), (y - x), x);
}
function code(x, y, z) return fma(fma(-6.0, z, 4.0), Float64(y - x), x) end
code[x_, y_, z_] := N[(N[(-6.0 * z + 4.0), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(-6, z, 4\right), y - x, 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
lower-fma.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
neg-mul-1N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lift-/.f64N/A
metadata-evalN/A
metadata-eval99.7
Applied rewrites99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* z -6.0) y)))
(if (<= t_0 -10000.0)
t_1
(if (<= t_0 1.0)
(fma -3.0 x (* y 4.0))
(if (<= t_0 4e+18) (* (* 6.0 z) x) t_1)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = (z * -6.0) * y;
double tmp;
if (t_0 <= -10000.0) {
tmp = t_1;
} else if (t_0 <= 1.0) {
tmp = fma(-3.0, x, (y * 4.0));
} else if (t_0 <= 4e+18) {
tmp = (6.0 * z) * 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 * -6.0) * y) tmp = 0.0 if (t_0 <= -10000.0) tmp = t_1; elseif (t_0 <= 1.0) tmp = fma(-3.0, x, Float64(y * 4.0)); elseif (t_0 <= 4e+18) tmp = Float64(Float64(6.0 * z) * 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 * -6.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, -10000.0], t$95$1, If[LessEqual[t$95$0, 1.0], N[(-3.0 * x + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+18], N[(N[(6.0 * z), $MachinePrecision] * x), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(z \cdot -6\right) \cdot y\\
\mathbf{if}\;t\_0 \leq -10000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-3, x, y \cdot 4\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+18}:\\
\;\;\;\;\left(6 \cdot z\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4 or 4e18 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
neg-mul-1N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lift-/.f64N/A
metadata-evalN/A
metadata-eval99.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6463.1
Applied rewrites63.1%
Taylor expanded in z around inf
Applied rewrites61.8%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6495.9
Applied rewrites95.9%
Taylor expanded in x around 0
Applied rewrites96.0%
if 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 4e18Initial program 99.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
neg-mul-1N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lift-/.f64N/A
metadata-evalN/A
metadata-eval99.8
Applied rewrites99.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6415.2
Applied rewrites15.2%
Taylor expanded in x around inf
*-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
associate-+r+N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f6488.0
Applied rewrites88.0%
Taylor expanded in z around inf
Applied rewrites66.9%
Final simplification77.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* z -6.0) y)))
(if (<= t_0 -10000.0)
t_1
(if (<= t_0 1.0)
(fma (- y x) 4.0 x)
(if (<= t_0 4e+18) (* (* 6.0 z) x) t_1)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = (z * -6.0) * y;
double tmp;
if (t_0 <= -10000.0) {
tmp = t_1;
} else if (t_0 <= 1.0) {
tmp = fma((y - x), 4.0, x);
} else if (t_0 <= 4e+18) {
tmp = (6.0 * z) * 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 * -6.0) * y) tmp = 0.0 if (t_0 <= -10000.0) tmp = t_1; elseif (t_0 <= 1.0) tmp = fma(Float64(y - x), 4.0, x); elseif (t_0 <= 4e+18) tmp = Float64(Float64(6.0 * z) * 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 * -6.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, -10000.0], t$95$1, If[LessEqual[t$95$0, 1.0], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], If[LessEqual[t$95$0, 4e+18], N[(N[(6.0 * z), $MachinePrecision] * x), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(z \cdot -6\right) \cdot y\\
\mathbf{if}\;t\_0 \leq -10000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+18}:\\
\;\;\;\;\left(6 \cdot z\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4 or 4e18 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
neg-mul-1N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lift-/.f64N/A
metadata-evalN/A
metadata-eval99.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6463.1
Applied rewrites63.1%
Taylor expanded in z around inf
Applied rewrites61.8%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6495.9
Applied rewrites95.9%
if 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 4e18Initial program 99.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
neg-mul-1N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lift-/.f64N/A
metadata-evalN/A
metadata-eval99.8
Applied rewrites99.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6415.2
Applied rewrites15.2%
Taylor expanded in x around inf
*-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
associate-+r+N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f6488.0
Applied rewrites88.0%
Taylor expanded in z around inf
Applied rewrites66.9%
Final simplification77.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (fma (* z -6.0) (- y x) x))) (if (<= t_0 -10000.0) t_1 (if (<= t_0 1.0) (fma -3.0 x (* y 4.0)) t_1))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = fma((z * -6.0), (y - x), x);
double tmp;
if (t_0 <= -10000.0) {
tmp = t_1;
} else if (t_0 <= 1.0) {
tmp = fma(-3.0, x, (y * 4.0));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = fma(Float64(z * -6.0), Float64(y - x), x) tmp = 0.0 if (t_0 <= -10000.0) tmp = t_1; elseif (t_0 <= 1.0) tmp = fma(-3.0, x, Float64(y * 4.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 * -6.0), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t$95$0, -10000.0], t$95$1, If[LessEqual[t$95$0, 1.0], N[(-3.0 * x + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \mathsf{fma}\left(z \cdot -6, y - x, x\right)\\
\mathbf{if}\;t\_0 \leq -10000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-3, x, y \cdot 4\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%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
neg-mul-1N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lift-/.f64N/A
metadata-evalN/A
metadata-eval99.7
Applied rewrites99.7%
Taylor expanded in z around inf
lower-*.f6496.4
Applied rewrites96.4%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6495.9
Applied rewrites95.9%
Taylor expanded in x around 0
Applied rewrites96.0%
Final simplification96.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* (- y x) -6.0) z))) (if (<= t_0 -10000.0) t_1 (if (<= t_0 1.0) (fma -3.0 x (* y 4.0)) t_1))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = ((y - x) * -6.0) * z;
double tmp;
if (t_0 <= -10000.0) {
tmp = t_1;
} else if (t_0 <= 1.0) {
tmp = fma(-3.0, x, (y * 4.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(Float64(y - x) * -6.0) * z) tmp = 0.0 if (t_0 <= -10000.0) tmp = t_1; elseif (t_0 <= 1.0) tmp = fma(-3.0, x, Float64(y * 4.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[(N[(y - x), $MachinePrecision] * -6.0), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$0, -10000.0], t$95$1, If[LessEqual[t$95$0, 1.0], N[(-3.0 * x + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(\left(y - x\right) \cdot -6\right) \cdot z\\
\mathbf{if}\;t\_0 \leq -10000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-3, x, y \cdot 4\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%
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.7
lift-/.f64N/A
metadata-eval99.7
Applied rewrites99.7%
metadata-evalN/A
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
remove-double-divN/A
lift-/.f64N/A
div-invN/A
frac-2negN/A
times-fracN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
times-fracN/A
metadata-evalN/A
Applied rewrites99.6%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6496.3
Applied rewrites96.3%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6495.9
Applied rewrites95.9%
Taylor expanded in x around 0
Applied rewrites96.0%
Final simplification96.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* (- y x) z) -6.0))) (if (<= t_0 -10000.0) t_1 (if (<= t_0 1.0) (fma -3.0 x (* y 4.0)) t_1))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = ((y - x) * z) * -6.0;
double tmp;
if (t_0 <= -10000.0) {
tmp = t_1;
} else if (t_0 <= 1.0) {
tmp = fma(-3.0, x, (y * 4.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(Float64(y - x) * z) * -6.0) tmp = 0.0 if (t_0 <= -10000.0) tmp = t_1; elseif (t_0 <= 1.0) tmp = fma(-3.0, x, Float64(y * 4.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[(N[(y - x), $MachinePrecision] * z), $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[(y * 4.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(\left(y - x\right) \cdot z\right) \cdot -6\\
\mathbf{if}\;t\_0 \leq -10000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-3, x, y \cdot 4\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--.f6496.3
Applied rewrites96.3%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6495.9
Applied rewrites95.9%
Taylor expanded in x around 0
Applied rewrites96.0%
Final simplification96.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* y (fma -6.0 z 4.0)))) (if (<= t_0 0.6665) t_1 (if (<= t_0 0.68) (fma -3.0 x (* y 4.0)) t_1))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = y * fma(-6.0, z, 4.0);
double tmp;
if (t_0 <= 0.6665) {
tmp = t_1;
} else if (t_0 <= 0.68) {
tmp = fma(-3.0, x, (y * 4.0));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(y * fma(-6.0, z, 4.0)) tmp = 0.0 if (t_0 <= 0.6665) tmp = t_1; elseif (t_0 <= 0.68) tmp = fma(-3.0, x, Float64(y * 4.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[(y * N[(-6.0 * z + 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.6665], t$95$1, If[LessEqual[t$95$0, 0.68], N[(-3.0 * x + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := y \cdot \mathsf{fma}\left(-6, z, 4\right)\\
\mathbf{if}\;t\_0 \leq 0.6665:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.68:\\
\;\;\;\;\mathsf{fma}\left(-3, x, y \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 0.666499999999999981 or 0.680000000000000049 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.6%
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.f6459.9
Applied rewrites59.9%
if 0.666499999999999981 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 0.680000000000000049Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6498.2
Applied rewrites98.2%
Taylor expanded in x around 0
Applied rewrites98.3%
Final simplification77.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* z -6.0) y))) (if (<= t_0 -10000.0) t_1 (if (<= t_0 4e+18) (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 * -6.0) * y;
double tmp;
if (t_0 <= -10000.0) {
tmp = t_1;
} else if (t_0 <= 4e+18) {
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 * -6.0) * y) tmp = 0.0 if (t_0 <= -10000.0) tmp = t_1; elseif (t_0 <= 4e+18) 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 * -6.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, -10000.0], t$95$1, If[LessEqual[t$95$0, 4e+18], 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 -6\right) \cdot y\\
\mathbf{if}\;t\_0 \leq -10000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+18}:\\
\;\;\;\;\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 4e18 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
neg-mul-1N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lift-/.f64N/A
metadata-evalN/A
metadata-eval99.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6463.1
Applied rewrites63.1%
Taylor expanded in z around inf
Applied rewrites61.8%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 4e18Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6490.6
Applied rewrites90.6%
Final simplification76.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* y -6.0) z))) (if (<= t_0 -10000.0) t_1 (if (<= t_0 4e+18) (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 = (y * -6.0) * z;
double tmp;
if (t_0 <= -10000.0) {
tmp = t_1;
} else if (t_0 <= 4e+18) {
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(y * -6.0) * z) tmp = 0.0 if (t_0 <= -10000.0) tmp = t_1; elseif (t_0 <= 4e+18) 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[(y * -6.0), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$0, -10000.0], t$95$1, If[LessEqual[t$95$0, 4e+18], 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(y \cdot -6\right) \cdot z\\
\mathbf{if}\;t\_0 \leq -10000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+18}:\\
\;\;\;\;\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 4e18 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
neg-mul-1N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lift-/.f64N/A
metadata-evalN/A
metadata-eval99.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6463.1
Applied rewrites63.1%
Taylor expanded in z around inf
Applied rewrites61.8%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 4e18Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6490.6
Applied rewrites90.6%
Final simplification76.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* y (fma -6.0 z 4.0)))) (if (<= y -3.3e-29) t_0 (if (<= y 2.2e-43) (* (fma 6.0 z -3.0) x) t_0))))
double code(double x, double y, double z) {
double t_0 = y * fma(-6.0, z, 4.0);
double tmp;
if (y <= -3.3e-29) {
tmp = t_0;
} else if (y <= 2.2e-43) {
tmp = fma(6.0, z, -3.0) * x;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y * fma(-6.0, z, 4.0)) tmp = 0.0 if (y <= -3.3e-29) tmp = t_0; elseif (y <= 2.2e-43) tmp = Float64(fma(6.0, z, -3.0) * x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(-6.0 * z + 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.3e-29], t$95$0, If[LessEqual[y, 2.2e-43], N[(N[(6.0 * z + -3.0), $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \mathsf{fma}\left(-6, z, 4\right)\\
\mathbf{if}\;y \leq -3.3 \cdot 10^{-29}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{-43}:\\
\;\;\;\;\mathsf{fma}\left(6, z, -3\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.30000000000000028e-29 or 2.19999999999999997e-43 < y 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.f6482.8
Applied rewrites82.8%
if -3.30000000000000028e-29 < y < 2.19999999999999997e-43Initial program 99.3%
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 rewrites80.4%
Final simplification81.8%
(FPCore (x y z) :precision binary64 (if (<= y -0.085) (* y 4.0) (if (<= y 8500000000.0) (* -3.0 x) (* y 4.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -0.085) {
tmp = y * 4.0;
} else if (y <= 8500000000.0) {
tmp = -3.0 * x;
} else {
tmp = y * 4.0;
}
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 <= (-0.085d0)) then
tmp = y * 4.0d0
else if (y <= 8500000000.0d0) then
tmp = (-3.0d0) * x
else
tmp = y * 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -0.085) {
tmp = y * 4.0;
} else if (y <= 8500000000.0) {
tmp = -3.0 * x;
} else {
tmp = y * 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -0.085: tmp = y * 4.0 elif y <= 8500000000.0: tmp = -3.0 * x else: tmp = y * 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -0.085) tmp = Float64(y * 4.0); elseif (y <= 8500000000.0) tmp = Float64(-3.0 * x); else tmp = Float64(y * 4.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -0.085) tmp = y * 4.0; elseif (y <= 8500000000.0) tmp = -3.0 * x; else tmp = y * 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -0.085], N[(y * 4.0), $MachinePrecision], If[LessEqual[y, 8500000000.0], N[(-3.0 * x), $MachinePrecision], N[(y * 4.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.085:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;y \leq 8500000000:\\
\;\;\;\;-3 \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot 4\\
\end{array}
\end{array}
if y < -0.0850000000000000061 or 8.5e9 < y Initial program 99.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6449.8
Applied rewrites49.8%
Taylor expanded in x around 0
Applied rewrites42.4%
if -0.0850000000000000061 < y < 8.5e9Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6444.4
Applied rewrites44.4%
Taylor expanded in x around inf
Applied rewrites39.9%
Final simplification41.1%
(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--.f6447.1
Applied rewrites47.1%
(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--.f6447.1
Applied rewrites47.1%
Taylor expanded in x around inf
Applied rewrites24.7%
herbie shell --seed 2024288
(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))))