Double Integral of a function that contains factorials

1 view (last 30 days)
I have never used Matlab and I need to know if it could help me to solve a particular double integral over a general region where the function contains the factorial of one or both variables. I have attached an example. Obviously a, b, c, s, t and q can be immediately substituted by real numbers as I need just the outcome of the double integral. Thank you all in advance for your kind support.
  2 Comments
John D'Errico
John D'Errico on 28 Aug 2018
@Stefano Innocenti
Please do not add an answer to your question, just to make a comment. I've moved your answer to a comment here:
"Misfortunately, I cannot upload the file in question, as I am not yet a Matlab user with the software already installed on my PC. I only need to know if the problem described above can or cannot be solved by using Matlab."

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 28 Aug 2018
Edited: John D'Errico on 28 Aug 2018
This is not really a question about MATLAB, but of mathematics in general.
The problem with your integral is factorials are not defined on the real line. So you cannot compute factorial(2.37) as a number. That means the integral you show is not a meaningful one, UNLESS you use the gamma function to extend factorials into the real line. That is, for integer n, we know that
gamma(n+1) == factorial(n)
We can test that for a few small integers.
gamma(5)
ans =
24
factorial(4)
ans =
24
This extension is fairly well known. The nice thing is that gamma IS defined for general real input. So, if we wanted to compute factorial(2.37), if that function had a valid meaningful, consistent output, it would logically be
gamma(2.37 + 1)
ans =
2.88751202727155
So, the answer is, yes, MATLAB can (in theory) compute the integral you show, IF you replace the factorial(y) term with gamma(y+1).
There are caveats of course. For large inputs, the factorial function grows to be immensely huge. So depending on your limits of integration, you might easily cause an overflow of double precision arithmetic. That would potentially cause your integration to start spewing garbage results.
That is, factorial(n) overflows double precision when n exceeds 170.
factorial(170)
ans =
7.25741561530799e+306
factorial(171)
ans =
Inf
And then, if your function happens to have a ratio of two infs, a difference of infs, etc., that operation is indeterminate, so it results in a NaN.
inf/inf
ans =
NaN
inf - inf
ans =
NaN
So depending on your limits of integration, you might start generating NaNs. (I'm just trying to forestall your next question on Answers, when you actually tried to write code.) So be careful, IF those limits of integration might be large.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!