
(FPCore (x) :precision binary64 (/ x (+ (* x x) 1.0)))
double code(double x) {
return x / ((x * x) + 1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x / ((x * x) + 1.0d0)
end function
public static double code(double x) {
return x / ((x * x) + 1.0);
}
def code(x): return x / ((x * x) + 1.0)
function code(x) return Float64(x / Float64(Float64(x * x) + 1.0)) end
function tmp = code(x) tmp = x / ((x * x) + 1.0); end
code[x_] := N[(x / N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x \cdot x + 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ x (+ (* x x) 1.0)))
double code(double x) {
return x / ((x * x) + 1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x / ((x * x) + 1.0d0)
end function
public static double code(double x) {
return x / ((x * x) + 1.0);
}
def code(x): return x / ((x * x) + 1.0)
function code(x) return Float64(x / Float64(Float64(x * x) + 1.0)) end
function tmp = code(x) tmp = x / ((x * x) + 1.0); end
code[x_] := N[(x / N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x \cdot x + 1}
\end{array}
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m)
:precision binary64
(*
x_s
(if (<= x_m 8000.0)
(/ (+ x_m (- (pow x_m 5.0) (pow x_m 3.0))) (+ 1.0 (pow x_m 6.0)))
(- (/ 1.0 x_m) (pow x_m -3.0)))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 8000.0) {
tmp = (x_m + (pow(x_m, 5.0) - pow(x_m, 3.0))) / (1.0 + pow(x_m, 6.0));
} else {
tmp = (1.0 / x_m) - pow(x_m, -3.0);
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8) :: tmp
if (x_m <= 8000.0d0) then
tmp = (x_m + ((x_m ** 5.0d0) - (x_m ** 3.0d0))) / (1.0d0 + (x_m ** 6.0d0))
else
tmp = (1.0d0 / x_m) - (x_m ** (-3.0d0))
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
double tmp;
if (x_m <= 8000.0) {
tmp = (x_m + (Math.pow(x_m, 5.0) - Math.pow(x_m, 3.0))) / (1.0 + Math.pow(x_m, 6.0));
} else {
tmp = (1.0 / x_m) - Math.pow(x_m, -3.0);
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): tmp = 0 if x_m <= 8000.0: tmp = (x_m + (math.pow(x_m, 5.0) - math.pow(x_m, 3.0))) / (1.0 + math.pow(x_m, 6.0)) else: tmp = (1.0 / x_m) - math.pow(x_m, -3.0) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) tmp = 0.0 if (x_m <= 8000.0) tmp = Float64(Float64(x_m + Float64((x_m ^ 5.0) - (x_m ^ 3.0))) / Float64(1.0 + (x_m ^ 6.0))); else tmp = Float64(Float64(1.0 / x_m) - (x_m ^ -3.0)); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m) tmp = 0.0; if (x_m <= 8000.0) tmp = (x_m + ((x_m ^ 5.0) - (x_m ^ 3.0))) / (1.0 + (x_m ^ 6.0)); else tmp = (1.0 / x_m) - (x_m ^ -3.0); end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * If[LessEqual[x$95$m, 8000.0], N[(N[(x$95$m + N[(N[Power[x$95$m, 5.0], $MachinePrecision] - N[Power[x$95$m, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Power[x$95$m, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / x$95$m), $MachinePrecision] - N[Power[x$95$m, -3.0], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 8000:\\
\;\;\;\;\frac{x\_m + \left({x\_m}^{5} - {x\_m}^{3}\right)}{1 + {x\_m}^{6}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x\_m} - {x\_m}^{-3}\\
\end{array}
\end{array}
if x < 8e3Initial program 84.3%
flip3-+75.7%
associate-/r/75.7%
pow375.7%
metadata-eval75.7%
+-commutative75.7%
pow375.7%
pow275.7%
pow-pow75.7%
metadata-eval75.7%
pow275.7%
pow275.7%
pow-prod-up75.7%
metadata-eval75.7%
metadata-eval75.7%
*-rgt-identity75.7%
pow275.7%
Applied egg-rr75.7%
associate-*l/75.7%
+-commutative75.7%
distribute-lft-out75.7%
distribute-lft-out--75.7%
*-rgt-identity75.7%
unpow275.7%
cube-mult75.7%
unsub-neg75.7%
mul-1-neg75.7%
*-commutative75.7%
pow-plus75.7%
metadata-eval75.7%
associate-+r+75.7%
+-commutative75.7%
mul-1-neg75.7%
unsub-neg75.7%
Simplified75.7%
if 8e3 < x Initial program 49.7%
flip-+23.4%
associate-/r/23.4%
metadata-eval23.4%
sub-neg23.4%
pow223.4%
pow223.4%
pow-prod-up23.3%
metadata-eval23.3%
metadata-eval23.3%
fma-neg23.3%
metadata-eval23.3%
Applied egg-rr23.3%
Taylor expanded in x around inf 100.0%
exp-to-pow100.0%
exp-neg100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
exp-to-pow100.0%
Simplified100.0%
Final simplification82.4%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m)
:precision binary64
(*
x_s
(if (<= x_m 10000.0)
(/ (- (pow x_m 3.0) x_m) (+ (pow x_m 4.0) -1.0))
(- (/ 1.0 x_m) (pow x_m -3.0)))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 10000.0) {
tmp = (pow(x_m, 3.0) - x_m) / (pow(x_m, 4.0) + -1.0);
} else {
tmp = (1.0 / x_m) - pow(x_m, -3.0);
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8) :: tmp
if (x_m <= 10000.0d0) then
tmp = ((x_m ** 3.0d0) - x_m) / ((x_m ** 4.0d0) + (-1.0d0))
else
tmp = (1.0d0 / x_m) - (x_m ** (-3.0d0))
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
double tmp;
if (x_m <= 10000.0) {
tmp = (Math.pow(x_m, 3.0) - x_m) / (Math.pow(x_m, 4.0) + -1.0);
} else {
tmp = (1.0 / x_m) - Math.pow(x_m, -3.0);
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): tmp = 0 if x_m <= 10000.0: tmp = (math.pow(x_m, 3.0) - x_m) / (math.pow(x_m, 4.0) + -1.0) else: tmp = (1.0 / x_m) - math.pow(x_m, -3.0) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) tmp = 0.0 if (x_m <= 10000.0) tmp = Float64(Float64((x_m ^ 3.0) - x_m) / Float64((x_m ^ 4.0) + -1.0)); else tmp = Float64(Float64(1.0 / x_m) - (x_m ^ -3.0)); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m) tmp = 0.0; if (x_m <= 10000.0) tmp = ((x_m ^ 3.0) - x_m) / ((x_m ^ 4.0) + -1.0); else tmp = (1.0 / x_m) - (x_m ^ -3.0); end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * If[LessEqual[x$95$m, 10000.0], N[(N[(N[Power[x$95$m, 3.0], $MachinePrecision] - x$95$m), $MachinePrecision] / N[(N[Power[x$95$m, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / x$95$m), $MachinePrecision] - N[Power[x$95$m, -3.0], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 10000:\\
\;\;\;\;\frac{{x\_m}^{3} - x\_m}{{x\_m}^{4} + -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x\_m} - {x\_m}^{-3}\\
\end{array}
\end{array}
if x < 1e4Initial program 84.3%
flip-+77.5%
associate-/r/77.5%
metadata-eval77.5%
sub-neg77.5%
pow277.5%
pow277.5%
pow-prod-up77.5%
metadata-eval77.5%
metadata-eval77.5%
fma-neg77.5%
metadata-eval77.5%
Applied egg-rr77.5%
associate-*l/77.3%
fma-udef77.3%
distribute-rgt-in77.3%
unpow377.3%
neg-mul-177.3%
*-rgt-identity77.3%
metadata-eval77.3%
div-inv77.3%
sub-neg77.3%
/-rgt-identity77.3%
Applied egg-rr77.3%
if 1e4 < x Initial program 49.7%
flip-+23.4%
associate-/r/23.4%
metadata-eval23.4%
sub-neg23.4%
pow223.4%
pow223.4%
pow-prod-up23.3%
metadata-eval23.3%
metadata-eval23.3%
fma-neg23.3%
metadata-eval23.3%
Applied egg-rr23.3%
Taylor expanded in x around inf 100.0%
exp-to-pow100.0%
exp-neg100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
exp-to-pow100.0%
Simplified100.0%
Final simplification83.6%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m)
:precision binary64
(*
x_s
(if (<= x_m 1000000.0)
(/ x_m (+ 1.0 (* x_m x_m)))
(- (/ 1.0 x_m) (pow x_m -3.0)))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 1000000.0) {
tmp = x_m / (1.0 + (x_m * x_m));
} else {
tmp = (1.0 / x_m) - pow(x_m, -3.0);
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8) :: tmp
if (x_m <= 1000000.0d0) then
tmp = x_m / (1.0d0 + (x_m * x_m))
else
tmp = (1.0d0 / x_m) - (x_m ** (-3.0d0))
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
double tmp;
if (x_m <= 1000000.0) {
tmp = x_m / (1.0 + (x_m * x_m));
} else {
tmp = (1.0 / x_m) - Math.pow(x_m, -3.0);
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): tmp = 0 if x_m <= 1000000.0: tmp = x_m / (1.0 + (x_m * x_m)) else: tmp = (1.0 / x_m) - math.pow(x_m, -3.0) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) tmp = 0.0 if (x_m <= 1000000.0) tmp = Float64(x_m / Float64(1.0 + Float64(x_m * x_m))); else tmp = Float64(Float64(1.0 / x_m) - (x_m ^ -3.0)); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m) tmp = 0.0; if (x_m <= 1000000.0) tmp = x_m / (1.0 + (x_m * x_m)); else tmp = (1.0 / x_m) - (x_m ^ -3.0); end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * If[LessEqual[x$95$m, 1000000.0], N[(x$95$m / N[(1.0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / x$95$m), $MachinePrecision] - N[Power[x$95$m, -3.0], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1000000:\\
\;\;\;\;\frac{x\_m}{1 + x\_m \cdot x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x\_m} - {x\_m}^{-3}\\
\end{array}
\end{array}
if x < 1e6Initial program 84.5%
if 1e6 < x Initial program 48.2%
flip-+21.2%
associate-/r/21.2%
metadata-eval21.2%
sub-neg21.2%
pow221.2%
pow221.2%
pow-prod-up21.2%
metadata-eval21.2%
metadata-eval21.2%
fma-neg21.2%
metadata-eval21.2%
Applied egg-rr21.2%
Taylor expanded in x around inf 100.0%
exp-to-pow100.0%
exp-neg100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
exp-to-pow100.0%
Simplified100.0%
Final simplification88.7%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s (if (<= x_m 20000000.0) (/ x_m (+ 1.0 (* x_m x_m))) (/ 1.0 x_m))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 20000000.0) {
tmp = x_m / (1.0 + (x_m * x_m));
} else {
tmp = 1.0 / x_m;
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8) :: tmp
if (x_m <= 20000000.0d0) then
tmp = x_m / (1.0d0 + (x_m * x_m))
else
tmp = 1.0d0 / x_m
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
double tmp;
if (x_m <= 20000000.0) {
tmp = x_m / (1.0 + (x_m * x_m));
} else {
tmp = 1.0 / x_m;
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): tmp = 0 if x_m <= 20000000.0: tmp = x_m / (1.0 + (x_m * x_m)) else: tmp = 1.0 / x_m return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) tmp = 0.0 if (x_m <= 20000000.0) tmp = Float64(x_m / Float64(1.0 + Float64(x_m * x_m))); else tmp = Float64(1.0 / x_m); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m) tmp = 0.0; if (x_m <= 20000000.0) tmp = x_m / (1.0 + (x_m * x_m)); else tmp = 1.0 / x_m; end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * If[LessEqual[x$95$m, 20000000.0], N[(x$95$m / N[(1.0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / x$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 20000000:\\
\;\;\;\;\frac{x\_m}{1 + x\_m \cdot x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x\_m}\\
\end{array}
\end{array}
if x < 2e7Initial program 84.5%
if 2e7 < x Initial program 48.2%
Taylor expanded in x around inf 100.0%
Final simplification88.7%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s (if (<= x_m 1.0) x_m (/ 1.0 x_m))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
double tmp;
if (x_m <= 1.0) {
tmp = x_m;
} else {
tmp = 1.0 / x_m;
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8) :: tmp
if (x_m <= 1.0d0) then
tmp = x_m
else
tmp = 1.0d0 / x_m
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
double tmp;
if (x_m <= 1.0) {
tmp = x_m;
} else {
tmp = 1.0 / x_m;
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): tmp = 0 if x_m <= 1.0: tmp = x_m else: tmp = 1.0 / x_m return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) tmp = 0.0 if (x_m <= 1.0) tmp = x_m; else tmp = Float64(1.0 / x_m); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m) tmp = 0.0; if (x_m <= 1.0) tmp = x_m; else tmp = 1.0 / x_m; end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * If[LessEqual[x$95$m, 1.0], x$95$m, N[(1.0 / x$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 1:\\
\;\;\;\;x\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x\_m}\\
\end{array}
\end{array}
if x < 1Initial program 84.3%
Taylor expanded in x around 0 68.3%
if 1 < x Initial program 49.7%
Taylor expanded in x around inf 99.2%
Final simplification76.8%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m) :precision binary64 (* x_s x_m))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m) {
return x_s * x_m;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
code = x_s * x_m
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m) {
return x_s * x_m;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m): return x_s * x_m
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m) return Float64(x_s * x_m) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m) tmp = x_s * x_m; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_] := N[(x$95$s * x$95$m), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x\_s \cdot x\_m
\end{array}
Initial program 74.7%
Taylor expanded in x around 0 50.4%
Final simplification50.4%
(FPCore (x) :precision binary64 (/ 1.0 (+ x (/ 1.0 x))))
double code(double x) {
return 1.0 / (x + (1.0 / x));
}
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 1.0 / (x + (1.0 / x));
}
def code(x): return 1.0 / (x + (1.0 / x))
function code(x) return Float64(1.0 / Float64(x + Float64(1.0 / x))) end
function tmp = code(x) tmp = 1.0 / (x + (1.0 / x)); end
code[x_] := N[(1.0 / N[(x + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + \frac{1}{x}}
\end{array}
herbie shell --seed 2024040
(FPCore (x)
:name "x / (x^2 + 1)"
:precision binary64
:herbie-target
(/ 1.0 (+ x (/ 1.0 x)))
(/ x (+ (* x x) 1.0)))