57 - Lecture_13_4_Code_Discretization [ID:40003]
32 von 32 angezeigt

Welcome to this last video on our project. I hope you were able to solve it for yourself.

I wanted to give you a reference on how to, well, for example, solve this problem. There

are many ways of doing that. The first task was to set up the discretization of the domain.

The easiest way is to use NumPy's linspace command, which takes the starting point of

an interval, an endpoint of an interval, and a number of points to use, or to build upon

that. Well, we can check quickly whether this works. If we take four points including zero

and one, then we would get zero, one third, two thirds, and one. So excluding the first

and the last would then give us one third and two thirds. And this is indeed what this

method does for n equal to four. So we can trust the output of that command. Okay. So

that's the discretization of the domain. The next step is to construct a matrix, which

looks very complicated, but if you know the right tools, then it's actually quite easy.

The matrix A was shown in the lecture to have this form. I have, in comparison to what I've

shown you in the lecture, put out one factor of i to the right of both matrices here. So

it's slightly more efficient to do this this way. So what you have to do is you first have to

define h equal to one over n minus one again. In one lecture, I said that it's one over n.

Of course it isn't. It's one over n minus one. And you can start with this matrix here,

the letter matrix here. And the way I've built that up is to start with an identity matrix

of the right dimension with diagonal values one half. So this gives you one halves on this

main diagonal. Then add a tri diagonal matrix going all the way up from the left bottom corner

to the first lower diagonal. So this is what this is. So this is an n minus two by n minus two matrix

with ones up to position n minus one, which is the first lower diagonal.

And then I just modify the first column and this entry here. And that gives us this matrix here.

And then the term front, this is, this matrix is built up like this. We use this range operator,

which gives us all the numbers between one and n minus two. We divide by n minus one at the end.

We reshape it into this form, multiply it by the last row of the matrix we've just built up. This

is A2 last row, all columns reshaped into the correct form. And then we can write A1 minus A2

times A2 times H squared. And this gives us the matrix A. So this is what we can do. And if we

construct the matrix, it looks like this. It has this nice, let's say, kernel shaped form. And

we can then test whether this makes sense by running the next line. And indeed, if we use

this matrix A here, as a discrete form mapping, we get exactly what, what you saw. Well, this is

slightly outside of the screen. Let's put this here. Okay. Sorry about that. So as you can see,

this gives you exactly what we have here, what we would expect. So this is the discretization step.

Teil einer Videoserie :

Zugänglich über

Offener Zugang

Dauer

00:04:35 Min

Aufnahmedatum

2022-01-13

Hochgeladen am

2022-01-13 21:16:11

Sprache

en-US

Einbetten
Wordpress FAU Plugin
iFrame
Teilen