1
00:00:00,240 --> 00:00:06,450
So a mathematical concept that is very important in physics, especially, for example, in electrodynamics,

2
00:00:06,930 --> 00:00:08,940
is multi-dimensional derivatives.

3
00:00:09,420 --> 00:00:16,140
So this includes the so-called Nublar operator, which contains the partial derivatives with respect

4
00:00:16,140 --> 00:00:18,060
to the individual coordinates.

5
00:00:19,200 --> 00:00:26,430
So with the help of this novel operator, we can calculate the gradient and the curl and the divergence,

6
00:00:27,180 --> 00:00:31,590
and we can calculate those things for multidimensional functions.

7
00:00:32,250 --> 00:00:38,310
So this means, for example, that a function is itself still single valued.

8
00:00:38,310 --> 00:00:40,830
So it's not a vector, but just a scalar function.

9
00:00:41,250 --> 00:00:43,600
But it depends on multiple arguments.

10
00:00:43,620 --> 00:00:45,180
For example, X, Y and Z.

11
00:00:46,230 --> 00:00:52,520
Or it could also mean that the function has multiple dimensions itself, so it has an X, Y and Z component,

12
00:00:52,980 --> 00:00:56,160
and all of them depend on X, Y and Z themselves.

13
00:00:57,480 --> 00:01:04,170
So now we can use to novel operator to basically calculate what happens when we apply this to a scalar

14
00:01:04,170 --> 00:01:04,690
function.

15
00:01:04,709 --> 00:01:10,260
You see this the gradient where we apply the partial derivatives now to the function for each of these

16
00:01:10,260 --> 00:01:10,860
components.

17
00:01:11,460 --> 00:01:16,990
For the curl, we calculate the cross product and for the divergence we calculate the dot product of

18
00:01:16,990 --> 00:01:19,050
the novel operator with the function.

19
00:01:19,800 --> 00:01:28,680
So for example, here we see the typical cross product shape y z minus z y z x minus XY and x y minus

20
00:01:28,680 --> 00:01:29,280
y x.

21
00:01:29,880 --> 00:01:35,700
So you just have to consider these partial derivatives, even though they are just operators, just

22
00:01:35,700 --> 00:01:38,640
like you would consider a number of variables.

23
00:01:38,670 --> 00:01:40,800
And then you just let them act on the function.

24
00:01:42,120 --> 00:01:47,460
So we we don't want to really deal so much here with the mathematics, but we will just implemented

25
00:01:47,790 --> 00:01:49,920
and we will consider a few examples.

26
00:01:50,790 --> 00:01:54,870
So as the functions that we are using here, we have these examples.

27
00:01:55,200 --> 00:02:00,840
The first one is an exponential function, basically a Gaussian function, which is a bit modulated

28
00:02:00,840 --> 00:02:01,830
in the white direction.

29
00:02:02,280 --> 00:02:04,380
And I have programmed this already.

30
00:02:04,380 --> 00:02:08,880
I have written down F of R R as a vector that has X, Y and Z.

31
00:02:09,030 --> 00:02:15,900
So three components, it is basically an exponential function and then X component square and here y

32
00:02:15,900 --> 00:02:18,060
component for the total power of for.

33
00:02:19,280 --> 00:02:27,740
And then I have used the plot prediction command to plot this, and you see it looks a bit like a mountain.

34
00:02:28,240 --> 00:02:31,700
This is really the physical example that we will consider here.

35
00:02:32,060 --> 00:02:34,440
Let's consider a mountain that looks like this.

36
00:02:34,460 --> 00:02:37,880
We have the X and Y coordinate and the values to Z coordinate.

37
00:02:38,390 --> 00:02:41,570
And then the question is what is the gradient at?

38
00:02:41,570 --> 00:02:46,700
The gradient always tells us the direction of the steepest slope of the mountain.

39
00:02:46,940 --> 00:02:52,130
So when we are at some point and we calculate the gradient, it will always point in to the direction

40
00:02:52,400 --> 00:02:54,500
where the slope is the steepest.

41
00:02:55,910 --> 00:03:04,040
And so the other example of a vector valued function is Geof River G is a vector and it is Vector R,

