?

Average Error: 8.62% → 0.16%
Time: 6.0s
Precision: binary64
Cost: 13385

?

\[x \cdot \left(1 + y \cdot y\right) \]
\[\begin{array}{l} \mathbf{if}\;y \leq -9.4 \cdot 10^{+151} \lor \neg \left(y \leq 72000000\right):\\ \;\;\;\;y \cdot \left(y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{{\left(\mathsf{hypot}\left(1, y\right)\right)}^{-2}}\\ \end{array} \]
(FPCore (x y) :precision binary64 (* x (+ 1.0 (* y y))))
(FPCore (x y)
 :precision binary64
 (if (or (<= y -9.4e+151) (not (<= y 72000000.0)))
   (* y (* y x))
   (/ x (pow (hypot 1.0 y) -2.0))))
double code(double x, double y) {
	return x * (1.0 + (y * y));
}
double code(double x, double y) {
	double tmp;
	if ((y <= -9.4e+151) || !(y <= 72000000.0)) {
		tmp = y * (y * x);
	} else {
		tmp = x / pow(hypot(1.0, y), -2.0);
	}
	return tmp;
}
public static double code(double x, double y) {
	return x * (1.0 + (y * y));
}
public static double code(double x, double y) {
	double tmp;
	if ((y <= -9.4e+151) || !(y <= 72000000.0)) {
		tmp = y * (y * x);
	} else {
		tmp = x / Math.pow(Math.hypot(1.0, y), -2.0);
	}
	return tmp;
}
def code(x, y):
	return x * (1.0 + (y * y))
def code(x, y):
	tmp = 0
	if (y <= -9.4e+151) or not (y <= 72000000.0):
		tmp = y * (y * x)
	else:
		tmp = x / math.pow(math.hypot(1.0, y), -2.0)
	return tmp
function code(x, y)
	return Float64(x * Float64(1.0 + Float64(y * y)))
end
function code(x, y)
	tmp = 0.0
	if ((y <= -9.4e+151) || !(y <= 72000000.0))
		tmp = Float64(y * Float64(y * x));
	else
		tmp = Float64(x / (hypot(1.0, y) ^ -2.0));
	end
	return tmp
end
function tmp = code(x, y)
	tmp = x * (1.0 + (y * y));
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -9.4e+151) || ~((y <= 72000000.0)))
		tmp = y * (y * x);
	else
		tmp = x / (hypot(1.0, y) ^ -2.0);
	end
	tmp_2 = tmp;
