@database Mathan.guide
@master Develop:mathan/doc/Mathan.guide

@node "Main" "Mathan V1.0"
                        -----------------------
                             @{b}@{fg shine} Mathan V1.2 @{ub}@{fg text}
                        -----------------------
                  Mathematical software for the Amiga.
    
  @{b}Wellcome to Mathan.@{ub}                @{"I.      Brief Introduction " link "Introduction" 0}
                                     @{"II.     Distribution " link "Distribution" 0}
  1996 Enrique Jimenez               @{"III.    Disclaimer " link "Disclaimer" 0}
                                     @{"IV.     System requirements " link "Requirements" 0} 
                                     @{"V.      Starting " link "Starting" 0}
   Enrique Jimenez                   @{"VI.     Functions " link "Functions" 0} 
   Romero Robledo 20, 3A             @{"VII.    Graphics " link "Graphics" 0}
   28008 MADRID                      @{"VIII.   Objects " link "Objects" 0} 
   SPAIN                             @{"IX.     Configuration " link "Configuration" 0}  
                                     @{"X.      DisplayM " link "External" 0}
  E-Mail:                            @{"XI.     Bugs " link "Bugs" 0}
                                     @{"XII.    Application examples " link "Applications" 0} 
   n109701@eicaiii.uc3m.es           @{"XIII.   Future " link "Future" 0} 
                                     @{"XIV.    History " link "History" 0} 
                                     @{"XV.     Author " link "Author" 0}
@endnode

@node "Introduction" "Introduction"


 INTRODUCTION 
 
 (Sorry for my bad english)

        Did  you ever  need  inverting  a  5x5 matrix, a  calculator with
 complex numbers, or solving (x+3)^4+2x+3=0?...

        The Amiga  has  plenty  of  killer  applications related to music,
 graphics, word proccesors, databases, etc..., but it lacks of engineering
 software (CAD/CAM, etc... ) and math programs like Mathemathica or MatLab
 for the IBM PC and Macintosh.
 
        Mathan  isn't  close  to these programs (yet), but it has a lot of
 advanced  features: You can plot a 3D  surface and then save it as an IFF
 ILBM  picture , solve  a linear  simultaneous equation system or find the
 eigenvalues of a square matrix.
 
        If you hate reading docs and want to see a fast demonstration of
 Mathan try the next command from the shell:
 
                 >mathan examples/demo.mth
                 
        (Use the cursor keys to rotate and +/- to magnify the image)
@endnode

@node "Disclaimer" "Disclaimer"


 DISCLAIMER
 
 
        This software and information is  provided  "as is". You use it at
 your own risk. No  representations or warranties are made with respect to
 the  accuracy, reliability, performance, currentness or operation of this
 software and  information.  The autor will not be liable for any  damages
 resulting from the use of this software.
@endnode

@node "Distribution" "Distribution"


  DISTRIBUTION
    
 
          This software and information is freely distributable, with
  the following limitations:
  
          - The package must remain complete and unchanged.
           
          - The package may be included on CD-ROMs, BBS, magazines
            or commercial distributions of software packages, but
            I ask you to inform the @{"Author" link "Author" 0}. 
            
          If you are using this program I ask you to send me a postcard
  or a message by E-Mail, so I know how many people is using my program
  and where my program is used. I have no intention of stopping
  development, but I would like to know whether the time I am investing
  is worth it.
@endnode

@node "Requirements" "Requirements"


 REQUIREMENTS
 
 
     Mathan requires the following system to run:
 
     * Workbench 3.0 or above.
     
     * 68020 or better.
@endnode

