1
00:00:00,860 --> 00:00:06,860
One day he had a question is a good start for us to solve it numerically.

2
00:00:06,860 --> 00:00:14,900
And later what we will do is we're going to solve it using, of course, neural networks.

3
00:00:15,230 --> 00:00:19,340
So what is what does what does it mean?

4
00:00:19,340 --> 00:00:20,540
That heat equation.

5
00:00:20,720 --> 00:00:29,570
So the heat equation is a partial differential equation that describes the or how the temperature of

6
00:00:29,570 --> 00:00:31,940
a physical system changes over time.

7
00:00:33,090 --> 00:00:36,000
And we can see how it's written.

8
00:00:36,000 --> 00:00:44,080
It's quite short, like d, u, d, t equals K, and the second derivative of u over d x.

9
00:00:44,130 --> 00:00:51,930
So the change of temperature or u, whatever the value we are talking about with time.

10
00:00:52,840 --> 00:00:59,500
Will depend on the second derivative of temperature with space.

11
00:01:01,390 --> 00:01:02,800
This is how we solve it.

12
00:01:02,800 --> 00:01:10,600
And the K is a diffusion factor or a constant that.

13
00:01:11,460 --> 00:01:12,960
Govern how?

14
00:01:14,040 --> 00:01:21,250
How how fast the temperature with time will change based on the spatial coordinate.

15
00:01:21,270 --> 00:01:27,660
So this one we call it spatial parameter or spatial part of the equation.

16
00:01:27,660 --> 00:01:32,490
As it changes the the temperature will change with space.

17
00:01:32,490 --> 00:01:40,170
With X, of course, this is 1D and we have X, but if it's 2D, you will have two dimensions.

18
00:01:40,170 --> 00:01:45,420
That is, you will have the change of temperature with x and temperature with Y.

19
00:01:45,810 --> 00:01:54,060
Now the other parameter or component of the equation is the temporal component of the equation, and

20
00:01:54,060 --> 00:01:58,380
temporal is just time based change of temperature with time.

21
00:01:59,900 --> 00:02:02,180
This is what we mean about temporal.

22
00:02:03,110 --> 00:02:04,250
A part of the equation.

23
00:02:04,790 --> 00:02:10,220
And the problem, what we are going to solve is we will have a rod.

24
00:02:10,250 --> 00:02:13,460
This rod will be frozen.

25
00:02:13,550 --> 00:02:16,070
Well, it's just zero degrees.

26
00:02:16,070 --> 00:02:17,030
It will have zero degrees.

27
00:02:17,120 --> 00:02:20,120
Was not, say, frozen because it will be made from aluminum.

28
00:02:20,540 --> 00:02:24,080
And then what we will have is two heat sources.

29
00:02:24,170 --> 00:02:28,190
Now, as the time goes, we will have these two heat sources.

30
00:02:28,190 --> 00:02:35,190
And as the time goes, this rod will change its temperature from zero to a higher value.

31
00:02:35,210 --> 00:02:42,500
So the temperature will start to rise in the tips and of course, also in the middle of the rod.

32
00:02:42,830 --> 00:02:49,340
Little by little, until, of course, it will reach to depending on the heat sources temperature.

33
00:02:49,490 --> 00:02:50,300
So.

34
00:02:51,500 --> 00:02:53,840
How we are going to solve it.

35
00:02:54,530 --> 00:03:03,740
First, in order to solve it, we we will need, of course, to to discretize or basically simplify

36
00:03:03,740 --> 00:03:05,810
how this equation is written.

37
00:03:06,320 --> 00:03:09,680
At the end, we are solving this equation numerically.

38
00:03:12,670 --> 00:03:22,390
And this is how we need to take into consideration the change of like change of temperature with space

39
00:03:22,390 --> 00:03:25,810
and change of temperature with time.

40
00:03:26,580 --> 00:03:28,590
And of course, we need to care about.

41
00:03:29,250 --> 00:03:35,820
So let's take or let's start from the easy part, which is the Kay.

42
00:03:36,420 --> 00:03:37,590
And the Kay.

43
00:03:37,590 --> 00:03:45,060
Here is the in regards to heat equation for an actual heat problem, which is we're trying to solve

44
00:03:45,090 --> 00:03:47,430
how the temperature will change with time.

45
00:03:48,090 --> 00:03:48,900
And space.

46
00:03:48,900 --> 00:03:53,460
Of course, we we will need a heat capacity.

47
00:03:53,460 --> 00:04:00,300
Property and heat capacity is a property of a substance that that quantifies the ability to store thermal

48
00:04:00,300 --> 00:04:01,080
energy.

49
00:04:01,080 --> 00:04:09,490
And we can see different values of like depending on the on the on the metal or on the material itself.

50
00:04:09,510 --> 00:04:13,170
So we can see here 0.45 for iron.

51
00:04:13,680 --> 00:04:22,710
We can see here aluminum, which we will use today like we will use for aluminum or in our numerical

