| Alternative 1 | |
|---|---|
| Error | 2.98% |
| Cost | 708 |
\[\begin{array}{l}
\mathbf{if}\;y \cdot z \leq 5 \cdot 10^{+180}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z) :precision binary64 (if (or (<= x -9.8e+48) (not (<= x 3.5e+23))) (* x (- 1.0 (* y z))) (- x (* y (* x z)))))
double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.8e+48) || !(x <= 3.5e+23)) {
tmp = x * (1.0 - (y * z));
} else {
tmp = x - (y * (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
code = x * (1.0d0 - (y * z))
end function
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 ((x <= (-9.8d+48)) .or. (.not. (x <= 3.5d+23))) then
tmp = x * (1.0d0 - (y * z))
else
tmp = x - (y * (x * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -9.8e+48) || !(x <= 3.5e+23)) {
tmp = x * (1.0 - (y * z));
} else {
tmp = x - (y * (x * z));
}
return tmp;
}
def code(x, y, z): return x * (1.0 - (y * z))
def code(x, y, z): tmp = 0 if (x <= -9.8e+48) or not (x <= 3.5e+23): tmp = x * (1.0 - (y * z)) else: tmp = x - (y * (x * z)) return tmp
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
function code(x, y, z) tmp = 0.0 if ((x <= -9.8e+48) || !(x <= 3.5e+23)) tmp = Float64(x * Float64(1.0 - Float64(y * z))); else tmp = Float64(x - Float64(y * Float64(x * z))); end return tmp end
function tmp = code(x, y, z) tmp = x * (1.0 - (y * z)); end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -9.8e+48) || ~((x <= 3.5e+23))) tmp = x * (1.0 - (y * z)); else tmp = x - (y * (x * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := If[Or[LessEqual[x, -9.8e+48], N[Not[LessEqual[x, 3.5e+23]], $MachinePrecision]], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \leq -9.8 \cdot 10^{+48} \lor \neg \left(x \leq 3.5 \cdot 10^{+23}\right):\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \left(x \cdot z\right)\\
\end{array}
Results
if x < -9.80000000000000059e48 or 3.5000000000000002e23 < x Initial program 0.13
if -9.80000000000000059e48 < x < 3.5000000000000002e23Initial program 8.26
Taylor expanded in x around 0 8.26
Simplified4.15
[Start]8.26 | \[ \left(1 - y \cdot z\right) \cdot x
\] |
|---|---|
*-commutative [=>]8.26 | \[ \color{blue}{x \cdot \left(1 - y \cdot z\right)}
\] |
distribute-rgt-out-- [<=]8.25 | \[ \color{blue}{1 \cdot x - \left(y \cdot z\right) \cdot x}
\] |
*-lft-identity [=>]8.25 | \[ \color{blue}{x} - \left(y \cdot z\right) \cdot x
\] |
associate-*r* [<=]4.15 | \[ x - \color{blue}{y \cdot \left(z \cdot x\right)}
\] |
Final simplification2.75
| Alternative 1 | |
|---|---|
| Error | 2.98% |
| Cost | 708 |
| Alternative 2 | |
|---|---|
| Error | 28.49% |
| Cost | 649 |
| Alternative 3 | |
|---|---|
| Error | 27.38% |
| Cost | 648 |
| Alternative 4 | |
|---|---|
| Error | 27.23% |
| Cost | 648 |
| Alternative 5 | |
|---|---|
| Error | 39.78% |
| Cost | 64 |
herbie shell --seed 2023088
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))