@node "Starting" "Starting"


  STARTING THE PROGRAM.
 
  There are two ways to start Mathan: from @{b}CLI@{ub} or from @{b}Workbench@{ub}. 
  
  When started from the @{b}Shell@{ub} without parameters, Mathan shows a prompt
  where you can enter the operations. If the parameter is a file name,
  then Mathan reads the operations from the file. To quit Mathan you
  may write the command 'Exit' or 'Quit' (NOTE the Upper case). 
  
  When started from the @{b}Workbench@{ub}, or when the parameter from the @{b}Shell@{ub}
  is -rexx, Mathan runs in the background, and accepts commands through
  an ARexx port called 'Mathan'. Mathan terminates when you send the
  command 'Exit' or 'Quit'. 

  Mathan may be used with any text editor or word processor with ARexx
  support. You can find some excelent shareware text editors in the
  public domain, like @{b}Blacks Editor@{ub} by Marco Negri, or you can use
  the AmigaDos text editor, @{b}Ed@{ub}.
  
  There are supplied ARexx scripts for @{b}Blacks Editor@{ub}, @{b}ProWrite@{ub} and @{b}Ed@{ub}.  
  If you use one of these programs, then you can try opening the file
  examples/demo.mth (for example), put the cursor in the line you want
  to evaluate and execute the ARexx macro for your editor (with @{b}Blacks@{ub}
  @{b}Editor@{ub} and @{b}ProWrite@{ub} you can assign the ARexx macro to a keyboard short
  cut, but with @{b}Ed@{ub} you can use @{b}FKey@{ub}).
  
  Otherwise you need to write an ARexx script for your text editor, then 
  assign the ARexx script to any menu item or keystroke, like CTRL-RETURN,
  to invoke Mathan to insert a result. SEE THE SUPPLIED SCRIPTS.
  The configuration can be a bit complicated for a novice user, so I hope
  to include more ARexx scripts in further versions. If you have any
  trouble, don't hesitate to contact me.
@endnode

@node "Functions" "Functions"


  FUNCTIONS
 


    Mathan supports standard built-in functions and @{"user functions" link "user_f" 0}.
    
         
    Built-in functions:
         
 
    Trigonometric (angular measurement unit = radians)
   
    Cos()            cosine
    Sin()            sine
    Tan()            tangent
    ArcCos()         arc cosine
    ArcSin()         arc sine
    ArcTan()         arc tangent
    Cosh()           hyperbolic cosine
    Sinh()           hyperbolic sine
    Tanh()           hyperbolic tangent
    Sec()            1/Cos()
    Cosec()          1/Sec()
    Sinc()           Sin(x)/x
    Cosc()           Cos(x)/x
    
    Logarithmic and exponential
   
    Exp()            e to the exponent
    Ln()             base e logarithm
    Log()            base 10 logarithm
    
    Other scientific calculations
    
    Abs()            absolute value
    Sgn()            sign
    Int()            interger
    Sqrt()           square root    
    
    @{"Complex" link "Complex" 0} related functions
    
    Mod()            magnitude of a complex number
    Arg()            phase of a complex number
    Re()             real part of a complex number
    Im()             imaginay part of a complex number
    
    @{"Matrix" link "Matrix" 0} related functions
    
    @{"Inverse()" link "Inverse_f" 0}        inverse of a matrix
    @{"Transpose()" link "Transpose_f" 0}      transpose of a matrix
    @{"EigenValues()" link "EigenValues_f" 0}    eigenvalues of a matrix
    @{"Det()" link "Det_f" 0}            determinant of a matrix
    @{"Pol()" link "Pol_f" 0}            characteristic polynomial of a matrix
    @{"LU()" link "LU_f" 0}             LU decomposition of a matrix
    @{"QR()" link "QR_f" 0}             QR decomposition of a matrix
    @{"LES()" link "LES_f" 0}            linear equation solver 
    
    @{"Polynomial" link "Polynomial" 0} related funtions
    
    @{"Roots()" link "Roots_f" 0}          polynomial roots
    
    @{"Special functions" link "Special" 0}
    
    Sum()            number addition
    Prod()           number multiplication
    NIntegrate()     numerical integration
    u()              unit step
      
    @{"Graphics" link "Graphics" 0} functions
    
    @{"Draw()" link "graphics" 0}           draw 2D/3D functions
    
    Special commands
      
    Exit             quit Mathan
    Quit             quit Mathan

    Predefined constants
        
    pi               pi=3.14159...
    i                i=Sqrt(-1)
    j                j=Sqrt(-1)
