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.

  • $\begingroup$ 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). $\endgroup$
    – Edwin_R
    Jun 10, 2014 at 19:36
  • $\begingroup$ 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. $\endgroup$
    – vadim123
    Jun 10, 2014 at 20:41
  • $\begingroup$ 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. $\endgroup$
    – Ned
    Jun 10, 2014 at 20:48

4 Answers 4


$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:



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

enter image description here

  • 4
    $\begingroup$ $|x|$ is a piecewise defined function. $\endgroup$
    – Edwin_R
    Jun 10, 2014 at 18:06
  • 1
    $\begingroup$ @Edwin_R : One definition of $|x|$ is a piecewise definition (in a reasonable interpretation of this undefined phrase), but what about $\sqrt{x^2}$? $\endgroup$ Jun 10, 2014 at 18:11
  • 1
    $\begingroup$ Presumably piecewise means piecewise in terms of elementary functions. If you consider |x| to be elementary then it isn't defined piecewise. $\endgroup$ Jun 10, 2014 at 18:11
  • 2
    $\begingroup$ You can always use $|x|=\sqrt{x^2}$ which is constructed from two continuous functions. In my opinion it depends what you expect. $\endgroup$
    – jojeck
    Jun 10, 2014 at 18:11
  • 1
    $\begingroup$ 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. $\endgroup$
    – Duncan
    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}$$

(as in another answer).

  • $\begingroup$ $a\ne b$ in my problem. $\endgroup$
    – Edwin_R
    Jun 10, 2014 at 18:08
  • 3
    $\begingroup$ This is not mentioned in the statement of the problem $\endgroup$
    – Vladimir
    Jun 10, 2014 at 18:09
  • $\begingroup$ This wasn't supposed to be a trick question. :-) I edited it though. $\endgroup$
    – Edwin_R
    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$$

  • $\begingroup$ I think this is piecewise defined. It reduces to different functions in different domains. $\endgroup$
    – Edwin_R
    Jun 10, 2014 at 18:22
  • 1
    $\begingroup$ 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. $\endgroup$
    – vadim123
    Jun 10, 2014 at 18:30
  • $\begingroup$ I mean non-zero length domains, which is the case in my problem. $\endgroup$
    – Edwin_R
    Jun 10, 2014 at 18:33
  • 1
    $\begingroup$ @Edwin_R, it's impossible to hit a target that moves all the time. $\endgroup$
    – vadim123
    Jun 10, 2014 at 18:39
  • $\begingroup$ 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? $\endgroup$
    – Edwin_R
    Jun 10, 2014 at 19:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .