
                  Kalkulator How-To (December 22, 1997)
                  =====================================

-------------------------------------------------------------------

NEW OR CHANGED TOPICS in the 97/12/22 release: Q-18, Q-19

NEW TOPICS in the 96/12/14 release: Q-17, Q-18

NEW TOPICS in the 96/11/05 release: Q-15, Q-16

NEW TOPICS in the 96/08/29 release: Q-13, Q-14

-------------------------------------------------------------------

NOTE: in these examples we assume you are currently in the
      Kalkulator Main Window and that the Expression line has been
      cleared (hit Escape to clear it if necessary).

-------------------------------------------------------------------

Q-01: How to compute 2/3-3/7 ??

A: Using the keyboard or mouse, enter

      2/3-3/7

   and hit the Return key.

-------------------------------------------------------------------

Q-02: How to show the result of the previous calculation as a
      fraction?

A: Press Alt-M [Format] and then R [Fraction].

-------------------------------------------------------------------

Q-03: How to convert 120 watts into horsepower units?

A: Enter 120 and hit Return. Press Alt-N [Convert]. Select "Power"
   from the top selector, then "watts" from the middle one, then
   "horsepower(MKS)" from the bottom one. Click on [OK]. The
   result should be 0.16...

-------------------------------------------------------------------

Q-04: A box-shaped container is 2 feet 2.5 inches tall, 1 foot
      2 1/3 inches wide and 10 3/8 inches deep. What is its volume
      in gallons?

A. Thank you for asking. First let us compute the volume in cubic
   feet; type

       ft(2,2.5)*ft(1,2+1/3)*ft(0,10+3/8)

   and hit the Enter key. The displayed result should be 2.28...
   Next, click on [Convert]. Then click on the "Convert" combo box
   and select "Volume". Click on the "From" combo and select
   "cu.feet", then on "To" and select "gallons(US)". Click on
   [OK]. The converted result will be 17.059...

-------------------------------------------------------------------

NOTE: if your needs are limited to simple tasks as shown above,
      you may like to shrink the Kalkulator: select [Options |
      Panel Options] from the menu, then select "Minimal" from the
      top selector and uncheck the "Menu and Title Bar" box. This
      way you get a small, simple and friendly calculator, with
      the more advanced features not getting into your way. You
      may also choose "Basic" instead of "Minimal".

As an alternative, you may consider using Kalkulator's offspring,
the Midget. It will handle these problems just fine, is smaller
and less expensive.

-------------------------------------------------------------------

Q-05: How to solve an equation x+exp(x)=2 ?

A: First express the equation as f(t)=0; to do this, enter f(t) as

     t+exp t-2

   Next, click on [Zero]. When asked for the solution limits and
   accuracy, enter something reasonable, like 0, 100 and 1E-8
   (or .00000001). Click on [OK]. The result should be 0.44...

-------------------------------------------------------------------

Q-06: How to compute an integral of f(x)=1/(x+4) from 0 to 2?

A: Enter f(t) as

     1/(t+4)

   into the Expression Line. Click on [Integ]. When the dialog box
   prompts you for integral limits and accuracy, enter 0, 2 and
   1E-6 (or another accuracy value), respectively. Click on [OK].
   The result, 0.405..., will be stored in the Temporary Variable,
   t.

-------------------------------------------------------------------

Q-07: How to graph a function, e.g. f(x)=exp(-abs(x))*sin(1/x) for
      x between -2 and 2 ??

A: Enter the expression using t as the function argument

     exp(-abs t)*sin(1/t)

   and click on [Graph]. Enter -2 and 2 as x-limits. Click on
   [Find] and [Round], then on [OK].

   Note: this is a very unpleasant function to graph. You may want
   to increase the graph precision by selecting the [Options|Graph
   Options] menu and checking the "Fine Detail" box (do it before
   clicking on [Graph], of course). Then find any other function
   graphing program and see what job it will do. Bingo.

-------------------------------------------------------------------

Q-08: How to fit a square regression curve through a series of XY
      points?

A: Click on [Edit]. If necessary, click on [Mode] to set the
   buffer to the XY mode. Make sure the buffer is clear (use
   [Clear] if necessary). Type your points into the yellow box:
   X on the left, Y on the right; use arrow, Tab and Return keys
   as needed.

   Click on Exit. In the Main Window click on [Regr] and select
   "2nd degree". When asked about the plot, click on [Yes].
   In the Graph Range dialog, click on [Find] and [Round]. Done.

-------------------------------------------------------------------

Q-09: How to compare visually a square regression curve from the
      example above with a linear regression line?

A: If the graph generated above is still visible, press Escape.
   Click on [Regr] and select "1st degree", but answer [No] to the
   question on drawing the line. Clear the Expression Line (press
   Escape), and enter

     poly t

   Click on [Show], then on [Add]. Enjoy.

-------------------------------------------------------------------

Q-10: How to solve a system of three linear equations:

      2*x1 -  x2             = 3
      -x1  + 1.5*x2 - 0.3*x3 = -7
             x2     - x3     = 1

