Jump to content

Formula calculator: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m minor changes to reference punctuation
m definition wording
Line 7: Line 7:
This is unlike a button-operated calculator, which requires the user to perform one step for each operation, by pressing buttons to calculate all the intermediate results, before the final value is shown.<ref>Microsoft’s Windows Operating System Calculator Accessory; 2001. Available on a Windows PC at: Start/All Programs/Accessories/Calculator</ref><ref>MotionNET [Calculator page on the Internet]; 2006. Available from: http://www.motionnet.com/calculator</ref><ref>Flow Simulation Ltd [Virtual Calc98 page on the Internet]; 2008. Available from: http://www.calculator.org/jcalc98.html</ref>
This is unlike a button-operated calculator, which requires the user to perform one step for each operation, by pressing buttons to calculate all the intermediate results, before the final value is shown.<ref>Microsoft’s Windows Operating System Calculator Accessory; 2001. Available on a Windows PC at: Start/All Programs/Accessories/Calculator</ref><ref>MotionNET [Calculator page on the Internet]; 2006. Available from: http://www.motionnet.com/calculator</ref><ref>Flow Simulation Ltd [Virtual Calc98 page on the Internet]; 2008. Available from: http://www.calculator.org/jcalc98.html</ref>


In this context, a formula is also known as an ''expression'',<ref>Reference 3, paragraphs 1 and 2 use ''formula'' and ''expression'' interchangeably</ref> and so formula calculators may be called ''expression'' calculators.<ref>Hot-Shareware.com [1st-Calculator page on the Internet]; 2009. Available from: http://www.hot-shareware.com/home-education/1st-calculator</ref> Also in this context, calculation is known as ''evaluation'',<ref>Reference 3, paragraph 1</ref> and so they may be called formula ''evaluators'', rather than ''calculators''.<ref>The Code Project [Dynamic Formula Calculator/Evaluator in VB.NET page on the Internet]; 2009. Available from: http://www.codeproject.com/KB/vb/Dynamic_Formula_Evaluator.aspx</ref>
In this context, a formula is also known as an ''expression'',<ref>Reference 3, paragraphs 1 and 2 use ''formula'' and ''expression'' interchangeably</ref> and so a formula calculator may be called an ''expression'' calculator.<ref>Hot-Shareware.com [1st-Calculator page on the Internet]; 2009. Available from: http://www.hot-shareware.com/home-education/1st-calculator</ref> Also in this context, calculation is known as ''evaluation'',<ref>Reference 3, paragraph 1</ref> and so it may be called a formula ''evaluator'', rather than a ''calculator''.<ref>The Code Project [Dynamic Formula Calculator/Evaluator in VB.NET page on the Internet]; 2009. Available from: http://www.codeproject.com/KB/vb/Dynamic_Formula_Evaluator.aspx</ref>


== Written-formula calculations ==
== Written-formula calculations ==

Revision as of 00:02, 28 January 2009

File:Formula Calculators.JPG

A formula calculator is a software calculator that can perform a calculation in two steps:

1. Type in a formula from the keyboard.
2. Press a button or key to see the formula’s value.[1][2][3]

This is unlike a button-operated calculator, which requires the user to perform one step for each operation, by pressing buttons to calculate all the intermediate results, before the final value is shown.[4][5][6]

In this context, a formula is also known as an expression,[7] and so a formula calculator may be called an expression calculator.[8] Also in this context, calculation is known as evaluation,[9] and so it may be called a formula evaluator, rather than a calculator.[10]

Written-formula calculations

Formulas as they are commonly written use infix notation for binary operators, such as addition, multiplication and subtraction. This notation uses:

Parentheses to enclose parts of a formula that must be calculated first.
• In the absence of parentheses, operator precedence, so that higher precedence operators, such as multiplication, must be applied before lower precedence operators, such as addition.
• Among operators with the same precedence, associativity, so that the left-most operator must be applied first.

Formulas also use:

Non-commutative operators that must be applied to numbers in the correct order, such as subtraction and division.
• The same symbol for more than one purpose, such as - for negative numbers and subtraction.

Although there may be some variation in the operations available between different calculators, formulas are typed into a formula calculator more or less as they are written. Once typed in, the calculator automatically follows the above rules, to produce the final result by:

