Big Oh Approximation of a Function

121 Views Asked by At

I am learnign the big Oh notation and still very weak at approximating a function by the notation. In this particular example, I am looking for verification of my solution about approximating a function using the big Oh notation. Could you please let me know if the way I did is correct? Furtheremore, if there are any intermediate steps that are not 'refined', please help me correct them. Finally, please feel free to let me know how my solution can be improved.

Let: $$ f(x) = \frac{1+x-e^x}{x^2} $$ Then $\lim_{x \to 0}f(x) = -\frac{1}{2}$.

Using Taylor approximation for $e^x$, then: $$ f(x)=\frac{\frac{-x^2}{2!}-\frac{x^3}{3!}-\frac{x^4}{4!}...}{x^2}=\frac{-1}{2!}-\frac{x}{3!}-\frac{x^2}{4!}... $$ So, $$ |f(x)-\frac{1}{2}|=|-\frac{x}{3!}-\frac{x^2}{4!}-...-\frac{1}{4}|\leq |\frac{x}{3!}|+|\frac{x^2}{4!}|+...+\frac{1}{4}\leq|\frac{x}{3!}|+|\frac{x}{3!}|+...+\frac{1}{4}=O(x)+O(x)+O(x)+...+O(x)=O(x) \text{, as x $\to 0$} $$ Therefore, $$ f(x)=\frac{1+x-e^x}{x^2}=-\frac{1}{2} + O(x) $$

1

There are 1 best solutions below

0
On

The solution is partially incorrect, and reveals a fundamental error in the handling of $O$-functions. That's why this post is more about showing that error and less about the actual correct argument (which can be found at the end).

The problem occurs when you estimate $|f(x)-{1\over 2}|$ (which should be $|f(x)+{1\over 2}|$, btw., plus there are some more clerical errors in that line).

You correctly get

$$\left|f(x)+{1\over 2}\right| \le \left|\frac{x}{3!}\right| + \left|\frac{x^2}{4!}\right| + \left|\frac{x^3}{5!}\right|+\ldots$$

And you are right that $\left|\frac{x}{3!}\right| \in O(x)$, $\left|\frac{x^2}{4!}\right| \in O(x)$, a.s.o.

But when you are summing up an infinite number of $O(x)$-functions, the sum is no longer guaranteed to be $O(x)$!

To see an example, consider first the following function $g(x)$ defined for $x \in (0,1)$:

$$g(x)=\frac1n, \text{ where $n$ is the unique integer satisfying } \frac1{n+1} \le x < \frac1n$$

It's easy to see that $g(x) < 2x$, because $\forall n \ge 1: \frac2{n+1} \ge \frac1n$.

Now consider the following functions $f_k(x)$, $k\ge 1$ defined for $x \in (0,1)$:

$$f_k(x)= \begin{cases} g(x) & \text{, if } g(x) \le \frac1k\\ 0 & \text{, otherwise.} \end{cases} $$

Clearly $f_k(x) \in O(x)$, as $\forall x: f_k (x) < 2x$.

But if you sum up those functions,

$$f(x)=\sum_{k=1}^\infty f_k(x)$$

you'll find that $\forall x:f(x) = 1$. That's because if $g(x)=\frac1n$, we have $f_k(x)=\frac1n$ for $1 \le k \le n$ and $f_k(x)=0$ for $k > n$. So the infinite sum is $n$ terms $\frac1n$ and otherwise $0$.

So clearly $f(x) \notin O(x).$

When you go to infinite or an unlimited number of summands, each part can be 'small' ($O(x)$), but because you get as many summands as you want, these samll contributions can become 'big' (not $O(x)$).

Another way to see this is looking at the definition for $O(x)$. $f(x) \in O(x)$ means there exists some number $M$ such that

$$|f(x)| \le M|x|$$

for $|x|$ 'small enough', that means $|x| < m$ for some $m > 0$.

If you have another function $g(x) \in O(x)$ with $|g(x)| \le N|x|$ for $|x| < n, (n > 0)$ , you get that

$$|f(x)+g(x)| \le |f(x)|+|g(x)| \le M|x| + N|x| = (M+N)|x|$$

for all $x$ that fit both $f$'s and $g$'s definition of 'small enough', that means $|x| < \min(m,n)$.

That's (roughly) the usual proof that the sum of 2 $O$-functions is itself a $O$-function. This proof can be easily expanded to the sum of any finite number of functions, as then the comparison constants ($M,N,\ldots$) get added and can become big, but stay finite and from all the 'small enough' constats ($m,n,\ldots$), the minimum is taken, which is still a small but positve number.

However, whith an infinite sum the argument breaks down on two fronts. First, the sum of $M,N,\ldots$ can get infinite. That's what happened in my example. Also the minimum (infimum) of $m,n,\ldots$ can be become $0$, so any resulting inequality would only apply to $0$, which makes it trivial/useless.

So I hope I could demonstrate that adding an infinte number of $O$-functions may not necessarily be a $O$-function itself.


Let's come back to your problem to prove that in the given case the sum actually is $O(x)$.

Recall

$$\left|f(x)+{1\over 2}\right| \le \left|\frac{x}{3!}\right| + \left|\frac{x^2}{4!}\right| + \left|\frac{x^3}{5!}\right|+\ldots$$

and we have

$$\left|\frac{x}{3!}\right| + \left|\frac{x^2}{4!}\right| + \left|\frac{x^3}{5!}\right|+\ldots = |x|\left(\left|\frac{1}{3!}\right| + \left|\frac{x}{4!}\right| + \left|\frac{x^2}{5!}\right|+\ldots\right)$$

and because we consider $x \to 0$, we can assume $|x| \le 1$ and we have $$\left|\frac{1}{3!}\right| + \left|\frac{x}{4!}\right| + \left|\frac{x^2}{5!}\right|+\ldots \le \left|\frac{1}{3!}\right| + \left|\frac{1}{4!}\right| + \left|\frac{1}{5!}\right|+\ldots = e-1-1-\frac12$$

That proves finally

$$\left|f(x)+{1\over 2}\right| \le |x|(e-2.5)$$

for $|x| \le 1$, which implies $f(x)+{1\over 2} \in O(x)$ for $x\to 0$.