{"id":12002,"date":"2015-08-28T16:07:52","date_gmt":"2015-08-28T16:07:52","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=12002"},"modified":"2015-08-28T16:07:52","modified_gmt":"2015-08-28T16:07:52","slug":"mathcomputer-science-exponentiation-algorithm","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/mathcomputer-science-exponentiation-algorithm\/","title":{"rendered":"Math\/computer science:  exponentiation algorithm"},"content":{"rendered":"<h1>By way of finding a power of a number the tutor opens a discussion about algorithms.<\/h1>\n<p>Years ago my computer science professor presented the following definition:<\/p>\n<p>An <em>algorithm<\/em> is a set of steps to solve a problem.<\/p>\n<p>Suppose there wasn&#8217;t a dedicated function to calculate <span style=\"font-size:medium\">a<\/span><sup style=\"font-size:medium\">b<\/sup>.  Then one would need to devise an algorithm for it.  One might commonly imagine a loop that multiplied the base by itself the necessary number of times;eg:<\/p>\n<p><span style=\"font-family:monospace;color:brown\"><br \/>\n#!\/usr\/bin\/perl<br \/>&#10;<br \/>\n$base=$ARGV[0];<br \/>\n$expon=$ARGV[1];<br \/>&#10;<br \/>\n$ans=1;<br \/>&#10;<br \/>\nfor($i=0;$i<$expon;$i++){<br \/>\n$ans*=$base;<span style=\"color:orange\">#means $ans=$ans*$base;<\/span><br \/>\n}<br \/>\nprint &#8220;$base to the exponent $expon is $ans\\n\\n&#8221;;<br \/>\n<\/span><\/p>\n<p>Perhaps surprisingly, there is another way of evaluating <span style=\"font-size:medium\">a<\/span><sup style=\"font-size:medium\">b<\/sup> that is more efficient.  I&#8217;ll be introducing that algorithm soon.<\/p>\n<p>Currently we are anticipating heavy rainfall on the west coast.  It&#8217;s a welcome development after a very dry summer; I&#8217;ve high hopes it will squelch the forest fire hazards.  Perhaps a coming post will celebrate this change in weather:)<\/p>\n<p>Source:<\/p>\n<p>Grimaldi, Ralph P.  <u>Discrete and Combinatorial Mathematics<\/u>.  Addison-Wesley:  Don<br \/>&nbsp;&nbsp; Mills, 1994.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By way of finding a power of a number the tutor opens a discussion about algorithms. Years ago my computer science professor presented the following definition: An algorithm is a set of steps to solve a problem. Suppose there wasn&#8217;t &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/mathcomputer-science-exponentiation-algorithm\/\"> <span class=\"screen-reader-text\">Math\/computer science:  exponentiation algorithm<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105,3],"tags":[1015,173],"class_list":["post-12002","post","type-post","status-publish","format-standard","hentry","category-computer-science","category-math","tag-exponentiation","tag-perl-programming"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/12002","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=12002"}],"version-history":[{"count":36,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/12002\/revisions"}],"predecessor-version":[{"id":12038,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/12002\/revisions\/12038"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=12002"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=12002"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=12002"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}