?

Average Error: 3.4 → 1.0
Time: 10.6s
Precision: binary64
Cost: 2632

?

\[ \begin{array}{c}[y, z] = \mathsf{sort}([y, z])\\ \end{array} \]
\[x \cdot \left(1 - y \cdot z\right) \]
\[\begin{array}{l} t_0 := x \cdot \left(1 - y \cdot z\right)\\ t_1 := x - z \cdot \left(y \cdot x\right)\\ t_2 := t_1 \cdot \left(t_1 \cdot \frac{1}{t_1}\right)\\ \mathbf{if}\;t_0 \leq -2 \cdot 10^{+262}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_0 \leq 10^{+300}:\\ \;\;\;\;x - x \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (- 1.0 (* y z))))
        (t_1 (- x (* z (* y x))))
        (t_2 (* t_1 (* t_1 (/ 1.0 t_1)))))
   (if (<= t_0 -2e+262) t_2 (if (<= t_0 1e+300) (- x (* x (* y z))) t_2))))
double code(double x, double y, double z) {
	return x * (1.0 - (y * z));
}
double code(double x, double y, double z) {
	double t_0 = x * (1.0 - (y * z));
	double t_1 = x - (z * (y * x));
	double t_2 = t_1 * (t_1 * (1.0 / t_1));
	double tmp;
	if (t_0 <= -2e+262) {
		tmp = t_2;
	} else if (t_0 <= 1e+300) {
		tmp = x - (x * (y * z));
	} else {
		tmp = t_2;
	}
	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 - (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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = x * (1.0d0 - (y * z))
    t_1 = x - (z * (y * x))
    t_2 = t_1 * (t_1 * (1.0d0 / t_1))
    if (t_0 <= (-2d+262)) then
        tmp = t_2
    else if (t_0 <= 1d+300) then
        tmp = x - (x * (y * z))
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	return x * (1.0 - (y * z));
}
public static double code(double x, double y, double z) {
	double t_0 = x * (1.0 - (y * z));
	double t_1 = x - (z * (y * x));
	double t_2 = t_1 * (t_1 * (1.0 / t_1));
	double tmp;
	if (t_0 <= -2e+262) {
		tmp = t_2;
	} else if (t_0 <= 1e+300) {
		tmp = x - (x * (y * z));
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z):
	return x * (1.0 - (y * z))
def code(x, y, z):
	t_0 = x * (1.0 - (y * z))
	t_1 = x - (z * (y * x))
	t_2 = t_1 * (t_1 * (1.0 / t_1))
	tmp = 0
	if t_0 <= -2e+262:
		tmp = t_2
	elif t_0 <= 1e+300:
		tmp = x - (x * (y * z))
	else:
		tmp = t_2
	return tmp
function code(x, y, z)
	return Float64(x * Float64(1.0 - Float64(y * z)))
end
function code(x, y, z)
	t_0 = Float64(x * Float64(1.0 - Float64(y * z)))
	t_1 = Float64(x - Float64(z * Float64(y * x)))
	t_2 = Float64(t_1 * Float64(t_1 * Float64(1.0 / t_1)))
	tmp = 0.0
	if (t_0 <= -2e+262)
		tmp = t_2;
	elseif (t_0 <= 1e+300)
		tmp = Float64(x - Float64(x * Float64(y * z)));
	else
		tmp = t_2;
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = x * (1.0 - (y * z));
end
function tmp_2 = code(x, y, z)
	t_0 = x * (1.0 - (y * z));
	t_1 = x - (z * (y * x));
	t_2 = t_1 * (t_1 * (1.0 / t_1));
	tmp = 0.0;
	if (t_0 <= -2e+262)
		tmp = t_2;
	elseif (t_0 <= 1e+300)
		tmp = x - (x * (y * z));
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x - N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(t$95$1 * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+262], t$95$2, If[LessEqual[t$95$0, 1e+300], N[(x - N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
t_0 := x \cdot \left(1 - y \cdot z\right)\\
t_1 := x - z \cdot \left(y \cdot x\right)\\
t_2 := t_1 \cdot \left(t_1 \cdot \frac{1}{t_1}\right)\\
\mathbf{if}\;t_0 \leq -2 \cdot 10^{+262}:\\
\;\;\;\;t_2\\

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

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 x (-.f64 1 (*.f64 y z))) < -2e262 or 1.0000000000000001e300 < (*.f64 x (-.f64 1 (*.f64 y z)))

    1. Initial program 32.4

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Simplified32.4

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

      [Start]32.4

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

      rational_best_oopsla_all_46_json_45_simplify-13 [=>]32.4

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]32.4

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

      rational_best_oopsla_all_46_json_45_simplify-52 [=>]32.4

      \[ \color{blue}{x} - x \cdot \left(y \cdot z\right) \]
    3. Taylor expanded in x around 0 7.2

      \[\leadsto x - \color{blue}{y \cdot \left(z \cdot x\right)} \]
    4. Simplified8.8

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

      [Start]7.2

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

      rational_best_oopsla_all_46_json_45_simplify-7 [=>]8.8

      \[ x - \color{blue}{z \cdot \left(y \cdot x\right)} \]
    5. Applied egg-rr8.8

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

    if -2e262 < (*.f64 x (-.f64 1 (*.f64 y z))) < 1.0000000000000001e300

    1. Initial program 0.1

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

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

      [Start]0.1

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

      rational_best_oopsla_all_46_json_45_simplify-13 [=>]0.1

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.1

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

      rational_best_oopsla_all_46_json_45_simplify-52 [=>]0.1

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

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

Alternatives

Alternative 1
Error0.2
Cost1480
\[\begin{array}{l} t_0 := x \cdot \left(1 - y \cdot z\right)\\ t_1 := z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+304}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error0.2
Cost1480
\[\begin{array}{l} t_0 := x \cdot \left(1 - y \cdot z\right)\\ t_1 := z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+304}:\\ \;\;\;\;x - x \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error0.3
Cost1480
\[\begin{array}{l} t_0 := x \cdot \left(1 - y \cdot z\right)\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;t_0 \leq 10^{+300}:\\ \;\;\;\;x - x \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot \left(y \cdot x\right)\\ \end{array} \]
Alternative 4
Error17.9
Cost912
\[\begin{array}{l} t_0 := y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{if}\;y \leq -3.5 \cdot 10^{+137}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6 \cdot 10^{+78}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{+29}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{-123}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error4.8
Cost904
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq -20000:\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{elif}\;y \cdot z \leq 0.04:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\left(-x\right) \cdot \left(y \cdot z\right)\\ \end{array} \]
Alternative 6
Error26.0
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023090 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
  :precision binary64
  (* x (- 1.0 (* y z))))