
(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 8 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 (* (* (- 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}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.85e+45) (not (<= x 7500000.0))) (* x (+ 1.0 (* z -6.0))) (+ x (* 6.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.85e+45) || !(x <= 7500000.0)) {
tmp = x * (1.0 + (z * -6.0));
} else {
tmp = x + (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 ((x <= (-2.85d+45)) .or. (.not. (x <= 7500000.0d0))) then
tmp = x * (1.0d0 + (z * (-6.0d0)))
else
tmp = x + (6.0d0 * (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.85e+45) || !(x <= 7500000.0)) {
tmp = x * (1.0 + (z * -6.0));
} else {
tmp = x + (6.0 * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.85e+45) or not (x <= 7500000.0): tmp = x * (1.0 + (z * -6.0)) else: tmp = x + (6.0 * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.85e+45) || !(x <= 7500000.0)) tmp = Float64(x * Float64(1.0 + Float64(z * -6.0))); else tmp = Float64(x + Float64(6.0 * Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.85e+45) || ~((x <= 7500000.0))) tmp = x * (1.0 + (z * -6.0)); else tmp = x + (6.0 * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.85e+45], N[Not[LessEqual[x, 7500000.0]], $MachinePrecision]], N[(x * N[(1.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.85 \cdot 10^{+45} \lor \neg \left(x \leq 7500000\right):\\
\;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\
\mathbf{else}:\\
\;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if x < -2.85000000000000013e45 or 7.5e6 < x Initial program 99.9%
Taylor expanded in x around inf 89.4%
if -2.85000000000000013e45 < x < 7.5e6Initial program 99.7%
Taylor expanded in y around inf 89.2%
Final simplification89.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.2e+40) (not (<= x 32000000.0))) (+ x (* z (* x -6.0))) (+ x (* 6.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.2e+40) || !(x <= 32000000.0)) {
tmp = x + (z * (x * -6.0));
} else {
tmp = x + (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 ((x <= (-5.2d+40)) .or. (.not. (x <= 32000000.0d0))) then
tmp = x + (z * (x * (-6.0d0)))
else
tmp = x + (6.0d0 * (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.2e+40) || !(x <= 32000000.0)) {
tmp = x + (z * (x * -6.0));
} else {
tmp = x + (6.0 * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.2e+40) or not (x <= 32000000.0): tmp = x + (z * (x * -6.0)) else: tmp = x + (6.0 * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.2e+40) || !(x <= 32000000.0)) tmp = Float64(x + Float64(z * Float64(x * -6.0))); else tmp = Float64(x + Float64(6.0 * Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.2e+40) || ~((x <= 32000000.0))) tmp = x + (z * (x * -6.0)); else tmp = x + (6.0 * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.2e+40], N[Not[LessEqual[x, 32000000.0]], $MachinePrecision]], N[(x + N[(z * N[(x * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{+40} \lor \neg \left(x \leq 32000000\right):\\
\;\;\;\;x + z \cdot \left(x \cdot -6\right)\\
\mathbf{else}:\\
\;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if x < -5.2000000000000001e40 or 3.2e7 < x Initial program 99.9%
Taylor expanded in y around 0 89.5%
if -5.2000000000000001e40 < x < 3.2e7Initial program 99.7%
Taylor expanded in y around inf 89.2%
Final simplification89.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -6500000000.0) (not (<= z 0.17))) (* -6.0 (* x z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6500000000.0) || !(z <= 0.17)) {
tmp = -6.0 * (x * z);
} 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 <= (-6500000000.0d0)) .or. (.not. (z <= 0.17d0))) then
tmp = (-6.0d0) * (x * z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -6500000000.0) || !(z <= 0.17)) {
tmp = -6.0 * (x * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6500000000.0) or not (z <= 0.17): tmp = -6.0 * (x * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6500000000.0) || !(z <= 0.17)) tmp = Float64(-6.0 * Float64(x * z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6500000000.0) || ~((z <= 0.17))) tmp = -6.0 * (x * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6500000000.0], N[Not[LessEqual[z, 0.17]], $MachinePrecision]], N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6500000000 \lor \neg \left(z \leq 0.17\right):\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.5e9 or 0.170000000000000012 < z Initial program 99.8%
Taylor expanded in x around inf 54.2%
Taylor expanded in z around inf 53.7%
*-commutative53.7%
Simplified53.7%
Taylor expanded in z around 0 53.6%
if -6.5e9 < z < 0.170000000000000012Initial program 99.9%
Taylor expanded in z around 0 69.6%
Final simplification61.0%
(FPCore (x y z) :precision binary64 (if (<= z -6500000000.0) (* z (* x -6.0)) (if (<= z 0.17) x (* -6.0 (* x z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -6500000000.0) {
tmp = z * (x * -6.0);
} else if (z <= 0.17) {
tmp = x;
} else {
tmp = -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 (z <= (-6500000000.0d0)) then
tmp = z * (x * (-6.0d0))
else if (z <= 0.17d0) then
tmp = x
else
tmp = (-6.0d0) * (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -6500000000.0) {
tmp = z * (x * -6.0);
} else if (z <= 0.17) {
tmp = x;
} else {
tmp = -6.0 * (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6500000000.0: tmp = z * (x * -6.0) elif z <= 0.17: tmp = x else: tmp = -6.0 * (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6500000000.0) tmp = Float64(z * Float64(x * -6.0)); elseif (z <= 0.17) tmp = x; else tmp = Float64(-6.0 * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6500000000.0) tmp = z * (x * -6.0); elseif (z <= 0.17) tmp = x; else tmp = -6.0 * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6500000000.0], N[(z * N[(x * -6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.17], x, N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6500000000:\\
\;\;\;\;z \cdot \left(x \cdot -6\right)\\
\mathbf{elif}\;z \leq 0.17:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < -6.5e9Initial program 99.8%
Taylor expanded in x around inf 57.0%
Taylor expanded in z around inf 57.0%
*-commutative57.0%
Simplified57.0%
Taylor expanded in z around 0 56.9%
*-commutative56.9%
associate-*r*57.1%
Simplified57.1%
if -6.5e9 < z < 0.170000000000000012Initial program 99.9%
Taylor expanded in z around 0 69.6%
if 0.170000000000000012 < z Initial program 99.7%
Taylor expanded in x around inf 51.0%
Taylor expanded in z around inf 49.7%
*-commutative49.7%
Simplified49.7%
Taylor expanded in z around 0 49.8%
Final simplification61.1%
(FPCore (x y z) :precision binary64 (if (<= z -6500000000.0) (* z (* x -6.0)) (if (<= z 0.17) x (/ z (/ -0.16666666666666666 x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -6500000000.0) {
tmp = z * (x * -6.0);
} else if (z <= 0.17) {
tmp = x;
} else {
tmp = z / (-0.16666666666666666 / 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 <= (-6500000000.0d0)) then
tmp = z * (x * (-6.0d0))
else if (z <= 0.17d0) then
tmp = x
else
tmp = z / ((-0.16666666666666666d0) / x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -6500000000.0) {
tmp = z * (x * -6.0);
} else if (z <= 0.17) {
tmp = x;
} else {
tmp = z / (-0.16666666666666666 / x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6500000000.0: tmp = z * (x * -6.0) elif z <= 0.17: tmp = x else: tmp = z / (-0.16666666666666666 / x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6500000000.0) tmp = Float64(z * Float64(x * -6.0)); elseif (z <= 0.17) tmp = x; else tmp = Float64(z / Float64(-0.16666666666666666 / x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6500000000.0) tmp = z * (x * -6.0); elseif (z <= 0.17) tmp = x; else tmp = z / (-0.16666666666666666 / x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6500000000.0], N[(z * N[(x * -6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.17], x, N[(z / N[(-0.16666666666666666 / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6500000000:\\
\;\;\;\;z \cdot \left(x \cdot -6\right)\\
\mathbf{elif}\;z \leq 0.17:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{-0.16666666666666666}{x}}\\
\end{array}
\end{array}
if z < -6.5e9Initial program 99.8%
Taylor expanded in x around inf 57.0%
Taylor expanded in z around inf 57.0%
*-commutative57.0%
Simplified57.0%
Taylor expanded in z around 0 56.9%
*-commutative56.9%
associate-*r*57.1%
Simplified57.1%
if -6.5e9 < z < 0.170000000000000012Initial program 99.9%
Taylor expanded in z around 0 69.6%
if 0.170000000000000012 < z Initial program 99.7%
Taylor expanded in x around inf 51.0%
Taylor expanded in z around inf 49.7%
*-commutative49.7%
Simplified49.7%
metadata-eval49.7%
div-inv49.8%
associate-/r/49.9%
Applied egg-rr49.9%
Final simplification61.1%
(FPCore (x y z) :precision binary64 (* x (+ 1.0 (* z -6.0))))
double code(double x, double y, double z) {
return x * (1.0 + (z * -6.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 * (1.0d0 + (z * (-6.0d0)))
end function
public static double code(double x, double y, double z) {
return x * (1.0 + (z * -6.0));
}
def code(x, y, z): return x * (1.0 + (z * -6.0))
function code(x, y, z) return Float64(x * Float64(1.0 + Float64(z * -6.0))) end
function tmp = code(x, y, z) tmp = x * (1.0 + (z * -6.0)); end
code[x_, y_, z_] := N[(x * N[(1.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + z \cdot -6\right)
\end{array}
Initial program 99.8%
Taylor expanded in x around inf 61.5%
Final simplification61.5%
(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 z around 0 33.7%
Final simplification33.7%
(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 2023199
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
:precision binary64
:herbie-target
(- x (* (* 6.0 z) (- x y)))
(+ x (* (* (- y x) 6.0) z)))