
(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 12 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.8
Applied rewrites99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* y z) -6.0)))
(if (<= t_0 -200.0)
t_1
(if (<= t_0 2000000000.0)
(fma (- y x) 4.0 x)
(if (<= t_0 4e+85) (* (* x z) 6.0) t_1)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = (y * z) * -6.0;
double tmp;
if (t_0 <= -200.0) {
tmp = t_1;
} else if (t_0 <= 2000000000.0) {
tmp = fma((y - x), 4.0, x);
} else if (t_0 <= 4e+85) {
tmp = (x * z) * 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(y * z) * -6.0) tmp = 0.0 if (t_0 <= -200.0) tmp = t_1; elseif (t_0 <= 2000000000.0) tmp = fma(Float64(y - x), 4.0, x); elseif (t_0 <= 4e+85) tmp = Float64(Float64(x * z) * 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[(y * z), $MachinePrecision] * -6.0), $MachinePrecision]}, If[LessEqual[t$95$0, -200.0], t$95$1, If[LessEqual[t$95$0, 2000000000.0], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], If[LessEqual[t$95$0, 4e+85], N[(N[(x * z), $MachinePrecision] * 6.0), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(y \cdot z\right) \cdot -6\\
\mathbf{if}\;t\_0 \leq -200:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2000000000:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+85}:\\
\;\;\;\;\left(x \cdot z\right) \cdot 6\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -200 or 4.0000000000000001e85 < (-.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
lower-*.f64N/A
lower--.f6498.8
Applied rewrites98.8%
Taylor expanded in y around inf
Applied rewrites68.3%
if -200 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 2e9Initial program 99.2%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.0
Applied rewrites97.0%
if 2e9 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 4.0000000000000001e85Initial program 99.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites72.4%
Final simplification82.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (<= t_0 -200.0)
(* (* (- y x) -6.0) z)
(if (<= t_0 1.0) (fma -3.0 x (* y 4.0)) (* (* (- y x) z) -6.0)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if (t_0 <= -200.0) {
tmp = ((y - x) * -6.0) * z;
} else if (t_0 <= 1.0) {
tmp = fma(-3.0, x, (y * 4.0));
} else {
tmp = ((y - x) * z) * -6.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_0 <= -200.0) tmp = Float64(Float64(Float64(y - x) * -6.0) * z); elseif (t_0 <= 1.0) tmp = fma(-3.0, x, Float64(y * 4.0)); else tmp = Float64(Float64(Float64(y - x) * z) * -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, -200.0], N[(N[(N[(y - x), $MachinePrecision] * -6.0), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(-3.0 * x + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * -6.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -200:\\
\;\;\;\;\left(\left(y - x\right) \cdot -6\right) \cdot z\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-3, x, y \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(y - x\right) \cdot z\right) \cdot -6\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -200Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6498.0
Applied rewrites98.0%
Applied rewrites98.0%
if -200 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.2%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.7
Applied rewrites97.7%
Taylor expanded in y around 0
Applied rewrites97.7%
if 1 < (-.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
lower-*.f64N/A
lower--.f6499.4
Applied rewrites99.4%
Final simplification98.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* (- y x) -6.0) z))) (if (<= t_0 -200.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 <= -200.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 <= -200.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, -200.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 -200:\\
\;\;\;\;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) < -200 or 1 < (-.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
lower-*.f64N/A
lower--.f6498.7
Applied rewrites98.7%
Applied rewrites98.7%
if -200 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.2%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.7
Applied rewrites97.7%
Taylor expanded in y around 0
Applied rewrites97.7%
Final simplification98.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* x z) 6.0)))
(if (<= t_0 -200.0)
t_1
(if (<= t_0 2000000000.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 = (x * z) * 6.0;
double tmp;
if (t_0 <= -200.0) {
tmp = t_1;
} else if (t_0 <= 2000000000.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(x * z) * 6.0) tmp = 0.0 if (t_0 <= -200.0) tmp = t_1; elseif (t_0 <= 2000000000.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[(x * z), $MachinePrecision] * 6.0), $MachinePrecision]}, If[LessEqual[t$95$0, -200.0], t$95$1, If[LessEqual[t$95$0, 2000000000.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(x \cdot z\right) \cdot 6\\
\mathbf{if}\;t\_0 \leq -200:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2000000000:\\
\;\;\;\;\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) < -200 or 2e9 < (-.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
lower-*.f64N/A
lower--.f6499.0
Applied rewrites99.0%
Taylor expanded in y around 0
Applied rewrites39.2%
if -200 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 2e9Initial program 99.2%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.0
Applied rewrites97.0%
Final simplification66.3%
(FPCore (x y z)
:precision binary64
(if (<= z -2.6e+85)
(* (* y z) -6.0)
(if (<= z -2.45e-6)
(* (fma 6.0 z -3.0) x)
(if (<= z 0.68) (fma -3.0 x (* y 4.0)) (* (* y -6.0) z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.6e+85) {
tmp = (y * z) * -6.0;
} else if (z <= -2.45e-6) {
tmp = fma(6.0, z, -3.0) * x;
} else if (z <= 0.68) {
tmp = fma(-3.0, x, (y * 4.0));
} else {
tmp = (y * -6.0) * z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -2.6e+85) tmp = Float64(Float64(y * z) * -6.0); elseif (z <= -2.45e-6) tmp = Float64(fma(6.0, z, -3.0) * x); elseif (z <= 0.68) tmp = fma(-3.0, x, Float64(y * 4.0)); else tmp = Float64(Float64(y * -6.0) * z); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -2.6e+85], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision], If[LessEqual[z, -2.45e-6], N[(N[(6.0 * z + -3.0), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[z, 0.68], N[(-3.0 * x + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(y * -6.0), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.6 \cdot 10^{+85}:\\
\;\;\;\;\left(y \cdot z\right) \cdot -6\\
\mathbf{elif}\;z \leq -2.45 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(6, z, -3\right) \cdot x\\
\mathbf{elif}\;z \leq 0.68:\\
\;\;\;\;\mathsf{fma}\left(-3, x, y \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot -6\right) \cdot z\\
\end{array}
\end{array}
if z < -2.60000000000000011e85Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites69.9%
if -2.60000000000000011e85 < z < -2.44999999999999984e-6Initial program 99.5%
Taylor expanded in y around 0
metadata-evalN/A
cancel-sign-sub-invN/A
*-commutativeN/A
associate-*r*N/A
sub-negN/A
*-lft-identityN/A
distribute-rgt-neg-inN/A
neg-mul-1N/A
associate-*r*N/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
neg-mul-1N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites69.5%
if -2.44999999999999984e-6 < z < 0.680000000000000049Initial program 99.2%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6498.3
Applied rewrites98.3%
Taylor expanded in y around 0
Applied rewrites98.3%
if 0.680000000000000049 < z Initial program 99.8%
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 y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6467.8
Applied rewrites67.8%
Taylor expanded in z around inf
Applied rewrites67.0%
Final simplification82.2%
(FPCore (x y z)
:precision binary64
(if (<= z -2.6e+85)
(* (* y z) -6.0)
(if (<= z -1900000000.0)
(* (* x z) 6.0)
(if (<= z 0.68) (fma -3.0 x (* y 4.0)) (* (* y -6.0) z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.6e+85) {
tmp = (y * z) * -6.0;
} else if (z <= -1900000000.0) {
tmp = (x * z) * 6.0;
} else if (z <= 0.68) {
tmp = fma(-3.0, x, (y * 4.0));
} else {
tmp = (y * -6.0) * z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -2.6e+85) tmp = Float64(Float64(y * z) * -6.0); elseif (z <= -1900000000.0) tmp = Float64(Float64(x * z) * 6.0); elseif (z <= 0.68) tmp = fma(-3.0, x, Float64(y * 4.0)); else tmp = Float64(Float64(y * -6.0) * z); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -2.6e+85], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision], If[LessEqual[z, -1900000000.0], N[(N[(x * z), $MachinePrecision] * 6.0), $MachinePrecision], If[LessEqual[z, 0.68], N[(-3.0 * x + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(y * -6.0), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.6 \cdot 10^{+85}:\\
\;\;\;\;\left(y \cdot z\right) \cdot -6\\
\mathbf{elif}\;z \leq -1900000000:\\
\;\;\;\;\left(x \cdot z\right) \cdot 6\\
\mathbf{elif}\;z \leq 0.68:\\
\;\;\;\;\mathsf{fma}\left(-3, x, y \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot -6\right) \cdot z\\
\end{array}
\end{array}
if z < -2.60000000000000011e85Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites69.9%
if -2.60000000000000011e85 < z < -1.9e9Initial program 99.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites72.4%
if -1.9e9 < z < 0.680000000000000049Initial program 99.2%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.0
Applied rewrites97.0%
Taylor expanded in y around 0
Applied rewrites97.0%
if 0.680000000000000049 < z Initial program 99.8%
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 y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6467.8
Applied rewrites67.8%
Taylor expanded in z around inf
Applied rewrites67.0%
Final simplification82.0%
(FPCore (x y z)
:precision binary64
(if (<= z -2.6e+85)
(* (* y z) -6.0)
(if (<= z -1900000000.0)
(* (* x z) 6.0)
(if (<= z 0.68) (fma (- y x) 4.0 x) (* (* y -6.0) z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.6e+85) {
tmp = (y * z) * -6.0;
} else if (z <= -1900000000.0) {
tmp = (x * z) * 6.0;
} else if (z <= 0.68) {
tmp = fma((y - x), 4.0, x);
} else {
tmp = (y * -6.0) * z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -2.6e+85) tmp = Float64(Float64(y * z) * -6.0); elseif (z <= -1900000000.0) tmp = Float64(Float64(x * z) * 6.0); elseif (z <= 0.68) tmp = fma(Float64(y - x), 4.0, x); else tmp = Float64(Float64(y * -6.0) * z); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -2.6e+85], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision], If[LessEqual[z, -1900000000.0], N[(N[(x * z), $MachinePrecision] * 6.0), $MachinePrecision], If[LessEqual[z, 0.68], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], N[(N[(y * -6.0), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.6 \cdot 10^{+85}:\\
\;\;\;\;\left(y \cdot z\right) \cdot -6\\
\mathbf{elif}\;z \leq -1900000000:\\
\;\;\;\;\left(x \cdot z\right) \cdot 6\\
\mathbf{elif}\;z \leq 0.68:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot -6\right) \cdot z\\
\end{array}
\end{array}
if z < -2.60000000000000011e85Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites69.9%
if -2.60000000000000011e85 < z < -1.9e9Initial program 99.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites72.4%
if -1.9e9 < z < 0.680000000000000049Initial program 99.2%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.0
Applied rewrites97.0%
if 0.680000000000000049 < z Initial program 99.8%
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 y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6467.8
Applied rewrites67.8%
Taylor expanded in z around inf
Applied rewrites67.0%
Final simplification82.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (fma z -6.0 4.0) y))) (if (<= y -3.7e-16) t_0 (if (<= y 1.22e-48) (* (fma 6.0 z -3.0) x) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(z, -6.0, 4.0) * y;
double tmp;
if (y <= -3.7e-16) {
tmp = t_0;
} else if (y <= 1.22e-48) {
tmp = fma(6.0, z, -3.0) * x;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(fma(z, -6.0, 4.0) * y) tmp = 0.0 if (y <= -3.7e-16) tmp = t_0; elseif (y <= 1.22e-48) 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[(N[(z * -6.0 + 4.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -3.7e-16], t$95$0, If[LessEqual[y, 1.22e-48], N[(N[(6.0 * z + -3.0), $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(z, -6, 4\right) \cdot y\\
\mathbf{if}\;y \leq -3.7 \cdot 10^{-16}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.22 \cdot 10^{-48}:\\
\;\;\;\;\mathsf{fma}\left(6, z, -3\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.7e-16 or 1.21999999999999993e-48 < y Initial program 99.6%
Taylor expanded in y around inf
*-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
*-commutativeN/A
lower-fma.f6485.3
Applied rewrites85.3%
if -3.7e-16 < y < 1.21999999999999993e-48Initial program 99.4%
Taylor expanded in y around 0
metadata-evalN/A
cancel-sign-sub-invN/A
*-commutativeN/A
associate-*r*N/A
sub-negN/A
*-lft-identityN/A
distribute-rgt-neg-inN/A
neg-mul-1N/A
associate-*r*N/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
neg-mul-1N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.2%
(FPCore (x y z) :precision binary64 (if (<= y -1.8e-6) (* y 4.0) (if (<= y 1.3e-8) (* -3.0 x) (* y 4.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.8e-6) {
tmp = y * 4.0;
} else if (y <= 1.3e-8) {
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 <= (-1.8d-6)) then
tmp = y * 4.0d0
else if (y <= 1.3d-8) 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 <= -1.8e-6) {
tmp = y * 4.0;
} else if (y <= 1.3e-8) {
tmp = -3.0 * x;
} else {
tmp = y * 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.8e-6: tmp = y * 4.0 elif y <= 1.3e-8: tmp = -3.0 * x else: tmp = y * 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.8e-6) tmp = Float64(y * 4.0); elseif (y <= 1.3e-8) 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 <= -1.8e-6) tmp = y * 4.0; elseif (y <= 1.3e-8) tmp = -3.0 * x; else tmp = y * 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.8e-6], N[(y * 4.0), $MachinePrecision], If[LessEqual[y, 1.3e-8], N[(-3.0 * x), $MachinePrecision], N[(y * 4.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{-6}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-8}:\\
\;\;\;\;-3 \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot 4\\
\end{array}
\end{array}
if y < -1.79999999999999992e-6 or 1.3000000000000001e-8 < y Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6442.3
Applied rewrites42.3%
Taylor expanded in y around inf
Applied rewrites37.4%
if -1.79999999999999992e-6 < y < 1.3000000000000001e-8Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6453.6
Applied rewrites53.6%
Taylor expanded in y around 0
Applied rewrites39.9%
(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.2
Applied rewrites47.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--.f6447.2
Applied rewrites47.2%
Taylor expanded in y around 0
Applied rewrites21.2%
herbie shell --seed 2024266
(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))))