end
code[x_, y_] := N[(x * N[(1.0 + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := If[Or[LessEqual[y, -9.4e+151], N[Not[LessEqual[y, 72000000.0]], $MachinePrecision]], N[(y * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(x / N[Power[N[Sqrt[1.0 ^ 2 + y ^ 2], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]]
x \cdot \left(1 + y \cdot y\right)
\begin{array}{l}
\mathbf{if}\;y \leq -9.4 \cdot 10^{+151} \lor \neg \left(y \leq 72000000\right):\\
\;\;\;\;y \cdot \left(y \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{{\left(\mathsf{hypot}\left(1, y\right)\right)}^{-2}}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original8.62%
Target0.13%
Herbie0.16%
\[x + \left(x \cdot y\right) \cdot y \]

Derivation?

  1. Split input into 2 regimes
  2. if y < -9.39999999999999978e151 or 7.2e7 < y

    1. Initial program 43.12

      \[x \cdot \left(1 + y \cdot y\right) \]
    2. Taylor expanded in y around inf 43.12

      \[\leadsto \color{blue}{{y}^{2} \cdot x} \]
    3. Simplified0.42

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

      [Start]43.12

      \[ {y}^{2} \cdot x \]

      unpow2 [=>]43.12

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

      associate-*l* [=>]0.42

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

    if -9.39999999999999978e151 < y < 7.2e7

    1. Initial program 0.08

      \[x \cdot \left(1 + y \cdot y\right) \]
    2. Applied egg-rr7.44

      \[\leadsto \color{blue}{\frac{\left(1 - {y}^{4}\right) \cdot x}{1 - y \cdot y}} \]
    3. Applied egg-rr2.18

      \[\leadsto \color{blue}{{\left(\sqrt[3]{x \cdot \left(1 + y \cdot y\right)}\right)}^{2} \cdot \sqrt[3]{x \cdot \left(1 + y \cdot y\right)}} \]
    4. Applied egg-rr0.11

      \[\leadsto \color{blue}{\frac{x}{\frac{1}{\mathsf{fma}\left(y, y, 1\right)}}} \]
    5. Applied egg-rr14.84

      \[\leadsto \frac{x}{\color{blue}{e^{\mathsf{log1p}\left(\frac{1}{\mathsf{fma}\left(y, y, 1\right)}\right)} - 1}} \]
    6. Simplified0.1

      \[\leadsto \frac{x}{\color{blue}{{\left(\mathsf{hypot}\left(1, y\right)\right)}^{-2}}} \]
      Proof

      [Start]14.84

      \[ \frac{x}{e^{\mathsf{log1p}\left(\frac{1}{\mathsf{fma}\left(y, y, 1\right)}\right)} - 1} \]

      expm1-def [=>]0.11

      \[ \frac{x}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\mathsf{fma}\left(y, y, 1\right)}\right)\right)}} \]

      expm1-log1p [=>]0.11

      \[ \frac{x}{\color{blue}{\frac{1}{\mathsf{fma}\left(y, y, 1\right)}}} \]

      rem-square-sqrt [<=]0.13

      \[ \frac{x}{\frac{1}{\color{blue}{\sqrt{\mathsf{fma}\left(y, y, 1\right)} \cdot \sqrt{\mathsf{fma}\left(y, y, 1\right)}}}} \]

      associate-/r* [=>]0.13

      \[ \frac{x}{\color{blue}{\frac{\frac{1}{\sqrt{\mathsf{fma}\left(y, y, 1\right)}}}{\sqrt{\mathsf{fma}\left(y, y, 1\right)}}}} \]

      unpow-1 [<=]0.13

      \[ \frac{x}{\frac{\color{blue}{{\left(\sqrt{\mathsf{fma}\left(y, y, 1\right)}\right)}^{-1}}}{\sqrt{\mathsf{fma}\left(y, y, 1\right)}}} \]

      *-lft-identity [<=]0.13

      \[ \frac{x}{\frac{\color{blue}{1 \cdot {\left(\sqrt{\mathsf{fma}\left(y, y, 1\right)}\right)}^{-1}}}{\sqrt{\mathsf{fma}\left(y, y, 1\right)}}} \]

      associate-*l/ [<=]0.18

      \[ \frac{x}{\color{blue}{\frac{1}{\sqrt{\mathsf{fma}\left(y, y, 1\right)}} \cdot {\left(\sqrt{\mathsf{fma}\left(y, y, 1\right)}\right)}^{-1}}} \]

      unpow-1 [<=]0.18

      \[ \frac{x}{\color{blue}{{\left(\sqrt{\mathsf{fma}\left(y, y, 1\right)}\right)}^{-1}} \cdot {\left(\sqrt{\mathsf{fma}\left(y, y, 1\right)}\right)}^{-1}} \]

      pow-sqr [=>]0.11

      \[ \frac{x}{\color{blue}{{\left(\sqrt{\mathsf{fma}\left(y, y, 1\right)}\right)}^{\left(2 \cdot -1\right)}}} \]

      metadata-eval [=>]0.11

      \[ \frac{x}{{\left(\sqrt{\mathsf{fma}\left(y, y, 1\right)}\right)}^{\color{blue}{-2}}} \]

      fma-udef [=>]0.11

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

      unpow2 [<=]0.11

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

      +-commutative [<=]0.11

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

      unpow2 [=>]0.11

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

      hypot-1-def [=>]0.1

      \[ \frac{x}{{\color{blue}{\left(\mathsf{hypot}\left(1, y\right)\right)}}^{-2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.16

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.4 \cdot 10^{+151} \lor \neg \left(y \leq 72000000\right):\\ \;\;\;\;y \cdot \left(y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{{\left(\mathsf{hypot}\left(1, y\right)\right)}^{-2}}\\ \end{array} \]

Alternatives

Alternative 1
Error0.15%
Cost708
\[\begin{array}{l} \mathbf{if}\;y \cdot y \leq 2 \cdot 10^{+14}:\\ \;\;\;\;x \cdot \left(1 + y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(y \cdot x\right)\\ \end{array} \]
Alternative 2
Error0.14%
Cost708
\[\begin{array}{l} \mathbf{if}\;y \cdot y \leq 2 \cdot 10^{+14}:\\ \;\;\;\;x + x \cdot \left(y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(y \cdot x\right)\\ \end{array} \]
Alternative 3
Error10.21%
Cost580
\[\begin{array}{l} \mathbf{if}\;y \cdot y \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot y\right)\\ \end{array} \]
Alternative 4
Error1.8%
Cost580
\[\begin{array}{l} \mathbf{if}\;y \cdot y \leq 0.0004:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(y \cdot x\right)\\ \end{array} \]
Alternative 5
Error32.09%
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023088 
(FPCore (x y)
  :name "Numeric.Integration.TanhSinh:everywhere from integration-0.2.1"
  :precision binary64

  :herbie-target
  (+ x (* (* x y) y))

  (* x (+ 1.0 (* y y))))