One way to write volume charge densities without using piecewise functions is to use step \((\Theta)\) or \(\delta\) functions. Consider a spherical shell with charge density \[\rho (\vec{r})=\alpha3e^{(k r)^3} \]
between the inner radius \(a\) and the outer radius \(b\). The charge density is zero everywhere else.