MiscEl: Calculator

Back to MiscEl main page Write a message to author


A calculator with many functions and the ability to draw curves and make tables.

General use

Write a expression and press enter, the result will be displayed in the result field, and copied to the "Last result" page. It is also possible to to write a statement or more statements with ; between, but a valid result will only be shown when the last item on the line is a expression.
A valid expression could be:
3*4
or
sin(pi/17)*power(3,2.3)/(1+cosh(4))
To store a result for later use:
var a;
a:=3*4
Or create a permanent variable with: a, then right click and select "Create variable", this variable is stored and will last until deleted (starting/stopping the MiscEl program will not delete the variable or the value)
Right click for more options: Use cursor up/down keys to recall the last expressions entered (From the "Last results" list).

Pages in calculator

Last results

A list of the last valid lines for the calculator and the corresponding result. Double click a line to get it back onto the editing line. Right click for more options:

Statements

List of statements, these are evaluated every time you press enter on the edit line, by using variables it is possible to calculate the same expression/statements many times with different values. Double click to copy the statement to the editing line
Right click for more options:

Variables

List of permanent variables, if a local variable with the same name is defined only the local variable will be changed with statements (To get rid of a local variable use free("name")).
Global variables can be used anywhere in MiscEl, but the pages will NOT update automatic when a variable is changed (Add or delete a space in a input field to update)! Right click for more options:

Functions

List of user defined functions. To define a function write functionname=expression in the editing line, then right click and select "Create function". All parameters passed to the function can be accessed in the "param" array, first parameter as index 0.
An example (Two resistor in parallel):
par=1./(1./param[0]+1./param[1])
Use the function by writing:
par(10k,30k)
The function can contain more than one statement, use ; as a delimeter. It is also possible to define variables with the var statement, these variables are local, and not saved between invocations of the function.
CAVEAT Any user defined function will not automatic convert to floating point when dividing integers, i.e. 5/2 will always be 2 in a user defined function! A typecast MUST be used (see above example for one way to handle the problem).
Functions can be used anywhere in MiscEl.
Double click to copy the function to the editing line
Right click for more options:

Const

A list of many different physical (and other) constants. Many of these constants can be directly used in expression anywhere in MiscEl. Use Category to select between different groups of constants. The rows displayet are: Double click to copy the constant to the editing line
Right click for more options:

Curve / Table setup

Define formulas for drawing a curve or making a table.
Fields:
XThe x-axis definition, usual just a t
Y1The first curve/column, write a expression with t as independ variable
Y2The second curve/column, write a expression with t as independ variable
StartStarting value for t
EndFinal value for t
StepsNumber of steps between starting and ending value, the X/Y1/Y2 are calculated once for each step
Log stepsUse logarithmic steps
Auto scaleAutomatic scale the graph to contain the curve
Use same scaleY1 and Y2 is displayed with the same scale
Left/RightMin/Max X value displayed
Bottom/TopMin/Max Y value displayed
Log x/y scaleUse logarithmic scales
DrawMake a curve
FillMake a table

Help

Shortform help for the calculator

Curve

Curve generated from "Curve / Table setup"
Right click for more options:

Table

Table generated from "Curve / Table setup"
Right click for more options:

Result

This page is used for large result

Specifications

Numbers

Numbers can be entered in a varity of ways: u is used as a easy typeable alternative to , k is accepted as both lower and upper case, all other prefixes must be in correct case

Operators

()Brackets
*Multiplication
/Division
%Returns the remainder of a division, only supported for integers
+Addition
-Subtraction
BitOrBitwise OR function, only supported for integers
BitAndBitwise AND function, only supported for integers
BitXORBitwise XOR function, only supported for integers
= or ==Equal, result is False=0, True=1
<>Not equal, result is False=0, True=1
<Less, result is False=0, True=1
<=Less equal, result is False=0, True=1
>Greater, result is False=0, True=1
>=Greater equal, result is False=0, True=1
| or ORLogical or (0=False, all other values=True), only supported for integers, result is False=0, True=1
& or ANDLogical and (0=False, all other values=True), only supported for integers, result is False=0, True=1
integer?expression1:expression2Returns expression1 if integer is non-zero else result is expression2

Statements

expressionAny expression can be used as a statement
variable:=expressionAssignment to a variable is a statement (variables must be created before use)
var name;Create a local variable named "name", this variable will not be shown on the "Variables" page and not saved, defining a variable multiple times is valid and will not change the value of the variable
if (expression) statements else statements endifA if statement with or without the else part
This list is not complete

Datatypes

