Sum of convex + concave which is convex - HELP

Hi so I’m trying to model a likelihood model where the loglikelihood becomes a sum of a concave and convex function, but it is still convex. Unfortunately I could not figure out a way of imposing it to CVX so it accepts and am out of ideas after several days. Here is the part of the objective function (which is quite big) that makes the problem:

Any ideas how to model it or any kind of approximation which will be good for values ranging in the interval [-100;100]?

As you have correctly discovered, you cannot express this function in CVX exactly. You have correctly discovered that you cannot express this function in CVX. I do wish people would not try and spend so much time trying to force CVX to accept a particular function. If it cannot be constructed in a straightforward manner by combining functions from the function library, using only the combination rules found in the DCP ruleset, then it is extremely unlikely that CVX can solve it. The limits here are not just due to the software but the underlying mathematics as well.

My suggestion is twofold. First, try consider the logarithm of your function, \log(1+e^x)+\log(1+e^{-x^2/8}). This should have a more modest dynamic range and be better suited for a numerical solver of any kind. The fact is that the range of your function over [-100,100] is over 10^{43}, and honestly no numerical solver I’m aware of will readily handle that kind of dynamic range. Taking the logarithm reduces that dynamic range to about 100. Much better.

Secondly, if you look at the logarithmic version, you’ll see it looks nearly horizontal for large negative x, a nearly straight 45-degree slant for large positive x. It’s only near the origin where an approximation would be needed. Perhaps a piecewise function \max\{0,x,g(x)\}, where g(x) is a convex (DCP-compliant!) function of your design, would suffice.

Another option is \max\{\log(1+e^x),g(x)\}, where again g(x) is a convex function. This will be a much better fit for large x, though of course do strongly heed this warning.