Accueil > Unclassified > Javascript Calculator

Javascript Calculator

The sciwebjs javascript calculator allows you to perform scientific calculations on an HTML client (HTML5 compatible). It is made up of a set of functions and javascript classes for scientific computing, 2D plotting, 3D plotting, image and video processing, etc. The javascript code is contained in input boxes that the user can modify and execute themselves. The javascript code contained in an input box is called a calculation block.

The first example below is an input box containing a few simple lines of javascript: Execute

f=function(x) {return Math.sin(2Math.PIx)}


In this page, the code is already executed. The user can run it again, after any modification, by clicking on the Run button. The disp function is specific to sciwebjs; it allows you to display textual information in the HTML page, just after the input box. The Help button is used to obtain help on a sciwebjs function selected in the input box. The new button opens a new input box between this one and the next one.

Let us see a second input box performing the trace of the function defined previously: Execute

f = function(x) {return Math.sin(2Math.PIx);}
plotframe({xmin:0,xmax:10,ymin:-1,ymax:1},{fill:”black”,font:”10pt sans-serif”})
plotlabels({x:”x”,y:”y”,title:”titre”},{fill:”black”,font:”bold 12pt sans-serif”})

The javascript code includes several functions of sciwebjs: fig, plotframe, plotgrid, plotlabels and fplot2d. Common sciwebjs functions like these are defined in the global javascript namespace. Care should be taken not to redefine these symbols. Note that the arguments of the functions are transmitted in the form of properties of javascript objects. The figure is generated as an HTML5 Canvas.

This calculator works entirely on the client. No data is transmitted to the server. As a result, changes made by the user are lost when the page is reloaded.

When the calculation blocks are automatically executed when the page is loaded, they are executed in order. In some cases, the calculation blocks must be executed at the request of the user (Execute button) because they call on asynchronous functions.

It may interest you

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
34 ⁄ 17 =