# How to Integrate the Derivative of a function with Assumptions on the function?

I have a monotonic increasing function g and constant αsuch that

{Element[x, Reals], Limit[g[x], x-> ∞] == 1, g[0] == 0,
Integrate[g'[x], {x, 0, ∞}] == 1,
ForAll[x, g[x] ≥ 0], ForAll[x, g'[x] >= 0], α > 0}


$\left\{x\in \mathbb{R},\underset{x\to \infty }{\text{lim}}g(x)=1,g(0)=0,\int_0^{\infty } g'(x) \, dx=1,\forall _xg(x)\geq 0,\forall _xg'(x)\geq 0,\alpha >0\right\}$

I would like to perform the integral

Integrate[x g'[x], {x, 0, α}] +
Integrate[α g'[x], {x, α, ∞}]


$\int_0^{\alpha } x g'(x) \, dx+\int_{\alpha }^{\infty } \alpha g'(x) \, dx$

and am expecting the result of

$\int_0^{\alpha } (1-g(x)) \, dx$

However, the kernel just quits after around a minute of processing.

Assuming[
{
Element[x, Reals],
Limit[g[x], x-> ∞] == 1,
g[0] == 0,
Integrate[g'[x], {x, 0, ∞}] == 1,
ForAll[x, g[x] ≥ 0],
ForAll[x, g'[x] ≥ 0],
α > 0
},
Integrate[x g'[x], {x, 0, α}] + Integrate[α g'[x], {x, α, ∞}]
]


Any ideas how to get this integral to complete such that it will resolve symbolically and when g or g' is defined?

MMA 11.3 on Win 10

PS: For context, g is a probability distribution CDF and g' its PDF. The integral sum is the limited expected loss (limited to α). The integral should resolve to the integral of the survival function from 0 to α.

• Do the assumptions g[0] == 0 and ForAll[x, g[x] > 0] square up? I am not really know if MMA gives the priority to the first listed one. – kkm Jul 10 '18 at 17:18
• @kkm That should be ≥. Fixed. – Edmund Jul 10 '18 at 17:19
• Did that help? As for the monotonic condition, the first idea that comes to mind is ForAll[x, g'[x] >= 0]. Also, I'd try an assumption that x is real, at times that helped me. It's not inferrible from your current conditions (I know MMA is smart enough to infer that for the α and g[x] becaue >, but the x does not seem to be restricted). It does not seem to make sense to looks at complex xs, but sometimes it seems MMA has a mind on its own :) – kkm Jul 10 '18 at 17:26
• @kkm Of course, first derivative for monotonic; very silly of me. Sadly, with this an x in the Reals MMA still will not resolve the integral. – Edmund Jul 10 '18 at 18:37
• Kills mine much faster, ~30s. Am I reading it correctly that of the first 3 assumptions, any one follows from the other two, or am I missing something? When I take out the Limit one, I am getting back the unsolved equation in good 2 minutes, if I take out the third, I get the same unsolution immediately. Interesting. – kkm Jul 10 '18 at 18:38

You could try using DSolveValue. First, define your sum using inactive integrals:

h[α_] := Inactive[Integrate][x g'[x],{x,0,α}] + Inactive[Integrate][α g'[x],{x,α,∞}]


Even though the integrals are inactive, Mathematica can still differentiate them:

h'[α]
h''[α]


Inactive[Integrate][g'[x], {x, α, ∞}]

-g'[α]

Clearly, your condition Integrate[g'[x], {x, 0, ∞}] == 1 means that h'[0]==1. Also, it is clear that h[0]==0. So, solving the following ODE is equivalent to finding h:

g[0] = 0;
Block[{K=x&},
DSolveValue[{s''[α] + g'[α] == 0, s[0]==0, s'[0]==1}, s[α], α]
] //TeXForm


$\alpha +\int_1^{\alpha } -g(x) \, dx-\int_1^0 -g(x) \, dx$

which is essentially what you wanted.

• Excellent work with DSolve. I did not consider this as I was too wrapped up in providing Integrate assumptions. – Edmund Jul 19 '18 at 0:09

You might have to help MMa with this one. First evaluate the integrals without the limits. First integral:

int1=Integrate[alpha g'[x],x]
(*alpha g(x)*)


Apply the integration limits

int1=(int1/.x->Infinity)-(int1/.x->alpha)
(*alpha*g[Infinity] - alpha*g[alpha]*)


Then use your condition

int1=int1/.g[Infinity]->1
(*alpha-alpha g(alpha)*)


For the second integral, teach MMa integration by parts.

u=x

du=D[u,x]
(*1*)

dv=g'[x];

v = Integrate[dv, x];

int2 = (u*v /. x -> alpha) - (u*v /. x -> 0) - Integrate[v*du, {x, 0, alpha}]
(*alpha*g[alpha] - Integrate[g[x], {x, 0, alpha}]*)

int=int1+int2
(*alpha - Integrate[g[x], {x, 0, alpha}]*)


Which is essentially what you have.

• I can do the calculus by hand myself but I am asking how to have Integrate perform the integration given that it has been provided all of the assumptions for g that will give the expected result. – Edmund Jul 12 '18 at 21:37
• After M8, MMa refuses to evaluate definite integrals of derivatives by its own design due to worry about branch cuts. Even M8 will not do definite integrals with infinite limits, but you can get around that by using algebraic limits, and then assign one or both of them to infinity. After M8, MMa will only do indefinite integrals of derivatives, so unless that changes, you are probably out of luck if you want your result automated in one step. – Bill Watts Jul 12 '18 at 22:07
• I added continuity assumptions for the derivatives that would be needed (Element[a, Reals], ForAll[a, Limit[g[x], x -> a] == g[a]], ForAll[a, Limit[g'[x], x -> a] == g'[a]], ForAll[a, Limit[g''[x], x -> a] == g''[a]],). However, it still does not evaluate. – Edmund Jul 12 '18 at 23:16