-1
$\begingroup$
P = 0;
l = 0;
x = 4;
κ = 0.01;
n = 5;
q = (κ*n)/2;

Do[Q = (Exp[((-I)*(MathieuCharacteristicA[ν, q] - x^2/4)*(τ/2))])*
       (Integrate[
         (Exp[(-I)*(l - x/2)*(θ)])*(Exp[(I)*(ν)*(θ)])*
         (MathieuC[MathieuCharacteristicA[ν, q], q, θ]),
         {θ, 0, 2 π}
        ])*
       (Integrate[
         (Exp[(I)*(y - x/2)*(z)])*(Exp[(-I)*(ν)*(z)])*
         (MathieuC[MathieuCharacteristicA[ν, q], q, z]),
         {z, 0, 2 π}
        ]);
  P = P + Q, 
  {y, 0, 8, 2}, {ν, 6, 14, 2}
];

Q1 = N[P]

I get error when I get numerical value. But there is no error until value of y is in range 0 to 6. As it increases from 6 to 8, I get the error. When I tried max recurssion limit of 12, I see a "not machine sized integer" error.

Please help.

| improve this question | | | | |
$\endgroup$
  • 1
    $\begingroup$ Please format your code and question to make it more readable. Help on editing can be found using the button on the top right of the edit box. $\endgroup$ – Sjoerd C. de Vries May 15 '15 at 12:49
  • $\begingroup$ is it ok now? Actually i am new and i m too much confused :( $\endgroup$ – Amrat Butt May 15 '15 at 13:02
  • $\begingroup$ I formatted your code. Please take note of how it should be, because your complicated expression was a real nuisance to indent properly, especially given how many extraneous parentheses you have. You are doing numerical integration completely wrongly. You should use NIntegrate. Additionally primed symbols mean derivatives in Mathematica, so you should get rid of those. $\endgroup$ – Oleksandr R. May 15 '15 at 13:21
  • 2
    $\begingroup$ There are problems with MathieuC, not sure if related $\endgroup$ – Histograms May 15 '15 at 13:49
  • $\begingroup$ primed symbol is just to differentiate otherwise these are not derivatives $\endgroup$ – Amrat Butt May 15 '15 at 17:13
3
$\begingroup$

Sometimes it is just a matter of adjusting the options. Here is a modification of your code that gives an answer fairly quickly and without any messages, using NIntegrate and some of its options:

P = 0;
l = 0;
x = 4;
κ = 0.01`20; (* note increased precision *)
n = 5;
q = (κ*n)/2;

Do[Q = Exp[((-I)*(MathieuCharacteristicA[ν, q] - x^2/4)*τ/2)]*
       NIntegrate[
        Exp[(-I)*(l - x/2)*θ]*Exp[I*ν*θ]*
        MathieuC[MathieuCharacteristicA[ν, q], q, θ],
        {θ, 0, 2 π},
        WorkingPrecision -> 20
       ]*
       NIntegrate[
        Exp[I*(y - x/2)*z]*Exp[(-I)*ν*z]*
        MathieuC[MathieuCharacteristicA[ν, q], q, z],
        {z, 0, 2 π},
        WorkingPrecision -> 20,
        Method -> {"GlobalAdaptive", Method -> "ClenshawCurtisOscillatoryRule"}
       ];
  P = P + Q, 
  {y, 0, 8, 2}, {ν, 6, 14, 2}
];

Q1 = P

I will not copy its result here, since you can easily run it for yourself. Although it gives an output without any complaints, what I cannot tell you is whether that result is anything like correct given other trouble observed with MathieuC under similar circumstances. Hopefully you will be able to tell whether or not the answer it provides is what you expected.

| improve this answer | | | | |
$\endgroup$
  • $\begingroup$ Its not correct because i have to further increase value of y in even integars and value of k will also be changed then it again gives error. $\endgroup$ – Amrat Butt May 16 '15 at 6:04
  • $\begingroup$ @AmratButt well, you will forgive me for not updating the answer if you don't say what the messages were, how large y you are interested in, or how κ is supposed to be changed. I will just note that I was able to go up to (at least) y = 16 with no messages by further adjusting the options. Please tell me that you did not just post your comment here at the first sign of trouble without having investigated other options settings yourself? $\endgroup$ – Oleksandr R. May 16 '15 at 17:17
  • $\begingroup$ k can vary from 0.01 to 1000 and values of y can go up to infinity because its sum But why its giving error i couldnot understand this thing $\endgroup$ – Amrat Butt May 17 '15 at 6:24
  • $\begingroup$ thanks for the cooperation and our help @Olesksandr R. $\endgroup$ – Amrat Butt May 17 '15 at 6:25

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