?

Average Accuracy: 94.5% → 97.1%
Time: 5.6s
Precision: binary64
Cost: 708

?

\[ \begin{array}{c}[y, z] = \mathsf{sort}([y, z])\\ \end{array} \]
\[x \cdot \left(1 - y \cdot z\right) \]
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq 10^{+302}:\\ \;\;\;\;x - \left(y \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
(FPCore (x y z)
 :precision binary64
 (if (<= (* y z) 1e+302) (- x (* (* y z) x)) (* z (* y (- x)))))
double code(double x, double y, double z) {
	return x * (1.0 - (y * z));
}
double code(double x, double y, double z) {
	double tmp;
	if ((y * z) <= 1e+302) {
		tmp = x - ((y * z) * x);
	} else {
		tmp = z * (y * -x);
	}
	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) :: tmp
    if ((y * z) <= 1d+302) then
        tmp = x - ((y * z) * x)
    else
        tmp = z * (y * -x)
    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 tmp;
	if ((y * z) <= 1e+302) {
		tmp = x - ((y * z) * x);
	} else {
		tmp = z * (y * -x);
	}
	return tmp;
}
def code(x, y, z):
	return x * (1.0 - (y * z))
def code(x, y, z):
	tmp = 0
	if (y * z) <= 1e+302:
		tmp = x - ((y * z) * x)
	else:
		tmp = z * (y * -x)
	return tmp
function code(x, y, z)
	return Float64(x * Float64(1.0 - Float64(y * z)))
end
function code(x, y, z)
	tmp = 0.0
	if (Float64(y * z) <= 1e+302)
		tmp = Float64(x - Float64(Float64(y * z) * x));
	else
		tmp = Float64(z * Float64(y * Float64(-x)));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = x * (1.0 - (y * z));
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y * z) <= 1e+302)
		tmp = x - ((y * z) * x);
	else
		tmp = z * (y * -x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], 1e+302], N[(x - N[(N[(y * z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision]]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq 10^{+302}:\\
\;\;\;\;x - \left(y \cdot z\right) \cdot x\\

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


\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 y z) < 1.0000000000000001e302

    1. Initial program 97.0%

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

      \[\leadsto \color{blue}{\left(1 - y \cdot z\right) \cdot x} \]
    3. Simplified92.5%

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

      [Start]97.0

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

      *-commutative [<=]97.0

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

      distribute-rgt-out-- [<=]97.0

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

      *-lft-identity [=>]97.0

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

      associate-*r* [<=]92.5

      \[ x - \color{blue}{y \cdot \left(z \cdot x\right)} \]
    4. Applied egg-rr52.4%

      \[\leadsto \color{blue}{\left(x \cdot x - {\left(x \cdot \left(y \cdot z\right)\right)}^{2}\right) \cdot \frac{1}{x + x \cdot \left(y \cdot z\right)}} \]
    5. Simplified96.8%

      \[\leadsto \color{blue}{\frac{1 - y \cdot z}{\frac{1}{x}}} \]
      Proof

      [Start]52.4

      \[ \left(x \cdot x - {\left(x \cdot \left(y \cdot z\right)\right)}^{2}\right) \cdot \frac{1}{x + x \cdot \left(y \cdot z\right)} \]

      *-commutative [=>]52.4

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

      associate-/r/ [<=]52.4

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

      unpow2 [=>]52.4

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

      difference-of-squares [=>]52.4

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

      associate-/r* [=>]96.8

      \[ \frac{1}{\color{blue}{\frac{\frac{x + x \cdot \left(y \cdot z\right)}{x + x \cdot \left(y \cdot z\right)}}{x - x \cdot \left(y \cdot z\right)}}} \]
    6. Applied egg-rr97.0%

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

    if 1.0000000000000001e302 < (*.f64 y z)

    1. Initial program 7.6%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Taylor expanded in y around inf 99.6%

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot \left(z \cdot x\right)\right)} \]
    3. Simplified99.5%

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

      [Start]99.6

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

      mul-1-neg [=>]99.6

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

      associate-*r* [=>]7.6

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

      distribute-rgt-neg-in [=>]7.6

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

      *-commutative [=>]7.6

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

      associate-*l* [=>]99.5

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

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

Alternatives

Alternative 1
Accuracy70.1%
Cost914
\[\begin{array}{l} \mathbf{if}\;y \leq -8.4 \cdot 10^{+155} \lor \neg \left(y \leq -6 \cdot 10^{+93} \lor \neg \left(y \leq -2.25 \cdot 10^{+45}\right) \land y \leq 2.05 \cdot 10^{-78}\right):\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Accuracy72.8%
Cost914
\[\begin{array}{l} \mathbf{if}\;y \leq -1.22 \cdot 10^{+153} \lor \neg \left(y \leq -1.5 \cdot 10^{+96} \lor \neg \left(y \leq -2.1 \cdot 10^{+45}\right) \land y \leq 2.3 \cdot 10^{-72}\right):\\ \;\;\;\;y \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Accuracy97.0%
Cost708
\[\begin{array}{l} \mathbf{if}\;y \cdot z \leq 10^{+302}:\\ \;\;\;\;x \cdot \left(1 - y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \end{array} \]
Alternative 4
Accuracy60.6%
Cost64
\[x \]

Error

Reproduce?

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