
(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 13 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 65.0%
+-commutative65.0%
associate-+r-65.0%
sub-neg65.0%
remove-double-neg65.0%
neg-sub065.0%
associate-+l-65.0%
neg-sub065.0%
distribute-neg-frac265.0%
distribute-frac-neg265.0%
associate-+r+65.0%
+-commutative65.0%
remove-double-neg65.0%
distribute-neg-frac265.0%
sub0-neg65.0%
associate-+l-65.0%
neg-sub065.0%
Simplified65.0%
Taylor expanded in x around inf 99.2%
associate-*r/99.2%
metadata-eval99.2%
Simplified99.2%
div-inv99.2%
pow-flip100.0%
metadata-eval100.0%
+-commutative100.0%
div-inv100.0%
fma-define100.0%
pow-flip100.0%
metadata-eval100.0%
Applied egg-rr100.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 65.0%
+-commutative65.0%
associate-+r-65.0%
sub-neg65.0%
remove-double-neg65.0%
neg-sub065.0%
associate-+l-65.0%
neg-sub065.0%
distribute-neg-frac265.0%
distribute-frac-neg265.0%
associate-+r+65.0%
+-commutative65.0%
remove-double-neg65.0%
distribute-neg-frac265.0%
sub0-neg65.0%
associate-+l-65.0%
neg-sub065.0%
Simplified65.0%
Taylor expanded in x around inf 98.7%
div-inv98.7%
pow-flip99.5%
metadata-eval99.5%
Applied egg-rr99.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (+ x -1.0) (- x -1.0))))
(if (<= (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (+ x -1.0))) 5e-25)
(/ (- x (+ x -1.0)) (* x (+ x -1.0)))
(/ (+ (* x (+ (+ x -1.0) (- x -1.0))) (* -2.0 t_0)) (* x t_0)))))
double code(double x) {
double t_0 = (x + -1.0) * (x - -1.0);
double tmp;
if ((((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 5e-25) {
tmp = (x - (x + -1.0)) / (x * (x + -1.0));
} else {
tmp = ((x * ((x + -1.0) + (x - -1.0))) + (-2.0 * t_0)) / (x * 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 - (-1.0d0))
if ((((1.0d0 / (x + 1.0d0)) - (2.0d0 / x)) + (1.0d0 / (x + (-1.0d0)))) <= 5d-25) then
tmp = (x - (x + (-1.0d0))) / (x * (x + (-1.0d0)))
else
tmp = ((x * ((x + (-1.0d0)) + (x - (-1.0d0)))) + ((-2.0d0) * t_0)) / (x * t_0)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x + -1.0) * (x - -1.0);
double tmp;
if ((((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 5e-25) {
tmp = (x - (x + -1.0)) / (x * (x + -1.0));
} else {
tmp = ((x * ((x + -1.0) + (x - -1.0))) + (-2.0 * t_0)) / (x * t_0);
}
return tmp;
}
def code(x): t_0 = (x + -1.0) * (x - -1.0) tmp = 0 if (((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 5e-25: tmp = (x - (x + -1.0)) / (x * (x + -1.0)) else: tmp = ((x * ((x + -1.0) + (x - -1.0))) + (-2.0 * t_0)) / (x * t_0) return tmp
function code(x) t_0 = Float64(Float64(x + -1.0) * 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))) <= 5e-25) tmp = Float64(Float64(x - Float64(x + -1.0)) / Float64(x * Float64(x + -1.0))); else tmp = Float64(Float64(Float64(x * Float64(Float64(x + -1.0) + Float64(x - -1.0))) + Float64(-2.0 * t_0)) / Float64(x * t_0)); end return tmp end
function tmp_2 = code(x) t_0 = (x + -1.0) * (x - -1.0); tmp = 0.0; if ((((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0))) <= 5e-25) tmp = (x - (x + -1.0)) / (x * (x + -1.0)); else tmp = ((x * ((x + -1.0) + (x - -1.0))) + (-2.0 * t_0)) / (x * t_0); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(x + -1.0), $MachinePrecision] * 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], 5e-25], N[(N[(x - N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * N[(N[(x + -1.0), $MachinePrecision] + N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + -1\right) \cdot \left(x - -1\right)\\
\mathbf{if}\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x + -1} \leq 5 \cdot 10^{-25}:\\
\;\;\;\;\frac{x - \left(x + -1\right)}{x \cdot \left(x + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(\left(x + -1\right) + \left(x - -1\right)\right) + -2 \cdot t\_0}{x \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)))) < 4.99999999999999962e-25Initial program 65.5%
+-commutative65.5%
associate-+r-65.5%
sub-neg65.5%
remove-double-neg65.5%
neg-sub065.5%
associate-+l-65.5%
neg-sub065.5%
distribute-neg-frac265.5%
distribute-frac-neg265.5%
associate-+r+65.5%
+-commutative65.5%
remove-double-neg65.5%
distribute-neg-frac265.5%
sub0-neg65.5%
associate-+l-65.5%
neg-sub065.5%
Simplified65.5%
Taylor expanded in x around inf 65.2%
div-inv65.2%
mul-1-neg65.2%
add-sqr-sqrt17.3%
sqrt-prod14.6%
frac-times13.8%
metadata-eval13.8%
metadata-eval13.8%
frac-times14.6%
sqrt-unprod2.8%
add-sqr-sqrt6.1%
sub-neg6.1%
clear-num6.1%
frac-sub51.0%
Applied egg-rr65.2%
if 4.99999999999999962e-25 < (+.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 37.9%
+-commutative37.9%
associate-+r-37.9%
sub-neg37.9%
remove-double-neg37.9%
neg-sub037.9%
associate-+l-37.9%
neg-sub037.9%
distribute-neg-frac237.9%
distribute-frac-neg237.9%
associate-+r+37.9%
+-commutative37.9%
remove-double-neg37.9%
distribute-neg-frac237.9%
sub0-neg37.9%
associate-+l-37.9%
neg-sub037.9%
Simplified37.9%
+-commutative37.9%
associate-+l-37.9%
Applied egg-rr37.9%
frac-sub37.4%
frac-sub99.7%
*-un-lft-identity99.7%
*-rgt-identity99.7%
Applied egg-rr99.7%
Final simplification65.9%
(FPCore (x) :precision binary64 (+ (/ 1.0 (+ x -1.0)) (+ (/ -2.0 x) (/ -1.0 (* x (+ -1.0 (/ -1.0 x)))))))
double code(double x) {
return (1.0 / (x + -1.0)) + ((-2.0 / x) + (-1.0 / (x * (-1.0 + (-1.0 / x)))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x + (-1.0d0))) + (((-2.0d0) / x) + ((-1.0d0) / (x * ((-1.0d0) + ((-1.0d0) / x)))))
end function
public static double code(double x) {
return (1.0 / (x + -1.0)) + ((-2.0 / x) + (-1.0 / (x * (-1.0 + (-1.0 / x)))));
}
def code(x): return (1.0 / (x + -1.0)) + ((-2.0 / x) + (-1.0 / (x * (-1.0 + (-1.0 / x)))))
function code(x) return Float64(Float64(1.0 / Float64(x + -1.0)) + Float64(Float64(-2.0 / x) + Float64(-1.0 / Float64(x * Float64(-1.0 + Float64(-1.0 / x)))))) end
function tmp = code(x) tmp = (1.0 / (x + -1.0)) + ((-2.0 / x) + (-1.0 / (x * (-1.0 + (-1.0 / x))))); end
code[x_] := N[(N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-2.0 / x), $MachinePrecision] + N[(-1.0 / N[(x * N[(-1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + -1} + \left(\frac{-2}{x} + \frac{-1}{x \cdot \left(-1 + \frac{-1}{x}\right)}\right)
\end{array}
Initial program 65.0%
+-commutative65.0%
associate-+r-65.0%
sub-neg65.0%
remove-double-neg65.0%
neg-sub065.0%
associate-+l-65.0%
neg-sub065.0%
distribute-neg-frac265.0%
distribute-frac-neg265.0%
associate-+r+65.0%
+-commutative65.0%
remove-double-neg65.0%
distribute-neg-frac265.0%
sub0-neg65.0%
associate-+l-65.0%
neg-sub065.0%
Simplified65.0%
Taylor expanded in x around inf 65.0%
Final simplification65.0%
(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 65.0%
Final simplification65.0%
(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 65.0%
+-commutative65.0%
associate-+r-65.0%
sub-neg65.0%
remove-double-neg65.0%
neg-sub065.0%
associate-+l-65.0%
neg-sub065.0%
distribute-neg-frac265.0%
distribute-frac-neg265.0%
associate-+r+65.0%
+-commutative65.0%
remove-double-neg65.0%
distribute-neg-frac265.0%
sub0-neg65.0%
associate-+l-65.0%
neg-sub065.0%
Simplified65.0%
Taylor expanded in x around inf 64.4%
associate-*r/64.4%
neg-mul-164.4%
distribute-neg-in64.4%
metadata-eval64.4%
distribute-neg-frac64.4%
metadata-eval64.4%
Simplified64.4%
(FPCore (x) :precision binary64 (/ (- x (+ x -1.0)) (* x (+ x -1.0))))
double code(double x) {
return (x - (x + -1.0)) / (x * (x + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x - (x + (-1.0d0))) / (x * (x + (-1.0d0)))
end function
public static double code(double x) {
return (x - (x + -1.0)) / (x * (x + -1.0));
}
def code(x): return (x - (x + -1.0)) / (x * (x + -1.0))
function code(x) return Float64(Float64(x - Float64(x + -1.0)) / Float64(x * Float64(x + -1.0))) end
function tmp = code(x) tmp = (x - (x + -1.0)) / (x * (x + -1.0)); end
code[x_] := N[(N[(x - N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - \left(x + -1\right)}{x \cdot \left(x + -1\right)}
\end{array}
Initial program 65.0%
+-commutative65.0%
associate-+r-65.0%
sub-neg65.0%
remove-double-neg65.0%
neg-sub065.0%
associate-+l-65.0%
neg-sub065.0%
distribute-neg-frac265.0%
distribute-frac-neg265.0%
associate-+r+65.0%
+-commutative65.0%
remove-double-neg65.0%
distribute-neg-frac265.0%
sub0-neg65.0%
associate-+l-65.0%
neg-sub065.0%
Simplified65.0%
Taylor expanded in x around inf 64.2%
div-inv64.2%
mul-1-neg64.2%
add-sqr-sqrt17.2%
sqrt-prod14.6%
frac-times13.7%
metadata-eval13.7%
metadata-eval13.7%
frac-times14.6%
sqrt-unprod2.8%
add-sqr-sqrt6.2%
sub-neg6.2%
clear-num6.2%
frac-sub50.2%
Applied egg-rr64.2%
Final simplification64.2%
(FPCore (x) :precision binary64 (- (/ -1.0 x) (/ (+ -1.0 (/ -1.0 x)) x)))
double code(double x) {
return (-1.0 / x) - ((-1.0 + (-1.0 / x)) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-1.0d0) / x) - (((-1.0d0) + ((-1.0d0) / x)) / x)
end function
public static double code(double x) {
return (-1.0 / x) - ((-1.0 + (-1.0 / x)) / x);
}
def code(x): return (-1.0 / x) - ((-1.0 + (-1.0 / x)) / x)
function code(x) return Float64(Float64(-1.0 / x) - Float64(Float64(-1.0 + Float64(-1.0 / x)) / x)) end
function tmp = code(x) tmp = (-1.0 / x) - ((-1.0 + (-1.0 / x)) / x); end
code[x_] := N[(N[(-1.0 / x), $MachinePrecision] - N[(N[(-1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{x} - \frac{-1 + \frac{-1}{x}}{x}
\end{array}
Initial program 65.0%
+-commutative65.0%
associate-+r-65.0%
sub-neg65.0%
remove-double-neg65.0%
neg-sub065.0%
associate-+l-65.0%
neg-sub065.0%
distribute-neg-frac265.0%
distribute-frac-neg265.0%
associate-+r+65.0%
+-commutative65.0%
remove-double-neg65.0%
distribute-neg-frac265.0%
sub0-neg65.0%
associate-+l-65.0%
neg-sub065.0%
Simplified65.0%
Taylor expanded in x around inf 64.2%
Taylor expanded in x around inf 64.2%
Final simplification64.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 65.0%
+-commutative65.0%
associate-+r-65.0%
sub-neg65.0%
remove-double-neg65.0%
neg-sub065.0%
associate-+l-65.0%
neg-sub065.0%
distribute-neg-frac265.0%
distribute-frac-neg265.0%
associate-+r+65.0%
+-commutative65.0%
remove-double-neg65.0%
distribute-neg-frac265.0%
sub0-neg65.0%
associate-+l-65.0%
neg-sub065.0%
Simplified65.0%
Taylor expanded in x around inf 64.2%
Final simplification64.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 65.0%
+-commutative65.0%
associate-+r-65.0%
sub-neg65.0%
remove-double-neg65.0%
neg-sub065.0%
associate-+l-65.0%
neg-sub065.0%
distribute-neg-frac265.0%
distribute-frac-neg265.0%
associate-+r+65.0%
+-commutative65.0%
remove-double-neg65.0%
distribute-neg-frac265.0%
sub0-neg65.0%
associate-+l-65.0%
neg-sub065.0%
Simplified65.0%
Taylor expanded in x around inf 64.2%
Taylor expanded in x around inf 63.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 65.0%
+-commutative65.0%
associate-+r-65.0%
sub-neg65.0%
remove-double-neg65.0%
neg-sub065.0%
associate-+l-65.0%
neg-sub065.0%
distribute-neg-frac265.0%
distribute-frac-neg265.0%
associate-+r+65.0%
+-commutative65.0%
remove-double-neg65.0%
distribute-neg-frac265.0%
sub0-neg65.0%
associate-+l-65.0%
neg-sub065.0%
Simplified65.0%
clear-num65.0%
frac-sub18.5%
*-un-lft-identity18.5%
div-inv18.5%
metadata-eval18.5%
div-inv18.5%
metadata-eval18.5%
Applied egg-rr18.5%
sub-neg18.5%
sub-neg18.5%
distribute-rgt-neg-in18.5%
metadata-eval18.5%
associate-+l+18.5%
neg-mul-118.5%
*-commutative18.5%
associate-*l*18.5%
distribute-lft-out18.5%
metadata-eval18.5%
metadata-eval18.5%
associate-*l*18.5%
sub-neg18.5%
+-commutative18.5%
distribute-rgt-in18.5%
distribute-lft-neg-in18.5%
distribute-rgt-neg-in18.5%
metadata-eval18.5%
metadata-eval18.5%
Simplified18.5%
Taylor expanded in x around inf 17.5%
Taylor expanded in x around 0 4.9%
div-inv4.9%
frac-2neg4.9%
metadata-eval4.9%
pow14.9%
metadata-eval4.9%
sqrt-pow149.7%
pow249.7%
sqr-neg49.7%
sqrt-prod3.5%
add-sqr-sqrt6.2%
Applied egg-rr6.2%
associate-*r/6.2%
metadata-eval6.2%
Simplified6.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 65.0%
+-commutative65.0%
associate-+r-65.0%
sub-neg65.0%
remove-double-neg65.0%
neg-sub065.0%
associate-+l-65.0%
neg-sub065.0%
distribute-neg-frac265.0%
distribute-frac-neg265.0%
associate-+r+65.0%
+-commutative65.0%
remove-double-neg65.0%
distribute-neg-frac265.0%
sub0-neg65.0%
associate-+l-65.0%
neg-sub065.0%
Simplified65.0%
clear-num65.0%
frac-sub18.5%
*-un-lft-identity18.5%
div-inv18.5%
metadata-eval18.5%
div-inv18.5%
metadata-eval18.5%
Applied egg-rr18.5%
sub-neg18.5%
sub-neg18.5%
distribute-rgt-neg-in18.5%
metadata-eval18.5%
associate-+l+18.5%
neg-mul-118.5%
*-commutative18.5%
associate-*l*18.5%
distribute-lft-out18.5%
metadata-eval18.5%
metadata-eval18.5%
associate-*l*18.5%
sub-neg18.5%
+-commutative18.5%
distribute-rgt-in18.5%
distribute-lft-neg-in18.5%
distribute-rgt-neg-in18.5%
metadata-eval18.5%
metadata-eval18.5%
Simplified18.5%
Taylor expanded in x around inf 17.5%
Taylor expanded in x around 0 4.9%
(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 65.0%
+-commutative65.0%
associate-+r-65.0%
sub-neg65.0%
remove-double-neg65.0%
neg-sub065.0%
associate-+l-65.0%
neg-sub065.0%
distribute-neg-frac265.0%
distribute-frac-neg265.0%
associate-+r+65.0%
+-commutative65.0%
remove-double-neg65.0%
distribute-neg-frac265.0%
sub0-neg65.0%
associate-+l-65.0%
neg-sub065.0%
Simplified65.0%
Taylor expanded in x around 0 4.9%
(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 2024123
(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))))