Custom functions and random number generator

A new version (0.4) of the scientific calculator was released last week, with a few more buttons, useful features, and bug fixes.

New features available in version 0.4:

The keyboard has been made a little wider to accomodate 5 extra buttons: comma, reset and rand. Two buttons are still unassigned and will be used in a future version.

Scientific Calculator now supports functions

Defining custom functions

This is probably the most important enhancement. Defining your own function can save you a lot of time if you need to perform the same calculation multiple times for different values. To define a new function youneed to specify a name, one or more parameters and an expression that rapresents the calculation you want to perform on the named parameters. A simple example will illustrate the usefulness of this new functionality:

We want to create a function that calculates the volume of a cone. The formula that we we will use is:

(pi*(r^2)*h)/3 where r is the radius of the base and h is the height of the cone.

This function will accept two parameters (r and h) and return the volume of the cone.

To define the function in the calculator we enter in the input line:

volumeofcone(r,h)=(pi*(r^2)*h)/3, then we hit ‘enter‘.


If all goes well, a small window pops up, showing the function we just defined.

Now we can use our function as many times as we want, passing different values for the height and radius of the cone:

Use custom functions

Composite functions

We can also use previously defined functions in new functions, creating a composite function.

Continuing from the previous example, let’s say we don’t have the radius of the base of the cone, but we have the circumference. We can first create a new function that calculates the radius from the circumference (circtoradius), then create another function that puts together volumeofcone and circtoradius:



Again we can use the new formula…

volumeofconefromcirc(35,12) ≈389.9296105751435

Creating composite functions

Pseudo-random number generator

The pseudo-random number generator function takes no parameters and returns a pseudo-random number between 0 and 1. For more information about pseudo-random numbers and why they are called like that,  see the Wikipedia article here. You can use the random function by pressing the ‘rand’ key or by typing ‘rand()’ directly inside your expression or function in the input field.

The Reset function

Use the reset function by pressing the ‘reset’ key to clear the calculator window.

This is the calculator window before reset…

Calculator before reset

And after reset…

Calculator window after reset

Did you notice that after pressing ‘reset’ the ‘delete’ button next to one of the functions has become available? That’s because now that there are no more expressions, that particular function is not used anymore. This means that it can be safely deleted without affecting any other calculation.

That’s it for this version. Hopefully you will find these new features useful. Remember that you can always request new functionalities using the feedback link on the calculator page. To learn more about the Online Scientific Calculator, see the first post here and the instruction manual here.

Tags: , , ,

Comments are closed.