
(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 12 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)) (+ (/ 2.0 (pow x 7.0)) (+ (* 2.0 (pow x -3.0)) (/ 2.0 (pow x 9.0))))))
double code(double x) {
return (2.0 / pow(x, 5.0)) + ((2.0 / pow(x, 7.0)) + ((2.0 * pow(x, -3.0)) + (2.0 / pow(x, 9.0))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (2.0d0 / (x ** 5.0d0)) + ((2.0d0 / (x ** 7.0d0)) + ((2.0d0 * (x ** (-3.0d0))) + (2.0d0 / (x ** 9.0d0))))
end function
public static double code(double x) {
return (2.0 / Math.pow(x, 5.0)) + ((2.0 / Math.pow(x, 7.0)) + ((2.0 * Math.pow(x, -3.0)) + (2.0 / Math.pow(x, 9.0))));
}
def code(x): return (2.0 / math.pow(x, 5.0)) + ((2.0 / math.pow(x, 7.0)) + ((2.0 * math.pow(x, -3.0)) + (2.0 / math.pow(x, 9.0))))
function code(x) return Float64(Float64(2.0 / (x ^ 5.0)) + Float64(Float64(2.0 / (x ^ 7.0)) + Float64(Float64(2.0 * (x ^ -3.0)) + Float64(2.0 / (x ^ 9.0))))) end
function tmp = code(x) tmp = (2.0 / (x ^ 5.0)) + ((2.0 / (x ^ 7.0)) + ((2.0 * (x ^ -3.0)) + (2.0 / (x ^ 9.0)))); end
code[x_] := N[(N[(2.0 / N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 / N[Power[x, 7.0], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 * N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 / N[Power[x, 9.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{{x}^{5}} + \left(\frac{2}{{x}^{7}} + \left(2 \cdot {x}^{-3} + \frac{2}{{x}^{9}}\right)\right)
\end{array}
Initial program 7.7%
sub-neg7.7%
distribute-neg-frac7.7%
metadata-eval7.7%
metadata-eval7.7%
metadata-eval7.7%
associate-/r*7.7%
metadata-eval7.7%
neg-mul-17.7%
+-commutative7.7%
associate-+l+7.5%
+-commutative7.5%
neg-mul-17.5%
metadata-eval7.5%
associate-/r*7.5%
metadata-eval7.5%
metadata-eval7.5%
+-commutative7.5%
+-commutative7.5%
Simplified7.5%
Taylor expanded in x around inf 99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
+-commutative99.6%
associate-*r/99.6%
metadata-eval99.6%
associate-*r/99.6%
metadata-eval99.6%
Simplified99.6%
expm1-log1p-u99.6%
expm1-udef8.1%
div-inv8.1%
pow-flip8.1%
metadata-eval8.1%
Applied egg-rr8.1%
expm1-def99.9%
expm1-log1p99.9%
Simplified99.9%
Final simplification99.9%
(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 7.7%
sub-neg7.7%
distribute-neg-frac7.7%
metadata-eval7.7%
metadata-eval7.7%
metadata-eval7.7%
associate-/r*7.7%
metadata-eval7.7%
neg-mul-17.7%
+-commutative7.7%
associate-+l+7.5%
+-commutative7.5%
neg-mul-17.5%
metadata-eval7.5%
associate-/r*7.5%
metadata-eval7.5%
metadata-eval7.5%
+-commutative7.5%
+-commutative7.5%
Simplified7.5%
Taylor expanded in x around inf 98.1%
expm1-log1p-u99.6%
expm1-udef8.1%
div-inv8.1%
pow-flip8.1%
metadata-eval8.1%
Applied egg-rr5.8%
expm1-def99.9%
expm1-log1p99.9%
Simplified98.5%
Final simplification98.5%
(FPCore (x) :precision binary64 (let* ((t_0 (* (+ x 1.0) (- 1.0 x)))) (/ (+ (* x (+ (- 1.0 x) (- -1.0 x))) (* t_0 -2.0)) (* x t_0))))
double code(double x) {
double t_0 = (x + 1.0) * (1.0 - x);
return ((x * ((1.0 - x) + (-1.0 - x))) + (t_0 * -2.0)) / (x * t_0);
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = (x + 1.0d0) * (1.0d0 - x)
code = ((x * ((1.0d0 - x) + ((-1.0d0) - x))) + (t_0 * (-2.0d0))) / (x * t_0)
end function
public static double code(double x) {
double t_0 = (x + 1.0) * (1.0 - x);
return ((x * ((1.0 - x) + (-1.0 - x))) + (t_0 * -2.0)) / (x * t_0);
}
def code(x): t_0 = (x + 1.0) * (1.0 - x) return ((x * ((1.0 - x) + (-1.0 - x))) + (t_0 * -2.0)) / (x * t_0)
function code(x) t_0 = Float64(Float64(x + 1.0) * Float64(1.0 - x)) return Float64(Float64(Float64(x * Float64(Float64(1.0 - x) + Float64(-1.0 - x))) + Float64(t_0 * -2.0)) / Float64(x * t_0)) end
function tmp = code(x) t_0 = (x + 1.0) * (1.0 - x); tmp = ((x * ((1.0 - x) + (-1.0 - x))) + (t_0 * -2.0)) / (x * t_0); end
code[x_] := Block[{t$95$0 = N[(N[(x + 1.0), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(x * N[(N[(1.0 - x), $MachinePrecision] + N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * -2.0), $MachinePrecision]), $MachinePrecision] / N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + 1\right) \cdot \left(1 - x\right)\\
\frac{x \cdot \left(\left(1 - x\right) + \left(-1 - x\right)\right) + t_0 \cdot -2}{x \cdot t_0}
\end{array}
\end{array}
Initial program 7.7%
sub-neg7.7%
distribute-neg-frac7.7%
metadata-eval7.7%
metadata-eval7.7%
metadata-eval7.7%
associate-/r*7.7%
metadata-eval7.7%
neg-mul-17.7%
+-commutative7.7%
associate-+l+7.5%
+-commutative7.5%
neg-mul-17.5%
metadata-eval7.5%
associate-/r*7.5%
metadata-eval7.5%
metadata-eval7.5%
+-commutative7.5%
+-commutative7.5%
Simplified7.5%
+-commutative7.5%
frac-add7.2%
frac-add10.0%
*-un-lft-identity10.0%
*-commutative10.0%
neg-mul-110.0%
distribute-neg-in10.0%
metadata-eval10.0%
+-commutative10.0%
+-commutative10.0%
Applied egg-rr10.0%
Final simplification10.0%
(FPCore (x) :precision binary64 (let* ((t_0 (* (- 1.0 x) (* x -0.5)))) (/ (+ (* (- 1.0 (* x 0.5)) (+ x 1.0)) t_0) (* (+ x 1.0) t_0))))
double code(double x) {
double t_0 = (1.0 - x) * (x * -0.5);
return (((1.0 - (x * 0.5)) * (x + 1.0)) + t_0) / ((x + 1.0) * t_0);
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = (1.0d0 - x) * (x * (-0.5d0))
code = (((1.0d0 - (x * 0.5d0)) * (x + 1.0d0)) + t_0) / ((x + 1.0d0) * t_0)
end function
public static double code(double x) {
double t_0 = (1.0 - x) * (x * -0.5);
return (((1.0 - (x * 0.5)) * (x + 1.0)) + t_0) / ((x + 1.0) * t_0);
}
def code(x): t_0 = (1.0 - x) * (x * -0.5) return (((1.0 - (x * 0.5)) * (x + 1.0)) + t_0) / ((x + 1.0) * t_0)
function code(x) t_0 = Float64(Float64(1.0 - x) * Float64(x * -0.5)) return Float64(Float64(Float64(Float64(1.0 - Float64(x * 0.5)) * Float64(x + 1.0)) + t_0) / Float64(Float64(x + 1.0) * t_0)) end
function tmp = code(x) t_0 = (1.0 - x) * (x * -0.5); tmp = (((1.0 - (x * 0.5)) * (x + 1.0)) + t_0) / ((x + 1.0) * t_0); end
code[x_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] * N[(x * -0.5), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(1.0 - N[(x * 0.5), $MachinePrecision]), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - x\right) \cdot \left(x \cdot -0.5\right)\\
\frac{\left(1 - x \cdot 0.5\right) \cdot \left(x + 1\right) + t_0}{\left(x + 1\right) \cdot t_0}
\end{array}
\end{array}
Initial program 7.7%
associate-+l-7.7%
sub-neg7.7%
+-commutative7.7%
sub-neg7.7%
distribute-neg-in7.7%
distribute-neg-frac7.7%
metadata-eval7.7%
remove-double-neg7.7%
sub-neg7.7%
metadata-eval7.7%
Simplified7.7%
clear-num7.7%
frac-2neg7.7%
metadata-eval7.7%
frac-add7.5%
*-un-lft-identity7.5%
+-commutative7.5%
distribute-neg-in7.5%
metadata-eval7.5%
sub-neg7.5%
div-inv7.5%
metadata-eval7.5%
div-inv7.5%
metadata-eval7.5%
+-commutative7.5%
distribute-neg-in7.5%
metadata-eval7.5%
sub-neg7.5%
Applied egg-rr7.5%
+-commutative7.5%
*-commutative7.5%
associate-/l/7.5%
*-commutative7.5%
+-commutative7.5%
associate-+l-7.5%
*-commutative7.5%
associate-*r*7.5%
neg-mul-17.5%
cancel-sign-sub7.5%
+-commutative7.5%
*-commutative7.5%
distribute-lft1-in7.5%
metadata-eval7.5%
metadata-eval7.5%
*-commutative7.5%
metadata-eval7.5%
Simplified7.5%
expm1-log1p-u7.5%
expm1-udef6.9%
associate-/l/6.9%
Applied egg-rr6.9%
expm1-def7.6%
expm1-log1p7.6%
*-commutative7.6%
Simplified7.6%
+-commutative7.6%
frac-add10.7%
+-commutative10.7%
+-commutative10.7%
Applied egg-rr10.7%
Final simplification10.7%
(FPCore (x) :precision binary64 (/ (+ (* x -0.5) (* (+ x 1.0) (/ (- 1.0 (* x 0.5)) (- 1.0 x)))) (* (+ x 1.0) (* x -0.5))))
double code(double x) {
return ((x * -0.5) + ((x + 1.0) * ((1.0 - (x * 0.5)) / (1.0 - x)))) / ((x + 1.0) * (x * -0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x * (-0.5d0)) + ((x + 1.0d0) * ((1.0d0 - (x * 0.5d0)) / (1.0d0 - x)))) / ((x + 1.0d0) * (x * (-0.5d0)))
end function
public static double code(double x) {
return ((x * -0.5) + ((x + 1.0) * ((1.0 - (x * 0.5)) / (1.0 - x)))) / ((x + 1.0) * (x * -0.5));
}
def code(x): return ((x * -0.5) + ((x + 1.0) * ((1.0 - (x * 0.5)) / (1.0 - x)))) / ((x + 1.0) * (x * -0.5))
function code(x) return Float64(Float64(Float64(x * -0.5) + Float64(Float64(x + 1.0) * Float64(Float64(1.0 - Float64(x * 0.5)) / Float64(1.0 - x)))) / Float64(Float64(x + 1.0) * Float64(x * -0.5))) end
function tmp = code(x) tmp = ((x * -0.5) + ((x + 1.0) * ((1.0 - (x * 0.5)) / (1.0 - x)))) / ((x + 1.0) * (x * -0.5)); end
code[x_] := N[(N[(N[(x * -0.5), $MachinePrecision] + N[(N[(x + 1.0), $MachinePrecision] * N[(N[(1.0 - N[(x * 0.5), $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] * N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot -0.5 + \left(x + 1\right) \cdot \frac{1 - x \cdot 0.5}{1 - x}}{\left(x + 1\right) \cdot \left(x \cdot -0.5\right)}
\end{array}
Initial program 7.7%
associate-+l-7.7%
sub-neg7.7%
+-commutative7.7%
sub-neg7.7%
distribute-neg-in7.7%
distribute-neg-frac7.7%
metadata-eval7.7%
remove-double-neg7.7%
sub-neg7.7%
metadata-eval7.7%
Simplified7.7%
clear-num7.7%
frac-2neg7.7%
metadata-eval7.7%
frac-add7.5%
*-un-lft-identity7.5%
+-commutative7.5%
distribute-neg-in7.5%
metadata-eval7.5%
sub-neg7.5%
div-inv7.5%
metadata-eval7.5%
div-inv7.5%
metadata-eval7.5%
+-commutative7.5%
distribute-neg-in7.5%
metadata-eval7.5%
sub-neg7.5%
Applied egg-rr7.5%
+-commutative7.5%
*-commutative7.5%
associate-/l/7.5%
*-commutative7.5%
+-commutative7.5%
associate-+l-7.5%
*-commutative7.5%
associate-*r*7.5%
neg-mul-17.5%
cancel-sign-sub7.5%
+-commutative7.5%
*-commutative7.5%
distribute-lft1-in7.5%
metadata-eval7.5%
metadata-eval7.5%
*-commutative7.5%
metadata-eval7.5%
Simplified7.5%
expm1-log1p-u7.5%
expm1-udef6.9%
associate-/l/6.9%
Applied egg-rr6.9%
expm1-def7.6%
expm1-log1p7.6%
*-commutative7.6%
Simplified7.6%
associate-/r*7.5%
frac-add7.8%
*-un-lft-identity7.8%
+-commutative7.8%
+-commutative7.8%
Applied egg-rr7.8%
Final simplification7.8%
(FPCore (x) :precision binary64 (+ (/ 1.0 (+ x 1.0)) (/ (* (- 1.0 (* x 0.5)) (/ 1.0 (- 1.0 x))) (* x -0.5))))
double code(double x) {
return (1.0 / (x + 1.0)) + (((1.0 - (x * 0.5)) * (1.0 / (1.0 - x))) / (x * -0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x + 1.0d0)) + (((1.0d0 - (x * 0.5d0)) * (1.0d0 / (1.0d0 - x))) / (x * (-0.5d0)))
end function
public static double code(double x) {
return (1.0 / (x + 1.0)) + (((1.0 - (x * 0.5)) * (1.0 / (1.0 - x))) / (x * -0.5));
}
def code(x): return (1.0 / (x + 1.0)) + (((1.0 - (x * 0.5)) * (1.0 / (1.0 - x))) / (x * -0.5))
function code(x) return Float64(Float64(1.0 / Float64(x + 1.0)) + Float64(Float64(Float64(1.0 - Float64(x * 0.5)) * Float64(1.0 / Float64(1.0 - x))) / Float64(x * -0.5))) end
function tmp = code(x) tmp = (1.0 / (x + 1.0)) + (((1.0 - (x * 0.5)) * (1.0 / (1.0 - x))) / (x * -0.5)); end
code[x_] := N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(1.0 - N[(x * 0.5), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + 1} + \frac{\left(1 - x \cdot 0.5\right) \cdot \frac{1}{1 - x}}{x \cdot -0.5}
\end{array}
Initial program 7.7%
associate-+l-7.7%
sub-neg7.7%
+-commutative7.7%
sub-neg7.7%
distribute-neg-in7.7%
distribute-neg-frac7.7%
metadata-eval7.7%
remove-double-neg7.7%
sub-neg7.7%
metadata-eval7.7%
Simplified7.7%
clear-num7.7%
frac-2neg7.7%
metadata-eval7.7%
frac-add7.5%
*-un-lft-identity7.5%
+-commutative7.5%
distribute-neg-in7.5%
metadata-eval7.5%
sub-neg7.5%
div-inv7.5%
metadata-eval7.5%
div-inv7.5%
metadata-eval7.5%
+-commutative7.5%
distribute-neg-in7.5%
metadata-eval7.5%
sub-neg7.5%
Applied egg-rr7.5%
+-commutative7.5%
*-commutative7.5%
associate-/l/7.5%
*-commutative7.5%
+-commutative7.5%
associate-+l-7.5%
*-commutative7.5%
associate-*r*7.5%
neg-mul-17.5%
cancel-sign-sub7.5%
+-commutative7.5%
*-commutative7.5%
distribute-lft1-in7.5%
metadata-eval7.5%
metadata-eval7.5%
*-commutative7.5%
metadata-eval7.5%
Simplified7.5%
div-inv7.6%
Applied egg-rr7.6%
Final simplification7.6%
(FPCore (x) :precision binary64 (+ (/ 1.0 (+ x 1.0)) (* (/ -2.0 x) (/ (+ 1.0 (* x -0.5)) (- 1.0 x)))))
double code(double x) {
return (1.0 / (x + 1.0)) + ((-2.0 / x) * ((1.0 + (x * -0.5)) / (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 * (-0.5d0))) / (1.0d0 - x)))
end function
public static double code(double x) {
return (1.0 / (x + 1.0)) + ((-2.0 / x) * ((1.0 + (x * -0.5)) / (1.0 - x)));
}
def code(x): return (1.0 / (x + 1.0)) + ((-2.0 / x) * ((1.0 + (x * -0.5)) / (1.0 - x)))
function code(x) return Float64(Float64(1.0 / Float64(x + 1.0)) + Float64(Float64(-2.0 / x) * Float64(Float64(1.0 + Float64(x * -0.5)) / Float64(1.0 - x)))) end
function tmp = code(x) tmp = (1.0 / (x + 1.0)) + ((-2.0 / x) * ((1.0 + (x * -0.5)) / (1.0 - x))); end
code[x_] := N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-2.0 / x), $MachinePrecision] * N[(N[(1.0 + N[(x * -0.5), $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + 1} + \frac{-2}{x} \cdot \frac{1 + x \cdot -0.5}{1 - x}
\end{array}
Initial program 7.7%
associate-+l-7.7%
sub-neg7.7%
+-commutative7.7%
sub-neg7.7%
distribute-neg-in7.7%
distribute-neg-frac7.7%
metadata-eval7.7%
remove-double-neg7.7%
sub-neg7.7%
metadata-eval7.7%
Simplified7.7%
clear-num7.7%
frac-2neg7.7%
metadata-eval7.7%
frac-add7.5%
*-un-lft-identity7.5%
+-commutative7.5%
distribute-neg-in7.5%
metadata-eval7.5%
sub-neg7.5%
div-inv7.5%
metadata-eval7.5%
div-inv7.5%
metadata-eval7.5%
+-commutative7.5%
distribute-neg-in7.5%
metadata-eval7.5%
sub-neg7.5%
Applied egg-rr7.5%
+-commutative7.5%
*-commutative7.5%
associate-/l/7.5%
*-commutative7.5%
+-commutative7.5%
associate-+l-7.5%
*-commutative7.5%
associate-*r*7.5%
neg-mul-17.5%
cancel-sign-sub7.5%
+-commutative7.5%
*-commutative7.5%
distribute-lft1-in7.5%
metadata-eval7.5%
metadata-eval7.5%
*-commutative7.5%
metadata-eval7.5%
Simplified7.5%
expm1-log1p-u7.5%
expm1-udef6.9%
associate-/l/6.9%
Applied egg-rr6.9%
expm1-def7.6%
expm1-log1p7.6%
*-lft-identity7.6%
times-frac7.7%
*-commutative7.7%
associate-/r*7.7%
metadata-eval7.7%
*-commutative7.7%
cancel-sign-sub-inv7.7%
metadata-eval7.7%
*-commutative7.7%
Simplified7.7%
Final simplification7.7%
(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 7.7%
Final simplification7.7%
(FPCore (x) :precision binary64 (+ (/ -2.0 x) (/ 1.0 (- (* x 0.5) (/ 0.5 x)))))
double code(double x) {
return (-2.0 / x) + (1.0 / ((x * 0.5) - (0.5 / x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-2.0d0) / x) + (1.0d0 / ((x * 0.5d0) - (0.5d0 / x)))
end function
public static double code(double x) {
return (-2.0 / x) + (1.0 / ((x * 0.5) - (0.5 / x)));
}
def code(x): return (-2.0 / x) + (1.0 / ((x * 0.5) - (0.5 / x)))
function code(x) return Float64(Float64(-2.0 / x) + Float64(1.0 / Float64(Float64(x * 0.5) - Float64(0.5 / x)))) end
function tmp = code(x) tmp = (-2.0 / x) + (1.0 / ((x * 0.5) - (0.5 / x))); end
code[x_] := N[(N[(-2.0 / x), $MachinePrecision] + N[(1.0 / N[(N[(x * 0.5), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-2}{x} + \frac{1}{x \cdot 0.5 - \frac{0.5}{x}}
\end{array}
Initial program 7.7%
sub-neg7.7%
distribute-neg-frac7.7%
metadata-eval7.7%
metadata-eval7.7%
metadata-eval7.7%
associate-/r*7.7%
metadata-eval7.7%
neg-mul-17.7%
+-commutative7.7%
associate-+l+7.5%
+-commutative7.5%
neg-mul-17.5%
metadata-eval7.5%
associate-/r*7.5%
metadata-eval7.5%
metadata-eval7.5%
+-commutative7.5%
+-commutative7.5%
Simplified7.5%
frac-add7.2%
clear-num7.4%
+-commutative7.4%
*-un-lft-identity7.4%
*-commutative7.4%
neg-mul-17.4%
distribute-neg-in7.4%
metadata-eval7.4%
Applied egg-rr7.4%
Taylor expanded in x around 0 7.4%
*-commutative7.4%
associate-*r/7.4%
metadata-eval7.4%
Simplified7.4%
Final simplification7.4%
(FPCore (x) :precision binary64 (+ (/ -2.0 x) (/ -2.0 (- 1.0 x))))
double code(double x) {
return (-2.0 / x) + (-2.0 / (1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-2.0d0) / x) + ((-2.0d0) / (1.0d0 - x))
end function
public static double code(double x) {
return (-2.0 / x) + (-2.0 / (1.0 - x));
}
def code(x): return (-2.0 / x) + (-2.0 / (1.0 - x))
function code(x) return Float64(Float64(-2.0 / x) + Float64(-2.0 / Float64(1.0 - x))) end
function tmp = code(x) tmp = (-2.0 / x) + (-2.0 / (1.0 - x)); end
code[x_] := N[(N[(-2.0 / x), $MachinePrecision] + N[(-2.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-2}{x} + \frac{-2}{1 - x}
\end{array}
Initial program 7.7%
sub-neg7.7%
distribute-neg-frac7.7%
metadata-eval7.7%
metadata-eval7.7%
metadata-eval7.7%
associate-/r*7.7%
metadata-eval7.7%
neg-mul-17.7%
+-commutative7.7%
associate-+l+7.5%
+-commutative7.5%
neg-mul-17.5%
metadata-eval7.5%
associate-/r*7.5%
metadata-eval7.5%
metadata-eval7.5%
+-commutative7.5%
+-commutative7.5%
Simplified7.5%
frac-add7.2%
associate-/r*7.5%
*-un-lft-identity7.5%
*-commutative7.5%
neg-mul-17.5%
distribute-neg-in7.5%
metadata-eval7.5%
+-commutative7.5%
Applied egg-rr7.5%
Taylor expanded in x around inf 5.3%
Final simplification5.3%
(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 7.7%
sub-neg7.7%
distribute-neg-frac7.7%
metadata-eval7.7%
metadata-eval7.7%
metadata-eval7.7%
associate-/r*7.7%
metadata-eval7.7%
neg-mul-17.7%
+-commutative7.7%
associate-+l+7.5%
+-commutative7.5%
neg-mul-17.5%
metadata-eval7.5%
associate-/r*7.5%
metadata-eval7.5%
metadata-eval7.5%
+-commutative7.5%
+-commutative7.5%
Simplified7.5%
Taylor expanded in x around 0 3.7%
Taylor expanded in x around inf 3.7%
Final simplification3.7%
(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 7.7%
sub-neg7.7%
distribute-neg-frac7.7%
metadata-eval7.7%
metadata-eval7.7%
metadata-eval7.7%
associate-/r*7.7%
metadata-eval7.7%
neg-mul-17.7%
+-commutative7.7%
associate-+l+7.5%
+-commutative7.5%
neg-mul-17.5%
metadata-eval7.5%
associate-/r*7.5%
metadata-eval7.5%
metadata-eval7.5%
+-commutative7.5%
+-commutative7.5%
Simplified7.5%
Taylor expanded in x around 0 3.7%
Taylor expanded in x around inf 3.7%
Final simplification3.7%
(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 2023339
(FPCore (x)
:name "3frac (problem 3.3.3)"
:precision binary64
:pre (and (> (fabs x) 1.0) (< (fabs x) 1e+100))
:herbie-target
(/ 2.0 (* x (- (* x x) 1.0)))
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))