
(FPCore (x) :precision binary64 (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / (x + 1.0d0)) - (2.0d0 / x)) + (1.0d0 / (x - 1.0d0))
end function
public static double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
def code(x): return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0))
function code(x) return Float64(Float64(Float64(1.0 / Float64(x + 1.0)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x - 1.0))) end
function tmp = code(x) tmp = ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0)); end
code[x_] := N[(N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / (x + 1.0d0)) - (2.0d0 / x)) + (1.0d0 / (x - 1.0d0))
end function
public static double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
def code(x): return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0))
function code(x) return Float64(Float64(Float64(1.0 / Float64(x + 1.0)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x - 1.0))) end
function tmp = code(x) tmp = ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0)); end
code[x_] := N[(N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\end{array}
(FPCore (x) :precision binary64 (* (fma 2.0 (pow x -2.0) 2.0) (pow x -3.0)))
double code(double x) {
return fma(2.0, pow(x, -2.0), 2.0) * pow(x, -3.0);
}
function code(x) return Float64(fma(2.0, (x ^ -2.0), 2.0) * (x ^ -3.0)) end
code[x_] := N[(N[(2.0 * N[Power[x, -2.0], $MachinePrecision] + 2.0), $MachinePrecision] * N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(2, {x}^{-2}, 2\right) \cdot {x}^{-3}
\end{array}
Initial program 67.7%
Simplified67.7%
Taylor expanded in x around inf 98.6%
associate-*r/98.6%
metadata-eval98.6%
Simplified98.6%
div-inv98.6%
+-commutative98.6%
div-inv98.6%
fma-define98.6%
pow-flip98.6%
metadata-eval98.6%
pow-flip99.2%
metadata-eval99.2%
Applied egg-rr99.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (* x (+ x -1.0))))
(if (<= (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (+ x -1.0))) 2e-29)
(pow x -3.0)
(/ (+ t_0 (* (+ x 1.0) (- 2.0 x))) (* (+ x 1.0) t_0)))))
double code(double x) {
double t_0 = x * (x + -1.0);
double tmp;
if ((((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 2e-29) {
tmp = pow(x, -3.0);
} else {
tmp = (t_0 + ((x + 1.0) * (2.0 - x))) / ((x + 1.0) * t_0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = x * (x + (-1.0d0))
if ((((1.0d0 / (x + 1.0d0)) - (2.0d0 / x)) + (1.0d0 / (x + (-1.0d0)))) <= 2d-29) then
tmp = x ** (-3.0d0)
else
tmp = (t_0 + ((x + 1.0d0) * (2.0d0 - x))) / ((x + 1.0d0) * t_0)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = x * (x + -1.0);
double tmp;
if ((((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 2e-29) {
tmp = Math.pow(x, -3.0);
} else {
tmp = (t_0 + ((x + 1.0) * (2.0 - x))) / ((x + 1.0) * t_0);
}
return tmp;
}
def code(x): t_0 = x * (x + -1.0) tmp = 0 if (((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 2e-29: tmp = math.pow(x, -3.0) else: tmp = (t_0 + ((x + 1.0) * (2.0 - x))) / ((x + 1.0) * t_0) return tmp
function code(x) t_0 = Float64(x * Float64(x + -1.0)) tmp = 0.0 if (Float64(Float64(Float64(1.0 / Float64(x + 1.0)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x + -1.0))) <= 2e-29) tmp = x ^ -3.0; else tmp = Float64(Float64(t_0 + Float64(Float64(x + 1.0) * Float64(2.0 - x))) / Float64(Float64(x + 1.0) * t_0)); end return tmp end
function tmp_2 = code(x) t_0 = x * (x + -1.0); tmp = 0.0; if ((((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 2e-29) tmp = x ^ -3.0; else tmp = (t_0 + ((x + 1.0) * (2.0 - x))) / ((x + 1.0) * t_0); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e-29], N[Power[x, -3.0], $MachinePrecision], N[(N[(t$95$0 + N[(N[(x + 1.0), $MachinePrecision] * N[(2.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x + -1\right)\\
\mathbf{if}\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x + -1} \leq 2 \cdot 10^{-29}:\\
\;\;\;\;{x}^{-3}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 + \left(x + 1\right) \cdot \left(2 - x\right)}{\left(x + 1\right) \cdot t\_0}\\
\end{array}
\end{array}
if (+.f64 (-.f64 (/.f64 #s(literal 1 binary64) (+.f64 x #s(literal 1 binary64))) (/.f64 #s(literal 2 binary64) x)) (/.f64 #s(literal 1 binary64) (-.f64 x #s(literal 1 binary64)))) < 1.99999999999999989e-29Initial program 68.1%
Simplified68.1%
Taylor expanded in x around -inf 67.9%
associate-*r/67.9%
distribute-lft-in67.9%
metadata-eval67.9%
mul-1-neg67.9%
mul-1-neg67.9%
distribute-neg-frac267.9%
distribute-frac-neg267.9%
remove-double-neg67.9%
Simplified67.9%
Taylor expanded in x around 0 71.8%
metadata-eval71.8%
cube-div71.8%
Simplified71.8%
inv-pow71.8%
pow-pow71.8%
metadata-eval71.8%
*-un-lft-identity71.8%
Applied egg-rr71.8%
*-lft-identity71.8%
Simplified71.8%
if 1.99999999999999989e-29 < (+.f64 (-.f64 (/.f64 #s(literal 1 binary64) (+.f64 x #s(literal 1 binary64))) (/.f64 #s(literal 2 binary64) x)) (/.f64 #s(literal 1 binary64) (-.f64 x #s(literal 1 binary64)))) Initial program 51.3%
Simplified51.4%
+-commutative51.4%
frac-add51.9%
div-inv52.0%
fma-define53.7%
*-rgt-identity53.7%
+-commutative53.7%
distribute-rgt-in53.7%
metadata-eval53.7%
metadata-eval53.7%
fma-define53.7%
metadata-eval53.7%
distribute-rgt-in53.7%
neg-mul-153.7%
sub-neg53.7%
pow253.7%
Applied egg-rr53.7%
Simplified51.1%
Taylor expanded in x around 0 52.2%
mul-1-neg52.2%
unsub-neg52.2%
Simplified52.2%
associate-/l/51.9%
frac-add83.1%
*-un-lft-identity83.1%
Applied egg-rr83.1%
Final simplification72.0%
(FPCore (x) :precision binary64 (* 2.0 (pow x -3.0)))
double code(double x) {
return 2.0 * pow(x, -3.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 2.0d0 * (x ** (-3.0d0))
end function
public static double code(double x) {
return 2.0 * Math.pow(x, -3.0);
}
def code(x): return 2.0 * math.pow(x, -3.0)
function code(x) return Float64(2.0 * (x ^ -3.0)) end
function tmp = code(x) tmp = 2.0 * (x ^ -3.0); end
code[x_] := N[(2.0 * N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot {x}^{-3}
\end{array}
Initial program 67.7%
Simplified67.7%
Taylor expanded in x around inf 98.0%
div-inv98.0%
pow-flip98.6%
metadata-eval98.6%
Applied egg-rr98.6%
(FPCore (x) :precision binary64 (/ (+ (+ x -1.0) (* (+ x 1.0) (+ (/ 2.0 x) -1.0))) (* (+ x 1.0) (+ x -1.0))))
double code(double x) {
return ((x + -1.0) + ((x + 1.0) * ((2.0 / x) + -1.0))) / ((x + 1.0) * (x + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x + (-1.0d0)) + ((x + 1.0d0) * ((2.0d0 / x) + (-1.0d0)))) / ((x + 1.0d0) * (x + (-1.0d0)))
end function
public static double code(double x) {
return ((x + -1.0) + ((x + 1.0) * ((2.0 / x) + -1.0))) / ((x + 1.0) * (x + -1.0));
}
def code(x): return ((x + -1.0) + ((x + 1.0) * ((2.0 / x) + -1.0))) / ((x + 1.0) * (x + -1.0))
function code(x) return Float64(Float64(Float64(x + -1.0) + Float64(Float64(x + 1.0) * Float64(Float64(2.0 / x) + -1.0))) / Float64(Float64(x + 1.0) * Float64(x + -1.0))) end
function tmp = code(x) tmp = ((x + -1.0) + ((x + 1.0) * ((2.0 / x) + -1.0))) / ((x + 1.0) * (x + -1.0)); end
code[x_] := N[(N[(N[(x + -1.0), $MachinePrecision] + N[(N[(x + 1.0), $MachinePrecision] * N[(N[(2.0 / x), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x + -1\right) + \left(x + 1\right) \cdot \left(\frac{2}{x} + -1\right)}{\left(x + 1\right) \cdot \left(x + -1\right)}
\end{array}
Initial program 67.7%
Simplified67.7%
+-commutative67.7%
frac-add18.3%
div-inv17.6%
fma-define7.7%
*-rgt-identity7.7%
+-commutative7.7%
distribute-rgt-in7.7%
metadata-eval7.7%
metadata-eval7.7%
fma-define7.7%
metadata-eval7.7%
distribute-rgt-in7.7%
neg-mul-17.7%
sub-neg7.7%
pow27.7%
Applied egg-rr7.7%
Simplified67.4%
Taylor expanded in x around inf 67.8%
sub-neg67.8%
associate-*r/67.8%
metadata-eval67.8%
metadata-eval67.8%
Simplified67.8%
frac-add67.8%
*-un-lft-identity67.8%
associate--l+67.8%
metadata-eval67.8%
Applied egg-rr67.8%
(FPCore (x) :precision binary64 (+ (/ 1.0 (+ x 1.0)) (/ (/ (- 2.0 x) x) (+ x -1.0))))
double code(double x) {
return (1.0 / (x + 1.0)) + (((2.0 - x) / x) / (x + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x + 1.0d0)) + (((2.0d0 - x) / x) / (x + (-1.0d0)))
end function
public static double code(double x) {
return (1.0 / (x + 1.0)) + (((2.0 - x) / x) / (x + -1.0));
}
def code(x): return (1.0 / (x + 1.0)) + (((2.0 - x) / x) / (x + -1.0))
function code(x) return Float64(Float64(1.0 / Float64(x + 1.0)) + Float64(Float64(Float64(2.0 - x) / x) / Float64(x + -1.0))) end
function tmp = code(x) tmp = (1.0 / (x + 1.0)) + (((2.0 - x) / x) / (x + -1.0)); end
code[x_] := N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(2.0 - x), $MachinePrecision] / x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + 1} + \frac{\frac{2 - x}{x}}{x + -1}
\end{array}
Initial program 67.7%
Simplified67.7%
+-commutative67.7%
frac-add18.3%
div-inv17.6%
fma-define7.7%
*-rgt-identity7.7%
+-commutative7.7%
distribute-rgt-in7.7%
metadata-eval7.7%
metadata-eval7.7%
fma-define7.7%
metadata-eval7.7%
distribute-rgt-in7.7%
neg-mul-17.7%
sub-neg7.7%
pow27.7%
Applied egg-rr7.7%
Simplified67.4%
Taylor expanded in x around 0 67.8%
mul-1-neg67.8%
unsub-neg67.8%
Simplified67.8%
(FPCore (x) :precision binary64 (+ (/ 1.0 (+ x 1.0)) (+ (/ -2.0 x) (/ 1.0 (+ x -1.0)))))
double code(double x) {
return (1.0 / (x + 1.0)) + ((-2.0 / x) + (1.0 / (x + -1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x + 1.0d0)) + (((-2.0d0) / x) + (1.0d0 / (x + (-1.0d0))))
end function
public static double code(double x) {
return (1.0 / (x + 1.0)) + ((-2.0 / x) + (1.0 / (x + -1.0)));
}
def code(x): return (1.0 / (x + 1.0)) + ((-2.0 / x) + (1.0 / (x + -1.0)))
function code(x) return Float64(Float64(1.0 / Float64(x + 1.0)) + Float64(Float64(-2.0 / x) + Float64(1.0 / Float64(x + -1.0)))) end
function tmp = code(x) tmp = (1.0 / (x + 1.0)) + ((-2.0 / x) + (1.0 / (x + -1.0))); end
code[x_] := N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-2.0 / x), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + 1} + \left(\frac{-2}{x} + \frac{1}{x + -1}\right)
\end{array}
Initial program 67.7%
Simplified67.7%
Final simplification67.7%
(FPCore (x) :precision binary64 (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (+ x -1.0))))
double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / (x + 1.0d0)) - (2.0d0 / x)) + (1.0d0 / (x + (-1.0d0)))
end function
public static double code(double x) {
return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0));
}
def code(x): return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))
function code(x) return Float64(Float64(Float64(1.0 / Float64(x + 1.0)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x + -1.0))) end
function tmp = code(x) tmp = ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0)); end
code[x_] := N[(N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x + -1}
\end{array}
Initial program 67.7%
Final simplification67.7%
(FPCore (x) :precision binary64 (+ (/ 1.0 (+ x 1.0)) (/ (+ -1.0 (/ 1.0 x)) x)))
double code(double x) {
return (1.0 / (x + 1.0)) + ((-1.0 + (1.0 / x)) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x + 1.0d0)) + (((-1.0d0) + (1.0d0 / x)) / x)
end function
public static double code(double x) {
return (1.0 / (x + 1.0)) + ((-1.0 + (1.0 / x)) / x);
}
def code(x): return (1.0 / (x + 1.0)) + ((-1.0 + (1.0 / x)) / x)
function code(x) return Float64(Float64(1.0 / Float64(x + 1.0)) + Float64(Float64(-1.0 + Float64(1.0 / x)) / x)) end
function tmp = code(x) tmp = (1.0 / (x + 1.0)) + ((-1.0 + (1.0 / x)) / x); end
code[x_] := N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + 1} + \frac{-1 + \frac{1}{x}}{x}
\end{array}
Initial program 67.7%
Simplified67.7%
Taylor expanded in x around inf 66.3%
Final simplification66.3%
(FPCore (x) :precision binary64 (+ (/ 1.0 (+ x 1.0)) (/ -1.0 x)))
double code(double x) {
return (1.0 / (x + 1.0)) + (-1.0 / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x + 1.0d0)) + ((-1.0d0) / x)
end function
public static double code(double x) {
return (1.0 / (x + 1.0)) + (-1.0 / x);
}
def code(x): return (1.0 / (x + 1.0)) + (-1.0 / x)
function code(x) return Float64(Float64(1.0 / Float64(x + 1.0)) + Float64(-1.0 / x)) end
function tmp = code(x) tmp = (1.0 / (x + 1.0)) + (-1.0 / x); end
code[x_] := N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + 1} + \frac{-1}{x}
\end{array}
Initial program 67.7%
Simplified67.7%
Taylor expanded in x around inf 66.0%
Final simplification66.0%
(FPCore (x) :precision binary64 (+ (/ 1.0 (+ x 1.0)) (/ 1.0 x)))
double code(double x) {
return (1.0 / (x + 1.0)) + (1.0 / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x + 1.0d0)) + (1.0d0 / x)
end function
public static double code(double x) {
return (1.0 / (x + 1.0)) + (1.0 / x);
}
def code(x): return (1.0 / (x + 1.0)) + (1.0 / x)
function code(x) return Float64(Float64(1.0 / Float64(x + 1.0)) + Float64(1.0 / x)) end
function tmp = code(x) tmp = (1.0 / (x + 1.0)) + (1.0 / x); end
code[x_] := N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + 1} + \frac{1}{x}
\end{array}
Initial program 67.7%
Simplified67.7%
Taylor expanded in x around inf 66.0%
*-un-lft-identity66.0%
+-commutative66.0%
add-sqr-sqrt20.4%
sqrt-unprod12.7%
frac-times12.0%
metadata-eval12.0%
metadata-eval12.0%
frac-times12.7%
sqrt-prod3.0%
add-sqr-sqrt6.4%
Applied egg-rr6.4%
*-lft-identity6.4%
+-commutative6.4%
Simplified6.4%
Final simplification6.4%
(FPCore (x) :precision binary64 (/ -1.0 x))
double code(double x) {
return -1.0 / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-1.0d0) / x
end function
public static double code(double x) {
return -1.0 / x;
}
def code(x): return -1.0 / x
function code(x) return Float64(-1.0 / x) end
function tmp = code(x) tmp = -1.0 / x; end
code[x_] := N[(-1.0 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{x}
\end{array}
Initial program 67.7%
Simplified67.7%
Taylor expanded in x around inf 66.0%
Taylor expanded in x around 0 5.0%
(FPCore (x) :precision binary64 (/ -2.0 x))
double code(double x) {
return -2.0 / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-2.0d0) / x
end function
public static double code(double x) {
return -2.0 / x;
}
def code(x): return -2.0 / x
function code(x) return Float64(-2.0 / x) end
function tmp = code(x) tmp = -2.0 / x; end
code[x_] := N[(-2.0 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{-2}{x}
\end{array}
Initial program 67.7%
Simplified67.7%
Taylor expanded in x around 0 5.0%
(FPCore (x) :precision binary64 (/ 2.0 (* x (- (* x x) 1.0))))
double code(double x) {
return 2.0 / (x * ((x * x) - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 2.0d0 / (x * ((x * x) - 1.0d0))
end function
public static double code(double x) {
return 2.0 / (x * ((x * x) - 1.0));
}
def code(x): return 2.0 / (x * ((x * x) - 1.0))
function code(x) return Float64(2.0 / Float64(x * Float64(Float64(x * x) - 1.0))) end
function tmp = code(x) tmp = 2.0 / (x * ((x * x) - 1.0)); end
code[x_] := N[(2.0 / N[(x * N[(N[(x * x), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{x \cdot \left(x \cdot x - 1\right)}
\end{array}
herbie shell --seed 2024100
(FPCore (x)
:name "3frac (problem 3.3.3)"
:precision binary64
:pre (> (fabs x) 1.0)
:alt
(/ 2.0 (* x (- (* x x) 1.0)))
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))