A: Click on [Extras | Linear algebra] to bring up the Linear
   Algebra Panel. Click on [Size] and select "3". Click on [Edit]
   and select "a". Enter the matrix so that the input grid
   contains:

      2    -1     0
     -1   1.5  -0.3
      0     1    -1

   and click on [OK]. Then click on [Edit] again and select "u".
   Enter the vector:

      3
     -7
      1

   and click on [OK] again.

   From the keyboard enter "a/u=v".

   To view the solution, click on [Edit] and select "v". The
   result will be (-2.64..., -8.28..., -9.28...).

-------------------------------------------------------------------

Q-11: How do I know that this is the right solution?

A: There are three ways:

   (1) Trust me.

   (2) In the Linear Algebra Panel, enter "a*v=w", then use [Edit]
       and "w". The vector w should be the same as u.

   (3) The hard way: exit the Linear Algebra Panel and
       compute the following three expressions in the Main Window:

          2v#1-v#2

          -v#1+1.5v#2-.3v#3

          v#2-v#3

       The results should be 3, -7 and 1, respectively.

    The recommended method is (1).

-------------------------------------------------------------------

Q-12: How to solve a cubic equation:

   2*x^3-9*x^2+x+5=0

   storing the largest real root as variable U?

A: First, get into the Root Panel by clicking on [Extras |
   Polynomial Roots]. Enter the polynomial coefficients into the
   yellow data grid at the left so that the grid looks like

         5
         1
        -9
         2

   Click on [Solve]. The solution display at the right will show
   three real roots: v1=-0.649..., v2=4.243... and v3=0.906...
   Click the left mouse button on the largest one (v2) and select
   U from the pop-up menu.

-------------------------------------------------------------------

Q-13: How to compute an integral of f(x)=x^3*exp(-x) over an
      interval from 0 to 8?

A: First enter the function as an expression line, remembering to
   use t as the argument:

      t^3*exp(-t)

   Then click on [Integ] and type in the limits: 0 and 8, as well
   as the desired accuracy, say, 1E-9. Click on [OK]. The result
   will be about 5.745719...

-------------------------------------------------------------------

Q-14: The above approach would not work if the "x^3" above is
      changed to "x^3.2": I'm getting an error message, why?

A: Integration of "t^3.2*exp(-t)" over [0,8] involves computing
   of 0^3.2, and this is an illegal arithmetic operation
   (fractional powers of zero are not defined).

   On the other hand, we know that the function converges to 0
   at 0; therefore we may redefine it with use of a conditional
   function as

      ifz(t,0,t^3.2*exp(-t))

   Type this expression in and repeat the rest of the previous
   procedure. The result will be 7.35919...

-------------------------------------------------------------------

Q-15: How do I convert the decimal value of -1200 to binary?

A: Go to the Computer Math Panel by clicking on [Extras | Computer
   math] and click on the mode button (on the right, just under
   the display) to select Signed Decimal. Now you have to choose
   the word length: click on the bit length button (just below the
   previous one) and select 16 bits (32 would be OK too, but the
   number will not fit into an 8-bit word). Type in "1200" and
   click on the [] button. The display should read "-1200" now.
   Click on the mode button again and select Binary. Done: the
   display should say now "11111011 01010000".

-------------------------------------------------------------------

Q-16: I'm using the Computer Math calculator to multiply 999 by
      66. The result is 398. What is wrong and how do I fix it?

A: Nothing is wrong. You are obviously working in the Decimal mode
   (signed or not) and with 16-bit words. The multiplication
   result, 65934, does not fit into a 16-bit word, so the program
   does what a computer doing 16-bit math would do: it drops the
   most significant part of the result. If you want this not to
   happen, switch to 32-bit words or, even better, use the Main
   Window for "regular" (as opposed to "computer") arithmetics.

-------------------------------------------------------------------

Q-17: I would like to define tan(x/4)*(2*sin(x/2)-cos(2x)) as a
      function of x so that it can be easily used in my
      calculations. How?

A: First, enter the function into the Expression Line, using t
   (not x!) as the argument:

      tan(t/4)*(2*sin(t/2)-cos(2*t))

   or, using fewer parentheses and multiplication signs

      tan .25t*(2 sin .5t-cos 2t)

   Click on the [User] tab in the Function Panel at the left and
   then on [Define]. Select a slot from the pop-up menu, for
   example, 1. Type the function name, for example, "trix" into
   the small box asking you for it. Hit Enter.

   Note that one of the buttons in the User Function Page will now
   be marked as [trix]. Now you can use trix as a regular function
   in your expression; as in

      trix(30.27)-2*trix(15/2A)+sin(27.333)

   (obviously, I'm doing this in the Degree mode, but this is not
   necessary).

-------------------------------------------------------------------

Q-18: Now I would like to define f(x,y) = xy+2*ln(x/y). How do I
      do it?

