
(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 7 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 (<= y -3.05e-43) (not (<= y 1.45e-98))) (+ x (* 6.0 (* y z))) (+ x (* -6.0 (* x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.05e-43) || !(y <= 1.45e-98)) {
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 ((y <= (-3.05d-43)) .or. (.not. (y <= 1.45d-98))) 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 ((y <= -3.05e-43) || !(y <= 1.45e-98)) {
tmp = x + (6.0 * (y * z));
} else {
tmp = x + (-6.0 * (x * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.05e-43) or not (y <= 1.45e-98): tmp = x + (6.0 * (y * z)) else: tmp = x + (-6.0 * (x * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.05e-43) || !(y <= 1.45e-98)) tmp = Float64(x + Float64(6.0 * Float64(y * z))); 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 <= -3.05e-43) || ~((y <= 1.45e-98))) tmp = x + (6.0 * (y * z)); else tmp = x + (-6.0 * (x * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.05e-43], N[Not[LessEqual[y, 1.45e-98]], $MachinePrecision]], N[(x + N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.05 \cdot 10^{-43} \lor \neg \left(y \leq 1.45 \cdot 10^{-98}\right):\\
\;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + -6 \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if y < -3.05000000000000019e-43 or 1.45e-98 < y Initial program 99.8%
Taylor expanded in y around inf 90.2%
*-commutative90.2%
Simplified90.2%
if -3.05000000000000019e-43 < y < 1.45e-98Initial program 99.8%
Taylor expanded in y around 0 87.2%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.85e-46) (not (<= y 2.4e-98))) (+ x (* 6.0 (* y z))) (+ x (* x (* z -6.0)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.85e-46) || !(y <= 2.4e-98)) {
tmp = x + (6.0 * (y * z));
} else {
tmp = x + (x * (z * -6.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.85d-46)) .or. (.not. (y <= 2.4d-98))) then
tmp = x + (6.0d0 * (y * z))
else
tmp = x + (x * (z * (-6.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.85e-46) || !(y <= 2.4e-98)) {
tmp = x + (6.0 * (y * z));
} else {
tmp = x + (x * (z * -6.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.85e-46) or not (y <= 2.4e-98): tmp = x + (6.0 * (y * z)) else: tmp = x + (x * (z * -6.0)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.85e-46) || !(y <= 2.4e-98)) tmp = Float64(x + Float64(6.0 * Float64(y * z))); else tmp = Float64(x + Float64(x * Float64(z * -6.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.85e-46) || ~((y <= 2.4e-98))) tmp = x + (6.0 * (y * z)); else tmp = x + (x * (z * -6.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.85e-46], N[Not[LessEqual[y, 2.4e-98]], $MachinePrecision]], N[(x + N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{-46} \lor \neg \left(y \leq 2.4 \cdot 10^{-98}\right):\\
\;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z \cdot -6\right)\\
\end{array}
\end{array}
if y < -1.84999999999999992e-46 or 2.40000000000000005e-98 < y Initial program 99.8%
Taylor expanded in y around inf 90.2%
*-commutative90.2%
Simplified90.2%
if -1.84999999999999992e-46 < y < 2.40000000000000005e-98Initial program 99.8%
Taylor expanded in y around 0 87.2%
*-commutative87.2%
associate-*r*87.3%
*-commutative87.3%
Simplified87.3%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -7.5e-43) (not (<= y 6.8e-99))) (+ x (* y (* 6.0 z))) (+ x (* x (* z -6.0)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.5e-43) || !(y <= 6.8e-99)) {
tmp = x + (y * (6.0 * z));
} else {
tmp = x + (x * (z * -6.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 <= (-7.5d-43)) .or. (.not. (y <= 6.8d-99))) then
tmp = x + (y * (6.0d0 * z))
else
tmp = x + (x * (z * (-6.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -7.5e-43) || !(y <= 6.8e-99)) {
tmp = x + (y * (6.0 * z));
} else {
tmp = x + (x * (z * -6.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7.5e-43) or not (y <= 6.8e-99): tmp = x + (y * (6.0 * z)) else: tmp = x + (x * (z * -6.0)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7.5e-43) || !(y <= 6.8e-99)) tmp = Float64(x + Float64(y * Float64(6.0 * z))); else tmp = Float64(x + Float64(x * Float64(z * -6.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7.5e-43) || ~((y <= 6.8e-99))) tmp = x + (y * (6.0 * z)); else tmp = x + (x * (z * -6.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.5e-43], N[Not[LessEqual[y, 6.8e-99]], $MachinePrecision]], N[(x + N[(y * N[(6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{-43} \lor \neg \left(y \leq 6.8 \cdot 10^{-99}\right):\\
\;\;\;\;x + y \cdot \left(6 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z \cdot -6\right)\\
\end{array}
\end{array}
if y < -7.50000000000000068e-43 or 6.80000000000000014e-99 < y Initial program 99.8%
Taylor expanded in y around inf 90.2%
*-commutative90.2%
associate-*r*90.4%
Simplified90.4%
if -7.50000000000000068e-43 < y < 6.80000000000000014e-99Initial program 99.8%
Taylor expanded in y around 0 87.2%
*-commutative87.2%
associate-*r*87.3%
*-commutative87.3%
Simplified87.3%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.1e-44) (not (<= y 4.8e-101))) (+ x (* y (* 6.0 z))) (+ x (* z (* x -6.0)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.1e-44) || !(y <= 4.8e-101)) {
tmp = x + (y * (6.0 * z));
} else {
tmp = x + (z * (x * -6.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.1d-44)) .or. (.not. (y <= 4.8d-101))) then
tmp = x + (y * (6.0d0 * z))
else
tmp = x + (z * (x * (-6.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.1e-44) || !(y <= 4.8e-101)) {
tmp = x + (y * (6.0 * z));
} else {
tmp = x + (z * (x * -6.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.1e-44) or not (y <= 4.8e-101): tmp = x + (y * (6.0 * z)) else: tmp = x + (z * (x * -6.0)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.1e-44) || !(y <= 4.8e-101)) tmp = Float64(x + Float64(y * Float64(6.0 * z))); else tmp = Float64(x + Float64(z * Float64(x * -6.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.1e-44) || ~((y <= 4.8e-101))) tmp = x + (y * (6.0 * z)); else tmp = x + (z * (x * -6.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.1e-44], N[Not[LessEqual[y, 4.8e-101]], $MachinePrecision]], N[(x + N[(y * N[(6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(x * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{-44} \lor \neg \left(y \leq 4.8 \cdot 10^{-101}\right):\\
\;\;\;\;x + y \cdot \left(6 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(x \cdot -6\right)\\
\end{array}
\end{array}
if y < -1.10000000000000006e-44 or 4.8e-101 < y Initial program 99.8%
Taylor expanded in y around inf 90.2%
*-commutative90.2%
associate-*r*90.4%
Simplified90.4%
if -1.10000000000000006e-44 < y < 4.8e-101Initial program 99.8%
Taylor expanded in y around 0 87.3%
Final simplification89.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 59.6%
Final simplification59.6%
(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 59.6%
Taylor expanded in z around 0 33.6%
Final simplification33.6%
(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 2024054
(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)))