Calculator Module

Introduction

The Calculator Module inherits the values of the last fit/plot performed by the user and allows for the writing/execution of a sequence of operations using a command syntax that has some similarities with Matlab/Octave and with the syntax of the Calculator toolbox .

A proper help/tutorial as yet to be written. One important aspect is that lines that start with '#' are comment lines. Here follows some examples :

Examples:

tnformat=%le;

# sets table numbers' format to scientific

onformat=%lg;

# sets other numbers' format to either scientific of decimal


[3:0.5:8];

# generates a table (T0) with one column with numbers 3 to 8 in steps of 0.5 with


[ c1 ]

> [

> 3.000000e+00

> 3.500000e+00

> 4.000000e+00

> 4.500000e+00

> 5.000000e+00

> 5.500000e+00

> 6.000000e+00

> 6.500000e+00

> 7.000000e+00

> 7.500000e+00

> 8.000000e+00

> ]

# shows the table with just the generated column


For functions of the "Specific funsctions library" the following call formats are equivalent

> ans=0

_BPP(1e7,1e9,1e-8)

> ans=22.6786

BPP(1e7,1e9,1e-8)

> ans=22.6786

OF(BPP,1e7,1e9,1e-8)

> ans=22.6786

x:=10**c1

f:=_BPP(x,1e9,1e-8)

# defines two functions x and f


[ x+1 f "_BPP(x, 1e9, 1e-8)"]

> [

> 1.001000e+03 5.000000e+01 5.000000e+01

> 3.163278e+03 4.999999e+01 4.999999e+01

> 1.000100e+04 4.999993e+01 4.999993e+01

> 3.162378e+04 4.999933e+01 4.999933e+01

> 1.000010e+05 4.999329e+01 4.999329e+01

> 3.162288e+05 4.993299e+01 4.993299e+01

> 1.000001e+06 4.933884e+01 4.933884e+01

> 3.162279e+06 4.416510e+01 4.416510e+01

> 1.000000e+07 2.267863e+01 2.267863e+01

> 3.162278e+07 4.403260e+00 4.403260e+00

> 1.000000e+08 4.987542e-01 4.987542e-01

> ]

# generates a table with the frequency and the values of the user library fucntion BPP calculated for each frequency and the parameters A=1e9 and tau=1e-8. The frequency poists are equally space in a log10 scale.Use " when using white spaces.


[c1 c2 dc2/dc1]

> [

> 1.001000e+03 5.000000e+01 -7.490889e-09

> 3.163278e+03 4.999999e+01 -1.315847e-08

> 1.000100e+04 4.999993e+01 -8.327452e-09

> 3.162378e+04 4.999933e+01 -2.703280e-08

> 1.000010e+05 4.999329e+01 -8.820407e-08

> 3.162288e+05 4.993299e+01 -3.483618e-07

> 1.000001e+06 4.933884e+01 -1.782487e-06

> 3.162279e+06 4.416510e+01 -3.464888e-06

> 1.000000e+07 2.267863e+01 -1.698340e-06

> 3.162278e+07 4.403260e+00 1.318976e-06

> 1.000000e+08 4.987542e-01 -1.660800e-07

> ]

# calculates de derivative of c2 with respect to c1


[log10(c1)]

> [

> 3.000434e+00

> 3.500137e+00

> 4.000043e+00

> 4.500014e+00

> 5.000004e+00

> 5.500001e+00

> 6.000000e+00

> 6.500000e+00

> 7.000000e+00

> 7.500000e+00

> 8.000000e+00

> ]

[c1 c1^2];

# calculates a new table (T1) with two columns:

# the first has the same values of the previous table c1_T1=c1_T0

# the second calculates the square of the values of the first column

# of the previous table c2_T1=c1_T0^2, but doesn't print the result

[c2 c1 c1+c2+1]

> [

> 9.002604e+00 3.000434e+00 1.300304e+01

> 1.225096e+01 3.500137e+00 1.675110e+01

> 1.600034e+01 4.000043e+00 2.100038e+01

> 2.025013e+01 4.500014e+00 2.575014e+01

> 2.500004e+01 5.000004e+00 3.100004e+01

> 3.025001e+01 5.500001e+00 3.675001e+01

> 3.600000e+01 6.000000e+00 4.300000e+01

> 4.225000e+01 6.500000e+00 4.975000e+01

> 4.900000e+01 7.000000e+00 5.700000e+01

> 5.625000e+01 7.500000e+00 6.475000e+01

> 6.400000e+01 8.000000e+00 7.300000e+01

> ]

# calculates a new table (T2) starting from the previous one

# c1_T2=c2_T1, c2_T2=c1_T1, c3_T2=c1_T1+c2_T1+1

# this time the results are printed


v1=2m

> v1=0.002

# variable v1 gets the value 2m where m is units' submultiple 0.001


v2=3;

# variable v3 is initialized with value 3


v3=v1**v2

> v3=8e-09

# v3=v1^v2


ans/2

> ans=4e-09

# the results of the previous operation is devided by 2


v3*1k^3/2

> ans=4

# v3 is multiplied by units' multiple 1000 to the power 3 and the result devided by 2


v3*1G

> ans=8

# v3 is multipled by units' multiple 1000000000


sqrt(16);

# square root of 16


onformat=%lf

# sets other numbers format to floating point decimal representation


ans*2

> ans=8.000000

# the result of the previous operation "sqrt(16)" is multiplied by 2


atan(1)*180/pi

> ans=45.000000

# calculates the angle for which arc tan is 1


sin(ans/180*pi)/cos(ans*pi/180)

> ans=1.000000

# the previous angle which is 45 degrees is calculated in radians and the tangent is calculated


log(exp(1))

> ans=1.000000

# calculates the natural logarithm of the the Euler's number e


pow(2,3)

> ans=8.000000

2**3

> ans=8.000000

2^3

> ans=8.000000

# produce equal results