52
00:04:22,710 --> 00:04:23,550
solution.

53
00:04:24,180 --> 00:04:27,390
And of course we have different quantities here.

54
00:04:27,390 --> 00:04:39,090
We have joule for gram and Celsius and here we have joule for mole Celsius.

55
00:04:39,090 --> 00:04:41,910
So we need to also be careful about this.

56
00:04:42,300 --> 00:04:43,230
So.

57
00:04:44,140 --> 00:04:45,670
Okay, now we're.

58
00:04:46,060 --> 00:04:47,010
We're ready.

59
00:04:47,020 --> 00:04:50,050
So what we should do, let's start solving it.

60
00:04:51,350 --> 00:05:00,500
So here we can see first the in order to care about or in order to solve the issue of a change of temperature

61
00:05:00,500 --> 00:05:03,350
with X and change of temperature with T.

62
00:05:03,530 --> 00:05:07,610
What we need to solve is we need to do a numerical derivation.

63
00:05:07,610 --> 00:05:11,180
A numerical derivation is basically we.

64
00:05:11,960 --> 00:05:14,160
Or the first derivative we need to.

65
00:05:15,810 --> 00:05:27,420
Calculate that it change the location where where the curve will will change basically the slope at

66
00:05:27,420 --> 00:05:28,290
that location.

67
00:05:28,290 --> 00:05:31,860
And in order to do that, of course, we have many formulas.

68
00:05:32,040 --> 00:05:39,630
For example, a central derivative method, we will use this one and H is the difference between this

69
00:05:39,630 --> 00:05:45,030
point and this point, which we will calculate around it, which is in this case, for example, we

70
00:05:45,030 --> 00:05:47,130
try to derivate this point.

71
00:05:47,160 --> 00:05:57,570
We have to calculate the function value at X plus h and minus the x minus H, this is X.

72
00:05:57,570 --> 00:06:00,210
So here is the lower value, here is the higher value.

73
00:06:00,210 --> 00:06:06,720
So we need to minus both values and then divide by the distance.

74
00:06:06,720 --> 00:06:14,220
This is how we will calculate or this is the general idea of a numerical derivation is very simple and

75
00:06:14,250 --> 00:06:19,090
of course we don't really care about the to describe the actual curve equation.

76
00:06:19,090 --> 00:06:20,170
So for example.

77
00:06:20,960 --> 00:06:24,520
If you have a curve that is X squared.

78
00:06:24,530 --> 00:06:27,020
So we will have it looks like this.

79
00:06:27,020 --> 00:06:33,020
And when we do our first derivative, we will have two X which will look like this.

80
00:06:33,020 --> 00:06:40,550
And if we have the second derivative, so deriving the already derived curve, we will have the slope

81
00:06:40,550 --> 00:06:44,090
of the whole curve will be, of course, for every point it will be two.

82
00:06:44,090 --> 00:06:48,530
And if we continue and two the third derivative, we will reach to zero.

83
00:06:48,530 --> 00:06:53,930
So this is how this like numerical derivation works.

84
00:06:53,930 --> 00:07:02,990
And actually there is many ways or sorry, there are many ways to calculate the numerical derivations

85
00:07:02,990 --> 00:07:07,850
in things we call usually in numerical computation, we call it schemes.

86
00:07:07,850 --> 00:07:14,540
So we have, for example, first order derivative schemes, we have second order derivative schemes

87
00:07:14,540 --> 00:07:19,100
and it is it will provide us with.

88
00:07:20,030 --> 00:07:26,810
A simple formula that we will use actually the numerical value of every point to calculate the change

89
00:07:26,810 --> 00:07:27,620
at this point.

90
00:07:27,620 --> 00:07:34,550
So in here we have a forward difference scheme and there is of course the backward difference scheme.

91
00:07:34,550 --> 00:07:42,680
So it will take, it will it depends on the, the point of interest and you consider that point in front

92
00:07:42,680 --> 00:07:47,570
of it which is called the forward difference and backward difference is the point behind it.

93
00:07:47,690 --> 00:07:51,110
And central difference is we will consider both points.

94
00:07:51,780 --> 00:07:58,080
And of course, for second derivatives, usually you need or not, usually you need more points.

95
00:07:58,290 --> 00:08:03,900
In this case, you will have, for example, three point central difference for second derivative.

96
00:08:03,900 --> 00:08:11,730
And we can see here, of course, this is we're not talking about deriving a curve and then derive it

97
00:08:11,730 --> 00:08:12,330
again.

98
00:08:12,330 --> 00:08:16,350
So it's not applying first derivative two times, which will work.

99
00:08:16,350 --> 00:08:23,580
But in what we do is we, we, we, we don't, we're not really interested in the first derivative curve

100
00:08:23,580 --> 00:08:24,900
and then we derive it again.

