
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
double code(double x, double y, double z) {
return x * (1.0 - (y * 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 * (1.0d0 - (y * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
def code(x, y, z): return x * (1.0 - (y * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - (y * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - y \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
double code(double x, double y, double z) {
return x * (1.0 - (y * 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 * (1.0d0 - (y * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
def code(x, y, z): return x * (1.0 - (y * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - (y * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - y \cdot z\right)
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* y (- x)) z)))
(if (<= (* y z) -5e+216)
t_0
(if (<= (* y z) 2e+250) (* x (- 1.0 (* y z))) t_0))))
double code(double x, double y, double z) {
double t_0 = (y * -x) * z;
double tmp;
if ((y * z) <= -5e+216) {
tmp = t_0;
} else if ((y * z) <= 2e+250) {
tmp = x * (1.0 - (y * 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 = (y * -x) * z
if ((y * z) <= (-5d+216)) then
tmp = t_0
else if ((y * z) <= 2d+250) then
tmp = x * (1.0d0 - (y * z))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y * -x) * z;
double tmp;
if ((y * z) <= -5e+216) {
tmp = t_0;
} else if ((y * z) <= 2e+250) {
tmp = x * (1.0 - (y * z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (y * -x) * z tmp = 0 if (y * z) <= -5e+216: tmp = t_0 elif (y * z) <= 2e+250: tmp = x * (1.0 - (y * z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(y * Float64(-x)) * z) tmp = 0.0 if (Float64(y * z) <= -5e+216) tmp = t_0; elseif (Float64(y * z) <= 2e+250) tmp = Float64(x * Float64(1.0 - Float64(y * z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y * -x) * z; tmp = 0.0; if ((y * z) <= -5e+216) tmp = t_0; elseif ((y * z) <= 2e+250) tmp = x * (1.0 - (y * z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y * (-x)), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[N[(y * z), $MachinePrecision], -5e+216], t$95$0, If[LessEqual[N[(y * z), $MachinePrecision], 2e+250], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y \cdot \left(-x\right)\right) \cdot z\\
\mathbf{if}\;y \cdot z \leq -5 \cdot 10^{+216}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+250}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 y z) < -4.9999999999999998e216 or 1.9999999999999998e250 < (*.f64 y z) Initial program 66.4%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6499.7
Applied rewrites99.7%
Applied rewrites99.8%
if -4.9999999999999998e216 < (*.f64 y z) < 1.9999999999999998e250Initial program 99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* y (- x)) z)))
(if (<= (* y z) -20.0)
t_0
(if (<= (* y z) 1e-7)
(* x 1.0)
(if (<= (* y z) 2e+250) (* x (* y (- z))) t_0)))))
double code(double x, double y, double z) {
double t_0 = (y * -x) * z;
double tmp;
if ((y * z) <= -20.0) {
tmp = t_0;
} else if ((y * z) <= 1e-7) {
tmp = x * 1.0;
} else if ((y * z) <= 2e+250) {
tmp = x * (y * -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 = (y * -x) * z
if ((y * z) <= (-20.0d0)) then
tmp = t_0
else if ((y * z) <= 1d-7) then
tmp = x * 1.0d0
else if ((y * z) <= 2d+250) then
tmp = x * (y * -z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y * -x) * z;
double tmp;
if ((y * z) <= -20.0) {
tmp = t_0;
} else if ((y * z) <= 1e-7) {
tmp = x * 1.0;
} else if ((y * z) <= 2e+250) {
tmp = x * (y * -z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (y * -x) * z tmp = 0 if (y * z) <= -20.0: tmp = t_0 elif (y * z) <= 1e-7: tmp = x * 1.0 elif (y * z) <= 2e+250: tmp = x * (y * -z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(y * Float64(-x)) * z) tmp = 0.0 if (Float64(y * z) <= -20.0) tmp = t_0; elseif (Float64(y * z) <= 1e-7) tmp = Float64(x * 1.0); elseif (Float64(y * z) <= 2e+250) tmp = Float64(x * Float64(y * Float64(-z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y * -x) * z; tmp = 0.0; if ((y * z) <= -20.0) tmp = t_0; elseif ((y * z) <= 1e-7) tmp = x * 1.0; elseif ((y * z) <= 2e+250) tmp = x * (y * -z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y * (-x)), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[N[(y * z), $MachinePrecision], -20.0], t$95$0, If[LessEqual[N[(y * z), $MachinePrecision], 1e-7], N[(x * 1.0), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 2e+250], N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y \cdot \left(-x\right)\right) \cdot z\\
\mathbf{if}\;y \cdot z \leq -20:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \cdot z \leq 10^{-7}:\\
\;\;\;\;x \cdot 1\\
\mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+250}:\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 y z) < -20 or 1.9999999999999998e250 < (*.f64 y z) Initial program 82.3%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6488.8
Applied rewrites88.8%
Applied rewrites92.3%
if -20 < (*.f64 y z) < 9.9999999999999995e-8Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites98.1%
if 9.9999999999999995e-8 < (*.f64 y z) < 1.9999999999999998e250Initial program 99.9%
Taylor expanded in y around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6499.7
Applied rewrites99.7%
(FPCore (x y z) :precision binary64 (if (<= (* y z) -20.0) (* (* y (- x)) z) (if (<= (* y z) 1e-7) (* x 1.0) (* y (* z (- x))))))
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -20.0) {
tmp = (y * -x) * z;
} else if ((y * z) <= 1e-7) {
tmp = x * 1.0;
} else {
tmp = y * (z * -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 ((y * z) <= (-20.0d0)) then
tmp = (y * -x) * z
else if ((y * z) <= 1d-7) then
tmp = x * 1.0d0
else
tmp = y * (z * -x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -20.0) {
tmp = (y * -x) * z;
} else if ((y * z) <= 1e-7) {
tmp = x * 1.0;
} else {
tmp = y * (z * -x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * z) <= -20.0: tmp = (y * -x) * z elif (y * z) <= 1e-7: tmp = x * 1.0 else: tmp = y * (z * -x) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= -20.0) tmp = Float64(Float64(y * Float64(-x)) * z); elseif (Float64(y * z) <= 1e-7) tmp = Float64(x * 1.0); else tmp = Float64(y * Float64(z * Float64(-x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y * z) <= -20.0) tmp = (y * -x) * z; elseif ((y * z) <= 1e-7) tmp = x * 1.0; else tmp = y * (z * -x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], -20.0], N[(N[(y * (-x)), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 1e-7], N[(x * 1.0), $MachinePrecision], N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -20:\\
\;\;\;\;\left(y \cdot \left(-x\right)\right) \cdot z\\
\mathbf{elif}\;y \cdot z \leq 10^{-7}:\\
\;\;\;\;x \cdot 1\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -20Initial program 88.3%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6485.7
Applied rewrites85.7%
Applied rewrites90.0%
if -20 < (*.f64 y z) < 9.9999999999999995e-8Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites98.1%
if 9.9999999999999995e-8 < (*.f64 y z) Initial program 90.6%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6490.3
Applied rewrites90.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* y (* z (- x))))) (if (<= (* y z) -20.0) t_0 (if (<= (* y z) 1e-7) (* x 1.0) t_0))))
double code(double x, double y, double z) {
double t_0 = y * (z * -x);
double tmp;
if ((y * z) <= -20.0) {
tmp = t_0;
} else if ((y * z) <= 1e-7) {
tmp = x * 1.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 = y * (z * -x)
if ((y * z) <= (-20.0d0)) then
tmp = t_0
else if ((y * z) <= 1d-7) then
tmp = x * 1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (z * -x);
double tmp;
if ((y * z) <= -20.0) {
tmp = t_0;
} else if ((y * z) <= 1e-7) {
tmp = x * 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (z * -x) tmp = 0 if (y * z) <= -20.0: tmp = t_0 elif (y * z) <= 1e-7: tmp = x * 1.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(z * Float64(-x))) tmp = 0.0 if (Float64(y * z) <= -20.0) tmp = t_0; elseif (Float64(y * z) <= 1e-7) tmp = Float64(x * 1.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (z * -x); tmp = 0.0; if ((y * z) <= -20.0) tmp = t_0; elseif ((y * z) <= 1e-7) tmp = x * 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z * (-x)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y * z), $MachinePrecision], -20.0], t$95$0, If[LessEqual[N[(y * z), $MachinePrecision], 1e-7], N[(x * 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(z \cdot \left(-x\right)\right)\\
\mathbf{if}\;y \cdot z \leq -20:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \cdot z \leq 10^{-7}:\\
\;\;\;\;x \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 y z) < -20 or 9.9999999999999995e-8 < (*.f64 y z) Initial program 89.6%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6488.2
Applied rewrites88.2%
if -20 < (*.f64 y z) < 9.9999999999999995e-8Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites98.1%
(FPCore (x y z) :precision binary64 (* x 1.0))
double code(double x, double y, double z) {
return x * 1.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 * 1.0d0
end function
public static double code(double x, double y, double z) {
return x * 1.0;
}
def code(x, y, z): return x * 1.0
function code(x, y, z) return Float64(x * 1.0) end
function tmp = code(x, y, z) tmp = x * 1.0; end
code[x_, y_, z_] := N[(x * 1.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 1
\end{array}
Initial program 94.8%
Taylor expanded in y around 0
Applied rewrites50.7%
herbie shell --seed 2024254
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))