
(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 11 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 (+ (pow x -5.0) (+ (pow x -3.0) (pow x -7.0)))))
double code(double x) {
return 2.0 * (pow(x, -5.0) + (pow(x, -3.0) + pow(x, -7.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 2.0d0 * ((x ** (-5.0d0)) + ((x ** (-3.0d0)) + (x ** (-7.0d0))))
end function
public static double code(double x) {
return 2.0 * (Math.pow(x, -5.0) + (Math.pow(x, -3.0) + Math.pow(x, -7.0)));
}
def code(x): return 2.0 * (math.pow(x, -5.0) + (math.pow(x, -3.0) + math.pow(x, -7.0)))
function code(x) return Float64(2.0 * Float64((x ^ -5.0) + Float64((x ^ -3.0) + (x ^ -7.0)))) end
function tmp = code(x) tmp = 2.0 * ((x ^ -5.0) + ((x ^ -3.0) + (x ^ -7.0))); end
code[x_] := N[(2.0 * N[(N[Power[x, -5.0], $MachinePrecision] + N[(N[Power[x, -3.0], $MachinePrecision] + N[Power[x, -7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left({x}^{-5} + \left({x}^{-3} + {x}^{-7}\right)\right)
\end{array}
Initial program 66.8%
associate-+l-66.8%
sub-neg66.8%
+-commutative66.8%
neg-sub066.8%
associate-+l-66.8%
neg-sub066.8%
distribute-neg-frac66.8%
metadata-eval66.8%
sub-neg66.8%
metadata-eval66.8%
Simplified66.8%
Taylor expanded in x around inf 98.7%
associate-*r/98.7%
metadata-eval98.7%
+-commutative98.7%
associate-*r/98.7%
metadata-eval98.7%
associate-*r/98.7%
metadata-eval98.7%
Simplified98.7%
expm1-log1p-u98.7%
expm1-udef66.3%
div-inv66.3%
div-inv66.3%
distribute-lft-out66.3%
pow-flip66.3%
metadata-eval66.3%
pow-flip66.3%
metadata-eval66.3%
Applied egg-rr66.3%
expm1-def99.7%
expm1-log1p99.7%
Simplified99.7%
div-inv99.7%
fma-def99.7%
pow-flip99.7%
metadata-eval99.7%
Applied egg-rr99.7%
fma-udef99.7%
distribute-lft-out99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x) :precision binary64 (* 2.0 (+ (pow x -5.0) (pow x -3.0))))
double code(double x) {
return 2.0 * (pow(x, -5.0) + pow(x, -3.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 2.0d0 * ((x ** (-5.0d0)) + (x ** (-3.0d0)))
end function
public static double code(double x) {
return 2.0 * (Math.pow(x, -5.0) + Math.pow(x, -3.0));
}
def code(x): return 2.0 * (math.pow(x, -5.0) + math.pow(x, -3.0))
function code(x) return Float64(2.0 * Float64((x ^ -5.0) + (x ^ -3.0))) end
function tmp = code(x) tmp = 2.0 * ((x ^ -5.0) + (x ^ -3.0)); end
code[x_] := N[(2.0 * N[(N[Power[x, -5.0], $MachinePrecision] + N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left({x}^{-5} + {x}^{-3}\right)
\end{array}
Initial program 66.8%
associate-+l-66.8%
sub-neg66.8%
+-commutative66.8%
neg-sub066.8%
associate-+l-66.8%
neg-sub066.8%
distribute-neg-frac66.8%
metadata-eval66.8%
sub-neg66.8%
metadata-eval66.8%
Simplified66.8%
Taylor expanded in x around inf 98.5%
associate-*r/98.5%
metadata-eval98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
expm1-log1p-u98.5%
expm1-udef65.7%
div-inv65.7%
div-inv65.7%
distribute-lft-out65.7%
pow-flip65.7%
metadata-eval65.7%
pow-flip65.7%
metadata-eval65.7%
Applied egg-rr65.7%
expm1-def99.5%
expm1-log1p99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x) :precision binary64 (/ (+ (/ 2.0 x) (/ 4.0 (pow x 2.0))) (* x (+ 2.0 x))))
double code(double x) {
return ((2.0 / x) + (4.0 / pow(x, 2.0))) / (x * (2.0 + x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((2.0d0 / x) + (4.0d0 / (x ** 2.0d0))) / (x * (2.0d0 + x))
end function
public static double code(double x) {
return ((2.0 / x) + (4.0 / Math.pow(x, 2.0))) / (x * (2.0 + x));
}
def code(x): return ((2.0 / x) + (4.0 / math.pow(x, 2.0))) / (x * (2.0 + x))
function code(x) return Float64(Float64(Float64(2.0 / x) + Float64(4.0 / (x ^ 2.0))) / Float64(x * Float64(2.0 + x))) end
function tmp = code(x) tmp = ((2.0 / x) + (4.0 / (x ^ 2.0))) / (x * (2.0 + x)); end
code[x_] := N[(N[(N[(2.0 / x), $MachinePrecision] + N[(4.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * N[(2.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{x} + \frac{4}{{x}^{2}}}{x \cdot \left(2 + x\right)}
\end{array}
Initial program 66.8%
associate-+l-66.8%
sub-neg66.8%
+-commutative66.8%
neg-sub066.8%
associate-+l-66.8%
neg-sub066.8%
distribute-neg-frac66.8%
metadata-eval66.8%
sub-neg66.8%
metadata-eval66.8%
Simplified66.8%
clear-num66.8%
frac-2neg66.8%
metadata-eval66.8%
frac-add19.0%
*-un-lft-identity19.0%
+-commutative19.0%
distribute-neg-in19.0%
metadata-eval19.0%
sub-neg19.0%
div-inv19.0%
metadata-eval19.0%
div-inv19.0%
metadata-eval19.0%
+-commutative19.0%
distribute-neg-in19.0%
metadata-eval19.0%
sub-neg19.0%
Applied egg-rr19.0%
associate-*l*19.0%
metadata-eval19.0%
*-commutative19.0%
Simplified19.0%
Applied egg-rr17.1%
sub-neg17.1%
associate-/l*66.8%
div-sub66.8%
sub-neg66.8%
*-commutative66.8%
associate-/r*66.8%
metadata-eval66.8%
*-inverses66.8%
metadata-eval66.8%
+-commutative66.8%
distribute-neg-in66.8%
metadata-eval66.8%
unsub-neg66.8%
*-commutative66.8%
Simplified66.8%
Taylor expanded in x around inf 66.1%
+-commutative66.1%
unpow266.1%
distribute-rgt-out66.1%
Simplified66.1%
Taylor expanded in x around inf 98.4%
associate-*r/98.4%
metadata-eval98.4%
associate-*r/98.4%
metadata-eval98.4%
Simplified98.4%
Final simplification98.4%
(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}
\\
\frac{2}{{x}^{3}}
\end{array}
Initial program 66.8%
associate-+l-66.8%
sub-neg66.8%
+-commutative66.8%
neg-sub066.8%
associate-+l-66.8%
neg-sub066.8%
distribute-neg-frac66.8%
metadata-eval66.8%
sub-neg66.8%
metadata-eval66.8%
Simplified66.8%
Taylor expanded in x around inf 97.7%
Final simplification97.7%
(FPCore (x)
:precision binary64
(if (<= (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (+ x -1.0))) 5e-29)
(/ (/ 2.0 x) (/ (* (+ x 1.0) (- 1.0 x)) (+ (/ 2.0 x) -1.0)))
(/
(+ (* (- 1.0 x) (* x 0.5)) (* (+ x 1.0) (+ -1.0 (* x 0.5))))
(* (- 1.0 x) (* (+ x 1.0) (* x 0.5))))))
double code(double x) {
double tmp;
if ((((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 5e-29) {
tmp = (2.0 / x) / (((x + 1.0) * (1.0 - x)) / ((2.0 / x) + -1.0));
} else {
tmp = (((1.0 - x) * (x * 0.5)) + ((x + 1.0) * (-1.0 + (x * 0.5)))) / ((1.0 - x) * ((x + 1.0) * (x * 0.5)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((((1.0d0 / (x + 1.0d0)) - (2.0d0 / x)) + (1.0d0 / (x + (-1.0d0)))) <= 5d-29) then
tmp = (2.0d0 / x) / (((x + 1.0d0) * (1.0d0 - x)) / ((2.0d0 / x) + (-1.0d0)))
else
tmp = (((1.0d0 - x) * (x * 0.5d0)) + ((x + 1.0d0) * ((-1.0d0) + (x * 0.5d0)))) / ((1.0d0 - x) * ((x + 1.0d0) * (x * 0.5d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 5e-29) {
tmp = (2.0 / x) / (((x + 1.0) * (1.0 - x)) / ((2.0 / x) + -1.0));
} else {
tmp = (((1.0 - x) * (x * 0.5)) + ((x + 1.0) * (-1.0 + (x * 0.5)))) / ((1.0 - x) * ((x + 1.0) * (x * 0.5)));
}
return tmp;
}
def code(x): tmp = 0 if (((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 5e-29: tmp = (2.0 / x) / (((x + 1.0) * (1.0 - x)) / ((2.0 / x) + -1.0)) else: tmp = (((1.0 - x) * (x * 0.5)) + ((x + 1.0) * (-1.0 + (x * 0.5)))) / ((1.0 - x) * ((x + 1.0) * (x * 0.5))) return tmp
function code(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))) <= 5e-29) tmp = Float64(Float64(2.0 / x) / Float64(Float64(Float64(x + 1.0) * Float64(1.0 - x)) / Float64(Float64(2.0 / x) + -1.0))); else tmp = Float64(Float64(Float64(Float64(1.0 - x) * Float64(x * 0.5)) + Float64(Float64(x + 1.0) * Float64(-1.0 + Float64(x * 0.5)))) / Float64(Float64(1.0 - x) * Float64(Float64(x + 1.0) * Float64(x * 0.5)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 5e-29) tmp = (2.0 / x) / (((x + 1.0) * (1.0 - x)) / ((2.0 / x) + -1.0)); else tmp = (((1.0 - x) * (x * 0.5)) + ((x + 1.0) * (-1.0 + (x * 0.5)))) / ((1.0 - x) * ((x + 1.0) * (x * 0.5))); end tmp_2 = tmp; end
code[x_] := 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], 5e-29], N[(N[(2.0 / x), $MachinePrecision] / N[(N[(N[(x + 1.0), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 / x), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 - x), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + N[(N[(x + 1.0), $MachinePrecision] * N[(-1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - x), $MachinePrecision] * N[(N[(x + 1.0), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x + -1} \leq 5 \cdot 10^{-29}:\\
\;\;\;\;\frac{\frac{2}{x}}{\frac{\left(x + 1\right) \cdot \left(1 - x\right)}{\frac{2}{x} + -1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - x\right) \cdot \left(x \cdot 0.5\right) + \left(x + 1\right) \cdot \left(-1 + x \cdot 0.5\right)}{\left(1 - x\right) \cdot \left(\left(x + 1\right) \cdot \left(x \cdot 0.5\right)\right)}\\
\end{array}
\end{array}
if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 4.99999999999999986e-29Initial program 67.3%
associate-+l-67.3%
sub-neg67.3%
+-commutative67.3%
neg-sub067.3%
associate-+l-67.3%
neg-sub067.3%
distribute-neg-frac67.3%
metadata-eval67.3%
sub-neg67.3%
metadata-eval67.3%
Simplified67.3%
clear-num67.3%
frac-2neg67.3%
metadata-eval67.3%
frac-add18.2%
*-un-lft-identity18.2%
+-commutative18.2%
distribute-neg-in18.2%
metadata-eval18.2%
sub-neg18.2%
div-inv18.2%
metadata-eval18.2%
div-inv18.2%
metadata-eval18.2%
+-commutative18.2%
distribute-neg-in18.2%
metadata-eval18.2%
sub-neg18.2%
Applied egg-rr18.2%
associate-*l*18.2%
metadata-eval18.2%
*-commutative18.2%
Simplified18.2%
Applied egg-rr16.3%
sub-neg16.3%
associate-/l*67.3%
div-sub67.3%
sub-neg67.3%
*-commutative67.3%
associate-/r*67.3%
metadata-eval67.3%
*-inverses67.3%
metadata-eval67.3%
+-commutative67.3%
distribute-neg-in67.3%
metadata-eval67.3%
unsub-neg67.3%
*-commutative67.3%
Simplified67.3%
Taylor expanded in x around inf 98.4%
if 4.99999999999999986e-29 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 46.3%
associate-+l-46.3%
sub-neg46.3%
+-commutative46.3%
neg-sub046.3%
associate-+l-46.3%
neg-sub046.3%
distribute-neg-frac46.3%
metadata-eval46.3%
sub-neg46.3%
metadata-eval46.3%
Simplified46.3%
clear-num46.3%
frac-2neg46.3%
metadata-eval46.3%
frac-add47.9%
*-un-lft-identity47.9%
+-commutative47.9%
distribute-neg-in47.9%
metadata-eval47.9%
sub-neg47.9%
div-inv47.9%
metadata-eval47.9%
div-inv47.9%
metadata-eval47.9%
+-commutative47.9%
distribute-neg-in47.9%
metadata-eval47.9%
sub-neg47.9%
Applied egg-rr47.9%
associate-*l*47.9%
metadata-eval47.9%
*-commutative47.9%
Simplified47.9%
Applied egg-rr85.5%
Final simplification98.1%
(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 66.8%
associate-+l-66.8%
sub-neg66.8%
+-commutative66.8%
neg-sub066.8%
associate-+l-66.8%
neg-sub066.8%
distribute-neg-frac66.8%
metadata-eval66.8%
sub-neg66.8%
metadata-eval66.8%
Simplified66.8%
Taylor expanded in x around inf 65.0%
Final simplification65.0%
(FPCore (x) :precision binary64 (/ (/ 2.0 x) (* x (+ 2.0 x))))
double code(double x) {
return (2.0 / x) / (x * (2.0 + x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (2.0d0 / x) / (x * (2.0d0 + x))
end function
public static double code(double x) {
return (2.0 / x) / (x * (2.0 + x));
}
def code(x): return (2.0 / x) / (x * (2.0 + x))
function code(x) return Float64(Float64(2.0 / x) / Float64(x * Float64(2.0 + x))) end
function tmp = code(x) tmp = (2.0 / x) / (x * (2.0 + x)); end
code[x_] := N[(N[(2.0 / x), $MachinePrecision] / N[(x * N[(2.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{x}}{x \cdot \left(2 + x\right)}
\end{array}
Initial program 66.8%
associate-+l-66.8%
sub-neg66.8%
+-commutative66.8%
neg-sub066.8%
associate-+l-66.8%
neg-sub066.8%
distribute-neg-frac66.8%
metadata-eval66.8%
sub-neg66.8%
metadata-eval66.8%
Simplified66.8%
clear-num66.8%
frac-2neg66.8%
metadata-eval66.8%
frac-add19.0%
*-un-lft-identity19.0%
+-commutative19.0%
distribute-neg-in19.0%
metadata-eval19.0%
sub-neg19.0%
div-inv19.0%
metadata-eval19.0%
div-inv19.0%
metadata-eval19.0%
+-commutative19.0%
distribute-neg-in19.0%
metadata-eval19.0%
sub-neg19.0%
Applied egg-rr19.0%
associate-*l*19.0%
metadata-eval19.0%
*-commutative19.0%
Simplified19.0%
Applied egg-rr17.1%
sub-neg17.1%
associate-/l*66.8%
div-sub66.8%
sub-neg66.8%
*-commutative66.8%
associate-/r*66.8%
metadata-eval66.8%
*-inverses66.8%
metadata-eval66.8%
+-commutative66.8%
distribute-neg-in66.8%
metadata-eval66.8%
unsub-neg66.8%
*-commutative66.8%
Simplified66.8%
Taylor expanded in x around inf 66.1%
+-commutative66.1%
unpow266.1%
distribute-rgt-out66.1%
Simplified66.1%
Taylor expanded in x around inf 96.9%
Final simplification96.9%
(FPCore (x) :precision binary64 (/ -1.0 (* x (+ 2.0 x))))
double code(double x) {
return -1.0 / (x * (2.0 + x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-1.0d0) / (x * (2.0d0 + x))
end function
public static double code(double x) {
return -1.0 / (x * (2.0 + x));
}
def code(x): return -1.0 / (x * (2.0 + x))
function code(x) return Float64(-1.0 / Float64(x * Float64(2.0 + x))) end
function tmp = code(x) tmp = -1.0 / (x * (2.0 + x)); end
code[x_] := N[(-1.0 / N[(x * N[(2.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{x \cdot \left(2 + x\right)}
\end{array}
Initial program 66.8%
associate-+l-66.8%
sub-neg66.8%
+-commutative66.8%
neg-sub066.8%
associate-+l-66.8%
neg-sub066.8%
distribute-neg-frac66.8%
metadata-eval66.8%
sub-neg66.8%
metadata-eval66.8%
Simplified66.8%
clear-num66.8%
frac-2neg66.8%
metadata-eval66.8%
frac-add19.0%
*-un-lft-identity19.0%
+-commutative19.0%
distribute-neg-in19.0%
metadata-eval19.0%
sub-neg19.0%
div-inv19.0%
metadata-eval19.0%
div-inv19.0%
metadata-eval19.0%
+-commutative19.0%
distribute-neg-in19.0%
metadata-eval19.0%
sub-neg19.0%
Applied egg-rr19.0%
associate-*l*19.0%
metadata-eval19.0%
*-commutative19.0%
Simplified19.0%
Applied egg-rr17.1%
sub-neg17.1%
associate-/l*66.8%
div-sub66.8%
sub-neg66.8%
*-commutative66.8%
associate-/r*66.8%
metadata-eval66.8%
*-inverses66.8%
metadata-eval66.8%
+-commutative66.8%
distribute-neg-in66.8%
metadata-eval66.8%
unsub-neg66.8%
*-commutative66.8%
Simplified66.8%
Taylor expanded in x around inf 66.1%
+-commutative66.1%
unpow266.1%
distribute-rgt-out66.1%
Simplified66.1%
Taylor expanded in x around 0 51.6%
Final simplification51.6%
(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 66.8%
associate-+l-66.8%
sub-neg66.8%
+-commutative66.8%
neg-sub066.8%
associate-+l-66.8%
neg-sub066.8%
distribute-neg-frac66.8%
metadata-eval66.8%
sub-neg66.8%
metadata-eval66.8%
Simplified66.8%
Taylor expanded in x around 0 4.9%
Final simplification4.9%
(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 66.8%
associate-+l-66.8%
sub-neg66.8%
+-commutative66.8%
neg-sub066.8%
associate-+l-66.8%
neg-sub066.8%
distribute-neg-frac66.8%
metadata-eval66.8%
sub-neg66.8%
metadata-eval66.8%
Simplified66.8%
Taylor expanded in x around inf 65.0%
Taylor expanded in x around 0 4.9%
Final simplification4.9%
(FPCore (x) :precision binary64 (/ -0.5 x))
double code(double x) {
return -0.5 / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-0.5d0) / x
end function
public static double code(double x) {
return -0.5 / x;
}
def code(x): return -0.5 / x
function code(x) return Float64(-0.5 / x) end
function tmp = code(x) tmp = -0.5 / x; end
code[x_] := N[(-0.5 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.5}{x}
\end{array}
Initial program 66.8%
associate-+l-66.8%
sub-neg66.8%
+-commutative66.8%
neg-sub066.8%
associate-+l-66.8%
neg-sub066.8%
distribute-neg-frac66.8%
metadata-eval66.8%
sub-neg66.8%
metadata-eval66.8%
Simplified66.8%
clear-num66.8%
frac-2neg66.8%
metadata-eval66.8%
frac-add19.0%
*-un-lft-identity19.0%
+-commutative19.0%
distribute-neg-in19.0%
metadata-eval19.0%
sub-neg19.0%
div-inv19.0%
metadata-eval19.0%
div-inv19.0%
metadata-eval19.0%
+-commutative19.0%
distribute-neg-in19.0%
metadata-eval19.0%
sub-neg19.0%
Applied egg-rr19.0%
associate-*l*19.0%
metadata-eval19.0%
*-commutative19.0%
Simplified19.0%
Applied egg-rr17.1%
sub-neg17.1%
associate-/l*66.8%
div-sub66.8%
sub-neg66.8%
*-commutative66.8%
associate-/r*66.8%
metadata-eval66.8%
*-inverses66.8%
metadata-eval66.8%
+-commutative66.8%
distribute-neg-in66.8%
metadata-eval66.8%
unsub-neg66.8%
*-commutative66.8%
Simplified66.8%
Taylor expanded in x around inf 66.1%
+-commutative66.1%
unpow266.1%
distribute-rgt-out66.1%
Simplified66.1%
Taylor expanded in x around 0 5.0%
Final simplification5.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 2024019
(FPCore (x)
:name "3frac (problem 3.3.3)"
:precision binary64
:pre (> (fabs x) 1.0)
:herbie-target
(/ 2.0 (* x (- (* x x) 1.0)))
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))