Cities of the Future

If my doctor told me I had only six months to live, I wouldn't brood. I'd type a little faster. - Isaac Asimov

2005/10/28

calculating is a pain

@ 09:19 AM (34 months, 25 days ago)
today i had to check some simple mathematical problems + and - things.

there are a huge amount of paper laying around my desk, the computer is filled with a lot of data sheets and one piece of agents is calculating wrong, financial wrong. so where is the heck ?  erp export ? converting engine ? transport ? transformation ? import ? some variuos SAP routines ? j2ee rendering and presentation layer ?

so i started looking the bug. the main job was addition, multiplication and % calculating with correct roundings. mh. whats the next calculator around ? the standard calc on my computer is too slow for a large amount of values. i can not go back. oh, lets take the new z22 i got yesterday. i installed easycalc. but same problem. outsch.

mh, lets remember which unit is next. ahh. i forgot. my swiss army knife in such cases. HP4x :) i own two units, a HP48G and a HP49G. the HP48G is always in my bag, for such cases.

with its RPN logic it works perfect for financial calculating. you got an endless stack. can see everything in one place and do massive simple calculations in seconds, not minutes with storing and remembering sub results. just calculate and let the result in the stack, where you can get it later with ease.

Jan Lukasiewicz developed in 1920 a formal logic system which allowed mathemacial expressions to be specified without parentheses by placing the operators before (prefix notation) or after (postfix notation) the operands.

lets give a small example.

normal expression, more human readable, (2 + 3) * 5

prefix notation * 5 + 2 3 or * + 2 4 5

postfix notation 2 3 + 5 * or 5 3 2 + *

The prefix notation is also known as Polish Notation. The first calculators of HP adopted the postfix notation. they adding a stack to hold the operands and functions to reorder the stack. HP named this technology Reverse Polish Notation RPN in honor of Lukasiewicz.

This way of handling operands was verry efficient for computer based math operations. the computer can scan the input from left to right. operands are simply placed into a LIFO stack, last in first out. so operators are immediately applied to the operands at the bottom of the stack. on almost all modern computers the statements where translated to RPN for faster execution.

in my opinion RPN outperforms normal algebraic expression in complex calculations, which exists a lot in science calculations. now you may say, that calculating with RPN is slower than doing it the normal way. but i can tell you, in sum you are faster with RPN !!

during my college i was the only guy, who used a RPN based calculator. my friends told me, that they can calculate faster and they dont understand, why i use a "slow" HP48. so we started a test and we started to compare the calculating of some tasks. it was quite funny. it was a complex calculation "strength of materials". after 50-60 minutes we got the results. we were 6 people with 6 different results. I was the last one who finished. everybody laughed .. I thought I was wrong but I could not found any mistakes in my calculation, checking the stack and sub results.

so everybody started to recalculate the results in 30 minutes. so we got 3 different results now. i got the same result from the first round and three friends got the same result like me now. so the other two friends started looking for their mistake and after 15 minutes they fixed the results.

now I started laughing, because I was the one, who got after 60 minutes the right result. and all other failed in the first round!!!!! after 50 minutes they thought they got the result. but they were wrong. they need 80 minutes or nearly 100 minutes then me. the double time.

so RPN rulez !

why they failed ? they used "complex" algebraic expressions, TI-89 and TI-92. they dont see each subresults, so they can not see errors in detail. they had to reenter complex expressions again and again, if they got a typo after execution.

lets go back to business.

ps. at hpcalc.org you will find emulators for variuos plattforms ..

» Leave a comment


:mrgreen: :neutral: :twisted: :arrow: :shock: :smile: :???: :cool: :evil: :grin: :idea: :oops: :razz: :roll: :wink: :cry: :eek: :lol: :mad: :sad: :!: :?:

Preview:

You say:

To prevent spam, please type in the exact word you see in this image: CAPTCHA
To refresh the image, click here. Otherwise, contact us.

  • Your E-mail address is never displayed. If you enter it, it will only be visible to the blog author
  • The line and paragraph breaks automatically