
(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 (/ 6.0 (/ (/ 1.0 (- y x)) z))))
double code(double x, double y, double z) {
return x + (6.0 / ((1.0 / (y - 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 / ((1.0d0 / (y - x)) / z))
end function
public static double code(double x, double y, double z) {
return x + (6.0 / ((1.0 / (y - x)) / z));
}
def code(x, y, z): return x + (6.0 / ((1.0 / (y - x)) / z))
function code(x, y, z) return Float64(x + Float64(6.0 / Float64(Float64(1.0 / Float64(y - x)) / z))) end
function tmp = code(x, y, z) tmp = x + (6.0 / ((1.0 / (y - x)) / z)); end
code[x_, y_, z_] := N[(x + N[(6.0 / N[(N[(1.0 / N[(y - x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{6}{\frac{\frac{1}{y - x}}{z}}
\end{array}
Initial program 99.8%
associate-*r*99.8%
*-commutative99.8%
flip--68.8%
associate-*r/65.1%
Applied egg-rr65.1%
associate-/l*68.7%
associate-/l*68.8%
difference-of-squares72.2%
associate-/r*99.8%
*-inverses99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.9e-75) (not (<= y 2.9e-95))) (+ x (* 6.0 (* y z))) (+ x (* -6.0 (* x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.9e-75) || !(y <= 2.9e-95)) {
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 <= (-2.9d-75)) .or. (.not. (y <= 2.9d-95))) 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 <= -2.9e-75) || !(y <= 2.9e-95)) {
tmp = x + (6.0 * (y * z));
} else {
tmp = x + (-6.0 * (x * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.9e-75) or not (y <= 2.9e-95): 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 <= -2.9e-75) || !(y <= 2.9e-95)) 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 <= -2.9e-75) || ~((y <= 2.9e-95))) 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, -2.9e-75], N[Not[LessEqual[y, 2.9e-95]], $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 -2.9 \cdot 10^{-75} \lor \neg \left(y \leq 2.9 \cdot 10^{-95}\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 < -2.9000000000000002e-75 or 2.90000000000000002e-95 < y Initial program 99.8%
Taylor expanded in y around inf 85.4%
*-commutative85.4%
Simplified85.4%
if -2.9000000000000002e-75 < y < 2.90000000000000002e-95Initial program 99.8%
Taylor expanded in y around 0 94.6%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.55e-75) (not (<= y 7.2e-95))) (+ x (* z (* 6.0 y))) (+ x (* -6.0 (* x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.55e-75) || !(y <= 7.2e-95)) {
tmp = x + (z * (6.0 * 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.55d-75)) .or. (.not. (y <= 7.2d-95))) then
tmp = x + (z * (6.0d0 * 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.55e-75) || !(y <= 7.2e-95)) {
tmp = x + (z * (6.0 * y));
} else {
tmp = x + (-6.0 * (x * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.55e-75) or not (y <= 7.2e-95): tmp = x + (z * (6.0 * y)) else: tmp = x + (-6.0 * (x * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.55e-75) || !(y <= 7.2e-95)) tmp = Float64(x + Float64(z * Float64(6.0 * 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.55e-75) || ~((y <= 7.2e-95))) tmp = x + (z * (6.0 * y)); else tmp = x + (-6.0 * (x * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.55e-75], N[Not[LessEqual[y, 7.2e-95]], $MachinePrecision]], N[(x + N[(z * N[(6.0 * 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.55 \cdot 10^{-75} \lor \neg \left(y \leq 7.2 \cdot 10^{-95}\right):\\
\;\;\;\;x + z \cdot \left(6 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x + -6 \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if y < -1.55000000000000003e-75 or 7.2e-95 < y Initial program 99.8%
Taylor expanded in y around inf 85.5%
if -1.55000000000000003e-75 < y < 7.2e-95Initial program 99.8%
Taylor expanded in y around 0 94.6%
Final simplification89.1%
(FPCore (x y z) :precision binary64 (if (<= y -3.4e-78) (+ x (* y (* 6.0 z))) (if (<= y 7.5e-96) (+ x (* -6.0 (* x z))) (+ x (* z (* 6.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.4e-78) {
tmp = x + (y * (6.0 * z));
} else if (y <= 7.5e-96) {
tmp = x + (-6.0 * (x * z));
} else {
tmp = x + (z * (6.0 * y));
}
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.4d-78)) then
tmp = x + (y * (6.0d0 * z))
else if (y <= 7.5d-96) then
tmp = x + ((-6.0d0) * (x * z))
else
tmp = x + (z * (6.0d0 * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.4e-78) {
tmp = x + (y * (6.0 * z));
} else if (y <= 7.5e-96) {
tmp = x + (-6.0 * (x * z));
} else {
tmp = x + (z * (6.0 * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.4e-78: tmp = x + (y * (6.0 * z)) elif y <= 7.5e-96: tmp = x + (-6.0 * (x * z)) else: tmp = x + (z * (6.0 * y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.4e-78) tmp = Float64(x + Float64(y * Float64(6.0 * z))); elseif (y <= 7.5e-96) tmp = Float64(x + Float64(-6.0 * Float64(x * z))); else tmp = Float64(x + Float64(z * Float64(6.0 * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.4e-78) tmp = x + (y * (6.0 * z)); elseif (y <= 7.5e-96) tmp = x + (-6.0 * (x * z)); else tmp = x + (z * (6.0 * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.4e-78], N[(x + N[(y * N[(6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.5e-96], N[(x + N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(6.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{-78}:\\
\;\;\;\;x + y \cdot \left(6 \cdot z\right)\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-96}:\\
\;\;\;\;x + -6 \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(6 \cdot y\right)\\
\end{array}
\end{array}
if y < -3.40000000000000012e-78Initial program 99.7%
associate-*r*99.8%
*-commutative99.8%
flip--64.6%
associate-*r/62.0%
Applied egg-rr62.0%
associate-/l*64.5%
associate-/l*64.4%
difference-of-squares67.4%
associate-/r*99.8%
*-inverses99.8%
Simplified99.8%
Taylor expanded in y around inf 83.7%
associate-/r*83.8%
Simplified83.8%
associate-/r/83.8%
associate-/r/83.8%
metadata-eval83.8%
*-commutative83.8%
associate-*r*83.9%
*-commutative83.9%
Applied egg-rr83.9%
if -3.40000000000000012e-78 < y < 7.5e-96Initial program 99.8%
Taylor expanded in y around 0 94.6%
if 7.5e-96 < y Initial program 99.9%
Taylor expanded in y around inf 87.1%
Final simplification89.1%
(FPCore (x y z) :precision binary64 (+ x (* 6.0 (* (- y x) z))))
double code(double x, double y, double z) {
return x + (6.0 * ((y - 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 * ((y - x) * z))
end function
public static double code(double x, double y, double z) {
return x + (6.0 * ((y - x) * z));
}
def code(x, y, z): return x + (6.0 * ((y - x) * z))
function code(x, y, z) return Float64(x + Float64(6.0 * Float64(Float64(y - x) * z))) end
function tmp = code(x, y, z) tmp = x + (6.0 * ((y - x) * z)); end
code[x_, y_, z_] := N[(x + N[(6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + 6 \cdot \left(\left(y - x\right) \cdot z\right)
\end{array}
Initial program 99.8%
Taylor expanded in z around 0 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (+ x (* z (* 6.0 (- y x)))))
double code(double x, double y, double z) {
return x + (z * (6.0 * (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 + (z * (6.0d0 * (y - x)))
end function
public static double code(double x, double y, double z) {
return x + (z * (6.0 * (y - x)));
}
def code(x, y, z): return x + (z * (6.0 * (y - x)))
function code(x, y, z) return Float64(x + Float64(z * Float64(6.0 * Float64(y - x)))) end
function tmp = code(x, y, z) tmp = x + (z * (6.0 * (y - x))); end
code[x_, y_, z_] := N[(x + N[(z * N[(6.0 * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + z \cdot \left(6 \cdot \left(y - x\right)\right)
\end{array}
Initial program 99.8%
Final simplification99.8%
(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 67.5%
Final simplification67.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 39.2%
Final simplification39.2%
(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 2023280
(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)))