(FPCore (x) :precision binary64 (/ x (+ (* x x) 1.0)))
(FPCore (x)
:precision binary64
(let* ((t_0
(+
(/ 1.0 x)
(+
(/ 1.0 (pow x 5.0))
(+ (/ -1.0 (pow x 3.0)) (/ -1.0 (pow x 7.0))))))
(t_1 (sqrt (pow (fma x x 1.0) -0.5))))
(if (<= x -220.46626152611887)
t_0
(if (<= x 0.03147942073716495)
(* (/ 1.0 (sqrt (fma x x 1.0))) (* t_1 (* x t_1)))
t_0))))double code(double x) {
return x / ((x * x) + 1.0);
}
double code(double x) {
double t_0 = (1.0 / x) + ((1.0 / pow(x, 5.0)) + ((-1.0 / pow(x, 3.0)) + (-1.0 / pow(x, 7.0))));
double t_1 = sqrt(pow(fma(x, x, 1.0), -0.5));
double tmp;
if (x <= -220.46626152611887) {
tmp = t_0;
} else if (x <= 0.03147942073716495) {
tmp = (1.0 / sqrt(fma(x, x, 1.0))) * (t_1 * (x * t_1));
} 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) + Float64(Float64(1.0 / (x ^ 5.0)) + Float64(Float64(-1.0 / (x ^ 3.0)) + Float64(-1.0 / (x ^ 7.0))))) t_1 = sqrt((fma(x, x, 1.0) ^ -0.5)) tmp = 0.0 if (x <= -220.46626152611887) tmp = t_0; elseif (x <= 0.03147942073716495) tmp = Float64(Float64(1.0 / sqrt(fma(x, x, 1.0))) * Float64(t_1 * Float64(x * t_1))); 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[(N[(1.0 / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Power[x, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[Power[N[(x * x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -220.46626152611887], t$95$0, If[LessEqual[x, 0.03147942073716495], N[(N[(1.0 / N[Sqrt[N[(x * x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * N[(x * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
t_0 := \frac{1}{x} + \left(\frac{1}{{x}^{5}} + \left(\frac{-1}{{x}^{3}} + \frac{-1}{{x}^{7}}\right)\right)\\
t_1 := \sqrt{{\left(\mathsf{fma}\left(x, x, 1\right)\right)}^{-0.5}}\\
\mathbf{if}\;x \leq -220.46626152611887:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 0.03147942073716495:\\
\;\;\;\;\frac{1}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}} \cdot \left(t_1 \cdot \left(x \cdot t_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
| Original | 14.9 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
if x < -220.466261526118871 or 0.031479420737164948 < x Initial program 29.5
Simplified29.5
Taylor expanded in x around inf 0.3
Simplified0.3
if -220.466261526118871 < x < 0.031479420737164948Initial program 0.0
Simplified0.0
Applied egg-rr0.0
Applied egg-rr0.0
Final simplification0.1
herbie shell --seed 2022213
(FPCore (x)
:name "x / (x^2 + 1)"
:precision binary64
:herbie-target
(/ 1.0 (+ x (/ 1.0 x)))
(/ x (+ (* x x) 1.0)))