?

Average Error: 5.37% → 1.06%
Time: 7.5s
Precision: binary64
Cost: 840

?

\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
\[\begin{array}{l} \mathbf{if}\;x \leq -7.5 \cdot 10^{+87}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{\frac{1}{1 - y}}\right)\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-134}:\\ \;\;\;\;x + z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 + z \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
 (if (<= x -7.5e+87)
   (* x (- 1.0 (/ z (/ 1.0 (- 1.0 y)))))
   (if (<= x 2.2e-134)
     (+ x (* z (* x (+ y -1.0))))
     (* x (+ 1.0 (* z (+ 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 tmp;
	if (x <= -7.5e+87) {
		tmp = x * (1.0 - (z / (1.0 / (1.0 - y))));
	} else if (x <= 2.2e-134) {
		tmp = x + (z * (x * (y + -1.0)));
	} else {
		tmp = x * (1.0 + (z * (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) :: tmp
    if (x <= (-7.5d+87)) then
        tmp = x * (1.0d0 - (z / (1.0d0 / (1.0d0 - y))))
    else if (x <= 2.2d-134) then
        tmp = x + (z * (x * (y + (-1.0d0))))
    else
        tmp = x * (1.0d0 + (z * (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 tmp;
	if (x <= -7.5e+87) {
		tmp = x * (1.0 - (z / (1.0 / (1.0 - y))));
	} else if (x <= 2.2e-134) {
		tmp = x + (z * (x * (y + -1.0)));
	} else {
		tmp = x * (1.0 + (z * (y + -1.0)));
	}
	return tmp;
}
def code(x, y, z):
	return x * (1.0 - ((1.0 - y) * z))
def code(x, y, z):
	tmp = 0
	if x <= -7.5e+87:
		tmp = x * (1.0 - (z / (1.0 / (1.0 - y))))
	elif x <= 2.2e-134:
		tmp = x + (z * (x * (y + -1.0)))
	else:
		tmp = x * (1.0 + (z * (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)
	tmp = 0.0
	if (x <= -7.5e+87)
		tmp = Float64(x * Float64(1.0 - Float64(z / Float64(1.0 / Float64(1.0 - y)))));
	elseif (x <= 2.2e-134)
		tmp = Float64(x + Float64(z * Float64(x * Float64(y + -1.0))));
	else
		tmp = Float64(x * Float64(1.0 + Float64(z * 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)
	tmp = 0.0;
	if (x <= -7.5e+87)
		tmp = x * (1.0 - (z / (1.0 / (1.0 - y))));
	elseif (x <= 2.2e-134)
		tmp = x + (z * (x * (y + -1.0)));
	else
		tmp = x * (1.0 + (z * (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_] := If[LessEqual[x, -7.5e+87], N[(x * N[(1.0 - N[(z / N[(1.0 / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.2e-134], N[(x + N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{+87}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{\frac{1}{1 - y}}\right)\\

\mathbf{elif}\;x \leq 2.2 \cdot 10^{-134}:\\
\;\;\;\;x + z \cdot \left(x \cdot \left(y + -1\right)\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original5.37%
Target0.35%
Herbie1.06%
\[\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 x < -7.50000000000000014e87

    1. Initial program 0.1

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Applied egg-rr0.14

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

    if -7.50000000000000014e87 < x < 2.2e-134

    1. Initial program 8.47

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
    2. Taylor expanded in z around 0 0.61

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

    if 2.2e-134 < x

    1. Initial program 2.16

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.06

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.5 \cdot 10^{+87}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{\frac{1}{1 - y}}\right)\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-134}:\\ \;\;\;\;x + z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\ \end{array} \]

Alternatives

Alternative 1
Error2.74%
Cost1220
\[\begin{array}{l} t_0 := x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;y \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error21.06%
Cost848
\[\begin{array}{l} t_0 := y \cdot \left(x \cdot z\right)\\ \mathbf{if}\;y \leq -4.8 \cdot 10^{+195}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -8.6 \cdot 10^{+128}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -5.6 \cdot 10^{+71}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.05 \cdot 10^{+151}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 3
Error1.05%
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{+86} \lor \neg \left(x \leq 4.5 \cdot 10^{-134}\right):\\ \;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \end{array} \]
Alternative 4
Error31%
Cost716
\[\begin{array}{l} t_0 := x \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-46}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{+17}:\\ \;\;\;\;x \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error31.02%
Cost716
\[\begin{array}{l} t_0 := x \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-46}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 8.9 \cdot 10^{+15}:\\ \;\;\;\;y \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error21.15%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+30} \lor \neg \left(z \leq 8.5 \cdot 10^{-46}\right):\\ \;\;\;\;x \cdot \left(z \cdot \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot z\\ \end{array} \]
Alternative 7
Error15.87%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -6.6 \cdot 10^{+22} \lor \neg \left(z \leq 8.5 \cdot 10^{-46}\right):\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot z\\ \end{array} \]
Alternative 8
Error1.49%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot \left(z \cdot y\right)\\ \end{array} \]
Alternative 9
Error15.82%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -6.6 \cdot 10^{+22}:\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-46}:\\ \;\;\;\;x - x \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot z\right) \cdot \left(y + -1\right)\\ \end{array} \]
Alternative 10
Error30.51%
Cost521
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;x \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error52.77%
Cost64
\[x \]

Error

Reproduce?

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