Finding the root of number

Suppose you want to add two large numbers such as 498454011879264 and 806515533049393. You feel lazy to add so many digits numbers like that by hand and you want to use calculator or you will use spreadsheet such as Microsoft Excel.

Try to input two numbers in the spreadsheet or calculator, what is the answer that your computer or calculator give?

Most probably you will get 1.30497E+15. That is only approximation answer. You want to get the exact answer but the computer or calculator has truncated your numbers.

To get exact answer, you suppose to tell the spreadsheet that your inputs are numbers or currency or you can also use accounting format. Then using Microsoft Excel, you will get

498,454,011,879,264.00 + 806,515,533,049,393.00 =   1,304,969,544,928,660.00

Now try to get the result by hand computation and to your surprise, your expensive spreadsheet actually produces incorrect result!

498454011879264 + 806515533049393 = 1304969544928657 and not 1304969544928660 as the computer give you. Even the addition of the last digit 4+3 is supposed to be 7 and not 0.

Why does the computer give you wrong answer and how to check whether the computer give wrong answer or not?

The computer give you wrong answer because of round off error. Computer treats number only up to certain digits and beyond that limit (say 15 digits), the computer will truncate the number and only give you the approximation. That approximation is fine for most cases but of course it is not correct if you want to get the exact answer.

To check whether your arithmetic computation is correct or not, you can use what is called digital root of a number. If you have a number say 65923, you can sum each digit recursively until you get only one digit number.  6+5+9+2+3 = 25, and 2+5 = 7, thus the digital root of 65923 is 7.

Digital root has nice property that digital root of an addition is equal to the digital root of each term.

Digital root of 498454011879264 is 9 and digital root of 806515533049393 is 1, thus the digital root of the summation of those two big numbers suppose to be digital root of (9+1 = 10) = 1+ 0 = 1.

However, what the calculator or spreadsheet gives you, 1304969544928660, has digital root of 4. Since the digital root is not equal, you can easily detect that the summation is not correct.

You can find more interesting tutorial about pattern of digital root in my web page http://people.revoledu.com/kardi/tutorial/DigitSum/. You can freely download the spreadsheet examples and you can also play around with online digital root calculator. Visit the web site today. Many more fascinating free tutorials are waiting for you to learn.

The Easiest Way to Learn Graph Theory

Graph Theory is a very useful and fun subject.

Let us start with a historical problem which is called the Konigsberg Bridge Problem. The city of Konigsberg in former Prussia (now called Kaliningrad, Russia) has two islands in the middle of the rivers. The two islands connected to the mainland by seven bridges. Leonhard Euler in 1736 asked this problem: is it possible to walk from his home around the city and cross each of the seven bridges only once and return home? The key problem lies on the word “to cross each bridge only once”.

Euler simplified the problem this way: each mass of land is considered as a node (or called vertex) and each of the bridge into a link (or called edge). The collection of nodes and links together with the properties and operations on the nodes and links is called Graph Theory. Euler also proved using this simple model that nobody can walk to cross each of the seven bridges once to return home. Thus, the Konigsberg Bridge Problem has no solution!

Since that time, the study of this theory has flourished. Now we can find many applications of graph theory. Just a few of them can be mentioned here:

  1. Road network can be modeled as graph theory with intersection as node and the midblock as link. Using this graph, you can find the shortest path from your home to your school or office.
  2. When each region in a map is represented as a node, and the connection of the region with its adjacent regions in the same map is indicated as a link, we will have a graph. Graph theory has lead to some results that you only 4 colors to color all regions in a map such that no adjacent region will be colored with the same color.
  3. Electrical network is a graph with each of the junction and electrical devices as nodes connected by the wire as links.
  4. Social network where each person is connected socially with their friends or relatives can be visualized as a graph.
  5. An activity in a project can be modeled a node. The preceding and successive activities are connected to the current activities. This graph of activities leads to optimization of schedules in project management.

Though Graph theory is very interesting, studying more advanced graph theory can become very complicated. For beginners, pictorial introduction to graph theory explained in very gentle English is very fun and motivating to the young people to learn more on graph theory.

Decimal to Fraction

We know that 0.125 = 1/8 and 0.33333=1/3, but how you will let the computer convert from decimal to fraction? In 2006, I posted tutorial on Continued Fraction together with the VB code and MS Excel. Several people requested for the online version to verify the code. Today I launch the online interactive program to convert decimal to fraction.

Compared to some interactive program over the internet (usually they use Euclid algorithm) to convert say 0.125 = 125/1000 and 0.33333=33333/10000, the continued fraction version performs much better. It produces 0.125 = 1/8 and 0.33333=1/3. Say if you input 0.142857142857143, their program will produce 142857142857143/100000000000000 while my version will simplify it beautifully to 1/7.

Check the interactive program at http://people.revoledu.com/kardi/tutorial/ContinuedFraction/Decimal%20to%20Fraction.html

New Tutorial on Linear Algebra

A long waited Kardi Teknomo’s tutorial on Linear algebra was launched yesterday.  The tutorials is useful for review of linear algebra materials as well as for the first learners.  Close to 50 new interactive programs were included in the tutorial and the content of the tutorial itself can be considered as a mini book with more than 100 pages on the original A4 document.

Personally I really like the interactive programs that produce rational number rather than decimal. I use continued fraction to convert decimal to rational. Take a look for example on the program to produce matrix inverse using only three elementary row operation (Gauss Jordan Reduction method). Instead of giving you only one example, you can use the random example button to generate infinitely (at least theoretically) many examples. The program even show step by step how to compute Gauss Jordan method.

For solving simultaneous linear equation equation, for instance, many old books on linear algebra will say that if your matrix is not square or does not have matrix inverse, then you cannot find any solution (inconsistent solution). That statement is probably too old because development of Generalized Inverse has been started more than 5 decades ago in the last century. I draw special chart to show the role of Generalized Inverse to solve Linear System. You can also try the interactive program. The solution based on pseudo inverse will be exactly the same as matrix inverse when the system is consistent and when the system is inconsistent (due to repetition of the data or more equations than the unknowns) the program will produce regression solution. That means the solution is only an approximation to minimize the error.

Other part of the tutorial that I would like to highlight is the similarity transformation that is very useful to produce diagonal matrix.  Once we can transform a square matrix into a diagonal matrix, we can perform any operation on the diagonal matrix as if we do that on the input square matrix. For instance, taking power, exponent or logarithm, or even derivative of the matrix is simply performing the same function to the diagonal elements.

There are many more that you may find out by yourself as you read the tutorial. I spend more than 500 hours in total to develop the tutorial and I only give it for free. I hope you will enjoy it. Consider to give donation for further development of the programs and the tutorials.