
(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(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.2%
+-lowering-+.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
*-lowering-*.f6499.8%
Simplified99.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* 6.0 (* (- y x) z)))) (if (<= z -0.175) t_0 (if (<= z 0.17) (+ x (* y (* 6.0 z))) t_0))))
double code(double x, double y, double z) {
double t_0 = 6.0 * ((y - x) * z);
double tmp;
if (z <= -0.175) {
tmp = t_0;
} else if (z <= 0.17) {
tmp = x + (y * (6.0 * z));
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = 6.0d0 * ((y - x) * z)
if (z <= (-0.175d0)) then
tmp = t_0
else if (z <= 0.17d0) then
tmp = x + (y * (6.0d0 * z))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 6.0 * ((y - x) * z);
double tmp;
if (z <= -0.175) {
tmp = t_0;
} else if (z <= 0.17) {
tmp = x + (y * (6.0 * z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 6.0 * ((y - x) * z) tmp = 0 if z <= -0.175: tmp = t_0 elif z <= 0.17: tmp = x + (y * (6.0 * z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(6.0 * Float64(Float64(y - x) * z)) tmp = 0.0 if (z <= -0.175) tmp = t_0; elseif (z <= 0.17) tmp = Float64(x + Float64(y * Float64(6.0 * z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 6.0 * ((y - x) * z); tmp = 0.0; if (z <= -0.175) tmp = t_0; elseif (z <= 0.17) tmp = x + (y * (6.0 * z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.175], t$95$0, If[LessEqual[z, 0.17], N[(x + N[(y * N[(6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 6 \cdot \left(\left(y - x\right) \cdot z\right)\\
\mathbf{if}\;z \leq -0.175:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.17:\\
\;\;\;\;x + y \cdot \left(6 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.17499999999999999 or 0.170000000000000012 < z Initial program 99.7%
Taylor expanded in z around inf
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6498.2%
Simplified98.2%
if -0.17499999999999999 < z < 0.170000000000000012Initial program 98.6%
+-lowering-+.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
*-lowering-*.f6499.9%
Simplified99.9%
Taylor expanded in y around inf
Simplified99.1%
Final simplification98.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 6.0 (* (- y x) z))))
(if (<= z -1850000.0)
t_0
(if (<= z 7.6e-80) (* x (+ 1.0 (* z -6.0))) t_0))))
double code(double x, double y, double z) {
double t_0 = 6.0 * ((y - x) * z);
double tmp;
if (z <= -1850000.0) {
tmp = t_0;
} else if (z <= 7.6e-80) {
tmp = x * (1.0 + (z * -6.0));
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = 6.0d0 * ((y - x) * z)
if (z <= (-1850000.0d0)) then
tmp = t_0
else if (z <= 7.6d-80) then
tmp = x * (1.0d0 + (z * (-6.0d0)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 6.0 * ((y - x) * z);
double tmp;
if (z <= -1850000.0) {
tmp = t_0;
} else if (z <= 7.6e-80) {
tmp = x * (1.0 + (z * -6.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 6.0 * ((y - x) * z) tmp = 0 if z <= -1850000.0: tmp = t_0 elif z <= 7.6e-80: tmp = x * (1.0 + (z * -6.0)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(6.0 * Float64(Float64(y - x) * z)) tmp = 0.0 if (z <= -1850000.0) tmp = t_0; elseif (z <= 7.6e-80) tmp = Float64(x * Float64(1.0 + Float64(z * -6.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 6.0 * ((y - x) * z); tmp = 0.0; if (z <= -1850000.0) tmp = t_0; elseif (z <= 7.6e-80) tmp = x * (1.0 + (z * -6.0)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1850000.0], t$95$0, If[LessEqual[z, 7.6e-80], N[(x * N[(1.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 6 \cdot \left(\left(y - x\right) \cdot z\right)\\
\mathbf{if}\;z \leq -1850000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 7.6 \cdot 10^{-80}:\\
\;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.85e6 or 7.59999999999999933e-80 < z Initial program 99.7%
Taylor expanded in z around inf
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6496.5%
Simplified96.5%
if -1.85e6 < z < 7.59999999999999933e-80Initial program 98.4%
Taylor expanded in x around inf
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6476.7%
Simplified76.7%
Final simplification87.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* 6.0 (* (- y x) z)))) (if (<= z -4.5e-82) t_0 (if (<= z 3.1e-79) x t_0))))
double code(double x, double y, double z) {
double t_0 = 6.0 * ((y - x) * z);
double tmp;
if (z <= -4.5e-82) {
tmp = t_0;
} else if (z <= 3.1e-79) {
tmp = x;
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = 6.0d0 * ((y - x) * z)
if (z <= (-4.5d-82)) then
tmp = t_0
else if (z <= 3.1d-79) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 6.0 * ((y - x) * z);
double tmp;
if (z <= -4.5e-82) {
tmp = t_0;
} else if (z <= 3.1e-79) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 6.0 * ((y - x) * z) tmp = 0 if z <= -4.5e-82: tmp = t_0 elif z <= 3.1e-79: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(6.0 * Float64(Float64(y - x) * z)) tmp = 0.0 if (z <= -4.5e-82) tmp = t_0; elseif (z <= 3.1e-79) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 6.0 * ((y - x) * z); tmp = 0.0; if (z <= -4.5e-82) tmp = t_0; elseif (z <= 3.1e-79) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.5e-82], t$95$0, If[LessEqual[z, 3.1e-79], x, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 6 \cdot \left(\left(y - x\right) \cdot z\right)\\
\mathbf{if}\;z \leq -4.5 \cdot 10^{-82}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.1 \cdot 10^{-79}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.4999999999999998e-82 or 3.0999999999999999e-79 < z Initial program 99.7%
Taylor expanded in z around inf
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6491.4%
Simplified91.4%
if -4.4999999999999998e-82 < z < 3.0999999999999999e-79Initial program 98.2%
Taylor expanded in z around 0
Simplified81.3%
Final simplification87.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* 6.0 (* y z)))) (if (<= z -3e-25) t_0 (if (<= z 3.2e-79) x t_0))))
double code(double x, double y, double z) {
double t_0 = 6.0 * (y * z);
double tmp;
if (z <= -3e-25) {
tmp = t_0;
} else if (z <= 3.2e-79) {
tmp = x;
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = 6.0d0 * (y * z)
if (z <= (-3d-25)) then
tmp = t_0
else if (z <= 3.2d-79) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 6.0 * (y * z);
double tmp;
if (z <= -3e-25) {
tmp = t_0;
} else if (z <= 3.2e-79) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 6.0 * (y * z) tmp = 0 if z <= -3e-25: tmp = t_0 elif z <= 3.2e-79: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(6.0 * Float64(y * z)) tmp = 0.0 if (z <= -3e-25) tmp = t_0; elseif (z <= 3.2e-79) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 6.0 * (y * z); tmp = 0.0; if (z <= -3e-25) tmp = t_0; elseif (z <= 3.2e-79) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3e-25], t$95$0, If[LessEqual[z, 3.2e-79], x, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 6 \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -3 \cdot 10^{-25}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{-79}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.9999999999999998e-25 or 3.19999999999999988e-79 < z Initial program 99.7%
Taylor expanded in z around inf
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6495.1%
Simplified95.1%
Taylor expanded in y around inf
Simplified58.0%
if -2.9999999999999998e-25 < z < 3.19999999999999988e-79Initial program 98.4%
Taylor expanded in z around 0
Simplified77.5%
Final simplification66.3%
(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.2%
Final simplification99.2%
(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.2%
Taylor expanded in z around 0
Simplified36.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 2024158
(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)))