
(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 7 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 (+ x 1.0)) (+ x -1.0)) x))
double code(double x) {
return ((2.0 / (x + 1.0)) / (x + -1.0)) / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((2.0d0 / (x + 1.0d0)) / (x + (-1.0d0))) / x
end function
public static double code(double x) {
return ((2.0 / (x + 1.0)) / (x + -1.0)) / x;
}
def code(x): return ((2.0 / (x + 1.0)) / (x + -1.0)) / x
function code(x) return Float64(Float64(Float64(2.0 / Float64(x + 1.0)) / Float64(x + -1.0)) / x) end
function tmp = code(x) tmp = ((2.0 / (x + 1.0)) / (x + -1.0)) / x; end
code[x_] := N[(N[(N[(2.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{2}{x + 1}}{x + -1}}{x}
\end{array}
Initial program 83.3%
associate-+l-83.3%
sub-neg83.3%
neg-mul-183.3%
metadata-eval83.3%
cancel-sign-sub-inv83.3%
+-commutative83.3%
*-lft-identity83.3%
sub-neg83.3%
metadata-eval83.3%
Simplified83.3%
frac-sub60.5%
frac-sub61.2%
*-un-lft-identity61.2%
distribute-rgt-in61.2%
neg-mul-161.2%
sub-neg61.2%
*-rgt-identity61.2%
distribute-rgt-in61.2%
metadata-eval61.2%
metadata-eval61.2%
fma-def61.2%
metadata-eval61.2%
distribute-rgt-in61.2%
neg-mul-161.2%
sub-neg61.2%
Applied egg-rr61.2%
+-commutative61.2%
remove-double-neg61.2%
metadata-eval61.2%
distribute-neg-in61.2%
neg-mul-161.2%
*-commutative61.2%
fma-udef61.2%
distribute-lft-neg-in61.2%
distribute-lft-neg-in61.2%
fma-udef61.2%
*-commutative61.2%
neg-mul-161.2%
distribute-neg-in61.2%
remove-double-neg61.2%
metadata-eval61.2%
+-commutative61.2%
Simplified61.2%
Taylor expanded in x around 0 99.6%
associate-/r*99.9%
div-inv99.8%
*-un-lft-identity99.8%
distribute-rgt-out--99.8%
sub-neg99.8%
metadata-eval99.8%
Applied egg-rr99.8%
un-div-inv99.9%
*-commutative99.9%
associate-/r*99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (if (or (<= x -0.85) (not (<= x 1.0))) (/ 2.0 (* (+ x 1.0) (* x x))) (- (* x -2.0) (/ 2.0 x))))
double code(double x) {
double tmp;
if ((x <= -0.85) || !(x <= 1.0)) {
tmp = 2.0 / ((x + 1.0) * (x * x));
} else {
tmp = (x * -2.0) - (2.0 / x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-0.85d0)) .or. (.not. (x <= 1.0d0))) then
tmp = 2.0d0 / ((x + 1.0d0) * (x * x))
else
tmp = (x * (-2.0d0)) - (2.0d0 / x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -0.85) || !(x <= 1.0)) {
tmp = 2.0 / ((x + 1.0) * (x * x));
} else {
tmp = (x * -2.0) - (2.0 / x);
}
return tmp;
}
def code(x): tmp = 0 if (x <= -0.85) or not (x <= 1.0): tmp = 2.0 / ((x + 1.0) * (x * x)) else: tmp = (x * -2.0) - (2.0 / x) return tmp
function code(x) tmp = 0.0 if ((x <= -0.85) || !(x <= 1.0)) tmp = Float64(2.0 / Float64(Float64(x + 1.0) * Float64(x * x))); else tmp = Float64(Float64(x * -2.0) - Float64(2.0 / x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -0.85) || ~((x <= 1.0))) tmp = 2.0 / ((x + 1.0) * (x * x)); else tmp = (x * -2.0) - (2.0 / x); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -0.85], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(2.0 / N[(N[(x + 1.0), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * -2.0), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.85 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{2}{\left(x + 1\right) \cdot \left(x \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;x \cdot -2 - \frac{2}{x}\\
\end{array}
\end{array}
if x < -0.849999999999999978 or 1 < x Initial program 65.9%
associate-+l-65.9%
sub-neg65.9%
neg-mul-165.9%
metadata-eval65.9%
cancel-sign-sub-inv65.9%
+-commutative65.9%
*-lft-identity65.9%
sub-neg65.9%
metadata-eval65.9%
Simplified65.9%
frac-sub19.1%
frac-sub20.5%
*-un-lft-identity20.5%
distribute-rgt-in20.6%
neg-mul-120.6%
sub-neg20.6%
*-rgt-identity20.6%
distribute-rgt-in20.6%
metadata-eval20.6%
metadata-eval20.6%
fma-def20.6%
metadata-eval20.6%
distribute-rgt-in20.6%
neg-mul-120.6%
sub-neg20.6%
Applied egg-rr20.6%
+-commutative20.6%
remove-double-neg20.6%
metadata-eval20.6%
distribute-neg-in20.6%
neg-mul-120.6%
*-commutative20.6%
fma-udef20.6%
distribute-lft-neg-in20.6%
distribute-lft-neg-in20.6%
fma-udef20.6%
*-commutative20.6%
neg-mul-120.6%
distribute-neg-in20.6%
remove-double-neg20.6%
metadata-eval20.6%
+-commutative20.6%
Simplified20.6%
Taylor expanded in x around 0 99.2%
Taylor expanded in x around inf 97.3%
unpow297.3%
Simplified97.3%
if -0.849999999999999978 < x < 1Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
neg-mul-1100.0%
metadata-eval100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 99.5%
associate-*r/99.5%
metadata-eval99.5%
Simplified99.5%
Final simplification98.4%
(FPCore (x) :precision binary64 (if (<= x -0.85) (/ (/ 2.0 (* x (+ x 1.0))) x) (if (<= x 1.0) (- (* x -2.0) (/ 2.0 x)) (/ 2.0 (* (+ x 1.0) (* x x))))))
double code(double x) {
double tmp;
if (x <= -0.85) {
tmp = (2.0 / (x * (x + 1.0))) / x;
} else if (x <= 1.0) {
tmp = (x * -2.0) - (2.0 / x);
} else {
tmp = 2.0 / ((x + 1.0) * (x * x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-0.85d0)) then
tmp = (2.0d0 / (x * (x + 1.0d0))) / x
else if (x <= 1.0d0) then
tmp = (x * (-2.0d0)) - (2.0d0 / x)
else
tmp = 2.0d0 / ((x + 1.0d0) * (x * x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -0.85) {
tmp = (2.0 / (x * (x + 1.0))) / x;
} else if (x <= 1.0) {
tmp = (x * -2.0) - (2.0 / x);
} else {
tmp = 2.0 / ((x + 1.0) * (x * x));
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.85: tmp = (2.0 / (x * (x + 1.0))) / x elif x <= 1.0: tmp = (x * -2.0) - (2.0 / x) else: tmp = 2.0 / ((x + 1.0) * (x * x)) return tmp
function code(x) tmp = 0.0 if (x <= -0.85) tmp = Float64(Float64(2.0 / Float64(x * Float64(x + 1.0))) / x); elseif (x <= 1.0) tmp = Float64(Float64(x * -2.0) - Float64(2.0 / x)); else tmp = Float64(2.0 / Float64(Float64(x + 1.0) * Float64(x * x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -0.85) tmp = (2.0 / (x * (x + 1.0))) / x; elseif (x <= 1.0) tmp = (x * -2.0) - (2.0 / x); else tmp = 2.0 / ((x + 1.0) * (x * x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -0.85], N[(N[(2.0 / N[(x * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(x * -2.0), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(x + 1.0), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.85:\\
\;\;\;\;\frac{\frac{2}{x \cdot \left(x + 1\right)}}{x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot -2 - \frac{2}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\left(x + 1\right) \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if x < -0.849999999999999978Initial program 61.3%
associate-+l-61.3%
sub-neg61.3%
neg-mul-161.3%
metadata-eval61.3%
cancel-sign-sub-inv61.3%
+-commutative61.3%
*-lft-identity61.3%
sub-neg61.3%
metadata-eval61.3%
Simplified61.3%
frac-sub21.8%
frac-sub25.9%
*-un-lft-identity25.9%
distribute-rgt-in25.9%
neg-mul-125.9%
sub-neg25.9%
*-rgt-identity25.9%
distribute-rgt-in25.9%
metadata-eval25.9%
metadata-eval25.9%
fma-def25.9%
metadata-eval25.9%
distribute-rgt-in25.9%
neg-mul-125.9%
sub-neg25.9%
Applied egg-rr25.9%
+-commutative25.9%
remove-double-neg25.9%
metadata-eval25.9%
distribute-neg-in25.9%
neg-mul-125.9%
*-commutative25.9%
fma-udef25.9%
distribute-lft-neg-in25.9%
distribute-lft-neg-in25.9%
fma-udef25.9%
*-commutative25.9%
neg-mul-125.9%
distribute-neg-in25.9%
remove-double-neg25.9%
metadata-eval25.9%
+-commutative25.9%
Simplified25.9%
Taylor expanded in x around 0 98.4%
Taylor expanded in x around inf 96.8%
unpow296.8%
Simplified96.8%
associate-/r*98.1%
div-inv98.1%
times-frac98.0%
Applied egg-rr98.0%
associate-*r/98.1%
associate-*l/98.1%
associate-*r/98.1%
metadata-eval98.1%
associate-/l/98.1%
Simplified98.1%
if -0.849999999999999978 < x < 1Initial program 100.0%
associate-+l-100.0%
sub-neg100.0%
neg-mul-1100.0%
metadata-eval100.0%
cancel-sign-sub-inv100.0%
+-commutative100.0%
*-lft-identity100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 99.5%
associate-*r/99.5%
metadata-eval99.5%
Simplified99.5%
if 1 < x Initial program 69.6%
associate-+l-69.6%
sub-neg69.6%
neg-mul-169.6%
metadata-eval69.6%
cancel-sign-sub-inv69.6%
+-commutative69.6%
*-lft-identity69.6%
sub-neg69.6%
metadata-eval69.6%
Simplified69.6%
frac-sub17.0%
frac-sub16.2%
*-un-lft-identity16.2%
distribute-rgt-in16.3%
neg-mul-116.3%
sub-neg16.3%
*-rgt-identity16.3%
distribute-rgt-in16.3%
metadata-eval16.3%
metadata-eval16.3%
fma-def16.3%
metadata-eval16.3%
distribute-rgt-in16.3%
neg-mul-116.3%
sub-neg16.3%
Applied egg-rr16.3%
+-commutative16.3%
remove-double-neg16.3%
metadata-eval16.3%
distribute-neg-in16.3%
neg-mul-116.3%
*-commutative16.3%
fma-udef16.3%
distribute-lft-neg-in16.3%
distribute-lft-neg-in16.3%
fma-udef16.3%
*-commutative16.3%
neg-mul-116.3%
distribute-neg-in16.3%
remove-double-neg16.3%
metadata-eval16.3%
+-commutative16.3%
Simplified16.3%
Taylor expanded in x around 0 99.8%
Taylor expanded in x around inf 97.6%
unpow297.6%
Simplified97.6%
Final simplification98.7%
(FPCore (x) :precision binary64 (/ 2.0 (* x (* (+ x 1.0) (+ x -1.0)))))
double code(double x) {
return 2.0 / (x * ((x + 1.0) * (x + -1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 2.0d0 / (x * ((x + 1.0d0) * (x + (-1.0d0))))
end function
public static double code(double x) {
return 2.0 / (x * ((x + 1.0) * (x + -1.0)));
}
def code(x): return 2.0 / (x * ((x + 1.0) * (x + -1.0)))
function code(x) return Float64(2.0 / Float64(x * Float64(Float64(x + 1.0) * Float64(x + -1.0)))) end
function tmp = code(x) tmp = 2.0 / (x * ((x + 1.0) * (x + -1.0))); end
code[x_] := N[(2.0 / N[(x * N[(N[(x + 1.0), $MachinePrecision] * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{x \cdot \left(\left(x + 1\right) \cdot \left(x + -1\right)\right)}
\end{array}
Initial program 83.3%
associate-+l-83.3%
sub-neg83.3%
neg-mul-183.3%
metadata-eval83.3%
cancel-sign-sub-inv83.3%
+-commutative83.3%
*-lft-identity83.3%
sub-neg83.3%
metadata-eval83.3%
Simplified83.3%
frac-sub60.5%
frac-sub61.2%
*-un-lft-identity61.2%
distribute-rgt-in61.2%
neg-mul-161.2%
sub-neg61.2%
*-rgt-identity61.2%
distribute-rgt-in61.2%
metadata-eval61.2%
metadata-eval61.2%
fma-def61.2%
metadata-eval61.2%
distribute-rgt-in61.2%
neg-mul-161.2%
sub-neg61.2%
Applied egg-rr61.2%
+-commutative61.2%
remove-double-neg61.2%
metadata-eval61.2%
distribute-neg-in61.2%
neg-mul-161.2%
*-commutative61.2%
fma-udef61.2%
distribute-lft-neg-in61.2%
distribute-lft-neg-in61.2%
fma-udef61.2%
*-commutative61.2%
neg-mul-161.2%
distribute-neg-in61.2%
remove-double-neg61.2%
metadata-eval61.2%
+-commutative61.2%
Simplified61.2%
Taylor expanded in x around 0 99.6%
add-log-exp35.6%
*-un-lft-identity35.6%
log-prod35.6%
metadata-eval35.6%
add-log-exp99.6%
*-commutative99.6%
associate-/r*99.9%
*-un-lft-identity99.9%
distribute-rgt-out--99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-lft-identity99.9%
associate-/r*99.6%
associate-*l*99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x) :precision binary64 (/ (/ 2.0 (+ x 1.0)) (* x (+ x -1.0))))
double code(double x) {
return (2.0 / (x + 1.0)) / (x * (x + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (2.0d0 / (x + 1.0d0)) / (x * (x + (-1.0d0)))
end function
public static double code(double x) {
return (2.0 / (x + 1.0)) / (x * (x + -1.0));
}
def code(x): return (2.0 / (x + 1.0)) / (x * (x + -1.0))
function code(x) return Float64(Float64(2.0 / Float64(x + 1.0)) / Float64(x * Float64(x + -1.0))) end
function tmp = code(x) tmp = (2.0 / (x + 1.0)) / (x * (x + -1.0)); end
code[x_] := N[(N[(2.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{x + 1}}{x \cdot \left(x + -1\right)}
\end{array}
Initial program 83.3%
associate-+l-83.3%
sub-neg83.3%
neg-mul-183.3%
metadata-eval83.3%
cancel-sign-sub-inv83.3%
+-commutative83.3%
*-lft-identity83.3%
sub-neg83.3%
metadata-eval83.3%
Simplified83.3%
frac-sub60.5%
frac-sub61.2%
*-un-lft-identity61.2%
distribute-rgt-in61.2%
neg-mul-161.2%
sub-neg61.2%
*-rgt-identity61.2%
distribute-rgt-in61.2%
metadata-eval61.2%
metadata-eval61.2%
fma-def61.2%
metadata-eval61.2%
distribute-rgt-in61.2%
neg-mul-161.2%
sub-neg61.2%
Applied egg-rr61.2%
+-commutative61.2%
remove-double-neg61.2%
metadata-eval61.2%
distribute-neg-in61.2%
neg-mul-161.2%
*-commutative61.2%
fma-udef61.2%
distribute-lft-neg-in61.2%
distribute-lft-neg-in61.2%
fma-udef61.2%
*-commutative61.2%
neg-mul-161.2%
distribute-neg-in61.2%
remove-double-neg61.2%
metadata-eval61.2%
+-commutative61.2%
Simplified61.2%
Taylor expanded in x around 0 99.6%
associate-/r*99.9%
div-inv99.8%
*-un-lft-identity99.8%
distribute-rgt-out--99.8%
sub-neg99.8%
metadata-eval99.8%
Applied egg-rr99.8%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (+ -1.0 (+ 1.0 (/ -2.0 x))))
double code(double x) {
return -1.0 + (1.0 + (-2.0 / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-1.0d0) + (1.0d0 + ((-2.0d0) / x))
end function
public static double code(double x) {
return -1.0 + (1.0 + (-2.0 / x));
}
def code(x): return -1.0 + (1.0 + (-2.0 / x))
function code(x) return Float64(-1.0 + Float64(1.0 + Float64(-2.0 / x))) end
function tmp = code(x) tmp = -1.0 + (1.0 + (-2.0 / x)); end
code[x_] := N[(-1.0 + N[(1.0 + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left(1 + \frac{-2}{x}\right)
\end{array}
Initial program 83.3%
associate-+l-83.3%
sub-neg83.3%
neg-mul-183.3%
metadata-eval83.3%
cancel-sign-sub-inv83.3%
+-commutative83.3%
*-lft-identity83.3%
sub-neg83.3%
metadata-eval83.3%
Simplified83.3%
Taylor expanded in x around 0 52.3%
Taylor expanded in x around 0 82.1%
associate--r-82.1%
*-un-lft-identity82.1%
cancel-sign-sub-inv82.1%
metadata-eval82.1%
*-commutative82.1%
associate-*l/82.1%
metadata-eval82.1%
Applied egg-rr82.1%
Final simplification82.1%
(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 83.3%
associate-+l-83.3%
sub-neg83.3%
neg-mul-183.3%
metadata-eval83.3%
cancel-sign-sub-inv83.3%
+-commutative83.3%
*-lft-identity83.3%
sub-neg83.3%
metadata-eval83.3%
Simplified83.3%
Taylor expanded in x around 0 53.1%
Final simplification53.1%
(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 2023214
(FPCore (x)
:name "3frac (problem 3.3.3)"
:precision binary64
:herbie-target
(/ 2.0 (* x (- (* x x) 1.0)))
(+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))