
(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
(let* ((t_0 (- (* x x) x)) (t_1 (/ (- 2.0 x) (- 1.0 x))))
(if (<= x -65000000.0)
(* (/ (/ 2.0 (* x x)) x) t_1)
(if (<= x 1050000.0)
(/ (+ t_0 (* (+ x 1.0) (- x (* (- 1.0 x) -2.0)))) (* t_0 (+ x 1.0)))
(* t_1 (/ (/ (+ (/ 2.0 x) (/ 4.0 (* x x))) (+ x 1.0)) x))))))
double code(double x) {
double t_0 = (x * x) - x;
double t_1 = (2.0 - x) / (1.0 - x);
double tmp;
if (x <= -65000000.0) {
tmp = ((2.0 / (x * x)) / x) * t_1;
} else if (x <= 1050000.0) {
tmp = (t_0 + ((x + 1.0) * (x - ((1.0 - x) * -2.0)))) / (t_0 * (x + 1.0));
} else {
tmp = t_1 * ((((2.0 / x) + (4.0 / (x * x))) / (x + 1.0)) / x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (x * x) - x
t_1 = (2.0d0 - x) / (1.0d0 - x)
if (x <= (-65000000.0d0)) then
tmp = ((2.0d0 / (x * x)) / x) * t_1
else if (x <= 1050000.0d0) then
tmp = (t_0 + ((x + 1.0d0) * (x - ((1.0d0 - x) * (-2.0d0))))) / (t_0 * (x + 1.0d0))
else
tmp = t_1 * ((((2.0d0 / x) + (4.0d0 / (x * x))) / (x + 1.0d0)) / x)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x * x) - x;
double t_1 = (2.0 - x) / (1.0 - x);
double tmp;
if (x <= -65000000.0) {
tmp = ((2.0 / (x * x)) / x) * t_1;
} else if (x <= 1050000.0) {
tmp = (t_0 + ((x + 1.0) * (x - ((1.0 - x) * -2.0)))) / (t_0 * (x + 1.0));
} else {
tmp = t_1 * ((((2.0 / x) + (4.0 / (x * x))) / (x + 1.0)) / x);
}
return tmp;
}
def code(x): t_0 = (x * x) - x t_1 = (2.0 - x) / (1.0 - x) tmp = 0 if x <= -65000000.0: tmp = ((2.0 / (x * x)) / x) * t_1 elif x <= 1050000.0: tmp = (t_0 + ((x + 1.0) * (x - ((1.0 - x) * -2.0)))) / (t_0 * (x + 1.0)) else: tmp = t_1 * ((((2.0 / x) + (4.0 / (x * x))) / (x + 1.0)) / x) return tmp
function code(x) t_0 = Float64(Float64(x * x) - x) t_1 = Float64(Float64(2.0 - x) / Float64(1.0 - x)) tmp = 0.0 if (x <= -65000000.0) tmp = Float64(Float64(Float64(2.0 / Float64(x * x)) / x) * t_1); elseif (x <= 1050000.0) tmp = Float64(Float64(t_0 + Float64(Float64(x + 1.0) * Float64(x - Float64(Float64(1.0 - x) * -2.0)))) / Float64(t_0 * Float64(x + 1.0))); else tmp = Float64(t_1 * Float64(Float64(Float64(Float64(2.0 / x) + Float64(4.0 / Float64(x * x))) / Float64(x + 1.0)) / x)); end return tmp end
function tmp_2 = code(x) t_0 = (x * x) - x; t_1 = (2.0 - x) / (1.0 - x); tmp = 0.0; if (x <= -65000000.0) tmp = ((2.0 / (x * x)) / x) * t_1; elseif (x <= 1050000.0) tmp = (t_0 + ((x + 1.0) * (x - ((1.0 - x) * -2.0)))) / (t_0 * (x + 1.0)); else tmp = t_1 * ((((2.0 / x) + (4.0 / (x * x))) / (x + 1.0)) / x); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 - x), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -65000000.0], N[(N[(N[(2.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[x, 1050000.0], N[(N[(t$95$0 + N[(N[(x + 1.0), $MachinePrecision] * N[(x - N[(N[(1.0 - x), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[(N[(N[(2.0 / x), $MachinePrecision] + N[(4.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot x - x\\
t_1 := \frac{2 - x}{1 - x}\\
\mathbf{if}\;x \leq -65000000:\\
\;\;\;\;\frac{\frac{2}{x \cdot x}}{x} \cdot t_1\\
\mathbf{elif}\;x \leq 1050000:\\
\;\;\;\;\frac{t_0 + \left(x + 1\right) \cdot \left(x - \left(1 - x\right) \cdot -2\right)}{t_0 \cdot \left(x + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \frac{\frac{\frac{2}{x} + \frac{4}{x \cdot x}}{x + 1}}{x}\\
\end{array}
\end{array}
if x < -6.5e7Initial program 75.8%
Simplified75.8%
frac-2neg75.8%
metadata-eval75.8%
frac-sub19.3%
+-commutative19.3%
distribute-neg-in19.3%
metadata-eval19.3%
sub-neg19.3%
*-commutative19.3%
neg-mul-119.3%
+-commutative19.3%
distribute-neg-in19.3%
metadata-eval19.3%
sub-neg19.3%
Applied egg-rr19.3%
Taylor expanded in x around 0 19.3%
neg-mul-119.3%
unsub-neg19.3%
Simplified19.3%
clear-num23.9%
frac-sub18.5%
*-un-lft-identity18.5%
Applied egg-rr18.5%
/-rgt-identity18.5%
associate-/r*18.5%
associate-/l*19.4%
associate-/r/19.4%
Simplified75.8%
Taylor expanded in x around inf 99.9%
unpow299.9%
Simplified99.9%
if -6.5e7 < x < 1.05e6Initial program 99.6%
Simplified99.6%
frac-2neg99.6%
frac-2neg99.6%
metadata-eval99.6%
frac-sub99.7%
metadata-eval99.7%
+-commutative99.7%
distribute-neg-in99.7%
metadata-eval99.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-in99.7%
metadata-eval99.7%
sub-neg99.7%
Applied egg-rr99.7%
cancel-sign-sub99.7%
*-commutative99.7%
neg-mul-199.7%
unsub-neg99.7%
sub-neg99.7%
+-commutative99.7%
distribute-lft-in99.7%
sqr-neg99.7%
unpow299.7%
sqr-pow99.7%
*-rgt-identity99.7%
sqr-pow99.7%
sub-neg99.7%
unpow299.7%
Simplified99.7%
frac-sub100.0%
*-un-lft-identity100.0%
*-commutative100.0%
Applied egg-rr100.0%
if 1.05e6 < x Initial program 69.7%
Simplified69.7%
frac-2neg69.7%
metadata-eval69.7%
frac-sub13.7%
+-commutative13.7%
distribute-neg-in13.7%
metadata-eval13.7%
sub-neg13.7%
*-commutative13.7%
neg-mul-113.7%
+-commutative13.7%
distribute-neg-in13.7%
metadata-eval13.7%
sub-neg13.7%
Applied egg-rr13.7%
Taylor expanded in x around 0 13.7%
neg-mul-113.7%
unsub-neg13.7%
Simplified13.7%
clear-num14.9%
frac-sub9.6%
*-un-lft-identity9.6%
Applied egg-rr9.6%
/-rgt-identity9.6%
associate-/r*9.6%
associate-/l*10.5%
associate-/r/10.5%
Simplified69.6%
Taylor expanded in x around inf 99.9%
associate-*r/99.9%
metadata-eval99.9%
associate-*r/99.9%
metadata-eval99.9%
unpow299.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (+ x -1.0)))))
(if (or (<= t_0 -0.0002) (not (<= t_0 1e-24)))
t_0
(* (/ (/ 2.0 (* x x)) x) (/ (- 2.0 x) (- 1.0 x))))))
double code(double x) {
double t_0 = ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if ((t_0 <= -0.0002) || !(t_0 <= 1e-24)) {
tmp = t_0;
} else {
tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 / (x + 1.0d0)) - (2.0d0 / x)) + (1.0d0 / (x + (-1.0d0)))
if ((t_0 <= (-0.0002d0)) .or. (.not. (t_0 <= 1d-24))) then
tmp = t_0
else
tmp = ((2.0d0 / (x * x)) / x) * ((2.0d0 - x) / (1.0d0 - x))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if ((t_0 <= -0.0002) || !(t_0 <= 1e-24)) {
tmp = t_0;
} else {
tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x));
}
return tmp;
}
def code(x): t_0 = ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0)) tmp = 0 if (t_0 <= -0.0002) or not (t_0 <= 1e-24): tmp = t_0 else: tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x)) return tmp
function code(x) t_0 = Float64(Float64(Float64(1.0 / Float64(x + 1.0)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x + -1.0))) tmp = 0.0 if ((t_0 <= -0.0002) || !(t_0 <= 1e-24)) tmp = t_0; else tmp = Float64(Float64(Float64(2.0 / Float64(x * x)) / x) * Float64(Float64(2.0 - x) / Float64(1.0 - x))); end return tmp end
function tmp_2 = code(x) t_0 = ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x + -1.0)); tmp = 0.0; if ((t_0 <= -0.0002) || ~((t_0 <= 1e-24))) tmp = t_0; else tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = 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]}, If[Or[LessEqual[t$95$0, -0.0002], N[Not[LessEqual[t$95$0, 1e-24]], $MachinePrecision]], t$95$0, N[(N[(N[(2.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * N[(N[(2.0 - x), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{if}\;t_0 \leq -0.0002 \lor \neg \left(t_0 \leq 10^{-24}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{x \cdot x}}{x} \cdot \frac{2 - x}{1 - x}\\
\end{array}
\end{array}
if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < -2.0000000000000001e-4 or 9.99999999999999924e-25 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 99.6%
if -2.0000000000000001e-4 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 9.99999999999999924e-25Initial program 72.6%
Simplified72.6%
frac-2neg72.6%
metadata-eval72.6%
frac-sub16.3%
+-commutative16.3%
distribute-neg-in16.3%
metadata-eval16.3%
sub-neg16.3%
*-commutative16.3%
neg-mul-116.3%
+-commutative16.3%
distribute-neg-in16.3%
metadata-eval16.3%
sub-neg16.3%
Applied egg-rr16.3%
Taylor expanded in x around 0 16.3%
neg-mul-116.3%
unsub-neg16.3%
Simplified16.3%
clear-num19.1%
frac-sub13.8%
*-un-lft-identity13.8%
Applied egg-rr13.8%
/-rgt-identity13.8%
associate-/r*13.8%
associate-/l*14.7%
associate-/r/14.7%
Simplified72.5%
Taylor expanded in x around inf 99.3%
unpow299.3%
Simplified99.3%
Final simplification99.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (+ x 1.0))) (t_1 (+ (- t_0 (/ 2.0 x)) (/ 1.0 (+ x -1.0)))))
(if (or (<= t_1 -0.0002) (not (<= t_1 1e-24)))
(+ t_0 (/ (- x 2.0) (* x (- 1.0 x))))
(* (/ (/ 2.0 (* x x)) x) (/ (- 2.0 x) (- 1.0 x))))))
double code(double x) {
double t_0 = 1.0 / (x + 1.0);
double t_1 = (t_0 - (2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if ((t_1 <= -0.0002) || !(t_1 <= 1e-24)) {
tmp = t_0 + ((x - 2.0) / (x * (1.0 - x)));
} else {
tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 / (x + 1.0d0)
t_1 = (t_0 - (2.0d0 / x)) + (1.0d0 / (x + (-1.0d0)))
if ((t_1 <= (-0.0002d0)) .or. (.not. (t_1 <= 1d-24))) then
tmp = t_0 + ((x - 2.0d0) / (x * (1.0d0 - x)))
else
tmp = ((2.0d0 / (x * x)) / x) * ((2.0d0 - x) / (1.0d0 - x))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = 1.0 / (x + 1.0);
double t_1 = (t_0 - (2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if ((t_1 <= -0.0002) || !(t_1 <= 1e-24)) {
tmp = t_0 + ((x - 2.0) / (x * (1.0 - x)));
} else {
tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x));
}
return tmp;
}
def code(x): t_0 = 1.0 / (x + 1.0) t_1 = (t_0 - (2.0 / x)) + (1.0 / (x + -1.0)) tmp = 0 if (t_1 <= -0.0002) or not (t_1 <= 1e-24): tmp = t_0 + ((x - 2.0) / (x * (1.0 - x))) else: tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x)) return tmp
function code(x) t_0 = Float64(1.0 / Float64(x + 1.0)) t_1 = Float64(Float64(t_0 - Float64(2.0 / x)) + Float64(1.0 / Float64(x + -1.0))) tmp = 0.0 if ((t_1 <= -0.0002) || !(t_1 <= 1e-24)) tmp = Float64(t_0 + Float64(Float64(x - 2.0) / Float64(x * Float64(1.0 - x)))); else tmp = Float64(Float64(Float64(2.0 / Float64(x * x)) / x) * Float64(Float64(2.0 - x) / Float64(1.0 - x))); end return tmp end
function tmp_2 = code(x) t_0 = 1.0 / (x + 1.0); t_1 = (t_0 - (2.0 / x)) + (1.0 / (x + -1.0)); tmp = 0.0; if ((t_1 <= -0.0002) || ~((t_1 <= 1e-24))) tmp = t_0 + ((x - 2.0) / (x * (1.0 - x))); else tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -0.0002], N[Not[LessEqual[t$95$1, 1e-24]], $MachinePrecision]], N[(t$95$0 + N[(N[(x - 2.0), $MachinePrecision] / N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * N[(N[(2.0 - x), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{x + 1}\\
t_1 := \left(t_0 - \frac{2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{if}\;t_1 \leq -0.0002 \lor \neg \left(t_1 \leq 10^{-24}\right):\\
\;\;\;\;t_0 + \frac{x - 2}{x \cdot \left(1 - x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{x \cdot x}}{x} \cdot \frac{2 - x}{1 - x}\\
\end{array}
\end{array}
if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < -2.0000000000000001e-4 or 9.99999999999999924e-25 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 99.6%
Simplified99.6%
frac-2neg99.6%
metadata-eval99.6%
frac-sub99.7%
+-commutative99.7%
distribute-neg-in99.7%
metadata-eval99.7%
sub-neg99.7%
*-commutative99.7%
neg-mul-199.7%
+-commutative99.7%
distribute-neg-in99.7%
metadata-eval99.7%
sub-neg99.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 99.7%
neg-mul-199.7%
unsub-neg99.7%
Simplified99.7%
if -2.0000000000000001e-4 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 9.99999999999999924e-25Initial program 72.6%
Simplified72.6%
frac-2neg72.6%
metadata-eval72.6%
frac-sub16.3%
+-commutative16.3%
distribute-neg-in16.3%
metadata-eval16.3%
sub-neg16.3%
*-commutative16.3%
neg-mul-116.3%
+-commutative16.3%
distribute-neg-in16.3%
metadata-eval16.3%
sub-neg16.3%
Applied egg-rr16.3%
Taylor expanded in x around 0 16.3%
neg-mul-116.3%
unsub-neg16.3%
Simplified16.3%
clear-num19.1%
frac-sub13.8%
*-un-lft-identity13.8%
Applied egg-rr13.8%
/-rgt-identity13.8%
associate-/r*13.8%
associate-/l*14.7%
associate-/r/14.7%
Simplified72.5%
Taylor expanded in x around inf 99.3%
unpow299.3%
Simplified99.3%
Final simplification99.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (- 2.0 x) (- 1.0 x))))
(if (<= x -350000.0)
(* (/ (/ 2.0 (* x x)) x) t_0)
(if (<= x 17000.0)
(+ (/ 1.0 (+ x 1.0)) (/ (- x (* (- 1.0 x) -2.0)) (- (* x x) x)))
(* t_0 (/ (/ (+ (/ 2.0 x) (/ 4.0 (* x x))) (+ x 1.0)) x))))))
double code(double x) {
double t_0 = (2.0 - x) / (1.0 - x);
double tmp;
if (x <= -350000.0) {
tmp = ((2.0 / (x * x)) / x) * t_0;
} else if (x <= 17000.0) {
tmp = (1.0 / (x + 1.0)) + ((x - ((1.0 - x) * -2.0)) / ((x * x) - x));
} else {
tmp = t_0 * ((((2.0 / x) + (4.0 / (x * x))) / (x + 1.0)) / x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (2.0d0 - x) / (1.0d0 - x)
if (x <= (-350000.0d0)) then
tmp = ((2.0d0 / (x * x)) / x) * t_0
else if (x <= 17000.0d0) then
tmp = (1.0d0 / (x + 1.0d0)) + ((x - ((1.0d0 - x) * (-2.0d0))) / ((x * x) - x))
else
tmp = t_0 * ((((2.0d0 / x) + (4.0d0 / (x * x))) / (x + 1.0d0)) / x)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (2.0 - x) / (1.0 - x);
double tmp;
if (x <= -350000.0) {
tmp = ((2.0 / (x * x)) / x) * t_0;
} else if (x <= 17000.0) {
tmp = (1.0 / (x + 1.0)) + ((x - ((1.0 - x) * -2.0)) / ((x * x) - x));
} else {
tmp = t_0 * ((((2.0 / x) + (4.0 / (x * x))) / (x + 1.0)) / x);
}
return tmp;
}
def code(x): t_0 = (2.0 - x) / (1.0 - x) tmp = 0 if x <= -350000.0: tmp = ((2.0 / (x * x)) / x) * t_0 elif x <= 17000.0: tmp = (1.0 / (x + 1.0)) + ((x - ((1.0 - x) * -2.0)) / ((x * x) - x)) else: tmp = t_0 * ((((2.0 / x) + (4.0 / (x * x))) / (x + 1.0)) / x) return tmp
function code(x) t_0 = Float64(Float64(2.0 - x) / Float64(1.0 - x)) tmp = 0.0 if (x <= -350000.0) tmp = Float64(Float64(Float64(2.0 / Float64(x * x)) / x) * t_0); elseif (x <= 17000.0) tmp = Float64(Float64(1.0 / Float64(x + 1.0)) + Float64(Float64(x - Float64(Float64(1.0 - x) * -2.0)) / Float64(Float64(x * x) - x))); else tmp = Float64(t_0 * Float64(Float64(Float64(Float64(2.0 / x) + Float64(4.0 / Float64(x * x))) / Float64(x + 1.0)) / x)); end return tmp end
function tmp_2 = code(x) t_0 = (2.0 - x) / (1.0 - x); tmp = 0.0; if (x <= -350000.0) tmp = ((2.0 / (x * x)) / x) * t_0; elseif (x <= 17000.0) tmp = (1.0 / (x + 1.0)) + ((x - ((1.0 - x) * -2.0)) / ((x * x) - x)); else tmp = t_0 * ((((2.0 / x) + (4.0 / (x * x))) / (x + 1.0)) / x); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(2.0 - x), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -350000.0], N[(N[(N[(2.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[x, 17000.0], N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x - N[(N[(1.0 - x), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(N[(2.0 / x), $MachinePrecision] + N[(4.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2 - x}{1 - x}\\
\mathbf{if}\;x \leq -350000:\\
\;\;\;\;\frac{\frac{2}{x \cdot x}}{x} \cdot t_0\\
\mathbf{elif}\;x \leq 17000:\\
\;\;\;\;\frac{1}{x + 1} + \frac{x - \left(1 - x\right) \cdot -2}{x \cdot x - x}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{\frac{\frac{2}{x} + \frac{4}{x \cdot x}}{x + 1}}{x}\\
\end{array}
\end{array}
if x < -3.5e5Initial program 75.8%
Simplified75.8%
frac-2neg75.8%
metadata-eval75.8%
frac-sub19.3%
+-commutative19.3%
distribute-neg-in19.3%
metadata-eval19.3%
sub-neg19.3%
*-commutative19.3%
neg-mul-119.3%
+-commutative19.3%
distribute-neg-in19.3%
metadata-eval19.3%
sub-neg19.3%
Applied egg-rr19.3%
Taylor expanded in x around 0 19.3%
neg-mul-119.3%
unsub-neg19.3%
Simplified19.3%
clear-num23.9%
frac-sub18.5%
*-un-lft-identity18.5%
Applied egg-rr18.5%
/-rgt-identity18.5%
associate-/r*18.5%
associate-/l*19.4%
associate-/r/19.4%
Simplified75.8%
Taylor expanded in x around inf 99.9%
unpow299.9%
Simplified99.9%
if -3.5e5 < x < 17000Initial program 99.6%
Simplified99.6%
frac-2neg99.6%
frac-2neg99.6%
metadata-eval99.6%
frac-sub99.7%
metadata-eval99.7%
+-commutative99.7%
distribute-neg-in99.7%
metadata-eval99.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-in99.7%
metadata-eval99.7%
sub-neg99.7%
Applied egg-rr99.7%
cancel-sign-sub99.7%
*-commutative99.7%
neg-mul-199.7%
unsub-neg99.7%
sub-neg99.7%
+-commutative99.7%
distribute-lft-in99.7%
sqr-neg99.7%
unpow299.7%
sqr-pow99.7%
*-rgt-identity99.7%
sqr-pow99.7%
sub-neg99.7%
unpow299.7%
Simplified99.7%
if 17000 < x Initial program 69.7%
Simplified69.7%
frac-2neg69.7%
metadata-eval69.7%
frac-sub13.7%
+-commutative13.7%
distribute-neg-in13.7%
metadata-eval13.7%
sub-neg13.7%
*-commutative13.7%
neg-mul-113.7%
+-commutative13.7%
distribute-neg-in13.7%
metadata-eval13.7%
sub-neg13.7%
Applied egg-rr13.7%
Taylor expanded in x around 0 13.7%
neg-mul-113.7%
unsub-neg13.7%
Simplified13.7%
clear-num14.9%
frac-sub9.6%
*-un-lft-identity9.6%
Applied egg-rr9.6%
/-rgt-identity9.6%
associate-/r*9.6%
associate-/l*10.5%
associate-/r/10.5%
Simplified69.6%
Taylor expanded in x around inf 99.9%
associate-*r/99.9%
metadata-eval99.9%
associate-*r/99.9%
metadata-eval99.9%
unpow299.9%
Simplified99.9%
Final simplification99.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (* x (- 1.0 x))) (t_1 (/ (- 2.0 x) (- 1.0 x))))
(if (<= x -135000000.0)
(* (/ (/ 2.0 (* x x)) x) t_1)
(if (<= x 140000000.0)
(/ (+ t_0 (* (- 2.0 x) (- -1.0 x))) (* (+ x 1.0) t_0))
(* t_1 (/ (/ (+ (/ 2.0 x) (/ 4.0 (* x x))) (+ x 1.0)) x))))))
double code(double x) {
double t_0 = x * (1.0 - x);
double t_1 = (2.0 - x) / (1.0 - x);
double tmp;
if (x <= -135000000.0) {
tmp = ((2.0 / (x * x)) / x) * t_1;
} else if (x <= 140000000.0) {
tmp = (t_0 + ((2.0 - x) * (-1.0 - x))) / ((x + 1.0) * t_0);
} else {
tmp = t_1 * ((((2.0 / x) + (4.0 / (x * x))) / (x + 1.0)) / x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * (1.0d0 - x)
t_1 = (2.0d0 - x) / (1.0d0 - x)
if (x <= (-135000000.0d0)) then
tmp = ((2.0d0 / (x * x)) / x) * t_1
else if (x <= 140000000.0d0) then
tmp = (t_0 + ((2.0d0 - x) * ((-1.0d0) - x))) / ((x + 1.0d0) * t_0)
else
tmp = t_1 * ((((2.0d0 / x) + (4.0d0 / (x * x))) / (x + 1.0d0)) / x)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = x * (1.0 - x);
double t_1 = (2.0 - x) / (1.0 - x);
double tmp;
if (x <= -135000000.0) {
tmp = ((2.0 / (x * x)) / x) * t_1;
} else if (x <= 140000000.0) {
tmp = (t_0 + ((2.0 - x) * (-1.0 - x))) / ((x + 1.0) * t_0);
} else {
tmp = t_1 * ((((2.0 / x) + (4.0 / (x * x))) / (x + 1.0)) / x);
}
return tmp;
}
def code(x): t_0 = x * (1.0 - x) t_1 = (2.0 - x) / (1.0 - x) tmp = 0 if x <= -135000000.0: tmp = ((2.0 / (x * x)) / x) * t_1 elif x <= 140000000.0: tmp = (t_0 + ((2.0 - x) * (-1.0 - x))) / ((x + 1.0) * t_0) else: tmp = t_1 * ((((2.0 / x) + (4.0 / (x * x))) / (x + 1.0)) / x) return tmp
function code(x) t_0 = Float64(x * Float64(1.0 - x)) t_1 = Float64(Float64(2.0 - x) / Float64(1.0 - x)) tmp = 0.0 if (x <= -135000000.0) tmp = Float64(Float64(Float64(2.0 / Float64(x * x)) / x) * t_1); elseif (x <= 140000000.0) tmp = Float64(Float64(t_0 + Float64(Float64(2.0 - x) * Float64(-1.0 - x))) / Float64(Float64(x + 1.0) * t_0)); else tmp = Float64(t_1 * Float64(Float64(Float64(Float64(2.0 / x) + Float64(4.0 / Float64(x * x))) / Float64(x + 1.0)) / x)); end return tmp end
function tmp_2 = code(x) t_0 = x * (1.0 - x); t_1 = (2.0 - x) / (1.0 - x); tmp = 0.0; if (x <= -135000000.0) tmp = ((2.0 / (x * x)) / x) * t_1; elseif (x <= 140000000.0) tmp = (t_0 + ((2.0 - x) * (-1.0 - x))) / ((x + 1.0) * t_0); else tmp = t_1 * ((((2.0 / x) + (4.0 / (x * x))) / (x + 1.0)) / x); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(x * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 - x), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -135000000.0], N[(N[(N[(2.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[x, 140000000.0], N[(N[(t$95$0 + N[(N[(2.0 - x), $MachinePrecision] * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[(N[(N[(2.0 / x), $MachinePrecision] + N[(4.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - x\right)\\
t_1 := \frac{2 - x}{1 - x}\\
\mathbf{if}\;x \leq -135000000:\\
\;\;\;\;\frac{\frac{2}{x \cdot x}}{x} \cdot t_1\\
\mathbf{elif}\;x \leq 140000000:\\
\;\;\;\;\frac{t_0 + \left(2 - x\right) \cdot \left(-1 - x\right)}{\left(x + 1\right) \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \frac{\frac{\frac{2}{x} + \frac{4}{x \cdot x}}{x + 1}}{x}\\
\end{array}
\end{array}
if x < -1.35e8Initial program 75.8%
Simplified75.8%
frac-2neg75.8%
metadata-eval75.8%
frac-sub19.3%
+-commutative19.3%
distribute-neg-in19.3%
metadata-eval19.3%
sub-neg19.3%
*-commutative19.3%
neg-mul-119.3%
+-commutative19.3%
distribute-neg-in19.3%
metadata-eval19.3%
sub-neg19.3%
Applied egg-rr19.3%
Taylor expanded in x around 0 19.3%
neg-mul-119.3%
unsub-neg19.3%
Simplified19.3%
clear-num23.9%
frac-sub18.5%
*-un-lft-identity18.5%
Applied egg-rr18.5%
/-rgt-identity18.5%
associate-/r*18.5%
associate-/l*19.4%
associate-/r/19.4%
Simplified75.8%
Taylor expanded in x around inf 99.9%
unpow299.9%
Simplified99.9%
if -1.35e8 < x < 1.4e8Initial program 99.6%
Simplified99.6%
frac-2neg99.6%
metadata-eval99.6%
frac-sub99.7%
+-commutative99.7%
distribute-neg-in99.7%
metadata-eval99.7%
sub-neg99.7%
*-commutative99.7%
neg-mul-199.7%
+-commutative99.7%
distribute-neg-in99.7%
metadata-eval99.7%
sub-neg99.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 99.7%
neg-mul-199.7%
unsub-neg99.7%
Simplified99.7%
frac-sub100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
if 1.4e8 < x Initial program 69.7%
Simplified69.7%
frac-2neg69.7%
metadata-eval69.7%
frac-sub13.7%
+-commutative13.7%
distribute-neg-in13.7%
metadata-eval13.7%
sub-neg13.7%
*-commutative13.7%
neg-mul-113.7%
+-commutative13.7%
distribute-neg-in13.7%
metadata-eval13.7%
sub-neg13.7%
Applied egg-rr13.7%
Taylor expanded in x around 0 13.7%
neg-mul-113.7%
unsub-neg13.7%
Simplified13.7%
clear-num14.9%
frac-sub9.6%
*-un-lft-identity9.6%
Applied egg-rr9.6%
/-rgt-identity9.6%
associate-/r*9.6%
associate-/l*10.5%
associate-/r/10.5%
Simplified69.6%
Taylor expanded in x around inf 99.9%
associate-*r/99.9%
metadata-eval99.9%
associate-*r/99.9%
metadata-eval99.9%
unpow299.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (if (or (<= x -350000.0) (not (<= x 250000.0))) (* (/ (/ 2.0 (* x x)) x) (/ (- 2.0 x) (- 1.0 x))) (+ (/ 1.0 (+ x 1.0)) (/ (- x (* (- 1.0 x) -2.0)) (- (* x x) x)))))
double code(double x) {
double tmp;
if ((x <= -350000.0) || !(x <= 250000.0)) {
tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x));
} else {
tmp = (1.0 / (x + 1.0)) + ((x - ((1.0 - x) * -2.0)) / ((x * x) - x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-350000.0d0)) .or. (.not. (x <= 250000.0d0))) then
tmp = ((2.0d0 / (x * x)) / x) * ((2.0d0 - x) / (1.0d0 - x))
else
tmp = (1.0d0 / (x + 1.0d0)) + ((x - ((1.0d0 - x) * (-2.0d0))) / ((x * x) - x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -350000.0) || !(x <= 250000.0)) {
tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x));
} else {
tmp = (1.0 / (x + 1.0)) + ((x - ((1.0 - x) * -2.0)) / ((x * x) - x));
}
return tmp;
}
def code(x): tmp = 0 if (x <= -350000.0) or not (x <= 250000.0): tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x)) else: tmp = (1.0 / (x + 1.0)) + ((x - ((1.0 - x) * -2.0)) / ((x * x) - x)) return tmp
function code(x) tmp = 0.0 if ((x <= -350000.0) || !(x <= 250000.0)) tmp = Float64(Float64(Float64(2.0 / Float64(x * x)) / x) * Float64(Float64(2.0 - x) / Float64(1.0 - x))); else tmp = Float64(Float64(1.0 / Float64(x + 1.0)) + Float64(Float64(x - Float64(Float64(1.0 - x) * -2.0)) / Float64(Float64(x * x) - x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -350000.0) || ~((x <= 250000.0))) tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x)); else tmp = (1.0 / (x + 1.0)) + ((x - ((1.0 - x) * -2.0)) / ((x * x) - x)); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -350000.0], N[Not[LessEqual[x, 250000.0]], $MachinePrecision]], N[(N[(N[(2.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * N[(N[(2.0 - x), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x - N[(N[(1.0 - x), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -350000 \lor \neg \left(x \leq 250000\right):\\
\;\;\;\;\frac{\frac{2}{x \cdot x}}{x} \cdot \frac{2 - x}{1 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + 1} + \frac{x - \left(1 - x\right) \cdot -2}{x \cdot x - x}\\
\end{array}
\end{array}
if x < -3.5e5 or 2.5e5 < x Initial program 72.6%
Simplified72.6%
frac-2neg72.6%
metadata-eval72.6%
frac-sub16.3%
+-commutative16.3%
distribute-neg-in16.3%
metadata-eval16.3%
sub-neg16.3%
*-commutative16.3%
neg-mul-116.3%
+-commutative16.3%
distribute-neg-in16.3%
metadata-eval16.3%
sub-neg16.3%
Applied egg-rr16.3%
Taylor expanded in x around 0 16.3%
neg-mul-116.3%
unsub-neg16.3%
Simplified16.3%
clear-num19.1%
frac-sub13.8%
*-un-lft-identity13.8%
Applied egg-rr13.8%
/-rgt-identity13.8%
associate-/r*13.8%
associate-/l*14.7%
associate-/r/14.7%
Simplified72.5%
Taylor expanded in x around inf 99.3%
unpow299.3%
Simplified99.3%
if -3.5e5 < x < 2.5e5Initial program 99.6%
Simplified99.6%
frac-2neg99.6%
frac-2neg99.6%
metadata-eval99.6%
frac-sub99.7%
metadata-eval99.7%
+-commutative99.7%
distribute-neg-in99.7%
metadata-eval99.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-in99.7%
metadata-eval99.7%
sub-neg99.7%
Applied egg-rr99.7%
cancel-sign-sub99.7%
*-commutative99.7%
neg-mul-199.7%
unsub-neg99.7%
sub-neg99.7%
+-commutative99.7%
distribute-lft-in99.7%
sqr-neg99.7%
unpow299.7%
sqr-pow99.7%
*-rgt-identity99.7%
sqr-pow99.7%
sub-neg99.7%
unpow299.7%
Simplified99.7%
Final simplification99.5%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.2))) (* (/ (/ 2.0 (* x x)) x) (/ (- 2.0 x) (- 1.0 x))) (- (* x -2.0) (/ 2.0 x))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.2)) {
tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - 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 <= (-1.0d0)) .or. (.not. (x <= 1.2d0))) then
tmp = ((2.0d0 / (x * x)) / x) * ((2.0d0 - x) / (1.0d0 - 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 <= -1.0) || !(x <= 1.2)) {
tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x));
} else {
tmp = (x * -2.0) - (2.0 / x);
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.2): tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x)) else: tmp = (x * -2.0) - (2.0 / x) return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.2)) tmp = Float64(Float64(Float64(2.0 / Float64(x * x)) / x) * Float64(Float64(2.0 - x) / Float64(1.0 - 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 <= -1.0) || ~((x <= 1.2))) tmp = ((2.0 / (x * x)) / x) * ((2.0 - x) / (1.0 - x)); else tmp = (x * -2.0) - (2.0 / x); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.2]], $MachinePrecision]], N[(N[(N[(2.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * N[(N[(2.0 - x), $MachinePrecision] / N[(1.0 - 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 -1 \lor \neg \left(x \leq 1.2\right):\\
\;\;\;\;\frac{\frac{2}{x \cdot x}}{x} \cdot \frac{2 - x}{1 - x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot -2 - \frac{2}{x}\\
\end{array}
\end{array}
if x < -1 or 1.19999999999999996 < x Initial program 72.6%
Simplified72.6%
frac-2neg72.6%
metadata-eval72.6%
frac-sub17.3%
+-commutative17.3%
distribute-neg-in17.3%
metadata-eval17.3%
sub-neg17.3%
*-commutative17.3%
neg-mul-117.3%
+-commutative17.3%
distribute-neg-in17.3%
metadata-eval17.3%
sub-neg17.3%
Applied egg-rr17.3%
Taylor expanded in x around 0 17.3%
neg-mul-117.3%
unsub-neg17.3%
Simplified17.3%
clear-num20.1%
frac-sub14.8%
*-un-lft-identity14.8%
Applied egg-rr14.8%
/-rgt-identity14.8%
associate-/r*14.8%
associate-/l*15.7%
associate-/r/15.7%
Simplified72.6%
Taylor expanded in x around inf 98.3%
unpow298.3%
Simplified98.3%
if -1 < x < 1.19999999999999996Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification99.1%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ -0.3333333333333333 (* x x)) (- (- x) (/ 2.0 x))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -0.3333333333333333 / (x * x);
} else {
tmp = -x - (2.0 / x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = (-0.3333333333333333d0) / (x * x)
else
tmp = -x - (2.0d0 / x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -0.3333333333333333 / (x * x);
} else {
tmp = -x - (2.0 / x);
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = -0.3333333333333333 / (x * x) else: tmp = -x - (2.0 / x) return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(-0.3333333333333333 / Float64(x * x)); else tmp = Float64(Float64(-x) - Float64(2.0 / x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = -0.3333333333333333 / (x * x); else tmp = -x - (2.0 / x); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(-0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision], N[((-x) - N[(2.0 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-0.3333333333333333}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) - \frac{2}{x}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 72.6%
Simplified72.6%
sub-neg72.6%
flip-+17.2%
Applied egg-rr11.5%
Taylor expanded in x around inf 11.0%
Taylor expanded in x around inf 59.0%
unpow259.0%
Simplified59.0%
if -1 < x < 1Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 99.6%
Taylor expanded in x around 0 99.6%
neg-mul-199.6%
associate-*r/99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification78.5%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ -0.3333333333333333 (* x x)) (/ -2.0 x)))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -0.3333333333333333 / (x * x);
} else {
tmp = -2.0 / x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = (-0.3333333333333333d0) / (x * x)
else
tmp = (-2.0d0) / x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -0.3333333333333333 / (x * x);
} else {
tmp = -2.0 / x;
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = -0.3333333333333333 / (x * x) else: tmp = -2.0 / x return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(-0.3333333333333333 / Float64(x * x)); else tmp = Float64(-2.0 / x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = -0.3333333333333333 / (x * x); else tmp = -2.0 / x; end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(-0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision], N[(-2.0 / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-0.3333333333333333}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{x}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 72.6%
Simplified72.6%
sub-neg72.6%
flip-+17.2%
Applied egg-rr11.5%
Taylor expanded in x around inf 11.0%
Taylor expanded in x around inf 59.0%
unpow259.0%
Simplified59.0%
if -1 < x < 1Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 99.6%
Final simplification78.5%
(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 85.8%
Simplified85.8%
Taylor expanded in x around 0 49.6%
Taylor expanded in x around 0 84.9%
Final simplification84.9%
(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 85.8%
Simplified85.8%
Taylor expanded in x around 0 50.6%
Final simplification50.6%
(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 85.8%
Simplified85.8%
Taylor expanded in x around 0 49.6%
Taylor expanded in x around inf 3.2%
Final simplification3.2%
(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 2023285
(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))))