?

Average Error: 3.5 → 0.2
Time: 5.7s
Precision: binary64
Cost: 968

?

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

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

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


\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.00000000000000005e242 or 2.00000000000000004e198 < (*.f64 y z)

    1. Initial program 30.4

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

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

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

      [Start]1.1

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

      rational.json-simplify-43 [=>]1.1

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

      rational.json-simplify-43 [=>]1.1

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

      rational.json-simplify-9 [=>]1.1

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

      rational.json-simplify-2 [=>]1.1

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

    if -1.00000000000000005e242 < (*.f64 y z) < 2.00000000000000004e198

    1. Initial program 0.1

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

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

Alternatives

Alternative 1
Error18.6
Cost1044
\[\begin{array}{l} t_0 := z \cdot \left(-y \cdot x\right)\\ \mathbf{if}\;z \leq -1.45 \cdot 10^{-39}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{-100}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.25 \cdot 10^{-55}:\\ \;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+144}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{+241}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z \cdot x\right)\\ \end{array} \]
Alternative 2
Error20.2
Cost912
\[\begin{array}{l} t_0 := x \cdot \left(y \cdot \left(-z\right)\right)\\ \mathbf{if}\;z \leq -1.6 \cdot 10^{-39}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 9.6 \cdot 10^{-102}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{+146}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error16.0
Cost648
\[\begin{array}{l} t_0 := y \cdot \left(-z \cdot x\right)\\ \mathbf{if}\;y \leq -5.2 \cdot 10^{+89}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{-49}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error25.2
Cost64
\[x \]

Error

Reproduce?

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