# A multipurpose scientific calculator

, 17 Apr 2008 CPOL
 Rate this:
A calculator handling complex numbers and scientific functions

## Introduction

This is a scientific calculator involving many functions such as:

1. Normal arithmetic operations.
2. Functions such as factorial, permutation, combination etc.
3. Scientific functions (sin, cos, sin-1, cos-1, sinh, cosh, sinh-1,etc.).
4. Operations on complex numbers.
5. Storage of values in variables and operations on these variables.
6. Use of abbreviated form of representing values (such as m for milli, M for mega, etc.).
7. Evaluation of simple series.
8. Expressions involving any combination of the above.

## Concepts used

### Recursive parser:

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

### Easy-to-use interface

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.

### Memory calculations

• 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.

#### Variables

• 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.

### Series

We may evaluate series such as sum of first ten natural numbers, or product of even numbers from 20 to 40.

## How to use

1. 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.
2. Enter any expression as stated earlier.
3. 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

1. Check the mem radio button.
2. 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.
3. The memory variables may contain real values or complex values.

### To evaluate expressions containing trignometric functions

1. Check the Trignometry radio button.
2. Now, to simply click the button in the trignometry form to get the funcions to the expression.
3. 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

1. Check the series radio button.
2. 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.
3. The upper and lower limit of the variable have to be integers and upper limit should be greater than lower limit numerically.
4. Now enter the expression containing the series expression and press = to view the result.
5. 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.
6. 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.

You can visit my webpage to know more about me.

## Share

India
I've studied info. sc. engg. from Sir MVIT, Bangalore.

I'm interested in programming.

Some of my technical blogs:

http://perl-blog.kbsbng.com/
http://java-blog.kbsbng.com/

I also enjoy writing some webpages such as http://sites.google.com/site/plantencyclopedia/

More about me at http://www.kbsbng.com and http://blog.kbsbng.com.

 First Prev Next
 C# version hannashin 19-Mar-12 13:05
 Re: C# version kbsbng 19-Mar-12 18:47
 Thank you for the appreciation. I do not have a C# version. Regards, Keshavaprasad B S Homepage: http://kbsbng.googlepages.com
 My vote of 1 VistaHacker 7-Nov-09 21:03
 Calculator Van Phuong Nguyen 30-Mar-07 19:53
 Nice tmacpherson 26-Feb-07 8:02
 Re: Nice kbsbng 27-Feb-07 4:36
 A bit on the short side WillemM 28-Jan-07 4:12
 Re: A bit on the short side kbsbng 7-Feb-07 18:03
 Re: A bit on the short side WillemM 7-Feb-07 21:02
 Re: A bit on the short side kbsbng 7-Feb-07 21:32
 Re: A bit on the short side kbsbng 8-Feb-07 3:56
 Last Visit: 31-Dec-99 19:00     Last Update: 17-Apr-15 15:13 Refresh 1