.. _chap-tayler-series-applications-and-intuition: ********************************************* Taylor series -- applications and intuition ********************************************* For now I have one example: the linearized pendulum. Earlier we did see a little bit of physics with the discussion of the Lorenz factor and :math:`E = mc^2\gamma`. But before we start on this example we have to have a brief introduction to differential equations! A tiny introduction to differential equations ============================================= Let us step back to that (now almost nostalgic) time in which we learned how to take derivatives. A glance at some differential equations and their answers --------------------------------------------------------- We will quickly write down some of the derivatives that we used in earlier chapters: .. math:: \frac{dx^n}{dx} & = n x^{n-1} \\ \frac{d \sin(x)}{dx} & = \cos(x) \\ \frac{d \cos(x)}{dx} & = - \sin(x) \\ \frac{d \sin(\omega x)}{dx} & = \omega \cos(\omega x) \\ \frac{d \cos(\omega x)}{dx} & = - \omega \sin(\omega x) \\ \frac{d e^x}{dx} & = e^x \\ \frac{d e^{rx}}{dx} & = r e^{rx} \\ And some higher order derivatives: .. math:: \frac{d^n x^n}{dx^n} & = n \times (n-1) \times \dots \times 1 = n! \\ \frac{d^2 \sin(\omega x)}{dx^2} & = - \omega^2 \sin(\omega x) \\ \frac{d^2 \cos(\omega x)}{dx^2} & = - \omega^2 \cos(\omega x) \\ \frac{d^2 e^{rx}}{dx^2} & = r^2 e^{rx} Now we ask three questions: #. If we know the *derivative* of a function, can we find what the original function was? #. If we know that the *derivative* of a function is related *linearly* to the *function itself*, can we find out what that function was? #. If we have *any equation* with derivatives of a function in it, can we find out what that function was? Note that in these questions: **the unknown is not a number; the unknown is a function!!** Let us look at examples of all three questions, and their solutions: #. Given a derivative: Simple antiderivative: .. math:: \textrm{Problem:} & \;\; \frac{df(x)}{dx} = x^4 \\ \\ \textrm{Solution:} & \;\; f(x) = \frac{1}{5} x^5 + C Or for second order: .. math:: \textrm{Problem:} & \;\; \frac{d^2f(x)}{dx^2} = x^7 \\ \\ \textrm{Solution:} & \;\; f(x) = \frac{1}{8\times 9} x^9 + C_1 x + C_2 Falling body, from Newton's second law with force of gravity: .. math:: \textrm{Problem:} & \;\; m \frac{d^2y(t)}{dt^2} = - m g \\ \\ \textrm{Solution:} & \;\; y(t) = - \frac{1}{2} g t^2 + v_0 t + h Note that the two arbitrary constants here were the initial velocity :math:`v_0` and the initial height from which you drop the body :math:`h`. #. Given a *linear* relation between the derivative and the function itself: Population growth: .. math:: \textrm{Problem:} & \;\; \frac{df(x)}{dx} = r f(x) \\ \textrm{Solution:} & \;\; f(x) = A e^{rx} Harmonic oscillator: .. math:: :label: harmonic-oscillator-general \textrm{Problem:} & \;\; \frac{d^2x(t)}{dt^2} = -\omega^2 x(t) \\ \textrm{Solution:} & \;\; x(t) = A \cos(\omega t) + B \sin(\omega t) #. Given any *arbitrary* relation between the derivative, the function itself, and the variable: Falling body with air drag (solution is very difficult): .. math:: m \frac{d^2y(t)}{dt^2} = -mg + c \left(\frac{dy(t)}{dt}\right)^2 which you can write in Newton's notation as: .. math:: m \ddot{y} = -mg + c \left(\dot{y}\right)^2 This has a *nonlinear* relationship between various derivatives and the function itself, which makes it much more difficult to solve. How did we get those answers? Not by *guessing*, I hope! --------------------------------------------------------- Yes, by guesswork, disappointing as that is. I showed you the examples of derivatives first, so that when you then saw the differential equations you would match them to the examples you knew about. In this section what we do is work through those examples and try to "get used to them". In the future, when you take a full course in differential equations, you will learn that there are some techniques that help your intuition. And what's with those arbitrary constants? ------------------------------------------ Understanding this harks back to the old days of the quadratic formula. Remember the :math:`\pm` that reared its head? Sometimes you have statements of problems that yield more than one solution. The way you pick between the solutions is by carefully considering the scientific logistics of the situation (the "word problem", as it used to be called when we were younger). Let us get used to that. Take the falling body: .. math:: y(t) = - \frac{1}{2} g t^2 + v_0 t + h Now plug in :math:`t = 0` and you get .. math:: y(0) = h so our arbitrary constant h represents the height at time zero! Now look at the velocity at time zero: .. math:: \dot{y}(0) = v_0 so the other arbitrary constant :math:`v_0` represents the velocity at time 0. So one way of thinking about those arbitrary constants is that you find them by looking at the *initial conditions*. A differential equation, paired with a description of the system at a starting point, is called an *"initial value problem"*. For further study: there are many introductions to differential equations. You might take a look at these lecture slides: https://www2.math.upenn.edu/~deturck/m104/notes/week5.pdf archived by the wayback machine at: http://web.archive.org/web/20240113235718if_/https://www2.math.upenn.edu/~deturck/m104/notes/week5.pdf The pendulum: the equation and how to simplify it ================================================= The "simple pendulum" is a classic physics setup shown in :numref:`fig-pendulum`. .. _fig-pendulum: .. figure:: Pendulum_gravity.* :width: 20% A force diagram of a simple pendulum. Because of the constraint of the string, the force of gravity acting on the mass *in the direction of montion* is :math:`mg \sin(\theta)` (Figure credit: wikipedia https://commons.wikimedia.org/wiki/File:Pendulum_gravity.svg licenced under the CC BY-SA 3.0 license.) Here is how to think about these diagrams: the quantity :math:`\theta` is a function of time -- we could write it fully as :math:`\theta(t)`, since it will change with time as the pendulum swings. Our scientific question then becomes: can you "solve" this equation, writing an expression: .. math:: \theta(t) = {\rm SomeFunctionExpression(t)} The terminology used in physics is that we need to "solve Newton's second equation" to find :math:`\theta.` Looking at the force diagram in the picture, we see focus on a very short bit of the *arc* of the circle that the pendulum's mass is constrained to travel. That arc leads from the current position. From geometry we know that the length of a bit of arc is: .. math:: \Delta {\rm ArcLength} = l \Delta(\theta) where l is the length of the string. That expression :math:`l\theta` is what will be used as a displacement in the classical physics equations. Some simple trigonometry will tell us that for this system Newton's 2nd law (:math:`F = m \frac{d^2(l \theta)}{dt^2}`), combined with the force of gravity for a falling body (:math:`F_{\rm gravity} = -mg\sin(\theta)`) will give us (after we cancel :math:`m` which appears on both sides): .. math:: l \frac{d^2\theta}{dt^2} = -g\sin(\theta) \\ \frac{d^2\theta}{dt^2} + \frac{g}{l} \sin(\theta) = 0 We use the name :math:`\omega` (angular frequency) to refer to :math:`\sqrt{g/l}`, and we get: .. math:: \frac{d^2\theta}{dt^2} + \omega^2 \sin(\theta) = 0 We do not know how to solve this! .. sidebar:: The general solution does exist At this time we are not yet looking at differential equations in detail, so we will simply mention (for those who have already studied them) that the *general* solution to this is very very difficult to find: it involves some advanced and subtle mathematical techniques, and the calculation of what are called *elliptical integrals*. For a discussion of the general solution you can `follow this video `_ (archived at `this location `_). But the cool thing we notice is that if :math:`\theta` is a *small* angle, then we can approximate it with: :math:`\sin(\theta) \approx \theta` and our equation becomes: .. math:: \frac{d^2\theta}{dt^2} + \omega^2 \theta = 0 \\ or: .. math:: \frac{d^2\theta}{dt^2} = - \omega^2 \theta This has us asking the question "hey, if you have a function where the slope of the slope of that function is equal to minus the function itself, what does that look like?" We recognize this as the *simple harmonic oscillator* equation. We had first hinted at how this might be solved in :numref:`Taylor Coefficients for sin() and cos() (Section %s) `, Equation :eq:`trig-second-derivative`. More recently we had recapitulated this type of differential equation Equation :eq:`harmonic-oscillator-general`. Briefly: using :math:`\omega = \sqrt{\frac{g}{l}}` we get: .. math:: :label: harmonic-oscillator-pendulum \textrm{Problem:} & \;\; \frac{d^2\theta(t)}{dt^2} = -\frac{g}{l} \theta(t) \\ \textrm{Solution:} & \;\; \theta(t) = A \cos\left(\sqrt{\frac{g}{l}} t\right) + B \sin\left(\sqrt{\frac{g}{l}} t\right) Taylor series, and an intuition on why they work ================================================ Nomenclature ------------ Remember: we always want to demistify terminology, so let's see what names mathematicians use to talk about these series we have experimented with. The kinds of series we work with most of the time are called *power series*. They have the form: .. math:: \sum_{k=0}^{N} c_k x^k where :math:`c_k` are constant *coefficients*. The name "power series" comes from the fact we have increasing powers of :math:`x`. There is a particular type of power series called the *Taylor* series. The Taylor series is a wonderful tool which allows you to approximate a function near a certain point, let's call it :math:`a`. It looks like: .. math:: S(x) = \sum_{k=1}^{\infty} \frac{f^{(k)}(a)}{k!} (x - a)^k :label: taylor-series This formula is dense, so let's unpack the *two parts* of it: #. There are the coefficients, which are constants (they do not depend on :math:`x`): :math:`\frac{f^{(k)}(a)}{k!}`. #. And there is the power term :math:`(x-a)^k`, which does depend on :math:`x`. So this looks like a polynomial of very high degree (you could almost say inifinite degree -- that's not mathematically meaningful, but for very well-behaved functions it's an OK way to think about it). The series for :math:`sin(x)`, :math:`cos(x)`, and :math:`e^x`, which we saw in previous chapters, are all examples of Taylor series. They are all centered at zero, and the coefficients are the *derivatives* of the function, evaluated at zero. In class we can work out what all those derivatives are, and check that the formula we have been using is indeed the Taylor series. You can understand this formula at two levels: you can either say "sure, when I made my plots I noticed that they approximate the sin, cos, and exponential functions nicely." Or you can say "hey that's really cool: I wonder how those high order derivatives come in to it". Intuition on the Taylor Series derivatives ------------------------------------------ This is a good topic to develop with the students. By looking at :numref:`fig-sin_polys` we can see how the various higher derivatives in the sin function in Equation :eq:`taylor-series` nudge our series to get closer and closer to the actual value of the function. [This writeup will continue when the students in the working group have come up with a good way of describing that intuition.] A historical diversion: Bhaskara I's formula ============================================ https://en.wikipedia.org/wiki/Bhaskara_I%27s_sine_approximation_formula