# Limit of a function whose values depend on $x$ being odd or even

I couldn't find an answer through google or here, so i hope this isn't a duplicate.

Let $f(x)$ be given by:

$$f(x) = \begin{cases} x & : x=2n\\ 1/x & : x=2n+1 \end{cases}$$

Find $\lim_{x \to \infty} f(x).$

The limit is different depending on $x$ being odd or even. So what's the limit of $f(x)$?
Attempt: this limit doesn't exist because we have different values for $x \to \infty$ which could be either odd or even. My doubt is $\infty$ can't be both even and odd at the same time so one should apply.
So what do you ladies/gents think? Also, when confronted with functions like these and one needs to know the limit to gain more information about the behavior of $f(x)$, how should the problem be attacked?

-
In addition to the nice answer from @amWhy, a similar question and easier example would ask, how do you find the limit of $f(x) = Cos(x)$ as $x \rightarrow \infty$? – Amzoti Dec 25 '12 at 0:00
@Amzoti: First $cos(x)$ cannot have any value outside $[-1,1]$. Second we remark that having $cos(x)$ defined using the unit circle way, the "maximum" angle is $360$ degrees. Any other angle greater than $360$ will have to come as a multiple of some angle in $[0,360]$. So as $x \to \infty$, $cos(x)$ will be taking various values between $[-1,1]$ depending on whether the current angle in a multiple of an angle in the second or third quadrant OR first or fourth quadrant. So $\lim_{x \to +\infty} cos(x)$ oscillates in $[-1,1]$. Hope that reasoning was correct! – nt.bas Dec 25 '12 at 0:42
Very good! Hopefully, your example and this one help! – Amzoti Dec 25 '12 at 0:48
@Amzoti: thanks! This was definitely helpful! I was accustomed to the replace-and-get-a-value way of doing things, now it's better than that! – nt.bas Dec 25 '12 at 0:53
@nt.bas These examples show why you can't do that when $x \rightarrow \infty$, but you might still be tempted to do that when x goes to some finite number. You should be cautious, though! This only works when f(x) is continuous at that point (in fact, this is a definition for continuity.) Limits really are only about what happens as you "approach" an x-value, not what the function actually is at that value. This is an important distinction! – AndrewG Dec 25 '12 at 1:03

Your first statement following the word "attempt" has the correct intuition: "this limit doesn't exist because we have different values for" ... $\lim_{x\to \infty} f(x)$, which depends on x "which could be either odd or even." (So I'm assuming we are taking $x$ to be an integer, since the property of being "odd" or "even" must entail $x \in \mathbb{Z}$).

The subsequent doubt you express originates from the erroneous conclusion that $\infty$ must be even or odd. It is neither. $\infty$ is not a number, not in the sense of it being odd or even, and not in the sense that we can evaluate $f(\infty)$! (We do not evaluate the $\lim_{x \to \infty} f(x)$ AT infinity, only as $x$ approaches infinity.)

When taking the limit of $f(x)$ as $x \to \infty$, we look at what happens as $x$ approaches infinity, and as you observe, $x$ oscillates between odd and even values, so as $x \to \infty$, $f(x)$, as defined, also oscillates: at extremely large $x$, $f(x)$ oscillates between extremely large values and extremely small values (approaching $\infty$ when $x$ is even, and approaching zero when $x$ is odd.

Hence the limit does not exist.

Note: when $x$ goes to some finite number, say $a$, you may be tempted to simply "plug it in" to $f(x)$ when evaluating $\lim_{x\to a}f(x)$. You should be careful, though. This only works when $f(x)$ is continuous at that point $a$. Limits are really only about what happens as $x$ approaches an x-value, or infinity, not what $f(x)$ actually is at that value. This is an important to remember.

-
Thanks, especially the enlightenment about $\infty$. Actually I got this function while working with series. The general term $a_n$ is defined by the $f(x)$ given in the question, so how would one test for convergence of such series? – nt.bas Dec 24 '12 at 23:17
Why don't you post a separate problem where you are trying to determine the convergence (or divergence) of $\sum_{n=0}^{infty}f(x)$ defining f(x) in terms of $n$: $f(2n)$ for even integers 2n, f(2n+1) for odd integers 2n+ 1. Do they "cancel out", e.g., (converge, perhaps), or does series converge? – amWhy Dec 24 '12 at 23:28
Yes, I'll post another question. Thanks – nt.bas Dec 24 '12 at 23:39