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