Slightly equal functions

Can there exist two elementary functions $f(x)$ and $g(x)$ defined everywhere on the real axis such that, \begin{align} f(x)&=g(x)\qquad \text{if} \quad a\le x\le b\\ f(x)&\neq g(x)\qquad \text{if} \quad x<a\quad\text{or}\quad x>b\end{align} where f(x) and g(x) are not piecewise defined functions. And $a\ne b$.

If yes, give example. If no, give proof.

Also, would it make any difference if the functions need not be elementary?

Edit : It seems there is a lot of confusion due to my inability of putting the question precisely. Please refer to the links.
Elementary functions http://en.wikipedia.org/wiki/Elementary_function
Piecewise defined function http://en.wikipedia.org/wiki/Piecewise

I have also added the 'defined everywhere' condition.

• What i really want is two functions which give the same value in range [a,b], but have different representations in that range. Below answers, all reduces to same representation in the range [a,b]. Can someone put it in mathematical terms (if it means anything at all). Jun 10, 2014 at 19:36
• Note: a function can be defined in more than one way, one of which is piecewise. This is standard mathematical notation, and what wikipedia says. Hence $|x|$ need not be a piecewise defined function. And before you say "can be piecewise defined", let me point out that every function can be piecewise defined. Jun 10, 2014 at 20:41
• It seems from your comment you want two elementary formulas which define equal functions (only) on some interval but are not "obviously" equal on that interval (trying to interpret your meaning of "reduces"). I'm not sure how to make that precise.
– Ned
Jun 10, 2014 at 20:48

$f(x) = x$

$g(x) = \arcsin(\sin x)$

Then: $f(x) = g(x)$, if and only if $x$ is in $[-\pi/2, \ \pi/2]$

Added in edit: Note that $f$ and $g$ are both defined and continuous for all reals. The graph of $g$ is a sawtooth.

Define "elementary", because $|x|$ (or $\sqrt{x^2}$) in my opinion is. A first pair I can think of is:

$f(x)=|x-1|=\sqrt{(x-1)^2}$

$g(x)=-|x-2|+1=-\sqrt{(x-2)^2}+1$

This makes them equal on the interval $[1,2]$, and different outside. Here is some plot:

• $|x|$ is a piecewise defined function. Jun 10, 2014 at 18:06
• @Edwin_R : One definition of $|x|$ is a piecewise definition (in a reasonable interpretation of this undefined phrase), but what about $\sqrt{x^2}$? Jun 10, 2014 at 18:11
• Presumably piecewise means piecewise in terms of elementary functions. If you consider |x| to be elementary then it isn't defined piecewise. Jun 10, 2014 at 18:11
• You can always use $|x|=\sqrt{x^2}$ which is constructed from two continuous functions. In my opinion it depends what you expect. Jun 10, 2014 at 18:11
• If we're going by the wikipedia link for elementary functions that Edwin_R provided, then nth roots are allowed, so I like this one. Jun 10, 2014 at 19:05

(NB. The $a \neq b$ statement was added after this answer).

I believe this is the simplest counterexample if the problem is stated correctly.

$$f(x) = 0$$

$$g(x) = x$$

$$a = b = 0$$

Another example (depending on how you define piecewise) could be constructed using: $$f(x) = \sqrt{(x-1)^2}$$

$$g(x) = 1-\sqrt{(x-2)^2}$$

• $a\ne b$ in my problem. Jun 10, 2014 at 18:08
• This is not mentioned in the statement of the problem Jun 10, 2014 at 18:09
• This wasn't supposed to be a trick question. :-) I edited it though. Jun 10, 2014 at 18:12

I define floor $\lfloor x\rfloor$ as the largest integer less than or equal to $x$. This definition does not require pieces, and I believe it's as elementary as anything else. And now:

$$f(x)=\lfloor x\rfloor$$ $$g(x)=0$$

• I think this is piecewise defined. It reduces to different functions in different domains. Jun 10, 2014 at 18:22
• Every function reduces to different functions in different domains. $f(x)=x$ reduces to $g(x)=1$ (on the domain $1\le x\le 1$) etc. Jun 10, 2014 at 18:30
• I mean non-zero length domains, which is the case in my problem. Jun 10, 2014 at 18:33
• @Edwin_R, it's impossible to hit a target that moves all the time. Jun 10, 2014 at 18:39
• What can I do, it seems that to ask a question is more difficult than answering one. Can you please look at my comment below the question. Does it make any sense? Jun 10, 2014 at 19:53