?

Average Accuracy: 94.9% → 99.5%
Time: 9.5s
Precision: binary64
Cost: 1352

?

\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
\[\begin{array}{l} t_0 := \left(1 - y\right) \cdot z\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{+306}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;t_0 \leq 4 \cdot 10^{+130}:\\ \;\;\;\;x - t_0 \cdot x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (- 1.0 y) z)))
   (if (<= t_0 -5e+306)
     (* y (* z x))
     (if (<= t_0 4e+130) (- x (* t_0 x)) (* z (* x (+ y -1.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 = (1.0 - y) * z;
	double tmp;
	if (t_0 <= -5e+306) {
		tmp = y * (z * x);
	} else if (t_0 <= 4e+130) {
		tmp = x - (t_0 * x);
	} else {
		tmp = z * (x * (y + -1.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
    code = x * (1.0d0 - ((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) :: t_0
    real(8) :: tmp
    t_0 = (1.0d0 - y) * z
    if (t_0 <= (-5d+306)) then
        tmp = y * (z * x)
    else if (t_0 <= 4d+130) then
        tmp = x - (t_0 * x)
    else
        tmp = z * (x * (y + (-1.0d0)))
    end if
    code = tmp
end function
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 = (1.0 - y) * z;
	double tmp;
	if (t_0 <= -5e+306) {
		tmp = y * (z * x);
	} else if (t_0 <= 4e+130) {
		tmp = x - (t_0 * x);
	} else {
		tmp = z * (x * (y + -1.0));
	}
	return tmp;
}
def code(x, y, z):
	return x * (1.0 - ((1.0 - y) * z))
def code(x, y, z):
	t_0 = (1.0 - y) * z
	tmp = 0
	if t_0 <= -5e+306:
		tmp = y * (z * x)
	elif t_0 <= 4e+130:
		tmp = x - (t_0 * x)
	else:
		tmp = z * (x * (y + -1.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(Float64(1.0 - y) * z)
	tmp = 0.0
	if (t_0 <= -5e+306)
		tmp = Float64(y * Float64(z * x));
	elseif (t_0 <= 4e+130)
		tmp = Float64(x - Float64(t_0 * x));
	else
		tmp = Float64(z * Float64(x * Float64(y + -1.0)));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = x * (1.0 - ((1.0 - y) * z));
end
function tmp_2 = code(x, y, z)
	t_0 = (1.0 - y) * z;
	tmp = 0.0;
	if (t_0 <= -5e+306)
		tmp = y * (z * x);
	elseif (t_0 <= 4e+130)
		tmp = x - (t_0 * x);
	else
		tmp = z * (x * (y + -1.0));
	end
	tmp_2 = 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[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+306], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+130], N[(x - N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
t_0 := \left(1 - y\right) \cdot z\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+306}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\

\mathbf{elif}\;t_0 \leq 4 \cdot 10^{+130}:\\
\;\;\;\;x - t_0 \cdot x\\

\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original94.9%
Target99.7%
Herbie99.5%
\[\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 (-.f64 1 y) z) < -4.99999999999999993e306

    1. Initial program 2.4%

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

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

    if -4.99999999999999993e306 < (*.f64 (-.f64 1 y) z) < 4.0000000000000002e130

    1. Initial program 99.9%

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Applied egg-rr99.9%

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

      [Start]99.9

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

      sub-neg [=>]99.9

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

      +-commutative [=>]99.9

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

      distribute-lft-in [=>]99.9

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

      distribute-lft-neg-in [=>]99.9

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

      *-commutative [=>]99.9

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

      sub-neg [=>]99.9

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

      distribute-neg-in [=>]99.9

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

      +-commutative [=>]99.9

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

      *-un-lft-identity [=>]99.9

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

      distribute-lft-neg-in [=>]99.9

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

      distribute-lft-neg-in [=>]99.9

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

      metadata-eval [=>]99.9

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

      metadata-eval [=>]99.9

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

      *-un-lft-identity [<=]99.9

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

      metadata-eval [=>]99.9

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

      *-commutative [<=]99.9

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

      *-un-lft-identity [<=]99.9

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

    if 4.0000000000000002e130 < (*.f64 (-.f64 1 y) z)

    1. Initial program 83.2%

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

      \[\leadsto \color{blue}{z \cdot \left(\left(y - 1\right) \cdot x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \leq -5 \cdot 10^{+306}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;\left(1 - y\right) \cdot z \leq 4 \cdot 10^{+130}:\\ \;\;\;\;x - \left(\left(1 - y\right) \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy99.5%
Cost1352
\[\begin{array}{l} t_0 := \left(1 - y\right) \cdot z\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{+306}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;t_0 \leq 4 \cdot 10^{+130}:\\ \;\;\;\;x \cdot \left(1 - t_0\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \end{array} \]
Alternative 2
Accuracy99.5%
Cost1352
\[\begin{array}{l} t_0 := \left(1 - y\right) \cdot z\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{+306}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;t_0 \leq 4 \cdot 10^{+130}:\\ \;\;\;\;x \cdot \left(\left(1 + y \cdot z\right) - z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \end{array} \]
Alternative 3
Accuracy81.0%
Cost1113
\[\begin{array}{l} t_0 := z \cdot \left(y \cdot x\right)\\ \mathbf{if}\;y \leq -1.4 \cdot 10^{+150}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4.4 \cdot 10^{+117}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.15 \cdot 10^{+32}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{+107}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{+175} \lor \neg \left(y \leq 2 \cdot 10^{+207}\right):\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Accuracy98.5%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -0.95 \lor \neg \left(z \leq 49000\right):\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot \left(y \cdot z\right)\\ \end{array} \]
Alternative 5
Accuracy69.7%
Cost521
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 49000\right):\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Accuracy48.1%
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023138 
(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))))