?

Average Error: 3.4 → 0.7
Time: 8.8s
Precision: binary64
Cost: 841

?

\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \]
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-71} \lor \neg \left(x \leq 2 \cdot 10^{-158}\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} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -1e-71) (not (<= x 2e-158)))
   (* x (+ 1.0 (* z (+ y -1.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 tmp;
	if ((x <= -1e-71) || !(x <= 2e-158)) {
		tmp = x * (1.0 + (z * (y + -1.0)));
	} else {
		tmp = x + (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) :: tmp
    if ((x <= (-1d-71)) .or. (.not. (x <= 2d-158))) then
        tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
    else
        tmp = x + (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 tmp;
	if ((x <= -1e-71) || !(x <= 2e-158)) {
		tmp = x * (1.0 + (z * (y + -1.0)));
	} else {
		tmp = x + (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):
	tmp = 0
	if (x <= -1e-71) or not (x <= 2e-158):
		tmp = x * (1.0 + (z * (y + -1.0)))
	else:
		tmp = x + (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)
	tmp = 0.0
	if ((x <= -1e-71) || !(x <= 2e-158))
		tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0))));
	else
		tmp = Float64(x + 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)
	tmp = 0.0;
	if ((x <= -1e-71) || ~((x <= 2e-158)))
		tmp = x * (1.0 + (z * (y + -1.0)));
	else
		tmp = x + (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_] := If[Or[LessEqual[x, -1e-71], N[Not[LessEqual[x, 2e-158]], $MachinePrecision]], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(x * 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 -1 \cdot 10^{-71} \lor \neg \left(x \leq 2 \cdot 10^{-158}\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}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.4
Target0.2
Herbie0.7
\[\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 x < -9.9999999999999992e-72 or 2.00000000000000013e-158 < x

    1. Initial program 1.1

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

    if -9.9999999999999992e-72 < x < 2.00000000000000013e-158

    1. Initial program 7.0

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

      \[\leadsto \color{blue}{z \cdot \left(\left(y - 1\right) \cdot x\right) + x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-71} \lor \neg \left(x \leq 2 \cdot 10^{-158}\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} \]

Alternatives

Alternative 1
Error21.1
Cost981
\[\begin{array}{l} t_0 := x \cdot \left(-z\right)\\ t_1 := x \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -1.68 \cdot 10^{+72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4.4 \cdot 10^{-17}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.25:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+84} \lor \neg \left(z \leq 2.2 \cdot 10^{+186}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error20.8
Cost981
\[\begin{array}{l} t_0 := x \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -4.1 \cdot 10^{+63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-14}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 1.25:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4 \cdot 10^{+83} \lor \neg \left(z \leq 3.7 \cdot 10^{+213}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot z\right)\\ \end{array} \]
Alternative 3
Error9.4
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -4.4 \cdot 10^{-16} \lor \neg \left(z \leq 1.15\right):\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \end{array} \]
Alternative 4
Error1.0
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 \cdot \left(1 + y \cdot z\right)\\ \end{array} \]
Alternative 5
Error1.8
Cost708
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{+42}:\\ \;\;\;\;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} \]
Alternative 6
Error11.8
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -4.9 \cdot 10^{+82} \lor \neg \left(y \leq 1.1 \cdot 10^{+83}\right):\\ \;\;\;\;y \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \end{array} \]
Alternative 7
Error19.3
Cost521
\[\begin{array}{l} \mathbf{if}\;z \leq -0.003 \lor \neg \left(z \leq 1.25\right):\\ \;\;\;\;x \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error33.3
Cost64
\[x \]

Error

Reproduce?

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