Automatic type conversion will hide the actuel datatype in many cases, but it is possible to force type conversion with typename(value) i.e. integer(pi) will return a integer (with the value 3). Be carefull with division: 5/2 is either 2 or 2.5 depending on datatype and automatic conversion to real setting (Watch out in user defined functions), (5./2 or (real(5)/2 is always 2.5).
Use VarType(Variable) to check the type of a variable.
IntegerNumbers without a decimalpoint i.e. 1 2 3 4 etc.
RealNumbers with the posibility for a decimalpoint i.e. 1.7 3.14 etc. (these numbers can also be without digits after the decimal point)
ComplexTwo real numbers, saved as r and i, only some operations are supported on complex numbers
StringAny sequence of characters, most mathematical operations are not supported on this type
ArrayA list of datatypes, accessed with [index], the first element is always 0
This list is not complete

Functions

Sin/Cos/Tan/ArcSin/ArcCos/ArcTanStandard trigonometric functions
todB/todBpwr/fromdB/fromdBpwrConvert to and from dB
ArcTan2(y,x)ArcTan(y/x) angle is in the correct quadrant
CoTan(x)Same as 1/tan(x)
Hypot(x,y)Same as sqrt(sqr(x)+sqr(y))
sinh/cosh/tanh/ArcSinh/ArcCosh/arcTanhHyperbolic trigonometric functions
Ln/Log10/Log2Logarithm functions Natural/base 10/base 2
LogN(Base,x)Logarithm with any base
Power(value,exponent)Raises value to exponent
Exp(x)/ALn(x)Raises e to the power of x
ALog(x)Raises 10 to the power of x
eReturns e (base of the natural logarithms)
piReturns pi
sqr(x)Returns x*x
sqrt(x)Returns square root of x
SolveSqr(x2,x,c)Solve a quadrantic equation, the result array may contain complex numbers
SolvePoly(xn,xn-1,....,x,c)/SolvePoly(array)Solve a n degree polynomial, the result array may contain complex numbers
EvalPoly(v,xn,xn-1,....,x,c)/EvalPoly(v,array)Evaluate a polynomial
InterpolateSpline(x,x1,y1,x2,y2,x3,y3,....)/InterpolateSpline(x,Array)Interpolate y from x using spline function
Array(v1,v2,v3,v4)Create a array, first value is placed at index 0
Arrayr(v1,v2,v3,v4)Create a array, last value is placed at index 0
hex/dec/oct/binReturns a hex/dec/oct/bin string of the integer part of the value
cpx(r,i)/complex(r,i)Create a complex number
int(x)Cuts any digits after the point
frac(x)Returns only digits after the point
ComplexAngle(x)Returns the angle of a complex number
ComplexVector(x)Returns the vector length of a complex number
ComplexR(x)Returns the real part of a complex number
ComplexI(x)Returns the complex part of a complex number
StdR(x)/StdC(x)/StdL(x)Round value to standard for specified component
StdE3(x)/.../StdE192(x)Round value to specified standard
FilterLP1(f0,f)Calculate the attenuation in dB for a first order low pass filter with 3 dB frequence f0 at frequence f
FilterHP1(f0,f)Calculate the attenuation in dB for a first order high pass filter with 3 dB frequence f0 at frequence f
FilterLP1cpx(f0,f)Calculate the complex factor for a first order low pass filter with 3 dB frequence f0 at frequence f
FilterHP1cpx(f0,f)Calculate the complex factor for a first order high pass filter with 3 dB frequence f0 at frequence f
RIAA(freq)Convert a frequence to RIAA dB value
RIAAIEC(freq)Convert a frequence to RIAA, with IEC modification dB, value
RIAAcpx(freq)Calculate the complex factor for a frequence according to the RIAA specification "todB(ComplexVector(RIAAcpx(freq)))" is the same as "RIAA(freq)"
RIAAIECcpx(freq)Calculate the complex factor for a frequence according to the RIAA, with IEC modification, specification
CRC8(poly,initial,string)/CRC16(poly,initial,string)/CRC32(poly,initial,string)Calculate crc for specified string. Some standard poly's:
PolyInitialTest "123456789"Name
$a001*0BB3DCRC16 standard crc-16
$8408$ffff29B1CRC16 CITT (REMARK: a bitreversal is automatic done when using this poly)
$edb88320*$ffffffffCBF43926CRC32 Standard crc-32 (REMARK: output is automatic inverted when using this poly)
All other poly's are calculated without special handling.
*Using 0 as poly will preload this poly and initial value, ie. using crc32(0,0,data) is the same as using crc32($edb88320,$ffffffff,data);
I your need code for crc calculations see CRC calculations
Remark:All these functions are working with inverted poly's, see CRC and Checksum hints for more explanation
CRCPoly(coefficients)Calculate a poly value from a list of coefficients i.e. CRCPoly(16,15,2,0) gives $a001 as poly value for x^16+x^15+x^2+x^0
CRCPolyReverse(ReversePolyValue)Reverse all bits in poly value. The poly value used here is with lsb coefficient FIRST and msb-1 coefficient last
BoxSurface(x,y,z)Calculates the surface area of a box. To estimate the mass of the box use (for a 10*20*30cm box made of 1mm aluminium): BoxSurface(100m,200m,300m)*1m*aluminium_density
UnitConversion(FromUnit,ToUnit,Value)Convert a value between any two units. Both full and short unit names can be used.
Example: UnitConversion("atm","mmHg",1)
ToSI(Unit,Value)Convert a value to corrosponding SI unit
FromSI(Unit,Value)Convert a value to from corrosponding SI unit
This list is not complete

Other pages