
(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%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.8e+132) (not (<= x 1.1e+182))) (* x (+ (* z -6.0) 1.0)) (+ x (* 6.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.8e+132) || !(x <= 1.1e+182)) {
tmp = x * ((z * -6.0) + 1.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 <= (-3.8d+132)) .or. (.not. (x <= 1.1d+182))) then
tmp = x * ((z * (-6.0d0)) + 1.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 <= -3.8e+132) || !(x <= 1.1e+182)) {
tmp = x * ((z * -6.0) + 1.0);
} else {
tmp = x + (6.0 * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.8e+132) or not (x <= 1.1e+182): tmp = x * ((z * -6.0) + 1.0) else: tmp = x + (6.0 * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.8e+132) || !(x <= 1.1e+182)) tmp = Float64(x * Float64(Float64(z * -6.0) + 1.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 <= -3.8e+132) || ~((x <= 1.1e+182))) tmp = x * ((z * -6.0) + 1.0); else tmp = x + (6.0 * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.8e+132], N[Not[LessEqual[x, 1.1e+182]], $MachinePrecision]], N[(x * N[(N[(z * -6.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{+132} \lor \neg \left(x \leq 1.1 \cdot 10^{+182}\right):\\
\;\;\;\;x \cdot \left(z \cdot -6 + 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if x < -3.80000000000000006e132 or 1.09999999999999998e182 < x Initial program 99.8%
Taylor expanded in x around inf 93.4%
+-commutative93.4%
Simplified93.4%
if -3.80000000000000006e132 < x < 1.09999999999999998e182Initial program 99.8%
Taylor expanded in y around inf 85.0%
*-commutative85.0%
Simplified85.0%
Final simplification87.1%
(FPCore (x y z) :precision binary64 (if (<= y -5.9e-49) (* 6.0 (* y z)) (if (<= y 1.18e+80) (* x (+ (* z -6.0) 1.0)) (* z (* y 6.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.9e-49) {
tmp = 6.0 * (y * z);
} else if (y <= 1.18e+80) {
tmp = x * ((z * -6.0) + 1.0);
} else {
tmp = z * (y * 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 <= (-5.9d-49)) then
tmp = 6.0d0 * (y * z)
else if (y <= 1.18d+80) then
tmp = x * ((z * (-6.0d0)) + 1.0d0)
else
tmp = z * (y * 6.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.9e-49) {
tmp = 6.0 * (y * z);
} else if (y <= 1.18e+80) {
tmp = x * ((z * -6.0) + 1.0);
} else {
tmp = z * (y * 6.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.9e-49: tmp = 6.0 * (y * z) elif y <= 1.18e+80: tmp = x * ((z * -6.0) + 1.0) else: tmp = z * (y * 6.0) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.9e-49) tmp = Float64(6.0 * Float64(y * z)); elseif (y <= 1.18e+80) tmp = Float64(x * Float64(Float64(z * -6.0) + 1.0)); else tmp = Float64(z * Float64(y * 6.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.9e-49) tmp = 6.0 * (y * z); elseif (y <= 1.18e+80) tmp = x * ((z * -6.0) + 1.0); else tmp = z * (y * 6.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.9e-49], N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.18e+80], N[(x * N[(N[(z * -6.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(z * N[(y * 6.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.9 \cdot 10^{-49}:\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;y \leq 1.18 \cdot 10^{+80}:\\
\;\;\;\;x \cdot \left(z \cdot -6 + 1\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot 6\right)\\
\end{array}
\end{array}
if y < -5.90000000000000037e-49Initial program 99.7%
Taylor expanded in y around inf 90.6%
*-commutative90.6%
Simplified90.6%
Taylor expanded in x around inf 83.9%
+-commutative83.9%
associate-/l*83.9%
Simplified83.9%
Taylor expanded in x around 0 71.7%
if -5.90000000000000037e-49 < y < 1.18e80Initial program 99.8%
Taylor expanded in x around inf 80.8%
+-commutative80.8%
Simplified80.8%
if 1.18e80 < y Initial program 99.8%
Taylor expanded in y around inf 97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in z around inf 90.4%
Taylor expanded in y around inf 86.1%
Final simplification79.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -7.5e+41) (not (<= x 2.7e-55))) (/ (* x z) z) (* z (* y 6.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -7.5e+41) || !(x <= 2.7e-55)) {
tmp = (x * z) / z;
} else {
tmp = z * (y * 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 ((x <= (-7.5d+41)) .or. (.not. (x <= 2.7d-55))) then
tmp = (x * z) / z
else
tmp = z * (y * 6.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -7.5e+41) || !(x <= 2.7e-55)) {
tmp = (x * z) / z;
} else {
tmp = z * (y * 6.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -7.5e+41) or not (x <= 2.7e-55): tmp = (x * z) / z else: tmp = z * (y * 6.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -7.5e+41) || !(x <= 2.7e-55)) tmp = Float64(Float64(x * z) / z); else tmp = Float64(z * Float64(y * 6.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -7.5e+41) || ~((x <= 2.7e-55))) tmp = (x * z) / z; else tmp = z * (y * 6.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -7.5e+41], N[Not[LessEqual[x, 2.7e-55]], $MachinePrecision]], N[(N[(x * z), $MachinePrecision] / z), $MachinePrecision], N[(z * N[(y * 6.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{+41} \lor \neg \left(x \leq 2.7 \cdot 10^{-55}\right):\\
\;\;\;\;\frac{x \cdot z}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot 6\right)\\
\end{array}
\end{array}
if x < -7.50000000000000072e41 or 2.70000000000000004e-55 < x Initial program 99.8%
Taylor expanded in z around inf 76.4%
Taylor expanded in z around 0 22.4%
associate-*r/55.2%
Applied egg-rr55.2%
if -7.50000000000000072e41 < x < 2.70000000000000004e-55Initial program 99.8%
Taylor expanded in y around inf 88.5%
*-commutative88.5%
Simplified88.5%
Taylor expanded in z around inf 88.5%
Taylor expanded in y around inf 70.3%
Final simplification63.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -3e-112) (not (<= z 6e-65))) (* 6.0 (* y z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3e-112) || !(z <= 6e-65)) {
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 <= (-3d-112)) .or. (.not. (z <= 6d-65))) 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 <= -3e-112) || !(z <= 6e-65)) {
tmp = 6.0 * (y * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3e-112) or not (z <= 6e-65): tmp = 6.0 * (y * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3e-112) || !(z <= 6e-65)) 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 <= -3e-112) || ~((z <= 6e-65))) tmp = 6.0 * (y * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3e-112], N[Not[LessEqual[z, 6e-65]], $MachinePrecision]], N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{-112} \lor \neg \left(z \leq 6 \cdot 10^{-65}\right):\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -3.0000000000000001e-112 or 5.99999999999999996e-65 < z Initial program 99.7%
Taylor expanded in y around inf 65.1%
*-commutative65.1%
Simplified65.1%
Taylor expanded in x around inf 55.9%
+-commutative55.9%
associate-/l*50.7%
Simplified50.7%
Taylor expanded in x around 0 58.4%
if -3.0000000000000001e-112 < z < 5.99999999999999996e-65Initial program 99.9%
Taylor expanded in z around 0 73.7%
Final simplification64.0%
(FPCore (x y z) :precision binary64 (if (<= z -1.05e-111) (* 6.0 (* y z)) (if (<= z 1.45e-68) x (* z (* y 6.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.05e-111) {
tmp = 6.0 * (y * z);
} else if (z <= 1.45e-68) {
tmp = x;
} else {
tmp = z * (y * 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 (z <= (-1.05d-111)) then
tmp = 6.0d0 * (y * z)
else if (z <= 1.45d-68) then
tmp = x
else
tmp = z * (y * 6.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.05e-111) {
tmp = 6.0 * (y * z);
} else if (z <= 1.45e-68) {
tmp = x;
} else {
tmp = z * (y * 6.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.05e-111: tmp = 6.0 * (y * z) elif z <= 1.45e-68: tmp = x else: tmp = z * (y * 6.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.05e-111) tmp = Float64(6.0 * Float64(y * z)); elseif (z <= 1.45e-68) tmp = x; else tmp = Float64(z * Float64(y * 6.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.05e-111) tmp = 6.0 * (y * z); elseif (z <= 1.45e-68) tmp = x; else tmp = z * (y * 6.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.05e-111], N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.45e-68], x, N[(z * N[(y * 6.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{-111}:\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{-68}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot 6\right)\\
\end{array}
\end{array}
if z < -1.0499999999999999e-111Initial program 99.7%
Taylor expanded in y around inf 67.7%
*-commutative67.7%
Simplified67.7%
Taylor expanded in x around inf 58.3%
+-commutative58.3%
associate-/l*53.9%
Simplified53.9%
Taylor expanded in x around 0 59.0%
if -1.0499999999999999e-111 < z < 1.45e-68Initial program 99.9%
Taylor expanded in z around 0 73.7%
if 1.45e-68 < z Initial program 99.8%
Taylor expanded in y around inf 61.9%
*-commutative61.9%
Simplified61.9%
Taylor expanded in z around inf 61.9%
Taylor expanded in y around inf 57.8%
Final simplification64.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 z around 0 32.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 2024108
(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)))