{"id":11582,"date":"2015-07-30T00:20:29","date_gmt":"2015-07-30T00:20:29","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=11582"},"modified":"2018-03-01T20:28:44","modified_gmt":"2018-03-01T20:28:44","slug":"python-the-power-function","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/python-the-power-function\/","title":{"rendered":"Python:  the power function"},"content":{"rendered":"<h1>The tutor focuses on Python&#8217;s pow(x,y) command.<\/h1>\n<p>Back in my <a href=\"?p=4148\">post on May 3, 2014<\/a> I pointed out that<\/p>\n<p><img decoding=\"async\" src=\"\/..\/images\/rat_exp.png\" style=\"display:block;margin:auto\" \/><\/p>\n<p>In the left expression above, c is the root while b is the exponent. Some might also call b the &#8220;power&#8221;.  The variable a you might call the argument.<\/p>\n<p>On this website I use the familiar notation<\/p>\n<p><img decoding=\"async\" src=\"\/..\/images\/exp_to_hat.png\" style=\"display:block\/margin:auto\" \/><\/p>\n<p>Note that it follows that<\/p>\n<p>&#8730;(49)=49^(1\/2)=7<\/p>\n<p>since the exponent on 49 in the left expression, not being written, is understood to be 1, while the root, not being stated, is assumed to be 2.<\/p>\n<p>Another example:<\/p>\n<p><sup>3<\/sup>&#8730;(125)=(125)^(1\/3)=5<\/p>\n<p>Python&#8217;s <span style=\"font-family:monospace\">pow<\/span> function seems to favour the a^(b\/c) interpretation.  Before using <span style=\"font-family:monospace\">pow<\/span>, you need the line<\/p>\n<p><span style=\"font-family:monospace\">import math<\/span><\/p>\n<p>to make <span style=\"font-family:monospace\">pow<\/span> available.  Then, <span style=\"font-family:monospace\">pow<\/span> can be used as follows:<\/p>\n<p><span style=\"font-family:monospace\">math.pow(argument, rational exponent)<\/span><\/p>\n<p>Therefore, the little program<br \/>\n<span style=\"font-family:monospace;color:brown\"><br \/>\nimport math<br \/>\nprint(str(math.pow(3,2)))<br \/>\nprint(str(math.pow(8,1\/3)))<br \/>\nprint(str(math.pow(32,2\/5)))<br \/><\/span><\/p>\n<p>should yield the output<\/p>\n<p><span style=\"font-family:monospace\"><br \/>\n9.0<br \/>\n2.0<br \/>\n4.0<br \/>\n<\/span><\/p>\n<p>I&#8217;ll be talking more about Python math functions in future posts:)<\/p>\n<p>Source:<\/p>\n<p>Donaldson, Toby.  <u>Python<\/u>, 3rd Ed.  Peachpit Press, 2014<\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The tutor focuses on Python&#8217;s pow(x,y) command. Back in my post on May 3, 2014 I pointed out that In the left expression above, c is the root while b is the exponent. Some might also call b the &#8220;power&#8221;. &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/python-the-power-function\/\"> <span class=\"screen-reader-text\">Python:  the power function<\/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],"tags":[953,955,954,930,957,956],"class_list":["post-11582","post","type-post","status-publish","format-standard","hentry","category-computer-science","tag-import-math","tag-math-pow","tag-pow","tag-python","tag-python-power-function-for-other-roots","tag-python-power-function-for-rational-exponents"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/11582","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=11582"}],"version-history":[{"count":23,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/11582\/revisions"}],"predecessor-version":[{"id":30668,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/11582\/revisions\/30668"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=11582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=11582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=11582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}