ComplexInfinity encountered in Mathematica

  • Mathematica
  • Thread starter EngWiPy
  • Start date
  • Tags
    Mathematica
In summary, the conversation discusses an error encountered when running a segment of code and the solution to add an If statement to handle undefined values. The discussion also mentions the importance of defining the domain for a function and finding the limit to overcome errors in calculations. The purpose of the code is to compute the Moment Generating Function for a wireless communication system.
  • #1
EngWiPy
1,368
61
Hello,

I have the following segement of code:

Code:
IA1[N_, k_, n_, sig_, al_] := (
   Sqrt[Pi]*(4*al)^(n + 1))/(sig - s + (2*al))^(NA + k + n + 1)*(
   Gamma[N + k + n + 1]*Gamma[N + k - n - 1])/Gamma[N + k + 0.5]*
   Hypergeometric2F1[N + k + n + 1, n + 1.5, N + k + 0.5, (
    sig - s - 2*al)/(sig - s + 2*al)];
IA2[N_, k_, n_, sig_, al_] := (Sqrt[Pi]*(4*al)^n)/(sig - s + (2*al))^(
   NA + k + n + 1)*(Gamma[N + k + n + 1]*Gamma[N + k - n + 1])/
   Gamma[N + k + 1.5]*
   Hypergeometric2F1[N + k + n + 1, n + 0.5, N + k + 1.5, (
    sig - s - 2*al)/(sig - s + 2*al)];
IA[N_, k_, n_, sig_, al_] := 
  2*(N + k - n - 1)*IA1[N, k, n, sig, al] - 
   sig*D[IA1[N, k, n, sig, al], s] - 2*al*IA2[N, k, n, sig, al];

and when I run it, the following error appears:

Code:
\[Infinity]::indet: Indeterminate expression 0 ComplexInfinity \
encountered. >>

\[Infinity]::indet: Indeterminate expression 0 ComplexInfinity \
encountered. >>

\[Infinity]::indet: Indeterminate expression 0 ComplexInfinity \
encountered. >>

But I didn't find a situation where we can get ComplexInfinity. Can anyone help me, please?

Note: the minimum value for N=1, K=0, n=0, and sig and al are essentially greater than zero
 
Last edited:
Physics news on Phys.org
  • #2
Hi S_David,

S_David said:
Hello,

I have the following segement of code:

Code:
IA1[N_, k_, n_, sig_, al_] := (
   Sqrt[Pi]*(4*al)^(n + 1))/(sig - s + (2*al))^(NA + k + n + 1)*(
   Gamma[N + k + n + 1]*Gamma[N + k - n - 1])/Gamma[N + k + 0.5]*
   Hypergeometric2F1[N + k + n + 1, n + 1.5, N + k + 0.5, (
    sig - s - 2*al)/(sig - s + 2*al)];
IA2[N_, k_, n_, sig_, al_] := (Sqrt[Pi]*(4*al)^n)/(sig - s + (2*al))^(
   NA + k + n + 1)*(Gamma[N + k + n + 1]*Gamma[N + k - n + 1])/
   Gamma[N + k + 1.5]*
   Hypergeometric2F1[N + k + n + 1, n + 0.5, N + k + 1.5, (
    sig - s - 2*al)/(sig - s + 2*al)];
IA[N_, k_, n_, sig_, al_] := 
  2*(N + k - n - 1)*IA1[N, k, n, sig, al] - 
   sig*D[IA1[N, k, n, sig, al], s] - 2*al*IA2[N, k, n, sig, al];

and when I run it, the following error appears:

Code:
\[Infinity]::indet: Indeterminate expression 0 ComplexInfinity \
encountered. >>

\[Infinity]::indet: Indeterminate expression 0 ComplexInfinity \
encountered. >>

\[Infinity]::indet: Indeterminate expression 0 ComplexInfinity \
encountered. >>

But I didn't find a situation where we can get ComplexInfinity. Can anyone help me, please?

Note: the minimum value for N=1, K=0, n=0, and sig and al are essentially greater than zero

Inside IA1 you have:

Code:
Gamma[N+k-n-1]

which for the values you are using becomes Gamma[0].
 
  • #3
Wow, you are absolutely right. I didn't know that Gamma[0] is undefined, too. I thought just for the negative values. In this case we must include an If[] statement for the code to work. Is this a valid step?

Ok, thanks a lot alphysicist, and wish you luck.

Best Regards
 
  • #4
S_David said:
Wow, you are absolutely right. I didn't know that Gamma[0] is undefined, too. I thought just for the negative values. In this case we must include an If[] statement for the code to work. Is this a valid step?

