Algorithms for comon things

1. Jun 17, 2007

ice109

what are some for evaluating logs? square roots? trig functions? this makes me curious

obviously i don't intend to be gauss but it made me realize these things are never taught and just taken for granted. and obviously im not talking about
$$log_{10}(100)$$ maybe something like to a rational number.

actually now that im thinking about it you could just solve the series expansion for the first couple of terms for the exponential but theres gotta be a better way.

2. Jun 17, 2007

Nasta

That is an interesting topic, I am too, interested in such algorithms, as using calculator for some simple or not so simple calculations is a distraction for what can be a fluent flow of thoughts.

Anyway, a little contribution from me: my father showed me this little trick and I have not to this day even tried to see why it works, but frequently use it. It is a quick multiplication rule for squaring numbers which have last digit 5. The rule is as follows:
Multiply the "first" part (the non-five part) of the number with the following integer and then simply put 25 at the end. i.e. 15 x 15 = 1x2|25 = 225; 25 x 25 =2x3|25 = 625; 35 x 35 = 3x4|25 = 1225; 125 x 125 = 12x13|25 = 15625 and so on, you get the idea.

As I said, I've used this method frequently in my school years, but I had never thought why this works the way it does to this very day. So, feel free to use it from now on and if anyone has any hints on why it works that way it will be appreciated.

Also any hints for algorithms to other easy or not so easy calculations will be appreciated.

Last edited: Jun 17, 2007
3. Jun 17, 2007

BSMSMSTMSPHD

It works like this. Think of the number as $$k5$$ where $$k$$ represents the digits in front of the 5.
Then, we can write the value of the number as $$10k + 5$$.

Squaring the number gives us: $$(10k + 5)^{2} = 100k^{2} + 100k + 25$$.

But, this can be factored: $$100k(k + 1) + 25$$.

And there it is.

4. Jun 17, 2007

chroot

Staff Emeritus
You're looking for the Numerical Recipes books. They're available in their entirety here:

Numerical Recipes Online

You might be most interested in the Newton-Raphson method, which is the numerical approximation algorithm used by most pocket calculators.

- Warren

5. Jun 18, 2007

Nasta

simple and beautiful. thank you.

6. Jun 24, 2007

mongoose

Nice! very cool

7. Jun 26, 2007

Gib Z

sometimes a good taylor series is all you need though. most trig functions i quickly use a 3 term expansions, but if its close to some exact value eg sin 61 degrees, then i use the expansion to sin (x+y) and use the small angle properties. its actually accurate. for logs i define them as the area under 1/x blah blah, and for that i use simpsons rule a few times. square rooting, usually newton-rhapson method. for large factorials theres stirlings approximation.