{"id":4811,"date":"2021-07-08T06:29:22","date_gmt":"2021-07-08T06:29:22","guid":{"rendered":"https:\/\/www.aiproblog.com\/index.php\/2021\/07\/08\/a-gentle-introduction-to-slopes-and-tangents\/"},"modified":"2021-07-08T06:29:22","modified_gmt":"2021-07-08T06:29:22","slug":"a-gentle-introduction-to-slopes-and-tangents","status":"publish","type":"post","link":"https:\/\/www.aiproblog.com\/index.php\/2021\/07\/08\/a-gentle-introduction-to-slopes-and-tangents\/","title":{"rendered":"A Gentle Introduction to Slopes and Tangents"},"content":{"rendered":"<p>Author: Mehreen Saeed<\/p>\n<div>\n<p>The slope of a line, and its relationship to the tangent line of a curve is a fundamental concept in calculus. It is important for a general understanding of function derivatives.<\/p>\n<p>In this tutorial, you will discover what is the slope of a line and what is a tangent to a curve.<\/p>\n<p>After completing this tutorial, you will know:<\/p>\n<ul>\n<li>The slope of a line<\/li>\n<li>The average rate of change of f(x) on an interval w.r.t. x<\/li>\n<li>The slope of a curve<\/li>\n<li>The tangent line to a curve at a point<\/li>\n<\/ul>\n<p>Let\u2019s get started.<\/p>\n<div id=\"attachment_12515\" style=\"width: 405px\" class=\"wp-caption aligncenter\">\n<a href=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/IMG_4270-scaled.jpg\"><img decoding=\"async\" aria-describedby=\"caption-attachment-12515\" loading=\"lazy\" class=\"wp-image-12515\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/IMG_4270-225x300.jpg\" alt=\"Walking to the sky at CMU\" width=\"395\" height=\"526\" srcset=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/IMG_4270-225x300.jpg 225w, https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/IMG_4270-768x1024.jpg 768w, https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/IMG_4270-1152x1536.jpg 1152w, https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/IMG_4270-1536x2048.jpg 1536w, https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/IMG_4270-scaled.jpg 1920w\" sizes=\"(max-width: 395px) 100vw, 395px\"><\/a><\/p>\n<p id=\"caption-attachment-12515\" class=\"wp-caption-text\">A Gentle Introduction to Slopes and Tangents Artist: Jonathan Borofsky, Photo by Mehreen Saeed, some rights reserved.<\/p>\n<\/div>\n<h2 id=\"Tutorial-Overview\">Tutorial Overview<\/h2>\n<p>This tutorial is divided into two parts; they are:<\/p>\n<ol>\n<li>The slope of a line and a curve<\/li>\n<li>The tangent line to a curve<\/li>\n<\/ol>\n<h2 id=\"The-Slope-of-a-Line\">The Slope of a Line<\/h2>\n<p>Let\u2019s start by reviewing the slope of a line. In calculus the slope of a line defines its steepness as a number. This number is calculated by dividing the change in the vertical direction to the change in the horizontal direction when moving from one point on the line to another. The figure shows how the slope can be calculated from two distinct points A and B on a line.<\/p>\n<div id=\"attachment_12514\" style=\"width: 371px\" class=\"wp-caption aligncenter\">\n<a href=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/slopeLine.png\"><img decoding=\"async\" aria-describedby=\"caption-attachment-12514\" loading=\"lazy\" class=\" wp-image-12514\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/slopeLine-277x300.png\" alt=\"Slope of a Line\" width=\"361\" height=\"391\" srcset=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/slopeLine-277x300.png 277w, https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/slopeLine.png 594w\" sizes=\"(max-width: 361px) 100vw, 361px\"><\/a><\/p>\n<p id=\"caption-attachment-12514\" class=\"wp-caption-text\">Slope of a line calculated from two points on the line<\/p>\n<\/div>\n<p>A straight line can be uniquely defined by two points on the line. The slope of a line is the same everywhere on the line; hence, any line can also be uniquely defined by the slope and one point on the line. From the known point we can move to any other point on the line according to the ratio defined by the slope of the line.<\/p>\n<h2 id=\"The-Average-Rate-of-Change-of-a-Curve\">The Average Rate of Change of a Curve<\/h2>\n<p>We can extend the idea of the slope of a line to the slope of a curve. Consider the left graph of the figure below. If we want to measure the \u2018steepness\u2019 of this curve, it is going to vary at different points on the curve. The average rate of change when moving from point A to point B is negative as the value of the function is decreasing when x is increasing. It is the same when moving from point B to point A. Hence, we can define it over the interval [x0,x1] as:<\/p>\n<p style=\"text-align: center;\">(y1-y0)\/(x1-x0)<\/p>\n<p>We can see that the above is also an expression for the slope of the secant line that includes the points A and B. To refresh your memory, a secant line intersects the curve at two points.<\/p>\n<p>Similarly, the average rate of change between point C and point D is positive and it\u2019s given by the slope of the secant line that includes these two points.<\/p>\n<div id=\"attachment_12511\" style=\"width: 684px\" class=\"wp-caption aligncenter\">\n<a href=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/rate.png\"><img decoding=\"async\" aria-describedby=\"caption-attachment-12511\" loading=\"lazy\" class=\"wp-image-12511\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/rate-300x117.png\" alt=\"Rate of change of a curve over an interval (left) Rate of change of a curve at a point (right)\" width=\"674\" height=\"263\" srcset=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/rate-300x117.png 300w, https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/rate-1024x400.png 1024w, https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/rate-768x300.png 768w, https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/rate.png 1414w\" sizes=\"(max-width: 674px) 100vw, 674px\"><\/a><\/p>\n<p id=\"caption-attachment-12511\" class=\"wp-caption-text\">Rate of change of a curve over an interval vs. at a point<\/p>\n<\/div>\n<h2 id=\"Defining-the-Slope-of-the-Curve\">Defining the Slope of the Curve<\/h2>\n<p>Let\u2019s now look at the right graph of the above figure. What happens when we move point B towards point A? Let\u2019s call the new point B\u2019. When the point B\u2019 is infinitesimally close to A, the secant line would turn into a line that touches the curve only once. Here the x coordinate of B\u2019 is (x0+h), with h an infinitesimally small value. The corresponding value of the y-coordinate of the point B\u2019 is the value of this function at (x0+h), i.e., f(x0+h).<\/p>\n<p>The average rate of change over the interval [x0,x0+h] represents the rate of change over a very small interval of length h, where h approaches zero.\u00a0This is called the slope of the curve at the point x0. Hence, at any point A(x0,f(x0)), the slope of the curve is defined as:<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/slopeofcurve.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-12513\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/slopeofcurve-300x86.png\" alt=\"\" width=\"199\" height=\"57\" srcset=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/slopeofcurve-300x86.png 300w, https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/slopeofcurve.png 406w\" sizes=\"(max-width: 199px) 100vw, 199px\"><\/a><\/p>\n<p>The expression of the slope of the curve at a point A is equivalent to the derivative of f(x) at the point x0. Hence, we can use the derivative to find the slope of the curve. You can review the concept of derivatives in this <a href=\"https:\/\/machinelearningmastery.com\/a-gentle-introduction-to-function-derivatives\">tutorial<\/a>.<\/p>\n<h3 id=\"Examples-of-Slope-of-the-Curve\">Examples of Slope of the Curve<\/h3>\n<p>Here are a few examples of the slope of the curve.<\/p>\n<ul>\n<li>The slope of f(x) = 1\/x at any point k (k\u22600) is given by (-1\/k^2). As an example:\n<ul>\n<li>Slope of f(x) = 1\/x at (x=2) is -1\/4<\/li>\n<li>Slope of f(x) = 1\/x at (x=-1) is -1<\/li>\n<\/ul>\n<\/li>\n<li>The slope of f(x) = x^2 at any point k is given by (2k). For example:\n<ul>\n<li>Slope of f(x) = x^2 at (x=0) is 0<\/li>\n<li>Slope of f(x) = x^2 at (x=1) is 2<\/li>\n<\/ul>\n<\/li>\n<li>The slope of f(x) = 2x+1, is a constant value equal to 2. We can see that f(x) defines a straight line.<\/li>\n<li>The slope of f(x) = k, (where k is a constant) is zero as the function does not change anywhere. Hence its average rate of change at any point is zero.<\/li>\n<\/ul>\n<h2 id=\"The-Tangent-Line\">The Tangent Line<\/h2>\n<p>It was mentioned earlier that any straight line can be uniquely defined by its slope and a point that passes through it. We also just defined the slope of a curve at a point A. Using these two facts, we\u2019ll define the tangent to a curve f(x) at a point A(x0,f(x0)) as a line that satisfies two of the following:<\/p>\n<ol>\n<li>The line passes through A<\/li>\n<li>The slope of the line is equal to the slope of the curve at the point A<\/li>\n<\/ol>\n<p>Using the above two facts, we can easily determine the equation of the tangent line at a point (x0,f(x0)). A few examples are shown next.<\/p>\n<h2 id=\"Examples-of-Tangent-Lines\">Examples of Tangent Lines<\/h2>\n<h3 id=\"1.-f(x)-=-1\/x\">1. f(x) = 1\/x<\/h3>\n<p>The graph of f(x) along with the tangent line at x=1 and x=-1 are shown in the figure. Below are the steps to determine the tangent line at x=1.<\/p>\n<div id=\"attachment_12510\" style=\"width: 310px\" class=\"wp-caption aligncenter\">\n<a href=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/oneoverx.png\"><img decoding=\"async\" aria-describedby=\"caption-attachment-12510\" loading=\"lazy\" class=\"size-medium wp-image-12510\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/oneoverx-300x240.png\" alt=\"f(x) = 1\/x\" width=\"300\" height=\"240\" srcset=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/oneoverx-300x240.png 300w, https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/oneoverx.png 562w\" sizes=\"(max-width: 300px) 100vw, 300px\"><\/a><\/p>\n<p id=\"caption-attachment-12510\" class=\"wp-caption-text\">f(x) = 1\/x<\/p>\n<\/div>\n<ul>\n<li>Equation of a line with slope m and y-intercept c is given by: y=mx+c<\/li>\n<li>Slope of the line at any point is given by the function f'(x) = -1\/x^2<\/li>\n<li>Slope of the tangent line to the curve at x=1 is -1, we get y=-x+c<\/li>\n<li>The tangent line passes through the point (1,1) and hence substituting in the above equation we get:\n<ul>\n<li>1 = -(1)+c \u27f9 c = 2<\/li>\n<\/ul>\n<\/li>\n<li>The final equation of the tangent line is y = -x+2<\/li>\n<\/ul>\n<h3 id=\"2.-f(x)-=-x^2\">2. f(x) = x^2<\/h3>\n<p>Shown below is the curve and the tangent lines at the points x=2, x=-2, x=0. At x=0, the tangent line is parallel to the x-axis as the slope of f(x) at x=0 is zero.<\/p>\n<p>This is how we compute the equation of the tangent line at x=2:<\/p>\n<div id=\"attachment_12512\" style=\"width: 310px\" class=\"wp-caption aligncenter\">\n<a href=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/xsq.png\"><img decoding=\"async\" aria-describedby=\"caption-attachment-12512\" loading=\"lazy\" class=\"size-medium wp-image-12512\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/xsq-300x228.png\" alt=\"f(x) = x^2\" width=\"300\" height=\"228\" srcset=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/xsq-300x228.png 300w, https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/xsq.png 582w\" sizes=\"(max-width: 300px) 100vw, 300px\"><\/a><\/p>\n<p id=\"caption-attachment-12512\" class=\"wp-caption-text\">f(x) = x^2<\/p>\n<\/div>\n<ul>\n<li>Equation of a line with slope m and y-intercept c is given by: y=mx+c<\/li>\n<li>Slope of the line at any point is given by the function f'(x) = 2x<\/li>\n<li>Slope of the tangent line to the curve at x=2 is 4, we get y=4x+c<\/li>\n<li>The tangent line passes through the point (2,4) and hence substituting in the above equation we get:\n<ul>\n<li>4 = 4(2)+c \u27f9 c = -4<\/li>\n<\/ul>\n<\/li>\n<li>The final equation of the tangent line is y = 4x-4<\/li>\n<\/ul>\n<h3 id=\"3.-f(x)-=-x^3+2x+1\">3. f(x) = x^3+2x+1<\/h3>\n<p>This function is shown below, along with its tangent lines at x=0, x=2 and x=-2. Below are the steps to derive an equation of the tangent line at x=0.<\/p>\n<div id=\"attachment_12509\" style=\"width: 310px\" class=\"wp-caption aligncenter\">\n<a href=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/cubic.png\"><img decoding=\"async\" aria-describedby=\"caption-attachment-12509\" loading=\"lazy\" class=\"wp-image-12509 size-medium\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/cubic-300x232.png\" alt=\"f(x) = x^3+2x+1\" width=\"300\" height=\"232\" srcset=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/cubic-300x232.png 300w, https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2021\/06\/cubic.png 572w\" sizes=\"(max-width: 300px) 100vw, 300px\"><\/a><\/p>\n<p id=\"caption-attachment-12509\" class=\"wp-caption-text\">f(x) = x^3+2x+1<\/p>\n<\/div>\n<ul>\n<li>Equation of a line with slope m and y-intercept c is given by: y=mx+c<\/li>\n<li>Slope of the line at any point is given by the function f'(x) = 3x^2+2<\/li>\n<li>Slope of the tangent line to the curve at x=0 is 2, we get y=2x+c<\/li>\n<li>The tangent line passes through the point (0,1) and hence substituting in the above equation we get:\n<ul>\n<li>1 = 2(0)+c \u27f9 c = 1<\/li>\n<\/ul>\n<\/li>\n<li>The final equation of the tangent line is y = 2x+1<\/li>\n<\/ul>\n<p>Note that the curve has the same slope at both x=2 and x=-2, and hence the two tangent lines at x=2 and x=-2 are parallel. The same would be true for any x=k and x=-k as f'(x) = f'(-x) = 3x^2+2<\/p>\n<h2 id=\"Extensions\">Extensions<\/h2>\n<p>This section lists some ideas for extending the tutorial that you may wish to explore.<\/p>\n<ul>\n<li>Velocity and acceleration<\/li>\n<li>Integration of a function<\/li>\n<\/ul>\n<p>If you explore any of these extensions, I\u2019d love to know. Post your findings in the comments below.<\/p>\n<h2 id=\"Further-Reading\">Further Reading<\/h2>\n<p>This section provides more resources on the topic if you are looking to go deeper.<\/p>\n<h3 id=\"Tutorials\">Tutorials<\/h3>\n<ul>\n<li><a href=\"https:\/\/machinelearningmastery.com\/a-gentle-introduction-to-limits-and-continuity\" target=\"_blank\" rel=\"noopener\">Limits and Continuity<\/a><\/li>\n<li><a href=\"https:\/\/machinelearningmastery.com\/a-gentle-introduction-to-evaluating-limits\" target=\"_blank\" rel=\"noopener\">Evaluating limits<\/a><\/li>\n<li><a href=\"https:\/\/machinelearningmastery.com\/a-gentle-introduction-to-function-derivatives\" target=\"_blank\" rel=\"noopener\">Derivatives<\/a><\/li>\n<\/ul>\n<h3 id=\"Resources\">Resources<\/h3>\n<ul>\n<li>Additional resources on <a href=\"https:\/\/machinelearningmastery.com\/calculus-books-for-machine-learning\/\" target=\"_blank\" rel=\"noopener\">Calculus Books for Machine Learning<\/a>\n<\/li>\n<\/ul>\n<h3 id=\"Books\">Books<\/h3>\n<ul>\n<li>\n<a href=\"https:\/\/amzn.to\/35Yeolv\" target=\"_blank\" rel=\"noopener\">Thomas\u2019 Calculus<\/a>, 14th edition, 2017. (based on the original works of George B. Thomas, revised by Joel Hass, Christopher Heil, Maurice Weir)<\/li>\n<li>\n<a href=\"https:\/\/www.amazon.com\/Calculus-3rd-Gilbert-Strang\/dp\/0980232759\/ref=as_li_ss_tl?dchild=1&amp;keywords=Gilbert+Strang+calculus&amp;qid=1606171602&amp;s=books&amp;sr=1-1&amp;linkCode=sl1&amp;tag=inspiredalgor-20&amp;linkId=423b93db012f7cc6bb92cb7494a3095f&amp;language=en_US\" target=\"_blank\" rel=\"noopener\">Calculus<\/a>, 3rd Edition, 2017. (Gilbert Strang)<\/li>\n<li>\n<a href=\"https:\/\/amzn.to\/3kS9I52\" target=\"_blank\" rel=\"noopener\">Calculus<\/a>, 8th edition, 2015. (James Stewart)<\/li>\n<\/ul>\n<h2 id=\"Summary\">Summary<\/h2>\n<p>In this tutorial, you discovered the concept of the slope of a curve at a point and the tangent line to a curve at a point.<\/p>\n<p>Specifically, you learned:<\/p>\n<ul>\n<li>What is the slope of a line<\/li>\n<li>What is the average rate of change of a curve over an interval w.r.t. x<\/li>\n<li>Slope of a curve at a point<\/li>\n<li>Tangent to a curve at a point<\/li>\n<\/ul>\n<h2 id=\"Do-you-have-any-questions?\">Do you have any questions?<\/h2>\n<p>Ask your questions in the comments below and I will do my best to answer.<\/p>\n<p>The post <a rel=\"nofollow\" href=\"https:\/\/machinelearningmastery.com\/a-gentle-introduction-to-slopes-and-tangents\/\">A Gentle Introduction to Slopes and Tangents<\/a> appeared first on <a rel=\"nofollow\" href=\"https:\/\/machinelearningmastery.com\/\">Machine Learning Mastery<\/a>.<\/p>\n<\/div>\n<p><a href=\"https:\/\/machinelearningmastery.com\/a-gentle-introduction-to-slopes-and-tangents\/\">Go to Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Author: Mehreen Saeed The slope of a line, and its relationship to the tangent line of a curve is a fundamental concept in calculus. It [&hellip;] <span class=\"read-more-link\"><a class=\"read-more\" href=\"https:\/\/www.aiproblog.com\/index.php\/2021\/07\/08\/a-gentle-introduction-to-slopes-and-tangents\/\">Read More<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":4812,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[24],"tags":[],"_links":{"self":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts\/4811"}],"collection":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=4811"}],"version-history":[{"count":0,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts\/4811\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/media\/4812"}],"wp:attachment":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=4811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=4811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=4811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}