@endnode

@node "user_f" "User functions"


  USER FUNCTIONS
 

       You can define functions of eight parameters. The format is:
 
         <function name>(<parameter1,parameter2,...>)=<expresion>
         
        * The function name can be up to 255 characters.
        * The expresion may be any object: number, matrix, etc...
        * Everything is case dependent.
         
    Some examples:
 
         /* Constants */
         
         a=3
        
         /* A function of three variables */
         
         f(x,y,z)=Sin(x)*Cos(y)+z        
         
         /* You can use long names */
         
         abcdefghij(var)=Sqrt(var+1) 
         
         /* A matrix function of two parameters */
         
         W(q,r)={{1,Sin(r),Cos(q)},{Sin(r),r,6},{Cos(q),6,q}}
@endnode

@node "Inverse_f" "Inverse"
 Inverse()
 
         Inverse of a matrix.
         Example:
                 
         >a={{1,2,3,4},{2,3,4,1},{3,4,1,2},{4,1,2,3}}
                 1        2        3        4
                 2        3        4        1
                 3        4        1        2
                 4        1        2        3
         >b=Inverse(a)
                -0.225    0.025    0.025    0.275
                 0.025    0.025    0.275   -0.225
                 0.025    0.275   -0.225    0.025
                 0.275   -0.225    0.025    0.025
                
         You can verify the result calculating a*b. The result is the
         identity matrix, but due to the number precision there are some
         rounding errors, so you can get numbers like 1e-16. You can
         assume these numbers to be 0.
@endnode

@node "Transpose_f" "Transpose"
 Transpose()
 
         Transpose of a matrix.
         Example:
         
         >c={{1,8,4},{2,3,1}}
                 1        8        4
                 2        3        1
         >Transpose(c)
                 1        2
                 8        3
                 4        1
@endnode

@node "LU_f" "LU"
                 
 LU()
         
          LU decomposition of a matrix. The format is:
          LU(<A matrix>,"<P name>","<L name>","<U name>")
          
          The function returns three matrices, P is a permutation matrix,
          L a low triangular and U an upper triangular matrix, and
          
                  A=P*L*U
                  
           Example:
           
           >a={{1,2,3,4},{2,3,4,1},{3,4,1,2},{4,1,2,3}}
                 1        2        3        4
                 2        3        4        1
                 3        4        1        2
                 4        1        2        3
           >LU(a,"p","l","u")
           >p
                0       0       0       1
                0       0       1       0
                0       1       0       0
                1       0       0       0
          >l
                1       0               0               0
                0.75    1               0               0
                0.5     0.769231        1               0
                0.25    0.538462        0.818182        1
          >u
                4       1       2         3
                0       3.25    -0.5      -0.25
                0       0       3.384615  -0.307692
                0       0       0         3.636364
                
          You can verify that a=p*l*u.
          
          >p*l*u
                1       2       3       4
                2       3       4       1
                3       4       1       2
                4       1       2       3
@endnode

@node "QR_f" "QR"
 QR()
 
          QR decomposition of a matrix. The format is:
          QR(<A matrix>,"<Q name>","<R name>")
                  
                  A=Q*R
          
          Q is ortogonal and R triangular.
          
          Example:
          
          >a={{1,2,3,4},{2,3,4,1},{3,4,1,2},{4,1,2,3}}
                 1        2        3        4
                 2        3        4        1
                 3        4        1        2
                 4        1        2        3
          >QR(a,"q","r")
          >q
          0.182574        0.365148        0.490098        0.770154
          0.365148        0.426006        0.536774       -0.630126
          0.547723        0.486864       -0.676802        0.070014
          0.730297       -0.669439        0.11669         0.070014
          >r
          5.477226        4.38178           4.016632        4.38178
          0               3.286335          1.947458        0.852013
          0               0                 3.173968        1.493632
          0               0                 0               2.80056
          >q*r
          1       2       3       4
          2       3       4       1
          3       4       1       2
          4       1       2       3
