A{{Short '''formula calculator''' is a softwaredescription|Software calculator that can perform a calculation in twoevaluate steps:expressions}}
[[File:Wi-Fi challenge Pi equation in microMathematics Plus 2.15.6 on Android 2.3.png|thumb|right|microMathematics Plus on Android displaying a formula for a popular Wi-Fi password challenge. The formula is entered first, and requires operator precedence — multiplications and divisions precede additions and subtractions.]]
A '''formula calculator''' is a [[software calculator]] that can perform a calculation in two steps:
1. # Enter the calculation by typing it in from the keyboard.
# Press a single button or key to see the final result.
This is unlike button-operated [[calculators]], such as the [[Windows calculator]] or the [[Calculator (Mac OS)|Mac OS X calculator]], which require the user to perform one step for each operation, by pressing buttons to calculate all the intermediate values, before the final result is shown.
2. Press a single button or key to see the final result.
<ref name ="SC">SpeedCrunch [home page on the Internet]; 2010. Available from: http://speedcrunch.org (freeware)</ref><ref name ="MPC">MagicPlot Calculator [home page on the Internet]; 2010. Available from: http://magicplot.com/calc (freeware)</ref><ref name ="CLC">Command Line Calculator [home page on the Internet]; 2010. Available from: http://www.kotiposti.net/jjhalme/clcmain.htm (freeware)</ref><ref name="FC">Formula Calculator Pty Ltd [home page on the Internet]; 2009. Available from: http://www.FormulaCalculator.com</ref><ref name="MO">Moisey Oysgelt [JavaScript Formula Calculator page on the Internet]; 2000. Available from: http://www.alemoi.com/math</ref><ref name="HS">Haxial Software Pty Ltd [calculator products page on the Internet]; 2001. Available from: http://www.haxial.com/products/calculator</ref>
In this context, a formula is also known as an [[Expression (programming)|expression]], and so formula calculators may be called ''expression'' calculators. Also in this context, calculation is known as ''evaluation'', and so they may be called formula ''evaluators'', rather than ''calculators''.
This is unlike button-operated [[calculators]], such as the [[Windows calculator]] or the [[Mac os calculator]], which require the user to perform one step for each operation, by pressing buttons to calculate all the intermediate values, before the final result 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 product 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 (programming)|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>
== How they work ==
Formulas as they are commonly written use [[infix notation]] for [[binary operators]], such as addition, multiplication, division and subtraction. This notation also 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. For example, in 2 + 3*4, the multiplication, 3*4, is done first.
* Among operators with the same precedence, [[associativity]], so that the left-most operator must be applied first. For example, in 2 - 3 + 4, the subtraction, 2 - 3, is done first.
* [[Non-commutative]] operators that must be applied to numbers in the correct order, such as subtraction and division.
* The same symbol used for more than one purpose, such as - for negative numbers and subtraction.
* Analysing the formula and breaking it down into its constituent parts, such as operators, numbers and parentheses.
* 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.
== How to enter formulas ==
=== Operators ===
Formulas printed in many text books use juxtaposition, underline and superscripts for multiplication, division and exponentiation respectively. Also, some operations, such as square root, are represented by special symbols that are not usually available on a computer keyboard. For example, see the formulas in [[Amortization calculator]], [[Heron's formula]] and [[Law of cosines]].
=== Multiplication ===
In many software tools, including [[spreadsheets]] and [[programming languages]], the asterisk, *, is used for multiplication.<ref name="Python">The Python Programming Language. Available from http://www.python.org</ref> However, it is also possible to use juxtaposition.<ref>See the discussion at http://www.autohotkey.com/forum/topic15055.ht</ref> For example:
2cos(3)
means 2 ''multiplied by'' cos(3).
In calculators that don’t allow juxtaposition, the asterisk (and possibly x rather than, or as well as, the asterisk), is used, and the calculation should be entered as:
2*cos(3)
Also, a period is sometimes used for multiplication, as in:
2.cos(3)
Because the period is also used as the decimal point in numbers, so that the “2.” in the above would be interpreted as 2.0, the period is not used for multiplication in a formula calculator, and this calculation should be entered using a different symbol, as above.
=== Division ===
Printed formulas often use a horizontal line for division, but in a formula calculator that uses only keyboard symbols, division is entered using the forward slash, /. When there is a calculation above or below the line, this should be done first, and so it should be enclosed in parentheses when typed in. For example,
2 + 3
—————
4 - 5
should be entered as
(2 + 3)/(4 - 5)
Also, the symbol ÷ is often used for division, as in
2 ÷ 3
This symbol is not available on most computer keyboards, so this division operation is entered using the forward slash, as above.
=== Exponentiation ===
Exponentiation, or raising to a power, is often represented using a superscript. For example:
2.45<sup>2</sup>
means 2.45 ''squared''.
With the limitations of a computer keyboard, in some software packages, such as [[Microsoft Excel]], this is entered using the caret, ^:
2.45^2
but two asterisks are also used:<ref name="Python"/>
2.45**2
=== Exponentiation and functions ===
When using functions, the superscript is sometimes placed immediately after the function name. For example, it is common to write the trigonometric version of [[Pythagoras’ Theorem]] ([[List of trigonometric identities]]) as:
sin<sup>2</sup>(x) + cos<sup>2</sup>(x) = 1
In this identity,
sin<sup>2</sup>(x)
means the square of sin(x), and is the same as:
sin(x)<sup>2</sup>
So, for x = 3.25, it could be entered into a formula calculator that uses the caret for exponentiation as:
sin(3.25)^2
=== Square roots ===
Square roots are often specified using the √ symbol, but with the limitations of a keyboard this is can be entered by using exponentiation. For example, the square root of 2:
√2
could be entered as:
2^(1/2)
but two asterisks are also used:<ref name="Python"/>
2**(1/2)
The parentheses specify that the division should be done first.
=== Other roots ===
All roots can be specified in this way. For example, the cube root of 2 can be entered as:
2^(1/3)
=== Heron’s formula example ===
An example that illustrates these features is [[Heron’s formula]].
One version of the formula, for a triangle with sides of length a, b and c, is equivalent to, using symbols that are available on a keyboard:
1/2*(a^2*c^2 - (a^2 + c^2 - b^2)/2)^0.5
For a = 2.5, b = 3.6 and c = 1.9, it could be entered into a formula calculator as:
1/2*(2.5^2*1.9^2 - (2.5^2 + 1.9^2 - 3.6^2)/2)^0.5
== Types of calculator ==
The formula calculator concept can be applied to all types of calculator, including arithmetic, scientific, statistics, financial and conversion calculators.
The calculation can be typed or pasted into an edit box of:
• *A software package that runs on a computer, for example as a dialog box.<ref name="CLC"/><ref name="FC"/><ref name="HS"/>
*An on-line formula calculator hosted on a web site.
It can also be entered on the command line of a programming language.
• An on-line formula calculator hosted on a web site.<ref name="MO"/>
It can also be entered on the command line of a programming language.<ref name="Python"/>
== Related software packages ==
Although they are not calculators in themselves, because they have a much broader feature set, many software tools have a formula-calculation capability, in that a formula can be typed in and evaluated. These include:
• *[[Spreadsheets]], where a formula can be entered to calculate a cell’s content.
*[[Databases]], where a formula can be used to define the value of a calculated field in a record.
• [[Databases]], where a formula can be used to define the value of a calculated field in a record.
== Declarative and imperative tools ==
Button-operated calculators are [[imperative programming|imperative]], because the user must provide details of how the calculation has to be performed.<ref name="Reference 13">[[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 Archived at: [https://web.archive.org/web/20070207044654/http://www.uclic.ucl.ac.uk/harold/srf/allcalcs.pdf web.archive.org][https://agecalculator.com]</ref>
On the other hand, formula calculators are more [[declarative programming|declarative]], because the entered 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.
Button-operated calculators are [[imperative]], because the user must provide details of how the calculation has to be performed.<ref name="Reference 13">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</ref>
Declarative solutions are easier to understand than imperative solutions,<ref name=" Reference 13"/><ref>Roy E. Furman. Declarative Programming - Strategies for Solving Software Problems, http://www.articlesalley.com {{webarchive|url=http://webarchive.loc.gov/all/20121220085209/http%3A//www.articlesalley.com/ |date=2012-12-20 }}, July 2006. Available from: {{cite web |url= http://www.articlesalley.com/article.detail.php/7013/178/Education/Internet/36/Declarative_Programming_-_Strategies_for_Solving_Software_Problems |title=Declarative Programming - Strategies for Solving Software Problems |accessdate=2009-05-04 |url-status=dead |archiveurl= https://archive.today/20120723100846/http://www.articlesalley.com/article.detail.php/7013/178/Education/Internet/36/Declarative_Programming_-_Strategies_for_Solving_Software_Problems |archivedate=2012-07-23}}</ref> and so there has been a long-term trend from imperative to declarative methods.<ref>David A. Watt. Programming language concepts and paradigms, Prentice Hall, 1990 (citation 13 at http://citeseer.ist.psu.edu/context/14802/0)</ref><ref>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)</ref> Formula calculators are part of this trend.
On the other hand, 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.
Many software tools for the general user, such as [[spreadsheets]], are declarative. Formula calculators are examples of such tools.
Declarative solutions are easier to understand than imperative solutions,<ref name=" Reference 13"/><ref>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</ref> and so there has been a long-term trend from imperative to declarative methods.<ref>David A. Watt. Programming language concepts and paradigms, Prentice Hall, 1990 (citation 13 at http://citeseer.ist.psu.edu/context/14802/0)</ref><ref> 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)</ref> Formula calculators are part of this trend.
Many software tools for the general user, such as [[spreadsheets]], are declarative.<ref>Reference 15, paragraph 6</ref> Formula calculators are examples of such tools.
== Hybrid calculators ==
There are hybrid calculators that combine typed-in formulae 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.
There are hybrid calculators that combine typed-in formula and button-operated calculation. For example:
*Formulas can be constructed using buttons, rather than being entered from the keyboard.
*Formula copies of button-operated calculations can be created, saved and re-loaded for application to different numbers.
• 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.<ref>Reference 1, Buttons and The Works calculators. Available from: http://www.FC-Scientific.com and http://www.FC-Max.net</ref>
• Formulas can be constructed using buttons, rather than being entered from the keyboard.<ref>Gold-Software Development [LeoCalculator page on the Internet]; 2006. Available from: http://www.batchconverter.com/LeoCalculator-download-24300.shtml</ref>
• Formula copies of button-operated calculations can be created, saved and re-loaded for application to different numbers.<ref>FarsightSoft Inc [Farsight Calculator page on the Internet]; 2008. Available from: http://www.farsightsoft.com/farsightcalculator.html</ref>
== See also ==
* [[Software calculator]]
* [[Comparison of software calculators]]
== References ==
<references/>
|