i3R68

                WUSINWUG -- what u see
                is not what u get

SMATH. FIRST LOOK
=================

Tools -> Options:
-----------------

NB! CHECK OPTIONS (NOT NECESSARILY SAVED)

  Interface language  English
  Units language      English
  Functions style     World
  Decimal symbol      . (period)
  Arguments separator , (comma)
  Font size           14
  Text color          Auto
  Background color    Auto
  Document layout     Pages view

SMath on Bionic Beaver
----------------------

  boots: SMathStudioDesktop.0_98_5935.Mono.tar.gz
  requires: tk mono-complete libcanberra-gtk-module

Tips
----

  import (notepad -> smath):

    f(t):220*sqrt(2)*sin(50*π/180*t)

  export (smath -> notepad):

    notepad document have to be in unicode format.

  Boolean:

    "2 (+) 3 = 0 [placeholder]"

    2¤3=0@#

  Greek letters:

    ω:2*π

  Integral:

    int(x^r,x)={x^{r+1}}/{r+1}+C@#
    int(x,x,0,3)

  Vectors and Matrices: (function overloading, signatures)

    to see  y:=[1..9]     type  y:range(1,9)
    to see  x:=[1,3..99]  type  x:range(1,99,3)

    matrix | 1 2 3 |
           | 4 5 6 |
           | 7 8 9 |

    mat(1,2,3,4,5,6,7,8,9,3,3)

  Fractions:

    5/9*K or {5*K}/9 but 5/{9*K}

  Copy-paste (size limit):

    line(row1,row2,..rowN,N,1)

Comment
-------

just use string constants on separate lines above the formula you want to comment on (see example by Fridel Selitsky) Then the comments stick to the context, but are not multi-lingual, just as separate text boxes next to the code could be.

Hello, World
------------

Program:

  line
    (
    pr:"Hello",
    pr:concat(pr,", World!"),
    2,1
    )

  pr=

Prepare: remove all ' ', \n, \r, \t, \v . remove comments if any (sed).

  line(pr:"Hello",pr:concat(pr,", World!"),2,1)
  line(pr:"Hi",pr:concat(pr," World"),2,1)

This explains why default argument separator is `;' (c-parator).

Now paste prepared code into SMath document.

Learn by example:
-----------------

example 1. Odd or even?

  n:55
  if(mod(n,2),pr:"odd",pr:"even")

  pr=

example 2. Arabic to Roman. With notes on sm format:
....................................................

  1. Indonesian translation.
  2. .sm file in XML format, expessions in RPN.

Roman numerals

  arabic:1984
  error:0  Value must be in range 0..3999
  relation:mat(1000,900,500,400,100,90,50,40,10,9,5,4,1, \
    "M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I",2,13)

  if
    (
    (arabic≤0)|(arabic≥4000),  # first comma means `then'
    roman:description(error),  # second comma means `else'
  line
    (
    roman:"",
    for
      (
      j:1,
      j≤cols(relation),
      j:j+1,
      while
        (
        arabic≥el(relation,1,j),
        line
          (
          arabic:arabic-el(relation,1,j),
          roman:concat(roman,el(relation,2,j)),
          2,1                 /* lines, ??? (always 1) */
          )                   /* enil */
        )                     /* elihw */
      ),                      /* rof */
    2,1                       /* lines, (always 1)  */
    )                         /* enil */
  )                           /* fi */

  roman="MCMLXXXIV"@#

