This is a scientific calculator involving many functions such as:
- Normal arithmetic operations.
- Functions such as factorial, permutation, combination etc.
- Scientific functions (sin, cos, sin-1, cos-1, sinh, cosh, sinh-1,etc.).
- Operations on complex numbers.
- Storage of values in variables and operations on these variables.
- Use of abbreviated form of representing values (such as m for milli, M for mega, etc.).
- Evaluation of simple series.
- Expressions involving any combination of the above.
The calculator uses a recursive parser for evaluation of expressions. A part of the recursive parser is represented in the diagram below. The parser uses a proper operator precedence. The complete precedence can be known by looking at the code.
Advantage of using the parser for expression evaluation
The complexity of procedure required is broken into many parts thus making each part simpler to understand and the overall structure robust. It becomes easier to to change the operator precedence implemented.
An alternative approach
We might use a stack to do the expression evaluation. But then, breaking down of the complexity to many procedures is not as straightforward as in the recursive function approach and we might stand to lose the advantages of the recursyve function approach.
Some Special Features
The calculator provides an easy-to-use interface. The expressions can be entered easily using the keyboard or by clicking the buttons using the mouse. For expressions using variables(X,Y,A,B,etc.) and symbols like pi(π), it is better to use the mouse since these characters are special characters.
Display of evaluated value in fraction form
Values of expressions can be viewed in normal decimal form or in the fraction form. Default is the decimal form. To change to fraction form check the option fraction in the toolstrip menu options->display.
Display of evaluated value in polar form
Complex numbers can be viewed either in the default form(a+bi) or in the form rLθ. To change to polar form, check the option polar in the toolstrip menu options->display.
Angle measurements in different units
Angle measurements may be in degree, radian, or grade. The selection may be done using the DomainUpDown at the top right of the main form. This selection effects the trignometric calculations as well as the measure of amplitude of complex numbers when they are displayed in polar form. The expression in the expression textbox is re-evaluated as soon as a change in the choice in the DomainUpDown is made.
Whenever a value appears on the value textbox, it automatically updates Ans memory contents by storing the result.
The value can be used in the next expression using the variable Ans at any position of the expression.
Ans memory is not updated in case of error in evaluation.
- The calculator provides 9 memory varaibles.
- Values can be stored in these variables and they may be used later in expressions.
- The values remain stored in the computer in a file even after closing the application and retain the values the next time we run the application.
- The value stored in variables can be that of real numbers or co mplex numbers.
We may evaluate series such as sum of first ten natural numbers, or product of even numbers from 20 to 40.
How to use
- Just run the demo project. To do this, download the file scientific_calculator_demo.zip. Unzip the file. Run the file scientific_calculator_demo/release/calculator.
- Enter any expression as stated earlier.
- Press = button, or hit the = or [Enter] key on the keyboard to see the answer. If the answer is lenghty scroll down the textbox to view the complete answer.
To store values in variables and use them
- Check the mem radio button.
- We may directly add or subtract to the memory variables. Depending on whether store,add or subtract checkboxes are checked, values are stored to, added to or subtracted from the variables whose buttons are clicked. If none of check boxes on the memory variables-form are checked, a hit on a button in this form inserts corresponding variable to the expression.
- The memory variables may contain real values or complex values.
To evaluate expressions containing trignometric functions
Check the Trignometry radio button.
Now, to simply click the button in the trignometry form to get the funcions to the expression.
To get the inverse functions to the expression click inv checkbox and then the button of the trignometric function whose inverse is required in the expression.
To evaluate expressions containing series
- Check the series radio button.
- Enter the lower value of the variable in the series expression in expression textbox and check Setlow and then I button. Similarly set the high value of the variable in the sries expression.
- The upper and lower limit of the variable have to be integers and upper limit should be greater than lower limit numerically.
- Now enter the expression containing the series expression and press = to view the result.
- For example, to find sum of first ten natural numbers:type 1 -> Setlow -> I; type 10 -> Sethigh -> I; type "SΣI"->=;to view the answer 55 in value textbox.
- At present, for all SΣ and Sπ that appear in a single expression, the range of variable will be same. With a further enhancement, we may get rid of this limitation.
Here is an android app that uses the same parser mentioned in this article: Calculator on Google Play. The only difference is that the App implements the same parser in JS and uses PhoneGap.
You can visit my webpage to know more about me.