Zernike polynomials

So,

I have recently started to work with Zernike polynomials to simulate some optical aberrations.
Igor has the function ZernikeR(n, m, r) in it, but I cannot manage to use it properly. The help section on this topic is quite succint.
This is what I wrote:

Make/O/N=(1024,1024) test
SetScale/I x -511,512,"", test
SetScale/I y -511,512,"", test
Variable n=2
Variable m=1
test=ZernikeR(n,m,sqrt(x^2+y^2))

What would be the appropriate syntax to create a 2D wave of a Zernike polynomial with given n and m?

Thanks.
Naturally the only reference one would have added to the documentation is the bible of Optics (a.k.a. Born&Wolf). Specifically, the expression for the radial polynomial is given in Eq. (5) page 523 (7th ed.)

The main problem with your code is in your wave scaling. The radius should be normalized (0 to 1). Personally I'd do away with the wave scaling and modify your ZernikeR() arguments to the correct normalization.

A.G.
WaveMetrics, Inc.
Thanks A. G. for your help.

I had both a normalization problem, and an inversion between n and m.

Here is my new working code:

Make/O/N=(1024,1024) test
SetScale/I x -1,1,"", test
SetScale/I y -1,1,"", test
Variable n=1
Variable m=2
test=ZernikeR(n,m,sqrt(x^2+y^2))

Here are a few extra comments on practical usage of the Zernike polynomials in Igor:
(1) don't forget to include the angular factor described in the Igor help file and B&W to get the full orthogonal circle polynomials.
(2) if you are applying the polynomials in calculations over a rectangular grid enclosing the unit circle, you will get a lot of NaNs for r>1 (this is what ZernikeR(n,m,r) returns). You can either use logic functions to exclude calculations for r>1, which will probably execute more slowly, or calculate everywhere and remove the NaNs if desired. I find  MatrixOP ReplaceNaNs to be particularly useful for this.