So now we will consider a curl into divergence for this example, function vector are divided by Ah,
and I've programmed this already here and we can have a look at the figure once again.
So you see, it's along the radial direction, always.
And now let's go ahead and calculate the divergence and the curl.
So the definition of the divergence of G at the position R and H, so this will be the step size again.
And these are three arguments that we always must provide.
And as previously, I will just label these components of art as X, Y and Z, and then I can just go
ahead and calculate the G X D X. So this will be the partial derivative of the X component of G.
With respect to X.
And so this will once again be a central difference as methods.
This will be G
four and P Dot Parade.
So now we must provide the vector of the position, which will be initially X, Y and Z.
And since we want to have here the X component of G, we must now use something like this.
So we accessed the first component and now we do central differences with respect to X.
So we write plus h for the X component, and then we copy the same thing minus and minus h.
And we divide it by two times h.
And now we do the other two terms, which will be g y DUI and GC DC.
So now we must just be careful to shift here to h for the central differences.
But not only that, we must also change here the index from here to the Y component for this one and
two, the Z component and here as well.
So now we have the individual terms.
Let me show you again these ones here g x the X G Y de Y GC DC.
And so for the divergence, we have to add these three up.
So I return
on d g x d x plus DG y d y plus DG, C D C, and then we can check what is the value for our specific
position.
Then we have to find to be 0.5, minus 1.2 and minus eight.
Just some random numbers.
This would be that.
And when we compare it with the analytical solution, which is actually pretty difficult to get when
you have never done it before, the analytical solution gives us
this number.
So once again, we have a pretty high accuracy.
You see, at some points after the dots, there is some difference, but we can of course, improve
this by just increasing or sorry, by decreasing the step size and then we increase the accuracy.
But I think this is really sufficient.
And yeah, it works.
We have implemented the divergence.
And now for the curl, the curl is actually pretty similar to the divergence because we must just calculate
the other partial derivatives.
So for example, GC, D, Y, G, Y, DC and so on and so on.
And then we must construct three components and calculate these differences here.
So this is really nothing special.
It's very similar actually to this one, but it's a bit more work to write everything down.
So for this reason, I will now just stop the video and write it down.
And then if you want, you can write it in your own notebook as well.
So see you in a second.
So you see pretty similar to the divergence I have now created to curl.
Once again, I've labeled X, Y and Z, and I have created the six remaining partial derivatives.
So for example, G X DUI, G X DC and so on and so on.
So all these mixed terms.
And for example, to calculate the derivative of G X with respect to why we must take the X components.
So here the component index will be zero.
And since we derive with respect to why we must add the H to Y and subtract the H from Y, and then
you do the same thing for the other.
Five components, and then you must have a look at how the gradient.
I'm sorry, sorry, how the curl is constructed.
This is just by taking these three components here and you always pairwise subtract them.
And for the X component, you calculate GC.
So DGC the Y minus the GeoEye DC.
And this is why I let the GC the y minus DG y these c, so exactly what I just said.
And then, of course, for the other components, you do the same thing and you see already the analytical
solution tells us that this is zero for every point in space.
So let's see if this really is true.
G ah, and h, yes, indeed.
So you see, there's a some value times 10 to the power of minus 12, 12, 13, so this is essentially
zero.
So I hope you're not disappointed that this example didn't give us such a cool result for the curl.
But actually in the next section where we will discuss integration, I will in the end consider a really
a physical example where we will calculate the magnetic fields of a charged wire.
And there we will first calculate a so-called vector potential using the integral method that we will
establish in the next section.
And thereafter, we must calculate the magnetic field from this vector potential and this we do by calculating
the curl.
So in the next section, there will be a nice exercise for practicing how to calculate the curl where
the result will something will be something different to zero.
So are you still excited and I see you in the next lecture?