Calc

Made by Sven Nilsen for efficient calculation purposes.

Basic Algebra

Operator Name Example
:Integers from/to1:3 = [1,2,3]
;Repeat1;3 = [1,1,1]
+Add2+3
-Subtract2-3
*Multiply2*3
/Divide2/3
^Power2^3
@Partion, number of ways to split a quantity into specificed pieces10@3
%Modulus10%3
<Less Than2<3 = 1
>Greater Than2>3 = 0
=Equals2=3 = 0
!=Not Equal To2!=3 = 1
<=Less Or Equals2<=3 = 1
>=Greater Or Equals2>=3 = 0
~Round to nearest5.6~1 = 6

Vectors

Operator Name Example
\Sums numbers at range0:9\1:3 = 6
\\Pick numbers at index or range1:3\\1 = 2
1:3\\[0,0,2] = [1,1,3]
\\\Number except index or range1:3\\\1 = [1,3]
1:3\\\[0,2] = 2
;Repeat pattern N times1:3;3 = [1,2,3,1,2,3,1,2,3]
;;Repeat each number by pattern1:3;;3 = [1,1,1,2,2,2,3,3,3]
1:3;;[0,2] = [2,2]
++Add2+3
--Subtract2-3
**Multiply2*3
//Divide1:2//3
^^Power2:5^^3
@@Partion, number of ways to split a quantity into specificed pieces10:20@@3
%%Modulus1:7%%5
<<Less Than2:5<<3 = [1,0,0,0]
>>Greater Than2:5>>3 = [0,0,1,1]
==Equals2:5==3 = [0,1,0,0]
!=!=Not Equal To2:5!=!=3 = [1,0,1,1]
<=<=Less Or Equals2:5<=<=3 = [1,1,0,0]
>=>=Greater Or Equals2:5>=>=3 = [0,1,1,1]
~~Round to nearest1:6~~2 = [2,2,4,4,6,6]

You can define vectors using '[' and ']', for example x=2 and y=3:

[2,3]

You can also define a sequence using ':', for example the numbers 1 to 10:

1:10

When substituting a sequence into a vector, use '(' and ')' around it:

[(1:10),2]

When using algebraic operations on vectors, each element is summed together:

1:4 * 2:5 = 1*2+2*3+3*4+4*5 = 40

To do the operator per dimension, use '**' instead of '*'.

1:4 ** 2:5 = [1*2,2*3,3*4,4*5] = 2,6,12,20

If you combine a vector and a scalar, the scalar will act like a vector with all same values.

1:4 ** 2 = [1,2,3,4] ** [2,2,2,2]

Notice that '--' means '+', use '++' and negative sign if needed:

1:4--3 = 1:4+3
1:4++-3 = [-2,-1,0,1]

When using the comparison functions like '<' be aware that it produces 1 for 'yes' and 0 for 'no'.
Since this is summed up when using a single sign, you are actually counting the number of objects that meet the criteria.

1:4<<3 = [1,1,0,0]

When you pass empty list to a function, it does not take up place:

sqrt([],4) = 2

Bitstream Processing

Operator Name Example
&Performs AND operation on two bitstream vectors[0,10]&[5,20] = [5,10]
|Performs OR operation on two bitstream vectors[0,10]|[5,20] = [0,20]
!Performs NOT operation at location specified in second argument[0,10]!2 = [0,2,10]
_Performs EXCEPT operation with invert location 0[3,5]_[4,7] = [3,4]

A bitstream vector i s a list of number that tells you when a default value of "false" changes to "true" and back.
For example [2,4] means it has the value "true" from the position 2 and changes back to "false" at position 4.

The NOT operation equals removing a number if it is in the list, or adding it to the list if it is not there.
Notice that you can perform multiple NOT operations as a construction of lists:

[]!1!2!3 = [1,2,3]
1!2!3![] = [1,2,3]
[]![1,2,3] = [1,2,3]
[1,2,3]![] = [1,2,3]

The EXCEPT operator got precedence -1, which results in the following evalutation:

[0,10]_[1,2]|[4,5] = [0,10]_[1,2,4,5] = [0,1,2,4,5,10]

Simple Functions

