yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

Laplacian computation example


4m read
·Nov 11, 2024

In the last video, I started introducing the intuition for the Laplacian operator in the context of the function with this graph and with the gradient field pictured below it, and here I'd like to go through the computation involved in that.

So, the function that I had there was defined as a two-variable function, and it's defined as ( f(x, y) = 3 + \cos\left(\frac{x}{2}\right) \cdot \sin\left(\frac{y}{2}\right) ). Then, the Laplacian, which we define with this right-side-up triangle, is an operator of ( f ), and it's defined to be the divergence – so kind of this ( \nabla \cdot ) times the gradient, which is just ( \nabla f ).

So, two different things going on: it's kind of like a second derivative. The first thing we need to do is take the gradient of ( f ). The way we do that is, we kind of imagine expanding this upside-down triangle as a vector full of partial differential operators ( \frac{\partial}{\partial x} ) and ( \frac{\partial}{\partial y} ).

With the gradient, you just kind of imagine multiplying that by the function, so if you imagine multiplying that by the function, what it looks like is just a vector full of partial derivatives. You're taking the partial of ( f ) with respect to ( x ) and the partial of ( f ) with respect to ( y ). Those are the two different components of this vector-valued function that is the gradient.

In our specific example, when we take the partial derivative of ( f ) with respect to ( x ), what we get is: so we look over here, ( 3 ) just looks like a constant, so nothing happens. The cosine of ( \frac{x}{2} ) has the derivative of that with respect to ( x ); we kind of take out that ( \frac{1}{2} ), so it's ( \frac{1}{2} ), and the derivative of cosine is negative sine, so that's ( -\sin\left(\frac{x}{2}\right) ).

As for ( \sin\left(\frac{y}{2}\right) ), well, ( y ) just looks like a constant, so ( \sin\left(\frac{y}{2}\right) ) is just some other constant, so in our derivative, we just keep that constant in there that ( \sin\left(\frac{y}{2}\right) ).

Then for the second component, the partial derivative of ( f ) with respect to ( y ): ( 3 ) still looks like a constant because it is a constant. Now ( \cos\left(\frac{x}{2}\right) ) looks like a constant as far as ( y ) is concerned since ( x ) is a constant. So, cosine of ( \frac{x}{2} ) is a constant.

But then, the ( \sin\left(\frac{y}{2}\right) ) has a derivative of cosine, and we also take out that ( \frac{1}{2} ); so you take out that ( \frac{1}{2} ) when you take the derivative of the inside, and then the derivative of the outside is cosine of whatever was in there, so in this case ( \frac{y}{2} ).

And we're multiplying it by that original constant ( \cos\left(\frac{x}{2}\right) ). So, still, we have our ( \cos\left(\frac{x}{2}\right) ) since it was a constant times a certain variable thing ( \frac{x}{2} ).

So that's the gradient. The next step here is to take the divergence of that. With that divergence, we're going to imagine taking that differential operator and dot-producting with this vector.

So, if I scroll down to give some room here, we're going to take that vector that’s kind of the same: the ( \frac{\partial}{\partial x} ) and I say "vector," but it is a thing ( \frac{\partial}{\partial y} ), and now we're going to take the dot product with this entire gradient.

I'll go ahead and just copy it over here. Let’s see, so we'll need a little bit more room to evaluate this. So here, when you imagine taking the dot product, you kind of multiply these top components together.

So, we're taking the partial derivative with respect to ( x ) of this whole guy, and when you do that, what you get is: you still have that ( \frac{1}{2} ), and then the derivative of ( -\sin\left(\frac{x}{2}\right) ). So that ( \frac{1}{2} ) gets pulled out when you're kind of taking the derivative of the inside, and the derivative of negative sine is negative cosine.

So, it's ( -\cos\left(\frac{x}{2}\right) ) multiplied by this constant ( \sin\left(\frac{y}{2}\right) ).

Then we add that because it’s kind of like a dot product; you add that to what it looks like when you multiply these next two components. So we're going to add. You have that ( \frac{1}{2} ), and then ( \cos\left(\frac{y}{2}\right) ).

When we differentiate that, you also pull out the ( \frac{1}{2} ), so again you have that pulled out ( \frac{1}{2} ). The derivative of cosine is negative sine, so now we're taking negative sine of that stuff on the inside ( \frac{y}{2} ), and we continue multiplying by the constant.

As far as ( y ) is concerned, ( \cos\left(\frac{x}{2}\right) ) is a constant, so we multiply it by that ( \cos\left(\frac{x}{2}\right) ).

So that is the divergence of that gradient field. The divergence of the gradient of our original function gives us the Laplacian. In fact, we could simplify this further because both of these terms kind of look identical.

But the main point of this video is kind of how you go through that process where you imagine taking the gradient of your function, and then the divergence of that, and that's what the Laplacian is.

See you in the next video.

More Articles

View All
A Losing Battle | Live Free or Die
[Music] [Music] Well, the water’s dropped quite a bit. It just means that I don’t have any water to drink right now, so I’ll have to try to dig it deeper. Starting to get a little bit of water pulling up, which I would expect. But I’m kind of at the limi…
The Golden Ratio: Nature's Favorite Number
Humanity has always been in search of patterns. They make us feel comfortable. They give us meaning. Whether they be in the deepest, most conceptually difficult topics like string theory and quantum mechanics, or even in simple things like the behaviour o…
This Virus Shouldn't Exist (But it Does)
Hidden in the microverse all around you, there’s a merciless war being fought by the true rulers of this planet: microorganisms. Amoeba, protists, bacteria, archaea, and fungi compete for resources and space. And then there are the strange horrors that ar…
Metric system unit conversion examples
Tomas dropped off two packages to be shipped. One package weighed 1.38 kg and the other package weighed 720 g. So the first one they given in kilograms and the second one they give us in grams. What was the combined weight of both packages in grams? So w…
Renting vs Buying a Home: What NOBODY Is Telling You
What’s up you guys? It’s Graham here. So the other day, one of my posts on LinkedIn went somewhat viral on Reddit where I said if you were to buy a million-dollar home, you would have to put $200,000 down, take on a mortgage of $5,600 a month, pay another…
Win Without Trying (A Taoist simile about losing your flow)
Competitions can be nerve-wracking. The more we live up to the day on which we are supposed to shine, the more anxiety builds up. What if I perform badly? What if something goes wrong? An Olympic swimmer trains thousands of hours just to get that medal. A…