@endnode

@node "Det_f" "Det"
 Det()
 
         Determinant of a matrix.
         
         Example:
         
         >a={{1,2,3,4},{2,3,4,1},{3,4,1,2},{4,1,2,3}}
                 1        2        3        4
                 2        3        4        1
                 3        4        1        2
                 4        1        2        3
         >Det(a)
                 160
@endnode

@node "LES_f" "LES"
 LES()
 
          Linear equation system solver. Format:
                  
                  LES(<A matrix>,<b matrix>)
          
          The function returns the x solution of: A*x=b
          
          Example:
          
          Imagine the system:
          
           2u +  v + w =  1
           4u +  v     = -2
          -2u + 2v + w =  7
          
          In the matrix notation:
          
           2         1        1         u        1
           4         1        0  *      v   =   -2
          -2         2        1         w        7
          
          >A={{2,1,1},{4,1,0},{-2,2,1}}
          >b={1,-2,7}
          >LES(A,b)
                  -1
                   2
                   1
          
          Then the solution is
                  u = -1
                  v =  2
                  w =  1
@endnode

@node "Pol_f" "Pol"
 Pol()     
     
          Characteristic polynomial of a matrix.
                
                Det(A-xI)
                
          Example:
          
          >mat={{1,0,3},{3,-1,2},{4,1,2}}
          >Pol(mat)
                  (x)^3-2*(x)^2-15*x-17
@endnode

@node "EigenValues_f" "EigenValues"
 EigenValues()
 
          Eigenvalues of a matrix.
          
                  Det(A-xI)=0
                  
          Example:
          
          >mat={{1,0,3},{3,-1,2},{4,1,2}}
          >EigenValues(mat)
                   5.377185         0
                  -1.688687        -0.556536
                  -1.688687         0.556536
                  
          The first column is the real part, and the second the imaginary
          part, so the eigenvalues are:
          
                   5.377185
                  -1.688687 - 0.556536*j
                  -1.688687 + 0.556536*j
          
          You can get the same result with 
          
          >Roots(Pol(mat))
@endnode

@node "Roots_f" "Roots"
                  
 POLYNOMIAL ROOTS
 
          The Roots() function calculates the polynomial roots, but this 
          will not work with multivariable polynomials.
          
          Example:
          
          >Roots(x^4+5x^3+7x^2-3x-10)
           -2    0
            1    0
           -2   -1
           -2    1
           
          The roots are -2,1,-2+i and -2-i. You can verify the result:
          
          >(x+2)(x-1)(x+2-i)(x+2+i)
           (x)^4+5*(x)^3+7*(x)^2-3*x-10+0*i
          
          NOTES: 
         
        * Mathan can't calculate the roots of multivariable polynomials
          like x^2+2y-3z+1.
          
        * For polynomials like Sin(x)*Sin(x)-1, the roots are for the 
          polynomial variable Sin(x), not x. Example:
          
          >f(x)=Sin(x)*Sin(x)-1
          >Roots(f(x))
           -1   0
            1   0
           
          Then the roots are in Sin(x)=-1, Sin(x)=1. The solutions are 
          
                  x=pi/2+k*pi (k=0,1,2,...)
@endnode

