# maths question about an integral

humy
Science 05 Mar '16 19:28
1. 05 Mar '16 19:2810 edits
This one has really got me totally stumped:
what is the integral of:

∫[θ = 0, ∞] ( h (θ^m) ) / ( e^( θ(h + s) ) ) dθ

m ∈ ℕ,
m>0,
h, s, m, θ ∈ ℝ,
s, m, θ ≥ 0,
h>0
( so all positive i.e. none are allowed to be negative )

and why?

I tried Wolfram-Alpha this but it wouldn't give me the answer directly and what I seemed to indirectly infer from Wolfram-Alpha (by inputting a series of reduced versions of the above integral into it ) is that it implies it is:
h θ^( (m-1)! ) / ( ( h + s )^m )
(bear in mind that m∈ℕ and m>0 else cannot have that factorial )
BUT it seems to me that this MUST be false because I just get complete nonsense when I test that with a computer program.
2. 05 Mar '16 21:187 edits
Originally posted by humy
what is the integral of:

∫[θ = 0, ∞] ( h (θ^m) ) / ( e^( θ(h + s) ) ) dθ

m ∈ ℕ,
m>0,
h, s, m, θ ∈ ℝ,
s, m, θ ≥ 0,
h>0
by a lot of trial and error and guess work and extrapolation from the many outputs from my computer program, assuming my program is bug-free, I think that integral should be:

( h * ( (m-1)! ) ) / ( (h + s)^m )

But the problem is that I have no idea how to justify that algebraically or with a mathematical proof and, for all I know, it could be false due to an undetected programming error I made in my program I designed for estimating the integral for it.
A possible bad sign is that it seems to differ a bit from what Wolfram-Alpha implies it should be.
3. joe shmo
Strange Egg
06 Mar '16 18:221 edit
Originally posted by humy
by a lot of trial and error and guess work and extrapolation from the many outputs from my computer program, assuming my program is bug-free, I think that integral should be:

( h * ( (m-1)! ) ) / ( (h + s)^m )

But the problem is that I have no idea how to justify that algebraically or with a mathematical proof and, for all I know, it could be false due ...[text shortened]... possible bad sign is that it seems to differ a bit from what Wolfram-Alpha implies it should be.
Try using the technique of integration by parts... The functions form suggests that will be how it's integral is derived.

EDIT: I feel like you have posted an integral of this nature in the past?
4. 06 Mar '16 22:235 edits
Originally posted by joe shmo

EDIT: I feel like you have posted an integral of this nature in the past?
definitely not exactly like this one as this one is totally new although I may have posted a vaguely similar looking one because all the integrals I make, including this one, are for probability distributions.

It is a long time since I used integration by parts but I will revise it at;
https://en.wikipedia.org/wiki/Integration_by_parts
but it looks very hard to me for this one since we have an awful lot of variables to contend with!
I mean we have h, θ and m for the ( h (θ^m) ) numerator and h, θ and s for the ( e^( θ(h + s) ) ) denominator.
Still, I will try and give it a go.
5. joe shmo
Strange Egg
07 Mar '16 00:25
Originally posted by humy
definitely not exactly like this one as this one is totally new although I may have posted a vaguely similar looking one because all the integrals I make, including this one, are for probability distributions.

It is a long time since I used integration by parts but I will revise it at;
https://en.wikipedia.org/wiki/Integration_by_parts
but it looks very ha ...[text shortened]... tor and h, θ and s for the ( e^( θ(h + s) ) ) denominator.
Still, I will try and give it a go.
The only variable you have is θ in this case. Just treat all the others as constants.
6. 07 Mar '16 08:478 edits
Originally posted by joe shmo
The only variable you have is θ in this case. Just treat all the others as constants.
Thanks for that.
I have just tried that and cannot make it work because the integrals don't seem to converge.

The wanted integral was:

∫[θ = 0, ∞] ( h (θ^m) ) / ( e^( θ(h + s) ) ) dθ

let S = h + s

then that becomes:

∫[θ = 0, ∞] ( h (θ^m) ) / ( e^( θS ) ) dθ

= ∫[θ = 0, ∞] ( h (θ^m) ) ( 1 / e^( θS) ) dθ

so let

let u = h (θ^m)
v = 1 / e^( θS)

then we have;

d/dθ u
= d/dθ h (θ^m)
= h * m (θ^(m - 1))

∫[θ = 0, ∞] v dθ
= ∫[θ = 0, ∞] ( 1 / e^( θS) ) dθ
= 1/S

so using integration by parts:

∫[θ = 0, ∞] ( h (θ^m) ) ( 1 / e^( θS) ) dθ
= ( (h (θ^m) ) * ( 1/S ) ) - ∫[θ = 0, ∞] h * m (θ^(m - 1)) * ( 1/S ) dθ
= h (θ^m)/S - ∫[θ = 0, ∞] h * m (θ^(m - 1)) / S dθ

But ∫[θ = 0, ∞] h * n (θ^(n - 1)) / S dθ does not converge.

and if I try

v = h (θ^m)

But then

