?

Average Accuracy: 74.9% → 79.1%
Time: 10.2s
Precision: binary64
Cost: 27336

?

\[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} \]
(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}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original74.9%
Target79.1%
Herbie79.1%
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) < -1.618195973607049 \cdot 10^{+50}:\\ \;\;\;\;x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\ \mathbf{elif}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) < 3.892237649663903 \cdot 10^{+134}:\\ \;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < -inf.0

    1. Initial program 0.0%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Simplified16.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y + -1, x \cdot z, x\right)} \]
      Proof

      [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) \]
    3. Applied egg-rr16.6%

      \[\leadsto \color{blue}{\left(y + -1\right) \cdot \left(x \cdot z\right) + x} \]
      Proof

      [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} \]
    4. Applied egg-rr0.0%

      \[\leadsto \color{blue}{\frac{\left(x \cdot z\right) \cdot \mathsf{fma}\left(y, y, -1\right)}{y + 1}} + x \]
      Proof

      [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 \]
    5. Simplified16.6%

      \[\leadsto \color{blue}{\frac{z \cdot x}{\frac{1}{-1 + y}}} + x \]
      Proof

      [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 \]
    6. Taylor expanded in y around inf 16.6%

      \[\leadsto \frac{z \cdot x}{\color{blue}{\frac{1}{y}}} + x \]
    7. Applied egg-rr17.4%

      \[\leadsto \color{blue}{\frac{z}{1} \cdot \frac{x}{\frac{1}{y}}} + x \]
      Proof

      [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.00000000000000026e300

    1. Initial program 99.9%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]

    if 5.00000000000000026e300 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z)))

    1. Initial program 0.0%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Taylor expanded in y around inf 21.8%

      \[\leadsto \color{blue}{y \cdot \left(z \cdot x\right)} \]
    3. Simplified22.3%

      \[\leadsto \color{blue}{z \cdot \left(y \cdot x\right)} \]
      Proof

      [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)} \]
    4. Applied egg-rr21.7%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{z \cdot \left(y \cdot x\right)}\right)}^{3}} \]
      Proof

      [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}} \]
    5. Applied egg-rr22.8%

      \[\leadsto {\color{blue}{\left(\sqrt{{\left(\sqrt[3]{z \cdot \left(y \cdot x\right)}\right)}^{2}}\right)}}^{3} \]
      Proof

      [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} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification80.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right) \leq -\infty:\\ \;\;\;\;x + z \cdot \frac{x}{\frac{1}{y}}\\ \mathbf{elif}\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right) \leq 5 \cdot 10^{+300}:\\ \;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt{{\left(\sqrt[3]{z \cdot \left(x \cdot y\right)}\right)}^{2}}\right)}^{3}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy79.0%
Cost1865
\[\begin{array}{l} t_0 := x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 10^{+296}\right):\\ \;\;\;\;x + z \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Accuracy79.0%
Cost1864
\[\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 10^{+296}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 3
Accuracy67.1%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -6.4 \cdot 10^{-36} \lor \neg \left(z \leq 6 \cdot 10^{-51}\right):\\ \;\;\;\;\left(x \cdot z\right) \cdot \left(y + -1\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Accuracy77.9%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1.05 \lor \neg \left(z \leq 1.4 \cdot 10^{-13}\right):\\ \;\;\;\;\left(x \cdot z\right) \cdot \left(y + -1\right)\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot \left(y \cdot z\right)\\ \end{array} \]
Alternative 5
Accuracy49.2%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -6 \cdot 10^{-36} \lor \neg \left(z \leq 6 \cdot 10^{-51}\right):\\ \;\;\;\;y \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Accuracy49.3%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -6.4 \cdot 10^{-36} \lor \neg \left(z \leq 6 \cdot 10^{-51}\right):\\ \;\;\;\;z \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Accuracy64.6%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{+113} \lor \neg \left(y \leq 10^{+39}\right):\\ \;\;\;\;z \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot z\\ \end{array} \]
Alternative 8
Accuracy38.4%
Cost64
\[x \]

Error

Reproduce?

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))))