
(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 6 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 (+ x (* 6.0 (* z (- y x)))))
double code(double x, double y, double z) {
return x + (6.0 * (z * (y - x)));
}
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 * (y - x)))
end function
public static double code(double x, double y, double z) {
return x + (6.0 * (z * (y - x)));
}
def code(x, y, z): return x + (6.0 * (z * (y - x)))
function code(x, y, z) return Float64(x + Float64(6.0 * Float64(z * Float64(y - x)))) end
function tmp = code(x, y, z) tmp = x + (6.0 * (z * (y - x))); end
code[x_, y_, z_] := N[(x + N[(6.0 * N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + 6 \cdot \left(z \cdot \left(y - x\right)\right)
\end{array}
Initial program 99.8%
Taylor expanded in y around 0 97.1%
+-commutative97.1%
associate-*r*97.1%
*-commutative97.1%
associate-*r*97.1%
metadata-eval97.1%
cancel-sign-sub-inv97.1%
*-commutative97.1%
associate-*r*97.0%
*-commutative97.0%
distribute-lft-out--99.8%
associate-*r*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.95e-71) (not (<= y 2.7e-94))) (+ x (* 6.0 (* z y))) (+ x (* -6.0 (* x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.95e-71) || !(y <= 2.7e-94)) {
tmp = x + (6.0 * (z * y));
} 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 ((y <= (-1.95d-71)) .or. (.not. (y <= 2.7d-94))) then
tmp = x + (6.0d0 * (z * y))
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 ((y <= -1.95e-71) || !(y <= 2.7e-94)) {
tmp = x + (6.0 * (z * y));
} else {
tmp = x + (-6.0 * (x * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.95e-71) or not (y <= 2.7e-94): tmp = x + (6.0 * (z * y)) else: tmp = x + (-6.0 * (x * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.95e-71) || !(y <= 2.7e-94)) tmp = Float64(x + Float64(6.0 * Float64(z * y))); else tmp = Float64(x + Float64(-6.0 * Float64(x * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.95e-71) || ~((y <= 2.7e-94))) tmp = x + (6.0 * (z * y)); else tmp = x + (-6.0 * (x * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.95e-71], N[Not[LessEqual[y, 2.7e-94]], $MachinePrecision]], N[(x + N[(6.0 * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{-71} \lor \neg \left(y \leq 2.7 \cdot 10^{-94}\right):\\
\;\;\;\;x + 6 \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + -6 \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if y < -1.9500000000000001e-71 or 2.7000000000000001e-94 < y Initial program 99.8%
Taylor expanded in y around inf 86.5%
*-commutative86.5%
Simplified86.5%
if -1.9500000000000001e-71 < y < 2.7000000000000001e-94Initial program 99.8%
Taylor expanded in y around 0 94.6%
Final simplification89.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.165) (not (<= z 1.8e-16))) (* x (* z -6.0)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.165) || !(z <= 1.8e-16)) {
tmp = x * (z * -6.0);
} else {
tmp = 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 <= (-0.165d0)) .or. (.not. (z <= 1.8d-16))) then
tmp = x * (z * (-6.0d0))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.165) || !(z <= 1.8e-16)) {
tmp = x * (z * -6.0);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.165) or not (z <= 1.8e-16): tmp = x * (z * -6.0) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.165) || !(z <= 1.8e-16)) tmp = Float64(x * Float64(z * -6.0)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.165) || ~((z <= 1.8e-16))) tmp = x * (z * -6.0); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.165], N[Not[LessEqual[z, 1.8e-16]], $MachinePrecision]], N[(x * N[(z * -6.0), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.165 \lor \neg \left(z \leq 1.8 \cdot 10^{-16}\right):\\
\;\;\;\;x \cdot \left(z \cdot -6\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -0.165000000000000008 or 1.79999999999999991e-16 < z Initial program 99.7%
Taylor expanded in y around 0 49.6%
Taylor expanded in x around 0 49.6%
+-commutative49.6%
Simplified49.6%
Taylor expanded in z around inf 47.3%
if -0.165000000000000008 < z < 1.79999999999999991e-16Initial program 99.9%
Taylor expanded in y around 0 70.7%
Taylor expanded in z around 0 69.9%
Final simplification58.5%
(FPCore (x y z) :precision binary64 (* x (+ (* z -6.0) 1.0)))
double code(double x, double y, double z) {
return x * ((z * -6.0) + 1.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * ((z * (-6.0d0)) + 1.0d0)
end function
public static double code(double x, double y, double z) {
return x * ((z * -6.0) + 1.0);
}
def code(x, y, z): return x * ((z * -6.0) + 1.0)
function code(x, y, z) return Float64(x * Float64(Float64(z * -6.0) + 1.0)) end
function tmp = code(x, y, z) tmp = x * ((z * -6.0) + 1.0); end
code[x_, y_, z_] := N[(x * N[(N[(z * -6.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(z \cdot -6 + 1\right)
\end{array}
Initial program 99.8%
Taylor expanded in y around 0 60.0%
Taylor expanded in x around 0 60.0%
+-commutative60.0%
Simplified60.0%
Final simplification60.0%
(FPCore (x y z) :precision binary64 (+ x (* -6.0 (* x z))))
double code(double x, double y, double z) {
return x + (-6.0 * (x * 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 + ((-6.0d0) * (x * z))
end function
public static double code(double x, double y, double z) {
return x + (-6.0 * (x * z));
}
def code(x, y, z): return x + (-6.0 * (x * z))
function code(x, y, z) return Float64(x + Float64(-6.0 * Float64(x * z))) end
function tmp = code(x, y, z) tmp = x + (-6.0 * (x * z)); end
code[x_, y_, z_] := N[(x + N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + -6 \cdot \left(x \cdot z\right)
\end{array}
Initial program 99.8%
Taylor expanded in y around 0 60.0%
Final simplification60.0%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.8%
Taylor expanded in y around 0 60.0%
Taylor expanded in z around 0 35.9%
Final simplification35.9%
(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 2024078
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
:precision binary64
:alt
(- x (* (* 6.0 z) (- x y)))
(+ x (* (* (- y x) 6.0) z)))