Smoothing corners of a function 
I start with a the function (in blue) which has corners. What would be an efficient way to smooth out the corners(like I attempt below) so that the function becomes differentiable? By efficient, I mean that I want the smoothed function to be as close to the original function as possible. Also I want the smoothed function to be non-negative.

There are two easy ways:
Method 1
If you have only isolated discontinuities and know exactly where they are, you can delete a small interval around each of them and use a cubic spline to join the ends back smoothly. This method allows you to fine-tune the smoothing of each discontinuity individually.
Method 2
If method 1 does not apply or you want a general formula that works for any bounded integrable function, and you do not mind that the new function may be different from the original at almost every point, then you can convolve the function with a 'spike' function. The idea is that you want some sort of average of the values around each point, so that it will change smoothly instead of jumping at a discontinuity. The convolution of $f$ and $g$ is $f*g = x \mapsto \int_{-\infty}^\infty f(t) g(x-t) dt$. If the function is $f$ and the 'spike' function is $g$, such that $\int_{-\infty}^\infty g = 1$, and $g$ is $0$ everywhere except on a small interval around $0$, then $f*g$ will be close to $f$ except when close to a discontinuity of $f$. Different 'spike' functions will give different properties. For example if $g$ is a triangular function, $f*g$ will be differentiable. But if you want $f*g$ to be infinitely differentiable, then you need $g$ to be something else such as a Gaussian function or a mollifier.