101
00:08:24,990 --> 00:08:32,940
But we will do is we will take the equation and we discretize it means we make it written in a, in

102
00:08:32,940 --> 00:08:41,520
a simple um, uh, in a simple values and or numerically possible to calculate values.

103
00:08:41,520 --> 00:08:50,730
That is, we will take this curve and then what we will describe it in, in, in terms of the function

104
00:08:50,730 --> 00:08:53,260
values of every point.

105
00:08:53,260 --> 00:08:55,540
So this is what we will do here.

106
00:08:55,960 --> 00:09:02,620
And by this we will be able to calculate the second derivative directly, the value of the second derivative

107
00:09:02,620 --> 00:09:04,780
from the function value itself.

108
00:09:04,780 --> 00:09:10,360
And I'm not talking about the first derivative, so it is like applying it first derivative, and then

109
00:09:10,360 --> 00:09:14,530
again another third, another derivatives to get the second derivative.

110
00:09:14,530 --> 00:09:20,980
But rather than going for this two step thing, we can go from one step which is using these three points.

111
00:09:21,010 --> 00:09:26,290
Or in this case also this scheme, what we call the scheme is the way we calculate this derivative.

112
00:09:26,320 --> 00:09:30,010
We will need to calculate this point.

113
00:09:30,010 --> 00:09:43,030
So, so basically this is how we can actually, uh, well, uh, translate a heat equation or any equation

114
00:09:43,030 --> 00:09:53,020
from a formula that looks like this to an actual values that can be calculated at every point.

115
00:09:55,160 --> 00:09:55,790
So.

116
00:09:56,650 --> 00:10:00,670
Now we understand how we can get care, which is a constant.

117
00:10:00,670 --> 00:10:06,910
So depending on the material, we simply get it and we know how to change the first derivative into,

118
00:10:06,940 --> 00:10:08,380
for example, a scheme.

119
00:10:08,470 --> 00:10:16,330
Of course we can pick any scheme we want, although a side note is of course to choose.

120
00:10:17,200 --> 00:10:22,990
The more accurate the derivative, the more accurate the scheme, and this is the inherent numerical

121
00:10:22,990 --> 00:10:24,190
property of the scheme.

122
00:10:24,190 --> 00:10:31,210
So you have the some schemes will have a first order accurate what we call and the second order accurate.

123
00:10:31,210 --> 00:10:35,980
And it is just the how numerically accurate the scheme itself.

124
00:10:35,980 --> 00:10:44,020
So in my experience most of the problems we don't really need second order or most of the time first

125
00:10:44,020 --> 00:10:45,670
order schemes will work.

126
00:10:45,670 --> 00:10:54,160
But the idea is some schemes will provide us inherently numerically feature that it will actually be

127
00:10:54,160 --> 00:10:54,880
more accurate.

128
00:10:54,880 --> 00:10:58,640
So it matters the choose the choosing of scheme.

129
00:10:58,640 --> 00:11:04,880
But however we will choose a very simple schemes in this problem to solve this problem.

130
00:11:05,240 --> 00:11:15,290
So for for our problem, what we will choose is the forward looking derivative for for space and time

131
00:11:15,290 --> 00:11:16,220
difference.

132
00:11:16,700 --> 00:11:19,250
And this this scheme.

133
00:11:19,250 --> 00:11:25,130
And for the second derivative we will choose the this three point scheme.

134
00:11:25,130 --> 00:11:33,740
And when we apply this to these two schemes on the equation, what we have it, we will end up with

135
00:11:33,740 --> 00:11:35,540
something that looks like this.

136
00:11:35,540 --> 00:11:47,690
So you at the time we were calculating plus the x minus 2UTX plus u x minus d x.

137
00:11:47,690 --> 00:11:51,620
So this is the three points we're calculating, using three points.

138
00:11:52,010 --> 00:11:55,940
Basically this scheme and the X square is this one.

139
00:11:55,970 --> 00:12:04,240
Of course, this is dy dx means the difference x the difference of x because this is there is no D here,

140
00:12:04,240 --> 00:12:05,650
so it's not like derivative.

141
00:12:05,650 --> 00:12:07,270
So just be careful.

142
00:12:07,270 --> 00:12:09,940
It's a little bit sometimes get confusing.

143
00:12:10,150 --> 00:12:15,820
So here for the first derivative is quite also simple.

144
00:12:15,820 --> 00:12:22,000
You take u t plus x minus u t x over t dt.

145
00:12:22,360 --> 00:12:33,130
This is how we discretize the heat equation from its original form, which is this one into a simple

146
00:12:33,130 --> 00:12:35,770
way, which is our simple form.

147
00:12:35,770 --> 00:12:37,540
Which is this one.

148
00:12:38,060 --> 00:12:44,600
So the this is, of course, the the theoretical way to describe it.

149
00:12:44,600 --> 00:12:54,090
And what we will do is we are going to actually apply it in a python code in in the next lessons.
