1
00:00:00,480 --> 00:00:04,170
Now, let us discuss a bit about basic integration methods.

2
00:00:04,740 --> 00:00:11,970
And here in this figure, I try to explain to you the problems that occur when we take two simple methods

3
00:00:11,970 --> 00:00:12,900
for integration.

4
00:00:13,710 --> 00:00:22,230
So as you probably know, when we integrate a function from boundary to boundary B, we basically try

5
00:00:22,230 --> 00:00:24,660
to calculate the area under the curve.

6
00:00:25,200 --> 00:00:30,870
So basically this red area here between the blue curve and the x axis.

7
00:00:31,920 --> 00:00:38,820
And if we try to calculate this integral starting from minus three to plus three, then when we do it

8
00:00:38,820 --> 00:00:43,930
numerically, we have to, first of all, find out some points of the graph, of course.

9
00:00:43,950 --> 00:00:49,200
So we must determine d the f of X values of these red dots here.

10
00:00:50,040 --> 00:00:57,900
And then what we can do is we can transform the integral, which is like a continuous treatment of this

11
00:00:57,900 --> 00:00:58,350
problem.

12
00:00:58,530 --> 00:01:00,870
We can transform it into a sum.

13
00:01:01,480 --> 00:01:05,730
And now the question is, how do we calculate the sum exactly?

14
00:01:06,400 --> 00:01:13,290
There exists several methods, and the most simple one would be to just consider basically a weighted

15
00:01:13,290 --> 00:01:13,740
sum.

16
00:01:13,740 --> 00:01:21,510
So basically, you take all of these values here and you add them up and then you just take into account

17
00:01:21,570 --> 00:01:24,810
the size or the distance between two of these dots.

18
00:01:25,200 --> 00:01:31,110
So basically the width of these bars and then you just add up all these rectangles here, and this will

19
00:01:31,110 --> 00:01:33,090
approximately give you the integral.

20
00:01:34,350 --> 00:01:40,260
However, you can see already a problem that occurs, especially when you have just a few of these points

21
00:01:40,260 --> 00:01:44,220
and also when the function doesn't go to zero at the boundaries.

22
00:01:44,730 --> 00:01:47,680
This is that the and the end point.

23
00:01:47,700 --> 00:01:54,090
So here, minus three and plus three are over pronounced because here we are not really calculating

24
00:01:54,090 --> 00:01:56,160
the integral from minus three to three.

25
00:01:56,520 --> 00:02:03,420
But we calculate the integral from, let's say, minus three point two five two plus three point two

26
00:02:03,420 --> 00:02:03,840
five.

27
00:02:04,800 --> 00:02:06,510
So this is a bit of a problem here.

28
00:02:07,050 --> 00:02:09,930
Our range is not perfectly determined.

29
00:02:10,740 --> 00:02:13,770
So better methods have to be found.

30
00:02:13,770 --> 00:02:20,880
And a very simple idea would be to just say that we can take the edge values of the interval over which

31
00:02:20,880 --> 00:02:21,540
we integrate.

32
00:02:21,930 --> 00:02:29,770
And this point here will only be taken into account with half the width or half the weight.

33
00:02:29,790 --> 00:02:30,720
You could also see.

34
00:02:31,200 --> 00:02:37,350
So you see this rectangle here has only half the width of the neighboring rectangle and then at least

35
00:02:37,350 --> 00:02:40,710
the interval the range over which we integrate is correct.

36
00:02:42,010 --> 00:02:44,080
And then there exist many other methods.

37
00:02:44,410 --> 00:02:51,700
For example, this truck has trapezoid methods, or we can also derive more advanced methods that give

38
00:02:51,700 --> 00:02:54,310
you a much better value for the integration.

39
00:02:55,390 --> 00:03:01,540
So let's get started and let's define the function and I have plotted here, and let's create the data

40
00:03:01,960 --> 00:03:05,080
points that we will use for our integration.

41
00:03:05,080 --> 00:03:10,600
And also, of course, let's first discuss the analytical results, which will be our reference point

42
00:03:10,900 --> 00:03:14,680
for evaluating the quality of these integration methods.

43
00:03:15,860 --> 00:03:20,630
So first of all, as always, we will load our modules are Nampai and Plotnick.

44
00:03:21,200 --> 00:03:23,900
And then we will define a function.

45
00:03:24,890 --> 00:03:34,400
So this will be the function that we want to integrate, and the function is 0.5 plus zero point one

