SuperCalc v 5.6

how deep the rabbit hole goes

Comments, suggestions or bugs report at Tsiros

download ( if you want ) SuperCalc

for an android device you can download and install the SuperCalc.apk

added recently

  1. Determinant calculation

  2. Linear Systems

  3. You have to reread iterations

  4. Recursive functions

  5. No standard variables(second encounter)

Some examples (click on them)
  • Linear Systems
    4 * x + 5 * y - 2 * z + 6.5 * v + 17.55 * w = -305.085
    1 * x + 2 * y + 3 * z - 3.1 * v - 9.3 * w= 162.24
    4 * x - 2 * y - 3 * z - 4.4 * v + 1.1 * w = -32.27
    -3.3 * x + 6 * y - 2.7 * z + 17 * v - 2 * w = 57.9
    -1 * x + 3 * y - 3 * z + 4.4 * v - 5.1 * w = 86.15
    where : x=1 ,y=-2, z=3 , v=2.7, w=-17.7
    warning : for five variables and more, as in the above example, you get only a hint about the solution
    warning : Supercalc does not make any check on the matrix of system's coeficients that you provide
    Let's see Supercalc in action !
  • Default Functions and Variables
    asin(x), acos(x), atan(x), log(x), log(x,y), ln(x), sin(x), cos(x), tan(x), pi, if(x,y,z), row(x,n), col(x,n), max(x), min(x), srt(x), c2r(x), ran, poly(x,y), integral(x, y, z, w), Length(x), Sn(x), Sn_1(x), Mean(x), rb(x), element(x,n), floor(x), round(x), mp(x,y,z), e


    Units conversion
    Calculate a loan 
    Curv Fit Least squares method.Least squares fitting 
    This way you can play with finit differences 
    YES!!!.You can pass and functions as parameters. Check this 
    for easy calculations added the variable _ (underscore) which has the value of the last completed calculation (and not only the value displayed at the end).
    Added the root symbol √ (control - Q for IE)
    Lists.This is the first try. So, more help, fewer bugs and more features later. 
    Integral approximation (Lists) 
    This is an expandable calculator.Look at the code and you will find that is very simple to add as many functions,variables and units as you want.Of course you can add your own operations or expand the functionality of operators but this is rather complex.

    Calculate the monthly payment of a loan
    mp(principal,rate,years) this is the function
    for a loan of 150000$ with rate=8% for 30 years, you have to pay monthly
    mp(150000,8,30) ===>1100.67$

    Finit differences (you have to read the Iterations)
    dif(y,k)=(Σ(((-1)^i*comb(k,i)*element(y,k+n-i+1))'(i,0,k)))'[n,0,Length(y)-k-1] (element(y,n) is the n th element of list y)
    dif(a,i)'[i,0,Length(a)] this is the List of the lists of "all order differences"
    [[1,8,27,64,125,216,343,512],[7,19,37,61,91,127,169],[12,18,24,30,36,42],[6,6,6,6,6],[0,0,0,0], [0,0,0],[0,0],[0],[]] 

    or from scratch
    f(a) the first order differences
    f(_) the second and so on. And 

    f(f(f(a))) the third order differences

    Recursives functions

    f(x)=values,body           this is the syntax

    values is a list and body is an expression

    f(x)=[2,4,7],x+1  means that f(0)=2, f(1)=4, f(2)=7 and for other x f(x)=x+1

    But you can include the f(x) 

    consider this

      a hundred (minus one) fibonacci numbers !!!



    and this is also valid


    and this


    or a double recursion


    an example

    they say that
    calculate the sum of 2000 terms (via recursion function)

    Yes!. Supercalc is FAST !!

    Of course this is simpler

    Warning! Recursive functions are powerful but be careful when define such functions.The browser will crash in case of an endless recursion.

    No standard variables

    a=value,expression     this is the syntax

    for each line, the first call of the variable return the value.Next calls returns expression


    a   returns 0

    a+a+a returns 6   (0+2+4)

    you can freely mix recursive functions with non standard variables at any depth


    Iterations (or what means this) 

    Has two forms

    The First case
    f(x)'[x,1,5] this expression has a left expression the f(x), a sign of operation ( ' ) and a right expression [x,1,4] a group of symbols (the x) and values (1 and 4) .The whole expression means: replace the x in f(x) with the integer values from 1 to 4 and give me a list of f(x) values. According to this 
    x'[x,1,4] => [1,2,3,4] the x inside the group is not visible outside the group (it is a symbol, not a variable) and hide the x on the left operator.After this
    x+x'[x,0,2] resolve to x+[0,1,2] In x'[x,a,b] the a and b are visible, so can be variables (warning: not. list)
    if you want you can provide a step

    the form f(x)'(x,1,5) does not return list - only the last operation is visible


    The Second case
    in this case the x iterate throu the list "somelist" and gives his value to the function f(x)
    (x/2)'[x,[4,5,6,sin(pi/2)]] ==> [2,2.5,3,.5]
    somelist can be a list of constants like in this example or a list of variables/functions or a variable/function that returns a list

    Same for f(x)'(x,somelist)

    The right operator can include many groups

    f(x,y)'( [x,a,b], [y,[x,x+1]] ) the x hide the parameters on the right


    but in 

    ([]◄f(x,y))'(x,1,y)'(y,[a,b,c]) the y in outer group give his value to the inner group



    You can define this
    isum(z)=(Σ(element(z,x)'[x,1,y]))'[y,1,Length(z)] which iterate thru a list z and add

    Something useful 
    The default function poly(x,y) define a polynome (a+b*x+c*x^2+ .....) 
    and here is his definition 
    poly(x,y)=Σ(y*(x^y)'[y,0,Length(y)-1]) y is the list of coefficients [a,b,c,....] and x is the variable (which can be and list)
    poly(2,[1,2,3]) => 1+2*2^1+3*2^2 ==>17
    or poly([1,5,7,8],[1,2,3]) ==> [6,86,162,209]

    Curve fitting
    Let's fit a line ( Least squares method or least squares fitting)in these points [[1,1],[2,3],[3,3]] and get the y for x=2 
    poly(2,fitpoly([[1,1],[2,3],[3,3]],1)) simple!!!!! 

    the function fitpoly([[X1,Y1],[X2,Y2], ...,[Xn,Yn]],degree_of_polynome) returns a list of polynome's coefficient.
    and these are 10 y after fitting a parabola at some points 
    poly(x,fitpoly([[2,2],[2,4],[4,6],[6,4],[8,2]],2))'[x,1,10] (SuperCalc is tough) 
    one more test

    but if you want the polynome (or polynomial or whatever you call it) which has known roots 
    here is the definition 
    poly2(x,y)=Π(x-y) x the variable and y is the list of roots (this definition does not support lists)

    but if you want to support list (for the variable) you have to define and this
    and then polyL([1,2,3,4,5,6],[1,3]) ==> [0,-1,0,3,8,15] 
    this definition can be "integrated" 
    f(x)=polyL(x,[1,2,3]) you have to define this first in order to have a function type


    There is a variable ran (returns random numbers [0,1]) 
    sin(ran'[x,1,10]*pi/2) is a list of ten sinus of random angles between 0 and pi/2

    Let's reverse a list

    by the way 4..9 is a range and means [4,5,6,7,8,9] ( a..b , fromthis(x)..tothat(x,y) is also valid)

    Passing a function (the function itself) as parameter 
    first the easy 
    f(fx(w))=fx(w-5)/3 what means this? 
    This is a function definition with name f, which has one variable named fx(w). 
    But this is a function.In the body of the function f it appears again. 
    f1(x)=x/2 Let's define another function, 
    f2(x)=x^2 and then another and then ..... 
    f(f1(10)) here the f1 gives his structure to the fx and the value of his variable go to w (w is a dummy variable) 
    the body of the f function is now f1(10-5)/3 ==> (10-5)/2 /3 ==>0.8333 
    f(f2(3)) same way the body of f is now f2(3-5) /3 ==> (3-5)^2 /3 ==> 1.3333 
    more complicated 
    f(f1(3),f2(4,6)) gives 2.25 
    let's see this 
    f(f1(z),4) what happens here? 
    the z is a dummy variable because of the second parameter y in the definition of the function f.This y (if exist) take precedence over the y of the fx(y) 
    Something useful, there is a default function with name 'integral' which approximate integrals over an interval (you must have read the use of Lists) 
    integral(f(x),a,b)=Σf([b,a]~100)*(b-a)/100 this is the definition . Let's use it 
    integral(sin(x),0,pi/2) => 1.000.. 
    f(x)=sin(x)+cos(x) No problem, can have the same name 
    integral(f(x),0,pi/2) => 2.0000 
    warning integral(sin(x)+cos(x),0,pi/2) or integral(x^2+x,0,10) is not valid, because sin(x)+cos(x) and x^2+x is not considered as one function (There is no way to find the variable(s)).Define a function and then ... 

    and as usual more help, more power and lesser bugs later 

    The structure [2,5,8] or [a,b,f(x)] is a list and not a matrix or vector.He can appear everywhere a number can appear but is not number.Rather is a group of numbers. So 
    [1,2,3,4]+5 -> [6,7,8,9], [2,3,4]+[7,6,5]=[9,9,9], [2,3,4]^2 -> [4,9,16], 1+[2,3,4]!->[3,7,25] 
    [2,3,4]*[4,5,6]->[8,15,24], 5/[1,2,5] ->[5,2.5,1], [2,3,4]^[4,2,1]->[16,9,1], Σ[1,2,3,5] ->11 means sum of list elements, Πa means product of elements of list a (i.e Π[2,3,4,6] -> 144) 
    All operations are "overloaded" in order to manage lists.So avoid to use the structure (condition?result_true:result_false).Instead use the if(condition,op1,op2) which covers and lists. 
    if( [1,2,4]>[2,1,1] , [5,6,7] , [8,9,10] ) returns [8,6,7]. 
    warning! lists must have the same number of elements, Other words [1,2]+[4,5,6] is an error (without error message by now).But [1,2]+[4,[5,6]] is OK because they have same number of elements (at first level !) 
    Σ : control-T for IE, "copy and paste" for Netscape returns the sum of elements 
    Π : control-U for IE, "copy and paste" for Netscape returns the product of elements 
    ◄: control-\ for IE, "copy and paste" for Netscape. Add something to a List 
    [1,2,3]◄56 => [1,2,3,56], [4,5,6]◄[7,8,9] ==> [4,5,6,7,8,9] 
    row(listname,n) is the nth row of list 
    col(listname,n) is the nth column of list 
    also the usual max(x) and min(x) (you don't need help for this) 
    function c2r(x): ie colums to rows c2r([[1,2,3],[5,6,7]])-> [[1,5],[2,6],[3,7]] 
    ~ : used to "split" a list (SuperCalc specific) 
    the Σ and Π are operations with the greatest priority. So Σ[2,5]! means 7! and not 2!+5! 
    Σ is an operation like + * /, which needs a list right of it (or a function who returns a list) 
    √Σ[2,3] is an error because √ expect an expression and not an operation. √(Σ[2,3]) is OK 
    But having defined a function say f(x)=[x,x/2] and a variable a=[3,4] then Σf(a) is valid (f is not an operation). Valid is also the Πsin(a) (product of sinus of elements) 
    (hmmm, i think this must be explained in details) 
    About the ~: 
    Syntax [a,b]~c , divide the interval a to b in c sections like this [3,8]~5 -> [3.5, 4.5, 5.5, 6.5, 7.5] 
    Use: approximation of integrals

    Data manipulation 
    Say you have a "multidimensional" list data=[ [1,2,3], [4,2,1], [4,4,2], [6,2,6], [10,1,6] ] 
    then col(data,0) -> [1,4,4,6,10] ie the list of the first elements 
    col(data,1) -> [2,2,4,2,1] the list of the second elenents and so on 
    Now watch this 
    f(data) ->[1, 6, 4, 1.33333, 1.833333 ] 
    or this way 

    Some examples with root symbol 

    2+√2 means 2 plus the square root of 2
    4*3√27 means 4 times the third root of 27 think of it like 4*3√27
    2^4√16 means 24√16 and 3√9^2 means (3√9)2
    3!√9! means 3!√(9!) (! has greater priority) 

    (a+b)√(y+z)*c means a+by+z · c
    √√4 is not allowed (exactly as ++ or ** is not allowed) ( √(√4) is OK). In supercalc √ is an operation like ^ or *, who expect an expression right of it.(if you omit the left operator he suppose it is 2), The 3!! is correct because factorial does not need expression right of it. 

    but √4√9√27 is OK (from left to right 2√9√27 then 3√27 then 3) 

    it's straight and easy

    the underscore "_" variable 
    You don't need to copy and paste from the result area to input area in order to use the result of a calculation.Simply use the underscore variable _ 
    _/2 gives 5 value used _=10 after _=5 
    1+ _! gives 121 value used _=5 after _=121 
    -_ gives -121 after this _= -121 
    warning: avoid to use this special variable in function or variable definition unless you know what you are doing 
    f(4) guess the answer 
    and don't forget the underscore variable keep his value after clearing memory 
    The nth result is kept in a variable with name _n.Now 
    _1+_2/_4 means a+b/d 
    warning:because functions definitions and empty lines does not return values they dont count!.Then we have 
    a=2 this is the 1 line 
    f(x)=x this line dont count!! 
    Who Am I but this count ,returns error 
    b=3 this is the 3 line 
    _1*_4 ( for a*b) is an error. Instead, the correct is _1*_3 

    Units Conversion
    super calc has an enough flexible way to convert units (actually the best) and there is no conflict between variables and units with the same name.
    m/s m/s ft/s
    result: 1.6404 ft/s

    if you look at the source you will find that you can add as many units as you want

    the symbols for units are taken from United States Department of Commerce
    National Institute of Standards and TechnologyGuide for the Use of the
    International System of Units (SI)
    NIST Special Publication 811
    1995 Edition
    United States Department of Commerce
    National Institute of Standards and Technology (go and read it)

    length m (meter) cm, mm, km, yd (yard) ft (international feet) in (inches) mi (international mile) (and miles is ok)
    time: s (second, but also sec is OK) , min (minute), h (hour) , d (day)
    volume: L (liter), bu (bushel U.S.), gal (U.S.) , bbl (barrel for petroleum 42 gallons U.S.)
    mass: g (gramm), kg, lb, t (metric ton 1000 kg), oz (ounce avoirdupois)
    force: N ( Newton ) dyn (dyne), kgf, lbf (pound-force) , kip (1000 lbf), kp (kilopond= 1 kgf), ozf (ounce avoirdupois- force)
    work, energy:  J (joule N*m), Btu (mean, warning: there are six different Btu), cal (mean, one of many calories)
    power: W (Watt), hp ( horsepower=550 ft *lbf /s, warning: there are six different horsepower!)
    pressure: Pa, Torr, bar, psi (lbf/in2), mmHg, inHg, atm (atmosphere standard) , at (atmosphere technical)
    viscosity: St (kinematic, stokes = cm2/s), P (dynamic, poise = dyn*s/cm2)
    speed: knot, mach
      Hz (1/s)   A (ampere) ,C (Coulomb, s*A), V (volt, W/A), F (farad, C/V), S (siemens, A/V), Wb (weber, V*s)
    money dollar, euro  these also are units but you must update the relation (hard code)

    The use of space 
    The space (white character) separate expressions from units and units from units.This is not always an idle character. 
    2+3 is OK. and 2 + 3 is OK and √ | - 4 ^ 2 ! | m /s mi / h is OK (converting meters per second to miles per hour) 
    but having defined a function say f(x) 
    trying f(4) or f( 4 ) is OK 
    f ( 4) is an error, because the calculator assume that f is a variable and (because there is no operation next) try to see the (4) as units. 
    f(4) is one valid expression, but f (4) are two valid expressions.Same as 22 is a number but 2 2 are two numbers. 
    One more time 
    trying f(m) or f( m ) is OK. Calculate the value of function. 
    but f (m) means f meters