@node "Special" "Special"


 SPECIAL FUNCTIONS
 
 
   Sum()
         
         Format:
                 Sum("<function>",<range>)
         
                 <range>={"<variable name>",<start>,<stop>}
         
         Example:
         
         >Sum("x^2",{"x",0,5})
          55
          
         (0^2+1^2+2^2+3^2+4^2+5^2 = 55)
         
   Prod()
   
           Format:
                   Prod("<function>",<range>)
                   
                   <range>={"<variable name>",<start>,<stop>}
                   
           Example:
           
           >Prod("x^2",{"x",1,5})
            14400
            
           (1^2*2^2*3^2*4^2*5^2 = 14400)
   
   NIntegrate()
   
           Format:
                   NIntegrate("<function>",<range>)
                   
                   <range>={"<variable name>",<start>,<stop>}
           
           Example:
           
           >NIntegrate("x*x",{"x",0,3})
            9
            
   u()        
           Unit step, or Heaviside function:
           
           u(x)=0 if x<0
           u(x)=1 if x>=0         
              
              Example:
              
              >Draw("{x,1+(x^2-x)*u(x-1)}",{"x",-2,2,100})
@endnode

@node "Graphics" "Graphics"


  GRAPHICS
  
  Drawing functions.     
          
        Draw("<point>",<range>,[<range>])
        
        <point> = {x,y,z,[color]} or {x,y} 
        
        <range> = {"name",start,stop,[count]}
          
  Drawing 2D functions.
         
        This example draws the Sin() function calculating 30 points
        between 0 and 2pi. The more points (count parameter), the
        more accurate plot. Note that the count parameter is not the
        step between points. The step is calculated (stop-start)/count.
            
          Draw("{x,Sin(x)}",{"x",0,2pi,30}) (@{"click here" link "sin.gif/main" 0} to see the result)
        
        You can print or save (IFF ILBM) the image in the Project menu,
        or set axis labels and ranges in the settings menu.
        
        Mathan can draw multiple functions if <point> is a matrix, for
        example:
        
          Draw("{{x,Sinc(x)},{x,Exp(-x)}}",{"x",0,2pi,40}) (@{"click here" link "multi2.gif/main" 0})
       
        There is a mode submenu in the settings menu to change the way
        points are connected (@{"click here" link "multi1.gif/main" 0}).   
          
  Drawing 3D functions.
          
        Try the next line (draws a @{"cube" link "cube.gif/main" 0}):
          
          Draw("{Cos(x),Sin(x),y}",{"x",-pi,pi,4},{"y",0,Sqrt(2),1})
                           
        This example draws the function f(x,y)=x*x-y*y in the range
        -2<x<2 and -3<y<3, calculating 20*20=400 points (@{"click" link "hypb.gif/main" 0}).
          
          Draw("{x,y,x*x-y*y}",{"x",-2,2,20},{"y",-3,3,20})
        
        In the 3D window the observer point can be rotated with the 
        keyboard cursor. Press the +/- keys to change the scale.
        
        If a function goes towards the infinity, then mathan will have
        problems calculating the scale factor, and you will not se anything
        in the window, but you can set the scale factor changing the "max"
        parameter in the settings menu, or cutting the function with the
        "cut" parameter.
   
  Drawing 3D functions with color filled polygons.
  
        Mathan can display 3D color graphics adding a fourth number, 
        specifing the color pen to be used to fill the polygon. This
        number may be a function, and is rounded to an integer to 
        select a valid pen number. You can obtain images with 256
        colors openning a Workbench Screen with 256 colors, and 
        setting an appropiate Palette. Perhaps it wold be better
        interpreting the value as an RGB integer, so this feature is
        open to changes in further versions.
        
        This option is also useful to remove the hidden lines behind
        the surface.
        
        Example:
        
         Draw("{x,y,x*x-y*y,Abs(x+y)}",{"x",-2,2,10},{"y",-2,2,10})


    *   NOTES
            
        -If you save the graphic as ASCII, then you can import the data 
         from any program like Excel and add axis labels and so on, or
         display the data with the program displaym.
   
        -The graphic window multitasks with Mathan. You can have several
         windows at once.                 
 
        -You have these examples and more in the file examples/demo.mth,
         so you can execute them with the command (from the Shell):
        
                >mathan examples/demo.mth
@endnode