46
00:03:34,400 --> 00:03:39,320
times x plus 0.2 times x squared.

47
00:03:39,680 --> 00:03:45,890
And then we have the last term 0.03 times X to the power of three.

48
00:03:46,910 --> 00:03:49,190
So it's a polynomial of third order.

49
00:03:50,330 --> 00:03:58,020
And if we want to plot it, we just write X list is in a line space and put in space.

50
00:03:59,480 --> 00:04:06,170
Do you see the plot range approximately, let's say, minus three point five to three point five and

51
00:04:06,170 --> 00:04:07,370
seventy one points?

52
00:04:07,970 --> 00:04:16,940
And then you plot the function by writing plot of plot x list and then the function acting on the X

53
00:04:16,940 --> 00:04:17,269
list.

54
00:04:19,459 --> 00:04:20,320
And here we go.

55
00:04:20,329 --> 00:04:23,270
This is our functions the same as is shown here.

56
00:04:24,140 --> 00:04:28,760
We can, of course, also change the Y range and we can add labels for the axes.

57
00:04:29,200 --> 00:04:33,200
I think it's OK to just leave it as it is because we have the plot already here.

58
00:04:34,520 --> 00:04:38,030
So now for the analytical solution, here we have again the function.

59
00:04:38,090 --> 00:04:44,810
And when we calculate the area from minus three to three under the curve, then we have to integrate

60
00:04:44,810 --> 00:04:45,740
over this function.

61
00:04:45,740 --> 00:04:52,190
And so basically we have to increase the power of the X and then take into account the factor here.

62
00:04:52,610 --> 00:04:58,070
So basically, when we arrived this function, we should end up with our initial function.

63
00:04:58,700 --> 00:05:06,830
So you can test this, the derivative is one five plus one over 10 x plus one over five x squared plus

64
00:05:08,420 --> 00:05:11,030
three over 100 x to the power of three.

65
00:05:12,170 --> 00:05:16,010
And then we have here the boundaries from minus three to plus three.

66
00:05:16,310 --> 00:05:19,730
So now we just have to calculate these two terms here.

67
00:05:20,060 --> 00:05:24,130
So I copy this line of code from my other notebook and then run it.

68
00:05:24,140 --> 00:05:25,760
So these are just these two terms.

69
00:05:26,240 --> 00:05:33,740
And the solution is six point six, and this will be the reference point for the integral of this red

70
00:05:33,740 --> 00:05:34,220
area.

71
00:05:35,720 --> 00:05:44,690
And then we want to consider here a situation where let's say we have our data could be some experimental

72
00:05:44,690 --> 00:05:46,730
measurement or could be just some.

73
00:05:46,730 --> 00:05:51,890
Some data points that we have from have taken from the internet of some function.

74
00:05:52,400 --> 00:05:55,100
Or maybe we did a survey or something like that.

75
00:05:55,580 --> 00:05:59,240
And so we don't know the function behind it yet.

76
00:06:00,020 --> 00:06:04,250
So we only know the data points that we are going to create next.

77
00:06:05,030 --> 00:06:08,870
So the data points aren't the ones that I have plotted here and read.

78
00:06:08,930 --> 00:06:11,960
This is the only information that we have about the graph.

79
00:06:13,430 --> 00:06:17,270
So we want to make the situation as difficult as possible.

80
00:06:17,960 --> 00:06:27,320
So the X points will be a in space and it goes from minus three to three and we have 13 points because

81
00:06:27,710 --> 00:06:33,440
then we have a distance of the neighboring points of zero point five.

82
00:06:34,220 --> 00:06:36,170
So you see here we have 13 points

83
00:06:39,200 --> 00:06:46,940
and then the data itself will be an every and detailed array and the X coordinates will, of course,

84
00:06:46,940 --> 00:06:53,210
be the X points and then the Y coordinates will be the function acting on the X points.

85
00:06:55,370 --> 00:07:06,410
So this will be our data and then we can just plot the data and this will just be PLG dot scatter data

86
00:07:07,100 --> 00:07:11,540
zero and data one.

87
00:07:13,900 --> 00:07:16,900
So this will be the situation that we will start with.

88
00:07:17,380 --> 00:07:24,040
We have just these data points and we try to calculate the integral over the corresponding function,

89
00:07:24,310 --> 00:07:28,900
which we don't know from the area minus three to three.

90
00:07:29,440 --> 00:07:33,190
This we will do by different methods and we will start in the next lecture.

