Average Error: 14.9 → 0.0
Time: 1.3s
Precision: binary64
Cost: 1090
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \leq -54864435368.92307:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{elif}\;x \leq 117265524.41492076:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \leq -54864435368.92307:\\
\;\;\;\;\frac{1}{x}\\

\mathbf{elif}\;x \leq 117265524.41492076:\\
\;\;\;\;\frac{x}{1 + x \cdot x}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{x}\\

\end{array}
(FPCore (x) :precision binary64 (/ x (+ (* x x) 1.0)))
(FPCore (x)
 :precision binary64
 (if (<= x -54864435368.92307)
   (/ 1.0 x)
   (if (<= x 117265524.41492076) (/ x (+ 1.0 (* x x))) (/ 1.0 x))))
double code(double x) {
	return x / ((x * x) + 1.0);
}
double code(double x) {
	double tmp;
	if (x <= -54864435368.92307) {
		tmp = 1.0 / x;
	} else if (x <= 117265524.41492076) {
		tmp = x / (1.0 + (x * x));
	} else {
		tmp = 1.0 / x;
	}
	return tmp;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.9
Target0.1
Herbie0.0
\[\frac{1}{x + \frac{1}{x}}\]

Alternatives

Alternative 1
Error39.4
Cost26560
\[\frac{\sqrt{x}}{\sqrt{x \cdot x + 1}} \cdot \frac{\sqrt{x}}{\sqrt{x \cdot x + 1}}\]
Alternative 2
Error15.9
Cost20672
\[\sqrt[3]{\frac{x}{x \cdot x + 1}} \cdot \left(\sqrt[3]{\frac{x}{x \cdot x + 1}} \cdot \sqrt[3]{\frac{x}{x \cdot x + 1}}\right)\]
Alternative 3
Error15.9
Cost19904
\[\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \frac{\sqrt[3]{x}}{x \cdot x + 1}\]
Alternative 4
Error14.8
Cost13760
\[\frac{1}{\sqrt{x \cdot x + 1}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\]
Alternative 5
Error39.4
Cost13376
\[\sqrt{x} \cdot \frac{\sqrt{x}}{x \cdot x + 1}\]
Alternative 6
Error39.6
Cost13312
\[\sqrt[3]{{\left(\frac{x}{x \cdot x + 1}\right)}^{3}}\]
Alternative 7
Error14.9
Cost576
\[\frac{1}{\frac{x \cdot x + 1}{x}}\]
Alternative 8
Error14.9
Cost448
\[\frac{x}{x \cdot x + 1}\]
Alternative 9
Error31.4
Cost192
\[\frac{1}{x}\]
Alternative 10
Error30.9
Cost64
\[x\]
Alternative 11
Error61.5
Cost64
\[1\]
Alternative 12
Error60.5
Cost64
\[0\]
Alternative 13
Error61.6
Cost64
\[-1\]

Error

Derivation

  1. Split input into 2 regimes
  2. if x < -54864435368.9230728 or 117265524.414920762 < x

    1. Initial program 31.0

      \[\frac{x}{x \cdot x + 1}\]
    2. Taylor expanded around inf 0.0

      \[\leadsto \color{blue}{\frac{1}{x}}\]
    3. Simplified0.0

      \[\leadsto \color{blue}{\frac{1}{x}}\]

    if -54864435368.9230728 < x < 117265524.414920762

    1. Initial program 0.0

      \[\frac{x}{x \cdot x + 1}\]
    2. Simplified0.0

      \[\leadsto \color{blue}{\frac{x}{x \cdot x + 1}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -54864435368.92307:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{elif}\;x \leq 117265524.41492076:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x}\\ \end{array}\]

Reproduce

herbie shell --seed 2021042 
(FPCore (x)
  :name "x / (x^2 + 1)"
  :precision binary64

  :herbie-target
  (/ 1.0 (+ x (/ 1.0 x)))

  (/ x (+ (* x x) 1.0)))