∫[θ = 0, ∞] v dθ
∫[θ = 0, ∞] ( h (θ^m) ) dθ does not converge.

Wow this is a hard one!
Perhaps I should just risk it and assume my computer program outputs (from numerical methods ) are right and just simply say in my book that the integral is equal to ( h * ( (m-1)! ) ) / ( (h + s)^m ) without mentioning its derivation?
But, if I do that, I better extremely thoroughly check my program for possible bugs and make absolutely sure that is exactly correct else I could have a pretty bad post-publication embarrassment!
7. DeepThought
07 Mar '16 11:25
Originally posted by humy
This one has really got me totally stumped:
what is the integral of:

∫[θ = 0, ∞] ( h (θ^m) ) / ( e^( θ(h + s) ) ) dθ

m ∈ ℕ,
m>0,
h, s, m, θ ∈ ℝ,
s, m, θ ≥ 0,
h>0
( so all positive i.e. none are allowed to be negative )

and why?

I tried Wolfram-Alpha this but it wouldn't give me the answer directly and what I seemed to indirectly inf ...[text shortened]... his MUST be false because I just get complete nonsense when I test that with a computer program.
Assuming I've read the integral right you can do this by differentiating with h.

∫[θ = 0, ∞] ( h (θ^m) ) / ( e^( θ(h + s) ) ) dθ
= h ∫[θ = 0, ∞] (θ^m) * exp(-θ(h + s)) dθ
= h* I(h, m)

I(h, m) = ∫[θ = 0, ∞] (θ^m) * exp(-θ(h + s)) dθ
= (-d/dh)^m ∫[θ = 0, ∞] exp(-θ(h + s)) dθ
I(h, m) = (-d/dh)^m (I(h, 0))

I(h. 0) = ∫[θ = 0, ∞] exp(-θ(h + s)) dθ = 1/(h + s)

-d/dh(1/(h+s)) = 2/[(h + s)^2]
(-d/dh)^m(1/(h + s)) = (m + 1)! / [(h + s) ^(m+1)]

I(m,h) = (m + 1)! / [(h+s)^(m + 1)]

and

∫[θ = 0, ∞] ( h (θ^m) ) / ( e^( θ(h + s) ) ) dθ = h (m + 1)! / [(h+s)^(m + 1)]
8. joe shmo
Strange Egg
07 Mar '16 12:532 edits
Originally posted by DeepThought
Assuming I've read the integral right you can do this by differentiating with h.

∫[θ = 0, ∞] ( h (θ^m) ) / ( e^( θ(h + s) ) ) dθ
= h ∫[θ = 0, ∞] (θ^m) * exp(-θ(h + s)) dθ
= h* I(h, m)

I(h, m) = ∫[θ = 0, ∞] (θ^m) * exp(-θ(h + s)) dθ
= (-d/dh)^m ∫[θ = 0, ∞] exp(-θ(h + s)) dθ
I(h, m) = (-d/dh)^m (I(h, 0))

I(h. 0) ...[text shortened]... + 1)]

and

∫[θ = 0, ∞] ( h (θ^m) ) / ( e^( θ(h + s) ) ) dθ = h (m + 1)! / [(h+s)^(m + 1)]
Huh...Integration by Differentiation...who would have thought!

I'm almost certain you can do it by parts, but your route seems to be rainbows and unicorns comparatively.

I've never seen this before. If its not too much trouble for you could you give a little more description so I can follow exactly what you are doing for my own knowledge?
9. DeepThought
07 Mar '16 17:064 edits
Originally posted by joe shmo
Huh...Integration by Differentiation...who would have thought!

I'm almost certain you can do it by parts, but your route seems to be rainbows and unicorns comparatively.

I've never seen this before. If its not too much trouble for you could you give a little more description so I can follow exactly what you are doing for my own knowledge?
Except the answer I gave above is wrong by a factor of (m + 1). The method relies on d/dh exp(-θh) = - θ exp(-θh) and the order of differentiation and integration not mattering. This is the correct working:

I(h, m) = (-d/dh)^m I(h, 0) = (-d/dh)^m 1/(h + s) = m! / (h + s)^(m + 1)

You can also do the integral by parts to set up a recurrence relation, it's no harder:

I (h + s, m) = ∫[θ = 0, ∞] (θ^m) * exp(-θ(h + s)) dθ

redefine h to absorb s.

I (h, m) = ∫[θ = 0, ∞] (θ^m) * exp(-θh) dθ = ∫[θ = 0, ∞] u dv/dθ dθ = [u v][θ = 0, ∞] - ∫[θ = 0, ∞] v du/dθ dθ

u = θ^m => du/dθ = mθ^(m - 1)
dv/dθ = exp(- θh) => v = -exp(-θh)/h

u(0) = 0 and v( ∞ ) = 0 so

=> I(h,m) = - ∫[θ = 0, ∞] (-m/h) θ^(m - 1) * exp(-θh) dθ = (m/h) I(h,m - 1)

I(h, 0) = ∫[θ = 0, ∞] exp(-θh) dθ = 1/h

