?

Average Accuracy: 95.0% → 99.5%
Time: 8.6s
Precision: binary64
Cost: 1353

?

\[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 -2 \cdot 10^{+150} \lor \neg \left(t_0 \leq 5 \cdot 10^{+165}\right):\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - t_0\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 (or (<= t_0 -2e+150) (not (<= t_0 5e+165)))
     (* z (* x (+ y -1.0)))
     (* x (- 1.0 t_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 <= -2e+150) || !(t_0 <= 5e+165)) {
		tmp = z * (x * (y + -1.0));
	} else {
		tmp = x * (1.0 - t_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 <= (-2d+150)) .or. (.not. (t_0 <= 5d+165))) then
        tmp = z * (x * (y + (-1.0d0)))
    else
        tmp = x * (1.0d0 - t_0)
    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 <= -2e+150) || !(t_0 <= 5e+165)) {
		tmp = z * (x * (y + -1.0));
	} else {
		tmp = x * (1.0 - t_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 <= -2e+150) or not (t_0 <= 5e+165):
		tmp = z * (x * (y + -1.0))
	else:
		tmp = x * (1.0 - t_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 <= -2e+150) || !(t_0 <= 5e+165))
		tmp = Float64(z * Float64(x * Float64(y + -1.0)));
	else
		tmp = Float64(x * Float64(1.0 - t_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 <= -2e+150) || ~((t_0 <= 5e+165)))
		tmp = z * (x * (y + -1.0));
	else
		tmp = x * (1.0 - t_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[Or[LessEqual[t$95$0, -2e+150], N[Not[LessEqual[t$95$0, 5e+165]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - t$95$0), $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 -2 \cdot 10^{+150} \lor \neg \left(t_0 \leq 5 \cdot 10^{+165}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - t_0\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original95.0%
Target99.6%
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 2 regimes
  2. if (*.f64 (-.f64 1 y) z) < -1.99999999999999996e150 or 4.9999999999999997e165 < (*.f64 (-.f64 1 y) z)

    1. Initial program 79.9%

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

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

    if -1.99999999999999996e150 < (*.f64 (-.f64 1 y) z) < 4.9999999999999997e165

    1. Initial program 99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \leq -2 \cdot 10^{+150} \lor \neg \left(\left(1 - y\right) \cdot z \leq 5 \cdot 10^{+165}\right):\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy79.6%
Cost848
\[\begin{array}{l} t_0 := x \cdot \left(1 - z\right)\\ \mathbf{if}\;y \leq -1.15 \cdot 10^{+233}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;y \leq -2.8 \cdot 10^{+119}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6.6 \cdot 10^{+39}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;y \leq 780000000000:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot x\right)\\ \end{array} \]
Alternative 2
Accuracy86.3%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1.3 \cdot 10^{-10} \lor \neg \left(z \leq 255000\right):\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \end{array} \]
Alternative 3
Accuracy86.3%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{-10}:\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{elif}\;z \leq 14000000:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot x - x\right)\\ \end{array} \]
Alternative 4
Accuracy98.4%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x \cdot \left(1 + y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot x - x\right)\\ \end{array} \]
Alternative 5
Accuracy70.2%
Cost521
\[\begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{-10} \lor \neg \left(z \leq 1\right):\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Accuracy47.7%
Cost64
\[x \]

Error

Reproduce?

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