42
00:03:04,160 --> 00:03:09,900
so basically a vector with X, Y and Z as two components divided by the absolute value of art.

43
00:03:09,950 --> 00:03:13,670
So square root of x squared plus y squared plus c square.

44
00:03:14,510 --> 00:03:20,120
This looks very simple, but actually to calculate the divergence and the curl of this is not so easy

45
00:03:20,120 --> 00:03:21,380
to do analytically.

46
00:03:21,920 --> 00:03:26,510
But here we will do that just numerically, and we will implement these functions here.

47
00:03:27,050 --> 00:03:31,510
And in terms of physics, this expression is very relevant, for example, in electoral dynamics.

48
00:03:31,910 --> 00:03:37,490
And there we even have to calculate the curl and the divergence of this term to determine, for example,

49
00:03:37,790 --> 00:03:41,270
the electric field of some charged distribution or vice versa.

50
00:03:42,530 --> 00:03:45,520
So now let me show you what this function looks like.

51
00:03:45,530 --> 00:03:47,030
Vector are divided by arm.

52
00:03:47,480 --> 00:03:51,390
So you see if you're interested, how to do this and please just post a video.

53
00:03:51,410 --> 00:03:55,460
I have used here a quiver plot, but actually it's not so important right now.

54
00:03:55,460 --> 00:04:00,590
I will use this later on to calls several times, and there I will explain to you in detail how this

55
00:04:00,590 --> 00:04:00,980
works.

56
00:04:01,370 --> 00:04:07,520
Basically, you just provide X, Y and Z coordinates by using a mesh grid command and then you provide

57
00:04:07,520 --> 00:04:09,590
the values of the function.

58
00:04:09,770 --> 00:04:16,790
Also, X, Y and Z components, another will show you the direction of G at every point in space.

59
00:04:17,060 --> 00:04:22,400
And you see, since it is vector are divided by R, it always points along the radial director.

60
00:04:23,880 --> 00:04:24,330
All right.

61
00:04:24,810 --> 00:04:32,790
So the next thing that we will implement is we will implement the gradient, so the gradient of.

62
00:04:33,240 --> 00:04:39,900
So this means, as I told you, the direction of the steepest slope of this mountain here.

63
00:04:40,920 --> 00:04:42,390
So let's go ahead and do this.

64
00:04:43,560 --> 00:04:46,980
So the gradient is defined.

65
00:04:49,590 --> 00:04:55,980
And it is the fight for function, if it is to find for position arc, which is a vector of three components

66
00:04:56,520 --> 00:05:02,010
and it is defined with a step size because it is still a derivative, after all.

67
00:05:02,010 --> 00:05:03,480
So we need the step size.

68
00:05:04,260 --> 00:05:07,830
And here, just for simplicity, I will use the central difference as method.

69
00:05:08,190 --> 00:05:11,850
You could also apply any other method that we have encountered previously.

70
00:05:12,210 --> 00:05:15,240
It will just increase or decrease the accuracy of the method.

71
00:05:15,240 --> 00:05:17,280
But here central differences will do.

72
00:05:17,280 --> 00:05:19,770
It's just just an exercise to show you how it works.

73
00:05:20,970 --> 00:05:27,060
So just to make our lives a bit more easy, we can define something like this where the individual components

74
00:05:27,060 --> 00:05:34,040
of arm are labeled X, Y and Z, and then we can write partial x has given as.

75
00:05:34,620 --> 00:05:38,940
But now we must use central differences with respect to the variable of X.

76
00:05:39,900 --> 00:05:42,300
So this would be f off.

77
00:05:43,200 --> 00:05:47,490
Now we must apply the array to vector array.

78
00:05:50,470 --> 00:05:51,760
X, Y and Z.

79
00:05:52,510 --> 00:05:59,920
And as I told you, central differences, we will change X by the value of H, and then we will just

80
00:06:00,580 --> 00:06:07,790
subtract the value of the function where H is reduced from X and we divide by two.

81
00:06:08,170 --> 00:06:13,570
H, this is really exactly as we did before, but we need to be careful now that we used to correct

