{"id":845,"date":"2011-12-27T22:42:40","date_gmt":"2011-12-28T04:42:40","guid":{"rendered":"http:\/\/bateru.com\/news\/?p=845"},"modified":"2011-12-27T23:06:54","modified_gmt":"2011-12-28T05:06:54","slug":"10-minute-tutorial-over-logarithms-with-a-mix-of-javascript","status":"publish","type":"post","link":"https:\/\/bateru.com\/news\/2011\/12\/10-minute-tutorial-over-logarithms-with-a-mix-of-javascript\/","title":{"rendered":"10 Minute Tutorial over Logarithms with a Mix of Javascript"},"content":{"rendered":"<p><a href=\"http:\/\/bateru.com\/news\/wp-content\/uploads\/2011\/12\/logarithm.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/bateru.com\/news\/wp-content\/uploads\/2011\/12\/logarithm-300x188.jpg\" alt=\"\" title=\"logarithm\" width=\"300\" height=\"188\" class=\"alignleft size-medium wp-image-854\" srcset=\"https:\/\/bateru.com\/news\/wp-content\/uploads\/2011\/12\/logarithm-300x188.jpg 300w, https:\/\/bateru.com\/news\/wp-content\/uploads\/2011\/12\/logarithm.jpg 618w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n<b>Summary:<\/b><br \/>\nThis tutorial will provide a simple overview of logarithms. <\/p>\n<p><b>What are Logarithms?<\/b><br \/>\nLogarithms are used to determine the exponent needed to receive a certain value with a particular base.<\/p>\n<pre>Example: Log 100 = 2. Since 10^2 = 100.<\/pre>\n<p>Here&#8217;s a short video explaining logarithms more in-depth with a practical example.<\/p>\n<p><iframe loading=\"lazy\" width=\"420\" height=\"315\" src=\"http:\/\/www.youtube.com\/embed\/djR8DkQ_UU0\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>The most common bases used for logarithms are base 10 and E. With base E logarithms normally referred to as the natural logarithm.<br \/>\nIn Javascript, the function Math.log returns the natural logarithm of the argument instead of a base 10 logarithm. This can cause some confusion for those unaware of this fact.<\/p>\n<pre lang='javascript'>\r\nMath.log( 100 ) == 2 \/\/ returns false\r\nMath.log( 100 ) \/\/ returns 4.605170185988092\r\n<\/pre>\n<p>So how can one use a different base other than E? Well, it simple. All you have to do is take the log of the value that you want, then divide that by the log of the desired based.<br \/>\nLike so.<\/p>\n<pre lang='javascript'>\r\nMath.log( x ) \/ Math.log( desiredBase );\r\n<\/pre>\n<p>Here&#8217;s a user defined function that does the same operation.<\/p>\n<pre lang='javascript'>\r\n\/**\r\n* @function Math.logx\r\n* @purpose: To provide the logarithm for any base desired. Default base is 10.\r\n* @returns a number.\r\n*\/\r\nMath.logx = function(x,base) {\r\n    return (Math.log(x)) \/ (Math.log(base | 10 ));\r\n}\r\n<\/pre>\n<p>And now, we can calculate log 10 as 2 instead of another number.<\/p>\n<pre lang='javascript'>\r\nMath.log( 100 ) == 2    \/\/ returns false\r\nMath.logx( 100 ) == 2   \/\/ returns true\r\n<\/pre>\n<p><iframe src=\"http:\/\/rcm.amazon.com\/e\/cm?t=baterucom-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0321559835&#038;ref=tf_til&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr\" style=\"width:120px;height:240px;\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: This tutorial will provide a simple overview of logarithms. What are Logarithms? Logarithms are used to determine the exponent needed to receive a certain value with a particular base. Example: Log 100 = 2. Since 10^2 = 100. Here&#8217;s a short video explaining logarithms more in-depth with a practical example. The most common bases &hellip; <a href=\"https:\/\/bateru.com\/news\/2011\/12\/10-minute-tutorial-over-logarithms-with-a-mix-of-javascript\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">10 Minute Tutorial over Logarithms with a Mix of Javascript<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,10,67],"tags":[164,102,16,174],"class_list":["post-845","post","type-post","status-publish","format-standard","hentry","category-math","category-tutorials","category-videos","tag-javascript","tag-logarithms","tag-tutorial","tag-video"],"_links":{"self":[{"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/posts\/845","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/comments?post=845"}],"version-history":[{"count":10,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/posts\/845\/revisions"}],"predecessor-version":[{"id":857,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/posts\/845\/revisions\/857"}],"wp:attachment":[{"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/media?parent=845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/categories?post=845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bateru.com\/news\/wp-json\/wp\/v2\/tags?post=845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}