Im attempting to plot a hypergeometric function with complex arguments. I know that this function is defined over all the reals. However, according to Mathematica, the function become indeterminate by x=+20 and x=-20. Ive attempted to change the workingprecision option of plot to a value of 2000, but the function is still shown to be indeterminate by x=-2500 and x=+2500. Is there a way that I can change this?
q = 3
p = 3
v = 1.1
A = 0.5 + 0.5 I
B = -1 + I
Plot[Re[Exp[-2 I p x]*(Conjugate[A]*Cosh[q - x]^(v + 1)* Hypergeometric2F1[0.5 (v + 1 - I), 0.5 (v + 1 + I), 1/2, -Sinh[q - x]^2] + Conjugate[B]*Cosh[q - x]^(v + 1)*Sinh[q - x]* Hypergeometric2F1[0.5 (v + 1 - I) + 0.5, 0.5 (v + 1 + I) + 0.5, 3/2, -Sinh[q - x]^2])*(A*Cosh[q + x]^(v + 1)* Hypergeometric2F1[0.5 (v + 1 + I), 0.5 (v + 1 - I), 1/2, -Sinh[q + x]^2] + B*Cosh[q + x]^(v + 1)*Sinh[q + x]* Hypergeometric2F1[0.5 (v + 1 + I) + 0.5, 0.5 (v + 1 - I) + 0.5, 3/2, -Sinh[q + x]^2])], {x, -30, 30}]
Your input for the plot uses machine precision numbers. So, increasing working precision does not really help.
More importantly you are plotting a sum of rapidly growing terms which mostly cancel. As a consequence the precision of the output decays rapidly. (If you plot Precion you will see it declines linearly.) When it reaches zero Mathematica will return Indeterminate. My advice, rewrite your function in a way that the individual terms are not manifestly divergent.
Thanks for your advice. In general, how do I rewrite a function so its terms are not manifestly divergent? Do I use Simplify, FullSimplify, FunctionExpand, or a similar command?
Looking at it more closely, the problem runs deepers than I originally thought. The loss of precision is not due to a cancelation of terms, but due to Mathematica’s evaluation of the 2F1’s. This should not normally happen because for Mathematica’s Hypergeometric functions “The precision of the output tracks the precision of the input” (according to the documentation).
Why it doesn’t do it in this particular case is somewhat of a mystery, as it could easily switch to evaluating the asymptotic expansion for large arguments. (Which is what it does for most other combinations of the parameters.)
I’ve modified my approach so I just look at functions of x and worry about q and p later. I think that if I get this sorted out, including q and p will work. I attempted to graph the hypergeometric function between x=-10 and +10 and the asymptotic expansion for the rest of the values. However, even though I used the unit step function, I’m still getting the combined functions to be indeterminate by x=+20 and x=-20. Changing the workingprecision option will allow me to delay the indeterminacy but it still eventually occurs no matter how large workingprecision is. The first image shows just the asmyptotic expansions while the second image shows the asmyptotic expansion combined with the hypergeometric function. (In this case, v=1 but changing the values of v will have little impact on the function being indeterminate or not.)
Your most recent example contains the undefined symbols u1 and u2. This prevents Plot from plotting anything outside of the -10 to 10 range. Since your image also did not get posted, it is difficult to say what is happening.
I did put in some random values for u1 and u2, and everything seemed to be working well as long as I made sure that all my inputs were exact numbers and made the WorkingPrecision reasonably high.
As Brett indicated, solving numerical problems like this is generally a two step process. You must remove all floating point numbers from your input, and then use the WorkingPrecision option. In your most recent example, your input includes floating point numbers, so simply increating the WorkingPrecision is not going to suffice. Please see the following for a brief discussion on exact vs approximate (or floating point) numbers:
John you tried to upload images in .PDF format - this is why they are not displayed. Could you please re-upload them in .PNG or .JPG or .GIF formats - as you did in your original post?