My mathematical problem is to solve the optimization problem: $$ Max_{u} \quad \mathbb{E}[\gamma S-S^2]$$ where $$S= A_0 u X+a-\max(\alpha u X+b,0)$$ with $\gamma,A_0,a,\alpha,b$ some constants and $X\sim N(\mu,\sigma)$.
As a starting point, I was trying to compute the tedious expectation via
Expectation[gamma*(a0*u*x+a-Max[alp*u*x+b,0])-((a0*u*x+a-Max[alp*u*x+b,0]))^2, x \[Distributed] NormalDistribution[mu, sig]]
using the Wolfram Engine (via Jupyter Interface). After that, I was trying to take the partial derivative with respect to $u$ using
D[%,u]
and it renders a very strange output:
My feeling is that the expression is so long that it is unable to display it so the problem is not from the mathematical difficulty but more from the display. I searched on stackexchange but couldn't find a similar issue.
Do you know what the exact issue is and I can get the proper derivative ?
Thanks a lot !
Edit: The problem is now solved thanks to the solution below. Since some people comment that they can't recover my output, here is the full Jupyter output:
Out[16]
can't be the one you show. $\endgroup$Out[1]
in Edit is exactly aPiecewise[…]
function. It's the default 2D display (formally we call itStandardForm
) of it. If you still don't understand what I mean, just execute e.g.Piecewise[{{a, a > 0}}, -a]
and observe. For more info, check the document ofPiecewise
. $\endgroup$