• Finding both operands of each binary operator.
• Working out the values of these operands.
• Applying the operator to these values, in the correct order so as to allow for non-commutative operators.
• Evaluating the parts of a formula in parentheses first.
• Taking operator precedence and associativity into account.
• Distinguishing between different uses of the same symbol.

Button-operated calculations

File:Windows Accessory Calculator.JPG

The user of a button-operated calculator presses buttons for the first operand, then the operator and then the second operand, so these calculators are based on infix notation. Because operators are applied one at a time, and because of the structure of infix notation, the user must work out which operator button to use at each stage. This can lead to problems,[11][12] and, when discussing these problems, Professor Harold Thimbleby has pointed out that button-operated calculators “… require numbers and operation signs to be punched in a certain order, and mistakes are easy to make and hard to spot”.[13]

Problems can occur because, for anything but the simplest calculation, to work out the value of a written formula, the user of a button-operated calculator is required to:

• Rearrange the formula so that the value can be calculated by pressing buttons one at a time, whilst taking operator precedence and parentheses into account.
• Use memory buttons to ensure that operations are applied in the correct order.
• Use the special buttons +/- and 1/x, that don’t correspond to operations in the formula, for non-commutative operators.

Mistakes can be hard to spot because:

• For the above reasons, the sequence of button presses may bear little resemblance to the original formula.
• The operation carried out when a button is pressed isn’t always the same as the button, but a previously entered operation.

Examples

The simplest example of a possible problem when using a button-operated calculator given by Professor Thimbleby is 4*-5.[14] As a written formula, the value of this is -20, because the minus sign is intended to indicate a negative number, rather than a subtraction, and this is the way that it would be interpreted by a formula calculator.

With a button-operated calculator, depending on which buttons are used, and the order in which they are pressed, the result for this calculation can be different. Also, among the calculators, there are differences in the way a given sequence of button presses is interpreted.[15] The result can be:

-1: If the subtraction button, -, is pressed after the multiplication, *, it is interpreted as a correction of the *, rather than a minus sign, so that 4 - 5 is calculated.
20: If the change-sign button, +/-, is pressed before the 5, it isn’t interpreted as -5, and 4*5 is calculated.
-20: To get the right answer, +/- must be pressed last, even though the minus sign isn’t written last in the formula.[16]

The effects of operator precedence, parentheses and non-commutative operators, on the sequence of button presses, are illustrated by:

4 - 5*6: The multiplication must be done first, and the formula has to be rearranged and calculated as -5*6 + 4. So +/- and addition have to be used rather than subtraction. When + is pressed, the multiplication is performed.
4*(5 + 6): The addition must be done first, so the calculation carried out is (5 + 6)*4. When * is pressed, the addition is performed.
4/(5 + 6): One way to do this is to calculate (5 + 6)/4 first, and then use the 1/x button, so the calculation carried out is 1/((5 + 6)/4).
4*5 + 6*7: The two multiplications must be done before the addition, and one of the results must be put into memory.[16]

These are only simple examples, but button-operated calculators can present even greater problems in more complex cases. In fact, Professor Thimbleby claims that users may have been conditioned to avoid them for all but the simplest calculations.[17]

Declarative and imperative tools

The potential problems with button-operated calculators stem from the fact that they are imperative.[18] This means that the user must provide details of how the calculation has to be performed.

Professor Thimbleby has identified the need for a calculator that is more automatic, and therefore easier to use, and he states that such a calculator should be more declarative.[19] This means that the user should be able to specify only what has to be done, not how, and in which order, it has to be done.

Formula calculators are more declarative because the typed-in formula specifies what to do, and the user does not have to provide any details of the step-by-step order in which the calculation has to be performed.

Declarative solutions are easier to understand than imperative solutions,[19][20] and there has been a long-term trend from imperative to declarative methods.[21][22] Formula calculators are part of this trend.

Many software tools for the general user, such as spreadsheets, are declarative.[23] Formula calculators are examples of such tools.

Using the full power of the computer

Software calculators that simulate hand-held, button-operated calculators do not use the full power of the computer: “A computer is a far more powerful device than a hand-held calculator, and thus it is illogical and limiting to duplicate hand-held calculators on a computer.” (Haxial Software Pty Ltd)[24]

