1
$\begingroup$

I have an integral inte1 as below:

f[x_] := PDF[NormalDistribution[0, 1], x];
F[x_] := CDF[NormalDistribution[0, 1], x];
inte1 = Integrate[f[x]*x^2, {x, -∞, k}] // FullSimplify

which is:

enter image description here

But I want to show it in terms of F[x]:

enter image description here

How can I achieve this? Many thanks!

$\endgroup$

3 Answers 3

1
$\begingroup$

You can use ComplexityFunction to make expressions with Erf costly:

FullSimplify[inte1, 
  ComplexityFunction -> (LeafCount[#] + 100 Count[#, _Erf, Infinity] &) ]

enter image description here

Alternatively, you can use the second argument of FullSimplify or the option Assumptions to provide simplifying assumptions:

FullSimplify[inte1, F[-k] == HoldForm[F][-k]] (* or *)
FullSimplify[inte1, Assumptions->{F[-k] == HoldForm[F][-k]}]

enter image description here

% // TeXForm

$-F(-k)-\frac{e^{-\frac{k^2}{2}} k}{\sqrt{2 \pi }}+1$

You can also use ReplaceAll to replace Erf with an alternative form:

inte1 /. Erf -> (2 (1 - HoldForm[F][-Sqrt[2] #]) - 1 &) 

same output

$\endgroup$
2
  • $\begingroup$ Thanks for your reply. It works for the above case, but failed for a slight variation. I tried inte2 = Integrate[f[x]*x, {x, -k + b, k + b}] // FullSimplify and FullSimplify[inte2, f[k] == HoldForm[f][k]], but it doesn't give me the desired output f[b - k] - f[b + k]... How can I fix that? $\endgroup$
    – H42
    Commented Sep 22, 2018 at 22:24
  • $\begingroup$ @H42, i will post an update i figure out how to handle the case in your comment. $\endgroup$
    – kglr
    Commented Sep 22, 2018 at 23:25
0
$\begingroup$

If you define F with F[x_] := CDF[NormalDistribution[0, 1], x]; then F can never appear in any subsequent evaluated expression since the definition will have been applied.

Clear[f, F]

f[x_] := PDF[NormalDistribution[0, 1], x];

Use a Rule to express Erf in terms of F

rule = Erf[x_] -> 2 F[x Sqrt[2]] - 1;

inte1 = (Integrate[f[x]*x^2, {x, -∞, k}] // FullSimplify) /. rule

(* -((E^(-(k^2/2)) k)/Sqrt[2 π]) + F[k] *)

To evaluate F replace it with CDF

FullSimplify[inte1 /. F -> (CDF[NormalDistribution[0, 1], #] &)]

(* -((E^(-(k^2/2)) k)/Sqrt[2 π]) + 1/2 (1 + Erf[k/Sqrt[2]]) *)
$\endgroup$
0
$\begingroup$

Try this:

Clear[F];
inte1 /. Erf[k/Sqrt[2]] -> 1 - 2 F[-k] // Simplify

giving exactly what you want.

Have fun!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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