Why "is $f(x)$ an odd function?" does not work with this function?

92 Views Asked by At

We know that $f(x)$ is odd if $-f(x)=f(-x)$. The function is $$f(x)=\begin{cases}2x-1&\text{if $-2<x<0$},\\2x+1&\text{if $0\leq x\leq2$}.\end{cases}$$

Plot of f

(link)

Now I want to know if $f$ is odd, so I query to WA is Piecewise[{{2x-1,-2<x<0},{2x+1,0<=x<=2}}] an odd function?:

Question to WA

I get the answer:

Answer

Now, if we query plot -Piecewise[{{2x-1,-2<x<0},{2x+1,0<=x<=2}}] from -2 to 2 then we see the graph of $-f(x)$:

Sketch of -f(x)

If we query plot Piecewise[{{2(-x)-1,-2<-x<0},{2(-x)+1,0<=-x<=2}}] from -2 to 2 then we obtain $f(-x)$:

Sketch of f(-x)

As the plots are the same, then $-f(x)=f(-x)$, so the function is odd.

However in the first input, WA did not recognize that. Why?

2

There are 2 best solutions below

1
On BEST ANSWER

As noted in the comments, $f(0)=1 \ne -f(-0)$. Also, the domain you have specified for $f$ includes $2$ but not $-2$. Mathematica's Piecewise functions have zero as a default value (you can actually see this in your first plot), and so your function has $f(-2)=0$ but $f(2)=5$.

Repeating your query with strict inequalities everywhere gives a function which Wolfram correctly says is odd.

1
On

The definition of odd function requires first that $-x$ be in the domain of the function whenever $x$ is. In your example, $2$ is in the domain but $-2$ is not, so it couldn't be odd. Also, for any odd function, it follows that $$f(-0)=f(0)=-f(0)\implies f(0)=0.$$ This, however, is not the case with your function. These are the two characteristics that prevent it from being odd.