
(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 9 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 (if (<= x -4e+69) (/ (/ 2.0 x) (fma x x x)) (/ 2.0 (- (* x (+ x -1.0)) (* x (* x (- 1.0 x)))))))
double code(double x) {
double tmp;
if (x <= -4e+69) {
tmp = (2.0 / x) / fma(x, x, x);
} else {
tmp = 2.0 / ((x * (x + -1.0)) - (x * (x * (1.0 - x))));
}
return tmp;
}
function code(x) tmp = 0.0 if (x <= -4e+69) tmp = Float64(Float64(2.0 / x) / fma(x, x, x)); else tmp = Float64(2.0 / Float64(Float64(x * Float64(x + -1.0)) - Float64(x * Float64(x * Float64(1.0 - x))))); end return tmp end
code[x_] := If[LessEqual[x, -4e+69], N[(N[(2.0 / x), $MachinePrecision] / N[(x * x + x), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision] - N[(x * N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+69}:\\
\;\;\;\;\frac{\frac{2}{x}}{\mathsf{fma}\left(x, x, x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{x \cdot \left(x + -1\right) - x \cdot \left(x \cdot \left(1 - x\right)\right)}\\
\end{array}
\end{array}
if x < -4.0000000000000003e69Initial program 82.6%
remove-double-neg82.6%
sub-neg82.6%
sub-neg82.6%
distribute-neg-frac82.6%
metadata-eval82.6%
metadata-eval82.6%
metadata-eval82.6%
associate-/r*82.6%
metadata-eval82.6%
neg-mul-182.6%
associate--l+82.6%
+-commutative82.6%
distribute-neg-frac82.6%
metadata-eval82.6%
metadata-eval82.6%
metadata-eval82.6%
associate-/r*82.6%
metadata-eval82.6%
neg-mul-182.6%
sub0-neg82.6%
associate-+l-82.6%
neg-sub082.6%
Simplified82.6%
frac-2neg82.6%
metadata-eval82.6%
frac-sub20.8%
frac-add22.6%
fma-def22.6%
+-commutative22.6%
distribute-neg-in22.6%
neg-mul-122.6%
metadata-eval22.6%
fma-def22.6%
*-rgt-identity22.6%
+-commutative22.6%
distribute-neg-in22.6%
neg-mul-122.6%
metadata-eval22.6%
fma-def22.6%
Applied egg-rr22.6%
Taylor expanded in x around 0 98.5%
*-un-lft-identity98.5%
*-commutative98.5%
Applied egg-rr99.9%
Taylor expanded in x around inf 99.9%
if -4.0000000000000003e69 < x Initial program 83.1%
remove-double-neg83.1%
sub-neg83.1%
sub-neg83.1%
distribute-neg-frac83.1%
metadata-eval83.1%
metadata-eval83.1%
metadata-eval83.1%
associate-/r*83.1%
metadata-eval83.1%
neg-mul-183.1%
associate--l+83.1%
+-commutative83.1%
distribute-neg-frac83.1%
metadata-eval83.1%
metadata-eval83.1%
metadata-eval83.1%
associate-/r*83.1%
metadata-eval83.1%
neg-mul-183.1%
sub0-neg83.1%
associate-+l-83.1%
neg-sub083.1%
Simplified83.1%
frac-2neg83.1%
metadata-eval83.1%
frac-sub68.4%
frac-add68.4%
fma-def68.4%
+-commutative68.4%
distribute-neg-in68.4%
neg-mul-168.4%
metadata-eval68.4%
fma-def68.4%
*-rgt-identity68.4%
+-commutative68.4%
distribute-neg-in68.4%
neg-mul-168.4%
metadata-eval68.4%
fma-def68.4%
Applied egg-rr68.4%
Taylor expanded in x around 0 99.9%
*-commutative99.9%
fma-udef99.9%
neg-mul-199.9%
distribute-lft-in99.9%
*-commutative99.9%
neg-mul-199.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (* 2.0 (/ (/ 1.0 (fma x x x)) (+ x -1.0))))
double code(double x) {
return 2.0 * ((1.0 / fma(x, x, x)) / (x + -1.0));
}
function code(x) return Float64(2.0 * Float64(Float64(1.0 / fma(x, x, x)) / Float64(x + -1.0))) end
code[x_] := N[(2.0 * N[(N[(1.0 / N[(x * x + x), $MachinePrecision]), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \frac{\frac{1}{\mathsf{fma}\left(x, x, x\right)}}{x + -1}
\end{array}
Initial program 83.0%
remove-double-neg83.0%
sub-neg83.0%
sub-neg83.0%
distribute-neg-frac83.0%
metadata-eval83.0%
metadata-eval83.0%
metadata-eval83.0%
associate-/r*83.0%
metadata-eval83.0%
neg-mul-183.0%
associate--l+83.0%
+-commutative83.0%
distribute-neg-frac83.0%
metadata-eval83.0%
metadata-eval83.0%
metadata-eval83.0%
associate-/r*83.0%
metadata-eval83.0%
neg-mul-183.0%
sub0-neg83.0%
associate-+l-83.0%
neg-sub083.0%
Simplified83.0%
frac-2neg83.0%
metadata-eval83.0%
frac-sub61.0%
frac-add61.2%
fma-def61.2%
+-commutative61.2%
distribute-neg-in61.2%
neg-mul-161.2%
metadata-eval61.2%
fma-def61.2%
*-rgt-identity61.2%
+-commutative61.2%
distribute-neg-in61.2%
neg-mul-161.2%
metadata-eval61.2%
fma-def61.2%
Applied egg-rr61.2%
Taylor expanded in x around 0 99.7%
*-un-lft-identity99.7%
*-commutative99.7%
Applied egg-rr99.9%
Applied egg-rr99.9%
associate-*l/99.9%
associate-*r/99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (/ (/ 2.0 (+ x -1.0)) (fma x x x)))
double code(double x) {
return (2.0 / (x + -1.0)) / fma(x, x, x);
}
function code(x) return Float64(Float64(2.0 / Float64(x + -1.0)) / fma(x, x, x)) end
code[x_] := N[(N[(2.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x * x + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{x + -1}}{\mathsf{fma}\left(x, x, x\right)}
\end{array}
Initial program 83.0%
remove-double-neg83.0%
sub-neg83.0%
sub-neg83.0%
distribute-neg-frac83.0%
metadata-eval83.0%
metadata-eval83.0%
metadata-eval83.0%
associate-/r*83.0%
metadata-eval83.0%
neg-mul-183.0%
associate--l+83.0%
+-commutative83.0%
distribute-neg-frac83.0%
metadata-eval83.0%
metadata-eval83.0%
metadata-eval83.0%
associate-/r*83.0%
metadata-eval83.0%
neg-mul-183.0%
sub0-neg83.0%
associate-+l-83.0%
neg-sub083.0%
Simplified83.0%
frac-2neg83.0%
metadata-eval83.0%
frac-sub61.0%
frac-add61.2%
fma-def61.2%
+-commutative61.2%
distribute-neg-in61.2%
neg-mul-161.2%
metadata-eval61.2%
fma-def61.2%
*-rgt-identity61.2%
+-commutative61.2%
distribute-neg-in61.2%
neg-mul-161.2%
metadata-eval61.2%
fma-def61.2%
Applied egg-rr61.2%
Taylor expanded in x around 0 99.7%
*-un-lft-identity99.7%
*-commutative99.7%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (if (<= x -1e+17) (/ 2.0 (pow x 3.0)) (/ 2.0 (- (* x (+ x -1.0)) (* x (* x (- 1.0 x)))))))
double code(double x) {
double tmp;
if (x <= -1e+17) {
tmp = 2.0 / pow(x, 3.0);
} else {
tmp = 2.0 / ((x * (x + -1.0)) - (x * (x * (1.0 - x))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1d+17)) then
tmp = 2.0d0 / (x ** 3.0d0)
else
tmp = 2.0d0 / ((x * (x + (-1.0d0))) - (x * (x * (1.0d0 - x))))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1e+17) {
tmp = 2.0 / Math.pow(x, 3.0);
} else {
tmp = 2.0 / ((x * (x + -1.0)) - (x * (x * (1.0 - x))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1e+17: tmp = 2.0 / math.pow(x, 3.0) else: tmp = 2.0 / ((x * (x + -1.0)) - (x * (x * (1.0 - x)))) return tmp
function code(x) tmp = 0.0 if (x <= -1e+17) tmp = Float64(2.0 / (x ^ 3.0)); else tmp = Float64(2.0 / Float64(Float64(x * Float64(x + -1.0)) - Float64(x * Float64(x * Float64(1.0 - x))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1e+17) tmp = 2.0 / (x ^ 3.0); else tmp = 2.0 / ((x * (x + -1.0)) - (x * (x * (1.0 - x)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1e+17], N[(2.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision] - N[(x * N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+17}:\\
\;\;\;\;\frac{2}{{x}^{3}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{x \cdot \left(x + -1\right) - x \cdot \left(x \cdot \left(1 - x\right)\right)}\\
\end{array}
\end{array}
if x < -1e17Initial program 60.3%
remove-double-neg60.3%
sub-neg60.3%
sub-neg60.3%
distribute-neg-frac60.3%
metadata-eval60.3%
metadata-eval60.3%
metadata-eval60.3%
associate-/r*60.3%
metadata-eval60.3%
neg-mul-160.3%
associate--l+60.3%
+-commutative60.3%
distribute-neg-frac60.3%
metadata-eval60.3%
metadata-eval60.3%
metadata-eval60.3%
associate-/r*60.3%
metadata-eval60.3%
neg-mul-160.3%
sub0-neg60.3%
associate-+l-60.3%
neg-sub060.3%
Simplified60.3%
Taylor expanded in x around inf 98.8%
if -1e17 < x Initial program 89.4%
remove-double-neg89.4%
sub-neg89.4%
sub-neg89.4%
distribute-neg-frac89.4%
metadata-eval89.4%
metadata-eval89.4%
metadata-eval89.4%
associate-/r*89.4%
metadata-eval89.4%
neg-mul-189.4%
associate--l+89.4%
+-commutative89.4%
distribute-neg-frac89.4%
metadata-eval89.4%
metadata-eval89.4%
metadata-eval89.4%
associate-/r*89.4%
metadata-eval89.4%
neg-mul-189.4%
sub0-neg89.4%
associate-+l-89.4%
neg-sub089.4%
Simplified89.4%
frac-2neg89.4%
metadata-eval89.4%
frac-sub73.5%
frac-add73.5%
fma-def73.5%
+-commutative73.5%
distribute-neg-in73.5%
neg-mul-173.5%
metadata-eval73.5%
fma-def73.5%
*-rgt-identity73.5%
+-commutative73.5%
distribute-neg-in73.5%
neg-mul-173.5%
metadata-eval73.5%
fma-def73.5%
Applied egg-rr73.5%
Taylor expanded in x around 0 99.9%
*-commutative99.9%
fma-udef99.9%
neg-mul-199.9%
distribute-lft-in99.9%
*-commutative99.9%
neg-mul-199.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
Applied egg-rr99.9%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (<= x -2e+104) 0.0 (/ 2.0 (- (* x (+ x -1.0)) (* x (* x (- 1.0 x)))))))
double code(double x) {
double tmp;
if (x <= -2e+104) {
tmp = 0.0;
} else {
tmp = 2.0 / ((x * (x + -1.0)) - (x * (x * (1.0 - x))));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-2d+104)) then
tmp = 0.0d0
else
tmp = 2.0d0 / ((x * (x + (-1.0d0))) - (x * (x * (1.0d0 - x))))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -2e+104) {
tmp = 0.0;
} else {
tmp = 2.0 / ((x * (x + -1.0)) - (x * (x * (1.0 - x))));
}
return tmp;
}
def code(x): tmp = 0 if x <= -2e+104: tmp = 0.0 else: tmp = 2.0 / ((x * (x + -1.0)) - (x * (x * (1.0 - x)))) return tmp
function code(x) tmp = 0.0 if (x <= -2e+104) tmp = 0.0; else tmp = Float64(2.0 / Float64(Float64(x * Float64(x + -1.0)) - Float64(x * Float64(x * Float64(1.0 - x))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2e+104) tmp = 0.0; else tmp = 2.0 / ((x * (x + -1.0)) - (x * (x * (1.0 - x)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -2e+104], 0.0, N[(2.0 / N[(N[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision] - N[(x * N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+104}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{x \cdot \left(x + -1\right) - x \cdot \left(x \cdot \left(1 - x\right)\right)}\\
\end{array}
\end{array}
if x < -2e104Initial program 98.4%
remove-double-neg98.4%
sub-neg98.4%
sub-neg98.4%
distribute-neg-frac98.4%
metadata-eval98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-/r*98.4%
metadata-eval98.4%
neg-mul-198.4%
associate--l+98.4%
+-commutative98.4%
distribute-neg-frac98.4%
metadata-eval98.4%
metadata-eval98.4%
metadata-eval98.4%
associate-/r*98.4%
metadata-eval98.4%
neg-mul-198.4%
sub0-neg98.4%
associate-+l-98.4%
neg-sub098.4%
Simplified98.4%
frac-sub23.6%
div-inv22.0%
*-rgt-identity22.0%
Applied egg-rr22.0%
Taylor expanded in x around inf 22.0%
Applied egg-rr25.7%
*-commutative25.7%
neg-mul-125.7%
sub-neg25.7%
div-sub25.7%
+-inverses98.4%
Simplified98.4%
if -2e104 < x Initial program 80.7%
remove-double-neg80.7%
sub-neg80.7%
sub-neg80.7%
distribute-neg-frac80.7%
metadata-eval80.7%
metadata-eval80.7%
metadata-eval80.7%
associate-/r*80.7%
metadata-eval80.7%
neg-mul-180.7%
associate--l+80.7%
+-commutative80.7%
distribute-neg-frac80.7%
metadata-eval80.7%
metadata-eval80.7%
metadata-eval80.7%
associate-/r*80.7%
metadata-eval80.7%
neg-mul-180.7%
sub0-neg80.7%
associate-+l-80.7%
neg-sub080.7%
Simplified80.7%
frac-2neg80.7%
metadata-eval80.7%
frac-sub66.5%
frac-add66.5%
fma-def66.5%
+-commutative66.5%
distribute-neg-in66.5%
neg-mul-166.5%
metadata-eval66.5%
fma-def66.5%
*-rgt-identity66.5%
+-commutative66.5%
distribute-neg-in66.5%
neg-mul-166.5%
metadata-eval66.5%
fma-def66.5%
Applied egg-rr66.5%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
fma-udef99.8%
neg-mul-199.8%
distribute-lft-in99.9%
*-commutative99.9%
neg-mul-199.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
Applied egg-rr99.9%
Final simplification99.7%
(FPCore (x) :precision binary64 (+ (- (/ 1.0 (+ 1.0 x)) (/ 2.0 x)) (/ 1.0 (+ x -1.0))))
double code(double x) {
return ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / (1.0d0 + x)) - (2.0d0 / x)) + (1.0d0 / (x + (-1.0d0)))
end function
public static double code(double x) {
return ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0));
}
def code(x): return ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0))
function code(x) return Float64(Float64(Float64(1.0 / Float64(1.0 + x)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x + -1.0))) end
function tmp = code(x) tmp = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0)); end
code[x_] := N[(N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{1}{x + -1}
\end{array}
Initial program 83.0%
Final simplification83.0%
(FPCore (x) :precision binary64 (if (<= x -1.0) 0.0 (if (<= x 1.0) (/ -2.0 x) 0.0)))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = 0.0;
} else if (x <= 1.0) {
tmp = -2.0 / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = 0.0d0
else if (x <= 1.0d0) then
tmp = (-2.0d0) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = 0.0;
} else if (x <= 1.0) {
tmp = -2.0 / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = 0.0 elif x <= 1.0: tmp = -2.0 / x else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = 0.0; elseif (x <= 1.0) tmp = Float64(-2.0 / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.0) tmp = 0.0; elseif (x <= 1.0) tmp = -2.0 / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.0], 0.0, If[LessEqual[x, 1.0], N[(-2.0 / x), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 63.4%
remove-double-neg63.4%
sub-neg63.4%
sub-neg63.4%
distribute-neg-frac63.4%
metadata-eval63.4%
metadata-eval63.4%
metadata-eval63.4%
associate-/r*63.4%
metadata-eval63.4%
neg-mul-163.4%
associate--l+63.4%
+-commutative63.4%
distribute-neg-frac63.4%
metadata-eval63.4%
metadata-eval63.4%
metadata-eval63.4%
associate-/r*63.4%
metadata-eval63.4%
neg-mul-163.4%
sub0-neg63.4%
associate-+l-63.4%
neg-sub063.4%
Simplified63.4%
frac-sub16.1%
div-inv14.8%
*-rgt-identity14.8%
Applied egg-rr14.8%
Taylor expanded in x around inf 13.8%
Applied egg-rr15.1%
*-commutative15.1%
neg-mul-115.1%
sub-neg15.1%
div-sub15.1%
+-inverses62.1%
Simplified62.1%
if -1 < x < 1Initial program 100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/r*100.0%
metadata-eval100.0%
neg-mul-1100.0%
associate--l+100.0%
+-commutative100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/r*100.0%
metadata-eval100.0%
neg-mul-1100.0%
sub0-neg100.0%
associate-+l-100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in x around 0 99.1%
Final simplification81.9%
(FPCore (x) :precision binary64 (+ 1.0 (+ -1.0 (/ -2.0 x))))
double code(double x) {
return 1.0 + (-1.0 + (-2.0 / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + ((-1.0d0) + ((-2.0d0) / x))
end function
public static double code(double x) {
return 1.0 + (-1.0 + (-2.0 / x));
}
def code(x): return 1.0 + (-1.0 + (-2.0 / x))
function code(x) return Float64(1.0 + Float64(-1.0 + Float64(-2.0 / x))) end
function tmp = code(x) tmp = 1.0 + (-1.0 + (-2.0 / x)); end
code[x_] := N[(1.0 + N[(-1.0 + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(-1 + \frac{-2}{x}\right)
\end{array}
Initial program 83.0%
remove-double-neg83.0%
sub-neg83.0%
sub-neg83.0%
distribute-neg-frac83.0%
metadata-eval83.0%
metadata-eval83.0%
metadata-eval83.0%
associate-/r*83.0%
metadata-eval83.0%
neg-mul-183.0%
associate--l+83.0%
+-commutative83.0%
distribute-neg-frac83.0%
metadata-eval83.0%
metadata-eval83.0%
metadata-eval83.0%
associate-/r*83.0%
metadata-eval83.0%
neg-mul-183.0%
sub0-neg83.0%
associate-+l-83.0%
neg-sub083.0%
Simplified83.0%
Taylor expanded in x around 0 54.5%
Taylor expanded in x around 0 81.9%
+-commutative81.9%
distribute-neg-in81.9%
associate-*r/81.9%
metadata-eval81.9%
distribute-neg-frac81.9%
metadata-eval81.9%
metadata-eval81.9%
Simplified81.9%
Final simplification81.9%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 83.0%
remove-double-neg83.0%
sub-neg83.0%
sub-neg83.0%
distribute-neg-frac83.0%
metadata-eval83.0%
metadata-eval83.0%
metadata-eval83.0%
associate-/r*83.0%
metadata-eval83.0%
neg-mul-183.0%
associate--l+83.0%
+-commutative83.0%
distribute-neg-frac83.0%
metadata-eval83.0%
metadata-eval83.0%
metadata-eval83.0%
associate-/r*83.0%
metadata-eval83.0%
neg-mul-183.0%
sub0-neg83.0%
associate-+l-83.0%
neg-sub083.0%
Simplified83.0%
frac-sub61.0%
div-inv60.4%
*-rgt-identity60.4%
Applied egg-rr60.4%
Taylor expanded in x around inf 8.1%
Applied egg-rr8.2%
*-commutative8.2%
neg-mul-18.2%
sub-neg8.2%
div-sub8.2%
+-inverses30.1%
Simplified30.1%
Final simplification30.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 2023310
(FPCore (x)
:name "3frac (problem 3.3.3)"
:precision binary64
:herbie-target
(/ 2.0 (* x (- (* x x) 1.0)))
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))