
(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 6 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) z) 6.0)))
double code(double x, double y, double z) {
return x + (((y - x) * z) * 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 + (((y - x) * z) * 6.0d0)
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * z) * 6.0);
}
def code(x, y, z): return x + (((y - x) * z) * 6.0)
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * z) * 6.0)) end
function tmp = code(x, y, z) tmp = x + (((y - x) * z) * 6.0); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot z\right) \cdot 6
\end{array}
Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites3.3%
Taylor expanded in x around 0
Applied rewrites68.5%
Taylor expanded in x around inf
Applied rewrites99.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- y x) z)) (t_1 (* t_0 6.0))) (if (<= z -6.6e-34) t_1 (if (<= z 0.000115) (+ x t_0) t_1))))
double code(double x, double y, double z) {
double t_0 = (y - x) * z;
double t_1 = t_0 * 6.0;
double tmp;
if (z <= -6.6e-34) {
tmp = t_1;
} else if (z <= 0.000115) {
tmp = x + t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = (y - x) * z
t_1 = t_0 * 6.0d0
if (z <= (-6.6d-34)) then
tmp = t_1
else if (z <= 0.000115d0) then
tmp = x + t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y - x) * z;
double t_1 = t_0 * 6.0;
double tmp;
if (z <= -6.6e-34) {
tmp = t_1;
} else if (z <= 0.000115) {
tmp = x + t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (y - x) * z t_1 = t_0 * 6.0 tmp = 0 if z <= -6.6e-34: tmp = t_1 elif z <= 0.000115: tmp = x + t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(y - x) * z) t_1 = Float64(t_0 * 6.0) tmp = 0.0 if (z <= -6.6e-34) tmp = t_1; elseif (z <= 0.000115) tmp = Float64(x + t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - x) * z; t_1 = t_0 * 6.0; tmp = 0.0; if (z <= -6.6e-34) tmp = t_1; elseif (z <= 0.000115) tmp = x + t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * 6.0), $MachinePrecision]}, If[LessEqual[z, -6.6e-34], t$95$1, If[LessEqual[z, 0.000115], N[(x + t$95$0), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - x\right) \cdot z\\
t_1 := t\_0 \cdot 6\\
\mathbf{if}\;z \leq -6.6 \cdot 10^{-34}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 0.000115:\\
\;\;\;\;x + t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -6.59999999999999965e-34 or 1.15e-4 < z Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites4.0%
Taylor expanded in x around 0
Applied rewrites97.3%
Taylor expanded in x around inf
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites97.4%
if -6.59999999999999965e-34 < z < 1.15e-4Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites77.0%
(FPCore (x y z) :precision binary64 (+ x (* (- y x) z)))
double code(double x, double y, double z) {
return x + ((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 + ((y - x) * z)
end function
public static double code(double x, double y, double z) {
return x + ((y - x) * z);
}
def code(x, y, z): return x + ((y - x) * z)
function code(x, y, z) return Float64(x + Float64(Float64(y - x) * z)) end
function tmp = code(x, y, z) tmp = x + ((y - x) * z); end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - x\right) \cdot z
\end{array}
Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites64.4%
(FPCore (x y z) :precision binary64 (* (- y x) z))
double code(double x, double y, double z) {
return (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 = (y - x) * z
end function
public static double code(double x, double y, double z) {
return (y - x) * z;
}
def code(x, y, z): return (y - x) * z
function code(x, y, z) return Float64(Float64(y - x) * z) end
function tmp = code(x, y, z) tmp = (y - x) * z; end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]
\begin{array}{l}
\\
\left(y - x\right) \cdot z
\end{array}
Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites63.9%
Taylor expanded in x around 0
Applied rewrites30.1%
(FPCore (x y z) :precision binary64 (+ x (- y x)))
double code(double x, double y, double z) {
return x + (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 + (y - x)
end function
public static double code(double x, double y, double z) {
return x + (y - x);
}
def code(x, y, z): return x + (y - x)
function code(x, y, z) return Float64(x + Float64(y - x)) end
function tmp = code(x, y, z) tmp = x + (y - x); end
code[x_, y_, z_] := N[(x + N[(y - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - x\right)
\end{array}
Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites3.3%
Taylor expanded in x around 0
Applied rewrites3.3%
(FPCore (x y z) :precision binary64 (- y x))
double code(double x, double y, double z) {
return 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 = y - x
end function
public static double code(double x, double y, double z) {
return y - x;
}
def code(x, y, z): return y - x
function code(x, y, z) return Float64(y - x) end
function tmp = code(x, y, z) tmp = y - x; end
code[x_, y_, z_] := N[(y - x), $MachinePrecision]
\begin{array}{l}
\\
y - x
\end{array}
Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites63.9%
Taylor expanded in x around inf
Applied rewrites3.3%
(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 2024321
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
:precision binary64
:pre (TRUE)
:alt
(! :herbie-platform default (- x (* (* 6 z) (- x y))))
(+ x (* (* (- y x) 6.0) z)))