home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / educatio / jabr103.zip / TUTORIAL.DOC < prev   
Text File  |  1991-04-06  |  13KB  |  413 lines

  1.  
  2.  
  3.  
  4.                              Tutorial for Al-Jabr V1.03
  5.  
  6.                                   by Uchenna Ogbuji
  7.  
  8.           This tutorial is very easy to use. Print it out as you will not be
  9.      able to view it on screen while Al-Jabr is running. You simply enter the
  10.      commands you are asked to and read the commentary on the results. The
  11.      commands are denoted by a ">" sign at the beginning of the line. This
  12.      symbolises the Al-Jabr command prompt and you should not include it in your
  13.      commands. Any text that doesn't have a ">" sign at the beginning of the
  14.      line is a comment and should not be entered at the command prompt. You
  15.      don't have to try alll the examples and you can skip over any material you
  16.      feel you have a good grasp of. At any point you can enter "quit" at the
  17.      command prompt and you will be returned to DOS.
  18.           Please read readme.doc first as it gives information on Al-Jabr's
  19.      minimum requirements and which file you should run.
  20.      ------------------------------------------------------------
  21.  
  22.  
  23.           Let us start simple. Al-Jabr has 26 variables you can use, each
  24.      denoted by a single letter. You can assign a value to a variable. The
  25.      simplest assignment, of course, is just to assign a number:
  26.  
  27.      >v = 3.678
  28.  
  29.      remember that the above line starts with a ">" sign so you should enter "v
  30.      = 3.678" at the ">" prompt in Al-Jabr. When you do, Al-Jabr will respond
  31.      with "= 3.678". This tells you that the number 3.678 has been successfully
  32.      stored in the variable v.
  33.  
  34.      >u = v
  35.  
  36.      now Al-Jabr still reports "= 3.678". Perhaps you have figured it out by
  37.      now. The variable v contains the value 3.678 and will always contain that
  38.      value until you assign it another value.
  39.  
  40.      >u = v + 6
  41.  
  42.      now the value in v, 3.678, is added to 6 and placed in u. Al-Jabr reports
  43.      that 9.678 is assigned to u.
  44.  
  45.      >f = v * 8.6e-3
  46.  
  47.      here v (still 3.678) is multiplied by 8.6e-3 (which is the computer
  48.      exponential form for 8.6*10^-3 or .0086) and the result (.0316308) is
  49.      placed in f. Al-Jabr has two special stored constants:
  50.  
  51.      >d = :p
  52.  
  53.      you will find 3.14159265 has been assigned to d. Some of you will recognise
  54.      this number. It is the ratio pi. :p is a short form of this number for Al-
  55.      Jabr. :e is the short form of e (2.718281828), the base of natural
  56.      logarithms, also known as Naperian logarithms.
  57.  
  58.      >f = :e ^ 2  +  d
  59.  
  60.      will place 10.5306488 in f. There is one more stored constant you will
  61.      encounter soon. Let us now explore the functions supported by Al-Jabr:
  62.  
  63.      >y = sin t
  64.  
  65.      should return 0 because since t hasn't been assigned a value yet, it is
  66.      assumed to be 0, and the sine of 0 is 0.
  67.  
  68.      >g = 4! + abs (-10)
  69.  
  70.      should return 34. First the factorial of 4 (4*3*2*1) is computed and then
  71.      added to the magnitude of -10 (10).
  72.  
  73.      >b = 2 * :p
  74.         = 6.28318531
  75.  
  76.      >c = sin (cos b) + atan (log 54)
  77.  
  78.      should return 1.88875426, the sine of the cosine of 2 times pi plus the
  79.      arctangent of the base ten logarithm of 54.
  80.  
  81.      >r = sqrt 16
  82.  
  83.      will return 4, the square root of 16. However if you execute
  84.  
  85.      >v = -16
  86.         = -16
  87.  
  88.      >r = sqrt v
  89.  
  90.      you will encounter a domain error because Al-Jabr cannot return the square
  91.      root of a negative number. For a detailed list of the functions supported
  92.      by Al-Jabr, see part I of the manual.
  93.  
  94.           Al-Jabr can compute the sum or product of sequences. I will show you a
  95.      few examples so you might figure out what is going on. To sum up all the
  96.      integers from 1 to 10, you would enter:
  97.  
  98.      >s = [n=1,10,1,n]
  99.         = 55
  100.  
  101.      first the sum is initialised to 0, then n is set to 1 and this is added to
  102.      the sum. n is then increased by 1 and this is added to the sum. This keeps
  103.      on going until n becomes greater than 10 which is the stop value. Then the
  104.      loop ends and the sum is assigned to s. To compute the sum of the squares
  105.      of the integers from 1 to 10 you enter:
  106.  
  107.      >c = [m=1,10,1,m^2]
  108.         = 385
  109.  
  110.      To sum up the square roots of all the integers from 10 to 100 and then add
  111.      50 to the sum enter:
  112.  
  113.      >h = [j=10,100,1,sqrt j] + 50
  114.         = 702.156947
  115.  
  116.      Here sum is initialised to 0, j is set to 10 and then the square root is
  117.      found and added to the sum. j is then increased by 1 and the process is
  118.      repeated until j is greater than 100. Then the sum is added to 50 and
  119.      assigned to h. To sum up all the odd numbers from 11 to 25 you could enter:
  120.      >v = [l=11,25,2,l]
  121.         = 144
  122.  
  123.      here l is increased by 2 at a time rather than 1 thus the above effectively
  124.      computes 11 + 13 + 15 + 17 + 19 + 21 + 23 + 25. Note that the start value,
  125.      the end value and the increment do not have to be integers:
  126.  
  127.      >s = [f=1.5, 3.5, 0.5, log f]
  128.         = 1.89625056
  129.  
  130.      adds log (1.5) + log (2.0) + log (2.5) + log (3.0) + log (3.5) and returns
  131.      the sum to s. Finding the product of the sequence is similar except that
  132.      you use curly brackets {} instead of square brackets. For instance
  133.  
  134.      >p = {f=1.5,3.5,0.5, log f}
  135.         = 0.00547579472
  136.  
  137.      finds log (1.5) * log (2.0) * log (2.5) * log (3.0) * log (3.5) and assigns
  138.      the product to p. See the manual for a more detailed coverage of the syntax
  139.      and operation of Al-Jabr's sum and product of sequence functions. Now try
  140.      something interesting. Enter
  141.  
  142.      >show all
  143.  
  144.      You should see a display of all your variables and their contents. This is
  145.      useful when you need to know what the variables contain. You don't have to
  146.      display them all to check the value of one, though, if you want to see just
  147.      what's in p for instance, you would enter
  148.  
  149.      >show p
  150.      p = 0.00547579472
  151.  
  152.      Now try this:
  153.  
  154.      >w = 45 * 2
  155.         = 90
  156.  
  157.      >s = :e
  158.         = 2.718281828
  159.  
  160.      note that each variable is automatically updated in the display as you
  161.      alter it.
  162.           
  163.           Try the following sequence of commands:
  164.  
  165.      >x = 1
  166.         = 1
  167.      >y = cos (3*x/2) + sin (x/2)
  168.         = 0.55016274
  169.      >store
  170.      cos (3*x/2) + sin (x/2) has been stored as expression #1
  171.      >f = #1
  172.         = 0.55016274
  173.  
  174.           You will find that f has been assigned the same thing as y. Now try:
  175.  
  176.      >x = :p
  177.         = 3.14159265
  178.      >z = #1
  179.         = 1
  180.  
  181.      Let me explain the above. the store command stores the last expression that
  182.      you worked with in memory. It calls the first expression it stores #1, the
  183.      second, #2 etc. up to #9. Thus you can store up to 9 expressions in memory
  184.      at a time. In the above sequence I stored "cos (3*x/2) + sin (x/2)" as
  185.      expression #1. At the time x contained 1 so #1 was evaluated as "cos (3/2)
  186.      + sin (1/2)" and f was assigned 0.5501627, the result. But when I changed x
  187.      to pi, the value of #1 changed as well. You can incorporate stored
  188.      expressions in to other expressions too. Eg.
  189.  
  190.      >q = #1 ^ 2 + #1 + 3.0
  191.         = 5
  192.  
  193.      There is a short-cut for storing expressions:
  194.  
  195.      >store b = 6 * :e - ln 5
  196.         = 14.7002531
  197.  
  198.      does exactly the same thing as
  199.  
  200.      >b = 6 * :e - ln 5
  201.  
  202.      >store
  203.  
  204.      You can display stored expressions just as you can stored variables:
  205.  
  206.      >show #1
  207.  
  208.      displays expression #1, while
  209.  
  210.      >show #all
  211.  
  212.      displays all the currently stored expressions. Here's a neat trick: try
  213.  
  214.      >store z = k^2
  215.         = 0
  216.      k^2 has been stored as expression #3.
  217.  
  218.      >y = {k=2,11,3,#3}
  219.         = 774400
  220.  
  221.      does exactly the same thing as
  222.  
  223.      >y = {k=2,11,3,k^2}
  224.         = 774400
  225.  
  226.      that is it finds 2^2 * 5^2 *8^2 * 11^2.
  227.  
  228.           If you have a printer connected enter
  229.  
  230.      >print
  231.  
  232.      as you can see the "print" command sends all the variables and stored
  233.      expressions to the printer.
  234.  
  235.           Now we finally get to Al-Jabr's graphical capabilities. Let us say we
  236.      want to plot the graph of y=4*x^2 + 2*x + 1 between x=-5 and x=5, and
  237.      between y=-20 and y=20, we could enter
  238.  
  239.      >plot x;4*x^2 + 2*x + 1;-5,5,-100,100
  240.  
  241.           If we wanted to plot the graph of d=v*cos v  between x=-3 and x=5 and
  242.      we didn't know the maximum and minimum values of d in this interval, yet we
  243.      wanted to show the entire function, we could enter:
  244.  
  245.      >plot v;v*cos v;-3,5
  246.  
  247.      since we didn't specify the range of the vertical axis Al-Jabr
  248.      automatically calculates it so that the entire function is shown. Note that
  249.      Al-Jabr cannot always compute the maximum and minimum vertical axis values.
  250.      For example if you enter
  251.  
  252.      >plot n;log -n;-2,2
  253.  
  254.      Al-Jabr will respond with an error when n becomes 0 and return you to the
  255.      command prompt. This is because log 0 is an infinite quantity and Al-Jabr
  256.      cannot display infinite quantities! To view the graph of this function you
  257.      will have to specify the vertical axis range yourself. For example you
  258.      might decide to see the portions of the graph that fall between -6 and 6 on
  259.      the vertical axis:
  260.  
  261.      >plot n;log -n;-2,2,-6,6
  262.  
  263.           Note that each time you plotted a new graph the viewing area is
  264.      cleared. You can plot a new graph uopn an existing one but you must use the
  265.      "over" command. For instance, to show the graph of r=tan (t^2) over the
  266.      last graph you plotted enter
  267.  
  268.      >over t;tan (t^2)
  269.  
  270.      and slect any color you would like for the new graph. Note that there are
  271.      no axis specifications. Over automatically displays the graph in the same
  272.      region as the last one and you shouldn't specify horizontal or vertical
  273.      axis ranges. There are 4 colors available to help you differentiate between
  274.      graphs. You can keep displaying graphs over and over each other in any
  275.      combination of white, grey, cyan and yellow ad infinitum.
  276.           
  277.           Al-Jabr can calculate a polynomial of best statistical fit to a set of
  278.      data and plot the graph of the polynomial. This is accomplished with the
  279.      "cfit" command. There is a sample file called infile.dat that should have
  280.      come with Al-Jabr. If it is in the current directory enter
  281.  
  282.      >cfit infile.dat
  283.  
  284.      You can view the contents of infile.dat at the MSDOS prompt by entering
  285.      "type infile.dat". As you will see, infile.dat just consists of several
  286.      sets of numbers. These numbers constitute the data that Al-Jabr attempts to
  287.      fit a curve to. These data points are shown as small green circles on the
  288.      graph. See the manual (part II, subheading "CFIT:") for a description of
  289.      the syntax of the data files.
  290.           One of Al-Jabr's most useful abilities is its ability to capture its
  291.      graphical displays to a .PCX format file. If you have a graph on the screen
  292.      right not, try capturing it to a file called sample.pcx with the command
  293.  
  294.      >capture sample.pcx
  295.  
  296.      You can later manipulate sample.pcx as any PCX format file and incorporate
  297.      it into other programs.
  298.  
  299.           Al-Jabr's commands are more fully described and explained in the
  300.      manual, part II.
  301.  
  302.           Now we shall explore some common error conditions and what might cause
  303.      them.
  304.  
  305.      >hello
  306.      Error 00: Unrecognized command.
  307.  
  308.      "hello" is not one of the commands that Al-Jabr understands.
  309.  
  310.      >plot 3*d;0,10
  311.      Error 01: Syntax error in command.
  312.  
  313.      The independent variable wasn't specified and thus Al-Jabr couldn't plot
  314.      the graph you requested.
  315.  
  316.      >plot d;3*d;0,10
  317.  
  318.      should work. Some errors have mathematical causes:
  319.  
  320.      >store y = acos -4
  321.      Error 03: The argument to acos is out of its domain.
  322.  
  323.      the argument to the arccosine function must be between -1 and +1.
  324.  
  325.      >x = 0
  326.         = 0
  327.      >z = 5 + 6/x
  328.      Error 06: Division by zero.
  329.  
  330.      Division by zero yields an infinite quantity, which Al-Jabr cannot handle.
  331.  
  332.      >h = 3.45e -3
  333.      Error 07: Syntax error in expression.
  334.  
  335.      No spaces are permitted whithin a number. Try
  336.  
  337.      >h = 3.45e-3
  338.  
  339.      Some errors are more subtle:
  340.  
  341.      >plot x;3 - 2*x^2;3,-5
  342.      Error 11: Invalid horizontal axis range.
  343.  
  344.      the minimum horizontal axis value (3) cannot be greater than the maximum (-
  345.      5)!
  346.  
  347.      >plot x;3 - 2*x^2;-5,3
  348.  
  349.      should work.
  350.  
  351.           Well by now you should have obtained a working knowledge of the
  352.      functioning of Al-Jabr. You might want to experiment some on your own. If
  353.      not you can enter
  354.  
  355.      >quit
  356.  
  357.      at the command prompt to exit to dos. For a more detailed guide to using
  358.      Al-Jabr, I'd advise you to read the manual. If you encounter a problem and
  359.      need to contact me, read the readme.doc file. I hope you enjoy using Al-
  360.      Jabr. I welcome any constructive suggestions and criticisms of the program,
  361.      manual, or this tutorial.
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.