| Alternative 1 | |
|---|---|
| Accuracy | 79.0% |
| Cost | 1865 |
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (+ 1.0 (* z (+ y -1.0))))))
(if (<= t_0 (- INFINITY))
(+ x (* z (/ x (/ 1.0 y))))
(if (<= t_0 5e+300)
t_0
(pow (sqrt (pow (cbrt (* z (* x y))) 2.0)) 3.0)))))double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
double code(double x, double y, double z) {
double t_0 = x * (1.0 + (z * (y + -1.0)));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = x + (z * (x / (1.0 / y)));
} else if (t_0 <= 5e+300) {
tmp = t_0;
} else {
tmp = pow(sqrt(pow(cbrt((z * (x * y))), 2.0)), 3.0);
}
return tmp;
}
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 + (z * (y + -1.0)));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = x + (z * (x / (1.0 / y)));
} else if (t_0 <= 5e+300) {
tmp = t_0;
} else {
tmp = Math.pow(Math.sqrt(Math.pow(Math.cbrt((z * (x * y))), 2.0)), 3.0);
}
return tmp;
}
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function code(x, y, z) t_0 = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(x + Float64(z * Float64(x / Float64(1.0 / y)))); elseif (t_0 <= 5e+300) tmp = t_0; else tmp = sqrt((cbrt(Float64(z * Float64(x * y))) ^ 2.0)) ^ 3.0; end return tmp end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(x + N[(z * N[(x / N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+300], t$95$0, N[Power[N[Sqrt[N[Power[N[Power[N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision]]]]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
t_0 := x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;x + z \cdot \frac{x}{\frac{1}{y}}\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+300}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{{\left(\sqrt[3]{z \cdot \left(x \cdot y\right)}\right)}^{2}}\right)}^{3}\\
\end{array}
Results
| Original | 74.9% |
|---|---|
| Target | 79.1% |
| Herbie | 79.1% |
if (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < -inf.0Initial program 0.0%
Simplified16.6%
[Start]0.0 | \[ x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\] |
|---|---|
distribute-rgt-out-- [<=]0.0 | \[ \color{blue}{1 \cdot x - \left(\left(1 - y\right) \cdot z\right) \cdot x}
\] |
*-lft-identity [=>]0.0 | \[ \color{blue}{x} - \left(\left(1 - y\right) \cdot z\right) \cdot x
\] |
cancel-sign-sub-inv [=>]0.0 | \[ \color{blue}{x + \left(-\left(1 - y\right) \cdot z\right) \cdot x}
\] |
+-commutative [=>]0.0 | \[ \color{blue}{\left(-\left(1 - y\right) \cdot z\right) \cdot x + x}
\] |
distribute-lft-neg-in [=>]0.0 | \[ \color{blue}{\left(\left(-\left(1 - y\right)\right) \cdot z\right)} \cdot x + x
\] |
associate-*l* [=>]16.6 | \[ \color{blue}{\left(-\left(1 - y\right)\right) \cdot \left(z \cdot x\right)} + x
\] |
fma-def [=>]16.6 | \[ \color{blue}{\mathsf{fma}\left(-\left(1 - y\right), z \cdot x, x\right)}
\] |
neg-sub0 [=>]16.6 | \[ \mathsf{fma}\left(\color{blue}{0 - \left(1 - y\right)}, z \cdot x, x\right)
\] |
associate--r- [=>]16.6 | \[ \mathsf{fma}\left(\color{blue}{\left(0 - 1\right) + y}, z \cdot x, x\right)
\] |
metadata-eval [=>]16.6 | \[ \mathsf{fma}\left(\color{blue}{-1} + y, z \cdot x, x\right)
\] |
+-commutative [=>]16.6 | \[ \mathsf{fma}\left(\color{blue}{y + -1}, z \cdot x, x\right)
\] |
*-commutative [<=]16.6 | \[ \mathsf{fma}\left(y + -1, \color{blue}{x \cdot z}, x\right)
\] |
Applied egg-rr16.6%
[Start]16.6 | \[ \mathsf{fma}\left(y + -1, x \cdot z, x\right)
\] |
|---|---|
fma-udef [=>]16.6 | \[ \color{blue}{\left(y + -1\right) \cdot \left(x \cdot z\right) + x}
\] |
Applied egg-rr0.0%
[Start]16.6 | \[ \left(y + -1\right) \cdot \left(x \cdot z\right) + x
\] |
|---|---|
*-commutative [=>]16.6 | \[ \color{blue}{\left(x \cdot z\right) \cdot \left(y + -1\right)} + x
\] |
flip-+ [=>]6.6 | \[ \left(x \cdot z\right) \cdot \color{blue}{\frac{y \cdot y - -1 \cdot -1}{y - -1}} + x
\] |
associate-*r/ [=>]0.0 | \[ \color{blue}{\frac{\left(x \cdot z\right) \cdot \left(y \cdot y - -1 \cdot -1\right)}{y - -1}} + x
\] |
metadata-eval [=>]0.0 | \[ \frac{\left(x \cdot z\right) \cdot \left(y \cdot y - \color{blue}{1}\right)}{y - -1} + x
\] |
fma-neg [=>]0.0 | \[ \frac{\left(x \cdot z\right) \cdot \color{blue}{\mathsf{fma}\left(y, y, -1\right)}}{y - -1} + x
\] |
metadata-eval [=>]0.0 | \[ \frac{\left(x \cdot z\right) \cdot \mathsf{fma}\left(y, y, \color{blue}{-1}\right)}{y - -1} + x
\] |
sub-neg [=>]0.0 | \[ \frac{\left(x \cdot z\right) \cdot \mathsf{fma}\left(y, y, -1\right)}{\color{blue}{y + \left(--1\right)}} + x
\] |
metadata-eval [=>]0.0 | \[ \frac{\left(x \cdot z\right) \cdot \mathsf{fma}\left(y, y, -1\right)}{y + \color{blue}{1}} + x
\] |
Simplified16.6%
[Start]0.0 | \[ \frac{\left(x \cdot z\right) \cdot \mathsf{fma}\left(y, y, -1\right)}{y + 1} + x
\] |
|---|---|
associate-/l* [=>]6.6 | \[ \color{blue}{\frac{x \cdot z}{\frac{y + 1}{\mathsf{fma}\left(y, y, -1\right)}}} + x
\] |
*-commutative [=>]6.6 | \[ \frac{\color{blue}{z \cdot x}}{\frac{y + 1}{\mathsf{fma}\left(y, y, -1\right)}} + x
\] |
fma-udef [=>]6.6 | \[ \frac{z \cdot x}{\frac{y + 1}{\color{blue}{y \cdot y + -1}}} + x
\] |
difference-of-sqr--1 [=>]6.6 | \[ \frac{z \cdot x}{\frac{y + 1}{\color{blue}{\left(y + 1\right) \cdot \left(y - 1\right)}}} + x
\] |
sub-neg [=>]6.6 | \[ \frac{z \cdot x}{\frac{y + 1}{\left(y + 1\right) \cdot \color{blue}{\left(y + \left(-1\right)\right)}}} + x
\] |
metadata-eval [=>]6.6 | \[ \frac{z \cdot x}{\frac{y + 1}{\left(y + 1\right) \cdot \left(y + \color{blue}{-1}\right)}} + x
\] |
associate-/r* [=>]16.6 | \[ \frac{z \cdot x}{\color{blue}{\frac{\frac{y + 1}{y + 1}}{y + -1}}} + x
\] |
*-inverses [=>]16.6 | \[ \frac{z \cdot x}{\frac{\color{blue}{1}}{y + -1}} + x
\] |
+-commutative [=>]16.6 | \[ \frac{z \cdot x}{\frac{1}{\color{blue}{-1 + y}}} + x
\] |
Taylor expanded in y around inf 16.6%
Applied egg-rr17.4%
[Start]16.6 | \[ \frac{z \cdot x}{\frac{1}{y}} + x
\] |
|---|---|
*-un-lft-identity [=>]16.6 | \[ \frac{z \cdot x}{\color{blue}{1 \cdot \frac{1}{y}}} + x
\] |
times-frac [=>]17.4 | \[ \color{blue}{\frac{z}{1} \cdot \frac{x}{\frac{1}{y}}} + x
\] |
if -inf.0 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < 5.00000000000000026e300Initial program 99.9%
if 5.00000000000000026e300 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) Initial program 0.0%
Taylor expanded in y around inf 21.8%
Simplified22.3%
[Start]21.8 | \[ y \cdot \left(z \cdot x\right)
\] |
|---|---|
associate-*r* [=>]0.4 | \[ \color{blue}{\left(y \cdot z\right) \cdot x}
\] |
*-commutative [=>]0.4 | \[ \color{blue}{\left(z \cdot y\right)} \cdot x
\] |
associate-*l* [=>]22.3 | \[ \color{blue}{z \cdot \left(y \cdot x\right)}
\] |
Applied egg-rr21.7%
[Start]22.3 | \[ z \cdot \left(y \cdot x\right)
\] |
|---|---|
add-cube-cbrt [=>]21.7 | \[ \color{blue}{\left(\sqrt[3]{z \cdot \left(y \cdot x\right)} \cdot \sqrt[3]{z \cdot \left(y \cdot x\right)}\right) \cdot \sqrt[3]{z \cdot \left(y \cdot x\right)}}
\] |
pow3 [=>]21.7 | \[ \color{blue}{{\left(\sqrt[3]{z \cdot \left(y \cdot x\right)}\right)}^{3}}
\] |
Applied egg-rr22.8%
[Start]21.7 | \[ {\left(\sqrt[3]{z \cdot \left(y \cdot x\right)}\right)}^{3}
\] |
|---|---|
add-sqr-sqrt [=>]21.5 | \[ {\color{blue}{\left(\sqrt{\sqrt[3]{z \cdot \left(y \cdot x\right)}} \cdot \sqrt{\sqrt[3]{z \cdot \left(y \cdot x\right)}}\right)}}^{3}
\] |
sqrt-unprod [=>]22.8 | \[ {\color{blue}{\left(\sqrt{\sqrt[3]{z \cdot \left(y \cdot x\right)} \cdot \sqrt[3]{z \cdot \left(y \cdot x\right)}}\right)}}^{3}
\] |
pow2 [=>]22.8 | \[ {\left(\sqrt{\color{blue}{{\left(\sqrt[3]{z \cdot \left(y \cdot x\right)}\right)}^{2}}}\right)}^{3}
\] |
Final simplification80.6%
| Alternative 1 | |
|---|---|
| Accuracy | 79.0% |
| Cost | 1865 |
| Alternative 2 | |
|---|---|
| Accuracy | 79.0% |
| Cost | 1864 |
| Alternative 3 | |
|---|---|
| Accuracy | 67.1% |
| Cost | 713 |
| Alternative 4 | |
|---|---|
| Accuracy | 77.9% |
| Cost | 713 |
| Alternative 5 | |
|---|---|
| Accuracy | 49.2% |
| Cost | 585 |
| Alternative 6 | |
|---|---|
| Accuracy | 49.3% |
| Cost | 585 |
| Alternative 7 | |
|---|---|
| Accuracy | 64.6% |
| Cost | 585 |
| Alternative 8 | |
|---|---|
| Accuracy | 38.4% |
| Cost | 64 |
herbie shell --seed 2023157
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:herbie-target
(if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))
(* x (- 1.0 (* (- 1.0 y) z))))