example notes:

  + obfuscate code -- remove spaces, new lines.
    Notepad++ search: \s replace with: (none)

  IMPORTANT: THE WHOLE PROGRAM IS SINGLE LINE OF CODE.

  + el -- the way to use indices el(x,1,2) means x[1,2] in C

  + line(..) means block eg. {..} or begin..end. Try

      line(a:1,b:2,c:3,d:4,e:5,5,1)

  +flow control: body in header, eg:

      if a>b then c=0 else c=1;   is   if(a>b,c:0,c:1)
      while (a>b) c=d;            is   while(a>b,c:d)
      for x in range(1,5) s+=x    is   for(x,

example 3. Polar Heart
......................

  https://en.smath.info/forum/yaf_postst257_Polar-plot.aspx

Sorry, but for some weird reasons i have to split this into a three parts:

  line
    (
    t:range(0.01,π,0.02),
    r(t):abs((tan(t))^abs(cot(t))),
    x(t):r(t)*cos(t),
    y(t):r(t)*sin(t),4,1
    )

  for
    (
    i,
    range(1,length(t)),
    line
      (
      el(x,i):eval(x(el(t,i))),
      el(y,i):eval(y(el(t,i))),2,1
      )
    )

   XY:augment(x,y)

Now apply plot2D to XY

Animation
.........

  1. Set range:

       p := [-89 .. 89]

  2. Define function to animate: f(p, u) :

       "p must be in argument list"
       f(p, u) = tan(p) * u

  3. Insert 2D plot:

       "first argument must be named as t (frame parameter)"
       "axes are x,y,z"
        f(t, x)

  4. RClick:

       set fps,
       animate on p

Complex example: Planetary gear with internal teeth (help -> examples).

Links:
......

  locals, globals, comments

    https://en.smath.info/forum
    /yaf_postst1939_Local-variables--Comments.aspx

  portable

    https://en.smath.info/wiki/SMath%20with%20Plugins.ashx

Reference (all of ~400, not units ~115)
.......................................

    1.  B   %   %  -- Percentage (Dimensionless)  % = 10^-2
    2.  B   '   "  -- Second of arc (Dimensionless) π/{180*60*60}
    3.  B   '   '  -- Minute of arc (Dimensionless) π/{180*60}
    4.  B   '   °  -- Degree (Dimensionless) π/180
    5.  B   '   °C -- Celsius (Temperature)
    6.  B   '   °F -- Fahrenheit (Temperature)
    7.  B   '   °R -- Rankine (Temperature)      °Ra=5/9*K
    8.  B   '   °R -- Reaumur (Temperature)      °Ra=5/9*K
    9.  B   '   ‰  -- Per mille (Dimensionless)  ‰
   10.  G   '   ∞  -- Positive infinity ∞ = -∞
   11.  B   a   a  -- Are (Area) a = 100 m^2
   12.  B   a   A  -- Ampere (Electric Current)
   13.  B   a   Å  -- Angstrom  Å = 10e-10m
   14.  V   a   abs -- abs("complexNumber") -- Absolute value
   15.  V   a   acos -- acos("complexNumber") -- returns the inverse cosine
   16.  V   a   acos -- acos("complexNumber") -- returns the inverse hyperbolic cosine
   17.  V   a   acot -- acot("complexNumber") -- returns the inverse cotangent
   18.  V   a   acoth -- acoth("complexNumber") -- returns the inverse hyperbolic cotangent
   19.  B   a   acre -- Acre (Area)  acre = 4.0468564224e3 m^2
   20.  V   a   acsc -- acsc("complexNumber") -- returns the inverse cosecant
   21.  V   a   ainterp("1:argument","2:argument", 3:argument") -- Returns an Akima-spline interpolated y-value at x="3:argument" for data vectors x-vector "1:argument" and y-vector "2:argument" of the same size. (A vector is a column matrix.)
   22.  V   a   alg("1:matrix","2:number", 3:number") -- Cofactor (algebraically signed minor) of matrix.
   23.  B   a   A  -- Angstrom  Å = 10e-10m
   24.  P   a   appVersion("argument") -- Returns SMath Studio version. Supported values for "argument" are from -4 to 4. Negative argument requests for version of the program which last saved a worksheet. Positive argument requests for current SMath Studio instance version. Special functions
   25.  V   a   arcmin -- Minute of arc (Dimensionless) arcmin = π/{180*60}
   26.  V   a   arcsec -- Second of arc (Dimensionless) arcsec = π/{180*60*60}
   27.  V   a   arg -- arg("complexNumber") -- Returns the angle from the real axis to the given complex number.
   28.  V   a   asec -- asec("complexNumber") - Returns the inverse secant.
   29.  V   a   asin -- asin("complexNumber") - Returns the inverse sine.
   30.  V   a   asinh -- asinh("complexNumber") - Returns the inverse hyperbolic sine.
   31.  V   a   atan (1) -- atan("complexNumber") - Returns the inverse tangent.
   32.  V   a   atan (2) -- atan("1:complexNumber","2:complexNumber") - Returns the inverse tangent.
   33.  V   a   atanh -- atanh("complexNumber") - Returns the inverse hyperbolic tangent.
   34.  B   a   atm -- Atmosphere (Pressure) - atm = 1.01325e+5 kg/{m*s^2}
   35.  B   a   atom (Substance) atom = 1.6605391e-24 mol
   36.  B   a   au -- Astronomical unit  au = 1.495978707e+11 m
   37.  V   a   augment -- augment(...) - Returns a matrix formed by placing the arguments left to right. Arguments are matrices/vectors having the same number of rows, or they are scalars and row matrices.
   38.  B   b   Byte -- Byte (information)  B = 8 bit
   39.  B   b   Bar (Pressure)  bar = 10e+5 kg/{m*s^2}
   40.  B   b   Barn (Area)  barn = 10e-28 m^2
   ...
