# Thread: Numerical integration with free parameters, Mathematica

1. ## Numerical integration with free parameters, Mathematica

Hi all!

I am trying to compute improper integrals as a function of additional parameters, where the integrand contains a special function, e.g.:

$f(a,t) := \int_0^{\infty}e^{-aq^2}S(a,q,t)dq$

where S(a,q,t) is the Mathieu sine (solution to Mathieu's ODE), cf:

Mathieu function - Wikipedia, the free encyclopedia

This special function is implemented in Mathematica under
MathieuS[a, q, t]
I am interested in the (approximate) dependence of the above improper integral on the parameters a and t. Since the integration is not possible analytically, I tried to do it numerically using
NIntegrate
but got an error, since I use parameters in the integrand and not numbers.

Is there any way of getting the a and/or t dependence of such a function numerically? Taylor or Fourier expansions of them /to an arbitrary order/ are absolutely sufficient

With regards,
marin

2. Why not just do

f[a_,t_]:=NIntegrate[Exp[-a q^2] MathieuS[a,q,t],{q,0,Infty}]?

(Your definition as f(q) is, perhaps, not terribly good, because the q is the dummy variable of integration!). Also, note that "Infty" stands for infinity. You should use the actual symbol, because "Infty" is not recognized as an appropriate upper limit of integration. I'm forgetting what the text version of Infinity is, since I always use the symbol from the palette.

Now you can do plots or whatever you like with f.

3. Ackbeet, thanks for pointing it out, I also meant f(a,t) - the above post is now edited

You should use the actual symbol, because "Infty" is not recognized as an appropriate upper limit of integration
Thanks for the hint

You're right that I can do plots with f, however I do not have an approximate expression for it, so I cannot make any analytical statement regarding the parameters a, t, which I would very much like to.

It's almost sure, that f(a,t) may not be obtainable in terms of analytic functions, but I still have hopes for series Is there any way to do this?

The main problem comes from the fact that I don't have the series expansions for the general Mathieu functions - I still wonder how they defined them in Mathematica at all..

However, if I could do some kind of parametric plot of f, so that I can plot it against the one variable, say, a and vary t, this would also be very nice too but I'm not sure if it's possible

4. The link at MathWorld indicates that an analytic representation of the Mathieu functions "presents great difficulties".

Are you sure you need to bark up this tree? What is the original problem? What are you ultimately trying to do?

5. I embarked on a problem of one-dimensional electrons subjected to a periodic potential, where the Mathieu eq. arises naturally.

However, in order to compute the physically relevant quantities calculations of the above type have to be done.

I also solved the equation approximately using perturbation theory, but then I noticed that it has its own name and the special solutions are implemented in the specific software, so now what I want to do is be as exact as possible.

6. I'm guessing you're solving the Schrödinger equation in 1 dimension, then? Yeah, I can see how you'd get the Mathieu equation from the separation of variables. Like I said, though, I think you'd have a hard time getting a full series solution. You could always try, though. You could implement a series solution of the original Mathieu DE, substituting in the series expression for the cosine function. It'd be fairly messy, I think, but it is, in theory, doable. Have fun with that!

7. The point is, by plugging in the ODE a general Fourier expansion I only get a recursion formula for the coefficients which I cannot solve, the formula reads:

$A_n = Q/2\frac{A_{n+2}+A_{n-2}}{n^2-a}$

Q, and a the constants from the ODE - these are parameters which in my case will depend analytically on 'q' and this is the variable I want to integrate out

does anyone know an analytical way of solving the recursion and thereby defining the coefficients - I guess it won't be doable this way?

Maybe someone knows another way helping me with the initial issue?

8. I'm not up enough on the theory of recurrence relations to be able to solve that. RSolve in Mathematica balks at solving it, as does WolframAlpha. I'm afraid I'm out of ideas. Sorry about that.

9. Well, after all, no one ever expected me to solve this recurrence relation - the mankind couldn't do it in the last 200 years..

But I am really impressed how poor the Mathieu functions are indeed understood - I could only find the series expansions in certain limits although various papers and books have been published on this topic through the years. And they still keep on popping up in most natural situations.

I guess I'm back to good old perturbation theory now

Thanks a lot for the help, Ackbeet!

10. You're welcome for whatever help I could provide.