Skip to content

Comment on Speeding up atan2f

Comments

Around 1988, I added phase shift to my optical thin film design program written in Excel 4.0 for the Mac. At the time, this was utterly unique: each spreadsheet row represented a layer and the matrices describing each layer could be calculated right in that row by squashing them down horizontally. The S- and P-polarization matrices could be recorded this way, and the running matrix products similarly maintained. Finally, using a simple one input table, the reflectance of a typically 25-31 layer laser mirror could be calculated. And in less than a second on a 20 MHz 68020 (?) Mac II for about 50 wavelengths. The best part were the graphics which were instantaneous, beautiful, publishable, and pasteable into customer quotations. Semi-technical people could be trained to use the whole thing.

Now about the phase shift. In 1988, atan2 didn’t exist. Anywhere. Not in FORTRAN, Basic, Excel, or a C library. I’m sure phase shift calculators implemented it, each working alone. For us, it was critical. You see we actually cared not about the phase shift, but its second derivative, the group delay dispersion. This was the beginning of the femtosecond laser era, and people needed to check whether these broadband laser pulses would be inadvertently stretched by reflection off or transmission through the mirror coating. So atan2, the QUADRANT-PRESERVING arc tangent, is required for a continuous,differential phase function. An Excel function macro did this, with IF statements correcting the quadrant. And the irony of all this?

I CALLED it atan2.

Fortran did have it much earlier. Per wikipedia atan2 appeared in Fortran IV from IBM in 1961. https://en.wikipedia.org/wiki/Atan2

And it's been in every ANSI & ISO Fortran standard from F'66 through F'2018.

Nice find. Anyone have a way to search for old versions "math.h"? The 1989 version of ANSI C had atan2:

https://web.archive.org/web/20161223125339/http://flash-gord...

...but I wonder when it first hit the scene.

According to https://unix.superglobalmegacorp.com/ it was in 3bsd libm -https://unix.superglobalmegacorp.com/cgi-bin/cvsweb.cgi/3BSD...

3BSD was released at the end of 1979 according to wikipedia, and that's just the oldest BSD source I could find, so it may have been in even older versions.

Before ANSI/ISO C I don't think there was really a "math.h" to look for - as it may be different on different systems, but as so many things derive from BSD I wouldn't be surprised if it was "de-facto" standardised to what that supported.

Around 1988, I added phase shift to my optical thin film design program written in Excel 4.0 for the Mac.

Excel 4 was released in 1992. In 1988 the only version of Excel that would have been available on the Mac would be the very first one.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.