
(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 4 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 (* 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}
Initial program 97.3%
Final simplification97.3%
(FPCore (x y z)
:precision binary64
(if (or (<= y -9.2e+48)
(and (not (<= y -56000000.0))
(or (<= y -1.7e-29) (not (<= y 4.4e-104)))))
(* x (* y (- z)))
x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -9.2e+48) || (!(y <= -56000000.0) && ((y <= -1.7e-29) || !(y <= 4.4e-104)))) {
tmp = x * (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 ((y <= (-9.2d+48)) .or. (.not. (y <= (-56000000.0d0))) .and. (y <= (-1.7d-29)) .or. (.not. (y <= 4.4d-104))) then
tmp = x * (y * -z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -9.2e+48) || (!(y <= -56000000.0) && ((y <= -1.7e-29) || !(y <= 4.4e-104)))) {
tmp = x * (y * -z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -9.2e+48) or (not (y <= -56000000.0) and ((y <= -1.7e-29) or not (y <= 4.4e-104))): tmp = x * (y * -z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -9.2e+48) || (!(y <= -56000000.0) && ((y <= -1.7e-29) || !(y <= 4.4e-104)))) tmp = Float64(x * Float64(y * Float64(-z))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -9.2e+48) || (~((y <= -56000000.0)) && ((y <= -1.7e-29) || ~((y <= 4.4e-104))))) tmp = x * (y * -z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -9.2e+48], And[N[Not[LessEqual[y, -56000000.0]], $MachinePrecision], Or[LessEqual[y, -1.7e-29], N[Not[LessEqual[y, 4.4e-104]], $MachinePrecision]]]], N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+48} \lor \neg \left(y \leq -56000000\right) \land \left(y \leq -1.7 \cdot 10^{-29} \lor \neg \left(y \leq 4.4 \cdot 10^{-104}\right)\right):\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -9.2000000000000001e48 or -5.6e7 < y < -1.69999999999999986e-29 or 4.40000000000000023e-104 < y Initial program 96.1%
Taylor expanded in y around inf 69.1%
mul-1-neg69.1%
associate-*r*69.2%
distribute-lft-neg-in69.2%
distribute-rgt-neg-out69.2%
*-commutative69.2%
Simplified69.2%
if -9.2000000000000001e48 < y < -5.6e7 or -1.69999999999999986e-29 < y < 4.40000000000000023e-104Initial program 99.0%
Taylor expanded in y around 0 80.4%
Final simplification73.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (* x (- z)))))
(if (<= y -1.22e+48)
t_0
(if (<= y -235000000.0)
x
(if (<= y -1.06e-29) (* x (* y (- z))) (if (<= y 1.12e-102) x t_0))))))
double code(double x, double y, double z) {
double t_0 = y * (x * -z);
double tmp;
if (y <= -1.22e+48) {
tmp = t_0;
} else if (y <= -235000000.0) {
tmp = x;
} else if (y <= -1.06e-29) {
tmp = x * (y * -z);
} else if (y <= 1.12e-102) {
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 = y * (x * -z)
if (y <= (-1.22d+48)) then
tmp = t_0
else if (y <= (-235000000.0d0)) then
tmp = x
else if (y <= (-1.06d-29)) then
tmp = x * (y * -z)
else if (y <= 1.12d-102) 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 = y * (x * -z);
double tmp;
if (y <= -1.22e+48) {
tmp = t_0;
} else if (y <= -235000000.0) {
tmp = x;
} else if (y <= -1.06e-29) {
tmp = x * (y * -z);
} else if (y <= 1.12e-102) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x * -z) tmp = 0 if y <= -1.22e+48: tmp = t_0 elif y <= -235000000.0: tmp = x elif y <= -1.06e-29: tmp = x * (y * -z) elif y <= 1.12e-102: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x * Float64(-z))) tmp = 0.0 if (y <= -1.22e+48) tmp = t_0; elseif (y <= -235000000.0) tmp = x; elseif (y <= -1.06e-29) tmp = Float64(x * Float64(y * Float64(-z))); elseif (y <= 1.12e-102) tmp = x; 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 <= -1.22e+48) tmp = t_0; elseif (y <= -235000000.0) tmp = x; elseif (y <= -1.06e-29) tmp = x * (y * -z); elseif (y <= 1.12e-102) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.22e+48], t$95$0, If[LessEqual[y, -235000000.0], x, If[LessEqual[y, -1.06e-29], N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.12e-102], x, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(x \cdot \left(-z\right)\right)\\
\mathbf{if}\;y \leq -1.22 \cdot 10^{+48}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -235000000:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -1.06 \cdot 10^{-29}:\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{elif}\;y \leq 1.12 \cdot 10^{-102}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.22000000000000004e48 or 1.12000000000000009e-102 < y Initial program 95.9%
Taylor expanded in y around inf 67.6%
mul-1-neg67.6%
distribute-rgt-neg-in67.6%
distribute-lft-neg-out67.6%
*-commutative67.6%
Simplified67.6%
if -1.22000000000000004e48 < y < -2.35e8 or -1.05999999999999995e-29 < y < 1.12000000000000009e-102Initial program 99.0%
Taylor expanded in y around 0 80.4%
if -2.35e8 < y < -1.05999999999999995e-29Initial program 100.0%
Taylor expanded in y around inf 99.8%
mul-1-neg99.8%
associate-*r*100.0%
distribute-lft-neg-in100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
Simplified100.0%
Final simplification73.7%
(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 97.3%
Taylor expanded in y around 0 50.5%
Final simplification50.5%
herbie shell --seed 2023199
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))