@node "Objects" "Objects"


  OBJECTS
  
        Mathan  works  with  several types of objects. Some functions only
 deal with certain objects types, and some operations are not allowed.


        List of objects types:
  
                @{"Real" link "Real" 0}
                @{"Complex" link "Complex" 0}
                @{"Matrix" link "Matrix" 0}
                @{"Polynomial" link "Polynomial" 0}
                @{"String" link "String" 0}
@endnode

@node "Real" "Real"


  REAL NUMBERS
  
          Real numbers are C-style signed double precision floating point
  numbers. The range depends of the implementation, in the Amiga the
  range is from 2.222E-308 to 1.797E+308. I'd have no problem changing
  the real type to long double in the source code, but this is planed
  for further versions.
    
          Internally mathan uses integer numbers for some operations. For
  example, type in a normal calculator:
     
          (2/15)*3
          
          You will get the reply 0.39999999, because the floating point
  format used by computers is not exact. You can see that:
  
          (2/15)*3 = 2/5 = 4/10 = 0.4
  
          Mathan will try to avoid using the floating point format. Mathan
  knows that (2/15)*3 is not (0.13333333)*3, but the fraction 2/5.
@endnode

@node "complex" "complex"


 COMPLEX NUMBERS
 
 
         Entering complex numbers is simple. Some examples:
         
                 3+2i
                 3+2j
                 (2+2i)*(4+i)/(2-i)
                 
         Mathan accepts "j" and "i" as constant functions with the value
  Sqrt(-1). Note that (2+3)i is 5*i, but i(2+3) is i(5), and i(5) is i,
  because "i" is constant. I recommend using the "*" symbol to prevent
  errors (see also @{"multiplicaton notes" link "Bugs" 0}).
@endnode

@node "Matrix" "Matrix"


 MATRIX OBJECTS
 
 
         The { and } symbols can be used to enter a matrix. For example:
         
                 A={{1,2,3},{4,5,6},{3,1,2}}
         
         
                         1 2 3
                      A= 4 5 6
                         3 1 2
        
        The matrix dimension is limited to 1000 elements in this version,
  so mathan can handle matrices up to 30x30 or 50x20. In further versions
  only the amount of free memory will restrict the matrix size.
  
          See Also:
         
         @{"Inverse()" link "Inverse_f" 0} 
         @{"Transpose()" link "Transpose_f" 0} 
         @{"Det()" link "Det_f" 0}     
         @{"LU()" link "LU_f" 0}
         @{"QR()" link "QR_f" 0}
         @{"LES()" link "LES_f" 0}   
         @{"Pol()" link "Pol_f" 0}     
         @{"EigenValues()" link "EigenValues_f" 0}
@endnode

@node "Polynomial" "Polynomial"


 POLYNOMIAL
 
         Mathan can operate with polynomials of order n. For example:
         
                 >(x+2)(x+3)^2
                  (x)^3+8(x)^2+21*x+18
         
         (if the variable x is defined then the result will be different)
         
         The polynomial can be composed of several variables:
         
                 >x*(y+z)^2
                  x*(y)^2+x*(z)^2+2*x*y*z
                  
             
         See Also:
             
         @{"Roots()" link "Roots_f" 0}
@endnode

@node "String" "String"


  STRING OBJECT
  
          Sometimes Mathan needs a variable name, not the current value of
  the variable, or needs a expression to evaluate later, not the current
  value of the expression. For this reason the string object is used.
  Some examples:
  
          "x"     (the variable x, not the current value)
           
           Sum("3x+2",{"x",1,3})
           Draw("{x,y,x*x+y*y}",{"x",-2,2},{"y",-2,2})
@endnode

@node "Configuration" "Configuration"


  CONFIGURATION
  
  
  Mathan needs some files to run:
  
  config/mathan.dfn
  dispthd
  
  You can edit the file mathan.dfn to translate the error messages
  to your language.
  
  Mathan needs the file dispthd to draw graphics.
@endnode

