1
00:00:10,000 --> 00:00:19,940
Hi, so what we will do today is we look at
I show you a demo right, the use hat functions.
2
00:00:19,940 --> 00:00:27,730
And what we have seen so far is the intervals
are important, number of intervals that we
3
00:00:27,730 --> 00:00:35,550
have, the size of the interval is important
for orthogonality. And the fact that overlaps
4
00:00:35,550 --> 00:00:44,079
do not, the intervals do not overlap is important
for orthogonality right, the what was it?
5
00:00:44,079 --> 00:00:48,510
The size of the interval so far did not matter
right, we took them as equal sizes right,
6
00:00:48,510 --> 00:00:51,530
that is what we basically had.
7
00:00:51,530 --> 00:00:57,129
The number of intervals increase the accuracy
with which we are able to represent the straight
8
00:00:57,129 --> 00:01:02,490
line for box function, if you think back to
the example of the box functions. How well
9
00:01:02,490 --> 00:01:08,380
we were able to represent the straight line,
it got better the error reduces as the number
10
00:01:08,380 --> 00:01:13,420
of intervals that we use increases. So we
will try to see if there is a relationship
11
00:01:13,420 --> 00:01:19,070
between the function that we are able to that
we want to represent right, and the number
12
00:01:19,070 --> 00:01:21,930
of intervals, is that fine.
13
00:01:21,930 --> 00:01:29,880
And I am going to use hat function to do the
demo, so this is so there will be a combination
14
00:01:29,880 --> 00:01:33,280
of things that we are going to get out of
this demonstration.
15
00:01:33,280 --> 00:01:38,670
I am going to use a scripting language called
Python, a particular version of it called
16
00:01:38,670 --> 00:01:44,100
Ipython, just so that what comes on the screen,
that is a sound strange to you. I am going
17
00:01:44,100 --> 00:01:49,530
to use 2 packages, I would suggest that you
find for yourself some package with which
18
00:01:49,530 --> 00:01:54,869
you are able to plot right, plot graphs and
check them out on screen. There are lots of
19
00:01:54,869 --> 00:02:01,990
packages out there, I am going to use a package
called grace plot, which I will this is as
20
00:02:01,990 --> 00:02:07,950
I said, so that you understand as a full of
those packages what it means, what I am doing.
21
00:02:07,950 --> 00:02:14,650
And to represent arrays, I am going to use
package called numpy I guess for numeric Python
22
00:02:14,650 --> 00:02:25,200
Numerical Python but anyway numpy. This is
all that we basically need right. So the objective
23
00:02:25,200 --> 00:02:32,790
is to see that if I take a function say for
example sin x, and I use 10 intervals on which
24
00:02:32,790 --> 00:02:40,879
to represent sin x. How well do I do it? And
then we will change the function sin x, sin
25
00:02:40,879 --> 00:02:46,530
2x, sin 3x, sin 4x to see whether it gets
better gets worse, you expect that maybe it
26
00:02:46,530 --> 00:02:49,080
gets better gets worse anything before we
start.
27
00:02:49,080 --> 00:02:56,700
If I use 10 intervals and I tried to use I
tried to represent sin x has suppose or sin
28
00:02:56,700 --> 00:03:06,209
2x or sin 3x sin Nx, you expect that a representation
to get better, the representation to get worse,
29
00:03:06,209 --> 00:03:11,349
you expect the representation to get worse.
And the reason why I pick trig functions,
30
00:03:11,349 --> 00:03:16,940
they are made actually numerous reasons why
I pick sin x, one of them of course is that
31
00:03:16,940 --> 00:03:20,630
it is possible for me to scale it. I can change
there is an inherent length scale associated
32
00:03:20,630 --> 00:03:21,879
with sin x.
33
00:03:21,879 --> 00:03:30,310
And by changing going to sin 2x, 3x, sin 4x,
I am changing those length scales right okay.
34
00:03:30,310 --> 00:03:36,730
So let me start it off. The first time around
I will set it up maybe subsequent classes,
35
00:03:36,730 --> 00:03:41,750
I will not go through as much of a setup and
doing going through the full setup this time,
36
00:03:41,750 --> 00:03:55,129
so that you see what I am doing okay. So I
am going to run Ipython, and I am going to
37
00:03:55,129 --> 00:03:59,970
setup my grace plot initially it is going
to be very intense I change the background
38
00:03:59,970 --> 00:04:03,230
color.
39
00:04:03,230 --> 00:04:21,010
I create the plot going to be an intense white
color, so I will quickly resize it, and I
40
00:04:21,010 --> 00:04:34,710
have set up something that you give it the
more not so bright color okay. Now what I
41
00:04:34,710 --> 00:04:45,280
will do is I will now get my numpy, from numpy
import star you can go learn Python if you
42
00:04:45,280 --> 00:04:48,270
want to use this programming language, most
of the stuff that I am doing I am not going
43
00:04:48,270 --> 00:04:54,610
to do anything unusual, I will create an array,
so numpy has in it various things including
44
00:04:54,610 --> 00:04:57,870
definitions of pi sin and so on right.
45
00:04:57,870 --> 00:05:02,590
So I will create a row vector, there is a
peculiar way by which you do it, going from
46
00:05:02,590 --> 00:05:16,000
row vector whose values go from 2 0 to 2 pi,
and I want 11 points that is 10 intervals,
47
00:05:16,000 --> 00:05:21,190
so if you say what I have managed to do, that
is what I have managed to do. So I have x
48
00:05:21,190 --> 00:05:31,910
going from 0.628 so on to 6.28 which is 2
pi right close to 2 pi. Now it is very simple,
49
00:05:31,910 --> 00:05:39,180
I create y which is sin of x, and since my
plotting utility is going to connect these
50
00:05:39,180 --> 00:05:41,430
points by piecewise straight lines.
51
00:05:41,430 --> 00:05:45,759
Which means that inherently underneath I am
doing hat functions, I just use it to plot
52
00:05:45,759 --> 00:05:52,110
okay, now if I were to use cubics, quadratics
I have to be a little more careful, I cannot
53
00:05:52,110 --> 00:05:54,880
just use this straight lines, I have to be
a little more careful. I have to actually
54
00:05:54,880 --> 00:05:58,960
plot the interpolating polynomial right, but
in this case by coincidence it happens there
55
00:05:58,960 --> 00:06:03,240
is going to join them by straight line, so
I am using hat functions okay.
56
00:06:03,240 --> 00:06:16,610
I say g dot plot x, y and I get that, what
do you say are you happy with the function?
57
00:06:16,610 --> 00:06:25,230
You have to a bit critical, is it any problem
with the this function, first of all it does
58
00:06:25,230 --> 00:06:31,700
not seem to reach the maximum right, it does
not reach 1, there is a small gap here. Why
59
00:06:31,700 --> 00:06:39,920
does not it reach 1? Because I am not sampling
the function at that point, so I am using
60
00:06:39,920 --> 00:06:43,460
the word sampling here, I am not sampling
the function at that point I am not sampling
61
00:06:43,460 --> 00:06:45,009
the function at the peak okay.
62
00:06:45,009 --> 00:06:51,509
Which is the reason why anything else, it
looks reasonably like sin x, it has a reasonable
63
00:06:51,509 --> 00:07:00,889
semblance to sin x okay, maybe if we try higher
number of grid points or whatever it is maybe
64
00:07:00,889 --> 00:07:15,860
it may be right. So what about sin 2x, shall
we try sin 2x, sin of 2 star x, I do not have
65
00:07:15,860 --> 00:07:19,880
to keep typing this every time.
66
00:07:19,880 --> 00:07:34,730
What now so is it any better, it is worse,
it really does not look like I do not know
67
00:07:34,730 --> 00:07:43,050
maybe the peaks also do not seem that great,
but actually if you look at it, it will turn
68
00:07:43,050 --> 00:07:48,759
out that the point where it crosses the 0,
the 0 crossing so to speak. These are the
69
00:07:48,759 --> 00:07:53,919
0 crossings will turn out to be quite good
okay, on this graph of course it may not be
70
00:07:53,919 --> 00:07:58,290
it is not that easy to find out, but you can
actually evaluate it and check it out.
71
00:07:58,290 --> 00:08:03,090
You will see that the 0 crossing are actually
fine okay, the point at which the function
72
00:08:03,090 --> 00:08:08,100
crosses the 0 is fine, and the number of 0
crossing is fine. The number of peaks and
73
00:08:08,100 --> 00:08:14,139
valleys is fine, the number of peaks and troughs
is fine right, the function value is seem
74
00:08:14,139 --> 00:08:20,740
okay not great. And the 10 intervals this
is not looking that good. So we will see what
75
00:08:20,740 --> 00:08:31,740
happens if I go to 3x okay, so tell me what
we have I see a lot of smiles, tell me what
76
00:08:31,740 --> 00:08:33,610
we have right.
77
00:08:33,610 --> 00:08:43,810
So here obviously that minima is gone minima
and maxima here are gone okay, and as it got
78
00:08:43,810 --> 00:08:49,790
at least the frequency does it seems as though
it got the frequency as number of 0 crossing
79
00:08:49,790 --> 00:08:54,790
that I am going to have right divided by 2
in this case, so it is like this so here to
80
00:08:54,790 --> 00:09:00,630
here. I can count it looks like the frequency
information has been picked up properly, the
81
00:09:00,630 --> 00:09:07,910
0 crossing seem to have been picked up properly,
amplitudes are totally off okay.
82
00:09:07,910 --> 00:09:16,899
So now I am doing sin 3x with 10 intervals
okay, so there is clearly some relationship
83
00:09:16,899 --> 00:09:21,529
between the number of intervals that you are
going to pick, and say the underlying frequency
84
00:09:21,529 --> 00:09:26,100
or length scale that you are trying to the
represent okay. So that is one of the things
85
00:09:26,100 --> 00:09:30,370
that we want to out of this. Let us go ahead,
I mean we will just try 4x, and see what it
86
00:09:30,370 --> 00:09:48,290
does, sin 4x. Now this is like nothing I do
not know, you tell me what do we have? We
87
00:09:48,290 --> 00:09:49,880
have anything at all.
88
00:09:49,880 --> 00:09:57,560
Do we have any is the frequency information
correct, is the number of 0 crossings is correct?
89
00:09:57,560 --> 00:10:06,110
How many times does it crosses 0? There is
1 here, 2 here, 3 here, 4 here, 5 here, 6
90
00:10:06,110 --> 00:10:13,910
here, 7 here, 8 here, 9. 4 x that looks about
right okay, so in some sense the frequency
91
00:10:13,910 --> 00:10:20,690
content is there right, and the function representation
that is if I were to show you this, you would
92
00:10:20,690 --> 00:10:27,360
be hard pressed to say that it is actually
sin of any anything sin 4x or something of
93
00:10:27,360 --> 00:10:31,560
that sort. So it is difficult to say that
sin 4x okay.
94
00:10:31,560 --> 00:10:39,251
Let us try the next one, what do you think
will happen here? It is been getting bad,
95
00:10:39,251 --> 00:10:54,790
how bad can it get, this is I should actually
this is we have to look at the scale before
96
00:10:54,790 --> 00:11:02,600
you look at this right that is 10 power-15
okay, 10 power-15 just for the fun of it just
97
00:11:02,600 --> 00:11:08,170
so that you can say that kind of stuff that
you may have to do when you are running or
98
00:11:08,170 --> 00:11:16,959
exploring these programs. I will reset the
scale here to -1 to +1 and that is what you
99
00:11:16,959 --> 00:11:17,959
get.
100
00:11:17,959 --> 00:11:25,000
So what happened? We sample the functions
exactly at the 0 crossing, now this is a bizarre
101
00:11:25,000 --> 00:11:32,829
situation we picked up the 0 crossing exactly,
but we have nothing right we do not the functions
102
00:11:32,829 --> 00:11:37,649
is just totally disappear we are not picked
up the peaks anywhere, so we really have nothing
103
00:11:37,649 --> 00:11:46,660
is that fine. So let us go on we go on and
see what we get, after all we have 10 intervals
104
00:11:46,660 --> 00:11:49,200
11 grid points 10 intervals.
105
00:11:49,200 --> 00:12:09,770
So what do you expect for 6? Going to be the
same as 4 is the prediction that I get, this
106
00:12:09,770 --> 00:12:20,480
it is the same as 4 or similar to 4? Is it
the same as 4, there is a sign change there
107
00:12:20,480 --> 00:12:23,779
is a sign change. So you would expect and
I think if all of you are familiar with this,
108
00:12:23,779 --> 00:12:24,779
I do not have to go on.
109
00:12:24,779 --> 00:12:37,780
So if I go to 7x okay and we see that the
pattern is repeated, the pattern is going
110
00:12:37,780 --> 00:12:49,880
to repeat, this is what I expect. I go quickly
to 8x, and I plot that right and 8x is getting
111
00:12:49,880 --> 00:13:09,430
better but it is not 8x. 9x what we expect
for 9x yes a bit strange it is clearly the
112
00:13:09,430 --> 00:13:16,550
sin is slipped. And 10 will be 10 should be
a straight line of course I mean I know I
113
00:13:16,550 --> 00:13:18,860
am not going to rescale it again, but 10 should
be a straight line.
114
00:13:18,860 --> 00:13:22,400
But we will see gets the same actually we
get the same value it should be a straight
115
00:13:22,400 --> 00:13:28,459
line, but remember we are dealing with numerics,
and it is not quite the same but yes the scale
116
00:13:28,459 --> 00:13:35,800
is still 10 power-15, so if I make it to -1
to+1 it would just be a straight line, the
117
00:13:35,800 --> 00:13:42,079
value is essential is 0 it is within machine
epsilon values essentially 0 okay. So and
118
00:13:42,079 --> 00:13:46,480
if we go on what do you expect to happen,
if I were to repeat this process what do you
119
00:13:46,480 --> 00:13:53,370
expect to happen is going to keep repeating.
120
00:13:53,370 --> 00:13:57,510
So the first lesson that we get out of here
as if I have 10 intervals, if I have 11 grid
121
00:13:57,510 --> 00:14:01,959
points, there is the largest frequency that
I will be able to represent with those grid
122
00:14:01,959 --> 00:14:09,950
points right. If I have 11 grid points, and
I am using hat function there is a largest
123
00:14:09,950 --> 00:14:15,709
frequency that I am going to be able to represent
using those grid points, is that fine, is
124
00:14:15,709 --> 00:14:33,639
that make sense okay fine. Now we can try
it, we can try a different set of grid points
125
00:14:33,639 --> 00:14:35,199
just to see if we can infer anything else.
126
00:14:35,199 --> 00:14:42,370
There is the largest frequency we had 10 intervals
and the largest frequency was what? It was
127
00:14:42,370 --> 00:14:49,220
4, so it looked like maybe right now you would
say then N/2-1 or something of that sort,
128
00:14:49,220 --> 00:15:05,340
so let us pick some other number. Let us say
we take x to have going to 2 pi, how many
129
00:15:05,340 --> 00:15:17,820
shall we take 21, do you want to take 21 take
21, 21 grid points is about 20 intervals fine.
130
00:15:17,820 --> 00:15:27,470
So we go through this business again y=sin
of x, check this out.
131
00:15:27,470 --> 00:15:33,350
21 grid points is definitely better than right,
21 grid points is definitely an improvement
132
00:15:33,350 --> 00:15:40,820
on 11 grid points, 20 intervals is definitely
an improvement on right 11 it looks like though
133
00:15:40,820 --> 00:15:45,009
it is pi/2, you know you are not going to
actually sample it exactly at pi/2, but we
134
00:15:45,009 --> 00:15:50,110
are quite close. We cannot make out that,
so it looks like it picked the peaks well,
135
00:15:50,110 --> 00:15:56,160
the function representation is quite clean
okay. So this is one thing that we should
136
00:15:56,160 --> 00:15:57,550
bear in mind now.
137
00:15:57,550 --> 00:16:03,962
The lesson that we take from here, that if
you are a representing a function it is a
138
00:16:03,962 --> 00:16:08,480
good idea as sometimes either an engineering
way to look at it would be to double the number
139
00:16:08,480 --> 00:16:12,760
of grid points to see whether there is an
any improvement, there is something to bear
140
00:16:12,760 --> 00:16:18,870
in mind right. I will you will come back and
visit this that suggestion at the end of the
141
00:16:18,870 --> 00:16:26,779
semester okay. So the function definitely
looks a lot better.
142
00:16:26,779 --> 00:16:44,490
What do you expect will happen to 2 star 2
time 2x, this I would expect this would be
143
00:16:44,490 --> 00:16:50,490
the same as sin x on the 10 right, so now
it is very clear it should be the same as
144
00:16:50,490 --> 00:16:58,779
sin x on the 10 right. So if I now go ahead,
we will do a few of these and then I will
145
00:16:58,779 --> 00:17:00,380
sort of jump ahead to that.
146
00:17:00,380 --> 00:17:08,589
So if I do 3x, 3x of course has no equivalent
there right, so it seems to pick the peak
147
00:17:08,589 --> 00:17:14,390
in some places, it picks the peak in some
places, it lost the peak in some places, the
148
00:17:14,390 --> 00:17:21,589
0 crossing are not there or I mean how good.
Otherwise, you could say it is sin, I mean
149
00:17:21,589 --> 00:17:26,910
we can live with it but I want you to bear
this in mind every time, so if you are going
150
00:17:26,910 --> 00:17:31,090
to if you are actually trying to represent
a trigonometric function right.
151
00:17:31,090 --> 00:17:34,660
It looks like if you are going to the represent
sin x, it looks like if you want to capture
152
00:17:34,660 --> 00:17:39,919
the function well right. It looks like you
need at least 20 grid points, 21 grid points,
153
00:17:39,919 --> 00:17:46,100
20 intervals right, employing hat functions
you need at least 20 intervals for a given
154
00:17:46,100 --> 00:17:51,670
wavelength that is one lesson you get out
of this, you need at least 20 intervals for
155
00:17:51,670 --> 00:17:57,720
wavelength. So if I am talking and you say
I want to model this in some fashion right.
156
00:17:57,720 --> 00:18:01,840
And you want to model it so that you can pick
up that signal, you actually pick up the pressure
157
00:18:01,840 --> 00:18:08,700
variations. Then you need at least 20, 10
that you could live with 10, but 10 does not
158
00:18:08,700 --> 00:18:12,300
that good okay.
159
00:18:12,300 --> 00:18:33,500
So let us try 4x should again look familiar,
4x is again familiar. But okay, let us skip
160
00:18:33,500 --> 00:18:48,030
ahead which one should we do? Let us try 7x,
so you can get it is very clear that beyond
161
00:18:48,030 --> 00:18:51,289
the certain point, the function start looking
very strange, and they do not really look
162
00:18:51,289 --> 00:18:57,280
like sin 7x that you want okay, that is the
only reason why I am sort of bothering you
163
00:18:57,280 --> 00:18:58,280
with this.
164
00:18:58,280 --> 00:19:03,350
It also looks like if you look carefully now
it looks like on top of this if I look at
165
00:19:03,350 --> 00:19:11,320
the envelope over this, there is a sin kind
of something like a sin that riding on top
166
00:19:11,320 --> 00:19:17,640
okay, so I am sorry about that, there is something
like the sin riding on top of that.
167
00:19:17,640 --> 00:19:27,130
Okay, let us try 8x, 8x something that we
have picked up earlier, 8x corresponding to
168
00:19:27,130 --> 00:19:41,210
4x that we had, however, of
course the wave number is different the frequency
169
00:19:41,210 --> 00:19:47,610
is different. Normally when you do it in space,
when I am doing this when I am talking about
170
00:19:47,610 --> 00:19:51,500
some of these kinds of problems you will see
me use wave number and frequency, and they
171
00:19:51,500 --> 00:19:53,450
are sort of an interchangeable fashion okay.
172
00:19:53,450 --> 00:19:59,130
But normally when it is in space we say wave
number, when it is in time we say frequency
173
00:19:59,130 --> 00:20:05,690
okay. So the wave number is a of course different
but it looks very similar to 4x, if you look
174
00:20:05,690 --> 00:20:08,090
at it on the 0 to pi interval.
175
00:20:08,090 --> 00:20:23,919
And what happens to 9? Why do I want to try
9? 9 should be the bad one, 9 and it has that
176
00:20:23,919 --> 00:20:30,039
the envelope again has that variation, so
there is something riding on it sin x riding
177
00:20:30,039 --> 00:20:33,140
on it literally okay.
178
00:20:33,140 --> 00:20:44,030
And what do you expect will happened with
10? 10 should be 0, each one has its own,
179
00:20:44,030 --> 00:20:48,510
it is 0 but each one because of the nature
of the representation of the number itself
180
00:20:48,510 --> 00:20:53,760
on the computer right. It should be 0 but
each one is the little different, and the
181
00:20:53,760 --> 00:20:58,340
magnitudes you can see that the maximum and
minimum magnitudes do not necessarily seem
182
00:20:58,340 --> 00:21:02,590
to be the same, and we get the impression
that has the value as you go further and further
183
00:21:02,590 --> 00:21:04,730
down, it is getting noisier and noisier.
184
00:21:04,730 --> 00:21:13,080
That it is closer its smaller value here closer
to the 0 value here, and much worse at higher
185
00:21:13,080 --> 00:21:17,220
at the higher angles okay, these all observations
that we can make just purely from looking
186
00:21:17,220 --> 00:21:21,470
at what we have got so far right.
187
00:21:21,470 --> 00:21:31,710
So what you expect will happen to 11? 11 will
repeat so it looks over so this is for this
188
00:21:31,710 --> 00:21:36,539
reason 10 would be called a folding frequency,
it looks as though the figure fold over right,
189
00:21:36,539 --> 00:21:42,330
fold over in the sense that 9 is same as the
11 except for a sin, right 8 is the same as
190
00:21:42,330 --> 00:21:50,010
12 except for the sin. So it says that we
have folded over right the folded it over
191
00:21:50,010 --> 00:21:58,090
that frequency, and anything else that we
can say?
192
00:21:58,090 --> 00:22:06,730
So if I give you N intervals or N+ 1 grid
points right, if I give you N+ 1 grid points
193
00:22:06,730 --> 00:22:13,420
then N/2 seems to be the largest N/2 in fact
seems to be the troublesome frequency, it
194
00:22:13,420 --> 00:22:20,910
is 0 there. So let me try a different set
of grid points again, let us try something
195
00:22:20,910 --> 00:22:26,030
we have both the ones that we have tried odd
21 grid points 10 interval, the number of
196
00:22:26,030 --> 00:22:31,470
intervals is even. Why do not we see what
happens when we change? Okay.
197
00:22:31,470 --> 00:22:39,110
So the first question is, do you expect any
change? We expect change x= we expect change
198
00:22:39,110 --> 00:22:48,740
okay, how many shall I do? I do 20, or let
us keep it at 10 in that way we do not have
199
00:22:48,740 --> 00:23:07,860
to okay, of course the trouble with 10 that
does will not look that good but it does not
200
00:23:07,860 --> 00:23:08,860
matter.
201
00:23:08,860 --> 00:23:16,211
It is not bad one improvement of 9 intervals
over 10 intervals is that we pick the peak
202
00:23:16,211 --> 00:23:24,350
better okay, let us not draw major conclusion
from that right, I mean it is possible just
203
00:23:24,350 --> 00:23:31,039
happenstance that may just be chance that
that is happened. The function does not look
204
00:23:31,039 --> 00:23:35,580
bad right, the function does not look bad.
205
00:23:35,580 --> 00:23:49,120
What about 2x again like last time we pick
the peaks better, this peak is off that peak
206
00:23:49,120 --> 00:24:10,640
is off. 3x okay this is a nice saw tooth,
we have picked the amplitude right, we have
207
00:24:10,640 --> 00:24:18,610
pick the frequency right, the 0 crossing are
right, it just is in sign that is the only
208
00:24:18,610 --> 00:24:25,870
problem right, it is got all the information.
Of course if you talk to your electrical engineering
209
00:24:25,870 --> 00:24:30,330
friends, they will tell you to convolve it
sinc function or something of that sort extract
210
00:24:30,330 --> 00:24:31,330
for the signal.
211
00:24:31,330 --> 00:24:34,380
But it does not matter right for us as far
as we are concerned, we are not going to do
212
00:24:34,380 --> 00:24:39,130
complicated things like that I just want the
sample points and I just want to use linear
213
00:24:39,130 --> 00:24:44,850
interpolants to represent a function, and
it bothers me that this is what I get okay,
214
00:24:44,850 --> 00:24:59,800
it bothers me that this is what I get okay.
4x give me a guess, what do you expect? You
215
00:24:59,800 --> 00:25:10,039
expect it to be 0 okay.
216
00:25:10,039 --> 00:25:18,530
So it does make a difference whether it is
even or odd, so the N/2 where N is the number
217
00:25:18,530 --> 00:25:25,130
of intervals, the N/2 seems to be significant
right. So N/2 so if you have N is even N/2
218
00:25:25,130 --> 00:25:31,360
is going to give me pick up that 0, or put
the other way if you know you start off by
219
00:25:31,360 --> 00:25:35,789
saying that this is my frequency of wave number
or whatever. You may make your choice as to
220
00:25:35,789 --> 00:25:40,090
what is the number of sample points that you
are going to take right.
221
00:25:40,090 --> 00:25:47,179
So you may take at least 2N sample points
2N+1 sample points right, sample the function
222
00:25:47,179 --> 00:25:58,110
at 2N+1 points at least okay is that fine
okay. So what do we have what is the so we
223
00:25:58,110 --> 00:26:06,140
have what are the other conclusions that we
can draw from this? “Professor - Student
224
00:26:06,140 --> 00:26:15,620
conversation starts” (()) (26:09) So frequency
information is it lost here? The frequency
225
00:26:15,620 --> 00:26:18,140
information is still there; the peaks are
gone right.
226
00:26:18,140 --> 00:26:25,740
So until up till that points, so up till the
point so one of the big conclusions that we
227
00:26:25,740 --> 00:26:29,729
can draw is the there is largest frequency
that can be represented okay. “Professor
228
00:26:29,729 --> 00:26:37,150
- Student conversation ends.” So if you
give me I will call it a mesh or a grid right,
229
00:26:37,150 --> 00:26:42,419
if you take an interval a, b you break it
up into equal number and for now because that
230
00:26:42,419 --> 00:26:45,130
is all we have been doing we cannot draw any
other conclusions equal number of intervals
231
00:26:45,130 --> 00:26:48,330
right N equal number of intervals.
232
00:26:48,330 --> 00:26:55,380
Then N/2 this is sort of the highest frequency
that can be represented okay, turn it the
233
00:26:55,380 --> 00:27:05,010
other way around for a given mesh whether
something is high frequency or low frequency
234
00:27:05,010 --> 00:27:08,850
depends on the mesh, am I making a sense.
235
00:27:08,850 --> 00:27:24,400
So if I were to pick very large number say
101 intervals, if I were to pick very large
236
00:27:24,400 --> 00:27:43,500
number right, so it comes out sin of x comes
out extremely smooth, but like I mean it is
237
00:27:43,500 --> 00:27:55,360
pretty obvious that I can actually represents
say 250, I am sorry say 25x sin of 25x, am
238
00:27:55,360 --> 00:28:02,580
I making sense. It is not a great representation
right, it is not a great representation but
239
00:28:02,580 --> 00:28:06,270
on 10 intervals I cannot pick it up at all.
It is obvious right now what we have seen
240
00:28:06,270 --> 00:28:07,550
it is always 10 intervals like.
241
00:28:07,550 --> 00:28:11,640
But that is not, I want you to pick I want
you to, so when we talk we talk about high
242
00:28:11,640 --> 00:28:15,360
frequencies and low frequencies. As we go
along you will see that we keep talking about
243
00:28:15,360 --> 00:28:19,960
high wave numbers low wave number, high frequencies
low frequencies, so the point that I want
244
00:28:19,960 --> 00:28:26,549
you to get out of this is when you say a frequency
is high right, in our world then you are performing
245
00:28:26,549 --> 00:28:30,529
some computation and you are trying to determine
a function, when you say a frequency is high.
246
00:28:30,529 --> 00:28:34,600
The frequency is high with reference to the
underlying grid or the underlying mesh that
247
00:28:34,600 --> 00:28:44,000
you have used, you understand. So what does
high frequency that is wave number 4 right
248
00:28:44,000 --> 00:28:52,940
on a grid of intervals 10 is a relatively
low frequency, on a grid of 100 intervals
249
00:28:52,940 --> 00:29:01,669
in fact we pick it extremely well, you understand.
So the mesh will pick up frequencies wave
250
00:29:01,669 --> 00:29:07,090
functions which are low with reference to
the mesh it will pick up well.
251
00:29:07,090 --> 00:29:09,690
And those that are high with reference to
the mesh it is not going to pick up as well
252
00:29:09,690 --> 00:29:18,340
okay, is that fine. So when we say high wave
number low wave number, when you are talking
253
00:29:18,340 --> 00:29:22,870
with respect to the physical problem you may
have actually an understanding as to what
254
00:29:22,870 --> 00:29:26,690
is the high wave number? What is the low wave
number? And when we are talking with respect
255
00:29:26,690 --> 00:29:31,730
to computation when we say high wave number
low wave number.
256
00:29:31,730 --> 00:29:35,110
You have to ask for clarification say what
is the grid size? Otherwise, there is no sense
257
00:29:35,110 --> 00:29:39,280
unless they give you the other piece of information,
what is high and low does not make sense right,
258
00:29:39,280 --> 00:29:44,500
high and low are compared to terms high with
respect to what? Low with respect to what?
259
00:29:44,500 --> 00:29:53,679
Right, that information has to be given, is
that fine okay. Are there any questions okay,
260
00:29:53,679 --> 00:30:04,549
so I think I would suggest that you possibly
can go onto trying out different functions.
261
00:30:04,549 --> 00:30:13,429
My suggestion is try out different functions
right with this hat functions as such try
262
00:30:13,429 --> 00:30:16,400
out representing different functions with
hat function. I would also suggest that maybe
263
00:30:16,400 --> 00:30:22,270
you can try the quadratics and cubics okay.
And you may be surprised, so I will let you
264
00:30:22,270 --> 00:30:26,640
try quadratics and cubics yourself, then I
will come back and we will do a little demo
265
00:30:26,640 --> 00:30:33,080
again with that okay, is that fine, are there
any questions okay.
266
00:30:33,080 --> 00:30:42,830
So there what do is I will stop by and I will
go back to my regular session of what we were
267
00:30:42,830 --> 00:30:59,970
doing earlier, what we had was we in the last
class right is that fine, in the last class
268
00:30:59,970 --> 00:31:10,779
we saw that if we had or okay, why do not
I continue first with the I just say something
269
00:31:10,779 --> 00:31:13,500
a little something about this hat functions
and so on, and then maybe we will connect
270
00:31:13,500 --> 00:31:16,640
up to the last class. I just want to make
a point here.
271
00:31:16,640 --> 00:31:32,549
So if I have a hat
function that is xi-1, xi, xi+1 this is x
272
00:31:32,549 --> 00:31:49,710
co-ordinate, I take one hat function is that
fine, I take one hat function. And the question
273
00:31:49,710 --> 00:31:54,080
that I have is we saw that we are able to
represent the function reasonably well when
274
00:31:54,080 --> 00:32:00,220
we have sufficient number of intervals, in
the last class we also saw that we may want
275
00:32:00,220 --> 00:32:06,930
to use differential we may want to use Taylor
series or something of that sort to represent
276
00:32:06,930 --> 00:32:07,930
derivatives.
277
00:32:07,930 --> 00:32:13,250
So then the question crops of how well can
I represent derivatives here using hat functions
278
00:32:13,250 --> 00:32:27,799
okay. So we have looked at 3 classes of functions
so far, we have looked at box functions right,
279
00:32:27,799 --> 00:32:37,669
we have looked at hat functions okay, so representing
derivatives of box functions. If you represent
280
00:32:37,669 --> 00:32:44,130
a function itself with the box function, then
the box function is a constant right it is
281
00:32:44,130 --> 00:32:48,649
a constant on the interval, the derivative
is always 0 in the interval does not work
282
00:32:48,649 --> 00:32:49,649
okay.
283
00:32:49,649 --> 00:32:55,010
What about hat functions? Hat functions there
is some hope right there is some hope, but
284
00:32:55,010 --> 00:33:04,830
the only point is that the slope is a constant
in the interval xi, xi-1, xi okay, so the
285
00:33:04,830 --> 00:33:09,330
derivative you can represent the derivative.
And in fact if I were to take the derivative
286
00:33:09,330 --> 00:33:25,600
or the hat function that is centered at x,
then what do I have? I would take the derivative
287
00:33:25,600 --> 00:33:35,730
of this hat function, let us restrict our
interest only xi-1 to xi right elsewhere only
288
00:33:35,730 --> 00:33:40,140
in the support, elsewhere the function value
is 0.
289
00:33:40,140 --> 00:33:47,750
So the derivative N prime, so if I have let
me let us say if you have a f of x is fi Ni
290
00:33:47,750 --> 00:34:01,980
summation over i that is a representation,
f sub i is the function f at xi at the grid
291
00:34:01,980 --> 00:34:16,850
points or the nodes these are terms that you
will see use for this points. So the derivative
292
00:34:16,850 --> 00:34:29,100
if I represent the derivative as f prime x
is in fact summation over i fi Ni of x derivative
293
00:34:29,100 --> 00:34:37,409
okay, and as a consequence I am asking the
question what is the derivative N prime of
294
00:34:37,409 --> 00:34:45,440
some hat function N prime of i? okay.
295
00:34:45,440 --> 00:35:23,210
Remember the function Ni of x is 0 for x 00:35:52,630
and 1-alpha of x for x in xi to xi+1, and
0 for x>=xi+1, is that okay. So the derivative
297
00:35:52,630 --> 00:35:58,240
of course as I said I am not really interested
in this because these are 0 anyway, but it
298
00:35:58,240 --> 00:36:14,390
is important they are 0, so N prime of i is
0 for x 00:36:43,099
what alpha was maybe I should remind you what
alpha is, alpha x=x-xi-1/xi-xi-1 okay.
300
00:36:43,099 --> 00:36:49,743
And I really need a subscript here, so if
I make this i either i and i+1 or whatever
301
00:36:49,743 --> 00:37:03,700
right, I really need a subscript there okay.
So what is this going to turn out to be? 1/xi-xi-1
302
00:37:03,700 --> 00:37:23,089
and we call that h right h is like xi-xi-1,
and otherwise it is -1/h, sorry h is
303
00:37:23,089 --> 00:37:54,750
like xi-xi-1 this is for x in xi-1, xi and
this is for x in xi, xi+1, and it is 0 otherwise.
304
00:37:54,750 --> 00:37:59,630
So what does this turn out to be? What does
the graph of this function turn out to be?
305
00:37:59,630 --> 00:38:25,510
The graph of the function, what does the graph
of the function? Is 1/h on i-1 and i, and
306
00:38:25,510 --> 00:38:36,600
-1/h on i i+1, okay. So given the relationship
between this and hat function it looks like
307
00:38:36,600 --> 00:38:43,700
a box function, but it is not quite the box
function right. So we use the box function
308
00:38:43,700 --> 00:38:49,030
for convenience of this class for what we
are doing and so on right, we use the box
309
00:38:49,030 --> 00:38:54,990
functions for that reason, so if you look
here we could take this interval.
310
00:38:54,990 --> 00:38:59,120
We could take another interval they are orthogonal
because the intervals were not overlapping
311
00:38:59,120 --> 00:39:04,190
that is all very nice right for that purpose
it was nice, but it is very likely that often
312
00:39:04,190 --> 00:39:09,310
we will use the hat function right to do a
representation because we are going to be
313
00:39:09,310 --> 00:39:13,040
solving differential equations. And if you
are going to be solving differential equations,
314
00:39:13,040 --> 00:39:18,070
it is nice to note that the derivative follows
some function that we are using to represent
315
00:39:18,070 --> 00:39:20,300
other functions right.
316
00:39:20,300 --> 00:39:27,119
So this may be preferable to the box function,
it belongs to it is named after Haar called
317
00:39:27,119 --> 00:39:45,200
Haar function, so it is clear that the derivative
is the constant but it can be represented.
318
00:39:45,200 --> 00:39:54,369
What do we do at the node i? What is the derivative
at the node i? There is a jump is there a
319
00:39:54,369 --> 00:40:03,490
way I can estimate it, is there a way I can
estimate the derivative at the node i, any
320
00:40:03,490 --> 00:40:10,450
suggestions? Why do not I take this?
321
00:40:10,450 --> 00:40:22,270
So if I have a function that is varying in
this fashion, it has the constant slope in
322
00:40:22,270 --> 00:40:26,890
this interval, constant slope in that interval,
I know the slope on either side of this value,
323
00:40:26,890 --> 00:40:39,530
why not I just take the average? Has the value
here maybe it works, let us see what we get
324
00:40:39,530 --> 00:40:46,560
if we do that just for the fun of right, let
us see what we get if you do. So if this is
325
00:40:46,560 --> 00:40:54,589
fi-1, fi, fi+1 right, what is the slope of
the first line segment here? What is the slope
326
00:40:54,589 --> 00:41:07,690
of the line segment there? fi-fi-1/h.
327
00:41:07,690 --> 00:41:21,410
And what is the slope of the second one? fi+1-fi/h,
I add the 2 and take the average, and these
328
00:41:21,410 --> 00:41:40,830
seems to tell me that an estimate of the derivative
f prime at i is fi+1-fi-1/2h it is good okay.
329
00:41:40,830 --> 00:41:44,869
So from this function it is possible almost
everywhere that we will be able to get it,
330
00:41:44,869 --> 00:41:51,220
whether this is an acceptable value or not
something that we will have to figure out
331
00:41:51,220 --> 00:41:56,280
okay, fine right. So before we leave this
Haar functions, let us get back here.
332
00:41:56,280 --> 00:42:09,290
Before we leave this Haar functions I just
want to point out something, I want you to
333
00:42:09,290 --> 00:42:29,630
try out something, before I get back to Taylor
series and so on I want you to try out something.
334
00:42:29,630 --> 00:42:41,270
On the interval 0, 1, you consider a function
it is a constant just drawn this vertical
335
00:42:41,270 --> 00:42:47,490
line it should be light vertical line, I will
consider a function that is constant. And
336
00:42:47,490 --> 00:43:08,920
then consider so I will call this H0 right
and I will call something H1 of x.
337
00:43:08,920 --> 00:43:36,210
So up to 0.5 it has value 1, sum 0.5 to 1
it has value -1, so you try to find H0, H0;
338
00:43:36,210 --> 00:43:50,490
H1, H1; H0, H1 is that fine okay. So far just
to keep it familiar I have been calling these
339
00:43:50,490 --> 00:43:54,470
dot products, maybe we should really call
them inner the products okay they are called
340
00:43:54,470 --> 00:44:02,940
inner products, you can continue to use the
dot product if you want, inner product. Because
341
00:44:02,940 --> 00:44:08,870
we use terms inner product, scalar product,
dot product right, dot product.
342
00:44:08,870 --> 00:44:17,520
So you can
and I call this H1 I call that H0, because
343
00:44:17,520 --> 00:44:22,730
if you think about it if you look at what
is happening on the interval 0 to 0.5 it looks
344
00:44:22,730 --> 00:44:29,220
like H0 that is just been squeezed down to
0 to 0.5, so I can again define a small function
345
00:44:29,220 --> 00:44:32,680
there which is positive negative right. I
mean you can so you can see that there is
346
00:44:32,680 --> 00:44:41,350
hierarchy of functions that we can build on
if I define an H2 I would actually normally
347
00:44:41,350 --> 00:44:43,630
put subscript also but it does not matter.
348
00:44:43,630 --> 00:44:57,090
So I can have something that is 1 up to 0.25
right, and -1 up to 0.25. And actually I can
349
00:44:57,090 --> 00:45:01,440
define 2 of these functions I can define H2
subscript 1 that is here, and I can actually
350
00:45:01,440 --> 00:45:07,520
translate that function to the right, so this
function just like so it looks like we are
351
00:45:07,520 --> 00:45:15,069
getting low frequency high frequency higher
frequency right just like sin x, sin 2x, and
352
00:45:15,069 --> 00:45:21,920
sin 3x it looks like that something very similar
to that, is that fine is that okay right.
353
00:45:21,920 --> 00:45:26,280
So I just wanted you to be familiar, I just
wanted you to get that idea right, now what
354
00:45:26,280 --> 00:45:38,849
we want is we will just tie up with the derivatives
representation of functions representation
355
00:45:38,849 --> 00:45:43,440
of derivatives that is basically what we want,
because we want to solve differential equations
356
00:45:43,440 --> 00:45:44,440
right.
357
00:45:44,440 --> 00:45:57,710
So in the last class we saw that if I have
if I give you f at x, then we could use Taylor
358
00:45:57,710 --> 00:46:11,200
series prime that indicates differentiation
and delta x+ f double prime. That we could
359
00:46:11,200 --> 00:46:18,251
use Taylor series to figure out what was the
nature of the error that we are making, if
360
00:46:18,251 --> 00:46:24,670
we were to approximate right f at x+delta
x as f of x right. So in the last class basically
361
00:46:24,670 --> 00:46:28,210
said well if you have a function value at
some point the easiest thing for us to do
362
00:46:28,210 --> 00:46:33,480
is assumed the same function value at a neighboring
point right at an adjacent to this point or
363
00:46:33,480 --> 00:46:34,480
whatever.
364
00:46:34,480 --> 00:46:42,450
So that would be an approximation f of x+delta
x approximately like f of x, and what would
365
00:46:42,450 --> 00:46:49,230
be the error that we would make in that approximation,
well we have an infinite series here and in
366
00:46:49,230 --> 00:46:54,220
this infinite series are basically truncated
the infinite series in making this approximation.
367
00:46:54,220 --> 00:46:58,381
We created what is called the truncation error,
this is a repeat of what I did last time,
368
00:46:58,381 --> 00:47:05,369
and the truncation error is typically indicated
by the leading term.
369
00:47:05,369 --> 00:47:12,530
So the order of the truncation error is f
prime of x times delta x and because the delta
370
00:47:12,530 --> 00:47:23,730
x has an exponent 1 right, this error is said
to be first order. So basically as delta goes
371
00:47:23,730 --> 00:47:38,230
to 0, this error goes to 0 in a linear fashion
okay, is that fine. What about higher order
372
00:47:38,230 --> 00:47:48,971
representation? How can I get a higher order
representation? I say f of x+delta x=f of
373
00:47:48,971 --> 00:47:58,369
x+delta x times f prime of x+ higher order
terms delta x squared/2 f double prime of
374
00:47:58,369 --> 00:48:01,220
x I keep that +higher order terms.
375
00:48:01,220 --> 00:48:09,480
It is clear that if I have the derivative
which we saw when we did when we use cubics,
376
00:48:09,480 --> 00:48:12,329
so if you have the derivative information
it is possible for us to get higher order
377
00:48:12,329 --> 00:48:15,450
a representation right. So there is a connection
between what we are doing there, and what
378
00:48:15,450 --> 00:48:20,869
we are doing here, but the trouble is what
if we do not have the derivative then we are
379
00:48:20,869 --> 00:48:26,010
in trouble right. So if you have the derivative
information it is actually possible for you
380
00:48:26,010 --> 00:48:27,730
to look at what is.
381
00:48:27,730 --> 00:48:32,650
So if you say that this is my function value
right now, this was my function value yesterday
382
00:48:32,650 --> 00:48:37,130
right. So my bank account has so much money
yesterday, my bank account has so much money
383
00:48:37,130 --> 00:48:41,700
today, then I can maybe predict what my bank
account is going to get, if I know the rate
384
00:48:41,700 --> 00:48:48,590
at which that value is changing right that
is basically what it is, is that fine okay.
385
00:48:48,590 --> 00:48:53,980
This also gives me the different clue.
386
00:48:53,980 --> 00:48:58,940
If I look at this equation, this equation
tells me right now we have been looking at
387
00:48:58,940 --> 00:49:04,220
saying that what happens in an x+delta x this
equation tells me so if I have prime and if
388
00:49:04,220 --> 00:49:09,410
I have f of x this equation basically tells
me that I can predict f of x+delta x right,
389
00:49:09,410 --> 00:49:16,760
in a little more earlier I was saying approximate,
but now I am saying I changing it around,
390
00:49:16,760 --> 00:49:21,290
I can actually predict. So if from a differential
equation you are able to get the derivative
391
00:49:21,290 --> 00:49:27,090
value you could actually predict what is going
to happen at x+delta x given the value at
392
00:49:27,090 --> 00:49:32,540
x and the derivative at x fine okay.
393
00:49:32,540 --> 00:49:36,000
That is one way to look at it, this is the
argument we have been using so far. The other
394
00:49:36,000 --> 00:49:39,280
things that you can get from this equation
once you have written this equation as you
395
00:49:39,280 --> 00:49:49,730
can write it as a way by which you can approximate
f prime of x, what does f prime of x? f of
396
00:49:49,730 --> 00:50:02,410
x+delta x-f of x/delta x that is the other
possibility that we can actually evaluate
397
00:50:02,410 --> 00:50:08,320
the derivative based on the values at x and
x+delta x given that now you know f of x+delta
398
00:50:08,320 --> 00:50:10,440
x, is that fine okay.
399
00:50:10,440 --> 00:50:18,980
So we will see in the next class, how to go
about doing this right. And we will see what
400
00:50:18,980 --> 00:50:24,290
is the error, so we will now go about representing
derivatives, how do we represent derivatives?
401
00:50:24,290 --> 00:50:28,330
How do you estimate derivatives? How do you
represent derivatives approximate derivatives?
402
00:50:28,330 --> 00:50:32,589
And how do you find the error N right, that
we are making in that representation fine
403
00:50:32,589 --> 00:50:35,220
okay. I will see you in the next class.