{"id":323,"date":"2012-09-17T19:42:21","date_gmt":"2012-09-18T01:42:21","guid":{"rendered":"http:\/\/www.ghyzmo.com\/?p=323"},"modified":"2012-11-16T21:25:45","modified_gmt":"2012-11-17T04:25:45","slug":"grokking-calculus","status":"publish","type":"post","link":"http:\/\/www.ghyzmo.com\/grokking-calculus\/","title":{"rendered":"Grokking Calculus"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><em>\u00a9Fernando Caracena 13 September 2012<\/em><\/p>\n<p>The way to get insight about mathematics is to visualize the various relationships between variables--by plotting for example. A function [f(x)] is a mathematical expression that assigns an output value for each input value (x). There are all kinds of weird functions that mathematicians can dream up, for example, a function that can give several output values for every input; or, a function where closely spaced input gives disjointed output. Physicists and engineers generally prefer to use functions that are very smooth and give a single output value for every input and, in which the output varies continually with the input, for example, as in Fig. 1. These are the kinds of functions associated with many physical processes of interest. Calculus normally deals with the properties of these types of functions.<\/p>\n<p>Calculus is an important branch of mathematics that is a vital part of the language of physics. It is used in a variety of areas of study, such as: engineering, chemistry, geology, economics, programming, signal processing, electronics, astronomy, biology, architecture, and all kinds of modelling and simulation. The methods of calculus expressed as finite differences are valuable in solving all kinds of dynamical problems on the computer, such as those governing weather systems, or the flow of air over an airplane wing.<\/p>\n<h2><em>Two Kinds of Problems in Calculus<\/em><\/h2>\n<p><a href=\"http:\/\/en.wikipedia.org\/wiki\/Calculus\">Calculus<\/a> deals with two types of mathematical problems:<\/p>\n<p>1. Differential calculus addresses the problem of determining the slope of a tangent line drawn at any given point on a curve that is generated by some formula (Eg., Fig. 1a). A tangent line at a point is one that goes through that point without touching nearby points on that curve. The slope of a tangent line to the curve at a given point gives the rate of change of the output variable relative to the input variable.<\/p>\n<p>2. Integral calculus addresses the problem of finding the area between a curve that is generated by a formula as a function of x and the x-axis (Eg., Fig. 2).<\/p>\n<p>Both problems use the idea of limiting values, the <a title=\"Theory of limits\" href=\"http:\/\/en.wikipedia.org\/wiki\/Limit_%28mathematics%29\" target=\"_blank\">theory of limits<\/a>, which is the idea that a function or sequence of numbers approaches some limiting value as the input, or independent variable, approaches some value. Specifically in the case of calculus, the ratio of two small quantities progressively approaches some limiting value as the quantities get progressively smaller<\/p>\n<p>Calculus is presented here for those who are interested in wading deeply into the ideas of physics. I will attempt to present a discussion of physics using as few equations as possible, but with reference to the mathematical parts, by hyperlinks for those who may be interested in greater detail.<\/p>\n<p>The history and mathematical development of <a href=\"http:\/\/en.wikipedia.org\/wiki\/Calculus\">calculus<\/a> are discussed in detail in the indicated hyperlink to a Wikipedia article on calculus<\/p>\n<p>The kind of function that lends itself best to the methods of calculus is one that plots to a curve on a certain scale, but approaches progressively a straight line at smaller scales. For example, the whole Earth is round, but as we approach Lake Bonneville, the surface of the Earth gets flatter. Straight lines drawn on that surface become circles if extended around the Earth. However, at some smaller scale reality gets rough again. In the case of Lake Bonneville, the ground is very flat until you shrink your point of view to that of a small ant, which can see the grains of sand and salt as huge and so cannot draw a straight line on that surface. The kind of flatting that mathematicians imagine for this class of functions is one that continues to get progressively flatter on progressively smaller scales, until the function is almost indistinguishable from a straight line.<\/p>\n<p>In the following examples, a snippet of python code (<span style=\"color: #0000ff;\">see listings<\/span>) precedes the figures with corresponding numbering, which it generates. If you run the code, make sure that you run the snippets in sequence so that you do not lose initial values.<\/p>\n<p>Let us begin developing the ideas of calculus by concentrating on single valued functions f(x) of one independent variable (x). It is possible to extend this treatment to single-valued functions of several variables, but we do not do that here in the interest of keeping the discussion as simple as possible.<\/p>\n<p>Consider a plot of x, y [= f(x)], which generates a curve on a two-dimensional piece of graph paper that is ruled as a Cartesian grid, viz., the familiar x and y axes perpendicular to each other. In this case the curve consists of all the points (x, y) generated by assigning the value of y to the function of x within a given, continuous range in the input variable,<\/p>\n<p>y=f(x), x<sub><strong><sub><strong>1<\/strong><\/sub><\/strong><\/sub>&lt; x &lt; x<sub><strong>2<\/strong><\/sub>\u00a0 . \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (1)<\/p>\n<p>Note that (1) makes the y-values entirely dependent on x-values, and that the range of y (its domain) is entirely limited to the domain over which x is defined. At x=x<sub><strong><sub><strong>1<\/strong><\/sub><\/strong><\/sub>, y<sub><strong>1<\/strong><\/sub> =f(x<sub><strong>1<\/strong><\/sub>) and at x=x<sub><strong>2<\/strong><\/sub>, y<sub><strong>2<\/strong><\/sub> =f(x<sub><strong>2<\/strong><\/sub>) and the maxima and minima of y in the middle of that range.<\/p>\n<p><span style=\"color: #0000ff;\">Listing 1 a<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">#______________________________________________________________________________________________________________<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">ipython \u2013pylab<br \/>\nfrom pylab import *<br \/>\na=1.0<br \/>\nx=arange(0,1.01, 0.01)<br \/>\ny=a*sin(math.pi*x)<br \/>\nfigure()<br \/>\np=fill([0.,0.,1.0,1.0],[0, 1.5*a,1.5*a,0], facecolor=\u2019w')<br \/>\n# plot([0.,1.0],[1.5*a,1.5*a], color=\u2019w')<br \/>\nlines=plot(x,y)<br \/>\nplt.setp(p, edgecolor=\u2019w', linewidth=2.0)<br \/>\nx0=0.35<br \/>\ny0=a*sin(math.pi*x0)<br \/>\nplot(x0,y0, \u2018ko\u2019, markeredgecolor=\u2019r')<br \/>\ndydx0=math.pi*a*cos(math.pi*x0)<br \/>\nytan=y0+(x-x0)*dydx0<br \/>\ntline=plot(x,ytan, color=\u2019r')<br \/>\nxlabel(\u2018x\u2019, color=\u2019k')<br \/>\nylabel(\u2018y\u2019, color=\u2019k')<br \/>\ntitle(\u201cFunction and Tangent line\u201d, color=\u2019k')<br \/>\ntext(x0-0.05,y0+.1,r\u2019(x0,y0)\u2019)<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">#______________________________________________________________________________________________________________<\/span><\/p>\n<div id=\"attachment_332\" style=\"width: 311px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.ghyzmo.com\/grokking-calculus\/tanline\/\" rel=\"attachment wp-att-332\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-332\" class=\" wp-image-332\" title=\"TanLine\" src=\"http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/TanLine.png\" alt=\"Line tangent to a plotted curve.\" width=\"301\" height=\"228\" srcset=\"http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/TanLine.png 812w, http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/TanLine-150x113.png 150w, http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/TanLine-300x226.png 300w\" sizes=\"auto, (max-width: 301px) 100vw, 301px\" \/><\/a><p id=\"caption-attachment-332\" class=\"wp-caption-text\">Fig. 1a Line tangent to a sine function at the point (x0, y0).<\/p><\/div>\n<p>The mathematical function plotted in Fig. 1a was generated by python code in Listing 1a. Note that the plot becomes progressively more linear on progressively smaller intervals , until the curve segment resembles a straight line. (See Figs. 1a-1c and corresponding listings.)<\/p>\n<h3><\/h3>\n<h3><span style=\"color: #0000ff;\"><em>Listing 1b (Python code for generating Fig. 1b<\/em><\/span><\/h3>\n<p><span style=\"font-size: x-small; color: #0000ff;\">#___________________________________________________________________<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">x1=x0-0.05<br \/>\nx2=x0+0.05<br \/>\nx=arange(0,1.01, 0.01)*(x2-x1)+x1<br \/>\ny=a*sin(math.pi*x)<br \/>\ny1=a*sin(math.pi*x1)<br \/>\ny2=a*sin(math.pi*x2)<br \/>\nfigure()<br \/>\np=fill([x1,x2,x2,x1,x1],[y1,y1,y2,y2,y1], facecolor='w')<br \/>\nplt.setp(p, edgecolor='w', linewidth=2.0)<br \/>\nlines=plot(x,y)<br \/>\nplot(x0,y0, 'ko', markeredgecolor='r')<br \/>\ndydx0=math.pi*a*cos(math.pi*x0)<br \/>\nytan=y0+(x-x0)*dydx0<br \/>\ntline=plot(x,ytan, color='r')<br \/>\nxlabel('x', color='k')<br \/>\nylabel('y', color='k')<br \/>\ntitle(\"Function and Tangent line\", color='k')<br \/>\ntext(x0-0.005,y0+.01,r'(x0,y0)')<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">#__________________________________________________________________<\/span><\/p>\n<div id=\"attachment_333\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.ghyzmo.com\/grokking-calculus\/tanline_2\/\" rel=\"attachment wp-att-333\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-333\" class=\" wp-image-333\" title=\"TanLine_2\" src=\"http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/TanLine_2.png\" alt=\"Sine plot and tangent line.\" width=\"300\" height=\"227\" srcset=\"http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/TanLine_2.png 812w, http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/TanLine_2-150x113.png 150w, http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/TanLine_2-300x226.png 300w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-333\" class=\"wp-caption-text\">Fig. 1b As in Fig. 1a, but defined over a smaller range of x.<\/p><\/div>\n<p>The Figs. 1a -1c illustrate how over a progressively smaller range of x, the values of y given by (1) for the function,<\/p>\n<p>f(x)=sin(\u03c0*x),<\/p>\n<p>generate a series of plots progressively approaching the tangent line at the point (x<sub>0<\/sub>, y<sub>0<\/sub>), where the value of x at that point is x<strong><sub>0<\/sub><\/strong> =3.5 (Fig. 3).<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #0000ff;\">Listing 1c<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">#______________________________________________________________<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">x1=x0-0.005<br \/>\nx2=x0+0.005<br \/>\nx=arange(0,1.01, 0.01)*(x2-x1)+x1<br \/>\ny=a*sin(math.pi*x)<br \/>\ny1=a*sin(math.pi*x1)<br \/>\ny2=a*sin(math.pi*x2)<br \/>\nfigure()<br \/>\np=fill([x1,x2,x2,x1,x1],[y1,y1,y2,y2,y1], facecolor='w')<br \/>\nplt.setp(p, edgecolor='w', linewidth=2.0)<br \/>\nlines=plot(x,y+(1-rnd())))<br \/>\nplot(x0,y0, 'ko', markeredgecolor='r')<br \/>\ndydx0=math.pi*a*cos(math.pi*x0)<br \/>\nytan=y0+(x-x0)*dydx0<br \/>\ntline=plot(x,ytan, color='r')<br \/>\nxlabel('x', color='k')<br \/>\nylabel('y', color='k')<br \/>\ntitle(\"Function and Tangent line\", color='k')<br \/>\ntext(x0-0.005,y0+.01,r'(x0,y0)')<\/span><\/p>\n<p><span style=\"font-size: x-small;\">#______________________________________________________________<\/span><\/p>\n<div id=\"attachment_334\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.ghyzmo.com\/grokking-calculus\/tanline_3\/\" rel=\"attachment wp-att-334\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-334\" class=\" wp-image-334\" title=\"TanLine_3\" src=\"http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/TanLine_3.png\" alt=\"Tangent to indicated point on sine plot over a restricted range\" width=\"300\" height=\"226\" srcset=\"http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/TanLine_3.png 812w, http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/TanLine_3-150x113.png 150w, http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/TanLine_3-300x226.png 300w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-334\" class=\"wp-caption-text\">Fig. 1c As in Fig. 1a and 1b but in a still more restricted range.<\/p><\/div>\n<h3><\/h3>\n<h3><\/h3>\n<h3><em><strong>The Derivative as the Limit of a Sequence of Ratios<\/strong><\/em><\/h3>\n<p>Listing 3 is a python snippet for estimating the value of the derivative of the function (2) at the point x0 =3.5 and y0 = f(x0). The derivative is estimated by the ratios,<\/p>\n<p>df\/dx \u2248 [f(x0+xs)-f(x0)]\/xs,\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (3a)<br \/>\nover the sequence of displacements<br \/>\nxs=1.00,....., 0.1, 0.01, 0.001, 0.0001, 0.00001 ,<\/p>\n<p>where the symbol,\u2248, stands for approximately equal. In (3b), the interval over which the derivative is estimated (xs) drops by a power of ten over what it is in Fig. 3a. Note that over the smaller range, the approach of xs to zero on the scale of 0.01 is almost linear, and the limit approximated by looking at the graph is about 1.46. Python gives as the estimate of the derivative for the smallest value of xs (0.00001) as 1.42620925, which compares well to the value of the actual derivative computed by the methods of calculus and evaluated with python, 1.42625321878. The two differ only in the 5th decimal place by<span style=\"font-size: small;\"> about 4 x 10<sup>-5<\/sup><\/span>, which means that with a computer, we can estimate the value of derivatives fairly well using finite differences.<\/p>\n<p>In physics problems, one does not normally require high precision given by python, especially when working with experimental values, which have a scale of measurement error that renders writing the number at higher precision meaningless. What python does is not to introduce further error by treating the numbers entering a calculation with a high precision. What physicists do in this situation, is to estimate the size of error in the result of calculations by the method of propagation of errors, which is adopted from calculus, and then round off the final number adding an estimate of the error as \u00b1 some smaller value.<\/p>\n<p><span style=\"color: #0000ff;\">Listing 2<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">#_________________________________________________________________<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">a=1.0<br \/>\nx=arange(0,1.01, 0.01)<br \/>\ny=a*sin(math.pi*x)<br \/>\nx1=concatenate((x,x[::-1]))<br \/>\ny1=concatenate((0*y,y[::-1]))<br \/>\nfigure()<br \/>\np=fill(x, y, facecolor='g')<br \/>\nplt.setp(p, edgecolor='w', linewidth=2.0)<br \/>\nlines=plot(x,y, color='r')<br \/>\nplt.setp(lines, edgecolor='r', linewidth=2.0)<br \/>\nplot([0.,1.0],[1.5*a,1.5*a], color='w')<br \/>\nxlabel('x', color='k')<br \/>\nylabel('y', color='k')<br \/>\ntitle(\"Integral as an area under a curve\", color='k')<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">#__________________________________________________________________<\/span><\/p>\n<div id=\"attachment_338\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.ghyzmo.com\/grokking-calculus\/intgrlasarea\/\" rel=\"attachment wp-att-338\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-338\" class=\" wp-image-338\" title=\"IntgrlAsArea\" src=\"http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/IntgrlAsArea.png\" alt=\"An Integral as an area under a curve\" width=\"300\" height=\"226\" srcset=\"http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/IntgrlAsArea.png 812w, http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/IntgrlAsArea-150x113.png 150w, http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/IntgrlAsArea-300x226.png 300w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-338\" class=\"wp-caption-text\">Fig. 2 An Integral as the area under a curve that is generated by a function of x.<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #0000ff;\">Listing 3<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">#__________________________________________________________________<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">a=1.0<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">figure()<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\"># define an array that defines decreasing increments of x about point defined by x0:<br \/>\nxs=array([1.00,0.1,0.01, 0.001, 0.0001, 0.00001])<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">#an array of derivative estimates at shrinking scales of dx=xs<br \/>\ndydxs=(a*sin(math.pi*(x0+xs))-y0)\/xs<br \/>\npdp=plot(xs, dydxs)<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\"># plot derivative computed by methods of calculus at the limit, xs=0:<br \/>\nplot(0,dydx0, 'ko', markeredgecolor='r')<br \/>\nxlabel('delx', color='k')<br \/>\nylabel('dely\/delx estimate', color='k')<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">#___________________________________________________________________<\/span><\/p>\n<p>&nbsp;<\/p>\n<div id=\"attachment_475\" style=\"width: 308px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.ghyzmo.com\/grokking-calculus\/derivaslimratio\/\" rel=\"attachment wp-att-475\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-475\" class=\" wp-image-475\" title=\"DerivAsLimRatio\" src=\"http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/DerivAsLimRatio.png\" alt=\"\" width=\"298\" height=\"224\" srcset=\"http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/DerivAsLimRatio.png 812w, http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/DerivAsLimRatio-150x113.png 150w, http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/DerivAsLimRatio-300x226.png 300w\" sizes=\"auto, (max-width: 298px) 100vw, 298px\" \/><\/a><p id=\"caption-attachment-475\" class=\"wp-caption-text\">Fig. 3a The derivative of the function at the point (x0,y0) computed from the limit of ratio of dy\/dx.<\/p><\/div>\n<h3><\/h3>\n<h3><\/h3>\n<h3><\/h3>\n<h3><\/h3>\n<h3><\/h3>\n<h3><\/h3>\n<h3><\/h3>\n<h3><em><strong>Definition of a Derivative<\/strong><\/em><\/h3>\n<p>The derivative of a function ( df(x)\/dy) is itself a function that is given at every point in the range of both the independent and output variable through a procedure that involves finding the limit of the ratio of increment of the output to that of the input:<\/p>\n<p>df(x)\/dy=Lim <sub><sub>\u0394<\/sub><sub>x<\/sub>\u2014&gt;0 <\/sub>[f(x+\u0394x)-f(x)]\/\u0394x.\u00a0\u00a0 (4a)<\/p>\n<p>Note that the ratio is not defined numerically at the limit, but anywhere as close as you want to approach \u0394x=0. In Fig. 3, the approach was generated by descending orders of magnitude, which in listing 1 are given as: \u00a0 \u0394x=array([1.00,0.1,0.01, 0.001, 0.0001, 0.00001]).<\/p>\n<div id=\"attachment_478\" style=\"width: 285px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.ghyzmo.com\/grokking-calculus\/derivaslimratio_c\/\" rel=\"attachment wp-att-478\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-478\" class=\" wp-image-478\" title=\"DerivAsLimRatio_C\" src=\"http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/DerivAsLimRatio_C.png\" alt=\"\" width=\"275\" height=\"207\" srcset=\"http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/DerivAsLimRatio_C.png 812w, http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/DerivAsLimRatio_C-150x113.png 150w, http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/DerivAsLimRatio_C-300x226.png 300w\" sizes=\"auto, (max-width: 275px) 100vw, 275px\" \/><\/a><p id=\"caption-attachment-478\" class=\"wp-caption-text\">Fig. 3b Plot of the ratio of the change in y and the change in x about a restricted range of xhanges in x about the point x0,y0.<\/p><\/div>\n<p>Well known functions functions subjected to the above derivative procedure, often give a term that is a function only of x, and trailing terms that contain various powers of \u0394x. As \u0394x approaches zero, that function of x remains as the limit.<\/p>\n<h3><\/h3>\n<h3><\/h3>\n<h3>Finite Difference Approximation<\/h3>\n<p>Sometimes an analyst is using tabulated values of a function that may not be defined mathematically, but are defined by observation. <a title=\"Galileo's observation of motion\" href=\"http:\/\/www.ghyzmo.com\/grokking-galileos-physics\/\">Galileo's observations of motion<\/a> are examples of this. Such situations arise in signal processing, or in higher dimensions, image processing. In this case, the derivatives of an observed function can be estimated from its tabulated values (<span style=\"font-family: Liberation Serif,serif;\">x<\/span><sub><span style=\"font-family: Liberation Serif,serif;\">i<\/span><\/sub><span style=\"font-family: Liberation Serif,serif;\"> and f<\/span><sub><span style=\"font-family: Liberation Serif,serif;\">i<\/span><\/sub>) by using finite differences. Suppose that the observed input values (x<sub>i<\/sub>) are evenly spaced, viz.<\/p>\n<p>x<sub>i<\/sub> = x<sub>o<\/sub> + i*\u0394x.<\/p>\n<p>In that case, the derivative of the observed function, f<sub>i<\/sub>\u00a0 \u00a0 is estimated as the ratio of finite increments,<\/p>\n<p>df<sub>i<\/sub>\/dx\u2248 (f<sub>i+1<\/sub>- f<sub>i-1<\/sub> )\/ (x<sub>i+1<\/sub>- x<sub>i-1<\/sub> ),<\/p>\n<p>Which is called the centered difference approximation.<\/p>\n<p><span>Listing 4<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">#__________________________________________________________________<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">dydx=0.*x<br \/>\nfor i in range(1,99):<br \/>\ndydx[i]=(y[i+1]-y[i-1])\/(x[i+1]-x[i-1])<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">figure()<br \/>\npdp=plot(x[1:99], dydx[1:99])<br \/>\ndydxf=math.pi*a*cos(math.pi*x)<br \/>\nplot(x[1:99], dydxf[1:99], color='r')<br \/>\nxlabel('x', color='k')<br \/>\nylabel('y', color='k')<br \/>\ntitle(\"Actual(red) and Estimated derivative(blue)\", color='k')<\/span><\/p>\n<p><span style=\"font-size: x-small; color: #0000ff;\">#_________________________________________________________________<\/span><\/p>\n<p>&nbsp;<\/p>\n<div id=\"attachment_339\" style=\"width: 309px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.ghyzmo.com\/grokking-calculus\/actualandestmtddervi\/\" rel=\"attachment wp-att-339\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-339\" class=\" wp-image-339\" title=\"actualAndEstmtdDervi\" src=\"http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/actualAndEstmtdDervi.png\" alt=\"Actual and estimated cenetered difference derivative\" width=\"299\" height=\"225\" srcset=\"http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/actualAndEstmtdDervi.png 812w, http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/actualAndEstmtdDervi-150x113.png 150w, http:\/\/www.ghyzmo.com\/wp-content\/uploads\/2012\/09\/actualAndEstmtdDervi-300x226.png 300w\" sizes=\"auto, (max-width: 299px) 100vw, 299px\" \/><\/a><p id=\"caption-attachment-339\" class=\"wp-caption-text\">Fig. 4 Actual and estimated centred difference derivative<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>The validity of the finite difference approximation is tested in Fig. 4, where the derivative computed by the methods of calculus is first plotted in blue, then the centred difference estimate is plotted on top of it in red. Note that over the entire range of the plot, the estimated derivative completely covers that of the analytically computed derivative.<\/p>\n<h3>Derivatives of Functions that are Powers of x<\/h3>\n<p>Below, the various derivatives are derived, showing almost every step in the derivation<\/p>\n<p>_____________________________________________________________________<\/p>\n<p><span style=\"color: #000080;\">f(x)=x<\/span><\/p>\n<p><span style=\"color: #000080;\">df(x)\/dx = lim <\/span>\u0394<span style=\"color: #000080;\"><span style=\"font-family: Liberation Serif,serif;\">x<\/span><\/span><span style=\"color: #000080;\"> \u2014&gt;0 in [<\/span><span style=\"color: #000080;\"><span style=\"font-family: Liberation Serif,serif;\">f(x+<\/span><\/span>\u0394<span style=\"color: #000080;\"><span style=\"font-family: Liberation Serif,serif;\">x)<\/span><\/span><span style=\"color: #000080;\">-f(x)]\/[x+<\/span>\u0394<strong><span style=\"color: #000080;\"><span style=\"font-family: Liberation Serif,serif;\">x<\/span><\/span><\/strong><span style=\"color: #000080;\">-x]<\/span><\/p>\n<p><span style=\"color: #000080;\">df(x)\/dx =lim x<\/span><span style=\"color: #000080;\"><sub>s<\/sub><\/span><span style=\"color: #000080;\">\u2014&gt;0 in [<\/span>\u0394<span style=\"color: #000080;\"><span style=\"font-family: Liberation Serif,serif;\">x\/<\/span><\/span>\u0394<span style=\"color: #000080;\"><span style=\"font-family: Liberation Serif,serif;\">x<\/span><\/span><span style=\"color: #000080;\">]<\/span><\/p>\n<p><span style=\"color: #000080;\">df(x)\/dx = 1<\/span><\/p>\n<p><span style=\"color: #000080;\">dx\/dx =1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (5)<br \/>\n<\/span><\/p>\n<p>___________________________________________________________________<\/p>\n<p><span style=\"color: #000080;\">df(x)\/dx =x<sup>2<\/sup><\/span><\/p>\n<p><span style=\"color: #000080;\">df(x)\/dx = lim <sub><span style=\"font-family: Symbol;\">\u0394<\/span><\/sub><sub><span style=\"font-family: Liberation Serif,serif;\">x\u2014&gt;0 <\/span><\/sub>in [f(x+\u0394<span style=\"font-family: Liberation Serif,serif;\">x<\/span>)-f(x)]\/[x+\u0394<strong><span style=\"font-family: Liberation Serif,serif;\">x<\/span><\/strong>-x]<\/span><\/p>\n<p><span style=\"color: #000080;\">df(x)\/dx = lim <sub><span style=\"font-family: Liberation Serif,serif;\"><sub>\u0394<\/sub><sub>x<\/sub>\u2014&gt;0<\/span><\/sub> in {[<span style=\"font-family: Liberation Serif,serif;\">(x+<\/span><span style=\"font-family: Liberation Serif,serif;\">\u0394x)<\/span><sup><span style=\"font-family: Liberation Serif,serif;\">2<\/span><\/sup>- <span style=\"font-family: Liberation Serif,serif;\">x<\/span><sup><span style=\"font-family: Liberation Serif,serif;\">2<\/span><\/sup>)]\/\u0394<strong><span style=\"font-family: Liberation Serif,serif;\">x<\/span><\/strong>}<\/span><\/p>\n<p><span style=\"color: #000080;\">df(x)\/dx = lim <sub><span style=\"font-family: Liberation Serif,serif;\"><sub>\u0394<\/sub><sub>x<\/sub>\u2014&gt;0<\/span><\/sub> in {[<span style=\"font-family: Liberation Serif,serif;\">(x<\/span><sup><span style=\"font-family: Liberation Serif,serif;\">2<\/span><\/sup><span style=\"font-family: Liberation Serif,serif;\">+2x*<\/span>\u0394<span style=\"font-family: Liberation Serif,serif;\">x+<\/span>\u0394<span style=\"font-family: Liberation Serif,serif;\">x <\/span><sup><span style=\"font-family: Liberation Serif,serif;\">2<\/span><\/sup><span style=\"font-family: Liberation Serif,serif;\">)<\/span>- x<sup>2<\/sup>]\/\u0394x}<\/span><\/p>\n<p><span style=\"font-family: Liberation Serif,serif; color: #000080;\">df(x)\/dx = lim <sub><span style=\"font-family: Liberation Serif,serif;\"><sub>\u0394<\/sub><sub>x<\/sub>\u2014&gt;0<\/span><\/sub> in {[2x*<span style=\"font-family: Liberation Serif,serif;\">\u0394x<\/span>+\u0394x<sup style=\"color: #0000ff;\">2 <\/sup>]\/\u0394x}<\/span><\/p>\n<p><span style=\"color: #000080;\">df(x)\/dx = lim <sub><span style=\"font-family: Liberation Serif,serif;\"><sub>\u0394<\/sub><sub>x<\/sub>\u2014&gt;0<\/span><\/sub> in {2x+<span style=\"font-family: Liberation Serif,serif;\">\u0394x<\/span>]}<\/span><\/p>\n<p><span style=\"color: #000080;\">df(x)\/dx = 2x<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #000080;\">\u00a0\u00a0\u00a0 (6)<\/span><\/p>\n<p>It is possible to expand the function, (x+\u0394x)<sup>n<\/sup>, as a power series in \u0394x,<\/p>\n<p>(x+\u0394x)<sup>n<\/sup>= x<sup>n<\/sup>+n*x<sup>n-1<\/sup> *\u00a0\u0394x + const.* x<sup>n-2<\/sup> *\u00a0\u0394x<sup>2<\/sup> \u00a0 +...+\u0394x<sup>n<\/sup>.<\/p>\n<p>The constant terms in front of the various products of powers of x and \u0394x, called binomial coefficients,do not matter here, except for the first two, because they stand in front of terms that go to zero.<\/p>\n<p><span style=\"color: #000080;\">df(x<sup>n<\/sup>)\/dx = lim <sub><sub>\u0394<\/sub><sub>x<\/sub>\u2014&gt;0<\/sub> in [(x+\u0394x)<sup>n<\/sup> - x<sup>n<\/sup> ]\/\u0394x<\/span><\/p>\n<p><span style=\"color: #000080;\">df(x<sup>n<\/sup>)\/dx = lim <sub><sub>\u0394<\/sub><sub>x<\/sub>\u2014&gt;0<\/sub> in [x<sup>n<\/sup>+n*x<sup>n-1<\/sup>*\u0394x+ const.* x<sup>n-2<\/sup> *\u00a0\u0394x<sup>2<\/sup> \u00a0 +...+\u0394x<sup>n<\/sup> - x<sup>n<\/sup>]\/\u0394x<\/span><\/p>\n<p><span style=\"color: #000080;\">d<span style=\"font-family: Liberation Serif,serif;\">(x<\/span><sup><span style=\"font-family: Liberation Serif,serif;\">n<\/span><\/sup>)dx = lim <sub><sub>\u0394<\/sub><sub>x<\/sub>\u2014&gt;0<\/sub> in [n*<span style=\"font-family: Liberation Serif,serif;\">x<\/span><sup><span style=\"font-family: Liberation Serif,serif;\">n-1<\/span><\/sup>+ const.* x<sup>n-2<\/sup> *\u00a0\u0394x \u00a0 +...+\u0394x<sup>n-1<\/sup>]<\/span><\/p>\n<p><span style=\"color: #000080;\">d(x<sup>n<\/sup>)dx =\u00a0n*x<sup>n-1<\/sup>. \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (7)<\/span><\/p>\n<h3><em><strong>Endnote<\/strong><\/em><\/h3>\n<p>There are properties of derivatives that should be added here and are listed as follows:<\/p>\n<p>if g(x)= A*f(x), where A is constant then<\/p>\n<p>dg(x)\/dx=A*df(x)\/dx.<\/p>\n<p>The derivative of a sum and product of two is given by the following two formulas:<\/p>\n<p>d[g(x)*f(x)]\/dx=f(x)*dg(x)\/dx+g(x)*df(x)\/dx<\/p>\n<p>d(g(x)+f(x))\/dx=dg(x)\/dx + df(x)\/dx.<\/p>\n<p>Some of the methods of <a title=\"Integral calculus\" href=\"http:\/\/www.ghyzmo.com\/grokking-calculus-integral-calculus\/\">integral calculus<\/a> will be discussed in the next blog entry on the subject of calculus, and derivatives of trigonometric function are also discussed.<\/p>\n<p>d f(x(t))\/dt = [df(x)\/dx]*dx(t)\/dt<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \u00a9Fernando Caracena 13 September 2012 The way to get insight about mathematics is to visualize the various relationships between variables--by plotting for example. A function [f(x)] is a mathematical expression that assigns an output value for each input value &hellip; <a href=\"http:\/\/www.ghyzmo.com\/grokking-calculus\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/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":[15,25,24,10,12,43,42],"tags":[9,13,14,17,11,79,80],"class_list":["post-323","post","type-post","status-publish","format-standard","hentry","category-calculus-2","category-derivatives","category-differential-calculus","category-mathematics","category-physics","category-programming","category-python","tag-calculus","tag-grok","tag-grokking","tag-integrals","tag-math","tag-mathematics","tag-physics"],"_links":{"self":[{"href":"http:\/\/www.ghyzmo.com\/wp-json\/wp\/v2\/posts\/323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.ghyzmo.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ghyzmo.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ghyzmo.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ghyzmo.com\/wp-json\/wp\/v2\/comments?post=323"}],"version-history":[{"count":42,"href":"http:\/\/www.ghyzmo.com\/wp-json\/wp\/v2\/posts\/323\/revisions"}],"predecessor-version":[{"id":379,"href":"http:\/\/www.ghyzmo.com\/wp-json\/wp\/v2\/posts\/323\/revisions\/379"}],"wp:attachment":[{"href":"http:\/\/www.ghyzmo.com\/wp-json\/wp\/v2\/media?parent=323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ghyzmo.com\/wp-json\/wp\/v2\/categories?post=323"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ghyzmo.com\/wp-json\/wp\/v2\/tags?post=323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}