# Computing expectation with some constants

I would like to compute the following expression in Wolfram alpha: $$\mathbb{E}[X-max(aX+b,0)]$$ where $$X\sim N(\mu,\sigma^2)$$ and $$a,b$$ are some constants.

Without constants, I can get the result with

expectation of (x-max(x,0)), x normal distributed

However, the following doesn't seem to work:

expectation of (x-max(ax+b,0)), x normal distributed

Do you know how I can get the general result with some arbitrary constants ?

I think your problem is "aX". This is interpreted as one variable name. You need a space between names. Then the following works:

Clear["Global*"]
Expectation[x - Max[a x - b,0], x \[Distributed] NormalDistribution[mu, sig]] • Thanks for your response ! To compute this expression, I need Mathematica ? The online free Wolfram Alpha is not enough ? Aug 5 at 10:23
• I tried it on WolframAlpha, but it seems that WolframAlpha does not know about "Expectation" Aug 5 at 13:19
• @Wiles01 You can install the full version for free and use Jupiter notebook interface mathematica.stackexchange.com/questions/198839/…. Aug 5 at 15:21
• True means: all other cases Aug 5 at 16:10
• You can get a simpler result if you simplify using the constraints on mu and sig required for the distribution to be valid, i.e., mu \[Element] Reals && sig > 0` Aug 5 at 16:43