
(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 (* (+ (fma 2.0 (pow x -2.0) 2.0) (fma 2.0 (pow x -6.0) (* 2.0 (+ (pow x -4.0) (pow x -8.0))))) (pow x -3.0)))
double code(double x) {
return (fma(2.0, pow(x, -2.0), 2.0) + fma(2.0, pow(x, -6.0), (2.0 * (pow(x, -4.0) + pow(x, -8.0))))) * pow(x, -3.0);
}
function code(x) return Float64(Float64(fma(2.0, (x ^ -2.0), 2.0) + fma(2.0, (x ^ -6.0), Float64(2.0 * Float64((x ^ -4.0) + (x ^ -8.0))))) * (x ^ -3.0)) end
code[x_] := N[(N[(N[(2.0 * N[Power[x, -2.0], $MachinePrecision] + 2.0), $MachinePrecision] + N[(2.0 * N[Power[x, -6.0], $MachinePrecision] + N[(2.0 * N[(N[Power[x, -4.0], $MachinePrecision] + N[Power[x, -8.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(2, {x}^{-2}, 2\right) + \mathsf{fma}\left(2, {x}^{-6}, 2 \cdot \left({x}^{-4} + {x}^{-8}\right)\right)\right) \cdot {x}^{-3}
\end{array}
Initial program 68.7%
+-commutative68.7%
associate-+r-68.7%
sub-neg68.7%
remove-double-neg68.7%
neg-sub068.7%
associate-+l-68.7%
neg-sub068.7%
distribute-neg-frac268.7%
distribute-frac-neg268.7%
associate-+r+68.7%
+-commutative68.7%
remove-double-neg68.7%
distribute-neg-frac268.7%
sub0-neg68.7%
associate-+l-68.7%
neg-sub068.7%
Simplified68.7%
Taylor expanded in x around inf 98.8%
*-un-lft-identity98.8%
div-inv98.8%
Applied egg-rr99.6%
associate-*r*99.6%
Simplified99.6%
(FPCore (x) :precision binary64 (* (pow x -3.0) (+ 2.0 (/ 2.0 (* x x)))))
double code(double x) {
return pow(x, -3.0) * (2.0 + (2.0 / (x * x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x ** (-3.0d0)) * (2.0d0 + (2.0d0 / (x * x)))
end function
public static double code(double x) {
return Math.pow(x, -3.0) * (2.0 + (2.0 / (x * x)));
}
def code(x): return math.pow(x, -3.0) * (2.0 + (2.0 / (x * x)))
function code(x) return Float64((x ^ -3.0) * Float64(2.0 + Float64(2.0 / Float64(x * x)))) end
function tmp = code(x) tmp = (x ^ -3.0) * (2.0 + (2.0 / (x * x))); end
code[x_] := N[(N[Power[x, -3.0], $MachinePrecision] * N[(2.0 + N[(2.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{x}^{-3} \cdot \left(2 + \frac{2}{x \cdot x}\right)
\end{array}
Initial program 68.7%
+-commutative68.7%
associate-+r-68.7%
sub-neg68.7%
remove-double-neg68.7%
neg-sub068.7%
associate-+l-68.7%
neg-sub068.7%
distribute-neg-frac268.7%
distribute-frac-neg268.7%
associate-+r+68.7%
+-commutative68.7%
remove-double-neg68.7%
distribute-neg-frac268.7%
sub0-neg68.7%
associate-+l-68.7%
neg-sub068.7%
Simplified68.7%
Taylor expanded in x around inf 98.8%
*-un-lft-identity98.8%
div-inv98.8%
Applied egg-rr99.6%
associate-*r*99.6%
Simplified99.6%
Taylor expanded in x around inf 98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
unpow298.9%
Applied egg-rr98.9%
Final simplification98.9%
(FPCore (x) :precision binary64 (- (/ 1.0 (+ x -1.0)) (/ (+ -1.0 (/ (* -2.0 (- -1.0 x)) x)) (- x -1.0))))
double code(double x) {
return (1.0 / (x + -1.0)) - ((-1.0 + ((-2.0 * (-1.0 - x)) / x)) / (x - -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x + (-1.0d0))) - (((-1.0d0) + (((-2.0d0) * ((-1.0d0) - x)) / x)) / (x - (-1.0d0)))
end function
public static double code(double x) {
return (1.0 / (x + -1.0)) - ((-1.0 + ((-2.0 * (-1.0 - x)) / x)) / (x - -1.0));
}
def code(x): return (1.0 / (x + -1.0)) - ((-1.0 + ((-2.0 * (-1.0 - x)) / x)) / (x - -1.0))
function code(x) return Float64(Float64(1.0 / Float64(x + -1.0)) - Float64(Float64(-1.0 + Float64(Float64(-2.0 * Float64(-1.0 - x)) / x)) / Float64(x - -1.0))) end
function tmp = code(x) tmp = (1.0 / (x + -1.0)) - ((-1.0 + ((-2.0 * (-1.0 - x)) / x)) / (x - -1.0)); end
code[x_] := N[(N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 + N[(N[(-2.0 * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + -1} - \frac{-1 + \frac{-2 \cdot \left(-1 - x\right)}{x}}{x - -1}
\end{array}
Initial program 68.7%
+-commutative68.7%
associate-+r-68.7%
sub-neg68.7%
remove-double-neg68.7%
neg-sub068.7%
associate-+l-68.7%
neg-sub068.7%
distribute-neg-frac268.7%
distribute-frac-neg268.7%
associate-+r+68.7%
+-commutative68.7%
remove-double-neg68.7%
distribute-neg-frac268.7%
sub0-neg68.7%
associate-+l-68.7%
neg-sub068.7%
Simplified68.7%
frac-sub17.3%
div-inv16.6%
*-rgt-identity16.6%
fmm-def16.6%
Applied egg-rr16.6%
associate-*r/17.3%
*-rgt-identity17.3%
associate-/r*68.8%
fmm-undef68.8%
div-sub68.7%
*-inverses68.7%
Simplified68.7%
Final simplification68.7%
(FPCore (x) :precision binary64 (+ (/ 1.0 (+ x -1.0)) (/ 1.0 (* x (/ (- -1.0 x) (+ 2.0 x))))))
double code(double x) {
return (1.0 / (x + -1.0)) + (1.0 / (x * ((-1.0 - x) / (2.0 + x))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x + (-1.0d0))) + (1.0d0 / (x * (((-1.0d0) - x) / (2.0d0 + x))))
end function
public static double code(double x) {
return (1.0 / (x + -1.0)) + (1.0 / (x * ((-1.0 - x) / (2.0 + x))));
}
def code(x): return (1.0 / (x + -1.0)) + (1.0 / (x * ((-1.0 - x) / (2.0 + x))))
function code(x) return Float64(Float64(1.0 / Float64(x + -1.0)) + Float64(1.0 / Float64(x * Float64(Float64(-1.0 - x) / Float64(2.0 + x))))) end
function tmp = code(x) tmp = (1.0 / (x + -1.0)) + (1.0 / (x * ((-1.0 - x) / (2.0 + x)))); end
code[x_] := N[(N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x * N[(N[(-1.0 - x), $MachinePrecision] / N[(2.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + -1} + \frac{1}{x \cdot \frac{-1 - x}{2 + x}}
\end{array}
Initial program 68.7%
+-commutative68.7%
associate-+r-68.7%
sub-neg68.7%
remove-double-neg68.7%
neg-sub068.7%
associate-+l-68.7%
neg-sub068.7%
distribute-neg-frac268.7%
distribute-frac-neg268.7%
associate-+r+68.7%
+-commutative68.7%
remove-double-neg68.7%
distribute-neg-frac268.7%
sub0-neg68.7%
associate-+l-68.7%
neg-sub068.7%
Simplified68.7%
frac-2neg68.7%
frac-2neg68.7%
metadata-eval68.7%
frac-sub17.3%
metadata-eval17.3%
sub-neg17.3%
distribute-neg-in17.3%
metadata-eval17.3%
neg-mul-117.3%
*-commutative17.3%
sub-neg17.3%
*-commutative17.3%
neg-mul-117.3%
sub-neg17.3%
distribute-neg-in17.3%
metadata-eval17.3%
neg-mul-117.3%
*-commutative17.3%
sub-neg17.3%
*-commutative17.3%
Applied egg-rr17.3%
*-commutative17.3%
sub-neg17.3%
remove-double-neg17.3%
distribute-rgt-in17.3%
metadata-eval17.3%
neg-mul-117.3%
remove-double-neg17.3%
sub-neg17.3%
remove-double-neg17.3%
distribute-lft-in17.3%
*-rgt-identity17.3%
neg-mul-117.3%
distribute-rgt-in17.3%
sub-neg17.3%
Simplified17.3%
clear-num20.2%
inv-pow20.2%
+-commutative20.2%
*-commutative20.2%
fma-define20.2%
Applied egg-rr20.2%
unpow-120.2%
associate-/l*68.7%
fma-undefine68.7%
*-commutative68.7%
distribute-lft1-in68.7%
distribute-rgt1-in68.7%
*-commutative68.7%
associate-+r-68.8%
*-lft-identity68.8%
distribute-rgt-out--68.8%
metadata-eval68.8%
*-rgt-identity68.8%
Simplified68.8%
(FPCore (x) :precision binary64 (+ (/ -2.0 x) (/ (/ (+ x x) (- -1.0 x)) (- 1.0 x))))
double code(double x) {
return (-2.0 / x) + (((x + x) / (-1.0 - x)) / (1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-2.0d0) / x) + (((x + x) / ((-1.0d0) - x)) / (1.0d0 - x))
end function
public static double code(double x) {
return (-2.0 / x) + (((x + x) / (-1.0 - x)) / (1.0 - x));
}
def code(x): return (-2.0 / x) + (((x + x) / (-1.0 - x)) / (1.0 - x))
function code(x) return Float64(Float64(-2.0 / x) + Float64(Float64(Float64(x + x) / Float64(-1.0 - x)) / Float64(1.0 - x))) end
function tmp = code(x) tmp = (-2.0 / x) + (((x + x) / (-1.0 - x)) / (1.0 - x)); end
code[x_] := N[(N[(-2.0 / x), $MachinePrecision] + N[(N[(N[(x + x), $MachinePrecision] / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-2}{x} + \frac{\frac{x + x}{-1 - x}}{1 - x}
\end{array}
Initial program 68.7%
+-commutative68.7%
associate-+r-68.7%
sub-neg68.7%
remove-double-neg68.7%
neg-sub068.7%
associate-+l-68.7%
neg-sub068.7%
distribute-neg-frac268.7%
distribute-frac-neg268.7%
associate-+r+68.7%
+-commutative68.7%
remove-double-neg68.7%
distribute-neg-frac268.7%
sub0-neg68.7%
associate-+l-68.7%
neg-sub068.7%
Simplified68.7%
+-commutative68.7%
associate-+l-68.7%
Applied egg-rr68.7%
frac-sub17.3%
*-un-lft-identity17.3%
Applied egg-rr17.3%
associate-/r*68.7%
metadata-eval68.7%
sub-neg68.7%
*-rgt-identity68.7%
associate--l-68.8%
associate-+r-68.7%
metadata-eval68.7%
neg-sub068.7%
Simplified68.7%
Final simplification68.7%
(FPCore (x) :precision binary64 (+ (/ -2.0 x) (+ (/ 1.0 (+ x -1.0)) (/ 1.0 (- x -1.0)))))
double code(double x) {
return (-2.0 / x) + ((1.0 / (x + -1.0)) + (1.0 / (x - -1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-2.0d0) / x) + ((1.0d0 / (x + (-1.0d0))) + (1.0d0 / (x - (-1.0d0))))
end function
public static double code(double x) {
return (-2.0 / x) + ((1.0 / (x + -1.0)) + (1.0 / (x - -1.0)));
}
def code(x): return (-2.0 / x) + ((1.0 / (x + -1.0)) + (1.0 / (x - -1.0)))
function code(x) return Float64(Float64(-2.0 / x) + Float64(Float64(1.0 / Float64(x + -1.0)) + Float64(1.0 / Float64(x - -1.0)))) end
function tmp = code(x) tmp = (-2.0 / x) + ((1.0 / (x + -1.0)) + (1.0 / (x - -1.0))); end
code[x_] := N[(N[(-2.0 / x), $MachinePrecision] + N[(N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-2}{x} + \left(\frac{1}{x + -1} + \frac{1}{x - -1}\right)
\end{array}
Initial program 68.7%
+-commutative68.7%
associate-+r-68.7%
sub-neg68.7%
remove-double-neg68.7%
neg-sub068.7%
associate-+l-68.7%
neg-sub068.7%
distribute-neg-frac268.7%
distribute-frac-neg268.7%
associate-+r+68.7%
+-commutative68.7%
remove-double-neg68.7%
distribute-neg-frac268.7%
sub0-neg68.7%
associate-+l-68.7%
neg-sub068.7%
Simplified68.7%
+-commutative68.7%
associate-+l-68.7%
Applied egg-rr68.7%
Final simplification68.7%
(FPCore (x) :precision binary64 (+ (/ 1.0 (+ x -1.0)) (- (/ 1.0 (+ x 1.0)) (/ 2.0 x))))
double code(double x) {
return (1.0 / (x + -1.0)) + ((1.0 / (x + 1.0)) - (2.0 / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x + (-1.0d0))) + ((1.0d0 / (x + 1.0d0)) - (2.0d0 / x))
end function
public static double code(double x) {
return (1.0 / (x + -1.0)) + ((1.0 / (x + 1.0)) - (2.0 / x));
}
def code(x): return (1.0 / (x + -1.0)) + ((1.0 / (x + 1.0)) - (2.0 / x))
function code(x) return Float64(Float64(1.0 / Float64(x + -1.0)) + Float64(Float64(1.0 / Float64(x + 1.0)) - Float64(2.0 / x))) end
function tmp = code(x) tmp = (1.0 / (x + -1.0)) + ((1.0 / (x + 1.0)) - (2.0 / x)); end
code[x_] := N[(N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + -1} + \left(\frac{1}{x + 1} - \frac{2}{x}\right)
\end{array}
Initial program 68.7%
Final simplification68.7%
(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 68.7%
+-commutative68.7%
associate-+r-68.7%
sub-neg68.7%
remove-double-neg68.7%
neg-sub068.7%
associate-+l-68.7%
neg-sub068.7%
distribute-neg-frac268.7%
distribute-frac-neg268.7%
associate-+r+68.7%
+-commutative68.7%
remove-double-neg68.7%
distribute-neg-frac268.7%
sub0-neg68.7%
associate-+l-68.7%
neg-sub068.7%
Simplified68.7%
Taylor expanded in x around inf 66.9%
associate-*r/66.9%
neg-mul-166.9%
distribute-neg-in66.9%
metadata-eval66.9%
distribute-neg-frac66.9%
metadata-eval66.9%
Simplified66.9%
Final simplification66.9%
(FPCore (x) :precision binary64 (/ (+ 2.0 (* x -2.0)) (* x (+ x -1.0))))
double code(double x) {
return (2.0 + (x * -2.0)) / (x * (x + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (2.0d0 + (x * (-2.0d0))) / (x * (x + (-1.0d0)))
end function
public static double code(double x) {
return (2.0 + (x * -2.0)) / (x * (x + -1.0));
}
def code(x): return (2.0 + (x * -2.0)) / (x * (x + -1.0))
function code(x) return Float64(Float64(2.0 + Float64(x * -2.0)) / Float64(x * Float64(x + -1.0))) end
function tmp = code(x) tmp = (2.0 + (x * -2.0)) / (x * (x + -1.0)); end
code[x_] := N[(N[(2.0 + N[(x * -2.0), $MachinePrecision]), $MachinePrecision] / N[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 + x \cdot -2}{x \cdot \left(x + -1\right)}
\end{array}
Initial program 68.7%
+-commutative68.7%
associate-+r-68.7%
sub-neg68.7%
remove-double-neg68.7%
neg-sub068.7%
associate-+l-68.7%
neg-sub068.7%
distribute-neg-frac268.7%
distribute-frac-neg268.7%
associate-+r+68.7%
+-commutative68.7%
remove-double-neg68.7%
distribute-neg-frac268.7%
sub0-neg68.7%
associate-+l-68.7%
neg-sub068.7%
Simplified68.7%
Taylor expanded in x around 0 3.5%
frac-add1.9%
*-un-lft-identity1.9%
sub-neg1.9%
metadata-eval1.9%
Applied egg-rr1.9%
Taylor expanded in x around 0 53.0%
*-commutative53.0%
Simplified53.0%
Final simplification53.0%
(FPCore (x) :precision binary64 (+ 1.0 (/ (+ -1.0 (/ 1.0 x)) x)))
double code(double x) {
return 1.0 + ((-1.0 + (1.0 / x)) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + (((-1.0d0) + (1.0d0 / x)) / x)
end function
public static double code(double x) {
return 1.0 + ((-1.0 + (1.0 / x)) / x);
}
def code(x): return 1.0 + ((-1.0 + (1.0 / x)) / x)
function code(x) return Float64(1.0 + Float64(Float64(-1.0 + Float64(1.0 / x)) / x)) end
function tmp = code(x) tmp = 1.0 + ((-1.0 + (1.0 / x)) / x); end
code[x_] := N[(1.0 + N[(N[(-1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{-1 + \frac{1}{x}}{x}
\end{array}
Initial program 68.7%
+-commutative68.7%
associate-+r-68.7%
sub-neg68.7%
remove-double-neg68.7%
neg-sub068.7%
associate-+l-68.7%
neg-sub068.7%
distribute-neg-frac268.7%
distribute-frac-neg268.7%
associate-+r+68.7%
+-commutative68.7%
remove-double-neg68.7%
distribute-neg-frac268.7%
sub0-neg68.7%
associate-+l-68.7%
neg-sub068.7%
Simplified68.7%
Taylor expanded in x around 0 3.5%
Taylor expanded in x around -inf 3.5%
mul-1-neg3.5%
unsub-neg3.5%
sub-neg3.5%
distribute-neg-frac3.5%
metadata-eval3.5%
Simplified3.5%
Final simplification3.5%
(FPCore (x) :precision binary64 (- 1.0 (/ 1.0 x)))
double code(double x) {
return 1.0 - (1.0 / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - (1.0d0 / x)
end function
public static double code(double x) {
return 1.0 - (1.0 / x);
}
def code(x): return 1.0 - (1.0 / x)
function code(x) return Float64(1.0 - Float64(1.0 / x)) end
function tmp = code(x) tmp = 1.0 - (1.0 / x); end
code[x_] := N[(1.0 - N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{1}{x}
\end{array}
Initial program 68.7%
+-commutative68.7%
associate-+r-68.7%
sub-neg68.7%
remove-double-neg68.7%
neg-sub068.7%
associate-+l-68.7%
neg-sub068.7%
distribute-neg-frac268.7%
distribute-frac-neg268.7%
associate-+r+68.7%
+-commutative68.7%
remove-double-neg68.7%
distribute-neg-frac268.7%
sub0-neg68.7%
associate-+l-68.7%
neg-sub068.7%
Simplified68.7%
Taylor expanded in x around 0 3.5%
Taylor expanded in x around inf 3.5%
(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 2024179
(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))))