Simple Division and Rational Numbers aka Fractions

Let’s return to simpler math for this post;  middle school math to be exact.    J has some unique features that make it an excellent tool for teaching division, fractions, and decimals.

Most calculators and computer programs have historically made no provision for rational numbers, aka fractions.   This included APL, and Dr. Iverson thought it was a serious shortcoming that needed to be remedied.  I did a few brief searches and discovered a pocket calculator, the Sharp EL348RB, that can convert decimals and fractions.  The iTunes store has a calculator type app, Fraction Calculator,  for their iphone  with  iOS 3. It calculates with fractions.  I haven’t used either one, but these are single line devices incapable of doing, say, this:

AddFractions

The above  is Dr. Iverson’s  fraction addition table using the (r) rational operator as in one half = 1r2.  The table was published in his Math for Layman, pg 2.  He was pleased that he could add this to J.  Note that the command line is above the box, which is created by the table command.  You might like to try making  tables using multiplication (*) and subtraction (-).

(Note on the table function. I used 1+i.12 for the multiplication tables in prior posts. The “i” in that case stands for integer. A fraction is not an integer, so the i function can’t be used. The table function provides another way. The table also produces boxes. J provides multiple roads to your destination.)

So, getting back to the actual division and fraction operators, I discussed Matrix Divide (%.) before I discussed plain old division (%) so let’s begin with ordinary division.  To do ordinary division in J, you type the problem as you say it. For example, “What is four divided by two?”  You would enter the problem that way:

        4 % 2
2

            444444 % 222
2002

            444444 % 2222
200.02

 

Which  brings up the question of decimals. You use divide (%) if you want your answers in decimals.

            2 % 4
0.5

              2 % 8
0.25

Note that J always puts a zero in front of the decimal point if the number is less than 1. So should you.  Also note that the division operator will only give you decimals.

So,  How do you calculate fractions in J?  As in the above fraction addition table, you use the (r) for rational operator instead of  the (%) division operator.  Let’s see how the (r) operator works in J.  We will start with a fraction that has not been simplified:

         2r4
1r2

Notice that J automatically simplifies the fraction.  It will also simplify the fraction to a whole number:

           8r2
4

In the following two examples, we see that when the division yields a whole number, the answers from both the r and the % operators are  the same:

             444444r222
2002

             444444  %  222
2002

In J, the r operator will also simplify the fraction to a whole number. But it will not simplify a fraction to a mixed number:

            7r2
7r2

In this case, you will have to use the division operator:

            7 % 2
3.5

Then, figure out the answer  on your own (3.5  = 3 and 1/2.)   But, the r operator will simplify the fraction if possible:
                   444444r2222
20202r101

And if we take the answer and substitute the % division operator for the
r rational operator, we get the same answer with either set of numbers:

                   20202 % 101
200.02

                444444 % 2222
200.02

You can use J to do the math, or to test your answers if you are learning math. If you need a book on basic arithmetic, my recommendation is Gerard W. Kelly Short Cut Math. You might want W. Michael Kelley’s Humongous Book of Pre-Algebra Problems if your need is junior high math.

 

About Richard Rollo

I am a retired Community College Instructor. I taught Political Science 1 American Government for 22 years in Southern California. I am originally from Northern Minnesota. My earliest years were spent in the living quarters of a rural Duluth Winnipeg & Pacific Railway Depot. Then my family joined the great 1950's migration to Southern California where I joined up with fellow baby boomers in overcrowded schools.
This entry was posted in APL and J, Do It Yourself Learning, Dr. Kenneth Iverson, Learning Math. Bookmark the permalink.