
(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 10 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 -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 68.4%
sub-neg68.4%
distribute-neg-frac68.4%
metadata-eval68.4%
metadata-eval68.4%
metadata-eval68.4%
associate-/r*68.4%
metadata-eval68.4%
neg-mul-168.4%
+-commutative68.4%
associate-+l+68.4%
+-commutative68.4%
neg-mul-168.4%
metadata-eval68.4%
associate-/r*68.4%
metadata-eval68.4%
metadata-eval68.4%
+-commutative68.4%
+-commutative68.4%
Simplified68.4%
Taylor expanded in x around inf 98.4%
expm1-log1p-u98.4%
expm1-udef67.2%
div-inv67.2%
pow-flip67.2%
metadata-eval67.2%
Applied egg-rr67.2%
expm1-def98.8%
expm1-log1p98.8%
Simplified98.8%
Final simplification98.8%
(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))) 4e-28)
(+ (/ -2.0 x) (+ (/ 1.0 x) (/ -1.0 (- 1.0 x))))
(/ (+ (* x (+ x x)) (* t_0 -2.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))) <= 4e-28) {
tmp = (-2.0 / x) + ((1.0 / x) + (-1.0 / (1.0 - x)));
} else {
tmp = ((x * (x + x)) + (t_0 * -2.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)))) <= 4d-28) then
tmp = ((-2.0d0) / x) + ((1.0d0 / x) + ((-1.0d0) / (1.0d0 - x)))
else
tmp = ((x * (x + x)) + (t_0 * (-2.0d0))) / (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))) <= 4e-28) {
tmp = (-2.0 / x) + ((1.0 / x) + (-1.0 / (1.0 - x)));
} else {
tmp = ((x * (x + x)) + (t_0 * -2.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))) <= 4e-28: tmp = (-2.0 / x) + ((1.0 / x) + (-1.0 / (1.0 - x))) else: tmp = ((x * (x + x)) + (t_0 * -2.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))) <= 4e-28) tmp = Float64(Float64(-2.0 / x) + Float64(Float64(1.0 / x) + Float64(-1.0 / Float64(1.0 - x)))); else tmp = Float64(Float64(Float64(x * Float64(x + x)) + Float64(t_0 * -2.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))) <= 4e-28) tmp = (-2.0 / x) + ((1.0 / x) + (-1.0 / (1.0 - x))); else tmp = ((x * (x + x)) + (t_0 * -2.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], 4e-28], N[(N[(-2.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] + N[(-1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * N[(x + x), $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(x + 1\right)\\
\mathbf{if}\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x + -1} \leq 4 \cdot 10^{-28}:\\
\;\;\;\;\frac{-2}{x} + \left(\frac{1}{x} + \frac{-1}{1 - x}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(x + x\right) + t_0 \cdot -2}{x \cdot t_0}\\
\end{array}
\end{array}
if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 3.99999999999999988e-28Initial program 68.9%
sub-neg68.9%
distribute-neg-frac68.9%
metadata-eval68.9%
metadata-eval68.9%
metadata-eval68.9%
associate-/r*68.9%
metadata-eval68.9%
neg-mul-168.9%
+-commutative68.9%
associate-+l+68.8%
+-commutative68.8%
neg-mul-168.8%
metadata-eval68.8%
associate-/r*68.8%
metadata-eval68.8%
metadata-eval68.8%
+-commutative68.8%
+-commutative68.8%
Simplified68.8%
Taylor expanded in x around inf 67.8%
if 3.99999999999999988e-28 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 45.4%
sub-neg45.4%
distribute-neg-frac45.4%
metadata-eval45.4%
metadata-eval45.4%
metadata-eval45.4%
associate-/r*45.4%
metadata-eval45.4%
neg-mul-145.4%
+-commutative45.4%
associate-+l+45.2%
+-commutative45.2%
neg-mul-145.2%
metadata-eval45.2%
associate-/r*45.2%
metadata-eval45.2%
metadata-eval45.2%
+-commutative45.2%
+-commutative45.2%
Simplified45.2%
frac-2neg45.2%
metadata-eval45.2%
frac-add41.2%
*-un-lft-identity41.2%
*-commutative41.2%
+-commutative41.2%
*-un-lft-identity41.2%
+-commutative41.2%
Applied egg-rr41.2%
associate-/r*41.7%
neg-sub041.7%
associate--r-41.7%
metadata-eval41.7%
+-commutative41.7%
neg-sub041.7%
associate--r-41.7%
metadata-eval41.7%
+-commutative41.7%
associate-/r*41.2%
+-commutative41.2%
associate-+l+41.2%
+-commutative41.2%
associate-+r+41.2%
metadata-eval41.2%
Simplified41.2%
+-commutative41.2%
frac-add80.0%
+-lft-identity80.0%
+-commutative80.0%
*-commutative80.0%
+-commutative80.0%
+-commutative80.0%
*-commutative80.0%
+-commutative80.0%
Applied egg-rr80.0%
Final simplification68.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (* x (+ x -1.0))))
(if (<= x 140000000.0)
(/ (+ (* x (+ x x)) (* (* (+ x -1.0) (+ x 1.0)) -2.0)) (+ t_0 (* x t_0)))
(+ (/ -2.0 x) (+ (/ 1.0 x) (/ -1.0 (- 1.0 x)))))))
double code(double x) {
double t_0 = x * (x + -1.0);
double tmp;
if (x <= 140000000.0) {
tmp = ((x * (x + x)) + (((x + -1.0) * (x + 1.0)) * -2.0)) / (t_0 + (x * t_0));
} else {
tmp = (-2.0 / x) + ((1.0 / x) + (-1.0 / (1.0 - x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = x * (x + (-1.0d0))
if (x <= 140000000.0d0) then
tmp = ((x * (x + x)) + (((x + (-1.0d0)) * (x + 1.0d0)) * (-2.0d0))) / (t_0 + (x * t_0))
else
tmp = ((-2.0d0) / x) + ((1.0d0 / x) + ((-1.0d0) / (1.0d0 - x)))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = x * (x + -1.0);
double tmp;
if (x <= 140000000.0) {
tmp = ((x * (x + x)) + (((x + -1.0) * (x + 1.0)) * -2.0)) / (t_0 + (x * t_0));
} else {
tmp = (-2.0 / x) + ((1.0 / x) + (-1.0 / (1.0 - x)));
}
return tmp;
}
def code(x): t_0 = x * (x + -1.0) tmp = 0 if x <= 140000000.0: tmp = ((x * (x + x)) + (((x + -1.0) * (x + 1.0)) * -2.0)) / (t_0 + (x * t_0)) else: tmp = (-2.0 / x) + ((1.0 / x) + (-1.0 / (1.0 - x))) return tmp
function code(x) t_0 = Float64(x * Float64(x + -1.0)) tmp = 0.0 if (x <= 140000000.0) tmp = Float64(Float64(Float64(x * Float64(x + x)) + Float64(Float64(Float64(x + -1.0) * Float64(x + 1.0)) * -2.0)) / Float64(t_0 + Float64(x * t_0))); else tmp = Float64(Float64(-2.0 / x) + Float64(Float64(1.0 / x) + Float64(-1.0 / Float64(1.0 - x)))); end return tmp end
function tmp_2 = code(x) t_0 = x * (x + -1.0); tmp = 0.0; if (x <= 140000000.0) tmp = ((x * (x + x)) + (((x + -1.0) * (x + 1.0)) * -2.0)) / (t_0 + (x * t_0)); else tmp = (-2.0 / x) + ((1.0 / x) + (-1.0 / (1.0 - x))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 140000000.0], N[(N[(N[(x * N[(x + x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(x + -1.0), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] + N[(-1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x + -1\right)\\
\mathbf{if}\;x \leq 140000000:\\
\;\;\;\;\frac{x \cdot \left(x + x\right) + \left(\left(x + -1\right) \cdot \left(x + 1\right)\right) \cdot -2}{t_0 + x \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{x} + \left(\frac{1}{x} + \frac{-1}{1 - x}\right)\\
\end{array}
\end{array}
if x < 1.4e8Initial program 69.8%
sub-neg69.8%
distribute-neg-frac69.8%
metadata-eval69.8%
metadata-eval69.8%
metadata-eval69.8%
associate-/r*69.8%
metadata-eval69.8%
neg-mul-169.8%
+-commutative69.8%
associate-+l+69.7%
+-commutative69.7%
neg-mul-169.7%
metadata-eval69.7%
associate-/r*69.7%
metadata-eval69.7%
metadata-eval69.7%
+-commutative69.7%
+-commutative69.7%
Simplified69.7%
frac-2neg69.7%
metadata-eval69.7%
frac-add16.9%
*-un-lft-identity16.9%
*-commutative16.9%
+-commutative16.9%
*-un-lft-identity16.9%
+-commutative16.9%
Applied egg-rr16.9%
associate-/r*68.8%
neg-sub068.8%
associate--r-68.8%
metadata-eval68.8%
+-commutative68.8%
neg-sub068.8%
associate--r-68.8%
metadata-eval68.8%
+-commutative68.8%
associate-/r*16.9%
+-commutative16.9%
associate-+l+16.9%
+-commutative16.9%
associate-+r+16.9%
metadata-eval16.9%
Simplified16.9%
+-commutative16.9%
frac-add17.1%
+-lft-identity17.1%
+-commutative17.1%
*-commutative17.1%
+-commutative17.1%
+-commutative17.1%
*-commutative17.1%
+-commutative17.1%
Applied egg-rr17.1%
*-commutative17.1%
distribute-lft-in17.1%
*-rgt-identity17.1%
distribute-rgt-in17.1%
Applied egg-rr17.1%
if 1.4e8 < x Initial program 66.9%
sub-neg66.9%
distribute-neg-frac66.9%
metadata-eval66.9%
metadata-eval66.9%
metadata-eval66.9%
associate-/r*66.9%
metadata-eval66.9%
neg-mul-166.9%
+-commutative66.9%
associate-+l+66.8%
+-commutative66.8%
neg-mul-166.8%
metadata-eval66.8%
associate-/r*66.8%
metadata-eval66.8%
metadata-eval66.8%
+-commutative66.8%
+-commutative66.8%
Simplified66.8%
Taylor expanded in x around inf 67.0%
Final simplification39.9%
(FPCore (x) :precision binary64 (+ (/ 1.0 (+ x 1.0)) (/ (/ (+ -1.0 (* x 0.5)) (+ x -1.0)) (* x -0.5))))
double code(double x) {
return (1.0 / (x + 1.0)) + (((-1.0 + (x * 0.5)) / (x + -1.0)) / (x * -0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x + 1.0d0)) + ((((-1.0d0) + (x * 0.5d0)) / (x + (-1.0d0))) / (x * (-0.5d0)))
end function
public static double code(double x) {
return (1.0 / (x + 1.0)) + (((-1.0 + (x * 0.5)) / (x + -1.0)) / (x * -0.5));
}
def code(x): return (1.0 / (x + 1.0)) + (((-1.0 + (x * 0.5)) / (x + -1.0)) / (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(x + -1.0)) / Float64(x * -0.5))) end
function tmp = code(x) tmp = (1.0 / (x + 1.0)) + (((-1.0 + (x * 0.5)) / (x + -1.0)) / (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[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + 1} + \frac{\frac{-1 + x \cdot 0.5}{x + -1}}{x \cdot -0.5}
\end{array}
Initial program 68.4%
associate-+l-68.4%
sub-neg68.4%
+-commutative68.4%
sub-neg68.4%
distribute-neg-in68.4%
distribute-neg-frac68.4%
metadata-eval68.4%
remove-double-neg68.4%
sub-neg68.4%
metadata-eval68.4%
Simplified68.4%
clear-num68.4%
frac-add18.4%
*-un-lft-identity18.4%
div-inv18.4%
metadata-eval18.4%
div-inv18.4%
metadata-eval18.4%
Applied egg-rr18.4%
*-rgt-identity18.4%
+-commutative18.4%
associate-/l/68.4%
associate-+r+68.4%
*-commutative68.4%
distribute-lft1-in68.4%
metadata-eval68.4%
metadata-eval68.4%
associate-*r*68.4%
*-commutative68.4%
+-commutative68.4%
*-commutative68.4%
associate-*l*68.4%
metadata-eval68.4%
Simplified68.4%
Final simplification68.4%
(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 68.4%
Final simplification68.4%
(FPCore (x) :precision binary64 (+ (/ -2.0 x) (+ (/ 1.0 x) (/ -1.0 (- 1.0 x)))))
double code(double x) {
return (-2.0 / x) + ((1.0 / x) + (-1.0 / (1.0 - x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-2.0d0) / x) + ((1.0d0 / x) + ((-1.0d0) / (1.0d0 - x)))
end function
public static double code(double x) {
return (-2.0 / x) + ((1.0 / x) + (-1.0 / (1.0 - x)));
}
def code(x): return (-2.0 / x) + ((1.0 / x) + (-1.0 / (1.0 - x)))
function code(x) return Float64(Float64(-2.0 / x) + Float64(Float64(1.0 / x) + Float64(-1.0 / Float64(1.0 - x)))) end
function tmp = code(x) tmp = (-2.0 / x) + ((1.0 / x) + (-1.0 / (1.0 - x))); end
code[x_] := N[(N[(-2.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] + N[(-1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-2}{x} + \left(\frac{1}{x} + \frac{-1}{1 - x}\right)
\end{array}
Initial program 68.4%
sub-neg68.4%
distribute-neg-frac68.4%
metadata-eval68.4%
metadata-eval68.4%
metadata-eval68.4%
associate-/r*68.4%
metadata-eval68.4%
neg-mul-168.4%
+-commutative68.4%
associate-+l+68.4%
+-commutative68.4%
neg-mul-168.4%
metadata-eval68.4%
associate-/r*68.4%
metadata-eval68.4%
metadata-eval68.4%
+-commutative68.4%
+-commutative68.4%
Simplified68.4%
Taylor expanded in x around inf 66.7%
Final simplification66.7%
(FPCore (x) :precision binary64 (+ (/ -2.0 x) (/ 2.0 x)))
double code(double x) {
return (-2.0 / x) + (2.0 / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-2.0d0) / x) + (2.0d0 / x)
end function
public static double code(double x) {
return (-2.0 / x) + (2.0 / x);
}
def code(x): return (-2.0 / x) + (2.0 / x)
function code(x) return Float64(Float64(-2.0 / x) + Float64(2.0 / x)) end
function tmp = code(x) tmp = (-2.0 / x) + (2.0 / x); end
code[x_] := N[(N[(-2.0 / x), $MachinePrecision] + N[(2.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-2}{x} + \frac{2}{x}
\end{array}
Initial program 68.4%
sub-neg68.4%
distribute-neg-frac68.4%
metadata-eval68.4%
metadata-eval68.4%
metadata-eval68.4%
associate-/r*68.4%
metadata-eval68.4%
neg-mul-168.4%
+-commutative68.4%
associate-+l+68.4%
+-commutative68.4%
neg-mul-168.4%
metadata-eval68.4%
associate-/r*68.4%
metadata-eval68.4%
metadata-eval68.4%
+-commutative68.4%
+-commutative68.4%
Simplified68.4%
Taylor expanded in x around inf 66.5%
Final simplification66.5%
(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 68.4%
sub-neg68.4%
distribute-neg-frac68.4%
metadata-eval68.4%
metadata-eval68.4%
metadata-eval68.4%
associate-/r*68.4%
metadata-eval68.4%
neg-mul-168.4%
+-commutative68.4%
associate-+l+68.4%
+-commutative68.4%
neg-mul-168.4%
metadata-eval68.4%
associate-/r*68.4%
metadata-eval68.4%
metadata-eval68.4%
+-commutative68.4%
+-commutative68.4%
Simplified68.4%
Taylor expanded in x around 0 4.9%
Final simplification4.9%
(FPCore (x) :precision binary64 (/ -1.0 x))
double code(double x) {
return -1.0 / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-1.0d0) / x
end function
public static double code(double x) {
return -1.0 / x;
}
def code(x): return -1.0 / x
function code(x) return Float64(-1.0 / x) end
function tmp = code(x) tmp = -1.0 / x; end
code[x_] := N[(-1.0 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1}{x}
\end{array}
Initial program 68.4%
associate-+l-68.4%
sub-neg68.4%
+-commutative68.4%
sub-neg68.4%
distribute-neg-in68.4%
distribute-neg-frac68.4%
metadata-eval68.4%
remove-double-neg68.4%
sub-neg68.4%
metadata-eval68.4%
Simplified68.4%
Taylor expanded in x around inf 66.7%
Taylor expanded in x around 0 4.9%
Final simplification4.9%
(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 68.4%
sub-neg68.4%
distribute-neg-frac68.4%
metadata-eval68.4%
metadata-eval68.4%
metadata-eval68.4%
associate-/r*68.4%
metadata-eval68.4%
neg-mul-168.4%
+-commutative68.4%
associate-+l+68.4%
+-commutative68.4%
neg-mul-168.4%
metadata-eval68.4%
associate-/r*68.4%
metadata-eval68.4%
metadata-eval68.4%
+-commutative68.4%
+-commutative68.4%
Simplified68.4%
Taylor expanded in x around 0 3.4%
Taylor expanded in x around inf 3.4%
Final simplification3.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 2024010
(FPCore (x)
:name "3frac (problem 3.3.3)"
:precision binary64
:pre (> (fabs x) 1.0)
:herbie-target
(/ 2.0 (* x (- (* x x) 1.0)))
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))