@node "External" "External Programs"


   DISPLAYM
   
   I'm suppling another program with Mathan: DisplayM
  
   DisplayM displays any graphic saved in the ASCII format. The ASCII
   files created by Mathan have four lines of internal parameters, and
   then the data. You can import the data from any spreadsheet removing
   the first four lines, or use DisplayM to display data generated by
   other programs adding the four lines with the correct values:
   
   line 1: dimension        (2 for 2D, 3 for 3D)
   line 2: draw mode        (use the value 6)
   line 3: m
   line 4: n
   line 5: (data)
     .
     .
     .
     
   The total number of points is m * n, so if there are 100 points you
   can set m=100 and n=1.
@endnode

@node "Bugs" "Bugs"


  BUGS AND NOTES
  

 Multiplication Notes.

        Mathan accepts implicit multiplication. When no operator is found
        multiplication is assumed.
 
                 3x     is 3*x
                 3(2+3) is 3*(2+3)
                 
        Sometimes you must write the "*" symbol:
         

        - xy is not x*y, but the function xy().
        
        - (3+2)x is parsed as 5*x, but x(3+2) is parsed as x(5), this is
          the function x with parameter 5. If the function x has no
          parameters (constant), then the parameters are ignored. 
          
        - 3e or 3E is not 3*e or 3*E, but 3e0 and 3E0 (i.e. 3*10^0).
          You must write the "*" before any function starting with "E",
          because Mathan reads the numbers in the scientific format.
          
          
 Bugs
 
        My system hasn't MMU, so I haven't tested Mathan with Enforcer.
        However, I have tested Mathan with MungWall, and it reported
        no errors.
 
        Bug reports can be sent to:
        
        e-mail:        n109701@eicaiii.uc3m.es
        
        or:
         
        Enrique Jimenez
        Romero Robledo 20, 3°A
        28008 MADRID
        SPAIN
@endnode

@node "Future" "Future"


 FUTURE
 
        I have no intention of stopping development. 
        I'm working in:
         
         
         - Bugs.
         - OS-independent source code.
            (I hope to compile an Unix/X Window version.) 
         - Derivation and integration (Numerical&Symbolic).
         - Quaternions
         - Matrix algebra.
            (EigenVectors,Singular Value Decomposition,...)
         - System analysys, control and estability.
            (Simulation, @{"Bode Plots" link "bode" 0}, @{"Root Locus" link "rlocus" 0} Plots,PID design,...)
         - Numerical methods for Ordinary and Partial differential
           Equations.         
           
         - Graphic User Interface for Mathan.
         - ARexx macros for all the text editors/word processors.
         - Interface with other software.
@endnode

@node "Applications" "Application examples"


  APPLICATION EXAMPLES
  
                  Example I:   @{"Linear Regression." link "regression" 0}
                  Example II:  @{"Bode Plots." link "bode" 0}
                  Example III: @{"Root Locus." link "rlocus" 0}
@endnode

@node "regression" "Linear Regression"

 EXAMPLE I
  
          Linear Regression.
   
          (Less Squares Method for Incompatible Linear Equation Systems)
      
          We don't know the function f(x,y,z), but we have the
          experimental data:
          
           x    y     z     f
           
           2    1     1     2
           4    1     0    -1
          -2    2     1     8
           1    1     1     5
           4    2     2     3  
          
          We think that f(x,y,z) is like 
          
                  f(x,y,z)=ax+by+cz+d
          
          So we have the system:
          
           2a+ b+ c+d= 2
           4a+ b+  +d=-1
          -2a+2b+ c+d= 8
            a+ b+ c+d= 5
           4a+2b+2c+d= 3
           
          Without the last equation we get a=-3,b=-6,c=-3,d=17.
          
          >A={{2,1,1,1},{4,1,0,1},{-2,2,1,1},{1,1,1,1}}
          >b={2,-1,8,5}
          >LES(A,b)
                   -3
                   -6
                   -3
                   17
                   
          But the last equation shows that the system is incompatible:
         
          >g(x,y,z)=-3x-6y-3z+17
          >g(4,2,2)=-13
          
          We can find the best function using the less squares method: 
          
          >A={{2,1,1,1},{4,1,0,1},{-2,2,1,1},{1,1,1,1},{4,2,2,1}}
          >b={2,-1,8,5,3}
          >AA=Transpose(A)*A
          >bb=Transpose(A)*b
          >LES(AA,bb)
                  -1.162162
                   0.486486
                   1.756757
                   3.054054   
           
          Then the best approximation is:
                  a=-1.162162
                  b=0.486486
                  c=1.756757
                  d=3.054054
