(FPCore (x) :precision binary64 (/ x (+ (* x x) 1.0)))
(FPCore (x)
:precision binary64
(let* ((t_0 (- (/ 1.0 x) (pow x -3.0))))
(if (<= x -9128.442067303562)
t_0
(if (<= x 10462486.132127088) (/ x (fma x x 1.0)) t_0))))double code(double x) {
return x / ((x * x) + 1.0);
}
double code(double x) {
double t_0 = (1.0 / x) - pow(x, -3.0);
double tmp;
if (x <= -9128.442067303562) {
tmp = t_0;
} else if (x <= 10462486.132127088) {
tmp = x / fma(x, x, 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(x) return Float64(x / Float64(Float64(x * x) + 1.0)) end
function code(x) t_0 = Float64(Float64(1.0 / x) - (x ^ -3.0)) tmp = 0.0 if (x <= -9128.442067303562) tmp = t_0; elseif (x <= 10462486.132127088) tmp = Float64(x / fma(x, x, 1.0)); else tmp = t_0; end return tmp end
code[x_] := N[(x / N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(N[(1.0 / x), $MachinePrecision] - N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9128.442067303562], t$95$0, If[LessEqual[x, 10462486.132127088], N[(x / N[(x * x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
t_0 := \frac{1}{x} - {x}^{-3}\\
\mathbf{if}\;x \leq -9128.442067303562:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 10462486.132127088:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(x, x, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}




Bits error versus x
| Original | 14.7 |
|---|---|
| Target | 0.1 |
| Herbie | 0.0 |
if x < -9128.442067303562 or 10462486.132127088 < x Initial program 30.2
Simplified30.2
Taylor expanded in x around inf 0.0
Applied egg-rr0.0
if -9128.442067303562 < x < 10462486.132127088Initial program 0.0
Simplified0.0
Final simplification0.0
herbie shell --seed 2022146
(FPCore (x)
:name "x / (x^2 + 1)"
:precision binary64
:herbie-target
(/ 1.0 (+ x (/ 1.0 x)))
(/ x (+ (* x x) 1.0)))