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 ?

Thanks in advance !


1 Answer 1


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

Expectation[x - Max[a x - b,0], x \[Distributed] NormalDistribution[mu, sig]]

enter image description here

  • 1
    $\begingroup$ Thanks for your response ! To compute this expression, I need Mathematica ? The online free Wolfram Alpha is not enough ? $\endgroup$
    – Wiles01
    Aug 5 at 10:23
  • 1
    $\begingroup$ I tried it on WolframAlpha, but it seems that WolframAlpha does not know about "Expectation" $\endgroup$ Aug 5 at 13:19
  • 1
    $\begingroup$ @Wiles01 You can install the full version for free and use Jupiter notebook interface mathematica.stackexchange.com/questions/198839/…. $\endgroup$
    – yarchik
    Aug 5 at 15:21
  • 1
    $\begingroup$ True means: all other cases $\endgroup$ Aug 5 at 16:10
  • 1
    $\begingroup$ 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 $\endgroup$
    – Bob Hanlon
    Aug 5 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.