
(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 15 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 (/ 1.0 (+ x -1.0))) (t_1 (+ (- (/ 1.0 (+ 1.0 x)) (/ 2.0 x)) t_0)))
(if (<= t_1 -4e-8)
(/
(+ (* (+ x x) (/ x 2.0)) (* (+ x -1.0) (- -1.0 x)))
(* (+ x -1.0) (* (+ 1.0 x) (/ x 2.0))))
(if (<= t_1 1e-22)
(* 2.0 (+ (pow x -5.0) (pow x -3.0)))
(fma
(/ 1.0 (+ 1.0 (pow x 3.0)))
(fma x x (- 1.0 x))
(+ t_0 (/ -2.0 x)))))))
double code(double x) {
double t_0 = 1.0 / (x + -1.0);
double t_1 = ((1.0 / (1.0 + x)) - (2.0 / x)) + t_0;
double tmp;
if (t_1 <= -4e-8) {
tmp = (((x + x) * (x / 2.0)) + ((x + -1.0) * (-1.0 - x))) / ((x + -1.0) * ((1.0 + x) * (x / 2.0)));
} else if (t_1 <= 1e-22) {
tmp = 2.0 * (pow(x, -5.0) + pow(x, -3.0));
} else {
tmp = fma((1.0 / (1.0 + pow(x, 3.0))), fma(x, x, (1.0 - x)), (t_0 + (-2.0 / x)));
}
return tmp;
}
function code(x) t_0 = Float64(1.0 / Float64(x + -1.0)) t_1 = Float64(Float64(Float64(1.0 / Float64(1.0 + x)) - Float64(2.0 / x)) + t_0) tmp = 0.0 if (t_1 <= -4e-8) tmp = Float64(Float64(Float64(Float64(x + x) * Float64(x / 2.0)) + Float64(Float64(x + -1.0) * Float64(-1.0 - x))) / Float64(Float64(x + -1.0) * Float64(Float64(1.0 + x) * Float64(x / 2.0)))); elseif (t_1 <= 1e-22) tmp = Float64(2.0 * Float64((x ^ -5.0) + (x ^ -3.0))); else tmp = fma(Float64(1.0 / Float64(1.0 + (x ^ 3.0))), fma(x, x, Float64(1.0 - x)), Float64(t_0 + Float64(-2.0 / x))); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-8], N[(N[(N[(N[(x + x), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + -1.0), $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-22], N[(2.0 * N[(N[Power[x, -5.0], $MachinePrecision] + N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(1.0 + N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x * x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{x + -1}\\
t_1 := \left(\frac{1}{1 + x} - \frac{2}{x}\right) + t_0\\
\mathbf{if}\;t_1 \leq -4 \cdot 10^{-8}:\\
\;\;\;\;\frac{\left(x + x\right) \cdot \frac{x}{2} + \left(x + -1\right) \cdot \left(-1 - x\right)}{\left(x + -1\right) \cdot \left(\left(1 + x\right) \cdot \frac{x}{2}\right)}\\
\mathbf{elif}\;t_1 \leq 10^{-22}:\\
\;\;\;\;2 \cdot \left({x}^{-5} + {x}^{-3}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{1 + {x}^{3}}, \mathsf{fma}\left(x, x, 1 - x\right), t_0 + \frac{-2}{x}\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < -4.0000000000000001e-8Initial program 99.6%
+-commutative99.6%
associate-+r-99.5%
sub-neg99.5%
metadata-eval99.5%
+-commutative99.5%
Applied egg-rr99.5%
frac-add99.5%
clear-num99.5%
frac-sub100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
*-rgt-identity100.0%
+-commutative100.0%
+-commutative100.0%
*-rgt-identity100.0%
+-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
Simplified100.0%
*-un-lft-identity100.0%
associate-+l+100.0%
+-commutative100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
associate-+r+100.0%
metadata-eval100.0%
+-lft-identity100.0%
Simplified100.0%
if -4.0000000000000001e-8 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 1e-22Initial program 73.7%
Taylor expanded in x around inf 99.8%
associate-*r/99.8%
metadata-eval99.8%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
expm1-log1p-u99.8%
expm1-udef73.3%
div-inv73.3%
fma-def73.3%
pow-flip73.3%
metadata-eval73.3%
div-inv73.3%
pow-flip73.3%
metadata-eval73.3%
Applied egg-rr73.3%
expm1-def100.0%
expm1-log1p100.0%
fma-udef100.0%
distribute-lft-out100.0%
Simplified100.0%
if 1e-22 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 99.9%
sub-neg99.9%
associate-+l+99.9%
flip3-+99.9%
associate-/r/99.9%
fma-def100.0%
metadata-eval100.0%
+-commutative100.0%
fma-def100.0%
metadata-eval100.0%
*-rgt-identity100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (+ 1.0 x))) (t_1 (+ (- t_0 (/ 2.0 x)) (/ 1.0 (+ x -1.0)))))
(if (<= t_1 -4e-8)
(/
(+ (* (+ x x) (/ x 2.0)) (* (+ x -1.0) (- -1.0 x)))
(* (+ x -1.0) (* (+ 1.0 x) (/ x 2.0))))
(if (<= t_1 1e-22)
(* 2.0 (+ (pow x -5.0) (pow x -3.0)))
(fma (/ 1.0 (fma x x -1.0)) (+ 1.0 x) (+ t_0 (/ -2.0 x)))))))
double code(double x) {
double t_0 = 1.0 / (1.0 + x);
double t_1 = (t_0 - (2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if (t_1 <= -4e-8) {
tmp = (((x + x) * (x / 2.0)) + ((x + -1.0) * (-1.0 - x))) / ((x + -1.0) * ((1.0 + x) * (x / 2.0)));
} else if (t_1 <= 1e-22) {
tmp = 2.0 * (pow(x, -5.0) + pow(x, -3.0));
} else {
tmp = fma((1.0 / fma(x, x, -1.0)), (1.0 + x), (t_0 + (-2.0 / x)));
}
return tmp;
}
function code(x) t_0 = Float64(1.0 / Float64(1.0 + x)) t_1 = Float64(Float64(t_0 - Float64(2.0 / x)) + Float64(1.0 / Float64(x + -1.0))) tmp = 0.0 if (t_1 <= -4e-8) tmp = Float64(Float64(Float64(Float64(x + x) * Float64(x / 2.0)) + Float64(Float64(x + -1.0) * Float64(-1.0 - x))) / Float64(Float64(x + -1.0) * Float64(Float64(1.0 + x) * Float64(x / 2.0)))); elseif (t_1 <= 1e-22) tmp = Float64(2.0 * Float64((x ^ -5.0) + (x ^ -3.0))); else tmp = fma(Float64(1.0 / fma(x, x, -1.0)), Float64(1.0 + x), Float64(t_0 + Float64(-2.0 / x))); end return tmp end
code[x_] := Block[{t$95$0 = N[(1.0 / N[(1.0 + x), $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[LessEqual[t$95$1, -4e-8], N[(N[(N[(N[(x + x), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + -1.0), $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-22], N[(2.0 * N[(N[Power[x, -5.0], $MachinePrecision] + N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 + x), $MachinePrecision] + N[(t$95$0 + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{1 + x}\\
t_1 := \left(t_0 - \frac{2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{if}\;t_1 \leq -4 \cdot 10^{-8}:\\
\;\;\;\;\frac{\left(x + x\right) \cdot \frac{x}{2} + \left(x + -1\right) \cdot \left(-1 - x\right)}{\left(x + -1\right) \cdot \left(\left(1 + x\right) \cdot \frac{x}{2}\right)}\\
\mathbf{elif}\;t_1 \leq 10^{-22}:\\
\;\;\;\;2 \cdot \left({x}^{-5} + {x}^{-3}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\mathsf{fma}\left(x, x, -1\right)}, 1 + x, t_0 + \frac{-2}{x}\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < -4.0000000000000001e-8Initial program 99.6%
+-commutative99.6%
associate-+r-99.5%
sub-neg99.5%
metadata-eval99.5%
+-commutative99.5%
Applied egg-rr99.5%
frac-add99.5%
clear-num99.5%
frac-sub100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
*-rgt-identity100.0%
+-commutative100.0%
+-commutative100.0%
*-rgt-identity100.0%
+-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
Simplified100.0%
*-un-lft-identity100.0%
associate-+l+100.0%
+-commutative100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
associate-+r+100.0%
metadata-eval100.0%
+-lft-identity100.0%
Simplified100.0%
if -4.0000000000000001e-8 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 1e-22Initial program 73.7%
Taylor expanded in x around inf 99.8%
associate-*r/99.8%
metadata-eval99.8%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
expm1-log1p-u99.8%
expm1-udef73.3%
div-inv73.3%
fma-def73.3%
pow-flip73.3%
metadata-eval73.3%
div-inv73.3%
pow-flip73.3%
metadata-eval73.3%
Applied egg-rr73.3%
expm1-def100.0%
expm1-log1p100.0%
fma-udef100.0%
distribute-lft-out100.0%
Simplified100.0%
if 1e-22 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 99.9%
+-commutative99.9%
flip--99.9%
associate-/r/99.9%
fma-def100.0%
metadata-eval100.0%
fma-neg100.0%
metadata-eval100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-commutative100.0%
+-commutative100.0%
+-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (- (/ 1.0 (+ 1.0 x)) (/ 2.0 x)) (/ 1.0 (+ x -1.0))))
(t_1 (* (+ x -1.0) (- -1.0 x))))
(if (<= t_0 -4e-8)
(/ (+ (* (+ x x) (/ x 2.0)) t_1) (* (+ x -1.0) (* (+ 1.0 x) (/ x 2.0))))
(if (<= t_0 1e-22)
(* 2.0 (+ (pow x -5.0) (pow x -3.0)))
(/
(+ (* x (+ (+ 1.0 x) (+ x -1.0))) (* 2.0 t_1))
(* (+ x -1.0) (+ x (* x x))))))))
double code(double x) {
double t_0 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0));
double t_1 = (x + -1.0) * (-1.0 - x);
double tmp;
if (t_0 <= -4e-8) {
tmp = (((x + x) * (x / 2.0)) + t_1) / ((x + -1.0) * ((1.0 + x) * (x / 2.0)));
} else if (t_0 <= 1e-22) {
tmp = 2.0 * (pow(x, -5.0) + pow(x, -3.0));
} else {
tmp = ((x * ((1.0 + x) + (x + -1.0))) + (2.0 * t_1)) / ((x + -1.0) * (x + (x * 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 / (1.0d0 + x)) - (2.0d0 / x)) + (1.0d0 / (x + (-1.0d0)))
t_1 = (x + (-1.0d0)) * ((-1.0d0) - x)
if (t_0 <= (-4d-8)) then
tmp = (((x + x) * (x / 2.0d0)) + t_1) / ((x + (-1.0d0)) * ((1.0d0 + x) * (x / 2.0d0)))
else if (t_0 <= 1d-22) then
tmp = 2.0d0 * ((x ** (-5.0d0)) + (x ** (-3.0d0)))
else
tmp = ((x * ((1.0d0 + x) + (x + (-1.0d0)))) + (2.0d0 * t_1)) / ((x + (-1.0d0)) * (x + (x * x)))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0));
double t_1 = (x + -1.0) * (-1.0 - x);
double tmp;
if (t_0 <= -4e-8) {
tmp = (((x + x) * (x / 2.0)) + t_1) / ((x + -1.0) * ((1.0 + x) * (x / 2.0)));
} else if (t_0 <= 1e-22) {
tmp = 2.0 * (Math.pow(x, -5.0) + Math.pow(x, -3.0));
} else {
tmp = ((x * ((1.0 + x) + (x + -1.0))) + (2.0 * t_1)) / ((x + -1.0) * (x + (x * x)));
}
return tmp;
}
def code(x): t_0 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0)) t_1 = (x + -1.0) * (-1.0 - x) tmp = 0 if t_0 <= -4e-8: tmp = (((x + x) * (x / 2.0)) + t_1) / ((x + -1.0) * ((1.0 + x) * (x / 2.0))) elif t_0 <= 1e-22: tmp = 2.0 * (math.pow(x, -5.0) + math.pow(x, -3.0)) else: tmp = ((x * ((1.0 + x) + (x + -1.0))) + (2.0 * t_1)) / ((x + -1.0) * (x + (x * x))) return tmp
function code(x) t_0 = Float64(Float64(Float64(1.0 / Float64(1.0 + x)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x + -1.0))) t_1 = Float64(Float64(x + -1.0) * Float64(-1.0 - x)) tmp = 0.0 if (t_0 <= -4e-8) tmp = Float64(Float64(Float64(Float64(x + x) * Float64(x / 2.0)) + t_1) / Float64(Float64(x + -1.0) * Float64(Float64(1.0 + x) * Float64(x / 2.0)))); elseif (t_0 <= 1e-22) tmp = Float64(2.0 * Float64((x ^ -5.0) + (x ^ -3.0))); else tmp = Float64(Float64(Float64(x * Float64(Float64(1.0 + x) + Float64(x + -1.0))) + Float64(2.0 * t_1)) / Float64(Float64(x + -1.0) * Float64(x + Float64(x * x)))); end return tmp end
function tmp_2 = code(x) t_0 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0)); t_1 = (x + -1.0) * (-1.0 - x); tmp = 0.0; if (t_0 <= -4e-8) tmp = (((x + x) * (x / 2.0)) + t_1) / ((x + -1.0) * ((1.0 + x) * (x / 2.0))); elseif (t_0 <= 1e-22) tmp = 2.0 * ((x ^ -5.0) + (x ^ -3.0)); else tmp = ((x * ((1.0 + x) + (x + -1.0))) + (2.0 * t_1)) / ((x + -1.0) * (x + (x * x))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + -1.0), $MachinePrecision] * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4e-8], N[(N[(N[(N[(x + x), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] / N[(N[(x + -1.0), $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-22], N[(2.0 * N[(N[Power[x, -5.0], $MachinePrecision] + N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * N[(N[(1.0 + x), $MachinePrecision] + N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(N[(x + -1.0), $MachinePrecision] * N[(x + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{1}{x + -1}\\
t_1 := \left(x + -1\right) \cdot \left(-1 - x\right)\\
\mathbf{if}\;t_0 \leq -4 \cdot 10^{-8}:\\
\;\;\;\;\frac{\left(x + x\right) \cdot \frac{x}{2} + t_1}{\left(x + -1\right) \cdot \left(\left(1 + x\right) \cdot \frac{x}{2}\right)}\\
\mathbf{elif}\;t_0 \leq 10^{-22}:\\
\;\;\;\;2 \cdot \left({x}^{-5} + {x}^{-3}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(\left(1 + x\right) + \left(x + -1\right)\right) + 2 \cdot t_1}{\left(x + -1\right) \cdot \left(x + x \cdot x\right)}\\
\end{array}
\end{array}
if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < -4.0000000000000001e-8Initial program 99.6%
+-commutative99.6%
associate-+r-99.5%
sub-neg99.5%
metadata-eval99.5%
+-commutative99.5%
Applied egg-rr99.5%
frac-add99.5%
clear-num99.5%
frac-sub100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
*-rgt-identity100.0%
+-commutative100.0%
+-commutative100.0%
*-rgt-identity100.0%
+-commutative100.0%
associate-*l*100.0%
+-commutative100.0%
Simplified100.0%
*-un-lft-identity100.0%
associate-+l+100.0%
+-commutative100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
associate-+r+100.0%
metadata-eval100.0%
+-lft-identity100.0%
Simplified100.0%
if -4.0000000000000001e-8 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 1e-22Initial program 73.7%
Taylor expanded in x around inf 99.8%
associate-*r/99.8%
metadata-eval99.8%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
expm1-log1p-u99.8%
expm1-udef73.3%
div-inv73.3%
fma-def73.3%
pow-flip73.3%
metadata-eval73.3%
div-inv73.3%
pow-flip73.3%
metadata-eval73.3%
Applied egg-rr73.3%
expm1-def100.0%
expm1-log1p100.0%
fma-udef100.0%
distribute-lft-out100.0%
Simplified100.0%
if 1e-22 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 99.9%
+-commutative99.9%
associate-+r-99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
Applied egg-rr99.9%
frac-add99.9%
frac-sub100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
*-commutative100.0%
*-rgt-identity100.0%
+-commutative100.0%
+-commutative100.0%
associate-*l*100.0%
/-rgt-identity100.0%
associate-*l/100.0%
associate-*l*100.0%
*-commutative100.0%
associate-*r/100.0%
/-rgt-identity100.0%
+-commutative100.0%
associate-*l*99.9%
+-commutative99.9%
distribute-rgt1-in99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x)
:precision binary64
(if (<= x -20000000000.0)
(/ 2.0 (pow x 3.0))
(if (<= x 100000000.0)
(/
(+ (* (+ x x) (/ x 2.0)) (* (+ x -1.0) (- -1.0 x)))
(* (+ x -1.0) (* (+ 1.0 x) (/ x 2.0))))
(/ (- (/ 2.0 x) (/ 4.0 (* x x))) (* x (+ x -2.0))))))
double code(double x) {
double tmp;
if (x <= -20000000000.0) {
tmp = 2.0 / pow(x, 3.0);
} else if (x <= 100000000.0) {
tmp = (((x + x) * (x / 2.0)) + ((x + -1.0) * (-1.0 - x))) / ((x + -1.0) * ((1.0 + x) * (x / 2.0)));
} else {
tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * (x + -2.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-20000000000.0d0)) then
tmp = 2.0d0 / (x ** 3.0d0)
else if (x <= 100000000.0d0) then
tmp = (((x + x) * (x / 2.0d0)) + ((x + (-1.0d0)) * ((-1.0d0) - x))) / ((x + (-1.0d0)) * ((1.0d0 + x) * (x / 2.0d0)))
else
tmp = ((2.0d0 / x) - (4.0d0 / (x * x))) / (x * (x + (-2.0d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -20000000000.0) {
tmp = 2.0 / Math.pow(x, 3.0);
} else if (x <= 100000000.0) {
tmp = (((x + x) * (x / 2.0)) + ((x + -1.0) * (-1.0 - x))) / ((x + -1.0) * ((1.0 + x) * (x / 2.0)));
} else {
tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * (x + -2.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= -20000000000.0: tmp = 2.0 / math.pow(x, 3.0) elif x <= 100000000.0: tmp = (((x + x) * (x / 2.0)) + ((x + -1.0) * (-1.0 - x))) / ((x + -1.0) * ((1.0 + x) * (x / 2.0))) else: tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * (x + -2.0)) return tmp
function code(x) tmp = 0.0 if (x <= -20000000000.0) tmp = Float64(2.0 / (x ^ 3.0)); elseif (x <= 100000000.0) tmp = Float64(Float64(Float64(Float64(x + x) * Float64(x / 2.0)) + Float64(Float64(x + -1.0) * Float64(-1.0 - x))) / Float64(Float64(x + -1.0) * Float64(Float64(1.0 + x) * Float64(x / 2.0)))); else tmp = Float64(Float64(Float64(2.0 / x) - Float64(4.0 / Float64(x * x))) / Float64(x * Float64(x + -2.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -20000000000.0) tmp = 2.0 / (x ^ 3.0); elseif (x <= 100000000.0) tmp = (((x + x) * (x / 2.0)) + ((x + -1.0) * (-1.0 - x))) / ((x + -1.0) * ((1.0 + x) * (x / 2.0))); else tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * (x + -2.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -20000000000.0], N[(2.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 100000000.0], N[(N[(N[(N[(x + x), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + -1.0), $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 / x), $MachinePrecision] - N[(4.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * N[(x + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -20000000000:\\
\;\;\;\;\frac{2}{{x}^{3}}\\
\mathbf{elif}\;x \leq 100000000:\\
\;\;\;\;\frac{\left(x + x\right) \cdot \frac{x}{2} + \left(x + -1\right) \cdot \left(-1 - x\right)}{\left(x + -1\right) \cdot \left(\left(1 + x\right) \cdot \frac{x}{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{x} - \frac{4}{x \cdot x}}{x \cdot \left(x + -2\right)}\\
\end{array}
\end{array}
if x < -2e10Initial program 73.3%
Taylor expanded in x around inf 99.9%
if -2e10 < x < 1e8Initial program 98.8%
+-commutative98.8%
associate-+r-98.7%
sub-neg98.7%
metadata-eval98.7%
+-commutative98.7%
Applied egg-rr98.7%
frac-add98.7%
clear-num98.7%
frac-sub100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
*-rgt-identity100.0%
+-commutative100.0%
+-commutative100.0%
*-rgt-identity100.0%
+-commutative100.0%
associate-*l*99.9%
+-commutative99.9%
Simplified99.9%
*-un-lft-identity99.9%
associate-+l+99.9%
+-commutative99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
associate-+r+99.9%
metadata-eval99.9%
+-lft-identity99.9%
Simplified99.9%
if 1e8 < x Initial program 75.0%
frac-sub16.8%
clear-num20.9%
*-commutative20.9%
+-commutative20.9%
/-rgt-identity20.9%
*-un-lft-identity20.9%
/-rgt-identity20.9%
+-commutative20.9%
Applied egg-rr20.9%
+-commutative20.9%
frac-2neg20.9%
metadata-eval20.9%
frac-add17.0%
Applied egg-rr72.3%
distribute-rgt-neg-out72.3%
distribute-lft-neg-out72.3%
Simplified72.3%
Taylor expanded in x around inf 99.8%
associate-*r/99.8%
metadata-eval99.8%
associate-*r/99.8%
metadata-eval99.8%
unpow299.8%
Simplified99.8%
Taylor expanded in x around inf 99.9%
unpow299.9%
distribute-rgt-out99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (- (/ 1.0 (+ 1.0 x)) (/ 2.0 x)) (/ 1.0 (+ x -1.0)))))
(if (or (<= t_0 -1e-16) (not (<= t_0 1e-22)))
t_0
(/ (- (/ 2.0 x) (/ 4.0 (* x x))) (* x x)))))
double code(double x) {
double t_0 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if ((t_0 <= -1e-16) || !(t_0 <= 1e-22)) {
tmp = t_0;
} else {
tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 / (1.0d0 + x)) - (2.0d0 / x)) + (1.0d0 / (x + (-1.0d0)))
if ((t_0 <= (-1d-16)) .or. (.not. (t_0 <= 1d-22))) then
tmp = t_0
else
tmp = ((2.0d0 / x) - (4.0d0 / (x * x))) / (x * x)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if ((t_0 <= -1e-16) || !(t_0 <= 1e-22)) {
tmp = t_0;
} else {
tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * x);
}
return tmp;
}
def code(x): t_0 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0)) tmp = 0 if (t_0 <= -1e-16) or not (t_0 <= 1e-22): tmp = t_0 else: tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * x) return tmp
function code(x) t_0 = Float64(Float64(Float64(1.0 / Float64(1.0 + x)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x + -1.0))) tmp = 0.0 if ((t_0 <= -1e-16) || !(t_0 <= 1e-22)) tmp = t_0; else tmp = Float64(Float64(Float64(2.0 / x) - Float64(4.0 / Float64(x * x))) / Float64(x * x)); end return tmp end
function tmp_2 = code(x) t_0 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0)); tmp = 0.0; if ((t_0 <= -1e-16) || ~((t_0 <= 1e-22))) tmp = t_0; else tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * x); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -1e-16], N[Not[LessEqual[t$95$0, 1e-22]], $MachinePrecision]], t$95$0, N[(N[(N[(2.0 / x), $MachinePrecision] - N[(4.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{-16} \lor \neg \left(t_0 \leq 10^{-22}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{x} - \frac{4}{x \cdot x}}{x \cdot x}\\
\end{array}
\end{array}
if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < -9.9999999999999998e-17 or 1e-22 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 99.4%
if -9.9999999999999998e-17 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 1e-22Initial program 73.9%
frac-sub17.8%
clear-num20.9%
*-commutative20.9%
+-commutative20.9%
/-rgt-identity20.9%
*-un-lft-identity20.9%
/-rgt-identity20.9%
+-commutative20.9%
Applied egg-rr20.9%
+-commutative20.9%
frac-2neg20.9%
metadata-eval20.9%
frac-add17.2%
Applied egg-rr70.8%
distribute-rgt-neg-out70.8%
distribute-lft-neg-out70.8%
Simplified70.8%
Taylor expanded in x around inf 99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*r/99.7%
metadata-eval99.7%
unpow299.7%
Simplified99.7%
Taylor expanded in x around inf 99.2%
unpow299.2%
Simplified99.2%
Final simplification99.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (- (/ 1.0 (+ 1.0 x)) (/ 2.0 x)) (/ 1.0 (+ x -1.0)))))
(if (or (<= t_0 -4e-8) (not (<= t_0 1e-22)))
t_0
(/ (- (/ 2.0 x) (/ 4.0 (* x x))) (* x (+ x -2.0))))))
double code(double x) {
double t_0 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if ((t_0 <= -4e-8) || !(t_0 <= 1e-22)) {
tmp = t_0;
} else {
tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * (x + -2.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 / (1.0d0 + x)) - (2.0d0 / x)) + (1.0d0 / (x + (-1.0d0)))
if ((t_0 <= (-4d-8)) .or. (.not. (t_0 <= 1d-22))) then
tmp = t_0
else
tmp = ((2.0d0 / x) - (4.0d0 / (x * x))) / (x * (x + (-2.0d0)))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0));
double tmp;
if ((t_0 <= -4e-8) || !(t_0 <= 1e-22)) {
tmp = t_0;
} else {
tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * (x + -2.0));
}
return tmp;
}
def code(x): t_0 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0)) tmp = 0 if (t_0 <= -4e-8) or not (t_0 <= 1e-22): tmp = t_0 else: tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * (x + -2.0)) return tmp
function code(x) t_0 = Float64(Float64(Float64(1.0 / Float64(1.0 + x)) - Float64(2.0 / x)) + Float64(1.0 / Float64(x + -1.0))) tmp = 0.0 if ((t_0 <= -4e-8) || !(t_0 <= 1e-22)) tmp = t_0; else tmp = Float64(Float64(Float64(2.0 / x) - Float64(4.0 / Float64(x * x))) / Float64(x * Float64(x + -2.0))); end return tmp end
function tmp_2 = code(x) t_0 = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / (x + -1.0)); tmp = 0.0; if ((t_0 <= -4e-8) || ~((t_0 <= 1e-22))) tmp = t_0; else tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * (x + -2.0)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e-8], N[Not[LessEqual[t$95$0, 1e-22]], $MachinePrecision]], t$95$0, N[(N[(N[(2.0 / x), $MachinePrecision] - N[(4.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * N[(x + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{1}{x + -1}\\
\mathbf{if}\;t_0 \leq -4 \cdot 10^{-8} \lor \neg \left(t_0 \leq 10^{-22}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{x} - \frac{4}{x \cdot x}}{x \cdot \left(x + -2\right)}\\
\end{array}
\end{array}
if (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < -4.0000000000000001e-8 or 1e-22 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) Initial program 99.8%
if -4.0000000000000001e-8 < (+.f64 (-.f64 (/.f64 1 (+.f64 x 1)) (/.f64 2 x)) (/.f64 1 (-.f64 x 1))) < 1e-22Initial program 73.7%
frac-sub18.0%
clear-num21.1%
*-commutative21.1%
+-commutative21.1%
/-rgt-identity21.1%
*-un-lft-identity21.1%
/-rgt-identity21.1%
+-commutative21.1%
Applied egg-rr21.1%
+-commutative21.1%
frac-2neg21.1%
metadata-eval21.1%
frac-add17.5%
Applied egg-rr70.7%
distribute-rgt-neg-out70.7%
distribute-lft-neg-out70.7%
Simplified70.7%
Taylor expanded in x around inf 99.5%
associate-*r/99.5%
metadata-eval99.5%
associate-*r/99.5%
metadata-eval99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in x around inf 99.6%
unpow299.6%
distribute-rgt-out99.6%
Simplified99.6%
Final simplification99.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (- (/ 2.0 x) (/ 4.0 (* x x)))))
(if (<= x -95000000.0)
(/ t_0 (* x x))
(if (<= x 100000000.0)
(/
(+ (* (+ x x) (/ x 2.0)) (* (+ x -1.0) (- -1.0 x)))
(* (+ x -1.0) (* (+ 1.0 x) (/ x 2.0))))
(/ t_0 (* x (+ x -2.0)))))))
double code(double x) {
double t_0 = (2.0 / x) - (4.0 / (x * x));
double tmp;
if (x <= -95000000.0) {
tmp = t_0 / (x * x);
} else if (x <= 100000000.0) {
tmp = (((x + x) * (x / 2.0)) + ((x + -1.0) * (-1.0 - x))) / ((x + -1.0) * ((1.0 + x) * (x / 2.0)));
} else {
tmp = t_0 / (x * (x + -2.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (2.0d0 / x) - (4.0d0 / (x * x))
if (x <= (-95000000.0d0)) then
tmp = t_0 / (x * x)
else if (x <= 100000000.0d0) then
tmp = (((x + x) * (x / 2.0d0)) + ((x + (-1.0d0)) * ((-1.0d0) - x))) / ((x + (-1.0d0)) * ((1.0d0 + x) * (x / 2.0d0)))
else
tmp = t_0 / (x * (x + (-2.0d0)))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (2.0 / x) - (4.0 / (x * x));
double tmp;
if (x <= -95000000.0) {
tmp = t_0 / (x * x);
} else if (x <= 100000000.0) {
tmp = (((x + x) * (x / 2.0)) + ((x + -1.0) * (-1.0 - x))) / ((x + -1.0) * ((1.0 + x) * (x / 2.0)));
} else {
tmp = t_0 / (x * (x + -2.0));
}
return tmp;
}
def code(x): t_0 = (2.0 / x) - (4.0 / (x * x)) tmp = 0 if x <= -95000000.0: tmp = t_0 / (x * x) elif x <= 100000000.0: tmp = (((x + x) * (x / 2.0)) + ((x + -1.0) * (-1.0 - x))) / ((x + -1.0) * ((1.0 + x) * (x / 2.0))) else: tmp = t_0 / (x * (x + -2.0)) return tmp
function code(x) t_0 = Float64(Float64(2.0 / x) - Float64(4.0 / Float64(x * x))) tmp = 0.0 if (x <= -95000000.0) tmp = Float64(t_0 / Float64(x * x)); elseif (x <= 100000000.0) tmp = Float64(Float64(Float64(Float64(x + x) * Float64(x / 2.0)) + Float64(Float64(x + -1.0) * Float64(-1.0 - x))) / Float64(Float64(x + -1.0) * Float64(Float64(1.0 + x) * Float64(x / 2.0)))); else tmp = Float64(t_0 / Float64(x * Float64(x + -2.0))); end return tmp end
function tmp_2 = code(x) t_0 = (2.0 / x) - (4.0 / (x * x)); tmp = 0.0; if (x <= -95000000.0) tmp = t_0 / (x * x); elseif (x <= 100000000.0) tmp = (((x + x) * (x / 2.0)) + ((x + -1.0) * (-1.0 - x))) / ((x + -1.0) * ((1.0 + x) * (x / 2.0))); else tmp = t_0 / (x * (x + -2.0)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(2.0 / x), $MachinePrecision] - N[(4.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -95000000.0], N[(t$95$0 / N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 100000000.0], N[(N[(N[(N[(x + x), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + -1.0), $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(x * N[(x + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{x} - \frac{4}{x \cdot x}\\
\mathbf{if}\;x \leq -95000000:\\
\;\;\;\;\frac{t_0}{x \cdot x}\\
\mathbf{elif}\;x \leq 100000000:\\
\;\;\;\;\frac{\left(x + x\right) \cdot \frac{x}{2} + \left(x + -1\right) \cdot \left(-1 - x\right)}{\left(x + -1\right) \cdot \left(\left(1 + x\right) \cdot \frac{x}{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{x \cdot \left(x + -2\right)}\\
\end{array}
\end{array}
if x < -9.5e7Initial program 73.3%
frac-sub18.9%
clear-num20.7%
*-commutative20.7%
+-commutative20.7%
/-rgt-identity20.7%
*-un-lft-identity20.7%
/-rgt-identity20.7%
+-commutative20.7%
Applied egg-rr20.7%
+-commutative20.7%
frac-2neg20.7%
metadata-eval20.7%
frac-add17.4%
Applied egg-rr69.9%
distribute-rgt-neg-out69.9%
distribute-lft-neg-out69.9%
Simplified69.9%
Taylor expanded in x around inf 99.7%
associate-*r/99.7%
metadata-eval99.7%
associate-*r/99.7%
metadata-eval99.7%
unpow299.7%
Simplified99.7%
Taylor expanded in x around inf 99.8%
unpow299.8%
Simplified99.8%
if -9.5e7 < x < 1e8Initial program 98.8%
+-commutative98.8%
associate-+r-98.7%
sub-neg98.7%
metadata-eval98.7%
+-commutative98.7%
Applied egg-rr98.7%
frac-add98.7%
clear-num98.7%
frac-sub100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
*-rgt-identity100.0%
+-commutative100.0%
+-commutative100.0%
*-rgt-identity100.0%
+-commutative100.0%
associate-*l*99.9%
+-commutative99.9%
Simplified99.9%
*-un-lft-identity99.9%
associate-+l+99.9%
+-commutative99.9%
Applied egg-rr99.9%
*-lft-identity99.9%
associate-+r+99.9%
metadata-eval99.9%
+-lft-identity99.9%
Simplified99.9%
if 1e8 < x Initial program 75.0%
frac-sub16.8%
clear-num20.9%
*-commutative20.9%
+-commutative20.9%
/-rgt-identity20.9%
*-un-lft-identity20.9%
/-rgt-identity20.9%
+-commutative20.9%
Applied egg-rr20.9%
+-commutative20.9%
frac-2neg20.9%
metadata-eval20.9%
frac-add17.0%
Applied egg-rr72.3%
distribute-rgt-neg-out72.3%
distribute-lft-neg-out72.3%
Simplified72.3%
Taylor expanded in x around inf 99.8%
associate-*r/99.8%
metadata-eval99.8%
associate-*r/99.8%
metadata-eval99.8%
unpow299.8%
Simplified99.8%
Taylor expanded in x around inf 99.9%
unpow299.9%
distribute-rgt-out99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ (- (/ 2.0 x) (/ 4.0 (* x x))) (* x x)) (- (* x -2.0) (/ 2.0 x))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = ((2.0 / x) - (4.0 / (x * x))) / (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 <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = ((2.0d0 / x) - (4.0d0 / (x * x))) / (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 <= -1.0) || !(x <= 1.0)) {
tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * x);
} else {
tmp = (x * -2.0) - (2.0 / x);
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * x) else: tmp = (x * -2.0) - (2.0 / x) return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(Float64(Float64(2.0 / x) - Float64(4.0 / Float64(x * x))) / 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 <= -1.0) || ~((x <= 1.0))) tmp = ((2.0 / x) - (4.0 / (x * x))) / (x * 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.0]], $MachinePrecision]], N[(N[(N[(2.0 / x), $MachinePrecision] - N[(4.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * x), $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\right):\\
\;\;\;\;\frac{\frac{2}{x} - \frac{4}{x \cdot x}}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot -2 - \frac{2}{x}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 73.9%
frac-sub19.1%
clear-num22.1%
*-commutative22.1%
+-commutative22.1%
/-rgt-identity22.1%
*-un-lft-identity22.1%
/-rgt-identity22.1%
+-commutative22.1%
Applied egg-rr22.1%
+-commutative22.1%
frac-2neg22.1%
metadata-eval22.1%
frac-add18.5%
Applied egg-rr70.9%
distribute-rgt-neg-out70.9%
distribute-lft-neg-out70.9%
Simplified70.9%
Taylor expanded in x around inf 98.5%
associate-*r/98.5%
metadata-eval98.5%
associate-*r/98.5%
metadata-eval98.5%
unpow298.5%
Simplified98.5%
Taylor expanded in x around inf 97.6%
unpow297.6%
Simplified97.6%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
Final simplification98.3%
(FPCore (x)
:precision binary64
(if (<= x -0.65)
(+ (- (/ 1.0 (+ 1.0 x)) (/ 2.0 x)) (/ 1.0 x))
(if (<= x 0.65)
(- (* x -2.0) (/ 2.0 x))
(+ (/ 1.0 (+ x -1.0)) (/ -1.0 x)))))
double code(double x) {
double tmp;
if (x <= -0.65) {
tmp = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / x);
} else if (x <= 0.65) {
tmp = (x * -2.0) - (2.0 / x);
} else {
tmp = (1.0 / (x + -1.0)) + (-1.0 / x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-0.65d0)) then
tmp = ((1.0d0 / (1.0d0 + x)) - (2.0d0 / x)) + (1.0d0 / x)
else if (x <= 0.65d0) then
tmp = (x * (-2.0d0)) - (2.0d0 / x)
else
tmp = (1.0d0 / (x + (-1.0d0))) + ((-1.0d0) / x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -0.65) {
tmp = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / x);
} else if (x <= 0.65) {
tmp = (x * -2.0) - (2.0 / x);
} else {
tmp = (1.0 / (x + -1.0)) + (-1.0 / x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -0.65: tmp = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / x) elif x <= 0.65: tmp = (x * -2.0) - (2.0 / x) else: tmp = (1.0 / (x + -1.0)) + (-1.0 / x) return tmp
function code(x) tmp = 0.0 if (x <= -0.65) tmp = Float64(Float64(Float64(1.0 / Float64(1.0 + x)) - Float64(2.0 / x)) + Float64(1.0 / x)); elseif (x <= 0.65) tmp = Float64(Float64(x * -2.0) - Float64(2.0 / x)); else tmp = Float64(Float64(1.0 / Float64(x + -1.0)) + Float64(-1.0 / x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -0.65) tmp = ((1.0 / (1.0 + x)) - (2.0 / x)) + (1.0 / x); elseif (x <= 0.65) tmp = (x * -2.0) - (2.0 / x); else tmp = (1.0 / (x + -1.0)) + (-1.0 / x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -0.65], N[(N[(N[(1.0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.65], N[(N[(x * -2.0), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.65:\\
\;\;\;\;\left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{1}{x}\\
\mathbf{elif}\;x \leq 0.65:\\
\;\;\;\;x \cdot -2 - \frac{2}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + -1} + \frac{-1}{x}\\
\end{array}
\end{array}
if x < -0.650000000000000022Initial program 73.0%
Taylor expanded in x around inf 71.3%
if -0.650000000000000022 < x < 0.650000000000000022Initial program 100.0%
Taylor expanded in x around 0 99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
if 0.650000000000000022 < x Initial program 74.6%
Taylor expanded in x around inf 73.5%
Final simplification85.5%
(FPCore (x)
:precision binary64
(if (<= x -1.0)
(- (/ 2.0 x) (/ 2.0 x))
(if (<= x 0.65)
(- (* x -2.0) (/ 2.0 x))
(+ (/ 1.0 (+ x -1.0)) (/ -1.0 x)))))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = (2.0 / x) - (2.0 / x);
} else if (x <= 0.65) {
tmp = (x * -2.0) - (2.0 / x);
} else {
tmp = (1.0 / (x + -1.0)) + (-1.0 / x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = (2.0d0 / x) - (2.0d0 / x)
else if (x <= 0.65d0) then
tmp = (x * (-2.0d0)) - (2.0d0 / x)
else
tmp = (1.0d0 / (x + (-1.0d0))) + ((-1.0d0) / x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = (2.0 / x) - (2.0 / x);
} else if (x <= 0.65) {
tmp = (x * -2.0) - (2.0 / x);
} else {
tmp = (1.0 / (x + -1.0)) + (-1.0 / x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = (2.0 / x) - (2.0 / x) elif x <= 0.65: tmp = (x * -2.0) - (2.0 / x) else: tmp = (1.0 / (x + -1.0)) + (-1.0 / x) return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(2.0 / x) - Float64(2.0 / x)); elseif (x <= 0.65) tmp = Float64(Float64(x * -2.0) - Float64(2.0 / x)); else tmp = Float64(Float64(1.0 / Float64(x + -1.0)) + Float64(-1.0 / x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.0) tmp = (2.0 / x) - (2.0 / x); elseif (x <= 0.65) tmp = (x * -2.0) - (2.0 / x); else tmp = (1.0 / (x + -1.0)) + (-1.0 / x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.0], N[(N[(2.0 / x), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.65], N[(N[(x * -2.0), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{2}{x} - \frac{2}{x}\\
\mathbf{elif}\;x \leq 0.65:\\
\;\;\;\;x \cdot -2 - \frac{2}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + -1} + \frac{-1}{x}\\
\end{array}
\end{array}
if x < -1Initial program 73.0%
+-commutative73.0%
associate-+r-72.9%
sub-neg72.9%
metadata-eval72.9%
+-commutative72.9%
Applied egg-rr72.9%
Taylor expanded in x around inf 71.0%
if -1 < x < 0.650000000000000022Initial program 100.0%
Taylor expanded in x around 0 99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
if 0.650000000000000022 < x Initial program 74.6%
Taylor expanded in x around inf 73.5%
Final simplification85.5%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (- (/ 2.0 x) (/ 2.0 x)) (- (* x -2.0) (/ 2.0 x))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = (2.0 / x) - (2.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.0d0))) then
tmp = (2.0d0 / x) - (2.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.0)) {
tmp = (2.0 / x) - (2.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.0): tmp = (2.0 / x) - (2.0 / x) else: tmp = (x * -2.0) - (2.0 / x) return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(Float64(2.0 / x) - Float64(2.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.0))) tmp = (2.0 / x) - (2.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.0]], $MachinePrecision]], N[(N[(2.0 / x), $MachinePrecision] - N[(2.0 / x), $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\right):\\
\;\;\;\;\frac{2}{x} - \frac{2}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot -2 - \frac{2}{x}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 73.9%
+-commutative73.9%
associate-+r-73.8%
sub-neg73.8%
metadata-eval73.8%
+-commutative73.8%
Applied egg-rr73.8%
Taylor expanded in x around inf 72.1%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
Final simplification85.3%
(FPCore (x) :precision binary64 (if (<= x -1.0) (/ -1.0 (* x x)) (if (<= x 1.0) (- (* x -2.0) (/ 2.0 x)) (/ 1.0 (* x x)))))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = -1.0 / (x * x);
} else if (x <= 1.0) {
tmp = (x * -2.0) - (2.0 / x);
} else {
tmp = 1.0 / (x * x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = (-1.0d0) / (x * x)
else if (x <= 1.0d0) then
tmp = (x * (-2.0d0)) - (2.0d0 / x)
else
tmp = 1.0d0 / (x * x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = -1.0 / (x * x);
} else if (x <= 1.0) {
tmp = (x * -2.0) - (2.0 / x);
} else {
tmp = 1.0 / (x * x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = -1.0 / (x * x) elif x <= 1.0: tmp = (x * -2.0) - (2.0 / x) else: tmp = 1.0 / (x * x) return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = Float64(-1.0 / Float64(x * x)); elseif (x <= 1.0) tmp = Float64(Float64(x * -2.0) - Float64(2.0 / x)); else tmp = Float64(1.0 / Float64(x * x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.0) tmp = -1.0 / (x * x); elseif (x <= 1.0) tmp = (x * -2.0) - (2.0 / x); else tmp = 1.0 / (x * x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.0], N[(-1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(x * -2.0), $MachinePrecision] - N[(2.0 / x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{-1}{x \cdot x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;x \cdot -2 - \frac{2}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot x}\\
\end{array}
\end{array}
if x < -1Initial program 73.0%
+-commutative73.0%
associate-+r-72.9%
sub-neg72.9%
metadata-eval72.9%
+-commutative72.9%
Applied egg-rr72.9%
Taylor expanded in x around inf 71.3%
Taylor expanded in x around inf 53.2%
unpow253.2%
Simplified53.2%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
if 1 < x Initial program 74.6%
frac-sub18.0%
clear-num22.1%
*-commutative22.1%
+-commutative22.1%
/-rgt-identity22.1%
*-un-lft-identity22.1%
/-rgt-identity22.1%
+-commutative22.1%
Applied egg-rr22.1%
+-commutative22.1%
frac-2neg22.1%
metadata-eval22.1%
frac-add18.2%
Applied egg-rr71.9%
distribute-rgt-neg-out71.9%
distribute-lft-neg-out71.9%
Simplified71.9%
Taylor expanded in x around 0 59.9%
Taylor expanded in x around inf 59.9%
unpow259.9%
Simplified59.9%
Final simplification77.6%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ -1.0 (* x x)) (/ -2.0 x)))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -1.0 / (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 = (-1.0d0) / (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 = -1.0 / (x * x);
} else {
tmp = -2.0 / x;
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = -1.0 / (x * x) else: tmp = -2.0 / x return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(-1.0 / 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 = -1.0 / (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[(-1.0 / 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{-1}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{x}\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 73.9%
+-commutative73.9%
associate-+r-73.8%
sub-neg73.8%
metadata-eval73.8%
+-commutative73.8%
Applied egg-rr73.8%
Taylor expanded in x around inf 72.2%
Taylor expanded in x around inf 56.1%
unpow256.1%
Simplified56.1%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 98.2%
Final simplification76.8%
(FPCore (x) :precision binary64 (if (<= x -1.0) (/ -1.0 (* x x)) (if (<= x 1.0) (/ -2.0 x) (/ 1.0 (* x x)))))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = -1.0 / (x * x);
} else if (x <= 1.0) {
tmp = -2.0 / x;
} else {
tmp = 1.0 / (x * x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = (-1.0d0) / (x * x)
else if (x <= 1.0d0) then
tmp = (-2.0d0) / x
else
tmp = 1.0d0 / (x * x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = -1.0 / (x * x);
} else if (x <= 1.0) {
tmp = -2.0 / x;
} else {
tmp = 1.0 / (x * x);
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = -1.0 / (x * x) elif x <= 1.0: tmp = -2.0 / x else: tmp = 1.0 / (x * x) return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = Float64(-1.0 / Float64(x * x)); elseif (x <= 1.0) tmp = Float64(-2.0 / x); else tmp = Float64(1.0 / Float64(x * x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.0) tmp = -1.0 / (x * x); elseif (x <= 1.0) tmp = -2.0 / x; else tmp = 1.0 / (x * x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.0], N[(-1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(-2.0 / x), $MachinePrecision], N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{-1}{x \cdot x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{-2}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot x}\\
\end{array}
\end{array}
if x < -1Initial program 73.0%
+-commutative73.0%
associate-+r-72.9%
sub-neg72.9%
metadata-eval72.9%
+-commutative72.9%
Applied egg-rr72.9%
Taylor expanded in x around inf 71.3%
Taylor expanded in x around inf 53.2%
unpow253.2%
Simplified53.2%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 98.2%
if 1 < x Initial program 74.6%
frac-sub18.0%
clear-num22.1%
*-commutative22.1%
+-commutative22.1%
/-rgt-identity22.1%
*-un-lft-identity22.1%
/-rgt-identity22.1%
+-commutative22.1%
Applied egg-rr22.1%
+-commutative22.1%
frac-2neg22.1%
metadata-eval22.1%
frac-add18.2%
Applied egg-rr71.9%
distribute-rgt-neg-out71.9%
distribute-lft-neg-out71.9%
Simplified71.9%
Taylor expanded in x around 0 59.9%
Taylor expanded in x around inf 59.9%
unpow259.9%
Simplified59.9%
Final simplification77.2%
(FPCore (x) :precision binary64 (/ -2.0 x))
double code(double x) {
return -2.0 / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-2.0d0) / x
end function
public static double code(double x) {
return -2.0 / x;
}
def code(x): return -2.0 / x
function code(x) return Float64(-2.0 / x) end
function tmp = code(x) tmp = -2.0 / x; end
code[x_] := N[(-2.0 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{-2}{x}
\end{array}
Initial program 86.7%
Taylor expanded in x around 0 50.9%
Final simplification50.9%
(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 2023255
(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))))