Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mathieu function zeros

62 views
Skip to first unread message

becko BECKO

unread,
Mar 3, 2010, 5:53:03 AM3/3/10
to
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?

dh

unread,
Mar 4, 2010, 5:25:22 AM3/4/10
to
Hi,
if a numerical solution is good enough, you can use "FindRoot". The
approx. start values you can get from a plot.
Daniel


--

Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:d...@metrohm.com>
Internet:<http://www.metrohm.com>


gekko

unread,
Mar 4, 2010, 5:31:14 AM3/4/10
to

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.

becko BECKO

unread,
Mar 9, 2010, 6:24:46 AM3/9/10
to
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: pfal...@gmail.com
> Subject:
Re: Mathieu function zeros
> To: math...@smc.vnet.net

gekko

unread,
Mar 10, 2010, 1:44:38 AM3/10/10
to
On Mar 9, 10:24 pm, becko BECKO <becko...@hotmail.com> wrote:
> 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?


One quick way would be too identify all local extrema within the plot
and test whether they are really zero. The following is a skeletal
implementation for minima (can be easily extended to cover maxima):

(* define a test function *)
f[x_] := Sin[x]^2

(* define domain *)
{xmin, xmax} = {0, 10*Pi};

(* get points from plot *)
pts = Cases[Plot[f[x], {x,xmin,xmax}], Line[___], Infinity][[1,1]];

(* define functions to test if middle point of a triple is a minimum
*)
minCheck = #[[2,2]]<#[[1,2]] && #[[2,2]]<#[[3,2]] &;

(* get local minima *)
minPts = Select[Partition[pts, 3, 1], minCheck][[All,All,1]];

(* refine minima to higher accuracy and get in the form (xmin, fmin)
*)
minSols = {x/.#[[2,1]], #[[1]]} & /@
(FindMinimum[f[x], {x, #[[1]], #[[3]]}] & /@ minPts);

(* get a reference value to determine the "scale" of the function *)
refVal = Max[Abs[pts[[All,2]]]];

(* select those minima which are essentially zero according to the
scale of the plot *)
zeros = Select[minSols, PossibleZeroQ[#[[2]]+refVal-refVal] &][[All,
1]]

Plot[f[x], {x,xmin,xmax}, Epilog->{Red, PointSize[0.02], Point[{#,0}]&/
@zeros}]


Cheers, P.

PS: in my previous response I was remiss in neglecting to mention that
I originally got the idea of using Plot in this way from Paul Abbott:

http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/1c124ca5e6a0d665/29c24748f126855e?lnk=gst&q=paul+abbott+rootsinrange#29c24748f126855e

David Park

unread,
Mar 10, 2010, 1:46:37 AM3/10/10
to
If I remember correctly Ted Ersek's RootSearch package (from the WRI site)
does pick up non crossing zeros. However, the package has not been updated
for Version 6 and 7. As a result it gives a warning message (that can be
suppressed with Quiet) but otherwise works.

Ted's routine is extremely convenient for searching for zeros along a real
line. It gets all the zeros, crossing and non-crossing, in order within an
interval. It is a specialized but common case of the FindRoot functionality
and Mathematica has nothing like it. It really should be an optional method
for FindRoot.


David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/


From: becko BECKO [mailto:beck...@hotmail.com]

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: pfal...@gmail.com
> Subject:
Re: Mathieu function zeros
> To: math...@smc.vnet.net
>

> On Mar 3, 9:53 pm, becko BECKO <becko...@hotmail.com>
wrote:

Ted Ersek

unread,
Mar 13, 2010, 8:00:23 AM3/13/10
to

David Park posted a message on 10 March, 2010 where he mentioned using
my RootSearch package for problems such as finding roots of Mathieu
functions.

David was right that RootSearch is very good at finding zeros where a
function does not change sign. If you have a specific example that is a
problem send me an email at ( Ted....@navy.mil ) and I will trouble
shoot.

David was also right that the message about setting $MinPrecision to
(-Infinity) can be ignored.

I am almost finished with an upgrade to the package that accounts for
several changes in Mathematica since the package was last updated. I
expect to have the new package posted on MathSource within a week.

You can always find the package by searching for "RootSearch" at
http://library.wolfram.com/


Regards,
Ted Ersek

Get my popular Mathematica Tips and Tricks from
http://library.wolfram.com/infocenter/MathSource/4557/

Note: My Tips, Tricks are still relevant, but haven't been updated
since May, 2004.

0 new messages