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
Ray Dalio & Bill Belichick on Going from Nothing to Something Big: Part 2
And then communicating well, because when I went from the 67 who knew me and knew where I was coming from, and then I had to go to another level, how was I going to keep that same communication, that same idea of meritocracy? That’s why I started to write…
Rulings on majority and minority rights by the Supreme Court | Khan Academy
We’ve already talked about the 14th Amendment in previous videos, but just as a reminder, Section 1 of the 14th Amendment says, “All persons born or naturalized in the United States, and subject to the jurisdiction thereof, are citizens of the United Stat…
Warren Buffett: Value Investing vs. Growth Investing
So if you tell me that you own a business that’s going to grow to the sky, and isn’t that wonderful? I don’t know whether it’s wonderful or not until I know what the economics are of that growth. How much you have to put in today, and how much you will re…
Daniel Kahneman: Adversarial Collaboration
There are different forms of adversarial collaboration. So one form is that you have people who disagree on some theoretical issue trying to conduct experiments that will resolve their differences or reduce their differences. And that is the first step i…
Religious Tolerance Shouldn't Mean Accepting Lower Moral Standards | Big Think
There’s a section within the left. I refer to them as the regressive left, and I want to clarify I don’t mean all of those on the left. I mean a section that has come to the view for the sake of political correctness, for the sake of tolerating what they …
What To Focus On To Make $1 Million Dollars in 90 days | Grant Cardone
If you had 90 days, 90 days to make a million dollars, start with nothing. You started with nothing, and you can’t use your name, Kevin O’Leary. What would you focus on? Wow, well, that’s a tough one, Grant. Like, that’s a real tough one. Does it make se…