So that:
I(h, m) = m! / h^(m + 1)
and
I(h + s, m) = m! / (h + s)^(m + 1)
10. 07 Mar '16 20:121 edit
Originally posted by DeepThought
Except the answer I gave above is wrong by a factor of (m + 1). The method relies on d/dh exp(-θh) = - θ exp(-θh) and the order of differentiation and integration not mattering. This is the correct working:

I(h, m) = (-d/dh)^m I(h, 0) = (-d/dh)^m 1/(h + s) = m! / (h + s)^(m + 1)

You can also do the integral by parts to set up a recurrence relatio ...[text shortened]... exp(-θh) dθ = 1/h

So that:
I(h, m) = m! / h^(m + 1)
and
I(h + s, m) = m! / (h + s)^(m + 1)
according to my current computer program, both your answers are wrong BUT there may be a bug in my program. I am currently working on making a much better program that should be totally reliable but it is taking me ages (several days so far ) to make but I will come back to you as soon as I have made it and then used it to test your answers on it.
11. DeepThought
07 Mar '16 21:40
Originally posted by humy
according to my current computer program, both your answers are wrong BUT there may be a bug in my program. I am currently working on making a much better program that should be totally reliable but it is taking me ages (several days so far ) to make but I will come back to you as soon as I have made it and then used it to test your answers on it.
I've got two different algebraic methods giving the same answer. I am definitely right. Your empirical formula differs from mine by replacing m with m + 1. Are you sure you've started counting in the right place as putting 0 into my equation gives h/(h + s), but putting it into yours means we need to evaluate (-1)! which is gamma(0) and a simple pole for the gamma function.
12. 07 Mar '16 22:006 edits
Originally posted by humy
according to my current computer program, both your answers are wrong BUT there may be a bug in my program. I am currently working on making a much better program that should be totally reliable but it is taking me ages (several days so far ) to make but I will come back to you as soon as I have made it and then used it to test your answers on it.
I have just completed that new computer program and then I tested on a number of integral formulas with known answers and it gave all the correct answers as required. I then tested on my OP integral formula and it confirmed that:

∫[0, ∞] h (θ^(m-1)) / ( e^( θ*(h + s) )) dθ = h * (m-1)! / (( h + s )^m )

(remember; all numbers positive and m is an integer greater than zero)
No doubt this time! This couldn't be due to a program bug!
+ to my surprise, with huge difficulty, I even at last found a way around the awkward wolfram-alpha to also confirm the above!

But I still don't have the algebraic reason. But I guess that doesn't matter too much for my book as long as I know for sure that result is definitely correct.

+ the really great thing about that is that that new program I made is highly generic and will help me out whenever I get stuck on virtually any integral, providing it is non-negative, in the future and that should speed up my research!
13. 07 Mar '16 22:08
Originally posted by DeepThought
I've got two different algebraic methods giving the same answer. I am definitely right. Your empirical formula differs from mine by replacing m with m + 1. Are you sure you've started counting in the right place as putting 0 into my equation gives h/(h + s), but putting it into yours means we need to evaluate (-1)! which is gamma(0) and a simple pole for the gamma function.
remember I said in my OP that m>0, which implies m≠0.
( There is a good reason for that; in the particular application I want to use the equation for, m=1 would be total nonsense because m is the number of observed data values specifically for a definable posterior probability and, if m=0, there is no observed values thus no definable posterior probability and the equation itself assumes definable posterior probability) .
14. DeepThought
07 Mar '16 23:13
Originally posted by humy
I have just completed that new computer program and then I tested on a number of integral formulas with known answers and it gave all the correct answers as required. I then tested on my OP integral formula and it confirmed that:

∫[0, ∞] h (θ^(m-1)) / ( e^( θ*(h + s) )) dθ = h * (m-1)! / (( h + s )^m )

(remember; all numbers positive and m is an integ ...[text shortened]... [/i] integral, providing it is non-negative, in the future and that should speed up my research!
You've changed the definition of the integral relative to the OP. In this post you have:

∫[0, ∞] h (θ^(m-1)) / ( e^( θ*(h + s) )) dθ

But in the OP you had:

∫[0, ∞] h (θ^m) / ( e^( θ*(h + s) )) dθ

Which explains the difference between the definition of m in our two answers.
15. 08 Mar '16 09:113 edits
Originally posted by DeepThought
You've changed the definition of the integral relative to the OP. In this post you have:

∫[0, ∞] h (θ^(m-1)) / ( e^( θ*(h + s) )) dθ

But in the OP you had:

∫[0, ∞] h (θ^m) / ( e^( θ*(h + s) )) dθ

Which explains the difference between the definition of m in our two answers.
Oh damn! You are right. And that was a misprint in my OP and which I propagated throughout my earlier workings causing me (and you ) confusion. Terribly sorry about that. My fault. That should have been;

∫[0, ∞] h (θ^(m-1)) / ( e^( θ*(h + s) )) dθ

I will now systematically iterate through all my files to correct that edit error wherever I have propagated it -that could take me hours.