How to write a function from graph? How to represent a graph in a function?
For example, I used 3 functions : 
$$f(x)=x^2$$
$$g(x)=x$$
$$h(x)=3$$
These 3 functions were plotted on the same graph and the result (after edit) is as given below
How would you represent the below graph in a function, lets say $k(x)$ ?

 A: You can simple define $k$ to be a piecewise function:
$$k(x) := \begin{cases}x^2 & 0 \le x < 1\\ x & 1 \le x < 3\\3 & 3 \le x\end{cases}$$
Now if you really don't like that, you can work out something using $\min$:
$$k(x) = \min(x^2, x, 3)$$
But not all piecewise functions have such a nice "closed" form.
A: You'd use a piecewise function. In this case, we have
$$
k(x) =  
\begin{cases}
x^2 & 0 \leq x \lt 1 \\
x & 1 \leq x \lt 3 \\
3 & x \geq 3
\end{cases}
$$
A: Depending on the context, it might also be useful to represent the function using Heaviside's step function $H(x)$, which equals $0$ for $x < 0$ and $1$ for $x > 0$. You could also define $H(0)=0$ or $H(0) = 1$ if you want, but it might not be so important, again depending on the context.
With this notation, your function may be written as
$$k(x) = x^2(H(x)-H(x-1))+x(H(x-1)-H(x-3))+3H(x-3),$$
or, collecting the Heaviside terms,
$$k(x) = x^2H(x)+x(1-x)H(x-1)+(3-x)H(x-3).$$
This is really just a shorthand notation for the piecewise function we're dealing with, but it is very useful for example if you're working with distributions. Also note that it doesn't really matter whether we define $H(0)=0$ or $H(0) = 1$, as $k$ evaluates to the same value at $x=1$ and $x=3$ either way, as clearly seen from the second expression of $k$.
