Warning: Division by zero in /var/www/sites/jtnew/wp-content/themes/twentysixteen/functions.php on line 16
Warning: Division by zero in /var/www/sites/jtnew/wp-content/themes/twentysixteen/functions.php on line 16
Warning: Division by zero in /var/www/sites/jtnew/wp-content/themes/twentysixteen/functions.php on line 16
Warning: Division by zero in /var/www/sites/jtnew/wp-content/themes/twentysixteen/functions.php on line 16
Warning: Division by zero in /var/www/sites/jtnew/wp-content/themes/twentysixteen/functions.php on line 16
Warning: Division by zero in /var/www/sites/jtnew/wp-content/themes/twentysixteen/functions.php on line 16
Warning: Division by zero in /var/www/sites/jtnew/wp-content/themes/twentysixteen/functions.php on line 16
Warning: Division by zero in /var/www/sites/jtnew/wp-content/themes/twentysixteen/functions.php on line 16
Warning: Division by zero in /var/www/sites/jtnew/wp-content/themes/twentysixteen/functions.php on line 16
Warning: Division by zero in /var/www/sites/jtnew/wp-content/themes/twentysixteen/functions.php on line 16
Love it or hate it, Facebook brings out the passion in people. People get unfriended and feelings get hurt. There’s no better way to experience it than to post an opinionated political viewpoint. Still, politics are far from the only fuel for these fires. Recently, I’ve seen heated discussions about Common Core Math, a relatively newer way to approach learning math principles. Some of the concepts seem, on the surface, to be a big, crazy departure from the concepts many of us learned as children and that’s what I’ve seen most of the noise about. In some instances, friends share an image from an angry parent whose child’s math solution was marked incorrect because the common core methods were not applied. In other cases, frustration is voiced because it appears that the new methods are actually worse than the old ones. Whatever side you’re on, be sure to open your mind to learning new things and making your own mind up.
I’m still on the fence, so as a software engineer, I decided to throw ones and zeros at the problem and see what stuck. In this case, I decided that the problem I wanted to solve would be to determine which method might be faster for subtracting numbers. The “old way”, as seen on the left in the image below, involves lining up your numbers and borrowing from the next digit to the left as you subtract each digit on the bottom from the one on the top. The new way involves essentially rounding up the number you’re subtracting until it matches the number you’re subtracting from and adding all the numbers you had to use to round up in order to get to the difference. The simplest explanation I saw for this was 9 minutes into this video, in which the teacher describes the process of counting change back to a customer at a cash register.
To solve my problem, I used PHP to try to mimic the process we go through as humans to subtract one number from another. I programmed functions for the old and new ways to solve a subtraction problem and added code to time each and loop lots of times to create a more visible comparison. The Commmon Core math in PHP code is on GitHub for anyone who would like to try it out or improve it and below are some example results.
1,000 cycles – random numbers between 1 and 1000.
Total time for the old way : 0.0071358680725098 seconds
Total time for the new way : 0.01004958152771 seconds
100,000 cycles – random numbers between 1 and 1000.
Total time for the old way : 0.71134495735168 seconds
Total time for the new way : 0.97455978393555 seconds
1,000,000 cycles – random numbers between 1 and 1000.
Total time for the old way : 6.9777636528015 seconds
Total time for the new way : 9.8461444377899 seconds
100 cycles – random numbers between 1 and 10,000,000.
Total time for the old way : 0.00092959403991699 seconds
Total time for the new way : 0.0014877319335938 seconds
100,000 cycles – random numbers between 1 and 10,000,000.
Total time for the old way : 1.0502970218658 seconds
Total time for the new way : 1.6906788349152 seconds
1,000,000 cycles – random numbers between 1 and 10,000,000.
Total time for the old way : 22.028552055359 seconds
Total time for the new way : 34.783274650574 seconds
It’s worth noting that computers and the human brain work in very different ways. This experiment is not intended to prove anything either way, nor is it intended as scientific data in the slightest. It’s merely an experiment on the process and I welcome discussion and open-minded debate in the comments.