views:

316

answers:

10

For example, how are exponential, logarithm, and trigonometric functions done within the chip on a hand-held calculator?

Where is a good starting place to learn about this?

EDIT: specifically, how could I recreate these functions in software? With the purpose of understanding both the mathematics and the trade-offs in time and complexity for the various methods.

+1  A: 

Please clarify: are you interested in transistor level operation logic, boolean functionality or how to implement a hardware solution in software ?

In case you are interested in the hardware side of the algorithem a good book is

ALGORITHMS AND DATA STRUCTURES IN VLSI DESIGN :OBDD - FOUNDATIONS AND APPLICATIONS Author: MEINEL Publisher: SPRINGER-VERLAG/SCI-TECH/TRADE

Edit:

This essay gives a good perspective and some basic starting points in how things are designed in hardware and will help you understand common algorithms as well as a high level functionality explanation if you want to implement a software solution.

For complete theory please refer to other recommended books.

Roman M
+1  A: 

Sounds like you want to understand how transcendental, trigonometric and similar functions work. These mathematical functions nearly always computed by iterative methods. This is how nearly all calculators, whether hand held or as software, work. The reason is because these functions' mathematical definition do not lend themselves to explicit solutions.

Take for example doing a square root. It is easy to express what a square root is: sqrt(x)*sqrt(x)=x. But to actually find sqrt(x) is difficult, because the equation can not be made explicit. One way to work out sqrt(x) is using Newton's method which makes a guess as to the value of sqrt(x) for each iterations. Each guess is more accurate than the last (under certain conditions, the guesses can get worst). After so many iterations, you have a fairly accurate value for sqrt(x), and by the law of diminishing returns, and it is not longer profitable to keep going. At this point you return the current guess for what value sqrt(x) should be, and often it is Good Enough for mere mortals.

Similar methods are used to calculate exponential, logarithm, and trigonometric functions. For example the arcsin(x) can be calculated using an infinite series. Of course you don't actually sum over infinity, you just go far enough to get the accuracy your data type can hold, and stop there.

There is a measure of how well a series approximate a function, and that is called convergence. If method A converges faster than method B, it means after x iterations, the value method A gives you is more accurate than the value method B gives you. In other words, method A's answer converges to the correct analytical answer faster than B.

That is then the mathematical considerations of methods. When you codify this programmatic considerations come into play - method A might be faster, but costs too much memory, and method B, while slower, is cheaper.

I can't recommend specific books on this, though I would recommend a good maths book (or google) to understand the maths, and a good algorithms book to understand things like complexity.

Cheers,
Steve

freespace
+2  A: 

To understand the theory behind the calculation, check up "series expansion", "Taylor series", "Maclaurin series". Probably any textbook on calculus and analysis covers these topics. This should give you an idea how to construct series converging to a particular function.

The other part (trade offs in time and complexity) is numerical analysis, in particular convergence rate analysis and series acceleration.

The topic is really broad, so these are just the most basic starting points.

Rafał Dowgird
+2  A: 

You'll find the classic book on subject is Handbook of Mathematical Functions by Abramowitz and Stegun which seems to be quoted everywhere, but there are more modern books with software oriented algorithms if you look, for example C/C++ Mathematical Algorithms for Scientists and Engineers

Martin
A: 

Numerical Recipes = famous book, been around for years in various flavors. Not the best source of real hard-core low-level computation of exp, log, sin etc. but enlightening enough for most scientists and engineers who are the audience of the books. The authors have a site at http://nr.com/

DarenW
+2  A: 

There's an important algorithm named CORDIC to compute sine and cosine, and hyperbolic versions of these, and spectacularly suitable for both hardware and software, as i recall. It only shifted and added/subtracted numbers, no multiplying. Try googling for it - there's probably plenty of info.

DarenW
Nice! That is a great start while I am waiting for amazon to ship those books.
TonyOssa
+2  A: 

There is a great book called Inside you Caculator by Gerald Rising which will cover the sort of thing you are looking for. I have a copy in front of me now and it includes things like algorithms for calculating square roots such as Newton's method, binary arithmetic and CORDIC algorithms for calculating trig functions.

MikeCroucher
A: 

Supplanting Numerical Recipes, the GNU Scientific Library is the definitive place to go for C implementations of mathematical algorithms. Chapter 7 of the manual should have all the functions you're looking for.

dreeves
+1  A: 

The classic book:

Hastings, Cecil: Approximations for Digital Computers. Princeton University Press. 1955. http://www.amazon.com/Approximations-Digital-Computers-Cecil-Hastings/dp/0691079145

contains series approximations for many functions together with graphs of error over the range of inputs.