
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
return x + (((y - x) * 6.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) * z)
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * z);
}
def code(x, y, z): return x + (((y - x) * 6.0) * z)
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z)) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * z); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
return x + (((y - x) * 6.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) * z)
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * z);
}
def code(x, y, z): return x + (((y - x) * 6.0) * z)
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z)) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * z); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\end{array}
(FPCore (x y z) :precision binary64 (fma (- y x) (* z 6.0) x))
double code(double x, double y, double z) {
return fma((y - x), (z * 6.0), x);
}
function code(x, y, z) return fma(Float64(y - x), Float64(z * 6.0), x) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(z * 6.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, z \cdot 6, x\right)
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
(FPCore (x y z) :precision binary64 (if (<= x -4.4e+75) (+ x (* (* z x) -6.0)) (if (<= x 1.9e+130) (+ x (* (* 6.0 y) z)) (+ x (* (* -6.0 x) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.4e+75) {
tmp = x + ((z * x) * -6.0);
} else if (x <= 1.9e+130) {
tmp = x + ((6.0 * y) * z);
} else {
tmp = x + ((-6.0 * x) * z);
}
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 (x <= (-4.4d+75)) then
tmp = x + ((z * x) * (-6.0d0))
else if (x <= 1.9d+130) then
tmp = x + ((6.0d0 * y) * z)
else
tmp = x + (((-6.0d0) * x) * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -4.4e+75) {
tmp = x + ((z * x) * -6.0);
} else if (x <= 1.9e+130) {
tmp = x + ((6.0 * y) * z);
} else {
tmp = x + ((-6.0 * x) * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4.4e+75: tmp = x + ((z * x) * -6.0) elif x <= 1.9e+130: tmp = x + ((6.0 * y) * z) else: tmp = x + ((-6.0 * x) * z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4.4e+75) tmp = Float64(x + Float64(Float64(z * x) * -6.0)); elseif (x <= 1.9e+130) tmp = Float64(x + Float64(Float64(6.0 * y) * z)); else tmp = Float64(x + Float64(Float64(-6.0 * x) * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -4.4e+75) tmp = x + ((z * x) * -6.0); elseif (x <= 1.9e+130) tmp = x + ((6.0 * y) * z); else tmp = x + ((-6.0 * x) * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4.4e+75], N[(x + N[(N[(z * x), $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.9e+130], N[(x + N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(-6.0 * x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.4 \cdot 10^{+75}:\\
\;\;\;\;x + \left(z \cdot x\right) \cdot -6\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+130}:\\
\;\;\;\;x + \left(6 \cdot y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + \left(-6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if x < -4.40000000000000024e75Initial program 98.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.0
Applied rewrites98.0%
if -4.40000000000000024e75 < x < 1.9000000000000001e130Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6484.9
Applied rewrites84.9%
if 1.9000000000000001e130 < x Initial program 100.0%
Taylor expanded in x around inf
lower-*.f6497.5
Applied rewrites97.5%
(FPCore (x y z) :precision binary64 (if (<= x -4.4e+75) (+ x (* (* z x) -6.0)) (if (<= x 1.9e+130) (fma (* y z) 6.0 x) (+ x (* (* -6.0 x) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.4e+75) {
tmp = x + ((z * x) * -6.0);
} else if (x <= 1.9e+130) {
tmp = fma((y * z), 6.0, x);
} else {
tmp = x + ((-6.0 * x) * z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -4.4e+75) tmp = Float64(x + Float64(Float64(z * x) * -6.0)); elseif (x <= 1.9e+130) tmp = fma(Float64(y * z), 6.0, x); else tmp = Float64(x + Float64(Float64(-6.0 * x) * z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -4.4e+75], N[(x + N[(N[(z * x), $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.9e+130], N[(N[(y * z), $MachinePrecision] * 6.0 + x), $MachinePrecision], N[(x + N[(N[(-6.0 * x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.4 \cdot 10^{+75}:\\
\;\;\;\;x + \left(z \cdot x\right) \cdot -6\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+130}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, 6, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(-6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if x < -4.40000000000000024e75Initial program 98.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.0
Applied rewrites98.0%
if -4.40000000000000024e75 < x < 1.9000000000000001e130Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
lower-*.f6484.8
Applied rewrites84.8%
if 1.9000000000000001e130 < x Initial program 100.0%
Taylor expanded in x around inf
lower-*.f6497.5
Applied rewrites97.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -4.4e+75) (not (<= x 1.9e+130))) (* (fma -6.0 z 1.0) x) (fma (* y z) 6.0 x)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4.4e+75) || !(x <= 1.9e+130)) {
tmp = fma(-6.0, z, 1.0) * x;
} else {
tmp = fma((y * z), 6.0, x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((x <= -4.4e+75) || !(x <= 1.9e+130)) tmp = Float64(fma(-6.0, z, 1.0) * x); else tmp = fma(Float64(y * z), 6.0, x); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[x, -4.4e+75], N[Not[LessEqual[x, 1.9e+130]], $MachinePrecision]], N[(N[(-6.0 * z + 1.0), $MachinePrecision] * x), $MachinePrecision], N[(N[(y * z), $MachinePrecision] * 6.0 + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.4 \cdot 10^{+75} \lor \neg \left(x \leq 1.9 \cdot 10^{+130}\right):\\
\;\;\;\;\mathsf{fma}\left(-6, z, 1\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, 6, x\right)\\
\end{array}
\end{array}
if x < -4.40000000000000024e75 or 1.9000000000000001e130 < x Initial program 99.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6497.7
Applied rewrites97.7%
if -4.40000000000000024e75 < x < 1.9000000000000001e130Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
lower-*.f6484.8
Applied rewrites84.8%
Final simplification89.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -9.5e-83) (not (<= x 4.4e-40))) (* (fma -6.0 z 1.0) x) (* (* 6.0 y) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.5e-83) || !(x <= 4.4e-40)) {
tmp = fma(-6.0, z, 1.0) * x;
} else {
tmp = (6.0 * y) * z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((x <= -9.5e-83) || !(x <= 4.4e-40)) tmp = Float64(fma(-6.0, z, 1.0) * x); else tmp = Float64(Float64(6.0 * y) * z); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.5e-83], N[Not[LessEqual[x, 4.4e-40]], $MachinePrecision]], N[(N[(-6.0 * z + 1.0), $MachinePrecision] * x), $MachinePrecision], N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{-83} \lor \neg \left(x \leq 4.4 \cdot 10^{-40}\right):\\
\;\;\;\;\mathsf{fma}\left(-6, z, 1\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(6 \cdot y\right) \cdot z\\
\end{array}
\end{array}
if x < -9.50000000000000051e-83 or 4.40000000000000018e-40 < x Initial program 99.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6484.5
Applied rewrites84.5%
if -9.50000000000000051e-83 < x < 4.40000000000000018e-40Initial program 99.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6472.0
Applied rewrites72.0%
Applied rewrites72.2%
Final simplification79.6%
(FPCore (x y z) :precision binary64 (if (<= x -4.4e+75) (+ x (* (* z x) -6.0)) (if (<= x 1.9e+130) (fma (* y z) 6.0 x) (fma (* -6.0 x) z x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.4e+75) {
tmp = x + ((z * x) * -6.0);
} else if (x <= 1.9e+130) {
tmp = fma((y * z), 6.0, x);
} else {
tmp = fma((-6.0 * x), z, x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -4.4e+75) tmp = Float64(x + Float64(Float64(z * x) * -6.0)); elseif (x <= 1.9e+130) tmp = fma(Float64(y * z), 6.0, x); else tmp = fma(Float64(-6.0 * x), z, x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -4.4e+75], N[(x + N[(N[(z * x), $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.9e+130], N[(N[(y * z), $MachinePrecision] * 6.0 + x), $MachinePrecision], N[(N[(-6.0 * x), $MachinePrecision] * z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.4 \cdot 10^{+75}:\\
\;\;\;\;x + \left(z \cdot x\right) \cdot -6\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+130}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, 6, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-6 \cdot x, z, x\right)\\
\end{array}
\end{array}
if x < -4.40000000000000024e75Initial program 98.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.0
Applied rewrites98.0%
if -4.40000000000000024e75 < x < 1.9000000000000001e130Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
lower-*.f6484.8
Applied rewrites84.8%
if 1.9000000000000001e130 < x Initial program 100.0%
Taylor expanded in x around 0
lower-*.f6452.4
Applied rewrites52.4%
Taylor expanded in x around -inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites97.4%
(FPCore (x y z) :precision binary64 (if (<= x -4.4e+75) (* (fma -6.0 z 1.0) x) (if (<= x 1.9e+130) (fma (* y z) 6.0 x) (fma (* -6.0 x) z x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.4e+75) {
tmp = fma(-6.0, z, 1.0) * x;
} else if (x <= 1.9e+130) {
tmp = fma((y * z), 6.0, x);
} else {
tmp = fma((-6.0 * x), z, x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -4.4e+75) tmp = Float64(fma(-6.0, z, 1.0) * x); elseif (x <= 1.9e+130) tmp = fma(Float64(y * z), 6.0, x); else tmp = fma(Float64(-6.0 * x), z, x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -4.4e+75], N[(N[(-6.0 * z + 1.0), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 1.9e+130], N[(N[(y * z), $MachinePrecision] * 6.0 + x), $MachinePrecision], N[(N[(-6.0 * x), $MachinePrecision] * z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.4 \cdot 10^{+75}:\\
\;\;\;\;\mathsf{fma}\left(-6, z, 1\right) \cdot x\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+130}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, 6, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-6 \cdot x, z, x\right)\\
\end{array}
\end{array}
if x < -4.40000000000000024e75Initial program 98.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6497.9
Applied rewrites97.9%
if -4.40000000000000024e75 < x < 1.9000000000000001e130Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
lower-*.f6484.8
Applied rewrites84.8%
if 1.9000000000000001e130 < x Initial program 100.0%
Taylor expanded in x around 0
lower-*.f6452.4
Applied rewrites52.4%
Taylor expanded in x around -inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites97.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.8e-7) (not (<= z 2.15e-145))) (* (* 6.0 y) z) (* 1.0 x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.8e-7) || !(z <= 2.15e-145)) {
tmp = (6.0 * y) * z;
} else {
tmp = 1.0 * x;
}
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 ((z <= (-3.8d-7)) .or. (.not. (z <= 2.15d-145))) then
tmp = (6.0d0 * y) * z
else
tmp = 1.0d0 * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3.8e-7) || !(z <= 2.15e-145)) {
tmp = (6.0 * y) * z;
} else {
tmp = 1.0 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.8e-7) or not (z <= 2.15e-145): tmp = (6.0 * y) * z else: tmp = 1.0 * x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.8e-7) || !(z <= 2.15e-145)) tmp = Float64(Float64(6.0 * y) * z); else tmp = Float64(1.0 * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.8e-7) || ~((z <= 2.15e-145))) tmp = (6.0 * y) * z; else tmp = 1.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.8e-7], N[Not[LessEqual[z, 2.15e-145]], $MachinePrecision]], N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision], N[(1.0 * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.8 \cdot 10^{-7} \lor \neg \left(z \leq 2.15 \cdot 10^{-145}\right):\\
\;\;\;\;\left(6 \cdot y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;1 \cdot x\\
\end{array}
\end{array}
if z < -3.80000000000000015e-7 or 2.15e-145 < z Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6452.2
Applied rewrites52.2%
Applied rewrites52.4%
if -3.80000000000000015e-7 < z < 2.15e-145Initial program 99.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6478.7
Applied rewrites78.7%
Taylor expanded in z around 0
Applied rewrites77.9%
Final simplification62.8%
(FPCore (x y z) :precision binary64 (if (<= z -0.17) (* (* -6.0 z) x) (if (<= z 2.15e-145) (* 1.0 x) (* (* 6.0 y) z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.17) {
tmp = (-6.0 * z) * x;
} else if (z <= 2.15e-145) {
tmp = 1.0 * x;
} else {
tmp = (6.0 * y) * z;
}
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 (z <= (-0.17d0)) then
tmp = ((-6.0d0) * z) * x
else if (z <= 2.15d-145) then
tmp = 1.0d0 * x
else
tmp = (6.0d0 * y) * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -0.17) {
tmp = (-6.0 * z) * x;
} else if (z <= 2.15e-145) {
tmp = 1.0 * x;
} else {
tmp = (6.0 * y) * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.17: tmp = (-6.0 * z) * x elif z <= 2.15e-145: tmp = 1.0 * x else: tmp = (6.0 * y) * z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.17) tmp = Float64(Float64(-6.0 * z) * x); elseif (z <= 2.15e-145) tmp = Float64(1.0 * x); else tmp = Float64(Float64(6.0 * y) * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.17) tmp = (-6.0 * z) * x; elseif (z <= 2.15e-145) tmp = 1.0 * x; else tmp = (6.0 * y) * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.17], N[(N[(-6.0 * z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[z, 2.15e-145], N[(1.0 * x), $MachinePrecision], N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.17:\\
\;\;\;\;\left(-6 \cdot z\right) \cdot x\\
\mathbf{elif}\;z \leq 2.15 \cdot 10^{-145}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(6 \cdot y\right) \cdot z\\
\end{array}
\end{array}
if z < -0.170000000000000012Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6458.3
Applied rewrites58.3%
Taylor expanded in z around inf
Applied rewrites56.9%
if -0.170000000000000012 < z < 2.15e-145Initial program 99.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6478.2
Applied rewrites78.2%
Taylor expanded in z around 0
Applied rewrites76.7%
if 2.15e-145 < z Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6454.7
Applied rewrites54.7%
Applied rewrites54.8%
Final simplification64.4%
(FPCore (x y z) :precision binary64 (fma (* z (- y x)) 6.0 x))
double code(double x, double y, double z) {
return fma((z * (y - x)), 6.0, x);
}
function code(x, y, z) return fma(Float64(z * Float64(y - x)), 6.0, x) end
code[x_, y_, z_] := N[(N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision] * 6.0 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z \cdot \left(y - x\right), 6, x\right)
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
(FPCore (x y z) :precision binary64 (* 1.0 x))
double code(double x, double y, double z) {
return 1.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 = 1.0d0 * x
end function
public static double code(double x, double y, double z) {
return 1.0 * x;
}
def code(x, y, z): return 1.0 * x
function code(x, y, z) return Float64(1.0 * x) end
function tmp = code(x, y, z) tmp = 1.0 * x; end
code[x_, y_, z_] := N[(1.0 * x), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot x
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6462.9
Applied rewrites62.9%
Taylor expanded in z around 0
Applied rewrites36.5%
Final simplification36.5%
(FPCore (x y z) :precision binary64 (- x (* (* 6.0 z) (- x y))))
double code(double x, double y, double z) {
return x - ((6.0 * z) * (x - y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x - ((6.0d0 * z) * (x - y))
end function
public static double code(double x, double y, double z) {
return x - ((6.0 * z) * (x - y));
}
def code(x, y, z): return x - ((6.0 * z) * (x - y))
function code(x, y, z) return Float64(x - Float64(Float64(6.0 * z) * Float64(x - y))) end
function tmp = code(x, y, z) tmp = x - ((6.0 * z) * (x - y)); end
code[x_, y_, z_] := N[(x - N[(N[(6.0 * z), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(6 \cdot z\right) \cdot \left(x - y\right)
\end{array}
herbie shell --seed 2024339
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
:precision binary64
:alt
(! :herbie-platform default (- x (* (* 6 z) (- x y))))
(+ x (* (* (- y x) 6.0) z)))