Apollo 11 implementation of Trigonometric functions (1969)
fermatslibrary.com
fermatslibrary.com
Margaret Hamilton has stated that her first assignment was the abort code FORGETIT in the Apollo 5 program Sunburst, and this exact single-precision sine/cosine routine already existed in Aurora [an earlier version of the software] earlier than March 1966 -- FORGETIT wasn't added to Sunburst until later that year (maybe October-November).
Source: I talked to people who have researched the Apollo code in detail. For more information on the Apollo software releases, see: https://www.ibiblio.org/apollo/Luminary.html
This is a work-in-progress disassembly of the core rope modules we dumped at the MIT Museum, so apologies for the less friendly formatting!
I read that as some indication as to the correctness of the claim that this is what was used (a bit like the difference between an email from Linus claiming something about early Linux and a thread on Reddit where X claims his neighbor knows somebody whose nephew worked with Linus, and had this on an old floppy, believing it to apply to early Linux)
Funny how these pioneers wrote bulletproof raw machine code and assembly, while today we have a slew of code analysis tools and "safe" programming languages, but everything still crashes six ways from Sunday.
How would these coefficients be derived in the first place?
+ 1/2 * sin(x * pi / 2)
+ 0.785313 * x - 0.321615 x^3 + 0.0363551 x^5
If you want to play with this sort of thing and you have access to a copy of Matlab, check out Chebfun, https://www.chebfun.org/examples/approx/
Now you just take the dot product of these new basis vectors with your target function.
The CPU has onle accumulator which instructions act on. The argument is normally an address. The relevant instructions for this code snippet is:
AD - Add the value pointed to by the argument to the accumulator
TS - Transfer to storage. Write the accumulator to the argument
TCF - Transfer control to fixed memory. Jumps to an instruction in fixed storage
DOUBLE - Assembler macro compiling to AD A. I.e. double the accumulator.
XCH - This exchanges the value in the accumulator with the argument
INDEX - Adjust the address used in the next instruction by the argument
COM - Complements the accumulator. Note that the AGC uses one's complement arithmetic, so this negates the value.
EXTEND - Indicate that the next instruction is an extended instruction
MP - Multiply the accumulator with the argument
The final instruction is TS Q which jumps to the location stored in the Q register. This is the return address which is updated by the TS instruction. In other words, TS can be used both as a regular jump as well as being used as a function call, depending on what the destination does with the Q register.
I hope this helps you analyse the code further. I haven't spent much time looking at the code itself, so I am not going to attempt an analysis right now.
Of course, in many places in the code you need values outside of this range and the actual number represented is scaled by some factor. However, the CPU has no internal representation of the scale factor (i.e. the exponent bits in a floating point number) so the programmer had to manually manage this.
I can strongly recommend this book, if you're interested in the AGC: http://www.apolloguidancecomputer.com/
https://news.mit.edu/2016/scene-at-mit-margaret-hamilton-apo...
Scan of Luminary - Lunar Module source code https://archive.org/details/Luminary99001J2k60/page/n979/mod...
Sollya has a great Remez implementation as well as a proven supremum norm (maximum error). I combined it with more traditional “loop over all 32-bit float values to also test my range reduction”, but being able to choose your error and number of coefficients is nice!
"The Apollo Guidance Computer: Architecture and Operation"