
(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 17 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 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
Taylor expanded in x around inf 99.2%
associate-*r/99.2%
metadata-eval99.2%
Simplified99.2%
div-inv99.2%
+-commutative99.2%
div-inv99.2%
fma-define99.2%
pow-flip99.2%
metadata-eval99.2%
pow-flip99.7%
metadata-eval99.7%
Applied egg-rr99.7%
(FPCore (x) :precision binary64 (/ (/ (/ (- (/ (+ (/ (- (* 16.0 (/ 1.0 x)) 8.0) x) 4.0) x) 2.0) x) (* x (/ (+ x 1.0) (+ 2.0 x)))) (- 1.0 x)))
double code(double x) {
return ((((((((16.0 * (1.0 / x)) - 8.0) / x) + 4.0) / x) - 2.0) / x) / (x * ((x + 1.0) / (2.0 + x)))) / (1.0 - x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((((((((16.0d0 * (1.0d0 / x)) - 8.0d0) / x) + 4.0d0) / x) - 2.0d0) / x) / (x * ((x + 1.0d0) / (2.0d0 + x)))) / (1.0d0 - x)
end function
public static double code(double x) {
return ((((((((16.0 * (1.0 / x)) - 8.0) / x) + 4.0) / x) - 2.0) / x) / (x * ((x + 1.0) / (2.0 + x)))) / (1.0 - x);
}
def code(x): return ((((((((16.0 * (1.0 / x)) - 8.0) / x) + 4.0) / x) - 2.0) / x) / (x * ((x + 1.0) / (2.0 + x)))) / (1.0 - x)
function code(x) return Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(16.0 * Float64(1.0 / x)) - 8.0) / x) + 4.0) / x) - 2.0) / x) / Float64(x * Float64(Float64(x + 1.0) / Float64(2.0 + x)))) / Float64(1.0 - x)) end
function tmp = code(x) tmp = ((((((((16.0 * (1.0 / x)) - 8.0) / x) + 4.0) / x) - 2.0) / x) / (x * ((x + 1.0) / (2.0 + x)))) / (1.0 - x); end
code[x_] := N[(N[(N[(N[(N[(N[(N[(N[(N[(16.0 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision] - 8.0), $MachinePrecision] / x), $MachinePrecision] + 4.0), $MachinePrecision] / x), $MachinePrecision] - 2.0), $MachinePrecision] / x), $MachinePrecision] / N[(x * N[(N[(x + 1.0), $MachinePrecision] / N[(2.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{\frac{\frac{16 \cdot \frac{1}{x} - 8}{x} + 4}{x} - 2}{x}}{x \cdot \frac{x + 1}{2 + x}}}{1 - x}
\end{array}
Initial program 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
frac-2neg72.0%
frac-2neg72.0%
metadata-eval72.0%
frac-sub15.7%
metadata-eval15.7%
sub-neg15.7%
distribute-neg-in15.7%
metadata-eval15.7%
neg-mul-115.7%
*-commutative15.7%
sub-neg15.7%
*-commutative15.7%
neg-mul-115.7%
sub-neg15.7%
distribute-neg-in15.7%
metadata-eval15.7%
neg-mul-115.7%
*-commutative15.7%
sub-neg15.7%
*-commutative15.7%
Applied egg-rr15.7%
*-commutative15.7%
sub-neg15.7%
remove-double-neg15.7%
distribute-lft-in15.7%
metadata-eval15.7%
neg-mul-115.7%
remove-double-neg15.7%
sub-neg15.7%
remove-double-neg15.7%
distribute-lft-in15.7%
*-rgt-identity15.7%
neg-mul-115.7%
distribute-rgt-in15.7%
sub-neg15.7%
Simplified15.7%
frac-2neg15.7%
metadata-eval15.7%
clear-num18.2%
frac-add14.1%
+-commutative14.1%
fma-define14.1%
+-commutative14.1%
fma-define14.1%
Applied egg-rr14.1%
Simplified72.0%
Taylor expanded in x around -inf 99.5%
Final simplification99.5%
(FPCore (x) :precision binary64 (/ (/ (/ (+ -2.0 (/ (+ 4.0 (/ -8.0 x)) x)) x) (* x (/ (+ x 1.0) (+ 2.0 x)))) (- 1.0 x)))
double code(double x) {
return (((-2.0 + ((4.0 + (-8.0 / x)) / x)) / x) / (x * ((x + 1.0) / (2.0 + x)))) / (1.0 - x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((((-2.0d0) + ((4.0d0 + ((-8.0d0) / x)) / x)) / x) / (x * ((x + 1.0d0) / (2.0d0 + x)))) / (1.0d0 - x)
end function
public static double code(double x) {
return (((-2.0 + ((4.0 + (-8.0 / x)) / x)) / x) / (x * ((x + 1.0) / (2.0 + x)))) / (1.0 - x);
}
def code(x): return (((-2.0 + ((4.0 + (-8.0 / x)) / x)) / x) / (x * ((x + 1.0) / (2.0 + x)))) / (1.0 - x)
function code(x) return Float64(Float64(Float64(Float64(-2.0 + Float64(Float64(4.0 + Float64(-8.0 / x)) / x)) / x) / Float64(x * Float64(Float64(x + 1.0) / Float64(2.0 + x)))) / Float64(1.0 - x)) end
function tmp = code(x) tmp = (((-2.0 + ((4.0 + (-8.0 / x)) / x)) / x) / (x * ((x + 1.0) / (2.0 + x)))) / (1.0 - x); end
code[x_] := N[(N[(N[(N[(-2.0 + N[(N[(4.0 + N[(-8.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / N[(x * N[(N[(x + 1.0), $MachinePrecision] / N[(2.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{-2 + \frac{4 + \frac{-8}{x}}{x}}{x}}{x \cdot \frac{x + 1}{2 + x}}}{1 - x}
\end{array}
Initial program 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
frac-2neg72.0%
frac-2neg72.0%
metadata-eval72.0%
frac-sub15.7%
metadata-eval15.7%
sub-neg15.7%
distribute-neg-in15.7%
metadata-eval15.7%
neg-mul-115.7%
*-commutative15.7%
sub-neg15.7%
*-commutative15.7%
neg-mul-115.7%
sub-neg15.7%
distribute-neg-in15.7%
metadata-eval15.7%
neg-mul-115.7%
*-commutative15.7%
sub-neg15.7%
*-commutative15.7%
Applied egg-rr15.7%
*-commutative15.7%
sub-neg15.7%
remove-double-neg15.7%
distribute-lft-in15.7%
metadata-eval15.7%
neg-mul-115.7%
remove-double-neg15.7%
sub-neg15.7%
remove-double-neg15.7%
distribute-lft-in15.7%
*-rgt-identity15.7%
neg-mul-115.7%
distribute-rgt-in15.7%
sub-neg15.7%
Simplified15.7%
frac-2neg15.7%
metadata-eval15.7%
clear-num18.2%
frac-add14.1%
+-commutative14.1%
fma-define14.1%
+-commutative14.1%
fma-define14.1%
Applied egg-rr14.1%
Simplified72.0%
Taylor expanded in x around -inf 99.5%
mul-1-neg99.5%
distribute-neg-frac299.5%
sub-neg99.5%
associate-*r/99.5%
sub-neg99.5%
distribute-lft-in99.5%
neg-mul-199.5%
associate-*r/99.5%
metadata-eval99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
metadata-eval99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x) :precision binary64 (/ (/ (/ (- (/ 4.0 x) 2.0) x) (* x (/ (+ x 1.0) (+ 2.0 x)))) (- 1.0 x)))
double code(double x) {
return ((((4.0 / x) - 2.0) / x) / (x * ((x + 1.0) / (2.0 + x)))) / (1.0 - x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((((4.0d0 / x) - 2.0d0) / x) / (x * ((x + 1.0d0) / (2.0d0 + x)))) / (1.0d0 - x)
end function
public static double code(double x) {
return ((((4.0 / x) - 2.0) / x) / (x * ((x + 1.0) / (2.0 + x)))) / (1.0 - x);
}
def code(x): return ((((4.0 / x) - 2.0) / x) / (x * ((x + 1.0) / (2.0 + x)))) / (1.0 - x)
function code(x) return Float64(Float64(Float64(Float64(Float64(4.0 / x) - 2.0) / x) / Float64(x * Float64(Float64(x + 1.0) / Float64(2.0 + x)))) / Float64(1.0 - x)) end
function tmp = code(x) tmp = ((((4.0 / x) - 2.0) / x) / (x * ((x + 1.0) / (2.0 + x)))) / (1.0 - x); end
code[x_] := N[(N[(N[(N[(N[(4.0 / x), $MachinePrecision] - 2.0), $MachinePrecision] / x), $MachinePrecision] / N[(x * N[(N[(x + 1.0), $MachinePrecision] / N[(2.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{\frac{4}{x} - 2}{x}}{x \cdot \frac{x + 1}{2 + x}}}{1 - x}
\end{array}
Initial program 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
frac-2neg72.0%
frac-2neg72.0%
metadata-eval72.0%
frac-sub15.7%
metadata-eval15.7%
sub-neg15.7%
distribute-neg-in15.7%
metadata-eval15.7%
neg-mul-115.7%
*-commutative15.7%
sub-neg15.7%
*-commutative15.7%
neg-mul-115.7%
sub-neg15.7%
distribute-neg-in15.7%
metadata-eval15.7%
neg-mul-115.7%
*-commutative15.7%
sub-neg15.7%
*-commutative15.7%
Applied egg-rr15.7%
*-commutative15.7%
sub-neg15.7%
remove-double-neg15.7%
distribute-lft-in15.7%
metadata-eval15.7%
neg-mul-115.7%
remove-double-neg15.7%
sub-neg15.7%
remove-double-neg15.7%
distribute-lft-in15.7%
*-rgt-identity15.7%
neg-mul-115.7%
distribute-rgt-in15.7%
sub-neg15.7%
Simplified15.7%
frac-2neg15.7%
metadata-eval15.7%
clear-num18.2%
frac-add14.1%
+-commutative14.1%
fma-define14.1%
+-commutative14.1%
fma-define14.1%
Applied egg-rr14.1%
Simplified72.0%
Taylor expanded in x around inf 99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (x) :precision binary64 (/ (/ (/ 2.0 x) (* x (/ (+ x 1.0) (+ 2.0 x)))) (+ x -1.0)))
double code(double x) {
return ((2.0 / x) / (x * ((x + 1.0) / (2.0 + x)))) / (x + -1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((2.0d0 / x) / (x * ((x + 1.0d0) / (2.0d0 + x)))) / (x + (-1.0d0))
end function
public static double code(double x) {
return ((2.0 / x) / (x * ((x + 1.0) / (2.0 + x)))) / (x + -1.0);
}
def code(x): return ((2.0 / x) / (x * ((x + 1.0) / (2.0 + x)))) / (x + -1.0)
function code(x) return Float64(Float64(Float64(2.0 / x) / Float64(x * Float64(Float64(x + 1.0) / Float64(2.0 + x)))) / Float64(x + -1.0)) end
function tmp = code(x) tmp = ((2.0 / x) / (x * ((x + 1.0) / (2.0 + x)))) / (x + -1.0); end
code[x_] := N[(N[(N[(2.0 / x), $MachinePrecision] / N[(x * N[(N[(x + 1.0), $MachinePrecision] / N[(2.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{2}{x}}{x \cdot \frac{x + 1}{2 + x}}}{x + -1}
\end{array}
Initial program 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
frac-2neg72.0%
frac-2neg72.0%
metadata-eval72.0%
frac-sub15.7%
metadata-eval15.7%
sub-neg15.7%
distribute-neg-in15.7%
metadata-eval15.7%
neg-mul-115.7%
*-commutative15.7%
sub-neg15.7%
*-commutative15.7%
neg-mul-115.7%
sub-neg15.7%
distribute-neg-in15.7%
metadata-eval15.7%
neg-mul-115.7%
*-commutative15.7%
sub-neg15.7%
*-commutative15.7%
Applied egg-rr15.7%
*-commutative15.7%
sub-neg15.7%
remove-double-neg15.7%
distribute-lft-in15.7%
metadata-eval15.7%
neg-mul-115.7%
remove-double-neg15.7%
sub-neg15.7%
remove-double-neg15.7%
distribute-lft-in15.7%
*-rgt-identity15.7%
neg-mul-115.7%
distribute-rgt-in15.7%
sub-neg15.7%
Simplified15.7%
frac-2neg15.7%
metadata-eval15.7%
clear-num18.2%
frac-add14.1%
+-commutative14.1%
fma-define14.1%
+-commutative14.1%
fma-define14.1%
Applied egg-rr14.1%
Simplified72.0%
Taylor expanded in x around inf 97.9%
Final simplification97.9%
(FPCore (x) :precision binary64 (+ (/ -1.0 (- 1.0 x)) (/ (+ -1.0 (+ 2.0 (/ 2.0 x))) (- -1.0 x))))
double code(double x) {
return (-1.0 / (1.0 - x)) + ((-1.0 + (2.0 + (2.0 / x))) / (-1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-1.0d0) / (1.0d0 - x)) + (((-1.0d0) + (2.0d0 + (2.0d0 / x))) / ((-1.0d0) - x))
end function
public static double code(double x) {
return (-1.0 / (1.0 - x)) + ((-1.0 + (2.0 + (2.0 / x))) / (-1.0 - x));
}
def code(x): return (-1.0 / (1.0 - x)) + ((-1.0 + (2.0 + (2.0 / x))) / (-1.0 - x))
function code(x) return Float64(Float64(-1.0 / Float64(1.0 - x)) + Float64(Float64(-1.0 + Float64(2.0 + Float64(2.0 / x))) / Float64(-1.0 - x))) end
function tmp = code(x) tmp = (-1.0 / (1.0 - x)) + ((-1.0 + (2.0 + (2.0 / x))) / (-1.0 - x)); end
code[x_] := N[(N[(-1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 + N[(2.0 + N[(2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{1 - x} + \frac{-1 + \left(2 + \frac{2}{x}\right)}{-1 - x}
\end{array}
Initial program 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
+-commutative72.0%
frac-sub15.7%
div-inv13.0%
fma-define7.2%
*-rgt-identity7.2%
fmm-def7.2%
Applied egg-rr7.2%
fma-undefine13.0%
+-commutative13.0%
associate-*r/15.7%
*-rgt-identity15.7%
associate-/r*72.0%
fmm-undef72.0%
div-sub72.0%
*-inverses72.0%
Simplified72.0%
Taylor expanded in x around inf 72.0%
associate-*r/72.0%
metadata-eval72.0%
Simplified72.0%
Final simplification72.0%
(FPCore (x) :precision binary64 (+ (/ -1.0 (- 1.0 x)) (/ (/ (+ 2.0 x) x) (- -1.0 x))))
double code(double x) {
return (-1.0 / (1.0 - x)) + (((2.0 + x) / x) / (-1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-1.0d0) / (1.0d0 - x)) + (((2.0d0 + x) / x) / ((-1.0d0) - x))
end function
public static double code(double x) {
return (-1.0 / (1.0 - x)) + (((2.0 + x) / x) / (-1.0 - x));
}
def code(x): return (-1.0 / (1.0 - x)) + (((2.0 + x) / x) / (-1.0 - x))
function code(x) return Float64(Float64(-1.0 / Float64(1.0 - x)) + Float64(Float64(Float64(2.0 + x) / x) / Float64(-1.0 - x))) end
function tmp = code(x) tmp = (-1.0 / (1.0 - x)) + (((2.0 + x) / x) / (-1.0 - x)); end
code[x_] := N[(N[(-1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(2.0 + x), $MachinePrecision] / x), $MachinePrecision] / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{1 - x} + \frac{\frac{2 + x}{x}}{-1 - x}
\end{array}
Initial program 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
+-commutative72.0%
frac-sub15.7%
div-inv13.0%
fma-define7.2%
*-rgt-identity7.2%
fmm-def7.2%
Applied egg-rr7.2%
fma-undefine13.0%
+-commutative13.0%
associate-*r/15.7%
*-rgt-identity15.7%
associate-/r*72.0%
fmm-undef72.0%
div-sub72.0%
*-inverses72.0%
Simplified72.0%
Taylor expanded in x around 0 72.0%
Final simplification72.0%
(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(-1.0 / Float64(1.0 - x)) - Float64(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[(-1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] - N[(N[(2.0 / x), $MachinePrecision] + N[(-1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{1 - x} - \left(\frac{2}{x} + \frac{-1}{x + 1}\right)
\end{array}
Initial program 72.0%
Final simplification72.0%
(FPCore (x) :precision binary64 (+ (* (/ 1.0 x) (+ 1.0 (/ 1.0 x))) (/ -1.0 x)))
double code(double x) {
return ((1.0 / x) * (1.0 + (1.0 / x))) + (-1.0 / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / x) * (1.0d0 + (1.0d0 / x))) + ((-1.0d0) / x)
end function
public static double code(double x) {
return ((1.0 / x) * (1.0 + (1.0 / x))) + (-1.0 / x);
}
def code(x): return ((1.0 / x) * (1.0 + (1.0 / x))) + (-1.0 / x)
function code(x) return Float64(Float64(Float64(1.0 / x) * Float64(1.0 + Float64(1.0 / x))) + Float64(-1.0 / x)) end
function tmp = code(x) tmp = ((1.0 / x) * (1.0 + (1.0 / x))) + (-1.0 / x); end
code[x_] := N[(N[(N[(1.0 / x), $MachinePrecision] * N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x} \cdot \left(1 + \frac{1}{x}\right) + \frac{-1}{x}
\end{array}
Initial program 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
Taylor expanded in x around inf 71.1%
Taylor expanded in x around inf 70.9%
div-inv70.9%
Applied egg-rr70.9%
Final simplification70.9%
(FPCore (x) :precision binary64 (* (/ 1.0 x) (+ -1.0 (+ 1.0 (/ 1.0 x)))))
double code(double x) {
return (1.0 / x) * (-1.0 + (1.0 + (1.0 / x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / x) * ((-1.0d0) + (1.0d0 + (1.0d0 / x)))
end function
public static double code(double x) {
return (1.0 / x) * (-1.0 + (1.0 + (1.0 / x)));
}
def code(x): return (1.0 / x) * (-1.0 + (1.0 + (1.0 / x)))
function code(x) return Float64(Float64(1.0 / x) * Float64(-1.0 + Float64(1.0 + Float64(1.0 / x)))) end
function tmp = code(x) tmp = (1.0 / x) * (-1.0 + (1.0 + (1.0 / x))); end
code[x_] := N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 + N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x} \cdot \left(-1 + \left(1 + \frac{1}{x}\right)\right)
\end{array}
Initial program 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
Taylor expanded in x around inf 71.1%
Taylor expanded in x around inf 70.9%
div-inv70.9%
Applied egg-rr70.9%
+-commutative70.9%
div-inv70.9%
fma-define70.9%
un-div-inv70.9%
Applied egg-rr70.9%
fma-undefine70.9%
*-rgt-identity70.9%
associate-/l*70.9%
distribute-rgt-out70.9%
Simplified70.9%
(FPCore (x) :precision binary64 (/ (- (+ x 1.0) x) (* x x)))
double code(double x) {
return ((x + 1.0) - x) / (x * x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x + 1.0d0) - x) / (x * x)
end function
public static double code(double x) {
return ((x + 1.0) - x) / (x * x);
}
def code(x): return ((x + 1.0) - x) / (x * x)
function code(x) return Float64(Float64(Float64(x + 1.0) - x) / Float64(x * x)) end
function tmp = code(x) tmp = ((x + 1.0) - x) / (x * x); end
code[x_] := N[(N[(N[(x + 1.0), $MachinePrecision] - x), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x + 1\right) - x}{x \cdot x}
\end{array}
Initial program 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
Taylor expanded in x around inf 71.1%
Taylor expanded in x around inf 70.9%
+-commutative70.9%
frac-2neg70.9%
metadata-eval70.9%
frac-add70.9%
*-un-lft-identity70.9%
Applied egg-rr70.9%
add-sqr-sqrt31.2%
fma-define27.8%
distribute-lft-neg-out27.8%
add-sqr-sqrt27.9%
sqrt-unprod1.2%
sqr-neg1.2%
sqrt-unprod0.0%
add-sqr-sqrt27.3%
fmm-def27.3%
add-sqr-sqrt58.7%
add-sqr-sqrt31.5%
sqrt-unprod7.2%
sqr-neg7.2%
sqrt-unprod31.2%
add-sqr-sqrt70.9%
Applied egg-rr70.9%
distribute-lft-in70.9%
*-rgt-identity70.9%
rgt-mult-inverse70.9%
Simplified70.9%
Final simplification70.9%
(FPCore (x) :precision binary64 (+ (/ -1.0 (- 1.0 x)) (/ -1.0 x)))
double code(double x) {
return (-1.0 / (1.0 - x)) + (-1.0 / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-1.0d0) / (1.0d0 - x)) + ((-1.0d0) / x)
end function
public static double code(double x) {
return (-1.0 / (1.0 - x)) + (-1.0 / x);
}
def code(x): return (-1.0 / (1.0 - x)) + (-1.0 / x)
function code(x) return Float64(Float64(-1.0 / Float64(1.0 - x)) + Float64(-1.0 / x)) end
function tmp = code(x) tmp = (-1.0 / (1.0 - x)) + (-1.0 / x); end
code[x_] := N[(N[(-1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{1 - x} + \frac{-1}{x}
\end{array}
Initial program 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
Taylor expanded in x around inf 70.9%
Final simplification70.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 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
Taylor expanded in x around inf 71.1%
Taylor expanded in x around inf 70.9%
div-inv70.9%
Applied egg-rr70.9%
Taylor expanded in x around inf 70.7%
(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(Float64(x - 2.0) / x)) end
function tmp = code(x) tmp = -1.0 + ((x - 2.0) / x); end
code[x_] := N[(-1.0 + N[(N[(x - 2.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \frac{x - 2}{x}
\end{array}
Initial program 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
Taylor expanded in x around 0 3.4%
Taylor expanded in x around 0 70.7%
(FPCore (x) :precision binary64 (/ -1.0 (- (* x x))))
double code(double x) {
return -1.0 / -(x * x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-1.0d0) / -(x * x)
end function
public static double code(double x) {
return -1.0 / -(x * x);
}
def code(x): return -1.0 / -(x * x)
function code(x) return Float64(-1.0 / Float64(-Float64(x * x))) end
function tmp = code(x) tmp = -1.0 / -(x * x); end
code[x_] := N[(-1.0 / (-N[(x * x), $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{-x \cdot x}
\end{array}
Initial program 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
Taylor expanded in x around inf 71.1%
Taylor expanded in x around inf 70.9%
+-commutative70.9%
frac-2neg70.9%
metadata-eval70.9%
frac-add70.9%
*-un-lft-identity70.9%
Applied egg-rr70.9%
Taylor expanded in x around 0 60.2%
Final simplification60.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 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
Taylor expanded in x around 0 5.4%
(FPCore (x) :precision binary64 1.0)
double code(double x) {
return 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0
end function
public static double code(double x) {
return 1.0;
}
def code(x): return 1.0
function code(x) return 1.0 end
function tmp = code(x) tmp = 1.0; end
code[x_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 72.0%
+-commutative72.0%
associate-+r-71.9%
sub-neg71.9%
remove-double-neg71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
distribute-neg-frac271.9%
distribute-frac-neg271.9%
associate-+r+72.0%
+-commutative72.0%
remove-double-neg72.0%
distribute-neg-frac272.0%
sub0-neg72.0%
associate-+l-72.0%
neg-sub072.0%
Simplified72.0%
Taylor expanded in x around 0 3.4%
Taylor expanded in x around inf 3.4%
(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 2024170
(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))))