82
00:06:13,570 --> 00:06:14,340
argument here.

83
00:06:15,460 --> 00:06:21,280
Then when you remember how the gradient was defined, we do know the same thing for the other components.

84
00:06:21,280 --> 00:06:26,710
But we we calculate the derivative respect to Y and with respect to see.

85
00:06:28,150 --> 00:06:37,780
So we will just write basically the same thing again, partial y and there the age will be added to

86
00:06:37,780 --> 00:06:44,500
Y and subtracted from Y and for Z, the same thing with the C component.

87
00:06:46,530 --> 00:06:52,120
And then the last thing is we must, of course, return something, and this will be a because now it's

88
00:06:52,120 --> 00:06:58,080
the vector gradient is always a vector because it shows you an orientation of the steep slope, so it

89
00:06:58,080 --> 00:06:58,890
must be a vector.

90
00:06:59,310 --> 00:07:07,980
And those will be partial acts, comma, partial light and partial z.

91
00:07:09,750 --> 00:07:13,410
And then we can just give us some random reference point.

92
00:07:13,410 --> 00:07:19,200
For example, are is given as an P dot array

93
00:07:22,020 --> 00:07:25,290
0.5 minus one point two.

94
00:07:25,740 --> 00:07:30,730
And you see, our function doesn't even depend on C, so it can take it and evaluate just to zero.

95
00:07:30,750 --> 00:07:32,190
But I could also take minus eight.

96
00:07:32,370 --> 00:07:32,940
Doesn't matter.

97
00:07:33,900 --> 00:07:39,000
And then we must specify the step size, which of course, gives us a better result the smaller it is.

98
00:07:39,600 --> 00:07:50,310
So I take it quite small and then I call gradient of f petition are steps each, and the value is now

99
00:07:50,310 --> 00:07:51,090
something like this.

100
00:07:51,090 --> 00:07:56,880
So you see we are to position 0.5 and minus one point two.

101
00:07:57,300 --> 00:08:06,300
And the direction of the gradient is a bit in the negative x direction and along the positive y direction.

102
00:08:07,080 --> 00:08:11,970
So let's look at the figure we go to 0.5 and minus one point two.

103
00:08:13,350 --> 00:08:19,170
So, for example, 0.5 minus one point two is something like here.

104
00:08:19,560 --> 00:08:23,100
So the gradient would point a bit to the left.

105
00:08:23,550 --> 00:08:27,180
Negative x direction and strongly along.

106
00:08:27,180 --> 00:08:30,570
Y yeah, positive y direction.

107
00:08:30,840 --> 00:08:32,039
Let's see if this is correct.

108
00:08:32,039 --> 00:08:38,070
Yes, this is exactly what we have calculated, and even we can check this with the analytical solution.

109
00:08:38,549 --> 00:08:43,860
Because if you know a bit about the mathematics and the derivatives, it's pretty easy to calculate

110
00:08:43,860 --> 00:08:44,580
the gradient.

111
00:08:44,820 --> 00:08:50,940
You just have the outer derivative with it, which is the exponential function of minus x squared minus

112
00:08:50,940 --> 00:08:52,530
Y to the power of four.

113
00:08:52,920 --> 00:09:00,390
And then you multiply the derivative, which for the X component will be minus two x and for the Y component

114
00:09:00,390 --> 00:09:03,120
will be minus four times Y two to pull off three.

115
00:09:04,050 --> 00:09:11,700
So this is exactly what I've written down here and now I can just copy what I have prepared.

116
00:09:12,390 --> 00:09:18,120
This is just an array which basically includes these exact components that I have just written down,

117
00:09:18,930 --> 00:09:21,930
and the value is exactly what we have here.

118
00:09:22,800 --> 00:09:28,770
And so you see within it with the step size of zero point zero zero zero one, we get really exactly

119
00:09:28,770 --> 00:09:31,570
the same result as we should get from analytics.

120
00:09:31,570 --> 00:09:38,280
So in this case, especially the central differences method was totally sufficient and we get a nice

121
00:09:38,280 --> 00:09:39,480
result for the gradient.

