
(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 (/ (+ (/ 2.0 (* x x)) (+ 2.0 (/ 2.0 (pow x 4.0)))) (pow x 3.0)))
double code(double x) {
return ((2.0 / (x * x)) + (2.0 + (2.0 / pow(x, 4.0)))) / pow(x, 3.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((2.0d0 / (x * x)) + (2.0d0 + (2.0d0 / (x ** 4.0d0)))) / (x ** 3.0d0)
end function
public static double code(double x) {
return ((2.0 / (x * x)) + (2.0 + (2.0 / Math.pow(x, 4.0)))) / Math.pow(x, 3.0);
}
def code(x): return ((2.0 / (x * x)) + (2.0 + (2.0 / math.pow(x, 4.0)))) / math.pow(x, 3.0)
function code(x) return Float64(Float64(Float64(2.0 / Float64(x * x)) + Float64(2.0 + Float64(2.0 / (x ^ 4.0)))) / (x ^ 3.0)) end
function tmp = code(x) tmp = ((2.0 / (x * x)) + (2.0 + (2.0 / (x ^ 4.0)))) / (x ^ 3.0); end
code[x_] := N[(N[(N[(2.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(2.0 + N[(2.0 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{x \cdot x} + \left(2 + \frac{2}{{x}^{4}}\right)}{{x}^{3}}
\end{array}
Initial program 74.3%
+-commutative74.3%
associate-+r-74.3%
sub-neg74.3%
remove-double-neg74.3%
neg-sub074.3%
associate-+l-74.3%
neg-sub074.3%
distribute-neg-frac274.3%
distribute-frac-neg274.3%
associate-+r+74.3%
+-commutative74.3%
remove-double-neg74.3%
distribute-neg-frac274.3%
sub0-neg74.3%
associate-+l-74.3%
neg-sub074.3%
Simplified74.3%
Taylor expanded in x around inf 99.0%
associate-+r+99.0%
+-commutative99.0%
associate-+l+99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
unpow299.0%
Applied egg-rr99.0%
(FPCore (x) :precision binary64 (/ (+ 2.0 (/ 2.0 (* x x))) (pow x 3.0)))
double code(double x) {
return (2.0 + (2.0 / (x * x))) / pow(x, 3.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (2.0d0 + (2.0d0 / (x * x))) / (x ** 3.0d0)
end function
public static double code(double x) {
return (2.0 + (2.0 / (x * x))) / Math.pow(x, 3.0);
}
def code(x): return (2.0 + (2.0 / (x * x))) / math.pow(x, 3.0)
function code(x) return Float64(Float64(2.0 + Float64(2.0 / Float64(x * x))) / (x ^ 3.0)) end
function tmp = code(x) tmp = (2.0 + (2.0 / (x * x))) / (x ^ 3.0); end
code[x_] := N[(N[(2.0 + N[(2.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 + \frac{2}{x \cdot x}}{{x}^{3}}
\end{array}
Initial program 74.3%
+-commutative74.3%
associate-+r-74.3%
sub-neg74.3%
remove-double-neg74.3%
neg-sub074.3%
associate-+l-74.3%
neg-sub074.3%
distribute-neg-frac274.3%
distribute-frac-neg274.3%
associate-+r+74.3%
+-commutative74.3%
remove-double-neg74.3%
distribute-neg-frac274.3%
sub0-neg74.3%
associate-+l-74.3%
neg-sub074.3%
Simplified74.3%
Taylor expanded in x around inf 98.8%
associate-*r/98.8%
metadata-eval98.8%
Simplified98.8%
unpow299.0%
Applied egg-rr98.8%
(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 74.3%
+-commutative74.3%
associate-+r-74.3%
sub-neg74.3%
remove-double-neg74.3%
neg-sub074.3%
associate-+l-74.3%
neg-sub074.3%
distribute-neg-frac274.3%
distribute-frac-neg274.3%
associate-+r+74.3%
+-commutative74.3%
remove-double-neg74.3%
distribute-neg-frac274.3%
sub0-neg74.3%
associate-+l-74.3%
neg-sub074.3%
Simplified74.3%
Taylor expanded in x around inf 98.3%
div-inv98.3%
pow-flip98.7%
metadata-eval98.7%
Applied egg-rr98.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (* x (- -1.0 x))))
(if (<= (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (+ x -1.0))) 2e-32)
(/ (/ 1.0 x) (* (+ x -1.0) (/ x (+ 1.0 (/ 1.0 x)))))
(/ (+ (* (+ x -1.0) (+ 2.0 x)) t_0) (* (+ x -1.0) t_0)))))
double code(double x) {
double t_0 = x * (-1.0 - x);
double tmp;
if ((((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 2e-32) {
tmp = (1.0 / x) / ((x + -1.0) * (x / (1.0 + (1.0 / x))));
} else {
tmp = (((x + -1.0) * (2.0 + x)) + t_0) / ((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 * ((-1.0d0) - x)
if ((((1.0d0 / (x + 1.0d0)) - (2.0d0 / x)) + (1.0d0 / (x + (-1.0d0)))) <= 2d-32) then
tmp = (1.0d0 / x) / ((x + (-1.0d0)) * (x / (1.0d0 + (1.0d0 / x))))
else
tmp = (((x + (-1.0d0)) * (2.0d0 + x)) + t_0) / ((x + (-1.0d0)) * t_0)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = x * (-1.0 - x);
double tmp;
if ((((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 2e-32) {
tmp = (1.0 / x) / ((x + -1.0) * (x / (1.0 + (1.0 / x))));
} else {
tmp = (((x + -1.0) * (2.0 + x)) + t_0) / ((x + -1.0) * t_0);
}
return tmp;
}
def code(x): t_0 = x * (-1.0 - x) tmp = 0 if (((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 2e-32: tmp = (1.0 / x) / ((x + -1.0) * (x / (1.0 + (1.0 / x)))) else: tmp = (((x + -1.0) * (2.0 + x)) + t_0) / ((x + -1.0) * t_0) return tmp
function code(x) t_0 = Float64(x * Float64(-1.0 - x)) 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-32) tmp = Float64(Float64(1.0 / x) / Float64(Float64(x + -1.0) * Float64(x / Float64(1.0 + Float64(1.0 / x))))); else tmp = Float64(Float64(Float64(Float64(x + -1.0) * Float64(2.0 + x)) + t_0) / Float64(Float64(x + -1.0) * t_0)); end return tmp end
function tmp_2 = code(x) t_0 = x * (-1.0 - x); tmp = 0.0; if ((((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 2e-32) tmp = (1.0 / x) / ((x + -1.0) * (x / (1.0 + (1.0 / x)))); else tmp = (((x + -1.0) * (2.0 + x)) + t_0) / ((x + -1.0) * t_0); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(x * N[(-1.0 - x), $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-32], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(x + -1.0), $MachinePrecision] * N[(x / N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x + -1.0), $MachinePrecision] * N[(2.0 + x), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] / N[(N[(x + -1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-1 - x\right)\\
\mathbf{if}\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x + -1} \leq 2 \cdot 10^{-32}:\\
\;\;\;\;\frac{\frac{1}{x}}{\left(x + -1\right) \cdot \frac{x}{1 + \frac{1}{x}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x + -1\right) \cdot \left(2 + x\right) + t\_0}{\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)))) < 2.00000000000000011e-32Initial program 74.2%
+-commutative74.2%
associate-+r-74.2%
sub-neg74.2%
remove-double-neg74.2%
neg-sub074.2%
associate-+l-74.2%
neg-sub074.2%
distribute-neg-frac274.2%
distribute-frac-neg274.2%
associate-+r+74.2%
+-commutative74.2%
remove-double-neg74.2%
distribute-neg-frac274.2%
sub0-neg74.2%
associate-+l-74.2%
neg-sub074.2%
Simplified74.2%
Taylor expanded in x around inf 73.7%
associate-*r/73.7%
neg-mul-173.7%
distribute-neg-in73.7%
metadata-eval73.7%
distribute-neg-frac73.7%
metadata-eval73.7%
Simplified73.7%
frac-2neg73.7%
metadata-eval73.7%
clear-num73.7%
frac-add73.7%
Applied egg-rr73.7%
*-rgt-identity73.7%
mul-1-neg73.7%
distribute-neg-out73.7%
+-commutative73.7%
distribute-neg-out73.7%
distribute-neg-in73.7%
metadata-eval73.7%
+-commutative73.7%
unsub-neg73.7%
distribute-neg-frac273.7%
distribute-neg-in73.7%
metadata-eval73.7%
distribute-neg-frac73.7%
metadata-eval73.7%
distribute-lft-neg-out73.7%
distribute-rgt-neg-in73.7%
distribute-neg-frac273.7%
Simplified73.7%
Taylor expanded in x around inf 77.2%
if 2.00000000000000011e-32 < (+.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 87.3%
+-commutative87.3%
associate-+r-86.4%
sub-neg86.4%
remove-double-neg86.4%
neg-sub086.4%
associate-+l-86.4%
neg-sub086.4%
distribute-neg-frac286.4%
distribute-frac-neg286.4%
associate-+r+87.3%
+-commutative87.3%
remove-double-neg87.3%
distribute-neg-frac287.3%
sub0-neg87.3%
associate-+l-87.3%
neg-sub087.3%
Simplified87.3%
frac-sub87.9%
div-inv87.9%
*-rgt-identity87.9%
fmm-def87.9%
Applied egg-rr87.9%
fmm-undef87.9%
Simplified87.9%
Taylor expanded in x around 0 87.9%
+-commutative87.9%
un-div-inv87.9%
frac-add99.5%
metadata-eval99.5%
div-inv99.5%
/-rgt-identity99.5%
Applied egg-rr99.5%
Final simplification77.4%
(FPCore (x) :precision binary64 (/ (/ 1.0 x) (* (+ x -1.0) (/ x (+ 1.0 (/ 1.0 x))))))
double code(double x) {
return (1.0 / x) / ((x + -1.0) * (x / (1.0 + (1.0 / x))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / x) / ((x + (-1.0d0)) * (x / (1.0d0 + (1.0d0 / x))))
end function
public static double code(double x) {
return (1.0 / x) / ((x + -1.0) * (x / (1.0 + (1.0 / x))));
}
def code(x): return (1.0 / x) / ((x + -1.0) * (x / (1.0 + (1.0 / x))))
function code(x) return Float64(Float64(1.0 / x) / Float64(Float64(x + -1.0) * Float64(x / Float64(1.0 + Float64(1.0 / x))))) end
function tmp = code(x) tmp = (1.0 / x) / ((x + -1.0) * (x / (1.0 + (1.0 / x)))); end
code[x_] := N[(N[(1.0 / x), $MachinePrecision] / N[(N[(x + -1.0), $MachinePrecision] * N[(x / N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{\left(x + -1\right) \cdot \frac{x}{1 + \frac{1}{x}}}
\end{array}
Initial program 74.3%
+-commutative74.3%
associate-+r-74.3%
sub-neg74.3%
remove-double-neg74.3%
neg-sub074.3%
associate-+l-74.3%
neg-sub074.3%
distribute-neg-frac274.3%
distribute-frac-neg274.3%
associate-+r+74.3%
+-commutative74.3%
remove-double-neg74.3%
distribute-neg-frac274.3%
sub0-neg74.3%
associate-+l-74.3%
neg-sub074.3%
Simplified74.3%
Taylor expanded in x around inf 73.1%
associate-*r/73.1%
neg-mul-173.1%
distribute-neg-in73.1%
metadata-eval73.1%
distribute-neg-frac73.1%
metadata-eval73.1%
Simplified73.1%
frac-2neg73.1%
metadata-eval73.1%
clear-num73.1%
frac-add73.1%
Applied egg-rr73.1%
*-rgt-identity73.1%
mul-1-neg73.1%
distribute-neg-out73.1%
+-commutative73.1%
distribute-neg-out73.1%
distribute-neg-in73.1%
metadata-eval73.1%
+-commutative73.1%
unsub-neg73.1%
distribute-neg-frac273.1%
distribute-neg-in73.1%
metadata-eval73.1%
distribute-neg-frac73.1%
metadata-eval73.1%
distribute-lft-neg-out73.1%
distribute-rgt-neg-in73.1%
distribute-neg-frac273.1%
Simplified73.1%
Taylor expanded in x around inf 76.5%
(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 74.3%
Final simplification74.3%
(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 74.3%
+-commutative74.3%
associate-+r-74.3%
sub-neg74.3%
remove-double-neg74.3%
neg-sub074.3%
associate-+l-74.3%
neg-sub074.3%
distribute-neg-frac274.3%
distribute-frac-neg274.3%
associate-+r+74.3%
+-commutative74.3%
remove-double-neg74.3%
distribute-neg-frac274.3%
sub0-neg74.3%
associate-+l-74.3%
neg-sub074.3%
Simplified74.3%
Taylor expanded in x around inf 73.1%
associate-*r/73.1%
neg-mul-173.1%
distribute-neg-in73.1%
metadata-eval73.1%
distribute-neg-frac73.1%
metadata-eval73.1%
Simplified73.1%
(FPCore (x) :precision binary64 (/ (- (- x -1.0) x) (* x (+ x -1.0))))
double code(double x) {
return ((x - -1.0) - x) / (x * (x + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x - (-1.0d0)) - x) / (x * (x + (-1.0d0)))
end function
public static double code(double x) {
return ((x - -1.0) - x) / (x * (x + -1.0));
}
def code(x): return ((x - -1.0) - x) / (x * (x + -1.0))
function code(x) return Float64(Float64(Float64(x - -1.0) - x) / Float64(x * Float64(x + -1.0))) end
function tmp = code(x) tmp = ((x - -1.0) - x) / (x * (x + -1.0)); end
code[x_] := N[(N[(N[(x - -1.0), $MachinePrecision] - x), $MachinePrecision] / N[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x - -1\right) - x}{x \cdot \left(x + -1\right)}
\end{array}
Initial program 74.3%
+-commutative74.3%
associate-+r-74.3%
sub-neg74.3%
remove-double-neg74.3%
neg-sub074.3%
associate-+l-74.3%
neg-sub074.3%
distribute-neg-frac274.3%
distribute-frac-neg274.3%
associate-+r+74.3%
+-commutative74.3%
remove-double-neg74.3%
distribute-neg-frac274.3%
sub0-neg74.3%
associate-+l-74.3%
neg-sub074.3%
Simplified74.3%
Taylor expanded in x around inf 72.9%
frac-2neg72.9%
metadata-eval72.9%
frac-add72.9%
Applied egg-rr72.9%
*-lft-identity72.9%
*-rgt-identity72.9%
+-commutative72.9%
associate-+l+72.9%
sub-neg72.9%
Simplified72.9%
Final simplification72.9%
(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 74.3%
+-commutative74.3%
associate-+r-74.3%
sub-neg74.3%
remove-double-neg74.3%
neg-sub074.3%
associate-+l-74.3%
neg-sub074.3%
distribute-neg-frac274.3%
distribute-frac-neg274.3%
associate-+r+74.3%
+-commutative74.3%
remove-double-neg74.3%
distribute-neg-frac274.3%
sub0-neg74.3%
associate-+l-74.3%
neg-sub074.3%
Simplified74.3%
Taylor expanded in x around inf 72.9%
(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 74.3%
+-commutative74.3%
associate-+r-74.3%
sub-neg74.3%
remove-double-neg74.3%
neg-sub074.3%
associate-+l-74.3%
neg-sub074.3%
distribute-neg-frac274.3%
distribute-frac-neg274.3%
associate-+r+74.3%
+-commutative74.3%
remove-double-neg74.3%
distribute-neg-frac274.3%
sub0-neg74.3%
associate-+l-74.3%
neg-sub074.3%
Simplified74.3%
Taylor expanded in x around inf 72.9%
Taylor expanded in x around inf 72.6%
Final simplification72.6%
(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 74.3%
+-commutative74.3%
associate-+r-74.3%
sub-neg74.3%
remove-double-neg74.3%
neg-sub074.3%
associate-+l-74.3%
neg-sub074.3%
distribute-neg-frac274.3%
distribute-frac-neg274.3%
associate-+r+74.3%
+-commutative74.3%
remove-double-neg74.3%
distribute-neg-frac274.3%
sub0-neg74.3%
associate-+l-74.3%
neg-sub074.3%
Simplified74.3%
Taylor expanded in x around inf 72.9%
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 74.3%
+-commutative74.3%
associate-+r-74.3%
sub-neg74.3%
remove-double-neg74.3%
neg-sub074.3%
associate-+l-74.3%
neg-sub074.3%
distribute-neg-frac274.3%
distribute-frac-neg274.3%
associate-+r+74.3%
+-commutative74.3%
remove-double-neg74.3%
distribute-neg-frac274.3%
sub0-neg74.3%
associate-+l-74.3%
neg-sub074.3%
Simplified74.3%
Taylor expanded in x around 0 5.2%
(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 2024180
(FPCore (x)
:name "3frac (problem 3.3.3)"
:precision binary64
:pre (> (fabs x) 1.0)
:alt
(! :herbie-platform default (/ 2 (* x (- (* x x) 1))))
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))