3
$\begingroup$

Does anyone know why a plot of a hypergeometric function turns out differently in Mathematica than in Maple?

The function I'm plotting between x=-30 and +30 is:

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])]

where q=p=3, v=1, A=0.5+0.5I and B=-1+I.

I've attached both plots from Maple (first image) and Mathematica (second image)

Maple plot

Mathematica [;pt

$\endgroup$

1 Answer 1

8
$\begingroup$

This seems to be a numerical issue. The first step in cases like this is to re-write your problem in terms of exact rather than approximate numbers. This basically boils down to replacing all instances of 0.5 with 1/2:

f[x_] := Re[Exp[-2 I p x]*(Conjugate[A] Cosh[q - x]^(v + 1) Hypergeometric2F1[
    1/2 (v + 1 - I), 1/2 (v + 1 + I), 1/2, -Sinh[q - x]^2] + 
  Conjugate[B]*
   Cosh[q - x]^(v + 1) Sinh[q - x] Hypergeometric2F1[
    1/2 (v + 1 - I) + 1/2, 1/2 (v + 1 + I) + 1/2, 
    3/2, -Sinh[q - x]^2])*(A*Cosh[q + x]^(v + 1)*
   Hypergeometric2F1[1/2 (v + 1 + I), 1/2 (v + 1 - I), 
    1/2, -Sinh[q + x]^2] + 
  B*Cosh[q + x]^(v + 1) Sinh[q + x] Hypergeometric2F1[
    1/2 (v + 1 + I) + 1/2, 1/2 (v + 1 - I) + 1/2, 
    3/2, -Sinh[q + x]^2])];

p = 3; q = 3; v = 1; A = 1/2 + 1/2*I; B = -1 + I;

We can see right away that there are some numerical issues:

In[7]:= N[f[21], 50]

(* 0.73319032007329183856302280309650876469026021907524 *)

N[f[21]]

(* Indeterminate *)

Therefore, you will likely have to increase the WorkingPrecision of Plot to a larger value. This appears to produce the same result that you got from Maple:

Plot[f[x], {x, -30, 30}, WorkingPrecision -> 50]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.