Solving the heat equation | DE3

Solving the heat equation | DE3


We last left off studying the heat equation in the one-dimensional case of a rod the question is how the temperature distribution along such a rod will tend to change over time and This gave us a nice first example for a partial differential equation It told us that the rate at which the temperature at a given point changes over time Depends on the second derivative of that temperature at that point with respect to space where there’s curvature in space there’s change in time Here we’re gonna look at how to solve that equation And actually it’s a little misleading to refer to all of this as solving an equation The PDE itself only describes one out of three constraints that our temperature function must satisfy If it’s gonna accurately describe heat flow, it must also satisfy certain boundary conditions Which is something we’ll talk about momentarily and a certain initial condition That is you don’t get to choose how it looks at time T equals zero that’s part of the problem statement These added constraints are really where all of the challenge actually lies there is a vast ocean of function solving the PDE in the sense that when you take their partial derivatives the thing is going to Be equal and a sizable subset of that ocean satisfies the right boundary conditions When Joseph Fourier solved this problem in 1822 his key contribution was to gain control of this ocean Turning all of the right knobs and dials. So as to be able to select from it the particular solution fitting a given initial condition We can think of his solution as being broken down into three fundamental observations Number one certain sine waves offer a really simple solution to this equation number two If you know multiple solutions the sum of these functions is also a solution and number three most surprisingly any Function can be expressed as a sum of sine waves Well a pedantic mathematician might point out that there are some pathological exceptions certain weird functions where this isn’t true But basically any distribution that you would come across in practice including discontinuous ones can be written as a sum of sine waves potentially infinitely many and if you’ve ever heard of Fourier series, you’ve at least heard of this last idea and if so, Maybe you’ve wondered why on earth. Would anyone care about breaking down a function as some of sine waves Well in many applications sine waves are nicer to deal with than anything else and differential equations offers us a really nice context Where you can see how that plays out for our heat equation when you write a function as a sum of these waves the relatively clean second derivatives makes it easy to solve the heat equation for each one of them and As you’ll see a sum of solutions to this equation Gives us another solution and so in turn that will give us a recipe for solving the heat equation for any complicated distribution as an initial state here Let’s dig into that first step why exactly would sign waves play nicely with the heat equation to avoid messy constants let’s start simple and say that the temperature function at time T equals zero is Simply sine of X where X describes the point on the rod Yes, the idea of a-rod’s temperature Just happening to look like sine of X varying around whatever temperature our conventions arbitrarily label a zero is clearly absurd but in math You should always be happy to play with examples that are idealized potentially Well beyond the point of being realistic because they can offer a good first step in the direction of something more general and hence more realistic The right-hand side of this heat equation asks about the second derivative of our function How much our temperature distribution curves as you move along space? The derivative of sine of X is cosine of X Whose derivative in turn is negative sine of X the amount that wave curves is in a sense Equal and opposite to its height at each point So at least at the time T equals zero This has the peculiar effect that each point changes its temperature at a rate proportional to the temperature of the point itself with the same proportionality constant across all points So after some tiny time step everything scales down by the same factor and after that It’s still the same sine curve shape just scale down a bit So the same logic applies and the next time step would scale it down Uniformly again and this applies just as well in the limit as the size of these time steps approaches zero So unlike other temperature distributions sine waves are peculiar in that they’ll get scaled down uniformly Looking like some constant times sine of X for all times T Now when you see that the rate at which some value changes is proportional to that value itself your mind should burn with the thought of an exponential and if it’s not or if you’re a little rusty on the idea of taking Derivatives of Exponential’s or what makes the number e special I’d recommend you take a look at this video the upshot is that the derivative of e to some constant times T is equal to that constant times itself if the rate at which your investment grows for example is always say 0.05 times the total value then its value over time is going to look like e to the 0.05 times T times whatever the initial investment was if The rate at which the count of carbon-14 atoms and an old bone changes is always equal to some negative Constant times that count itself then over time that number will look approximately like e to that negative constant times T times whatever the initial count was So when you look at our heat equation and you know that for a sine wave the right-hand side is going to be negative alpha times the temperature function itself Hopefully it wouldn’t be too surprising to propose that the solution is to scale down by a factor of e to the negative alpha T Here go ahead and check the partial derivatives the proposed function of X and T is sine of X times e to the negative alpha T Taking the second partial derivative with respect to X that e to the negative alpha T term looks like a constant It doesn’t have any X in it So it just comes along for the ride as if it was any other Constant like 2 and the first derivative with respect to X is cosine of X times e to the negative alpha T likewise the second partial derivative with respect to X becomes negative sine of X times e to the negative alpha T and on the flip side If you look at the partial derivative with respect to T That sine of X term now looks like a constant since it doesn’t have a T in it So we get negative alpha times e to the negative alpha T times sine of X so indeed This function does make the partial differential equation true And oh, if it was only that simple this narrative flow could be so nice We would just beeline directly to the delicious Fourier series conclusion sadly nature is not so nice knocking us off onto an annoying But highly necessary detour Here’s the thing even if nature were to somehow produce a temperature distribution on this rod Which looks like this perfect sine wave the exponential decay is not actually how it would evolve Assuming that no heat flows in or out of the rod Here’s what that evolution would actually look like the points on the left are heated up a little at first and those on the right are cooled down by their neighbors to the interior in Fact let me give you an even simpler solution to the PDE which fails to describe actual heat flow a straight line That is the temperature function will be some nonzero constant times X and never change over time The second partial derivative with respect to X is indeed zero I mean there is no curvature and it’s partial derivative with respect to time is also zero since it never changes over time And yet if I throw this into the simulator, it does actually change over time slowly approaching a uniform temperature at the mean value What’s going on here? Is that the simulation I’m using treats the two boundary points of the rod Differently from how it treats all the others Which is a more accurate reflection of what would actually happen in nature if you’ll recall from the last video the intuition for where that second derivative with respect to X actually came from Was rooted in having each point tend towards the average value of its two neighbors on either side But at the boundary there is no neighbor to one side If we went back to thinking of the discrete version modeling only finitely many points on this rod you could have each boundary point simply tend towards its one neighbor at a rate proportional to their difference as We do this for higher and higher resolutions notice how pretty much immediately after the clock starts Our distribution looks flat at either of those two boundary points In fact in the limiting case as these finer and finer Discretized setups approach a continuous curve the slope of our curve at the boundary will be zero for all times after the start One way this is often described. Is that the slope at any given point is proportional to the rate of heat flow at that point? so if you want to model the restriction that no heat flows into or out of the rod the Slope at either end will be zero That’s somewhat hand wavy and incomplete I know so if you want the fuller details, I’ve left links and resources in the description Taking the example of a straight line whose slope at the boundary points is decidedly not Zero as soon as the clock starts those boundary values will shift in Phantasmal II such that the slope there suddenly becomes zero and remains that way through the remainder of the evolution in other words Finding a function satisfying the heat equation itself is not enough It must also satisfy the property that it’s flat at each of those end points for all x greater than zero phrased more precisely the partial derivative with respect to X of our temperature function at Zero T and at LT must be zero for all times T greater than zero where L is the length of the rod This is an example of a boundary condition and pretty much any time that you have to solve a partial differential equation in practice there Will also be some boundary condition hanging along for the ride which demands just as much attention as the PDE itself all of this may make it feel like we’ve gotten nowhere but the function which is a sine wave in space and an Exponential decay in time actually gets us quite close We just need to tweak it a little bit so that it’s flat at both end points First off notice that we could just as well use a cosine function instead of a sine. I mean, it’s the same wave It’s just shifted and phased by a quarter of the period which would make it flat at x equals zero as we want The second derivative of cosine of X is also negative 1 times itself So for all the same reasons as before the product cosine of x times e to the negative alpha T still satisfies the PDE To make sure that it also satisfies the boundary condition on that right side. We’re going to adjust the frequency of the wave however That will affect the second derivative since higher frequency waves curve more sharply and lower frequency one’s curve more gently Changing the frequency means introducing some constant. Say Omega Multiplied by the input of this function a higher value of Omega means the wave oscillates more quickly Since as you increase X the input to the cosine increases more rapidly Taking the derivative with respect to X we still get negative sign but the chain rule tells us to multiply that Omega on the outside and Similarly, the second derivative will still be negative cosine but now with Omega squared this means that the right-hand side of our equation has now picked up this Omega squared term, so To balance things out on the left-hand side. The exponential decay part should have an additional Omega squared term up top Unpacking what that actually means should feel intuitive for a temperature function filled with sharper curves It decays more quickly towards an equilibrium and evidently it Does this quadratically for instance doubling the frequency results in an exponential decay four times as fast? If the length of the rod is L Then the lowest frequency where that rightmost point of the distribution will be flat is when Omega is equal to PI divided by L See that way as x increases up to the value L The input of our cosine expression goes up to PI, which is half the period of a cosine wave Finding all the other frequencies which satisfy this boundary condition is sort of like finding harmonics You essentially go through all the whole number multiples of this base frequency PI over L In fact Even multiplying it by zero works since that gives us a constant function which is indeed a valid solution Boundary condition in all and with that we’re off the bumpy boundary condition detour and back onto the freeway Moving forward were equipped with an infinite family of functions satisfying both the PDE and the pesky boundary condition Things are definitely looking more intricate now but it all stems from the one basic observation that a function which looks like a sine curve in space and an exponential decay in time fits this equation relating second derivatives in space with first derivatives in time and Of course your formulas should start to look more intricate. You’re solving a genuinely hard problem This actually makes for a pretty good stopping point So let’s call it an end here and in the next video we’ll look at how to use this infinite family to construct a more general solution to any of you worried about dwelling too much on a single example in a series that’s meant to give a general overview of differential equations It’s worth emphasizing that many of the considerations which pop up here are frequent themes throughout the field First off the fact that we modeled the boundary with its own special rule while the main differential equation only Characterized the interior is a very regular theme and a pattern well worth getting used to especially in the context of PDEs Also take note of how what we’re doing is breaking down a general situation into simpler idealized cases this strategy comes up all the time and it’s actually quite common for these simpler cases to look like some mixture of sine curves and Exponential’s that’s not at all unique to the heat equation And as time goes on we’re going to get a deeper feel for why that’s true

