?

Average Accuracy: 76.6% → 99.8%
Time: 6.0s
Precision: binary64
Cost: 448

?

\[\frac{x}{x \cdot x + 1} \]
\[\frac{1}{x + \frac{1}{x}} \]
(FPCore (x) :precision binary64 (/ x (+ (* x x) 1.0)))
(FPCore (x) :precision binary64 (/ 1.0 (+ x (/ 1.0 x))))
double code(double x) {
	return x / ((x * x) + 1.0);
}
double code(double x) {
	return 1.0 / (x + (1.0 / x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = x / ((x * x) + 1.0d0)
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = 1.0d0 / (x + (1.0d0 / x))
end function
public static double code(double x) {
	return x / ((x * x) + 1.0);
}
public static double code(double x) {
	return 1.0 / (x + (1.0 / x));
}
def code(x):
	return x / ((x * x) + 1.0)
def code(x):
	return 1.0 / (x + (1.0 / x))
function code(x)
	return Float64(x / Float64(Float64(x * x) + 1.0))
end
function code(x)
	return Float64(1.0 / Float64(x + Float64(1.0 / x)))
end
function tmp = code(x)
	tmp = x / ((x * x) + 1.0);
end
function tmp = code(x)
	tmp = 1.0 / (x + (1.0 / x));
end
code[x_] := N[(x / N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(1.0 / N[(x + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x}{x \cdot x + 1}
\frac{1}{x + \frac{1}{x}}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original76.6%
Target99.8%
Herbie99.8%
\[\frac{1}{x + \frac{1}{x}} \]

Derivation?

  1. Initial program 76.6%

    \[\frac{x}{x \cdot x + 1} \]
  2. Applied egg-rr58.6%

    \[\leadsto \color{blue}{\frac{x}{1 + {x}^{6}} \cdot \left({x}^{4} + \left(1 - x \cdot x\right)\right)} \]
    Proof

    [Start]76.6

    \[ \frac{x}{x \cdot x + 1} \]

    flip3-+ [=>]58.6

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

    associate-/r/ [=>]58.6

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

    metadata-eval [=>]58.6

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

    +-commutative [=>]58.6

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

    pow2 [=>]58.6

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

    pow-pow [=>]58.6

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

    metadata-eval [=>]58.6

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

    metadata-eval [=>]58.6

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

    *-rgt-identity [=>]58.6

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

    pow2 [=>]58.6

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

    pow2 [=>]58.6

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

    pow-sqr [=>]58.6

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

    metadata-eval [=>]58.6

    \[ \frac{x}{1 + {x}^{6}} \cdot \left({x}^{\color{blue}{4}} + \left(1 - x \cdot x\right)\right) \]
  3. Applied egg-rr76.6%

    \[\leadsto \color{blue}{\frac{1}{\frac{1 + x \cdot x}{x}}} \]
    Proof

    [Start]58.6

    \[ \frac{x}{1 + {x}^{6}} \cdot \left({x}^{4} + \left(1 - x \cdot x\right)\right) \]

    associate-*l/ [=>]58.5

    \[ \color{blue}{\frac{x \cdot \left({x}^{4} + \left(1 - x \cdot x\right)\right)}{1 + {x}^{6}}} \]

    clear-num [=>]58.4

    \[ \color{blue}{\frac{1}{\frac{1 + {x}^{6}}{x \cdot \left({x}^{4} + \left(1 - x \cdot x\right)\right)}}} \]

    *-commutative [=>]58.4

    \[ \frac{1}{\frac{1 + {x}^{6}}{\color{blue}{\left({x}^{4} + \left(1 - x \cdot x\right)\right) \cdot x}}} \]

    associate-/r* [=>]58.5

    \[ \frac{1}{\color{blue}{\frac{\frac{1 + {x}^{6}}{{x}^{4} + \left(1 - x \cdot x\right)}}{x}}} \]
  4. Taylor expanded in x around 0 99.8%

    \[\leadsto \frac{1}{\color{blue}{\frac{1}{x} + x}} \]
  5. Final simplification99.8%

    \[\leadsto \frac{1}{x + \frac{1}{x}} \]

Alternatives

Alternative 1
Accuracy99.2%
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -0.86:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{elif}\;x \leq 0.86:\\ \;\;\;\;x \cdot \left(1 - x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x}\\ \end{array} \]
Alternative 2
Accuracy98.9%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x}\\ \end{array} \]
Alternative 3
Accuracy51.6%
Cost64
\[x \]

Error

Reproduce?

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

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

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