
(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 (* (pow x -3.0) (+ 2.0 (fma 2.0 (pow x -4.0) (/ 2.0 (pow x 2.0))))))
double code(double x) {
return pow(x, -3.0) * (2.0 + fma(2.0, pow(x, -4.0), (2.0 / pow(x, 2.0))));
}
function code(x) return Float64((x ^ -3.0) * Float64(2.0 + fma(2.0, (x ^ -4.0), Float64(2.0 / (x ^ 2.0))))) end
code[x_] := N[(N[Power[x, -3.0], $MachinePrecision] * N[(2.0 + N[(2.0 * N[Power[x, -4.0], $MachinePrecision] + N[(2.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{-3} \cdot \left(2 + \mathsf{fma}\left(2, {x}^{-4}, \frac{2}{{x}^{2}}\right)\right)
\end{array}
Initial program 72.2%
+-commutative72.2%
associate-+r-72.1%
sub-neg72.1%
remove-double-neg72.1%
neg-sub072.1%
associate-+l-72.1%
neg-sub072.1%
distribute-neg-frac272.1%
distribute-frac-neg272.1%
associate-+r+72.2%
+-commutative72.2%
remove-double-neg72.2%
distribute-neg-frac272.2%
sub0-neg72.2%
associate-+l-72.2%
neg-sub072.2%
Simplified72.2%
Taylor expanded in x around inf 99.2%
associate-*r/99.2%
metadata-eval99.2%
Simplified99.2%
*-un-lft-identity99.2%
div-inv99.2%
+-commutative99.2%
div-inv99.2%
fma-define99.2%
pow-flip99.2%
metadata-eval99.2%
pow-flip99.9%
metadata-eval99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
*-commutative99.9%
Simplified99.9%
(FPCore (x) :precision binary64 (* (pow x -3.0) (+ 2.0 (/ 2.0 (pow x 2.0)))))
double code(double x) {
return pow(x, -3.0) * (2.0 + (2.0 / pow(x, 2.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** (-3.0d0)) * (2.0d0 + (2.0d0 / (x ** 2.0d0)))
end function
public static double code(double x) {
return Math.pow(x, -3.0) * (2.0 + (2.0 / Math.pow(x, 2.0)));
}
def code(x): return math.pow(x, -3.0) * (2.0 + (2.0 / math.pow(x, 2.0)))
function code(x) return Float64((x ^ -3.0) * Float64(2.0 + Float64(2.0 / (x ^ 2.0)))) end
function tmp = code(x) tmp = (x ^ -3.0) * (2.0 + (2.0 / (x ^ 2.0))); end
code[x_] := N[(N[Power[x, -3.0], $MachinePrecision] * N[(2.0 + N[(2.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{-3} \cdot \left(2 + \frac{2}{{x}^{2}}\right)
\end{array}
Initial program 72.2%
+-commutative72.2%
associate-+r-72.1%
sub-neg72.1%
remove-double-neg72.1%
neg-sub072.1%
associate-+l-72.1%
neg-sub072.1%
distribute-neg-frac272.1%
distribute-frac-neg272.1%
associate-+r+72.2%
+-commutative72.2%
remove-double-neg72.2%
distribute-neg-frac272.2%
sub0-neg72.2%
associate-+l-72.2%
neg-sub072.2%
Simplified72.2%
Taylor expanded in x around inf 99.2%
associate-*r/99.2%
metadata-eval99.2%
Simplified99.2%
*-un-lft-identity99.2%
div-inv99.2%
+-commutative99.2%
div-inv99.2%
fma-define99.2%
pow-flip99.2%
metadata-eval99.2%
pow-flip99.9%
metadata-eval99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 99.8%
(FPCore (x) :precision binary64 (* (/ (+ 2.0 (/ 2.0 (pow x 2.0))) x) (* (/ 1.0 x) (/ 1.0 x))))
double code(double x) {
return ((2.0 + (2.0 / pow(x, 2.0))) / x) * ((1.0 / x) * (1.0 / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((2.0d0 + (2.0d0 / (x ** 2.0d0))) / x) * ((1.0d0 / x) * (1.0d0 / x))
end function
public static double code(double x) {
return ((2.0 + (2.0 / Math.pow(x, 2.0))) / x) * ((1.0 / x) * (1.0 / x));
}
def code(x): return ((2.0 + (2.0 / math.pow(x, 2.0))) / x) * ((1.0 / x) * (1.0 / x))
function code(x) return Float64(Float64(Float64(2.0 + Float64(2.0 / (x ^ 2.0))) / x) * Float64(Float64(1.0 / x) * Float64(1.0 / x))) end
function tmp = code(x) tmp = ((2.0 + (2.0 / (x ^ 2.0))) / x) * ((1.0 / x) * (1.0 / x)); end
code[x_] := N[(N[(N[(2.0 + N[(2.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 + \frac{2}{{x}^{2}}}{x} \cdot \left(\frac{1}{x} \cdot \frac{1}{x}\right)
\end{array}
Initial program 72.2%
+-commutative72.2%
associate-+r-72.1%
sub-neg72.1%
remove-double-neg72.1%
neg-sub072.1%
associate-+l-72.1%
neg-sub072.1%
distribute-neg-frac272.1%
distribute-frac-neg272.1%
associate-+r+72.2%
+-commutative72.2%
remove-double-neg72.2%
distribute-neg-frac272.2%
sub0-neg72.2%
associate-+l-72.2%
neg-sub072.2%
Simplified72.2%
Taylor expanded in x around inf 99.2%
associate-*r/99.2%
metadata-eval99.2%
Simplified99.2%
*-un-lft-identity99.2%
unpow399.1%
unpow299.1%
times-frac99.7%
pow-flip99.7%
metadata-eval99.7%
+-commutative99.7%
div-inv99.7%
fma-define99.7%
pow-flip99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 99.6%
metadata-eval99.6%
pow-prod-up99.5%
inv-pow99.5%
inv-pow99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x) :precision binary64 (* (/ 1.0 (* x x)) (/ (+ 2.0 (/ 2.0 (pow x 2.0))) x)))
double code(double x) {
return (1.0 / (x * x)) * ((2.0 + (2.0 / pow(x, 2.0))) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x * x)) * ((2.0d0 + (2.0d0 / (x ** 2.0d0))) / x)
end function
public static double code(double x) {
return (1.0 / (x * x)) * ((2.0 + (2.0 / Math.pow(x, 2.0))) / x);
}
def code(x): return (1.0 / (x * x)) * ((2.0 + (2.0 / math.pow(x, 2.0))) / x)
function code(x) return Float64(Float64(1.0 / Float64(x * x)) * Float64(Float64(2.0 + Float64(2.0 / (x ^ 2.0))) / x)) end
function tmp = code(x) tmp = (1.0 / (x * x)) * ((2.0 + (2.0 / (x ^ 2.0))) / x); end
code[x_] := N[(N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 + N[(2.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot x} \cdot \frac{2 + \frac{2}{{x}^{2}}}{x}
\end{array}
Initial program 72.2%
+-commutative72.2%
associate-+r-72.1%
sub-neg72.1%
remove-double-neg72.1%
neg-sub072.1%
associate-+l-72.1%
neg-sub072.1%
distribute-neg-frac272.1%
distribute-frac-neg272.1%
associate-+r+72.2%
+-commutative72.2%
remove-double-neg72.2%
distribute-neg-frac272.2%
sub0-neg72.2%
associate-+l-72.2%
neg-sub072.2%
Simplified72.2%
Taylor expanded in x around inf 99.2%
associate-*r/99.2%
metadata-eval99.2%
Simplified99.2%
*-un-lft-identity99.2%
unpow399.1%
unpow299.1%
times-frac99.7%
pow-flip99.7%
metadata-eval99.7%
+-commutative99.7%
div-inv99.7%
fma-define99.7%
pow-flip99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 99.6%
metadata-eval99.6%
pow-prod-up99.5%
inv-pow99.5%
inv-pow99.5%
frac-2neg99.5%
metadata-eval99.5%
pow199.5%
metadata-eval99.5%
sqrt-pow184.3%
pow284.3%
sqr-neg84.3%
sqrt-prod32.1%
add-sqr-sqrt70.5%
clear-num70.5%
frac-times70.5%
metadata-eval70.5%
frac-2neg70.5%
pow170.5%
metadata-eval70.5%
sqrt-pow185.8%
pow285.8%
sqr-neg85.8%
sqrt-prod47.3%
add-sqr-sqrt99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x) :precision binary64 (* (pow x -3.0) 2.0))
double code(double x) {
return pow(x, -3.0) * 2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** (-3.0d0)) * 2.0d0
end function
public static double code(double x) {
return Math.pow(x, -3.0) * 2.0;
}
def code(x): return math.pow(x, -3.0) * 2.0
function code(x) return Float64((x ^ -3.0) * 2.0) end
function tmp = code(x) tmp = (x ^ -3.0) * 2.0; end
code[x_] := N[(N[Power[x, -3.0], $MachinePrecision] * 2.0), $MachinePrecision]
\begin{array}{l}
\\
{x}^{-3} \cdot 2
\end{array}
Initial program 72.2%
+-commutative72.2%
associate-+r-72.1%
sub-neg72.1%
remove-double-neg72.1%
neg-sub072.1%
associate-+l-72.1%
neg-sub072.1%
distribute-neg-frac272.1%
distribute-frac-neg272.1%
associate-+r+72.2%
+-commutative72.2%
remove-double-neg72.2%
distribute-neg-frac272.2%
sub0-neg72.2%
associate-+l-72.2%
neg-sub072.2%
Simplified72.2%
Taylor expanded in x around inf 98.6%
div-inv98.6%
pow-flip99.2%
metadata-eval99.2%
Applied egg-rr99.2%
Final simplification99.2%
(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 72.2%
Final simplification72.2%
(FPCore (x) :precision binary64 (+ (/ (+ 1.0 (/ 1.0 x)) x) (/ -1.0 x)))
double code(double x) {
return ((1.0 + (1.0 / x)) / x) + (-1.0 / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 + (1.0d0 / x)) / x) + ((-1.0d0) / x)
end function
public static double code(double x) {
return ((1.0 + (1.0 / x)) / x) + (-1.0 / x);
}
def code(x): return ((1.0 + (1.0 / x)) / x) + (-1.0 / x)
function code(x) return Float64(Float64(Float64(1.0 + Float64(1.0 / x)) / x) + Float64(-1.0 / x)) end
function tmp = code(x) tmp = ((1.0 + (1.0 / x)) / x) + (-1.0 / x); end
code[x_] := N[(N[(N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 + \frac{1}{x}}{x} + \frac{-1}{x}
\end{array}
Initial program 72.2%
+-commutative72.2%
associate-+r-72.1%
sub-neg72.1%
remove-double-neg72.1%
neg-sub072.1%
associate-+l-72.1%
neg-sub072.1%
distribute-neg-frac272.1%
distribute-frac-neg272.1%
associate-+r+72.2%
+-commutative72.2%
remove-double-neg72.2%
distribute-neg-frac272.2%
sub0-neg72.2%
associate-+l-72.2%
neg-sub072.2%
Simplified72.2%
Taylor expanded in x around inf 71.2%
Taylor expanded in x around inf 71.2%
(FPCore (x) :precision binary64 (+ (/ -1.0 x) (/ 1.0 (+ x -1.0))))
double code(double x) {
return (-1.0 / x) + (1.0 / (x + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-1.0d0) / x) + (1.0d0 / (x + (-1.0d0)))
end function
public static double code(double x) {
return (-1.0 / x) + (1.0 / (x + -1.0));
}
def code(x): return (-1.0 / x) + (1.0 / (x + -1.0))
function code(x) return Float64(Float64(-1.0 / x) + Float64(1.0 / Float64(x + -1.0))) end
function tmp = code(x) tmp = (-1.0 / x) + (1.0 / (x + -1.0)); end
code[x_] := N[(N[(-1.0 / x), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{x} + \frac{1}{x + -1}
\end{array}
Initial program 72.2%
+-commutative72.2%
associate-+r-72.1%
sub-neg72.1%
remove-double-neg72.1%
neg-sub072.1%
associate-+l-72.1%
neg-sub072.1%
distribute-neg-frac272.1%
distribute-frac-neg272.1%
associate-+r+72.2%
+-commutative72.2%
remove-double-neg72.2%
distribute-neg-frac272.2%
sub0-neg72.2%
associate-+l-72.2%
neg-sub072.2%
Simplified72.2%
Taylor expanded in x around inf 71.2%
Final simplification71.2%
(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(Float64(1.0 / x) + Float64(-1.0 / x)) end
function tmp = code(x) tmp = (1.0 / x) + (-1.0 / x); end
code[x_] := N[(N[(1.0 / x), $MachinePrecision] + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x} + \frac{-1}{x}
\end{array}
Initial program 72.2%
+-commutative72.2%
associate-+r-72.1%
sub-neg72.1%
remove-double-neg72.1%
neg-sub072.1%
associate-+l-72.1%
neg-sub072.1%
distribute-neg-frac272.1%
distribute-frac-neg272.1%
associate-+r+72.2%
+-commutative72.2%
remove-double-neg72.2%
distribute-neg-frac272.2%
sub0-neg72.2%
associate-+l-72.2%
neg-sub072.2%
Simplified72.2%
Taylor expanded in x around inf 71.2%
Taylor expanded in x around inf 71.0%
(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 72.2%
+-commutative72.2%
associate-+r-72.1%
sub-neg72.1%
remove-double-neg72.1%
neg-sub072.1%
associate-+l-72.1%
neg-sub072.1%
distribute-neg-frac272.1%
distribute-frac-neg272.1%
associate-+r+72.2%
+-commutative72.2%
remove-double-neg72.2%
distribute-neg-frac272.2%
sub0-neg72.2%
associate-+l-72.2%
neg-sub072.2%
Simplified72.2%
Taylor expanded in x around inf 71.2%
frac-2neg71.2%
metadata-eval71.2%
clear-num71.2%
frac-add71.2%
frac-2neg71.2%
pow171.2%
metadata-eval71.2%
sqrt-pow110.9%
pow210.9%
sqr-neg10.9%
sqrt-prod22.7%
add-sqr-sqrt51.6%
metadata-eval51.6%
frac-2neg51.6%
pow151.6%
metadata-eval51.6%
sqrt-pow152.2%
pow252.2%
sqr-neg52.2%
sqrt-prod23.3%
add-sqr-sqrt52.7%
metadata-eval52.7%
Applied egg-rr52.7%
*-rgt-identity52.7%
+-commutative52.7%
/-rgt-identity52.7%
*-commutative52.7%
*-commutative52.7%
mul-1-neg52.7%
unsub-neg52.7%
+-commutative52.7%
distribute-neg-in52.7%
metadata-eval52.7%
unsub-neg52.7%
/-rgt-identity52.7%
*-commutative52.7%
distribute-neg-in52.7%
mul-1-neg52.7%
metadata-eval52.7%
+-commutative52.7%
mul-1-neg52.7%
unsub-neg52.7%
Simplified52.7%
Taylor expanded in x around 0 6.2%
(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 72.2%
+-commutative72.2%
associate-+r-72.1%
sub-neg72.1%
remove-double-neg72.1%
neg-sub072.1%
associate-+l-72.1%
neg-sub072.1%
distribute-neg-frac272.1%
distribute-frac-neg272.1%
associate-+r+72.2%
+-commutative72.2%
remove-double-neg72.2%
distribute-neg-frac272.2%
sub0-neg72.2%
associate-+l-72.2%
neg-sub072.2%
Simplified72.2%
Taylor expanded in x around inf 71.2%
Taylor expanded in x around 0 5.2%
(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 72.2%
+-commutative72.2%
associate-+r-72.1%
sub-neg72.1%
remove-double-neg72.1%
neg-sub072.1%
associate-+l-72.1%
neg-sub072.1%
distribute-neg-frac272.1%
distribute-frac-neg272.1%
associate-+r+72.2%
+-commutative72.2%
remove-double-neg72.2%
distribute-neg-frac272.2%
sub0-neg72.2%
associate-+l-72.2%
neg-sub072.2%
Simplified72.2%
Taylor expanded in x around 0 5.1%
(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 2024110
(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))))