100 thoughts on “Solving the heat equation | DE3

  1. Next up we finally get to Fourier series, which will be the beginning of a turn in the series towards understanding the surprising depth and importance of exponential functions for differential equations. Stay tuned!

  2. What's – 3² ?

    Me:
    9

    3Blue1brown:
    [5464364643_5466£4464-73743433,65965¢%868-868⅞+3²>55522+5578556866/8686×e=mc²2855556+555

    =9,0000000314

  3. I love the way you visualize the topic where you gain a good intuition for why doing all this math. Thanks Grant!

  4. Very nice work again!! Loved it. However, I think you glanced over the boundary conditions too quick. There are conditions where for instance a side if the rod is kept fixed at a certain temperature or that the heat flow is determined by temperature. That is probably to detailed for this series but I would have appreciated a quick mentioning of that.

  5. You should do a series on stochastic processes – things like Brownian motion will probably be really interesting to the viewers 🙂

  6. Grant, watch out for Flammable Maths! He has insulted other members of the math community with well known victims include blackpenredpen, Dr. Peyam and presh talwalker! Beware!

  7. I have a B.S. In physics…in 1972 ! I have finally learned enough math to justify my degree ! Seriously,math and physics instruction is so much better on YouTube than it was in the 60's that even the few bucks it cost back then,that I am thinking of asking for my money back. With compounded interest of course.
    Then again that B. S. has me worth several mil at retirement so maybe I'll call it even.

  8. I watched through your videos on linear algebra a while ago and thought to myself "man, if only I had seen these while taking my linear algebra course, it would have given me a lot more intuition for the subject a lot easier" and now this, in the middle of my course on integral transforms and differential equations 😀
    Thanks a lot, you're doing a great job.

  9. wish I had a better math teacher in highschool, whenever I see formulas I just memorize them and skip the math. This was very educational, thank you

  10. Hi Grant,

    I really love your videos. They helped me a lot understanding complex math. Thanks to your explaination and animations I don't just see math as pure formulas anymore – I see vectors and functions in a transforming spatial space and this is really helpful. When this series is done I'd love to see an "essence of tensor calculus" or something like that. You have so much fun in creating animations – I guess tensors would be a good choice even for you 😉

    Thank you very much for your work 🙂

  11. would you say this is a high school topic? i need to do a research paper, and i am thinking of using this as my topic (the paper can be a thorough explanation of a proof / proving an equation), and I 'm not sure in terms of complexity if this is a viable option for me. I'm in Grade 11 (17y/o), any advice / opinions?

  12. @3blue1brown Hey Grant! Just a little feedback here. I think I found a jewel when I found your channel, for real. The reason why is because I have a tendency to understand things better when they're explained to me through graphs and animation, especially when it comes to math. I'm more of an artsy person myself, but I really love science.
    You see, I'm studying chemistry in Argentina, and despite the language barrier, I do think that it's worth the time and effort to try and understand the material you're producing, mainly because it's given me a deeper insight on the topic which I'm struggling to comprehend the most, that is, calculus. I'm currently doing the course for the second time… And last year my failure on every exam that I had was a bad hit to my self-esteem. But now, I'm starting to grasp more the concepts of divergence, curl, and all those things that seemed something that I had to memorize. Because of your videos, I do realise that I do have some kind of ingrained passion for math and physics, even though I do suck at them for the most part in terms of explaining my thoughts and reflecting it on paper.
    So, to wrap it up, thank you a lot for your passion and effort! I'm aware that the probability that you'll read this is rather scarce, but hey, a tiny dot in a tiny fraction of probability is not negligible, since it forms part of a bigger thing, right?
    Anyway, I'll go and try to watch the videos again. Listening to your lessons gets easier to understand the more time I let my brain traduce what you're saying, hahaha.
    Have a good one!

  13. When you have exam from this in 2 weeks,
    there are no more 3Blue1Brown videos on the topic,
    and this is the 666th comment :
    This must be the work of the devil!
    😛

  14. A solution of T = Cx is a real world solution to the problem just corresponding to different boundary conditions than the adiabatic (lnsulated object) boundary conditions. But it's not important for the purpose of the video. This is a really interesting video because I never understood the connection of how Fourier transform could be used to solve heat equation. Thank you for making such a great videos!

  15. A zero derivative at the boundary is only because you selected Neumann boundary conditions. We could have used sine waves if you wanted Diricelet Boundary Conditions

  16. Can the temperature distribution of a klein bottle over time be modeled with PDE's without using boundary conditions? 😉

  17. Walking into the bar I became aware of an exponentially decaying pencil of complex sinusoids flexing and writhing in the centre of the room, shedding colours across the watching conics.
    It was The Heat Equation.

    Disregarded, a bored Lissajous pattern spun idly in the corner.

  18. ugh I HATE messy nature why can't rods be infinitely long and then they'd DEFINITELY be like a sine wave forever :V

  19. I like the fact that music from the Essence of Linear Algebra series plays during this particular video. Just to give a slight hint of how important the subject is for Differential Equations.

  20. It sounds like a bell. Those wave functions describe the string on a guitar, or a bell, or the Moon itself, which also resonates like a bell in an specific frequency.
    Thanks!
    No wonder Tesla said that in order to understand we need to think in terms of frequencies, the Spectrum.
    Math is proof of it.
    You are a great professor. You manage to explain complex into simple. Such a gift from Logos.

  21. Ohh la idea del seno modelando el eje x y el exponencial modelando el eje t me ayudó a entender porque se usa el método de separación de variables para resolver las edp

  22. Every math class into the future will be infinitely more useful with these videos, man. Like… before, math was the domain of those few who could easily translate it all into animations in their heads, and everyone else just had to struggle to try to do so, never really knowing if they had it right up top. Showing these animations to someone once is enough to make it all click so much more reliably. I sucked monumentally in my math courses in HS & college. I spent 10x the time for 10% of the understanding of the kids who just "got it" out of the box. Watching all of these videos almost a decade later, so much of it finally starts to make sense. I don't have to just cram-memorize formulas the night before an exam, only to dump them from my head immediately afterward, never actually able to get any real-world use out of them, lol.

  23. I get it that for t>0 the function have to satify the boundary condition, but nowhere in this video say it also have to at t=0. My question is for that condition to be satified, do the function at t=0 also have to satify it, or is it possible for us to generate a function such that the curves at boundaries is not 0 at t=0 and is 0 at all time t>0, and if not then why? Does anyone know?

  24. just finished a degree in ECSE and did not have an intuition for boundary conditions until just now, thank you for your content

  25. Thanks for the video!

    I'd like to ask how when there is a curvature i.e. change in space you say that there is a change in time as well?

  26. Hmm, so for an arbitrary function of temperature as a function of x, the arbitrary function of temperature in terms of x is approximated by the fourier series as an infinite summation of trigonometric curves. I wonder, would it have been easier if the temperature as a function of x be approximated by a taylor or maclaurin series? Would an infinite summation of monomials satisfy the boundary conditions?

  27. Hmm, so it seems that cosine functions (with zero derivative at boundary) makes sense for unbounded rods, where the rods are not subject to any temperature constraint. What would happen if we set the temperature of the rod at some constant temperature?

  28. This is the point of my life, where I realize how idle have I been 🙁 I have a PhD. in Maths and don't understand what he said about the flat thing in the boundaries (I could solve the equations as a student, yeah, but didn't understand the meaning); I will watch the video again… be dilligent and start again if necesary 🙁 Thanks a lot for the very illustrative videos

  29. I was trying to numerically solve the heat equation by substituting derivatives by its definitions and it looks like it is working, but how do I include the boundary condition stated in 9:33? How does the system even evolve at 9:04 if, by definition, the second derivative of the linear function is zero? Meaning that linear heat distribution will stay always the same as time passes by. Seems like the only way to solve the problem is to assume that boundary condition is also valid for t = 0 and then, after discretization of domain, we can assume that two points in the boundaries act as a single point (and have the same temperatures, so that the first derivative is zero) when heat is distributed, maintaining like that a slope of zero at boundaries as system evolves.

  30. SUGGESTIONS – 03:58 – In my humble opinion, You should have represented the "- alpha * sin(x)" representing the First Derivative of the Temperature Curve, then the Second Derivative, et cetera, and not// just the Arrows pointing down. You stick on the screen with the original sin(x) (or "c * sin(x)" curve while it is no more the subject and it is phase with sin(x) while the curve should be opposite phase which creates a bit of confusion.

    Also, I think it would have been Better that You represent, at least few seconds, the "cos(x)" curve, and in general, EACH AND EVERY OBJECT YOU WERE TALKING ABOUT, like also at 04:55, I think it would have been Better to trace the "-0.2*C*e^(-0.2*t)" curve, would be in dot line and very quickly.

    The problem, as I have seen is that even if a person think to Understand, one can lose some of the points and not really grasping all in its full depth and even leave with Little Misconceptions, of course not been Aware of but still having the Feeling having Greatly Understood all :/

    Nevertheless, it is still a A AWESOME WORK in term of Pedagogic Quality, thanks A Whole Lot For That 🙂

  31. What if you use an open subset of IR for our rod? Then every point has neighbours and thus no boundary-conditions are necessary. What am I missing?

  32. can any one suugest me on line lectures about real life applications of one dimensional,two dimensional and 3 dimensional heat and wave equations???i have to give presentation about this,,,,

  33. This video is amazing! But it leaves some things unmentioned. Adiabatic boundaries (dT/dx=0) are not the only boundary conditions in heat equations. Linear temperature profile T=c*x is perfctly good solution in some situations. It just states that the system is stationary and the boundaries are in constant temperatures Uniform temperature distribution is not the stationary solution of any other system than isolated systems. For the purpose of the video it doesn't matter tough.

  34. Anyone else wonder what is "c" in 4:00 and then what is c^2? I stopped the video and did a bit of algebra. I hope this helps someone else. We know the temperature at whatever point x starting from a time step 0 to be sin(x). If we use this recursively plus the fact that any future temperature value is the previous value plus (in this case minus because of the sign from second derivative) the rate of change times the time elapsed: T(x,0+dt) = T(x,0)-a*T(x,0+dt)*dt = sin(x)-a*sin(x)*dt=sin(x)*(1-a*dt). let's define c:=(1-a*dt). Thus for T(x,0+dt+dt)=T(x,2dt)=sin(x)-a*sin(x)*dt-a*(sin(x)-a*sin(x)*dt)*dt. Collect terms and you get sin(x)*(1-a*dt-a*dt-a^2*dt^2). The stuff in the last parenthesis is just c^2.

  35. Could the boundary condition be replaced by something related to energy conservation, ie. the total heat contained in the rod must remain constant?

  36. A mind-blowing clarity!
    I think it might be difficult to thank you enough for your contribution in spreading the love of (mathematical) beauty. I really agree beauty is the language of the universe.

  37. I like how the equation describing ME becomes more complicated, but less intricate, with time. Ultimately, I will just be a featureless infinite series of sines, indistinguishable from all the others.

  38. The stopping point at first did not bother me since I did not quite understand what happened after 6min into the video, but after rewatching it the cliff hanger tore my heart as I finally grasped the reason for the frequency change xD. Atleast the final video is already out !

Leave a Reply

Your email address will not be published. Required fields are marked *