Average Error: 3.5 → 0.9
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 -3.5 \cdot 10^{-165} \lor \neg \left(x \leq 10^{-47}\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 -3.5e-165) (not (<= x 1e-47)))
   (* 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 <= -3.5e-165) || !(x <= 1e-47)) {
		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 <= (-3.5d-165)) .or. (.not. (x <= 1d-47))) 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 <= -3.5e-165) || !(x <= 1e-47)) {
		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 <= -3.5e-165) or not (x <= 1e-47):
		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 <= -3.5e-165) || !(x <= 1e-47))
		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 <= -3.5e-165) || ~((x <= 1e-47)))
		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, -3.5e-165], N[Not[LessEqual[x, 1e-47]], $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 -3.5 \cdot 10^{-165} \lor \neg \left(x \leq 10^{-47}\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.5
Target0.2
Herbie0.9
\[\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 < -3.5000000000000002e-165 or 9.9999999999999997e-48 < x

    1. Initial program 1.5

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

    if -3.5000000000000002e-165 < x < 9.9999999999999997e-48

    1. Initial program 6.5

      \[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.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{-165} \lor \neg \left(x \leq 10^{-47}\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
Error0.9
Cost1864
\[\begin{array}{l} t_0 := x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;z \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+289}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot z}{\frac{1}{y}}\\ \end{array} \]
Alternative 2
Error19.3
Cost981
\[\begin{array}{l} t_0 := x \cdot \left(-z\right)\\ t_1 := x \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -3300000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.5 \cdot 10^{-25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{+55} \lor \neg \left(z \leq 8.6 \cdot 10^{+82}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error19.7
Cost981
\[\begin{array}{l} t_0 := x \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -3600000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.25 \cdot 10^{-25}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.08 \cdot 10^{+55} \lor \neg \left(z \leq 1.5 \cdot 10^{+143}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot z\right)\\ \end{array} \]
Alternative 4
Error19.7
Cost981
\[\begin{array}{l} t_0 := x \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -3450000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{-25}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.08 \cdot 10^{+55} \lor \neg \left(z \leq 1.9 \cdot 10^{+144}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 5
Error12.0
Cost977
\[\begin{array}{l} \mathbf{if}\;y \leq -4.8 \cdot 10^{+19}:\\ \;\;\;\;z \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;y \leq 2200000000:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{elif}\;y \leq 1.08 \cdot 10^{+48} \lor \neg \left(y \leq 8.5 \cdot 10^{+79}\right):\\ \;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error11.9
Cost849
\[\begin{array}{l} t_0 := z \cdot \left(x \cdot y\right)\\ \mathbf{if}\;y \leq -1.8 \cdot 10^{+18}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 110000000000:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{elif}\;y \leq 1.12 \cdot 10^{+46} \lor \neg \left(y \leq 1.9 \cdot 10^{+81}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error12.0
Cost848
\[\begin{array}{l} t_0 := z \cdot \left(x \cdot y\right)\\ \mathbf{if}\;y \leq -1.7 \cdot 10^{+20}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 230000000000:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{+45}:\\ \;\;\;\;x \cdot \left(z \cdot \left(y + -1\right)\right)\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+81}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error4.1
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -82 \lor \neg \left(y \leq 1\right):\\ \;\;\;\;x + z \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \end{array} \]
Alternative 9
Error0.9
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1000000 \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 10
Error3.2
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -82:\\ \;\;\;\;x + z \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(x \cdot z\right)\\ \end{array} \]
Alternative 11
Error19.1
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 12
Error32.8
Cost64
\[x \]

Error

Reproduce

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