One day he had a question is a good start for us to solve it numerically.
And later what we will do is we're going to solve it using, of course, neural networks.
So what is what does what does it mean?
That heat equation.
So the heat equation is a partial differential equation that describes the or how the temperature of
a physical system changes over time.
And we can see how it's written.
It's quite short, like d, u, d, t equals K, and the second derivative of u over d x.
So the change of temperature or u, whatever the value we are talking about with time.
Will depend on the second derivative of temperature with space.
This is how we solve it.
And the K is a diffusion factor or a constant that.
Govern how?
How how fast the temperature with time will change based on the spatial coordinate.
So this one we call it spatial parameter or spatial part of the equation.
As it changes the the temperature will change with space.
With X, of course, this is 1D and we have X, but if it's 2D, you will have two dimensions.
That is, you will have the change of temperature with x and temperature with Y.
Now the other parameter or component of the equation is the temporal component of the equation, and
temporal is just time based change of temperature with time.
This is what we mean about temporal.
A part of the equation.
And the problem, what we are going to solve is we will have a rod.
This rod will be frozen.
Well, it's just zero degrees.
It will have zero degrees.
Was not, say, frozen because it will be made from aluminum.
And then what we will have is two heat sources.
Now, as the time goes, we will have these two heat sources.
And as the time goes, this rod will change its temperature from zero to a higher value.
So the temperature will start to rise in the tips and of course, also in the middle of the rod.
Little by little, until, of course, it will reach to depending on the heat sources temperature.
So.
How we are going to solve it.
First, in order to solve it, we we will need, of course, to to discretize or basically simplify
how this equation is written.
At the end, we are solving this equation numerically.
And this is how we need to take into consideration the change of like change of temperature with space
and change of temperature with time.
And of course, we need to care about.
So let's take or let's start from the easy part, which is the Kay.
And the Kay.
Here is the in regards to heat equation for an actual heat problem, which is we're trying to solve
how the temperature will change with time.
And space.
Of course, we we will need a heat capacity.
Property and heat capacity is a property of a substance that that quantifies the ability to store thermal
energy.
And we can see different values of like depending on the on the on the metal or on the material itself.
So we can see here 0.45 for iron.
We can see here aluminum, which we will use today like we will use for aluminum or in our numerical
solution.
And of course we have different quantities here.
We have joule for gram and Celsius and here we have joule for mole Celsius.
So we need to also be careful about this.
So.
Okay, now we're.
We're ready.
So what we should do, let's start solving it.
So here we can see first the in order to care about or in order to solve the issue of a change of temperature
with X and change of temperature with T.
What we need to solve is we need to do a numerical derivation.
A numerical derivation is basically we.
Or the first derivative we need to.
Calculate that it change the location where where the curve will will change basically the slope at
that location.
And in order to do that, of course, we have many formulas.
For example, a central derivative method, we will use this one and H is the difference between this
point and this point, which we will calculate around it, which is in this case, for example, we
try to derivate this point.
We have to calculate the function value at X plus h and minus the x minus H, this is X.
So here is the lower value, here is the higher value.
So we need to minus both values and then divide by the distance.
This is how we will calculate or this is the general idea of a numerical derivation is very simple and
of course we don't really care about the to describe the actual curve equation.
So for example.
If you have a curve that is X squared.
So we will have it looks like this.
And when we do our first derivative, we will have two X which will look like this.
And if we have the second derivative, so deriving the already derived curve, we will have the slope
of the whole curve will be, of course, for every point it will be two.
And if we continue and two the third derivative, we will reach to zero.
So this is how this like numerical derivation works.
And actually there is many ways or sorry, there are many ways to calculate the numerical derivations
in things we call usually in numerical computation, we call it schemes.
So we have, for example, first order derivative schemes, we have second order derivative schemes
and it is it will provide us with.
A simple formula that we will use actually the numerical value of every point to calculate the change
at this point.
So in here we have a forward difference scheme and there is of course the backward difference scheme.
So it will take, it will it depends on the, the point of interest and you consider that point in front
of it which is called the forward difference and backward difference is the point behind it.
And central difference is we will consider both points.
And of course, for second derivatives, usually you need or not, usually you need more points.
In this case, you will have, for example, three point central difference for second derivative.
And we can see here, of course, this is we're not talking about deriving a curve and then derive it
again.
So it's not applying first derivative two times, which will work.
But in what we do is we, we, we, we don't, we're not really interested in the first derivative curve
and then we derive it again.
But we will do is we will take the equation and we discretize it means we make it written in a, in
a simple um, uh, in a simple values and or numerically possible to calculate values.
That is, we will take this curve and then what we will describe it in, in, in terms of the function
values of every point.
So this is what we will do here.
And by this we will be able to calculate the second derivative directly, the value of the second derivative
from the function value itself.
And I'm not talking about the first derivative, so it is like applying it first derivative, and then
again another third, another derivatives to get the second derivative.
But rather than going for this two step thing, we can go from one step which is using these three points.
Or in this case also this scheme, what we call the scheme is the way we calculate this derivative.
We will need to calculate this point.
So, so basically this is how we can actually, uh, well, uh, translate a heat equation or any equation
from a formula that looks like this to an actual values that can be calculated at every point.
So.
Now we understand how we can get care, which is a constant.
So depending on the material, we simply get it and we know how to change the first derivative into,
for example, a scheme.
Of course we can pick any scheme we want, although a side note is of course to choose.
The more accurate the derivative, the more accurate the scheme, and this is the inherent numerical
property of the scheme.
So you have the some schemes will have a first order accurate what we call and the second order accurate.
And it is just the how numerically accurate the scheme itself.
So in my experience most of the problems we don't really need second order or most of the time first
order schemes will work.
But the idea is some schemes will provide us inherently numerically feature that it will actually be
more accurate.
So it matters the choose the choosing of scheme.
But however we will choose a very simple schemes in this problem to solve this problem.
So for for our problem, what we will choose is the forward looking derivative for for space and time
difference.
And this this scheme.
And for the second derivative we will choose the this three point scheme.
And when we apply this to these two schemes on the equation, what we have it, we will end up with
something that looks like this.
So you at the time we were calculating plus the x minus 2UTX plus u x minus d x.
So this is the three points we're calculating, using three points.
Basically this scheme and the X square is this one.
Of course, this is dy dx means the difference x the difference of x because this is there is no D here,
so it's not like derivative.
So just be careful.
It's a little bit sometimes get confusing.
So here for the first derivative is quite also simple.
You take u t plus x minus u t x over t dt.
This is how we discretize the heat equation from its original form, which is this one into a simple
way, which is our simple form.
Which is this one.
So the this is, of course, the the theoretical way to describe it.
And what we will do is we are going to actually apply it in a python code in in the next lessons.