@endnode

@node "bode" "Bode Plots"

  EXAMPLE II
 
          Bode Plot of a transfer function.
 
          We are going to draw the Bode Plot of the Example C-3 from the
          book Microelectronics (Millman/Grabel).
        
          We need to draw the magnitude of F(jw) in dB versus Log(w).
          Note that F(jw) is a function of complex variable. If we want
          to evaluate the function in the range from 0.1 Hz to 10 KHz
          then we can type:   
                
          >Draw("{Log(w),20*Log(Mod(F(i*w)))}",{"w",0.1,10000,100})
          
          This is not very accurate for low frecuencies because Mathan
          calculates a point every 100 rad/s. If we set the count parameter
          to 1000 the step is 10 rad/s, but Mathan will waste much time.
          We solve this problem using y=Log(w) from -1 to 4 and 
          evaluating the function in 10^y.  
                        
          >F(s)=1e4*(s+40)/(s^2+410s+4000)
          >Draw("{y,20*Log(Mod(F(i*10^y)))}",{"y",-1,4,100})
        
          @{"Click here" link "bode.gif/main" 0} to see the result.
@endnode

@node "rlocus" "Root Locus"

 EXAMPLE III
 
          Root Locus. 

          Imagine that our feedback control system has poles at 
          s=-5,s=-3,s=-1 and a zero at s=-4 (in open chain).

          We want to plot the Root Locus for the polynomial
          (s+5)(s+3)(s+1)+k(s+4)=0 for k>0. Note that the Roots()
          function is designed to return the roots in a Nx2 matrix,
          and that Draw() accepts the matrix to draw N 2D graphics,
          so it is very easy to draw the Root Locus.
                
          >f(s)=(s+5)(s+3)(s+1)+k(s+4)
          >Draw("Roots(f(s))",{"k",0,100,100})
        
          @{"Click Here" link "rlocus.gif/main" 0} to see the result. Actually, the graphic was 
          calculated with 1000 points (not 100 as above), and you
          need to set the draw mode in the settings menu to "points"
          or "draw 2", because the default is "draw 1&2".
@endnode

@node "History" "History"


   HISTORY
   
   
   Version    Date       Comment
   
   V1.0ß      17- 4-96    First release.
   V1.1       17- 7-96    Better graphic drawing and other improvements.
   V1.1(PC)    7-10-96    First IBM PC release.
   V1.2        3-11-96    Filled polygon drawing and color graphics.
                          Numerical integration.
@endnode

@node "Author" "Author"
  AUTHOR
      
        I'm a 21 years old engineering student in Madrid, Spain. Mathan is
 my first program, and it was  written  in  standard C using the DICE V3.0
 compiler on an  Amiga 1200 with a  68030/50Mhz, 6 Mb of memory and 430 Mb
 of HD.
  
        About 90% of the code is ANSI C.  There is a IBM PC DOS version of
 Mathan... but it seems  that the whole PC users community is playing
 Doom...       
                    
        Queries, comments,  bug reports,  suggestions  or anything are all
 wellcome, and can be sent to:
        
        Enrique Jimenez
        Romero Robledo 20, 3°A
        28008 MADRID
        SPAIN
        
        e-mail:        n109701@eicaiii.uc3m.es
@endnode

