?

Average Error: 3.5 → 0.2
Time: 12.5s
Precision: binary64
Cost: 840

?

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

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.5
Target0.2
Herbie0.2
\[\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 < -2.0000000000000001e47 or 2.5000000000000002e49 < x

    1. Initial program 0.1

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

    if -2.0000000000000001e47 < x < 2.5000000000000002e49

    1. Initial program 5.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{+47}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{+49}:\\ \;\;\;\;z \cdot \left(\left(y - 1\right) \cdot x\right) + x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \end{array} \]

Alternatives

Alternative 1
Error2.3
Cost964
\[\begin{array}{l} t_0 := \left(1 - y\right) \cdot z\\ \mathbf{if}\;t_0 \leq 10^{+280}:\\ \;\;\;\;x \cdot \left(1 - t_0\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \end{array} \]
Alternative 2
Error21.8
Cost784
\[\begin{array}{l} t_0 := z \cdot \left(-x\right)\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 10^{-159}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{-83}:\\ \;\;\;\;x \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 0.00012:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error4.1
Cost712
\[\begin{array}{l} t_0 := \left(y \cdot z + 1\right) \cdot x\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;z \cdot \left(-x\right) + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error4.1
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;\left(y \cdot z + 1\right) \cdot x\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;z \cdot \left(-x\right) + x\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot \left(y \cdot z\right)\\ \end{array} \]
Alternative 5
Error2.2
Cost712
\[\begin{array}{l} t_0 := y \cdot \left(z \cdot x\right) + x\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;z \cdot \left(-x\right) + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error11.8
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -2.45 \cdot 10^{+47}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{+97}:\\ \;\;\;\;z \cdot \left(-x\right) + x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot x\right)\\ \end{array} \]
Alternative 7
Error11.8
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -2.85 \cdot 10^{+51}:\\ \;\;\;\;y \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{+97}:\\ \;\;\;\;\left(1 - z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot x\right)\\ \end{array} \]
Alternative 8
Error19.7
Cost520
\[\begin{array}{l} t_0 := z \cdot \left(-x\right)\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.00012:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error33.6
Cost64
\[x \]

Error

Reproduce?

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