A: Starting from Version 2.00 you can do it! Enter the following
   into the Expression Line:

      v1*v2+2*ln(v1/v2)

   using v1 and v2 as arguments instead of x and y. You may also
   use the simpler form:

      v1v2+2ln(v1/v2)

   Switch to the User Page of the Function Panel (by clicking on
   the [User] tab) and click on [Define]. Select a function slot
   by from the pop-up menu, say, 2. Type in the new function
   name, e.g., "foo". Hit Enter.

   Now you can use foo as a regular two-argument function in any
   Kalkulator operations, like in

      foo(3.5R+1,2.72(A+B))+3foo(7,9)

-------------------------------------------------------------------

Q19: Show me how to solve a system of non-linear equations.

A: Let us assume that our system consists of three equations:

      (x+y)-z = 7.59
      x+y*z    = 8.36
      xy/(y+z) = 0.44

   (I have reverse-engineered these three so that x=1.1, y=2.2 and
   z=3.3 is a solution.)

   First of all, we have to use v1, v2 and v3 as the arguments, not
   x, y and z. (I could allow you to use x, y and z, but then I would
   have to allow you to use any other variables, too, at least in
   systems of more than three equations, and this would be messy!)
   We also have to show every equation as f(v1..v3)=0.

   To do this, use the arrow keys to go to the first expression in
   the Expression Line, erase the old contents by hitting Escape,
   and enter

      (v1+v2)-7.59

   Then enter

      v1+v2*v3-8.36

   into line number 2 and

      v1*v2/(v2+v3)-.44

   into line number 3.

   Now we have to enter our initial guess of the solution into the
   Argument Page. Let us try v1=10, v2=10 and v3=10. To do it, click
   on the [Args] tab in the Variable Panel, then on the [Put] button.
   Select "v1" from the pop-up menu, enter "10" in the input box,
   hit Enter. Repeat the same for v2 and v3.

   Before trying to solve our system, let us see how good our initial
   guess is. Go to Line 1, hit Enter. The result is 382.41 (and we are
   looking for v1, v2 and v3 for which all three lines will be zero!).
   Similarly, Line 2 gives 101.64 and Line 3 - 4.56. Obviously, our
   initial guess is way off.

   Now click on the [Numerical] tab of the Application Panel (at the
   bottom) and then on [Non-Linear]. You will see a dialog box with
   six (or, in the registered version, 24) buttons, each corresponding
   to one of the expression lines. Our system is defined by lines
   1, 2 and 3, so click on these buttons so that they become depressed
   (you may have to click twice; the first click just brings the
   selected expression to the Expression Line so that you can see it).

   The last remaining thing is to click on [OK]. Done. The Argument
   Page shows the results: v1=2.427, v2=1.146 and v3=5.176.

   Wait, something is wrong! Why not (1.1,2.2,3.3) like I said above?
   Well, a system like this can have a number of solutions and there
   seems to be no general rule how to find them all. Kalkulator found
   one of the solutions and it is good: check it by going to line 1
   and pressing the Enter key, then doing the same for lines 2 and 3.
   The computed expression values are, indeed, within the limits of
   arithmetic error.

   To try for another solution, use the [Put] button in the Argument
   Page to enter another initial guess, v1=5, v2=5 and v3=5.
   Then click on [Non-Linear] and [OK] to solve the system again.
   Yes, this time you arrived to (1.1,2.2,3.3), as we expected.
   Yet anotherinitial guess, (-1,-1,-1) will bring us to yet another
   solution, approximately (0.796,-3.058,-2.474).

   Now try the initial guess (-10,-10,-10). This time Kalkulator will
   tell you it was unable to find the solution at all. This is not
   a bug in the program - just the regular joys of working in multi-
   dimensional solution space!

   Try one more initial guess: (0,0,0). This time the program will
   diagnose an arithmetic error. Of course: the third expression
   has no value defined at this point!

   Imagine yourself hiking in the North Wales mountains and trying to
   find your way to the sea level. Without any maps the obvious way
   is just to follow the steepest path down. Depending on from where
   you start, you may reach the shore in a number of different places.
   If you are unlucky enough (separated from the shore by a mountain
   ridge), your downhill path may bring you to a mountain lake.
   (Stretching the comparison, points where one or more of the left
   sides, i.e. our expressions, are undefined, can be compared to
   bottomless wells you can fall into...)

   The hiking model illustrates fairly well what the Newton method
   used in Kalkulator is doing. With no limitations on the shape of
   the left side functions, the algorithm is just trying to walk
   towards zeros, with no guarantee of reaching them (assuming they
   exist at all).

   Usually, having some knowledge of the physical nature of the
   problem behind your equation system allows you to come up with a
   reasonably good initial guess, and then the algorithm does a good
   job in bringing you to the solution. No guarantees, or iron-clad
   rules, however, exist here.

   But I am not here to teach you numerical analysis. You've got a
   tool; now use it with understanding.

-------------------------------------------------------------------

Q-99: How do I get the newest version of Kalkulator?

A: Set your browser to my Web page:

     http://www.freeflight.com/wrotniak/works.html

   This Web page contains both 16- and 32-bit versions of
   Kalkulator.

-------------------------------------------------------------------

