
(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(y - x) * Float64(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[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - x\right) \cdot \left(6 \cdot z\right)
\end{array}
Initial program 99.8%
associate-*l*99.8%
Simplified99.8%
(FPCore (x y z) :precision binary64 (if (<= z -2.5e+91) (* z (* x -6.0)) (if (or (<= z -1.9e-31) (not (<= z 1.54e-55))) (* 6.0 (* y z)) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.5e+91) {
tmp = z * (x * -6.0);
} else if ((z <= -1.9e-31) || !(z <= 1.54e-55)) {
tmp = 6.0 * (y * 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 <= (-2.5d+91)) then
tmp = z * (x * (-6.0d0))
else if ((z <= (-1.9d-31)) .or. (.not. (z <= 1.54d-55))) then
tmp = 6.0d0 * (y * z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.5e+91) {
tmp = z * (x * -6.0);
} else if ((z <= -1.9e-31) || !(z <= 1.54e-55)) {
tmp = 6.0 * (y * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.5e+91: tmp = z * (x * -6.0) elif (z <= -1.9e-31) or not (z <= 1.54e-55): tmp = 6.0 * (y * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.5e+91) tmp = Float64(z * Float64(x * -6.0)); elseif ((z <= -1.9e-31) || !(z <= 1.54e-55)) tmp = Float64(6.0 * Float64(y * z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.5e+91) tmp = z * (x * -6.0); elseif ((z <= -1.9e-31) || ~((z <= 1.54e-55))) tmp = 6.0 * (y * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.5e+91], N[(z * N[(x * -6.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -1.9e-31], N[Not[LessEqual[z, 1.54e-55]], $MachinePrecision]], N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{+91}:\\
\;\;\;\;z \cdot \left(x \cdot -6\right)\\
\mathbf{elif}\;z \leq -1.9 \cdot 10^{-31} \lor \neg \left(z \leq 1.54 \cdot 10^{-55}\right):\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.5000000000000001e91Initial program 99.8%
associate-*r*99.9%
+-commutative99.9%
*-commutative99.9%
associate-*r*99.9%
fma-define99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*r*99.8%
Simplified99.8%
Taylor expanded in y around 0 60.9%
if -2.5000000000000001e91 < z < -1.9e-31 or 1.54000000000000007e-55 < z Initial program 99.7%
associate-*r*99.7%
+-commutative99.7%
*-commutative99.7%
associate-*r*99.7%
fma-define99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 58.3%
*-commutative58.3%
Simplified58.3%
if -1.9e-31 < z < 1.54000000000000007e-55Initial program 99.9%
Taylor expanded in z around 0 78.4%
Final simplification67.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -6.5e+19) (not (<= z 0.165))) (* z (* (- y x) 6.0)) (+ x (* y (* 6.0 z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6.5e+19) || !(z <= 0.165)) {
tmp = z * ((y - x) * 6.0);
} else {
tmp = x + (y * (6.0 * 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 <= (-6.5d+19)) .or. (.not. (z <= 0.165d0))) then
tmp = z * ((y - x) * 6.0d0)
else
tmp = x + (y * (6.0d0 * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -6.5e+19) || !(z <= 0.165)) {
tmp = z * ((y - x) * 6.0);
} else {
tmp = x + (y * (6.0 * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6.5e+19) or not (z <= 0.165): tmp = z * ((y - x) * 6.0) else: tmp = x + (y * (6.0 * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6.5e+19) || !(z <= 0.165)) tmp = Float64(z * Float64(Float64(y - x) * 6.0)); else tmp = Float64(x + Float64(y * Float64(6.0 * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6.5e+19) || ~((z <= 0.165))) tmp = z * ((y - x) * 6.0); else tmp = x + (y * (6.0 * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6.5e+19], N[Not[LessEqual[z, 0.165]], $MachinePrecision]], N[(z * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+19} \lor \neg \left(z \leq 0.165\right):\\
\;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(6 \cdot z\right)\\
\end{array}
\end{array}
if z < -6.5e19 or 0.165000000000000008 < z Initial program 99.7%
associate-*r*99.8%
+-commutative99.8%
*-commutative99.8%
associate-*r*99.7%
fma-define99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 98.5%
associate-*r*98.6%
*-commutative98.6%
associate-*r*98.6%
Simplified98.6%
if -6.5e19 < z < 0.165000000000000008Initial program 99.8%
Taylor expanded in y around inf 99.3%
*-commutative99.3%
associate-*r*99.3%
Simplified99.3%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -6.5e+19) (not (<= z 0.165))) (* z (* (- y x) 6.0)) (+ x (* 6.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6.5e+19) || !(z <= 0.165)) {
tmp = z * ((y - 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 ((z <= (-6.5d+19)) .or. (.not. (z <= 0.165d0))) then
tmp = z * ((y - 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 ((z <= -6.5e+19) || !(z <= 0.165)) {
tmp = z * ((y - x) * 6.0);
} else {
tmp = x + (6.0 * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6.5e+19) or not (z <= 0.165): tmp = z * ((y - x) * 6.0) else: tmp = x + (6.0 * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6.5e+19) || !(z <= 0.165)) tmp = Float64(z * Float64(Float64(y - 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 ((z <= -6.5e+19) || ~((z <= 0.165))) tmp = z * ((y - x) * 6.0); else tmp = x + (6.0 * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6.5e+19], N[Not[LessEqual[z, 0.165]], $MachinePrecision]], N[(z * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+19} \lor \neg \left(z \leq 0.165\right):\\
\;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\
\mathbf{else}:\\
\;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -6.5e19 or 0.165000000000000008 < z Initial program 99.7%
associate-*r*99.8%
+-commutative99.8%
*-commutative99.8%
associate-*r*99.7%
fma-define99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 98.5%
associate-*r*98.6%
*-commutative98.6%
associate-*r*98.6%
Simplified98.6%
if -6.5e19 < z < 0.165000000000000008Initial program 99.8%
Taylor expanded in y around inf 99.3%
*-commutative99.3%
Simplified99.3%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.3e-56) (not (<= z 4.3e-57))) (* z (* (- y x) 6.0)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.3e-56) || !(z <= 4.3e-57)) {
tmp = z * ((y - x) * 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 <= (-2.3d-56)) .or. (.not. (z <= 4.3d-57))) then
tmp = z * ((y - x) * 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 <= -2.3e-56) || !(z <= 4.3e-57)) {
tmp = z * ((y - x) * 6.0);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.3e-56) or not (z <= 4.3e-57): tmp = z * ((y - x) * 6.0) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.3e-56) || !(z <= 4.3e-57)) tmp = Float64(z * Float64(Float64(y - x) * 6.0)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.3e-56) || ~((z <= 4.3e-57))) tmp = z * ((y - x) * 6.0); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.3e-56], N[Not[LessEqual[z, 4.3e-57]], $MachinePrecision]], N[(z * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{-56} \lor \neg \left(z \leq 4.3 \cdot 10^{-57}\right):\\
\;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.30000000000000002e-56 or 4.30000000000000022e-57 < z Initial program 99.7%
associate-*r*99.8%
+-commutative99.8%
*-commutative99.8%
associate-*r*99.7%
fma-define99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 92.7%
associate-*r*92.8%
*-commutative92.8%
associate-*r*92.7%
Simplified92.7%
if -2.30000000000000002e-56 < z < 4.30000000000000022e-57Initial program 99.9%
Taylor expanded in z around 0 79.3%
Final simplification86.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.35e-31) (not (<= z 5.1e-56))) (* 6.0 (* y z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.35e-31) || !(z <= 5.1e-56)) {
tmp = 6.0 * (y * 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 <= (-1.35d-31)) .or. (.not. (z <= 5.1d-56))) then
tmp = 6.0d0 * (y * z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.35e-31) || !(z <= 5.1e-56)) {
tmp = 6.0 * (y * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.35e-31) or not (z <= 5.1e-56): tmp = 6.0 * (y * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.35e-31) || !(z <= 5.1e-56)) tmp = Float64(6.0 * Float64(y * z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.35e-31) || ~((z <= 5.1e-56))) tmp = 6.0 * (y * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.35e-31], N[Not[LessEqual[z, 5.1e-56]], $MachinePrecision]], N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{-31} \lor \neg \left(z \leq 5.1 \cdot 10^{-56}\right):\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.35000000000000007e-31 or 5.1e-56 < z Initial program 99.7%
associate-*r*99.8%
+-commutative99.8%
*-commutative99.8%
associate-*r*99.7%
fma-define99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 55.6%
*-commutative55.6%
Simplified55.6%
if -1.35000000000000007e-31 < z < 5.1e-56Initial program 99.9%
Taylor expanded in z around 0 78.4%
Final simplification65.8%
(FPCore (x y z) :precision binary64 (+ x (* z (* (- y x) 6.0))))
double code(double x, double y, double z) {
return x + (z * ((y - x) * 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 + (z * ((y - x) * 6.0d0))
end function
public static double code(double x, double y, double z) {
return x + (z * ((y - x) * 6.0));
}
def code(x, y, z): return x + (z * ((y - x) * 6.0))
function code(x, y, z) return Float64(x + Float64(z * Float64(Float64(y - x) * 6.0))) end
function tmp = code(x, y, z) tmp = x + (z * ((y - x) * 6.0)); end
code[x_, y_, z_] := N[(x + N[(z * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + z \cdot \left(\left(y - x\right) \cdot 6\right)
\end{array}
Initial program 99.8%
Final simplification99.8%
(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 39.1%
(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 2024180
(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)))