I have the following question and the solution along with it but I can't get my head around what's been done.
The aim is to write the following function as a sum of even and odd functions:
$h(x) = \begin{cases} 1, & \text{if $x<0$} \\ e^x, & \text{if $ x\geq 0$} \end{cases} $
I am aware that any function $f(x)$ can be written as:
$f(x) = \underbrace{\frac{1}{2}(h(x)+h(-x))}_{f_{even}(x)}+ \underbrace{\frac{1}{2}(h(x)-h(-x))}_{f_{odd}(x)}$
I attempted to do it myself but it was incorrect.
The correct method was to find the following:
We have
$h(-x) = \begin{cases} 1, & \text{if $x>0$} \\ e^{-x}, & \text{if $ x\leq 0$} \end{cases} $
Hence:
$h_{even}(x) = \begin{cases} \frac{1}{2}(1+e^{-x}), & \text{if $x<0$} \\ \frac{1}{2}(1+e^{x}), & \text{if $ x> 0$} \\ \ 1, & \text{ if $x=0$}\end{cases} $
$h_{odd}(x) = \begin{cases} \frac{1}{2}(1-e^{-x}), & \text{if $x<0$} \\ \frac{1}{2}(e^{x}-1), & \text{if $ x> 0$} \\ \ 0, & \text{ if $x=0$}\end{cases} $
My problem is I have no idea how these functions were found.. I'm sure it's as simple as applying the formula I stated above but I think perhaps because they are piece wise functions I am not entirely sure how this happened.
Any explanation is greatly appreciated.
Further Info:
I think I understand the formula but applying it to examples particularly is where I struggle, as in the actual calculation is what I don't understand.
For example, to calculate $h_{even}(x)$ we should do the addition of the following functions, if I am correct:
$ \frac{1}{2}h(x) = \begin{cases} \frac{1}{2}, & \text{if $x<0$} \\ \frac{1}{2}e^x, & \text{if $ x\geq 0$} \end{cases} $
$\frac{1}{2}h(-x) = \begin{cases} \frac{1}{2}, & \text{if $x>0$} \\ \frac{1}{2}e^{-x}, & \text{if $ x\leq 0$} \end{cases}$
But my issue is, how do you combine these? How can you deduce that for example $h_{even}(x)=1$, if $x=0$ purely from this addition.
I guess my question is quite simple really as in just how to add piece wise functions when the conditions are different.