Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Algorithms for comon things

  1. Jun 17, 2007 #1
    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
    [tex]log_{10}(100)[/tex] 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. jcsd
  3. Jun 17, 2007 #2
    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
  4. Jun 17, 2007 #3
    It works like this. Think of the number as [tex]k5[/tex] where [tex]k[/tex] represents the digits in front of the 5.
    Then, we can write the value of the number as [tex]10k + 5[/tex].

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

    But, this can be factored: [tex]100k(k + 1) + 25[/tex].

    And there it is.
  5. Jun 17, 2007 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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
  6. Jun 18, 2007 #5
    simple and beautiful. thank you.
  7. Jun 24, 2007 #6
    Nice! very cool
  8. Jun 26, 2007 #7

    Gib Z

    User Avatar
    Homework Helper

    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.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Algorithms for comon things
  1. Search algorithm (Replies: 14)

  2. Math algorithm (Replies: 5)

  3. Nesting Algorithm (Replies: 1)