Operator Name Example
absAbsolute valueabs([-1,2,-3]) = [1,2,3]
countCount listcount([1,2,3]) = 3
revReverse listrev([1,2,3]) = [3,2,1]
floorRound downfloor(4.24) = 4
dateDate in format YYYYMMDDHHmmSSTT where
TT is UTC time zone, starting at 24
date()
sqrtSquare rootsqrt(2)
sinSinesin(3)
cosCosinecos(3)
tanTangenttan(3)
atanInverse tangentatan(3)
atan2Inverse tangent, x first then yatan2([3,4])
fibFibonacci sequencefib(1) = 2
prodProduct ofprod([3,4]) = 3*4
minMinimummin([3,4]) = 3
maxMaximummax([3,4]) = 4
sigmSigmoidsigm([3,4])
tauTau, circumference of a circle with radius 1tau()
piPipi()
eEuler's numbere()
lnNatural logarithmln(5)
log10-base logarithmlog(5)
phiGolden ratiophi()
factFactorizefact(25) = [5,5]
primPrime Number, starting at prim(0) = 2prim(3) = 7

Physical Constants

Operator Name Example
hPlanck constanth()
hbReduced Planck constanthb()
cSpeed of lightc()
lpPlanck lengthlb()
tpPlanck timetp()
fscFine structure constantfsc()
grGravitational constantgr()

Matrix Algebra

Operator Name Example
***Multiplies two matrices, must be square[1,0, 0,1]***[2,0, 0,2]
idReturns an identity matrix of specified sizeid(4)
detReturns determinant of square matrix. Limit: 50x50det([1,0, 0,1]) = 1

Dynamics

Operator Name Example
+++Integrate with order[0,1,0,0]+++1 = [0,1,1,1]
---Differentiate with order[0,1,1,1]---1 = [0,1,0,0]

Integration and differentiation are best illustrated by example:
If you have a vector describing an acceleration at different intervals of time,
it often will look like a collection of 0's and positive numbers when force is applied.
In the following example, we apply the force 1 at the third time interval.
The integration of acceleration by time equals velocity, so by order 1 we get a new vector.
This vector describe the velocity at each time interval.
When we integrate again, or by order 2, we get the position.

[0,0,1,0,0]+++1 = [0,0,1,1,1]
[0,0,1,0,0]+++2 = [0,0,1,2,3]

This process is reversible, differentiation.
This calculator let's you differentiate with the operator '---'.

[0,0,1,1,1]---1 = [0,0,1,0,0]
[0,0,1,2,3]---2 = [0,0,1,0,0]

Complex Numbers

Operator Name Example
*iMultiply complex numbers and sum them[1,2]*i[3,4]
**iMultiply each complex number couple1:4*i1:4
/iDivide complex numbers and sum them[1,2]/i[3,4]
//iDivide each complex number couple1:4//i1:4

Complex numbers are treated like couples in array, but does not have a specific tag.
I consider complex numbers as relationship between dimensions, not a specific dimension in itself.

Counting

Operator Name Example
===Counts each left with any of the right1:20===10:1+0 = 10

When you want to check if a vector contains a range, you can use the count function to see if all the numbers on the right exists.
This require each number on the right to be unique, but it does not have to be in the same order as the left side.

x=[1,2,3,4,5,6,40]
y=1:20
count(x())++-(x()===y()+0)

An analog can be made to the hangman game, where you try to guess one letter by one.
When you have filled up the right side, then you know what the left side is from the order you guessed.

Special commands

Operator Name Example
hideHides output up to this pointhide
xRemember value as xx=[4,5]
x()+4
yRemember value as yy=[4,5]
y()+4
zRemember value as zz=[4,5]
z()+4
tRemember value as tt=[4,5]
t()+4

When you assign the t variable and one of the x, y, z graphs will appear.
The graph is scaled to fit the bounds of the minimum and the maximum of the range.
The thought behind this design is to let the user adjust which area to look at numerically, often using the ':' operator.
x has a red color, y as a green color, z as a blue color.

Built-In Functions

When doing physics, you often want to calculate the velocity at each coordinate along a path.
Set the x,y,z,t variables to use the 'v()' function that calculates the velocity for you.
Strictly speaking, this is not functions that works like the others that takes arguments.
These functions uses the defined variables and replaces it with another expression that else would have taken much place to write.
I recommend using these functions when possible as it saves you from doing many mistakes.

Operator Name Example Expression
vVelocity along path, x,y,z,t must be setv() sqrt(((x()---1)^^2++(y()---1)^^2++(z()---1)^^2)//(t()---1)^^2)
lorLorentz factor along path, x,y,z,t must be setlor() (1//sqrt(1++-(v()//c())^^2))
lapLaplace operator, x,y,z must be setlap() ((x()---2)^^2++(y()---2)^^2++(z()---2)^^2)