Formula calculators use more of the computer’s power because, besides calculating the value of a formula, they work out the order in which things should be done.

Hybrid calculators

There are hybrid calculators that combine written-formula and button-operated calculation. For example:

• Calculations can be entered entirely from the keyboard, or operations can be applied to typed-in numbers or formulas using buttons, in the same calculator.[25]
• Formulas can be constructed using buttons, rather than being entered from the keyboard.[26]
• Formula copies of button-operated calculations can be created, saved and re-loaded for application to different numbers.[27]
• Some button-operated calculators have a precedence mode and parentheses buttons so that they can be used to evaluate a written formula without re-arrangement.[28]

See also

Calculator

Scientific calculator

Programmable calculator

References

  1. ^ Formula Calculators Pty Ltd [Home page on the Internet]; 2009. Available from: http://fCalculators.com
  2. ^ Moisey Oysgelt [JavaScript Formula Calculator page on the Internet]; 2000. Available from: http://www.alemoi.com/math
  3. ^ Haxial Software Pty Ltd [Calculator Product page on the Internet]; 2001. Available from: http://www.haxial.com/products/calculator
  4. ^ Microsoft’s Windows Operating System Calculator Accessory; 2001. Available on a Windows PC at: Start/All Programs/Accessories/Calculator
  5. ^ MotionNET [Calculator page on the Internet]; 2006. Available from: http://www.motionnet.com/calculator
  6. ^ Flow Simulation Ltd [Virtual Calc98 page on the Internet]; 2008. Available from: http://www.calculator.org/jcalc98.html
  7. ^ Reference 3, paragraphs 1 and 2 use formula and expression interchangeably
  8. ^ Hot-Shareware.com [1st-Calculator page on the Internet]; 2009. Available from: http://www.hot-shareware.com/home-education/1st-calculator
  9. ^ Reference 3, paragraph 1
  10. ^ The Code Project [Dynamic Formula Calculator/Evaluator in VB.NET page on the Internet]; 2009. Available from: http://www.codeproject.com/KB/vb/Dynamic_Formula_Evaluator.aspx
  11. ^ Harold Thimbleby. A new calculator and why it is necessary, Computing Science, Middlesex University, London, UK; September 1998. Available from: http://www.uclic.ucl.ac.uk/harold/srf/allcalcs.pdf
  12. ^ Neville Holmes. Truth and Clarity in Arithmetic, University of Tasmania; 2003. Available from: http://standards.computer.org/sabminutes/2003Wint/Truth%20and%20Clarity%20in%20Arithmetic%20-%20Neville%20Holmes.pdf
  13. ^ http://www.physorg.com. Professor devises easier calculator; June 2005. Available from: http://www.physorg.com/news4773.html
  14. ^ Reference 11, section 2
  15. ^ References 4, 5 and 6
  16. ^ a b Reference 4
  17. ^ Reference 11, section 3.2, second paragraph
  18. ^ Reference 11, sections 1 and 10
  19. ^ a b Reference 11
  20. ^ Roy E. Furman. Declarative Programming - Strategies for Solving Software Problems, http://www.articlesalley.com; July 2006. Available from: http://www.articlesalley.com/article.detail.php/7013/178/Education/Internet/36/Declarative_Programming_-_Strategies_for_Solving_Software_Problems
  21. ^ David A. Watt. Programming language concepts and paradigms, Prentice Hall; 1990. Citation 13 at: http://citeseer.ist.psu.edu/context/14802/0
  22. ^ Tatsuru Matsushita. Expressive Power of Declarative Programming Languages, PhD thesis, Department of Computer Science, University of York; October 1998. Citation 13 at: http://citeseer.ist.psu.edu/context/14802/0
  23. ^ Reference 20, paragraph 6
  24. ^ Reference 3, second paragraph
  25. ^ Reference 1, Arithmetic and Scientific calculators
  26. ^ Gold-Software Development [LeoCalculator page on the Internet]; 2006. Available from: http://www.batchconverter.com/LeoCalculator-download-24300.shtml
  27. ^ FarsightSoft Inc [Farsight Calculator page on the Internet]; 2008. Available from: http://www.farsightsoft.com/farsightcalculator.html
  28. ^ ESB Consultancy [ESBCalc Pro page on the Internet]; 2009. Available from: http://www.esbcalc.com