| Alternative 1 | |
|---|---|
| Accuracy | 98.4% |
| Cost | 968 |
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z) :precision binary64 (if (<= (* y z) -4e+250) (/ (* z x) (/ -1.0 y)) (if (<= (* y z) 1e+50) (* x (- 1.0 (* y z))) (* z (* x (- y))))))
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 ((y * z) <= -4e+250) {
tmp = (z * x) / (-1.0 / y);
} else if ((y * z) <= 1e+50) {
tmp = x * (1.0 - (y * z));
} else {
tmp = z * (x * -y);
}
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 ((y * z) <= (-4d+250)) then
tmp = (z * x) / ((-1.0d0) / y)
else if ((y * z) <= 1d+50) then
tmp = x * (1.0d0 - (y * z))
else
tmp = z * (x * -y)
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 ((y * z) <= -4e+250) {
tmp = (z * x) / (-1.0 / y);
} else if ((y * z) <= 1e+50) {
tmp = x * (1.0 - (y * z));
} else {
tmp = z * (x * -y);
}
return tmp;
}
def code(x, y, z): return x * (1.0 - (y * z))
def code(x, y, z): tmp = 0 if (y * z) <= -4e+250: tmp = (z * x) / (-1.0 / y) elif (y * z) <= 1e+50: tmp = x * (1.0 - (y * z)) else: tmp = z * (x * -y) 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 (Float64(y * z) <= -4e+250) tmp = Float64(Float64(z * x) / Float64(-1.0 / y)); elseif (Float64(y * z) <= 1e+50) tmp = Float64(x * Float64(1.0 - Float64(y * z))); else tmp = Float64(z * Float64(x * Float64(-y))); 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 ((y * z) <= -4e+250) tmp = (z * x) / (-1.0 / y); elseif ((y * z) <= 1e+50) tmp = x * (1.0 - (y * z)); else tmp = z * (x * -y); 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[LessEqual[N[(y * z), $MachinePrecision], -4e+250], N[(N[(z * x), $MachinePrecision] / N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 1e+50], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * (-y)), $MachinePrecision]), $MachinePrecision]]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -4 \cdot 10^{+250}:\\
\;\;\;\;\frac{z \cdot x}{\frac{-1}{y}}\\
\mathbf{elif}\;y \cdot z \leq 10^{+50}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(-y\right)\right)\\
\end{array}
Results
if (*.f64 y z) < -3.9999999999999997e250Initial program 39.2%
Applied egg-rr0.0%
[Start]39.2 | \[ x \cdot \left(1 - y \cdot z\right)
\] |
|---|---|
flip3-- [=>]0.0 | \[ x \cdot \color{blue}{\frac{{1}^{3} - {\left(y \cdot z\right)}^{3}}{1 \cdot 1 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) + 1 \cdot \left(y \cdot z\right)\right)}}
\] |
associate-*r/ [=>]0.0 | \[ \color{blue}{\frac{x \cdot \left({1}^{3} - {\left(y \cdot z\right)}^{3}\right)}{1 \cdot 1 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) + 1 \cdot \left(y \cdot z\right)\right)}}
\] |
metadata-eval [=>]0.0 | \[ \frac{x \cdot \left(\color{blue}{1} - {\left(y \cdot z\right)}^{3}\right)}{1 \cdot 1 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) + 1 \cdot \left(y \cdot z\right)\right)}
\] |
metadata-eval [=>]0.0 | \[ \frac{x \cdot \left(1 - {\left(y \cdot z\right)}^{3}\right)}{\color{blue}{1} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) + 1 \cdot \left(y \cdot z\right)\right)}
\] |
distribute-rgt-out [=>]0.0 | \[ \frac{x \cdot \left(1 - {\left(y \cdot z\right)}^{3}\right)}{1 + \color{blue}{\left(y \cdot z\right) \cdot \left(y \cdot z + 1\right)}}
\] |
+-commutative [<=]0.0 | \[ \frac{x \cdot \left(1 - {\left(y \cdot z\right)}^{3}\right)}{1 + \left(y \cdot z\right) \cdot \color{blue}{\left(1 + y \cdot z\right)}}
\] |
Simplified0.0%
[Start]0.0 | \[ \frac{x \cdot \left(1 - {\left(y \cdot z\right)}^{3}\right)}{1 + \left(y \cdot z\right) \cdot \left(1 + y \cdot z\right)}
\] |
|---|---|
associate-/l* [=>]0.0 | \[ \color{blue}{\frac{x}{\frac{1 + \left(y \cdot z\right) \cdot \left(1 + y \cdot z\right)}{1 - {\left(y \cdot z\right)}^{3}}}}
\] |
Taylor expanded in y around inf 39.2%
Simplified44.3%
[Start]39.2 | \[ \frac{x}{\frac{-1}{y \cdot z}}
\] |
|---|---|
associate-/r* [=>]44.3 | \[ \frac{x}{\color{blue}{\frac{\frac{-1}{y}}{z}}}
\] |
Applied egg-rr99.4%
[Start]44.3 | \[ \frac{x}{\frac{\frac{-1}{y}}{z}}
\] |
|---|---|
frac-2neg [=>]44.3 | \[ \frac{x}{\color{blue}{\frac{-\frac{-1}{y}}{-z}}}
\] |
associate-/r/ [=>]99.4 | \[ \color{blue}{\frac{x}{-\frac{-1}{y}} \cdot \left(-z\right)}
\] |
distribute-neg-frac [=>]99.4 | \[ \frac{x}{\color{blue}{\frac{--1}{y}}} \cdot \left(-z\right)
\] |
metadata-eval [=>]99.4 | \[ \frac{x}{\frac{\color{blue}{1}}{y}} \cdot \left(-z\right)
\] |
Applied egg-rr98.7%
[Start]99.4 | \[ \frac{x}{\frac{1}{y}} \cdot \left(-z\right)
\] |
|---|---|
associate-*l/ [=>]98.7 | \[ \color{blue}{\frac{x \cdot \left(-z\right)}{\frac{1}{y}}}
\] |
frac-2neg [=>]98.7 | \[ \color{blue}{\frac{-x \cdot \left(-z\right)}{-\frac{1}{y}}}
\] |
add-sqr-sqrt [=>]0.0 | \[ \frac{-x \cdot \color{blue}{\left(\sqrt{-z} \cdot \sqrt{-z}\right)}}{-\frac{1}{y}}
\] |
sqrt-unprod [=>]0.3 | \[ \frac{-x \cdot \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}}{-\frac{1}{y}}
\] |
sqr-neg [=>]0.3 | \[ \frac{-x \cdot \sqrt{\color{blue}{z \cdot z}}}{-\frac{1}{y}}
\] |
sqrt-unprod [<=]0.6 | \[ \frac{-x \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}}{-\frac{1}{y}}
\] |
add-sqr-sqrt [<=]0.6 | \[ \frac{-x \cdot \color{blue}{z}}{-\frac{1}{y}}
\] |
distribute-rgt-neg-out [<=]0.6 | \[ \frac{\color{blue}{x \cdot \left(-z\right)}}{-\frac{1}{y}}
\] |
add-sqr-sqrt [=>]0.0 | \[ \frac{x \cdot \color{blue}{\left(\sqrt{-z} \cdot \sqrt{-z}\right)}}{-\frac{1}{y}}
\] |
sqrt-unprod [=>]40.0 | \[ \frac{x \cdot \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}}{-\frac{1}{y}}
\] |
sqr-neg [=>]40.0 | \[ \frac{x \cdot \sqrt{\color{blue}{z \cdot z}}}{-\frac{1}{y}}
\] |
sqrt-unprod [<=]98.3 | \[ \frac{x \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}}{-\frac{1}{y}}
\] |
add-sqr-sqrt [<=]98.7 | \[ \frac{x \cdot \color{blue}{z}}{-\frac{1}{y}}
\] |
distribute-neg-frac [=>]98.7 | \[ \frac{x \cdot z}{\color{blue}{\frac{-1}{y}}}
\] |
metadata-eval [=>]98.7 | \[ \frac{x \cdot z}{\frac{\color{blue}{-1}}{y}}
\] |
if -3.9999999999999997e250 < (*.f64 y z) < 1.0000000000000001e50Initial program 99.9%
if 1.0000000000000001e50 < (*.f64 y z) Initial program 82.9%
Taylor expanded in y around inf 91.2%
Simplified82.9%
[Start]91.2 | \[ -1 \cdot \left(y \cdot \left(z \cdot x\right)\right)
\] |
|---|---|
mul-1-neg [=>]91.2 | \[ \color{blue}{-y \cdot \left(z \cdot x\right)}
\] |
associate-*r* [=>]82.9 | \[ -\color{blue}{\left(y \cdot z\right) \cdot x}
\] |
distribute-lft-neg-in [=>]82.9 | \[ \color{blue}{\left(-y \cdot z\right) \cdot x}
\] |
distribute-rgt-neg-out [<=]82.9 | \[ \color{blue}{\left(y \cdot \left(-z\right)\right)} \cdot x
\] |
*-commutative [<=]82.9 | \[ \color{blue}{x \cdot \left(y \cdot \left(-z\right)\right)}
\] |
Taylor expanded in x around 0 91.2%
Simplified90.5%
[Start]91.2 | \[ -1 \cdot \left(y \cdot \left(z \cdot x\right)\right)
\] |
|---|---|
mul-1-neg [=>]91.2 | \[ \color{blue}{-y \cdot \left(z \cdot x\right)}
\] |
*-commutative [=>]91.2 | \[ -\color{blue}{\left(z \cdot x\right) \cdot y}
\] |
associate-*l* [=>]90.5 | \[ -\color{blue}{z \cdot \left(x \cdot y\right)}
\] |
distribute-rgt-neg-in [=>]90.5 | \[ \color{blue}{z \cdot \left(-x \cdot y\right)}
\] |
*-commutative [=>]90.5 | \[ z \cdot \left(-\color{blue}{y \cdot x}\right)
\] |
Final simplification98.3%
| Alternative 1 | |
|---|---|
| Accuracy | 98.4% |
| Cost | 968 |
| Alternative 2 | |
|---|---|
| Accuracy | 70.7% |
| Cost | 914 |
| Alternative 3 | |
|---|---|
| Accuracy | 72.3% |
| Cost | 912 |
| Alternative 4 | |
|---|---|
| Accuracy | 72.4% |
| Cost | 648 |
| Alternative 5 | |
|---|---|
| Accuracy | 60.5% |
| Cost | 64 |
herbie shell --seed 2023147
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))