Re: Mathieu function zeros
- To: mathgroup at smc.vnet.net
- Subject: [mg108166] Re: Mathieu function zeros
- From: becko BECKO <becko565 at hotmail.com>
- Date: Tue, 9 Mar 2010 06:26:41 -0500 (EST)
Thanks a lot. This is VERY useful. As you said, I extended it to handle the other Mathieu's and it worked very well. I think the only issue is that this method doesn't detect zeros where the graph doesn't cross the axis (it doesn't detect the zero of x^2, but it does detect the zero of x^3). This is not an issue with Mathieu functions. But it would be nice if one could exploit the inner workings of Plot a bit more to detect zeros that are not crossings. Any ideas? > Date: Thu, 4 Mar 2010 05:31:00 -0500 > From: pfalloon at gmail.com > Subject: [mg107987] Re: Mathieu function zeros > To: mathgroup at smc.vnet.net > > On Mar 3, 9:53 pm, becko BECKO <becko... at hotmail.com> wrote: > > Hi. I'm doing some work with Mathieu functions and I need to know the zeros > > of these functions (MathieuC, MathieuS, MathieuCPrime, MathieuSPrime). This doesn't seem to be implemented in Mathematica (as opposed to Bessel functions, where there is a package that calculates the zeros). > > > > Can someone tell me where can I find any implementation of this? > > > > Or perhaps point me in some direction as to how I can get started in implementing it myself? > > The built-in function FindRoot will readily compute the zeros to > whatever precision you need. You just need to specify one or two > starting guesses. > > If you need to find all zeros in a fixed domain (e.g. the interval 0 > <= x <= Pi), a neat trick is to leverage the Plot function's adaptive > capabilities (i.e. computing sufficient points to capture the > structure of interest) to get the approximate locations of the zeros, > then refine these using FindRoot. > > Here is a simple implementation: > > mathieuCZeros[r_,q_] := Module[{ce, lineElts, crossings, z}, > (* define ce function *) > ce[z_] := MathieuC[MathieuCharacteristicA[r,q], q, z]; > (* get line elements from plot *) > lineElts = Cases[Plot[ce[z], {z,0,Pi}], Line[___], Infinity][[1,1]]; > (* get x values on either side of all zero crossings *) > crossings = Select[Partition[lineElts,2,1], Sign[#[[1,2]]] == - > Sign[#[[2,2]]] &][[All,All,1]]; > (* find zeros between each crossing using secant method *) > z /. FindRoot[ce[z], {z,#1,#2}] & @@@ crossings > ]mathieuCZeros[r_,q_] := Module[{ce, lineElts, crossings, z}, > (* define ce function *) > ce[z_] := MathieuC[MathieuCharacteristicA[r,q], q, z]; > (* get line elements from plot *) > lineElts = Cases[Plot[ce[z], {z,0,Pi}], Line[___], Infinity][[1,1]]; > (* get x values on either side of all zero crossings *) > crossings = Select[Partition[lineElts,2,1], Sign[#[[1,2]]] == - > Sign[#[[2,2]]] &][[All,All,1]]; > (* find zeros between each crossing using secant method *) > z /. FindRoot[ce[z], {z,#1,#2}] & @@@ crossings > ] > > > This can be extended as required to handle MathieuS, other domains, > higher precision, possible zeros on boundaries, etc. > > Cheers, P.