Ok, thanks a lot alphysicist, and wish you luck.

Best Regards

Sure, glad to help!

I'm not sure what you are calculating, so I can't say that an If statement is the right thing to do. I can't see that there is anything wrong with it, though. I have done calculations in the past that blew up at the origin and just did a quick If branch to get through it.
 
  • #5
alphysicist said:
Sure, glad to help!

I'm not sure what you are calculating, so I can't say that an If statement is the right thing to do. I can't see that there is anything wrong with it, though. I have done calculations in the past that blew up at the origin and just did a quick If branch to get through it.

If we have the following expression [tex]f(x)=\frac{1}{\sqrt{x}}[/tex], then the domain must be [tex]x>0[/tex], because for other values the function doen't exist in the real axis. I think we can say the same in my problem, because there is no other way to overcome the problem. I am computing the Moment Generating Function (MGF) to compute the Symbol Error Rate in a wireless communication system.

Thanks.
 
  • #6
S_David said:
If we have the following expression [tex]f(x)=\frac{1}{\sqrt{x}}[/tex], then the domain must be [tex]x>0[/tex], because for other values the function doen't exist in the real axis. I think we can say the same in my problem, because there is no other way to overcome the problem. I am computing the Moment Generating Function (MGF) to compute the Symbol Error Rate in a wireless communication system.

Thanks.

Here's what I essentially did the last time I ran into this type of problem. The problem was essentially along the lines of:

[tex]
f(x)=\frac{1-e^{-x}}{x}
[/tex]

which has a finite limit at [itex]x=0[/itex], but the computer does not want to divide by zero. So I just calculated the limit by hand and put it in an If statement.

However, I did that just because it was straightforward. Your problem looks more difficult, so maybe you would want to see if mathematica can calculate the limit, if that's what needed? Or do you already know the value, or can you just skip that value altogether? Those considerations will tell you the right approach.
 
  • #7
alphysicist said:
Here's what I essentially did the last time I ran into this type of problem. The problem was essentially along the lines of:

[tex]
f(x)=\frac{1-e^{-x}}{x}
[/tex]

which has a finite limit at [itex]x=0[/itex], but the computer does not want to divide by zero. So I just calculated the limit by hand and put it in an If statement.

However, I did that just because it was straightforward. Your problem looks more difficult, so maybe you would want to see if mathematica can calculate the limit, if that's what needed? Or do you already know the value, or can you just skip that value altogether? Those considerations will tell you the right approach.

After double check, the term [tex](N+k-n-1)\ge 0[/tex], because the maximum value of [tex]n[/tex] is [tex]N+k-1[/tex]. I tried to write the limit as [tex]n\longrightarrow N+k-1[/tex] but Mathematica didn't compute it, and gives ComplexInfinity again. I am not sure if I can calculate it manually, it seems complicated.

I don't know where, but I am sure that I have something wrong, because when I run the program, after writting the If statement, I got negative answers, which must not occur in my case, because the SER is in the range of [tex][0,1][/tex] by definition.

Best regards
 

Related to ComplexInfinity encountered in Mathematica

1. What is ComplexInfinity encountered in Mathematica?

ComplexInfinity is a special symbol in Mathematica that represents an infinite complex number. It is often encountered in calculations involving complex numbers where the result is undefined or infinite.

2. How does Mathematica handle ComplexInfinity?

Mathematica treats ComplexInfinity as a special type of number and includes it in its symbolic computations. It has specific rules for dealing with ComplexInfinity in different mathematical operations, such as addition, multiplication, and integration.

3. Can ComplexInfinity be used in mathematical expressions?

Yes, ComplexInfinity can be used in mathematical expressions just like any other number. However, it is important to keep in mind that certain operations with ComplexInfinity may not be well-defined and can result in unexpected outcomes.

4. How can I check for ComplexInfinity in my Mathematica code?

To check for ComplexInfinity in your code, you can use the function InfinityQ, which returns True if the input is ComplexInfinity and False otherwise. You can also use the function Element to check if a certain number is an element of the set of complex numbers.

5. Is there a way to avoid encountering ComplexInfinity in Mathematica?

It is not always possible to avoid encountering ComplexInfinity in Mathematica, as it is a natural result of certain mathematical operations. However, you can use the option Assumptions in some functions to specify assumptions about the variables involved in the calculation, which can help to avoid getting ComplexInfinity as a result.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
6K
  • Differential Geometry
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • Atomic and Condensed Matter
Replies
3
Views
1K
  • Topology and Analysis
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Advanced Physics Homework Help
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
Replies
1
Views
631
Back
Top