Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,000 --> 00:00:05,360
This college algebra course is different than other college
2
00:00:05,360 --> 00:00:10,720
ones, you will be learning all the concepts from an experienced
3
00:00:10,720 --> 00:00:16,320
But in this course, the instructor Ed Protowski will also show you
4
00:00:16,320 --> 00:00:22,160
concepts in Python. This course is for everybody, but especially
5
00:00:22,160 --> 00:00:33,039
science. Hello and welcome to the Algebra with Python course. My
6
00:00:33,039 --> 00:00:40,640
guide on this adventure. So we're going to learn about algebra and
7
00:00:40,640 --> 00:00:46,960
all of your algebra. Because there's so many different things that
8
00:00:46,960 --> 00:00:53,759
You learn these formulas. Hey, anytime you have a formula, you can
9
00:00:53,759 --> 00:00:58,640
So that's what we're going to do. We're going to write some code
10
00:01:00,320 --> 00:01:07,519
That's Python, a Jupyter notebook, essentially in your Google
11
00:01:07,519 --> 00:01:13,920
we'll do is look at how to set that up. We're going to go through
12
00:01:13,920 --> 00:01:20,320
look at the math. We're going to look in the actual lessons. I'll
13
00:01:20,319 --> 00:01:25,519
and we'll look at the concepts, how to do the math on the board.
14
00:01:26,319 --> 00:01:33,359
then how to write the code to do this. And you'll be able to
15
00:01:33,359 --> 00:01:39,760
In fact, I hope you do create your own notebook or two along the
16
00:01:39,760 --> 00:01:46,480
resources that you can use. You can also, you know, once we set it
17
00:01:46,480 --> 00:01:51,359
download the CoLab, the Google CoLab app, and you have access to
18
00:01:51,359 --> 00:01:57,120
your phone. So, you know, you can make your own like, you know,
19
00:01:57,120 --> 00:02:03,040
access to on your phone, you know, solve all kinds of things, you
20
00:02:03,040 --> 00:02:08,719
You know what, you know, building these resources, but also
21
00:02:08,719 --> 00:02:13,680
you go further in math and in writing code and eventually leading
22
00:02:13,680 --> 00:02:19,439
data science, that you really understand these concepts and you
23
00:02:19,439 --> 00:02:25,359
that you're creating. So that's really, that's the idea. That's
24
00:02:25,360 --> 00:02:29,360
going to be a lot like this. I'm going to talk about the math, you
25
00:02:29,360 --> 00:02:36,160
on the board and then we'll flip it and we'll look at how to do
26
00:02:36,159 --> 00:02:43,280
all the resources for you. And then in addition to the core
27
00:02:43,280 --> 00:02:50,640
then what we'll do is I'll have another video or two of extra
28
00:02:50,639 --> 00:02:54,479
So, you know, you know how to write the code, you're building your
29
00:02:54,479 --> 00:02:58,399
and then we'll just work through a bunch of extra problems, you
30
00:02:59,680 --> 00:03:04,640
And it'll be really great. You know, you'll learn algebra, you'll
31
00:03:04,639 --> 00:03:08,879
and you'll have all these skills under your belt that you can use
32
00:03:08,879 --> 00:03:16,079
we're going to build upon these in future courses. So I hope you
33
00:03:16,080 --> 00:03:23,360
to set up Google CoLab in your Google Drive. So in your Google
34
00:03:23,360 --> 00:03:29,280
in folders and, you know, you have a, you'll set up a folder for
35
00:03:29,280 --> 00:03:36,560
you can have all the documents and notebooks and everything there,
36
00:03:36,560 --> 00:03:43,680
and you will have access to all these documents you see, you know,
37
00:03:44,560 --> 00:03:50,240
if we take a look at the little yellow infinity symbol, that's the
38
00:03:51,280 --> 00:03:56,479
And, you know, if you want to create a new Google CoLab, you're in
39
00:03:56,479 --> 00:04:02,479
be, click on new, and it won't be here, and you go to more, and
40
00:04:03,280 --> 00:04:07,199
So Google CoLab. Now, if you don't have it already, if you have
41
00:04:07,919 --> 00:04:15,280
then you go down to connect more apps. And, you know, it's begins
42
00:04:15,280 --> 00:04:21,920
you know, here. But if not, then you can search, you know, and
43
00:04:21,920 --> 00:04:30,800
you just do Co, it comes up. But if you type in CoLab, then it'll
44
00:04:30,800 --> 00:04:36,400
mine's already installed. But if it wasn't, you'd see it there,
45
00:04:36,399 --> 00:04:41,519
button, instead of saying uninstall, it would say install. And
46
00:04:42,560 --> 00:04:49,199
And there we go. Then when you go to new, and then you can go to
47
00:04:49,199 --> 00:04:58,319
and it loads. There you go. So as you see, I like the dark theme
48
00:04:58,319 --> 00:05:05,920
that's just what I picked. You know, you can change that. So this
49
00:05:05,920 --> 00:05:10,560
where you're going to write the code, you know, it's set up to
50
00:05:10,560 --> 00:05:18,160
addition to that, you have the ability to add more code or more
51
00:05:18,160 --> 00:05:23,520
another block of code, you can add more text. And if you click up
52
00:05:24,399 --> 00:05:30,079
And, you know, if you type text, now, if I hit enter, that just
53
00:05:30,079 --> 00:05:35,199
I have to click somewhere else to get out of that. So there you
54
00:05:35,199 --> 00:05:40,159
doing that. Also, if you might have noticed this appear, if you
55
00:05:40,160 --> 00:05:48,880
you can add code or text. And that works anywhere. You see, so you
56
00:05:48,879 --> 00:05:56,319
in between these two. And there we go. And that text actually,
57
00:05:56,319 --> 00:06:03,279
actually use some a few HTML tags to, you know, make new line
58
00:06:03,279 --> 00:06:12,239
And then if you get really fancy, you can use the latex math
59
00:06:12,240 --> 00:06:16,639
formulas. But we'll get to that soon enough. Alright, so you have
60
00:06:16,639 --> 00:06:22,000
you can do, you know, your code, your text. And one of the other
61
00:06:22,000 --> 00:06:27,360
like any document, give it a name. And you'll notice the familiar
62
00:06:27,360 --> 00:06:36,800
Google Docs, you can, there we go. Let's just call this week one
63
00:06:37,680 --> 00:06:41,120
you know, give it a name, you know, you don't want to leave all
64
00:06:41,120 --> 00:06:47,199
might be, you might forget, and it might be hard to find later.
65
00:06:47,199 --> 00:06:58,639
whatever you'd like to put in there, print. Okay. And, you know,
66
00:06:58,639 --> 00:07:05,360
code until you run it. And you can click this run button, or if
67
00:07:05,360 --> 00:07:14,879
notebooks, you can hit shift enter, that'll run it also. And there
68
00:07:14,879 --> 00:07:24,800
here. Notice you can also do a lot of math right there in the
69
00:07:25,360 --> 00:07:34,480
put in math formulas, you see hit enter, it just gives you a new
70
00:07:34,480 --> 00:07:39,920
of math formulas. And remember, the add, subtract, multiply,
71
00:07:49,040 --> 00:07:58,319
this asterisk, two of them. So there you go. So that would be
72
00:08:00,399 --> 00:08:05,919
And you see it'll, it'll do the math right there. If you wanted to
73
00:08:05,920 --> 00:08:10,080
you have to import something. And we'll get to imports as we go
74
00:08:10,639 --> 00:08:15,759
But notice you can, you know, you can have your text, you can
75
00:08:15,759 --> 00:08:18,719
for a lot of simple things. You can just do that right in the
76
00:08:19,360 --> 00:08:24,480
One of the other interesting things you can do is, and if I make
77
00:08:27,759 --> 00:08:34,799
I'll just make that B for a certain reason, then you have a table
78
00:08:34,799 --> 00:08:41,039
Now this has nothing because I don't have any headings or
79
00:08:41,039 --> 00:08:47,360
table of contents looks for. If you click on a new section, then
80
00:08:47,360 --> 00:08:52,560
it as new section and call it good right there. You see it shows
81
00:08:53,679 --> 00:09:00,079
And if you double click, now this B is underneath that section. So
82
00:09:00,080 --> 00:09:09,280
it becomes minimized within that section. And then here, A, if I
83
00:09:10,080 --> 00:09:15,920
then take a look at the section heading. If I double click on it,
84
00:09:16,639 --> 00:09:23,840
would be normally used for a Python comment, but we're, but we're
85
00:09:23,840 --> 00:09:30,240
It would be normally used for a Python comment, but since we're in
86
00:09:30,240 --> 00:09:41,120
just use it to indicate a new section. So I can go up to here,
87
00:09:41,120 --> 00:09:45,200
section. You probably don't need the space, but I like it. And
88
00:09:45,200 --> 00:09:51,600
out of that. So now I have A and I have my new section here. So I
89
00:09:51,600 --> 00:09:58,960
I can put some, I can put some code here and I can, in this code,
90
00:09:58,960 --> 00:10:06,560
arrow over there? I can move it up. And then maybe I'll make B,
91
00:10:06,559 --> 00:10:18,000
make B its own section. I'll click somewhere else. And so I can
92
00:10:18,000 --> 00:10:22,480
and now B is its own section. That kind of didn't matter because I
93
00:10:22,480 --> 00:10:31,600
of it. There we go. Put text in here, click somewhere else, and
94
00:10:31,600 --> 00:10:36,720
So you see, I can have these different sections collapsed, and
95
00:10:36,720 --> 00:10:45,920
of contents, A, new section, B. So if you give them names more
96
00:10:45,919 --> 00:10:52,719
them more than A and B. It becomes useful because you can find
97
00:10:52,720 --> 00:10:58,720
And then you just click to expand each section in whatever else.
98
00:10:58,720 --> 00:11:07,840
section, you can have code, text, you know, and as many of those
99
00:11:07,840 --> 00:11:14,240
goes until you create a new section. So some good useful things
100
00:11:14,240 --> 00:11:19,600
Google CoLab notebooks. You might decide that you might like that
101
00:11:19,600 --> 00:11:27,120
you know, keep them in sections. So that helps. Also, the Google
102
00:11:27,120 --> 00:11:34,879
the Google Drive, it does save automatically, but it doesn't do it
103
00:11:34,879 --> 00:11:47,200
and you do have a save here, and also the normal shortcuts, Ctrl
104
00:11:47,200 --> 00:11:56,640
work. And that way, sometimes, you know, if it goes a while in
105
00:11:56,639 --> 00:12:01,679
it, it might actually prompt you to say that you might need to
106
00:12:01,679 --> 00:12:09,039
to think about. You know, you actually do actually make an effort
107
00:12:09,039 --> 00:12:15,439
CoLab. So we set up our code. We can do math right there in the
108
00:12:15,440 --> 00:12:22,080
sections, table of contents, and all these sections, you know,
109
00:12:22,080 --> 00:12:29,040
expand or collapse them all at once if you want. You know, that's
110
00:12:29,039 --> 00:12:33,599
all the code we're going to work on, you know, you also have down
111
00:12:33,600 --> 00:12:40,960
that looks like, you know, XML or HTML tags, and it's a bunch of
112
00:12:40,960 --> 00:12:48,720
you know, copy and paste, try these right in your Google CoLab
113
00:12:48,720 --> 00:12:57,360
things to explore. And there we have it. You're going to be
114
00:12:57,360 --> 00:13:06,879
You might want to build one for algebra and, you know, just
115
00:13:06,879 --> 00:13:11,840
in which case, definitely make sections because that's going to be
116
00:13:11,840 --> 00:13:17,600
to find what you want. So you could do that. You could make a
117
00:13:17,600 --> 00:13:24,000
for each unit or each week or however you want to organize it. But
118
00:13:24,000 --> 00:13:29,039
these resources that you will have access to. And as well as
119
00:13:30,159 --> 00:13:34,959
you can also download and install the app. So that'll be useful.
120
00:13:34,960 --> 00:13:40,960
That when you first run it, you need to do a few things to go
121
00:13:42,240 --> 00:13:45,759
authentication and such. But, you know, it doesn't take that
122
00:13:46,879 --> 00:13:50,639
All right, so we have this, you're going to be building your stuff
123
00:13:50,639 --> 00:13:55,919
in your Google CoLab and it's going to be exciting. We'll get to a
124
00:13:55,919 --> 00:14:01,839
a lot of interesting things. So let's get into the math next.
125
00:14:06,159 --> 00:14:11,039
So we can't talk about proportions without talking about ratios.
126
00:14:11,039 --> 00:14:17,599
word for a fraction. So this two out of four, I can write that as,
127
00:14:17,600 --> 00:14:21,600
but I could say two fourths. I can call it a fraction, but it's
128
00:14:22,240 --> 00:14:28,879
And then a proportion is two equal ratios. So if I know that these
129
00:14:28,879 --> 00:14:34,159
things I can do with this. And one of the things that works and
130
00:14:34,159 --> 00:14:43,679
multiply. So if these two are equal ratios, then I can cross
131
00:14:43,679 --> 00:14:53,519
I can do two times 10 equals four times five. And that's another
132
00:14:53,519 --> 00:15:00,480
get it out of the proportion mode and I can use this to double
133
00:15:00,480 --> 00:15:06,960
So two times 10, we see 20 equals 20 and then that's true. So, you
134
00:15:06,960 --> 00:15:11,840
works. We can always do this. If these were other numbers, I can
135
00:15:11,840 --> 00:15:18,160
cross multiplying, because if that doesn't work, then that
136
00:15:18,159 --> 00:15:25,600
if one of these numbers is unknown. So if I have three out of six
137
00:15:26,159 --> 00:15:31,439
other ways to solve this, but this is the go-to way because it
138
00:15:31,440 --> 00:15:44,480
when I do my cross multiplying, then I can do this three times
139
00:15:44,480 --> 00:15:51,120
go. Three times four is 12 and then six times X is six X. And then
140
00:15:51,120 --> 00:16:02,240
going to do is going to be dividing by six. So then I get that X
141
00:16:02,799 --> 00:16:10,079
we can jump ahead and say, okay, let's I know that when I multiply
142
00:16:10,080 --> 00:16:15,600
step. It's going to be six X. So the next thing I'm doing is
143
00:16:15,600 --> 00:16:21,759
just put this in one step. So I multiply the diagonal that I can
144
00:16:21,759 --> 00:16:28,159
because I know that the next step and then my answer is X. So we
145
00:16:28,159 --> 00:16:34,719
in writing code. I can see the proportion and I can then just put
146
00:16:34,720 --> 00:16:41,840
for X. And again, that's it's the go-to way it works every time.
147
00:16:41,840 --> 00:16:48,879
for these numbers, cross multiply and then solve for X. One of the
148
00:16:48,879 --> 00:16:56,000
some of the other applications. If I have, let's say I'm
149
00:16:56,000 --> 00:17:09,440
kilometers. So if I have one mile is about 1.6 kilometers, then I
150
00:17:09,440 --> 00:17:19,680
ratio that I know. So as long as I have miles and then kilometers,
151
00:17:19,680 --> 00:17:27,759
out the other. This unknown can be either place. So if I have two
152
00:17:27,759 --> 00:17:35,519
is that? You see, we can make use of this. I know that I'm cross
153
00:17:35,519 --> 00:17:46,400
by one. And then, so there we go. So X would be 3.2. And again,
154
00:17:46,400 --> 00:17:51,600
two times 1.6 dividing by the other number, which in this case,
155
00:17:51,599 --> 00:17:56,159
So then I can solve. So this is what we're going to use. And we're
156
00:17:56,160 --> 00:18:02,880
how to put this into code. And so prompt for these four numbers or
157
00:18:02,880 --> 00:18:08,640
and then figure out the fourth one. So let's take a look at how
158
00:18:08,640 --> 00:18:16,320
at the code. So we're going to see here how much easier it is to
159
00:18:16,319 --> 00:18:21,839
our problems. And just like proportions, we have that cross
160
00:18:21,839 --> 00:18:29,599
time. So I'm going to put just a display here to remind us that
161
00:18:29,599 --> 00:18:37,039
And here's what it looks like. N1, D1 equals N2 over D2. So N for
162
00:18:37,599 --> 00:18:44,480
And if I have a proportion, I would know one of the ratios. So I
163
00:18:45,359 --> 00:18:53,439
And then N2 or D2, one of those I would not know, but I would know
164
00:18:53,440 --> 00:19:00,080
comment here in the code, put a zero in for the unknown value,
165
00:19:00,079 --> 00:19:06,000
these values would be zero. That would just, you know, you
166
00:19:06,000 --> 00:19:10,240
that, that zero is everything out, or if it's in the denominator,
167
00:19:10,240 --> 00:19:17,359
never occur in something that we're really trying to solve. So I
168
00:19:17,359 --> 00:19:25,679
just change these numbers, put in my numbers that I know, and I'll
169
00:19:25,680 --> 00:19:35,840
know. And then I'll put two if statements. So I have if N2 equals
170
00:19:35,839 --> 00:19:41,759
the setup of the if statement in Python. If N2 at the double
171
00:19:41,759 --> 00:19:52,240
I have a colon. And then the indentation afterward is one, two,
172
00:19:52,240 --> 00:19:58,480
some people use a tab, I would hesitate to not use a tab. They
173
00:19:58,480 --> 00:20:07,360
of spaces. So indent four spaces. And then I have the answer is,
174
00:20:07,359 --> 00:20:16,240
multiplying. So you see D2 times N1 divided by D1, that cross
175
00:20:16,240 --> 00:20:23,680
and then we'll print out the answer. And we'll do the same thing
176
00:20:23,680 --> 00:20:30,320
so my if statement, if D2 equals zero, colon, four spaces indent,
177
00:20:30,319 --> 00:20:38,079
notice the cross multiplying. So D2 is what I don't know. So I'd
178
00:20:38,079 --> 00:20:45,359
by N1. And then I'd print out that answer. So there we go. And
179
00:20:45,359 --> 00:20:55,279
equals what over 16. And then if I would run this, and it will
180
00:20:55,279 --> 00:21:04,799
we go. N2 equals eight. Or if I had this, I'll keep this and maybe
181
00:21:07,119 --> 00:21:13,599
Rio, and if we run it, there we go. Really straightforward. We
182
00:21:13,599 --> 00:21:18,879
that we know these we know these formulas, and we can just put
183
00:21:18,880 --> 00:21:25,440
display something to set it up, and cross multiply, solve any
184
00:21:29,440 --> 00:21:34,480
Now that we've worked through the core skills in this unit, let's
185
00:21:34,480 --> 00:21:40,160
And I'm going to work through extra problems using the CoLab
186
00:21:40,160 --> 00:21:46,240
you can apply these resources that you're building and use these
187
00:21:46,240 --> 00:21:52,160
up in a textbook or in day-to-day life. So we're going to go
188
00:21:52,160 --> 00:21:58,160
We're going to work through some extra problems here relating to
189
00:21:58,160 --> 00:22:04,560
working with proportions and ratios. And one of the things that
190
00:22:04,559 --> 00:22:10,079
numbers. And in math, I might write it like this, but then you
191
00:22:10,079 --> 00:22:16,079
And Python, remember, you can even do math in the print statement.
192
00:22:16,079 --> 00:22:22,319
two thirds becomes one plus two thirds, and you see two divided by
193
00:22:22,319 --> 00:22:26,639
sometimes I use parentheses, extra parentheses, but we really
194
00:22:26,640 --> 00:22:33,200
operations. So you could have one plus two thirds, plus three and
195
00:22:33,200 --> 00:22:41,120
plus four divided by five. And, you know, you can change up minus
196
00:22:41,119 --> 00:22:48,719
print statement there and it would output the answer. Now, later
197
00:22:48,720 --> 00:22:55,360
going to also talk about converting that output. If it was a weird
198
00:22:55,359 --> 00:23:00,639
number, but we'll get to that. So you can do this, but even also
199
00:23:00,640 --> 00:23:06,880
if you wanted to, instead of print and you don't need the
200
00:23:06,880 --> 00:23:13,760
there, you can store them as a variable. So if you had something
201
00:23:13,759 --> 00:23:20,000
variable and then use that later on, or any one of these, you
202
00:23:20,000 --> 00:23:26,160
as a variable, because some of these, like two thirds, that will
203
00:23:26,160 --> 00:23:32,400
mixed number, or the one and two thirds that will come out as that
204
00:23:33,599 --> 00:23:38,719
later on, you might want to keep as many of those decimal places
205
00:23:38,720 --> 00:23:43,519
it as a variable will do that for you without you having to write
206
00:23:43,519 --> 00:23:47,759
So really, that's the whole thing. We're trying to build, you
207
00:23:47,759 --> 00:23:53,039
you might use a calculator. Hey, might as well use Google CoLab
208
00:23:53,039 --> 00:23:59,839
formulas in there, store variables and everything. So for all the
209
00:23:59,839 --> 00:24:04,879
work with mixed numbers. Yeah. Print it out, store it as a
210
00:24:05,440 --> 00:24:10,240
work with the rest of the problem. So if this comes out as a
211
00:24:10,240 --> 00:24:17,120
let's take a look at one other thing here. If this comes out, so
212
00:24:17,119 --> 00:24:24,479
one and two thirds. So we know the one, but if I look at the two
213
00:24:25,119 --> 00:24:34,159
you know, 0.6 and it keeps repeating. You know, it'll keep
214
00:24:34,160 --> 00:24:40,160
how would you know that that would be two thirds? Well, one of the
215
00:24:40,160 --> 00:24:46,240
throw in some other variables here. Let's call, let's call this X.
216
00:24:46,240 --> 00:24:55,279
decimals. So if it repeats each, um, each place, then I just need
217
00:25:00,880 --> 00:25:07,760
You see, and that keeps going because if this keeps going and then
218
00:25:07,759 --> 00:25:22,079
if I subtract them 10 X minus one X, so that would be nine X
219
00:25:22,079 --> 00:25:30,559
it, but I am subtracting this bottom row minus the top row because
220
00:25:30,559 --> 00:25:39,279
line up and it would subtract. So multiplying it by 10 moves it
221
00:25:39,279 --> 00:25:49,440
and when I subtract 10 X minus one X is nine X, then that all
222
00:25:49,440 --> 00:25:57,680
how do I get to X divide both sides by nine? So we get six over
223
00:25:57,680 --> 00:26:06,480
we can reduce divided by three is two divided by three is three.
224
00:26:06,480 --> 00:26:17,360
any single digit that repeats is a factor of nine. So if I have,
225
00:26:17,359 --> 00:26:23,919
and actually I might use the same, same formula, but if I have
226
00:26:23,920 --> 00:26:34,080
um, point four and it's a four that keeps repeating. So then 10
227
00:26:34,720 --> 00:26:42,640
and as many fours as you want. So then when we subtract 10 X minus
228
00:26:42,640 --> 00:26:50,960
I subtract this, everything after the decimal subtracts. And so
229
00:26:50,960 --> 00:27:00,960
by nine X equals four over nine. Now, so this works for any number
230
00:27:01,599 --> 00:27:08,719
but this is kind of interesting then, um, how, what if you get a
231
00:27:08,720 --> 00:27:19,440
Because would that be then nine over nine? Yes, maybe. So if I
232
00:27:22,319 --> 00:27:27,200
and so then 10 times that would be nine point and as many nines as
233
00:27:28,160 --> 00:27:36,160
we'll do the same thing. So nine X equals, so you see if this is
234
00:27:36,160 --> 00:27:40,880
this still follows 10 times that. And then when we subtract
235
00:27:44,240 --> 00:27:49,759
it all lines up, it becomes nine X equals nine over nine, which is
236
00:27:51,039 --> 00:27:58,240
So you see some algebra acrobatics. How do I show that point nine,
237
00:27:58,960 --> 00:28:03,680
And these are kind of the things that we want to bring in. Um,
238
00:28:03,680 --> 00:28:09,120
can do, you know, this works out nicely just seeing it on the
239
00:28:09,119 --> 00:28:13,759
different things to convert decimals to fractions, you can see
240
00:28:14,799 --> 00:28:18,240
But yeah, some math acrobatics, this is kind of what we want to be
241
00:28:18,240 --> 00:28:22,400
We want to also sometimes use the code to show different ways to
242
00:28:22,960 --> 00:28:27,200
And when we see it get to a solution in different ways, it kind of
243
00:28:27,839 --> 00:28:30,879
reproves, Hey, this works. This is the true solution.
244
00:28:30,880 --> 00:28:37,280
So these are some of the things that we can do, um, with
245
00:28:39,039 --> 00:28:43,839
you know, some of the other things we'll do, we, you know, we
246
00:28:44,960 --> 00:28:47,200
convert converting, uh, money like.
247
00:28:51,279 --> 00:28:59,119
Yeah. So if I have, you know, let's say, um, you know, one U S
248
00:28:59,119 --> 00:29:08,719
I just looked this up. It's 1.29 Canadian dollars. So if I want to
249
00:29:08,720 --> 00:29:16,640
ratio and proportion as long as you know, I know one of these, so
250
00:29:16,640 --> 00:29:20,160
And then as long as I know one of these, I can figure out the
251
00:29:21,359 --> 00:29:26,959
And in the code, you remember, we just add it, whichever one I
252
00:29:26,960 --> 00:29:34,559
I put a zero there because either way zero over anything is zero.
253
00:29:34,559 --> 00:29:39,440
You know, the zero in the numerator, the answer is zero and zero
254
00:29:39,440 --> 00:29:46,799
undefined. You know, you could look up different, uh, images of
255
00:29:47,440 --> 00:29:50,799
things like going into the abyss and all kinds of fun things like
256
00:29:50,799 --> 00:29:57,759
But yeah, we don't want to divide by zero. So if I know one of
257
00:29:57,759 --> 00:30:03,440
zero, that just really would, we would never arrive at that
258
00:30:03,440 --> 00:30:08,880
that that's why we would put a zero in for the one we want to
259
00:30:08,880 --> 00:30:13,440
have it set up, you know, then I can figure out, oh, okay. Well,
260
00:30:14,799 --> 00:30:20,480
um, how many, I'll put the question mark here since we're not in
261
00:30:20,480 --> 00:30:26,880
okay, if one U S is 1.29 Canadian, then what's one Canadian hour
262
00:30:26,880 --> 00:30:33,120
multiply divide by 1.29 and you'll get that exchange rate. So
263
00:30:33,920 --> 00:30:39,440
to this one, one U S to how many Canadian, we can change it to one
264
00:30:40,559 --> 00:30:44,720
you know, cause very often you find exchange rates and they'll
265
00:30:44,720 --> 00:30:48,640
And maybe you want to find it in the other direction. So these are
266
00:30:48,640 --> 00:30:55,600
use this for. We can also do things like miles to kilometers or,
267
00:30:56,400 --> 00:31:00,880
you know, other unit conversion you want, but you know, if you
268
00:31:03,039 --> 00:31:12,000
is 1.6 kilometers, um, it's that exactly 1.6, you know, there's
269
00:31:12,000 --> 00:31:17,680
another nine meters or something, but okay. And then there we go.
270
00:31:17,680 --> 00:31:27,920
then as long as I have miles and I have kilometers, then it'll
271
00:31:27,920 --> 00:31:32,720
put that in the code. So now that you have these tools, you can
272
00:31:32,720 --> 00:31:40,720
have that ratio of one aspect of it, then you can, you know, plug
273
00:31:40,720 --> 00:31:46,480
figure out the other. So, you know, here, you know, some, some of
274
00:31:46,480 --> 00:31:50,880
of the things we want to do in the extra practice section. You'll
275
00:31:51,599 --> 00:31:56,639
that, you know, we're going to get to the core, um, core skills in
276
00:31:56,640 --> 00:32:04,080
your ongoing, uh, CoLab notebook. So you have some resources and
277
00:32:04,880 --> 00:32:11,280
um, extra practice, extra problem section where we then use some
278
00:32:11,279 --> 00:32:17,039
and let's apply this and let's solve a bunch of extra problems. So
279
00:32:18,559 --> 00:32:21,519
and we will, uh, we'll go on to the next unit.
280
00:32:25,839 --> 00:32:30,000
Here, we're going to look at four different ways to solve for the
281
00:32:30,559 --> 00:32:37,119
And in algebra, we often call this X just because X works nicely,
282
00:32:37,119 --> 00:32:43,919
if I have, I had to put four different situations here, add,
283
00:32:43,920 --> 00:32:49,519
simple numbers because you might be able to do this in your head
284
00:32:50,240 --> 00:32:57,599
explanation is you want to see what you're doing and do the
285
00:32:57,599 --> 00:33:04,480
are equal, both sides of the equal sign, if you do the same thing
286
00:33:04,480 --> 00:33:10,720
So that works. What am I doing? I want to do the opposite to
287
00:33:10,720 --> 00:33:14,799
is do the same thing to both sides of the equal sign. I'm going to
288
00:33:16,000 --> 00:33:23,279
algebra operations here. So if we have X plus three equals five,
289
00:33:23,279 --> 00:33:31,519
the goal is that I get X equals something. So I would like that X
290
00:33:31,519 --> 00:33:35,839
on the left side of the equal sign. So what am I doing? I'm adding
291
00:33:35,839 --> 00:33:42,159
opposite, subtract three, and then I'm going to do the same thing
292
00:33:42,160 --> 00:33:49,120
three is zero. I don't have to write plus zero. Five minus three
293
00:33:50,079 --> 00:33:55,759
So it's like Sherlock Holmes eliminating possibilities, and then
294
00:33:55,759 --> 00:34:02,960
So the next one, if I'm subtracting, I'm going to do the opposite.
295
00:34:02,960 --> 00:34:10,559
something. So X minus two, if I add two, that cancels. That's why
296
00:34:10,559 --> 00:34:17,360
same thing to the other side. So negative two plus two is zero.
297
00:34:17,360 --> 00:34:25,840
Have to write plus zero. And then 10 plus two is 12. There we go,
298
00:34:25,840 --> 00:34:33,360
very similar. Also notice in writing math, most textbooks, you
299
00:34:33,360 --> 00:34:38,160
see a multiplication symbol at some point. Just the fact that
300
00:34:38,159 --> 00:34:42,559
that I'm multiplying. Now we have to remember this in Python
301
00:34:42,559 --> 00:34:51,759
multiplication symbol. But here three X means three times X. So to
302
00:34:51,760 --> 00:34:56,080
so I have to want to divide. And notice I'm going to write that
303
00:34:56,880 --> 00:35:01,920
and then divided by three here. Now here's something else about
304
00:35:01,920 --> 00:35:09,119
by three is one, but I don't have to put one X. You could, but you
305
00:35:09,119 --> 00:35:13,920
you won't see it. One X. Any other number there, I'd have to write
306
00:35:14,880 --> 00:35:23,200
we often don't write that. So then 12 divided by three is four.
307
00:35:23,199 --> 00:35:29,839
Somehow, whatever I teach this, everybody's like, get it, get it,
308
00:35:29,840 --> 00:35:35,039
thing. I'm dividing. So I'm going to do the opposite, which is
309
00:35:35,039 --> 00:35:40,239
I might write it, how can I write multiplied by four? I might even
310
00:35:41,280 --> 00:35:47,120
just saying it's next to that, so that means I'm multiplying.
311
00:35:47,119 --> 00:35:55,839
I'll put in parentheses. So divided by four times four cancels
312
00:35:55,840 --> 00:36:06,079
X. And then here, two times four is eight. So with some simple
313
00:36:06,079 --> 00:36:12,400
add, subtract, multiply, and divide. And the key is no matter what
314
00:36:14,159 --> 00:36:17,839
what else you encounter, how complicated the numbers are, it's the
315
00:36:17,840 --> 00:36:23,680
So we recognize this method, then whatever number comes up, then
316
00:36:23,679 --> 00:36:35,919
this I can do in my head, but supposing I have instead of X plus
317
00:36:37,519 --> 00:36:48,000
7.2 equals 11.1 or something like that. So supposing I have
318
00:36:48,000 --> 00:36:55,280
how could I solve it? Oh, I have an algebra method. What am I
319
00:36:55,280 --> 00:37:04,640
in this case, 7.2 from both sides. And so then I get X equals, and
320
00:37:04,639 --> 00:37:12,000
complicated, I know what I'm doing on the calculator. I'm
321
00:37:12,000 --> 00:37:20,159
and then I know what I'm doing on the calculator. There we go. So
322
00:37:21,760 --> 00:37:29,760
anytime I have a two-step equation. And in the two-step equations,
323
00:37:31,679 --> 00:37:37,519
order of operations in reverse, because the addition is the
324
00:37:37,519 --> 00:37:49,840
like 4X plus 6 equals 22, so two steps, I'm still going to combine
325
00:37:49,840 --> 00:37:54,640
we were talking about. I'm just going to do one than the other.
326
00:37:54,639 --> 00:37:59,199
Like I said, like order of operations in reverse, the addition or
327
00:37:59,199 --> 00:38:08,000
easiest to do first. If I then subtract 6 from both sides, so if I
328
00:38:08,000 --> 00:38:20,320
I have 4X equals 16. And now I get to my second step, divide by 4,
329
00:38:20,320 --> 00:38:30,640
divide by 4, then I get X equals 4. So we have our two-step
330
00:38:30,639 --> 00:38:36,000
are, you're going to get quick enough at this that it's not even
331
00:38:36,000 --> 00:38:42,559
or anything to solve this. But some of these, as they get more
332
00:38:42,559 --> 00:38:48,880
there's other factoring and more elaborate problems, then it would
333
00:38:48,880 --> 00:38:57,280
because I'll show you now how we can just put this in Python,
334
00:38:57,280 --> 00:39:03,120
and it'll output the answer. So let's take a look at the code. So
335
00:39:04,559 --> 00:39:12,239
solve for X in Python because we can just import the Sympy library
336
00:39:12,239 --> 00:39:15,759
math library. You don't have to install anything. You can just
337
00:39:15,760 --> 00:39:20,480
Google Colab works nicely behind the scenes like that. And then
338
00:39:20,480 --> 00:39:28,320
symbols. And from Sympy.solvers, we're going to import solve. So
339
00:39:28,320 --> 00:39:35,440
X as a math symbol and solve for that. And solve is going to be
340
00:39:35,440 --> 00:39:41,599
then I'll define X equals symbols X. And that's defining that X is
341
00:39:41,599 --> 00:39:48,480
I just put this comment here. But then the next thing we have, I
342
00:39:48,480 --> 00:39:57,519
equals X minus two. And this is the function set equal to zero. So
343
00:39:57,519 --> 00:40:02,159
is what we're solving for. And then that's the equation. So then I
344
00:40:02,159 --> 00:40:11,759
statement, print X equals, and Python syntax, then print that
345
00:40:11,760 --> 00:40:19,120
And here's where we see solve eq, the equation, and use X as the
346
00:40:19,119 --> 00:40:26,319
So we're going to solve that X minus two equals zero. And you see
347
00:40:26,320 --> 00:40:31,039
It'll print an array of whatever your answer is. This just had one
348
00:40:31,760 --> 00:40:42,640
But if I had something like X, X squared, X squared minus two, now
349
00:40:42,639 --> 00:40:49,839
answer. Kind of interesting how that'll show up. You see square
350
00:40:49,840 --> 00:40:57,039
make that a decimal. But if we make this something that works out
351
00:40:57,039 --> 00:41:03,599
that, see it'll give me an array of my two answers. X squared
352
00:41:03,599 --> 00:41:10,400
equation. And negative two or positive two, either one works. And
353
00:41:10,400 --> 00:41:20,160
something like two X, I can't just write two X. I have to put, I
354
00:41:20,960 --> 00:41:28,559
that's Python syntax. Two X minus four. And then if we run that,
355
00:41:30,239 --> 00:41:36,639
There we go. Much easier. And all this stays the same. You just
356
00:41:36,639 --> 00:41:42,799
run it, and you can solve anything. Just make sure it's that
357
00:41:47,360 --> 00:41:52,480
Now that we've worked through the core skills in this unit, let's
358
00:41:52,480 --> 00:41:58,079
And I'm going to work through extra problems using the Colab
359
00:41:58,079 --> 00:42:04,319
you can apply these resources that you're building, and use these
360
00:42:04,320 --> 00:42:10,880
You can use these to solve problems that might come up in a
361
00:42:10,880 --> 00:42:15,360
So we're going to go through some more extra problems here. All
362
00:42:15,360 --> 00:42:24,000
bit deeper, looking at different ways we can solve for X here,
363
00:42:24,559 --> 00:42:30,320
code that we were talking about before. So we import Sympy, so we
364
00:42:30,320 --> 00:42:37,680
and then we're still from Sympy, import symbols, and some
365
00:42:37,679 --> 00:42:45,279
to define that symbol X. And this is the simplest thing. We can
366
00:42:45,280 --> 00:42:53,200
just put my equation right here. Here's my equation. And then I
367
00:42:53,199 --> 00:42:57,919
and I'm solving for X. Notice I don't even really need a print
368
00:42:57,920 --> 00:43:07,119
function is the last thing there. And then when we run it, we see
369
00:43:07,119 --> 00:43:14,639
half. And notice the brackets around it, because it's a finite
370
00:43:15,679 --> 00:43:24,399
And if I have something that solves for even, you know, something
371
00:43:24,400 --> 00:43:35,519
plus 1. Now this is setting this equal to zero. So 2X squared plus
372
00:43:35,519 --> 00:43:43,519
solution. We can actually take a look at that. And you see the
373
00:43:43,519 --> 00:43:52,159
and that is I, the imaginary number. So it will give us this.
374
00:43:52,159 --> 00:43:58,159
square root display in a better way, but we'll get to that later.
375
00:43:58,159 --> 00:44:05,679
you know, it gives us two solutions as this finite set of these
376
00:44:05,679 --> 00:44:14,960
you know, minus 1, or I can even make it minus, you know, 4, we'll
377
00:44:14,960 --> 00:44:19,360
But there's still going to be square root solutions. There we go.
378
00:44:19,360 --> 00:44:25,360
will output. But you get this. You can put the equation in there
379
00:44:25,920 --> 00:44:33,599
pretty much anything you can type in there. All right. But let's
380
00:44:33,599 --> 00:44:42,079
fancier. What if we prompt for input? So let's say I want this to
381
00:44:42,639 --> 00:44:47,359
rather than somebody going in and finding that correct line and
382
00:44:47,360 --> 00:44:57,680
we can just prompt for the input here. And notice the function is
383
00:44:57,679 --> 00:45:05,839
display this. Enter equation. And I even have it as zero equals to
384
00:45:05,840 --> 00:45:10,640
equal to zero. You could add another print statement saying make
385
00:45:10,639 --> 00:45:19,920
you know, if that's what you'd like. And this input does come in
386
00:45:19,920 --> 00:45:27,200
are using these symbols, it will be able to interpret that. And
387
00:45:28,559 --> 00:45:36,400
and just putting that into a print statement. There we go. So we
388
00:45:36,400 --> 00:45:51,440
the equation. And maybe I just make it three x minus six. How
389
00:45:51,440 --> 00:46:01,039
good. One solution. Three x minus six, because if x is two, then
390
00:46:01,039 --> 00:46:08,000
But again, if, you know, I have multiple solutions, or maybe if I
391
00:46:08,000 --> 00:46:14,159
maybe I want it to be a little bit fancier. So, again, this solve
392
00:46:14,639 --> 00:46:20,719
so we can do more. All right, we're going to import all the rest
393
00:46:20,719 --> 00:46:28,000
knowing that it's a finite set, I'm going to store that answer as
394
00:46:28,000 --> 00:46:34,159
And then this particular equation, I know this has one solution,
395
00:46:34,159 --> 00:46:40,239
display solution index zero. And that's going to be the first
396
00:46:40,239 --> 00:46:48,639
to be the only solution. So when we run it, there we go. And
397
00:46:48,639 --> 00:46:54,159
it a little bit nicer output, just like having that nice user
398
00:46:54,159 --> 00:47:02,000
having it display zero equals and then waiting for the prompt. So,
399
00:47:02,000 --> 00:47:11,199
do this. And, you know, here's saving this. Okay, that's great.
400
00:47:13,039 --> 00:47:20,239
And what if I don't know how many answers I'll have? So I'm going
401
00:47:20,239 --> 00:47:26,399
so if I enter the solution, now, maybe I'll just put the first one
402
00:47:26,400 --> 00:47:32,720
this one next soon enough. So I'll just take the same solution
403
00:47:33,840 --> 00:47:39,360
And just like we were doing before, I'm going to solve it and
404
00:47:40,320 --> 00:47:43,840
notice my loop here and Python has this great
405
00:47:43,840 --> 00:47:56,160
method of iterating through everything in that list. So for S in
406
00:47:56,719 --> 00:48:01,119
item in that solution set, whether it be one, whether it be
407
00:48:02,159 --> 00:48:07,920
it'll iterate through that. So S is that solution. And then it'll
408
00:48:07,920 --> 00:48:14,240
And each time, I'm just going to print x equals, and then I'm
409
00:48:14,239 --> 00:48:23,199
we make use of the Python shortcuts. There we go. So 2x minus 4,
410
00:48:23,199 --> 00:48:31,759
through and did this. So what if I have something like something
411
00:48:31,760 --> 00:48:42,880
what if I have something like something that has multiple
412
00:48:42,880 --> 00:48:52,000
want to prompt for this. All right. So what if I just plug in
413
00:48:53,360 --> 00:48:58,640
I know is going to have three solutions, because the three
414
00:48:58,639 --> 00:49:06,239
So let's see what this does. Again, loops through, and it will
415
00:49:07,679 --> 00:49:14,480
So we see we're building some of these things behind the scenes
416
00:49:14,480 --> 00:49:22,000
solutions and output it in a nice way. So we see, you know, if
417
00:49:22,000 --> 00:49:27,840
you're going to use, this is the one to do it. Because, you know,
418
00:49:27,840 --> 00:49:38,240
you take out this, this was my demonstration. But there we go. And
419
00:49:38,239 --> 00:49:45,839
So this could be your code. And that will work for anything,
420
00:49:45,840 --> 00:49:50,640
you or you or anybody else using this to enter the enter the
421
00:49:50,639 --> 00:49:57,599
we're building some tools here that we can use to solve. All
422
00:49:57,599 --> 00:50:04,639
Now, some interesting things. We're also this time, we're going to
423
00:50:04,639 --> 00:50:12,239
and we're going to use x, y, but we'll come back to the y. And we
424
00:50:12,239 --> 00:50:16,799
because you can use this for multiple equations, but I just call
425
00:50:16,800 --> 00:50:22,080
two x plus 10. All right. Now, we know that this is set equal to
426
00:50:22,079 --> 00:50:29,679
the go-to way of doing this. But then this simpy syntax, we're
427
00:50:29,679 --> 00:50:39,279
define it. EQ first, comma zero, saying that this is set equal to
428
00:50:40,800 --> 00:50:44,800
for x. That's great. And this solution I just called sol.
429
00:50:44,800 --> 00:50:51,760
And since I have this one, I know that the solution is, you know,
430
00:50:51,760 --> 00:50:58,400
just put salt. You know, that's my finite set. And I want the
431
00:50:58,400 --> 00:51:04,240
actually, these are factored results, but this is actually going
432
00:51:04,239 --> 00:51:11,679
because I can get that answer. X is negative five. All right. Now,
433
00:51:11,679 --> 00:51:22,079
Now, I have to have y there. If I define y as a variable. Now,
434
00:51:23,039 --> 00:51:32,320
this is equal to y. And you see that works. So spelling it out
435
00:51:32,320 --> 00:51:41,680
But now I now I'll solve for x. So that's kind of interesting. And
436
00:51:42,639 --> 00:51:48,319
Python could actually do some of this factoring for you. You know,
437
00:51:48,320 --> 00:51:58,720
algebraically. So now it's solved. Why over two minus five. Pretty
438
00:51:58,719 --> 00:52:08,719
like that. We can rearrange things. And then if I have this, you
439
00:52:08,719 --> 00:52:14,719
around a little bit or whatever. But some different things you can
440
00:52:14,719 --> 00:52:20,719
to zero. Make this equal to zero. But this gives you this other
441
00:52:20,719 --> 00:52:30,480
to y. And then you can do some other things you can solve for it.
442
00:52:30,480 --> 00:52:35,679
as you incorporate this into, you know, some of the notebooks that
443
00:52:35,679 --> 00:52:40,079
around with this and, you know, try some different things. You
444
00:52:40,079 --> 00:52:46,960
some different some different formulas or different equations in a
445
00:52:46,960 --> 00:52:52,639
try this? Like, we could take a look at this and say, all right,
446
00:52:52,639 --> 00:53:04,639
what about if I have two x, then, then if I want to solve it for
447
00:53:04,639 --> 00:53:13,039
So there we go. And if that's included in y, then I still might
448
00:53:13,039 --> 00:53:21,759
this is equal to zero, because that's kind of the default way for
449
00:53:21,760 --> 00:53:30,400
back and solve for x, and it should end up being very similar.
450
00:53:30,400 --> 00:53:40,079
do something very similar, because whether that was, you know,
451
00:53:40,079 --> 00:53:45,119
it's equal to y or with this minus y saying it's equal to zero,
452
00:53:46,719 --> 00:53:58,079
And, you know, we could even just to show you, we can even say
453
00:53:58,079 --> 00:54:04,239
this. There we go, x is y over two, all kinds of different things
454
00:54:04,239 --> 00:54:11,759
rearrange this, you can put that in this setup here. And then, you
455
00:54:11,760 --> 00:54:20,960
set equal to now? And what am I solving for here? And in this
456
00:54:20,960 --> 00:54:27,039
zero for that solution set each time. So these are some cool
457
00:54:27,039 --> 00:54:32,639
the factoring for you. Well, here's some other factoring.
458
00:54:32,639 --> 00:54:41,119
you know, we can divide out common factors. Now, you might see
459
00:54:42,159 --> 00:54:51,440
ten times y, plus four. Now, supposing this is another thing in
460
00:54:51,440 --> 00:54:55,760
You know, I'm not saying that's equal to zero or anything. I just
461
00:54:55,760 --> 00:55:03,200
I don't want to factor it. Look at that. And SymPy also does the
462
00:55:04,320 --> 00:55:11,920
So you see, there was a common factor of two. And that worked.
463
00:55:11,920 --> 00:55:18,960
and let's say this is three, which then doesn't factor at all. So
464
00:55:18,960 --> 00:55:25,760
you know, it will just output that because it's not factorable.
465
00:55:25,760 --> 00:55:43,760
interesting is if I have something else, like x squared, and let's
466
00:55:43,760 --> 00:55:47,760
you may or may not be familiar with that factoring, but I can
467
00:55:48,480 --> 00:55:53,280
I look at that. It'll factor that out. That's the correct
468
00:55:54,480 --> 00:56:02,320
So it will do a lot of really interesting factoring for you. So
469
00:56:05,360 --> 00:56:09,360
we can, you know, just to show you that we can even take it to the
470
00:56:09,360 --> 00:56:17,760
X to the third minus two x squared minus five x plus six. So we
471
00:56:19,440 --> 00:56:27,119
there we go. Look at that. It breaks it down into these factors.
472
00:56:27,119 --> 00:56:37,759
you know, knowing that you can set your factoring, you know, you
473
00:56:37,760 --> 00:56:45,840
factoring, you can make your own factoring calculator here. All
474
00:56:45,840 --> 00:56:52,720
at some of the functions here. So when we have, you know, we have
475
00:56:53,519 --> 00:56:59,280
you've been doing some of this practice with these functions. So I
476
00:56:59,280 --> 00:57:07,760
you know, looking at these and this different input, how we can,
477
00:57:07,760 --> 00:57:11,600
you know, remember you were doing the practicing the one step
478
00:57:13,679 --> 00:57:22,239
the one step addition, one step multiply. There we go. Now, that
479
00:57:22,239 --> 00:57:31,359
is because you can't do string to a fraction. This print, this
480
00:57:31,360 --> 00:57:38,640
we take this input, now other inputs, if it's actually a number or
481
00:57:38,639 --> 00:57:44,719
and you can cast it as a float. So that's a number that could
482
00:57:44,719 --> 00:57:52,319
it's going to be a fraction, this float won't work because that
483
00:57:52,320 --> 00:57:58,559
parse nicely. So then this will give an error. Now, just because
484
00:57:58,559 --> 00:58:04,400
just a display. If I just disobeyed that and put in a number, then
485
00:58:04,400 --> 00:58:10,079
But if I, as soon as they use that divided by, I need that. So
486
00:58:10,079 --> 00:58:19,679
is how do I convert the string input, including fractions to a
487
00:58:19,679 --> 00:58:26,319
functions work. I'm going to use this DEF to define it. And then
488
00:58:28,320 --> 00:58:33,920
I give it the name of the function. I need the open and closed
489
00:58:33,920 --> 00:58:40,480
and this particular one will also have input. So I define this
490
00:58:40,480 --> 00:58:45,760
That's going to be the input and then colon at the end. So once I
491
00:58:47,440 --> 00:58:56,320
then everything under this is indented for spaces. Yep. And I
492
00:58:56,320 --> 00:59:05,120
use indentations. So then I have an if statement and if, and then
493
00:59:05,119 --> 00:59:15,039
is true, colon, and then that's indented for spaces. Okay. So I
494
00:59:15,760 --> 00:59:25,040
and I'm testing to see if this fraction bar is in there. And
495
00:59:25,039 --> 00:59:33,759
in string, cause that's what I called it. That's my input. If it's
496
00:59:35,199 --> 00:59:45,199
Each string has this split function. So you can split it and say,
497
00:59:45,199 --> 00:59:51,119
I'm going to split it. And then that creates two different arrays.
498
00:59:51,119 --> 00:59:58,079
input. So it's going to be two string arrays or two or one array
499
00:59:58,079 --> 01:00:06,079
going to be ND. I call that for numerator denominator. So then ND
500
01:00:06,079 --> 01:00:15,519
everything before that. And ND one is going to be everything after
501
01:00:15,519 --> 01:00:22,800
if somebody put a fraction in there, then ND zero, everything
502
01:00:22,800 --> 01:00:30,000
So I'll cast it as a float, store it as N for the numerator. And
503
01:00:30,000 --> 01:00:38,480
that. So I will cast it as a float, store it as D for denominator.
504
01:00:38,480 --> 01:00:46,400
we had to detect that split that string. And then each of these
505
01:00:46,400 --> 01:00:55,920
them as float numbers. And now these are numbers N and D. And now
506
01:00:55,920 --> 01:01:04,880
N divided by D. So you see, because that slash doesn't work for
507
01:01:04,880 --> 01:01:13,200
like work around it. And now I have ANS as this answer. And then I
508
01:01:13,199 --> 01:01:18,480
this, this function doesn't have a print statement, just returns
509
01:01:18,480 --> 01:01:23,599
comes up. But it just, you know, wherever this function is, it'll
510
01:01:24,800 --> 01:01:30,000
So that's if it has that. And if it doesn't, because I want to be
511
01:01:30,000 --> 01:01:38,400
either way. So anything else, colon, indent, then I won't have a
512
01:01:38,400 --> 01:01:46,480
in string cast as a float. That works. So anything else you put
513
01:01:46,480 --> 01:01:58,159
return ANS. Now, where this comes in, I'll come back to that one,
514
01:01:58,159 --> 01:02:05,199
So here's this function, one step more. And I put this common in
515
01:02:05,199 --> 01:02:11,199
else using this, that it uses this function. So we need to make
516
01:02:12,239 --> 01:02:18,639
All right, so here's, here's the idea to generate, you know, some
517
01:02:18,639 --> 01:02:26,319
random. And then here, I'm going to get random dot Rand int from
518
01:02:26,320 --> 01:02:32,559
a random integer, and I'll store it as variable A. So that's going
519
01:02:34,159 --> 01:02:40,239
including one, but not including 11. So one could show up, 10
520
01:02:40,800 --> 01:02:44,640
So that's, that's the way the random integer works. It includes
521
01:02:44,639 --> 01:02:53,119
And then B, I just wanted to make this two to 24. So given these
522
01:02:53,119 --> 01:03:02,719
notice what we're going to print here. So AX equals B. So we see
523
01:03:03,440 --> 01:03:07,920
times X. And I just want to display this. So I didn't need to
524
01:03:09,119 --> 01:03:16,079
to show the multiplying. All right, so AX equals B. And then you
525
01:03:16,079 --> 01:03:25,440
You want to divide both sides by A. So you know that, and we're
526
01:03:26,239 --> 01:03:32,000
you know, X equals, and whatever your input is, we'll store it as
527
01:03:34,960 --> 01:03:40,880
And then the actual answer at this point is going to be, we know
528
01:03:40,880 --> 01:03:50,800
so the actual answer is going to be B divided by A. So then this
529
01:03:50,800 --> 01:03:58,160
still a string. And that's where we're going to use that in our
530
01:03:58,159 --> 01:04:05,920
string frack. So see, it's going to take that answer, run it
531
01:04:05,920 --> 01:04:11,760
run it through that function, and return right here, that answer.
532
01:04:13,519 --> 01:04:19,759
So that way we can easily compare it because this function will
533
01:04:19,760 --> 01:04:23,760
the double equal sign to compare, and we're going to compare it to
534
01:04:24,719 --> 01:04:27,119
So there we go. So that's the return statement, wherever I don't
535
01:04:28,000 --> 01:04:32,400
print or output anything, it just returns that value right here
536
01:04:32,400 --> 01:04:37,440
And if it's, if it is good, we're going to print correct. If not,
537
01:04:38,239 --> 01:04:44,719
but then print out the answer. So there we go. And now it'll loop
538
01:04:44,719 --> 01:04:49,119
it once, and then, you know, we can create a loop to have as many
539
01:04:49,119 --> 01:04:56,239
practice one-step equations. So there we go, and then test them
540
01:04:56,239 --> 01:05:05,519
And then test them each time. So, you know, we have the simplest
541
01:05:07,280 --> 01:05:12,640
is another very similar one. There we go, import random, display
542
01:05:14,079 --> 01:05:18,000
random integers, and yes, you can go through negative numbers if
543
01:05:18,000 --> 01:05:26,239
All right. And what are we printing out here? X plus A equals B,
544
01:05:26,960 --> 01:05:37,440
you know that to solve for X, subtract A. So we'll take your
545
01:05:38,000 --> 01:05:44,079
But also we're going to calculate exactly B minus A. What is it
546
01:05:44,079 --> 01:05:50,880
we don't need to do anything else. We just say, if A and S equals
547
01:05:51,760 --> 01:05:56,400
And here, see, we can cast the float, cast the input as a float
548
01:05:56,400 --> 01:06:05,360
expecting anything fancy. You see the other one, knowing that I'm
549
01:06:05,360 --> 01:06:12,400
to address all the other things that could come up. And there we
550
01:06:12,400 --> 01:06:18,960
If not, and then we print out the answer. Cool. So some different
551
01:06:18,960 --> 01:06:25,039
one-step addition with negative numbers, just we just did in a
552
01:06:25,039 --> 01:06:35,199
a bunch of things that we can do, just practicing your own ability
553
01:06:35,199 --> 01:06:42,159
more into some other functions later, but, you know, good to see
554
01:06:42,159 --> 01:06:52,399
yeah, here we go. Just some of the things you can do, factor or
555
01:06:52,400 --> 01:06:59,039
that you want to be able to do and, you know, set up, you know,
556
01:06:59,039 --> 01:07:06,159
your own CoLab notebook. So by now, you might have some things
557
01:07:06,159 --> 01:07:13,279
You might have some things to, you know, solve for X and, you
558
01:07:13,280 --> 01:07:18,800
those, you know, convert fraction input to something, you know,
559
01:07:18,800 --> 01:07:24,720
copy these, tweak them, make use of them on your own. And, you
560
01:07:24,719 --> 01:07:31,679
library as well as really understanding the code as you're
561
01:07:31,679 --> 01:07:36,000
your understanding of the math, understanding of the code gets
562
01:07:36,000 --> 01:07:48,880
here. All right, so I think we're ready to go on to the next unit.
563
01:07:48,880 --> 01:07:57,039
decimals and how to convert from one to the other. Well,
564
01:07:57,039 --> 01:08:03,840
could be one out of 10. If I say out of, that means divide. So any
565
01:08:03,840 --> 01:08:10,079
denominator, you can do that on your calculator and it most likely
566
01:08:10,079 --> 01:08:16,399
decimal. There you go. So fractions, decimals, you know, pretty
567
01:08:16,399 --> 01:08:23,039
you know, pretty easy. Calculator, do the division and then, you
568
01:08:23,039 --> 01:08:29,039
what about doing it in the reverse process? So when we look at
569
01:08:29,920 --> 01:08:36,800
one out of 10, I could call it one tenth or 0.1 is what you would
570
01:08:37,359 --> 01:08:43,119
I would still call that one tenth because that first decimal place
571
01:08:43,119 --> 01:08:50,640
be one tenth. Or then if I had one out of a hundred, then there we
572
01:08:50,640 --> 01:08:56,160
So tenths, the second one, the hundredths. So whether I write it
573
01:08:56,159 --> 01:09:02,079
I would still call it one hundredth with the th. Then, you know, I
574
01:09:02,079 --> 01:09:08,960
you know, third decimal is would be thousandths. So, and it would
575
01:09:08,960 --> 01:09:15,920
we have that, you know, tenths, hundredths, thousandths, then that
576
01:09:15,920 --> 01:09:25,039
if we want to convert it back the other way. So if I would, if I
577
01:09:26,880 --> 01:09:36,560
you know, 0.234, so something that I wanted to convert, then I
578
01:09:36,560 --> 01:09:45,520
hundredths, thousandths. That's where it ends. So then I could
579
01:09:47,840 --> 01:09:56,000
And I could reduce that, but that still is the fraction that I'm
580
01:09:56,000 --> 01:10:04,640
thousand. Or if I had something, you know, like 0.4 one place,
581
01:10:04,640 --> 01:10:10,160
four out of ten. And again, I could reduce it or I could leave it
582
01:10:10,159 --> 01:10:15,760
that that's converting my decimal right to a fraction. And when we
583
01:10:15,760 --> 01:10:22,000
we're going to look at how to see here. I'm just looking at this
584
01:10:22,000 --> 01:10:26,000
hundredths, thousandths, et cetera. It could keep going. You could
585
01:10:26,000 --> 01:10:31,920
but I'm looking at these remembering the place values and then
586
01:10:31,920 --> 01:10:38,960
have ten with one followed by three zeros, you know, one decimal
587
01:10:38,960 --> 01:10:42,399
one followed by one zero. And we get into the code, we're going to
588
01:10:43,119 --> 01:10:47,680
in a different way rather than just, well, there's a few ways you
589
01:10:47,680 --> 01:10:54,079
count how many places, or we're going to, you know, one of the
590
01:10:54,079 --> 01:10:58,960
logarithm way, probably the string and just counting it, that's
591
01:10:58,960 --> 01:11:06,319
straightforward. We'll do that one. But there we go. Converting
592
01:11:06,319 --> 01:11:12,319
and then, you know, how do I reduce it? Okay. So we think we have
593
01:11:14,159 --> 01:11:22,239
if I have a repeating decimal? So supposing I have 0.3333 and it
594
01:11:22,239 --> 01:11:29,920
And mathematically, if I was writing this, you put the line over
595
01:11:29,920 --> 01:11:34,720
So I really could just keep it as one, but I want to show you
596
01:11:34,720 --> 01:11:40,560
three. So that keeps repeating. Okay. So we were just talking
597
01:11:40,560 --> 01:11:46,080
places and then put it over that. But if it keeps repeating, where
598
01:11:46,079 --> 01:11:51,760
at a trick how to do this. We want to get to the end of the
599
01:11:51,760 --> 01:11:58,239
repeats once, then if I multiply this, let's, let me call this X
600
01:11:58,239 --> 01:12:04,159
this down a little bit further. This is, that's going to make
601
01:12:04,159 --> 01:12:16,800
X is my 0.3333 repeating. All right. So if that's my value, I only
602
01:12:16,800 --> 01:12:28,239
the decimal place once. And then that cancel out. So if I have 10
603
01:12:28,239 --> 01:12:34,960
And these keep repeating. Now, the reason I do that is because of
604
01:12:35,760 --> 01:12:40,159
everything that repeats now is going to line up. And so if I
605
01:12:40,159 --> 01:12:50,239
what can I do on the left? 10 X minus X is nine X equal sign still
606
01:12:50,239 --> 01:12:54,399
minus zero point, all this that cancels all this, however many
607
01:12:54,399 --> 01:13:01,439
it all cancels and my answer's three. And then one step of
608
01:13:01,439 --> 01:13:10,719
nine. So I get X equals three over nine because nine divided by
609
01:13:10,720 --> 01:13:18,480
three divided by nine. And I could reduce that as one third if I
610
01:13:18,479 --> 01:13:24,159
over nine, you know, that's nice, like bonus math insight. If I
611
01:13:24,159 --> 01:13:29,920
it's that number over nine. That's the fraction. So if I had four
612
01:13:29,920 --> 01:13:37,440
if I had four, if I had, you know, very similar type, type of
613
01:13:38,720 --> 01:13:46,560
something like, uh, if I had zero point four repeating, so then 10
614
01:13:46,560 --> 01:13:55,440
point or four, et cetera. They both keep repeating. Do the same
615
01:13:55,439 --> 01:14:01,679
And when I subtract these, all the repeating decimals cancel. So
616
01:14:01,680 --> 01:14:07,680
four is exactly four. And when I divide both sides by nine, X
617
01:14:10,880 --> 01:14:19,600
So there we go. And, uh, so one more bonus here. If I had nine
618
01:14:19,600 --> 01:14:30,320
we could do the same thing. And you would think 0.999. That's not
619
01:14:30,319 --> 01:14:36,639
in calculus, we can look at limits and how 0.9 repeating. If it
620
01:14:36,640 --> 01:14:42,480
purposes, that is one. But if we did this, it would be nine's
621
01:14:42,479 --> 01:14:49,359
and you get X equals one. So it kind of works out nicely, but this
622
01:14:49,359 --> 01:14:55,359
You know, notice we're not looking at code here. Now we're just
623
01:14:55,359 --> 01:15:01,439
something that repeats, then that's what we need to do. We need to
624
01:15:01,439 --> 01:15:08,239
had something that repeated, um, you know, three, two, two places
625
01:15:08,239 --> 01:15:15,039
that one. And just to give you an idea of a different way, if I
626
01:15:15,840 --> 01:15:29,600
then if I have, uh, so X equals, uh, 0.090909, something like
627
01:15:29,600 --> 01:15:39,760
it's the zero nine that repeats. So I need to multiply it by a
628
01:15:39,760 --> 01:15:50,960
X because that would move the decimal place twice and that makes
629
01:15:50,960 --> 01:16:01,199
So when I do that now, same method, if I subtract these, that's 99
630
01:16:01,199 --> 01:16:13,199
cancels. So then X equals 99, uh, nine over 99 and fine, perfectly
631
01:16:13,199 --> 01:16:20,880
reduce this divided by nine. So that's one out of 11. We'll get
632
01:16:20,880 --> 01:16:26,800
code for that too, but you see, this is, this is one way. If you
633
01:16:26,800 --> 01:16:33,279
maybe you're right the way you write the code, it might seem to
634
01:16:33,279 --> 01:16:38,159
you don't find some way around it, this is the way around it. So
635
01:16:38,159 --> 01:16:43,439
decimal, but now we're going to, what we're going to do is we're
636
01:16:43,439 --> 01:16:50,079
to take any decimal. Just here's the decimal input. How can I find
637
01:16:50,079 --> 01:16:56,640
is and reframe that as a fraction so that given the decimal and
638
01:16:57,439 --> 01:17:05,119
related to that is percents because remember the first is 10th
639
01:17:05,119 --> 01:17:12,079
are the hundredths and that's really what percent means out of a
640
01:17:12,079 --> 01:17:16,880
thing. And then just, I'm always looking at the first two decimal
641
01:17:17,840 --> 01:17:22,800
So, you know, very similar, but just the first two decimal places.
642
01:17:22,800 --> 01:17:30,560
and we'll see how to convert any decimal to a fraction. All right.
643
01:17:30,560 --> 01:17:37,600
convert decimals to fractions with code. And first we'll get some
644
01:17:37,600 --> 01:17:43,360
going to be useful. So if I have 10 two different exponents, let's
645
01:17:43,359 --> 01:17:51,920
exponents. So 10 to the first power, we see this first one, 10 to
646
01:17:51,920 --> 01:17:57,119
10 to the third. We'll see these come up. What happens when we
647
01:17:57,119 --> 01:18:03,039
10 or anything else to the zero exponent, and then we'll take a
648
01:18:03,680 --> 01:18:09,200
or negative two or negative three. So this will just print these
649
01:18:09,840 --> 01:18:19,440
what this does. So we see 10 to the first, second, or third
650
01:18:19,439 --> 01:18:31,759
to the zero is 1. And then the negative exponents are how many
651
01:18:33,119 --> 01:18:40,640
So these are the things we're looking for and we're going to make
652
01:18:40,640 --> 01:18:48,960
our decimals to fractions. So the next thing, we'll take a look at
653
01:18:50,000 --> 01:18:58,239
And we have this formula here, user input, open parentheses, and
654
01:18:58,239 --> 01:19:04,079
will display. And then you'll see then a box, you know, then
655
01:19:04,079 --> 01:19:11,600
going to store that as text as that's the variable. For our
656
01:19:11,600 --> 01:19:17,039
you that you can enter a number and we're going to print it out. I
657
01:19:17,039 --> 01:19:22,880
to remind you it comes in as a string. We can't do any math with
658
01:19:22,880 --> 01:19:29,920
do, any string, I can figure out the length of that string. So
659
01:19:29,920 --> 01:19:34,640
And I just have, again, this comment here, if I tried to do math
660
01:19:34,640 --> 01:19:41,680
error. So let's take a look. So you see, enter a number. And then
661
01:19:41,680 --> 01:19:52,159
like 0.123, I hit enter. You see 0.123, the length of it is four,
662
01:19:52,159 --> 01:20:00,399
these are four characters, the decimal point counts as one
663
01:20:00,399 --> 01:20:11,439
with this. So I, you know, if I wanted to enter a number, now, if
664
01:20:12,640 --> 01:20:21,200
now I can do math to it. And I can cast it as a float or an int
665
01:20:21,199 --> 01:20:26,399
mind, you know, things I might want to do with this, a float can
666
01:20:26,399 --> 01:20:32,399
usually my default cast. But, you know, if you definitely know
667
01:20:32,399 --> 01:20:37,039
we would use that. But we're going to enter a number, cast it as a
668
01:20:37,039 --> 01:20:44,399
the variable number num. Now I can do math to it. I'm going to
669
01:20:44,399 --> 01:20:55,920
There we go. If I enter a number, there we go. And if I have
670
01:20:55,920 --> 01:21:03,279
now I can add. All right, or whatever other math operation you
671
01:21:03,279 --> 01:21:09,679
an int, then you can do math to it. And the float, because it can
672
01:21:09,680 --> 01:21:15,200
operation that there might be a chance of a decimal use float.
673
01:21:15,199 --> 01:21:28,079
together. So converting this input, which will come in as a
674
01:21:28,560 --> 01:21:34,160
and here's what I'm going to print out. Enter a decimal number to
675
01:21:34,159 --> 01:21:38,319
that that's input and that's going to be stored as digits. And we
676
01:21:38,319 --> 01:21:44,799
And we know that that's going to be a string. So to get the number
677
01:21:45,359 --> 01:21:54,799
So I'm going to use this, the length of that input digits, and I'm
678
01:21:54,800 --> 01:22:03,119
first. So notice that happens first. Then I'm going to subtract
679
01:22:03,119 --> 01:22:09,199
that decimal point is going to count when I do the length of that
680
01:22:09,199 --> 01:22:15,199
because I don't want that decimal. So now whatever decimal enter
681
01:22:15,840 --> 01:22:23,680
that's going to be an integer that's going to be the exponent. And
682
01:22:23,680 --> 01:22:32,800
that is still a string. Now I'm going to cast that exactly as a
683
01:22:34,159 --> 01:22:41,039
So now I know how many decimal places it took to make that and the
684
01:22:41,039 --> 01:22:54,079
So let's talk about our fraction. My numerator is going to be n
685
01:22:54,079 --> 01:23:02,559
10 to that exponent. So in my previous example, point one, two,
686
01:23:02,560 --> 01:23:11,760
you know, that was four, the length of that was four, so minus
687
01:23:12,479 --> 01:23:19,039
my exponent. And then when I multiply it by that exponent, it
688
01:23:19,039 --> 01:23:23,279
know it's going to be a whole number, I will cast it as an
689
01:23:23,279 --> 01:23:30,719
numerator. And then the denominator is going to be 10 times that
690
01:23:30,720 --> 01:23:36,640
what we were doing before we were doing the code. You know, how
691
01:23:36,640 --> 01:23:44,000
and then, you know, my numerator is that times 10 to that many
692
01:23:44,000 --> 01:23:53,439
denominator is just 10 to that exponent. So three decimal places
693
01:23:53,439 --> 01:23:57,919
and then the numerator denominator would be 10 to the third, and
694
01:23:57,920 --> 01:24:02,880
Now, that's numerator and denominator for any fraction. Percent is
695
01:24:02,880 --> 01:24:11,440
places. So whatever n is, I'm going to multiply it by 100, because
696
01:24:11,439 --> 01:24:19,839
That decimal, move it over tw- move decimal place twice, which is
697
01:24:19,840 --> 01:24:26,079
see the output, the decimal. There we go. We just repeat the
698
01:24:26,079 --> 01:24:31,439
and I'm just going to print this out to show you it's numerator
699
01:24:31,439 --> 01:24:37,919
percent, and then I'll print out the percent symbol. There we go.
700
01:24:37,920 --> 01:24:43,760
something else, but here I'm putting it in quotes. It'll just be
701
01:24:43,760 --> 01:24:54,239
to enter a decimal number to convert, and there we go. Point, uh,
702
01:24:54,239 --> 01:25:00,559
The decimal, point, one, two, five, and then the fraction is 125
703
01:25:00,560 --> 01:25:06,000
and the percent's 12.5. And we can run this again and do this for
704
01:25:06,960 --> 01:25:14,239
Um, you know, point two, enter. So it's point two, two out of 10,
705
01:25:16,000 --> 01:25:20,079
And there we go. The same things we were doing, and this is what
706
01:25:20,079 --> 01:25:27,039
look at throughout this course. You know, the steps that we're
707
01:25:27,039 --> 01:25:34,000
this down, and we're pretty much doing the same steps, but then
708
01:25:34,000 --> 01:25:40,159
code, then, you know, you have a formula that you can reuse. Okay,
709
01:25:40,159 --> 01:25:50,479
script here, and I'll be able to convert any decimal to a
710
01:25:51,680 --> 01:25:56,480
Now that we've worked through the core skills in this unit, let's
711
01:25:56,479 --> 01:26:02,399
and I'm going to work through extra problems using the Colab
712
01:26:02,399 --> 01:26:09,920
apply these resources that you're building, and use these to solve
713
01:26:09,920 --> 01:26:15,680
have, problems that might come up in a textbook or in day-to-day
714
01:26:15,680 --> 01:26:22,000
some more extra problems here. So now I want to show you how to
715
01:26:22,000 --> 01:26:27,680
You know, this is what we're talking about here. You're making
716
01:26:27,680 --> 01:26:33,680
the things that I'm showing you, and you'll have access to all
717
01:26:33,680 --> 01:26:38,240
but you're going to put together yours. So you're going to click
718
01:26:38,239 --> 01:26:48,000
the Google Colab, so go over to Google Colaboratory, click on it,
719
01:26:48,000 --> 01:26:56,560
so actually I will call it that. I'm going to put the underscore,
720
01:26:56,560 --> 01:27:06,720
your calculator, and you just hit enter or click somewhere else,
721
01:27:06,720 --> 01:27:12,320
you can do to put together your calculator based on things that
722
01:27:12,319 --> 01:27:19,199
and then things that we do further on in the class, then you can
723
01:27:20,399 --> 01:27:24,079
go to, let's say, the week one notebook where you solve for
724
01:27:24,880 --> 01:27:32,000
and here's some things you can do. So if you click on this text
725
01:27:32,000 --> 01:27:36,720
let's copy that first. So you click on that text and go all the
726
01:27:37,359 --> 01:27:40,880
This looks like copy, but it actually doesn't do what you're
727
01:27:42,000 --> 01:27:49,439
Click on the three dots, copy that cell, and when you go back to
728
01:27:49,439 --> 01:28:01,599
I'm just going to click in the open space here and paste it, Ctrl
729
01:28:01,600 --> 01:28:07,440
it's kind of cool. So, you know, Ctrl V for the Windows, Command V
730
01:28:07,439 --> 01:28:17,439
either one, and then we can go back. That's your proportion set up
731
01:28:17,439 --> 01:28:27,439
over all the way over the three dots, copy cell, and your
732
01:28:28,239 --> 01:28:35,439
So you can have this, you know, we don't need this. If you have an
733
01:28:35,439 --> 01:28:41,439
the trash can over there. So there we go. Now you have your text
734
01:28:41,439 --> 01:28:49,439
and then it really is then self-explanatory. You know, you see the
735
01:28:49,439 --> 01:28:56,079
N2, D2, and even the comment there, put the zero in for the
736
01:28:56,640 --> 01:29:03,440
each of these. Then if we look at week two, now we were doing a
737
01:29:04,479 --> 01:29:11,039
and maybe you don't need to do the simplest one. Maybe you like
738
01:29:11,039 --> 01:29:19,439
that. Doing more with the solution, how we split it up. Now, I
739
01:29:19,439 --> 01:29:27,439
might be the one that I copy as one of them. And what you can do
740
01:29:27,439 --> 01:29:35,039
because notice this one, I personally like this one. It prompts
741
01:29:35,039 --> 01:29:43,039
that it's something equal to zero. You know, there we go. We
742
01:29:43,039 --> 01:29:49,039
this also prints out multiple solutions if you have them. So this
743
01:29:51,039 --> 01:29:59,039
And when you go back into yours, now if I just paste this, that's
744
01:29:59,039 --> 01:30:03,519
And notice it didn't paste where I wanted it to be. So watch what
745
01:30:03,520 --> 01:30:09,120
in here and use these arrows. I'm going to move it down, and
746
01:30:10,319 --> 01:30:18,319
Now, we wanted some text in there. So right above it, you hover
747
01:30:18,319 --> 01:30:31,119
solve for X. Maybe I'll just add that text there. So there's more
748
01:30:31,119 --> 01:30:40,319
That's nice. Now, this solve in other ways, that was pretty good.
749
01:30:40,319 --> 01:30:50,319
factoring. So you could include something like this, solve in
750
01:30:52,319 --> 01:30:58,319
you know, simpy.factor. Now, I might include this because you'll
751
01:30:58,319 --> 01:31:08,319
the one of the other ones. So if we copy this, and this is just
752
01:31:08,319 --> 01:31:16,319
do this. And this is just factor when there's, you know, nothing
753
01:31:16,319 --> 01:31:26,319
we'll copy this cell, and paste this down here. Now, maybe I'm
754
01:31:26,319 --> 01:31:39,279
factor. And down here, then I will paste it. Didn't show up where
755
01:31:39,279 --> 01:31:47,759
arrow, move it down. So, you know, there we go. We have set
756
01:31:47,760 --> 01:31:58,880
But we can even make this, you know, equation to factor. And see,
757
01:31:58,880 --> 01:32:13,440
want. There we go. And then, you know, you can factor things. So
758
01:32:13,439 --> 01:32:21,439
the next week. Now, notice to put it all together, because when we
759
01:32:21,439 --> 01:32:31,439
of these leading up to converting a decimal to a fraction. So this
760
01:32:31,439 --> 01:32:37,439
You're prompting the person to enter in this, and then we're going
761
01:32:37,439 --> 01:32:48,479
decimal, the fraction, the percent. So that's nice. Maybe we copy
762
01:32:48,479 --> 01:33:00,719
back to. So then we go down to here. Maybe I'll paste that here.
763
01:33:00,720 --> 01:33:19,199
some text ahead of it. Decimal to fraction. So you see now you're
764
01:33:19,199 --> 01:33:30,399
here. And we don't need that output right now. Now, we have one
765
01:33:30,399 --> 01:33:41,920
for a variable. And notice it's when I paste this, I might put it
766
01:33:41,920 --> 01:33:48,000
remember we did this, then you have the left side, which could be
767
01:33:48,000 --> 01:33:54,960
of the equation, which could be anything. You know, this would be
768
01:33:54,960 --> 01:34:02,800
you would need to change here. Change the variable you want to
769
01:34:02,800 --> 01:34:08,480
your basic common variables that you would use, but you know, you
770
01:34:08,479 --> 01:34:13,199
if you want, but you might not need to change that line. And then
771
01:34:14,399 --> 01:34:21,199
even if it is something that you can just, you know, solve for a
772
01:34:21,199 --> 01:34:27,359
It doesn't come down to an exact number here. So that might be a
773
01:34:27,359 --> 01:34:41,839
example in here. You know, copy this. Now, we might put this in
774
01:34:41,840 --> 01:34:51,600
factor solve for x, and factor solve for a variable. Maybe we put
775
01:34:51,600 --> 01:34:56,800
And notice you can just click and add code. I'll click right in
776
01:35:00,319 --> 01:35:07,920
And this will be pretty much right where I want it to be. Then I
777
01:35:07,920 --> 01:35:12,000
add some text, solve for a variable.
778
01:35:18,239 --> 01:35:22,159
Now, these are just some examples here of how you could put this
779
01:35:23,119 --> 01:35:32,720
So that then you have your resource here, proportion. There we go.
780
01:35:32,720 --> 01:35:42,720
solve for a variable, convert decimal to fraction to percent. And
781
01:35:42,720 --> 01:35:48,720
you could add more into this here. Now, supposing you want you you
782
01:35:48,720 --> 01:35:54,480
then you add all this, that's this is a lot of scrolling. So one
783
01:35:54,479 --> 01:36:06,639
is now I'm going to start with proportion. I like so right around
784
01:36:06,640 --> 01:36:11,440
there's multiple ways to do this. You could insert, you go up top,
785
01:36:13,439 --> 01:36:19,679
a section header cell. So I'll do it one way this way. I'll do
786
01:36:19,680 --> 01:36:31,920
And actually, I want that above. So I noticed this, when you
787
01:36:31,920 --> 01:36:40,880
some of this. These text boxes accept HTML, look at that the br to
788
01:36:40,880 --> 01:36:48,239
and they accept latex, which is how to format various things
789
01:36:48,239 --> 01:36:59,119
all kinds of things. So in this new section, and you see, because
790
01:36:59,119 --> 01:37:04,640
that's not a comment in Python, it's the new section. And I might
791
01:37:04,640 --> 01:37:21,440
Okay, so now, you see, it takes that and all these cells become a
792
01:37:22,079 --> 01:37:30,559
I don't want that. But what I want to do is, if this next one, I
793
01:37:30,560 --> 01:37:36,880
this section, and I don't need another one, I think that'll be the
794
01:37:37,439 --> 01:37:43,119
There we go. So I'm just going to put this here. Now that's a new
795
01:37:46,479 --> 01:37:53,279
So we see proportions now just has the two cells, the text about
796
01:37:53,279 --> 01:38:02,239
And solve for x has just one cell because that section said it
797
01:38:04,319 --> 01:38:10,000
There we go factor. And maybe you want to say something more than
798
01:38:10,399 --> 01:38:21,920
but you can make this a section heading. Solve for a variable.
799
01:38:21,920 --> 01:38:25,039
this together. So you see solve for a variable.
800
01:38:28,079 --> 01:38:32,479
Convert decimal to fraction. You know, that probably I didn't need
801
01:38:32,479 --> 01:38:36,159
solve for a variable. All the rest was explained in the comments.
802
01:38:40,079 --> 01:38:42,880
And convert decimal to fraction.
803
01:38:42,880 --> 01:38:50,000
So now this just has the one cell. And the advantage of doing this
804
01:38:50,000 --> 01:38:53,520
you see these lines. Now we have the table of contents here.
805
01:38:57,119 --> 01:39:01,920
There we go. And I could change, you know, that's long enough. I
806
01:39:01,920 --> 01:39:07,840
two lines, but that fits so that it's a longer title, but that's
807
01:39:07,840 --> 01:39:15,760
table of contents that you can actually go through. And you see
808
01:39:15,760 --> 01:39:24,079
x. You know, different things. And in the view, you could change
809
01:39:24,880 --> 01:39:27,680
You don't have to, but you could. And then you see you have all
810
01:39:28,960 --> 01:39:35,119
So these are some things you can do in putting together your
811
01:39:35,119 --> 01:39:42,319
Putting together your Google CoLab notebook. You know, I want this
812
01:39:42,319 --> 01:39:47,759
that you're building. So then you're learning how to do all this,
813
01:39:47,760 --> 01:39:54,480
your resources here that you can then refer to. Oh, what do I need
814
01:39:55,359 --> 01:39:59,359
Enter what I need to enter and solve it. You know, you're
815
01:39:59,359 --> 01:40:08,559
So that's what I want you to do for this unit, is take a look at
816
01:40:08,560 --> 01:40:13,680
and put it together in your own notebook. Some of the things we'll
817
01:40:13,680 --> 01:40:18,480
and we'll, you know, make some of these into functions that you
818
01:40:19,039 --> 01:40:24,159
But this would be a good place. Put together your notebook of
819
01:40:24,159 --> 01:40:32,639
but you know, you can tweak it to the way you like it. All right.
820
01:40:36,800 --> 01:40:43,840
So what does it mean to be a function? A function means it in math
821
01:40:43,840 --> 01:40:49,119
some input and then doing something to it. And actually there are
822
01:40:49,119 --> 01:40:55,039
don't have to take input, but in math we will. So like we were
823
01:40:55,039 --> 01:41:03,199
being X, the output will be Y. So each function we want to take X
824
01:41:03,199 --> 01:41:08,319
to say that the output is Y. And here we're dealing with all
825
01:41:09,279 --> 01:41:15,679
and then outputting Y. So you see we have like solving for X we
826
01:41:15,680 --> 01:41:21,039
have a second variable and we still want the idea that just like
827
01:41:21,920 --> 01:41:27,199
in science and in research, we can call X the independent variable
828
01:41:27,199 --> 01:41:35,119
first. And then Y is the dependent variable because it depends on
829
01:41:36,159 --> 01:41:41,840
want to solve this or do anything to it, then I'm going to plug in
830
01:41:41,840 --> 01:41:49,360
and I can pick any value. I might start with zero. So I'm going to
831
01:41:49,359 --> 01:41:58,319
is zero. And then what happens when I plug that in? So that'd be Y
832
01:41:59,439 --> 01:42:06,319
And you see I'll just put in zero in parentheses where I plug in
833
01:42:07,199 --> 01:42:11,119
it highlights that that's what I just plugged in. And also the
834
01:42:11,119 --> 01:42:17,920
I'm still multiplying. So when we do this two times zero zero plus
835
01:42:17,920 --> 01:42:29,359
three and my output is Y. And if you remember then that's an XY
836
01:42:29,359 --> 01:42:35,759
Y is three and I'd be able to plot that point and I can keep
837
01:42:35,760 --> 01:42:42,640
what other numbers can I plug in? I'm even just going to keep
838
01:42:43,840 --> 01:42:50,159
X equals one. Plug in one. Two times one is two plus three is
839
01:42:54,479 --> 01:42:58,399
And then we'll plug that in and I can plug in as many or as few. I
840
01:42:58,399 --> 01:43:02,879
integers. I tend to do that so you can see the numbers a little
841
01:43:02,880 --> 01:43:07,199
But you know you don't have to worry about doing any other
842
01:43:07,199 --> 01:43:12,800
But if I have this I can put in whatever numbers I want as many or
843
01:43:12,800 --> 01:43:18,239
numbers in there and we can plot these on the graph which we'll
844
01:43:18,239 --> 01:43:24,159
But this is the essence of a function that X comes before Y. I
845
01:43:24,159 --> 01:43:33,920
output the Y value. So another function notation that a lot of
846
01:43:34,479 --> 01:43:41,279
another variable Y and this connects a lot with the way the code's
847
01:43:42,079 --> 01:43:50,479
F of X and F for function. So two X plus three. So if you see
848
01:43:50,479 --> 01:43:56,719
Y equals two X plus three or F of X equals two X plus three. This
849
01:43:56,720 --> 01:44:07,199
what we read F of X, F for function. We solve it the same and this
850
01:44:07,199 --> 01:44:13,920
your computer science. So if I have the output called F of X, one
851
01:44:13,920 --> 01:44:21,680
into writing the code is that in algebra we tend to just say F for
852
01:44:21,680 --> 01:44:26,560
or other code you can actually give your function a name and it
853
01:44:26,560 --> 01:44:36,880
function. It can be add, divide, calculate the area, something
854
01:44:36,880 --> 01:44:42,480
long as there's no spaces. So if we have this and then sometimes
855
01:44:42,479 --> 01:44:51,839
into two I could write in F of two. And so again the usefulness of
856
01:44:51,840 --> 01:44:57,520
what what am I already defining as my input and then I know what
857
01:44:57,520 --> 01:45:08,160
two times two plus three. Two times two is four plus three is
858
01:45:08,159 --> 01:45:18,639
I know that answer and when I see that X is two, Y is seven. And
859
01:45:18,640 --> 01:45:24,240
relates to the code and how we can write even a little bit more
860
01:45:24,239 --> 01:45:30,000
and how we can define the input there. Then we'll look at graphing
861
01:45:30,000 --> 01:45:37,199
look at the code. So with the code and functions we can do very
862
01:45:37,199 --> 01:45:44,559
by hand writing out the math. Here I'm just going to define one X
863
01:45:44,560 --> 01:45:50,800
the function that Y value. Y equals four times X plus three. And
864
01:45:50,800 --> 01:45:58,800
make sure we put the times. So I'm just going to plug in that Y X
865
01:45:58,800 --> 01:46:03,119
in for this X value. So it's four times five plus three and then
866
01:46:03,119 --> 01:46:13,840
my solution X comma Y. So we see that and before I print that out.
867
01:46:13,840 --> 01:46:22,159
but I can loop this. So I'm going to print out this line here
868
01:46:22,159 --> 01:46:29,519
tab Y. So that's defining my columns here X and Y. And then what
869
01:46:29,520 --> 01:46:36,480
all those values. So for X in range 11 so X is going to go 0
870
01:46:36,479 --> 01:46:44,799
take that same function and each time then I'm going to plug in
871
01:46:44,800 --> 01:46:49,520
I'm going to print out the X Y values. And in this case again I'm
872
01:46:50,319 --> 01:46:56,079
So this is the essence of what we're doing with a function. Each
873
01:46:56,079 --> 01:47:01,920
solve for Y and then I have an X Y value and this is going to
874
01:47:01,920 --> 01:47:08,319
So when I run this we'll see it'll come out first of all we'll
875
01:47:09,279 --> 01:47:14,800
you see five twenty three five comma twenty three that first
876
01:47:14,800 --> 01:47:23,520
Y and all of our X Y values if X is zero Y is three if X is one Y
877
01:47:23,520 --> 01:47:31,120
five twenty three that shows up on the list too. So that's
878
01:47:31,119 --> 01:47:37,439
lot of other functions beyond math you can do things with and we
879
01:47:37,439 --> 01:47:45,599
of Python function definition for our math. Here we can on this
880
01:47:45,600 --> 01:47:52,000
space and Python I can name my function anything but I'm going to
881
01:47:52,000 --> 01:47:59,039
F of X and then here I have a colon. So this is going to define
882
01:47:59,039 --> 01:48:10,079
is indented four spaces and I have Y equals my four times X plus
883
01:48:10,720 --> 01:48:18,320
and what am I going to do then I'll return the Y value. So
884
01:48:18,319 --> 01:48:26,399
Y value. So you see this in use if I print here if I print five so
885
01:48:26,399 --> 01:48:33,119
my X value comma and then I'm going to call this function right
886
01:48:33,119 --> 01:48:40,000
take that and run it through there we go. Same type of thing same
887
01:48:40,000 --> 01:48:49,359
define this and when we run this it's just going to print that 523
888
01:48:49,359 --> 01:48:59,039
loop I could just take the same loop here and I'm going to copy
889
01:48:59,039 --> 01:49:08,800
loop if I wanted to and in this case I'm going to print because I
890
01:49:08,800 --> 01:49:22,720
defined I don't need this and I could really just put put that
891
01:49:22,720 --> 01:49:31,199
I could just have right here since I defined that function X F of
892
01:49:31,199 --> 01:49:38,559
and I don't have my headings here but I think we can use our
893
01:49:38,560 --> 01:49:45,520
one value but then in the loop just went through and looped so
894
01:49:46,159 --> 01:49:53,680
illustrate a function in code and you know what we can do with
895
01:49:54,880 --> 01:49:59,119
almost limitless you know you can have a function do anything and
896
01:49:59,119 --> 01:50:04,319
more complex than this you know give it a word but I wanted to
897
01:50:04,319 --> 01:50:10,880
classic math notation and functions in Python whether I actually
898
01:50:10,880 --> 01:50:17,039
that still works as a function or whether I define it and next
899
01:50:21,119 --> 01:50:27,359
so now when we talk about graphing functions we'll use this
900
01:50:27,359 --> 01:50:34,880
and I'll use the x and y notation so we have our input and output
901
01:50:34,880 --> 01:50:41,359
values and what y values match up so if you ever come across
902
01:50:41,840 --> 01:50:48,880
you can see that if I plug in both of these x and y that should
903
01:50:48,880 --> 01:50:54,239
have a few of our points here and then now we're going to see how
904
01:50:54,239 --> 01:51:01,840
plane our x y coordinate plane it's Cartesian because Rene
905
01:51:03,840 --> 01:51:12,560
zero zero at the center and how much I count for x positive to the
906
01:51:12,560 --> 01:51:20,640
it comes first like x comes first in the alphabet then my y value
907
01:51:20,640 --> 01:51:28,160
and my coordinate pair would be my x y so this zero three would
908
01:51:30,560 --> 01:51:37,360
zero so I'm not going left or right at all up to three plot the
909
01:51:37,359 --> 01:51:45,279
write this but I'll show you so then that would be the point zero
910
01:51:45,279 --> 01:51:54,479
so I would go over one up five plot the point and then that's one
911
01:51:55,359 --> 01:52:03,119
now I just plotted three points but I'll tell you if you really
912
01:52:03,119 --> 01:52:12,479
decimals or other numbers that are in between you could bet that
913
01:52:12,479 --> 01:52:21,679
one point something two point something they would all end up
914
01:52:21,680 --> 01:52:29,200
there's no x value that can't go into this well whatever weird
915
01:52:29,199 --> 01:52:37,279
number anything so all the numbers would be on this line so with
916
01:52:37,279 --> 01:52:42,319
going to call it linear and we'll get into other types of
917
01:52:42,319 --> 01:52:48,079
points and then we want to look at these patterns what type of
918
01:52:49,359 --> 01:52:56,319
so what we're going to do now is look at in the python code how to
919
01:52:56,960 --> 01:53:07,760
to make a basic blank graph we're going to import this library
920
01:53:07,760 --> 01:53:14,320
we're going to we can import this as plt so I can reference this
921
01:53:14,319 --> 01:53:21,039
out and here's what we're going to do the first line is these are
922
01:53:21,600 --> 01:53:30,480
fig for the figure axe for the axis so these two variables and
923
01:53:30,479 --> 01:53:39,439
and then that sets this up and we'll do plt.show the base there
924
01:53:39,439 --> 01:53:46,079
show and then that gives a basic graph these are all the defaults
925
01:53:46,800 --> 01:53:54,159
and you know we have this set up so we're going to build upon that
926
01:53:54,159 --> 01:53:59,039
here notice that was all just the first quadrant everything's
927
01:53:59,039 --> 01:54:09,199
positive and even only one goes up to one so again import matplot
928
01:54:09,199 --> 01:54:17,679
first lines but now let's take a look at these dimensions now I
929
01:54:17,680 --> 01:54:26,000
and I'm going to set this axis all right and it gives you the
930
01:54:26,000 --> 01:54:31,680
going to show a better way in a second but you can do this on one
931
01:54:31,680 --> 01:54:41,760
when we show it I want it to go from negative 10 we see across the
932
01:54:41,760 --> 01:54:48,960
up to 10 zero in the middle and on the y-axis negative 10 up to 10
933
01:54:48,960 --> 01:54:57,039
great but I have no lines I have no axis and you know not the
934
01:54:57,039 --> 01:55:02,000
here's a better way to set the dimensions is I'll define them
935
01:55:02,880 --> 01:55:10,720
as variables x min x max y min y max and that way all right I want
936
01:55:10,720 --> 01:55:17,600
and I can set them here easy to see it and change it if I want to
937
01:55:17,600 --> 01:55:26,960
really what I'm doing when I set the axis size x min x max y min y
938
01:55:26,960 --> 01:55:34,000
that it's taking and it becomes a lot clearer when we set it up
939
01:55:34,880 --> 01:55:41,440
I can set this and then if I wanted to I say oh for this one this
940
01:55:41,439 --> 01:55:51,119
so maybe I want that y maximum to be 20 instead of 10 and then
941
01:55:51,119 --> 01:55:58,479
size of this still looks the same but it adjusted accordingly and
942
01:55:59,279 --> 01:56:01,279
and on my x-axis negative 10 to 10
943
01:56:01,279 --> 01:56:15,039
and so let's display axis lines here if I have my dimensions
944
01:56:15,680 --> 01:56:21,280
well that's the one we already did here the window size but I'm
945
01:56:21,279 --> 01:56:37,039
this line here I have x min x max as my array of x values see
946
01:56:37,039 --> 01:56:45,439
array of x values and then my array of y values and the default is
947
01:56:45,439 --> 01:56:55,199
just plot two x values and two y values it'll draw the line from x
948
01:56:55,760 --> 01:57:04,960
in quotes makes it blue so we're going to do the same thing with
949
01:57:04,960 --> 01:57:12,720
are going to be 0 at 0 y min 0 y max and then it'll get make that
950
01:57:12,720 --> 01:57:26,320
just because I like blue and there we go so now we have this that
951
01:57:27,760 --> 01:57:31,520
so from everything we do now we have an axis we have a point of
952
01:57:32,560 --> 01:57:38,800
so everything that we plot is going to you know start with this
953
01:57:38,800 --> 01:57:45,360
set all this up we might not even need to change any of this and
954
01:57:45,840 --> 01:57:53,520
with an x y-axis all right so how do we plot one point so we see
955
01:57:54,399 --> 01:58:01,439
and I made it blue b in quotes so how do I plot a point well I
956
01:58:01,439 --> 01:58:10,319
I have an array of one value which is five for the x value one
957
01:58:10,800 --> 01:58:19,600
and then the r makes it red and the zero makes it a circle
958
01:58:19,600 --> 01:58:25,360
other options you can do you can do a dash you can do different
959
01:58:25,359 --> 01:58:31,359
to make this a red circle and that's how we make make that circle
960
01:58:31,359 --> 01:58:41,599
here if I have these two and so when I run this it'll still plot
961
01:58:41,600 --> 01:58:49,360
do five four and then that's going to be a red dot all right so if
962
01:58:50,880 --> 01:58:59,119
now connecting with what we were doing with the functions here I'm
963
01:58:59,119 --> 01:59:06,319
and here in rain in my range I'm going to have the range from 10
964
01:59:07,119 --> 01:59:18,800
from this value my y value y equals 0.5 x plus one and in this
965
01:59:18,800 --> 01:59:28,239
going to do plot plt dot plot and I'm going to plot that x y value
966
01:59:28,239 --> 01:59:33,279
I'm going to plot these x y values and again that's the essence of
967
01:59:33,279 --> 01:59:40,719
these different values and when I plot all these points I'm going
968
01:59:41,600 --> 01:59:48,560
that this all lines up and I'll tell you if I plotted points that
969
01:59:48,560 --> 01:59:54,640
x values there would be they would also line up that's why it's a
970
01:59:54,640 --> 02:00:00,960
of it's going to be a straight line and then every point on this
971
02:00:00,960 --> 02:00:11,760
this function it's going to work so my loop to graph a function
972
02:00:11,760 --> 02:00:19,600
to do the function and the table so like we were doing before I'm
973
02:00:19,600 --> 02:00:25,280
graph that I have I'm going to print the x tab y for the heading
974
02:00:26,079 --> 02:00:31,519
I'll use the same function here I'm going to plot the point and
975
02:00:33,520 --> 02:00:39,200
and all these it it actually won't plot all the it'll kind of save
976
02:00:39,199 --> 02:00:44,800
them all it's really just going to add them all to the table and
977
02:00:44,800 --> 02:00:51,760
really doesn't show the graph until the last thing outside the
978
02:00:51,760 --> 02:00:58,720
when you have graphs I think Python just likes to have that
979
02:00:58,720 --> 02:01:07,360
first and then show the graph so then we have this and we have our
980
02:01:07,359 --> 02:01:14,799
put one number in the range it'll do zero to that number but I can
981
02:01:15,359 --> 02:01:21,359
or I could even just go back to those original values that I
982
02:01:21,359 --> 02:01:29,439
x min x max you see and then but as you know you can put any two
983
02:01:29,439 --> 02:01:38,079
do the range between there and you see it just abruptly starts
984
02:01:38,079 --> 02:01:53,439
I could change that to make this x min and I can make this x max
985
02:01:53,439 --> 02:02:05,439
last point so I'll do x max plus one and I can have that range and
986
02:02:05,439 --> 02:02:17,839
of values and it'll graph the full dimensions so there we go we
987
02:02:17,840 --> 02:02:22,960
I have whatever math function I have plug in different values and
988
02:02:22,960 --> 02:02:30,319
numerical output see the graphing output and now we see the
989
02:02:34,399 --> 02:02:38,960
now that we've worked through the core skills in this unit let's
990
02:02:38,960 --> 02:02:44,800
problems and I'm going to work through extra problems using the
991
02:02:44,800 --> 02:02:50,880
see how you can apply these resources that you're building and use
992
02:02:50,880 --> 02:02:56,079
might come up in a textbook or in day-to-day life so we're going
993
02:02:56,079 --> 02:03:02,079
extra problems here so let's talk about more ways to graph and
994
02:03:02,720 --> 02:03:09,039
because we want to be able to display our data our functions so we
995
02:03:09,039 --> 02:03:17,439
can loop through inputs you know I can define my graph and we
996
02:03:17,439 --> 02:03:26,799
y min and max and we talked about how we can loop through I get x
997
02:03:26,800 --> 02:03:34,239
going to plug this in and plot that value and that's the idea of
998
02:03:34,239 --> 02:03:40,960
x value in this range plug it in for y plug it in here get y and I
999
02:03:40,960 --> 02:03:48,480
as a red dot after doing all that then we show the graph but what
1000
02:03:48,479 --> 02:03:58,159
a loop for our input what if we could use an array and we'll
1001
02:03:58,159 --> 02:04:05,840
but we have this numpy array and it's not that long of a word but
1002
02:04:05,840 --> 02:04:11,680
convention that we import it as np and so you'll see a lot of
1003
02:04:12,239 --> 02:04:19,439
np dot this or that so that's what we're going to do and again
1004
02:04:19,439 --> 02:04:26,799
so given this numpy array here's what we're going to do then given
1005
02:04:26,800 --> 02:04:35,360
how many points I want in my array and in this case it's going to
1006
02:04:35,359 --> 02:04:40,399
min I feel like that's probably enough for our purposes but that
1007
02:04:40,399 --> 02:04:48,000
10 or whatever you want and then we see so then we want to make as
1008
02:04:48,560 --> 02:04:55,840
these values as we can that way if that changes if I change my
1009
02:04:55,840 --> 02:05:02,079
accordingly and I don't have to go through and find all these
1010
02:05:02,079 --> 02:05:08,000
range times two so that's two points through that you'll see that
1011
02:05:08,000 --> 02:05:13,600
just fine but you can always increase that so now they have any
1012
02:05:13,600 --> 02:05:19,680
of x values and since I really am only using this once I'm going
1013
02:05:19,680 --> 02:05:29,039
my array of x values and so numpy we have np dot linspace so we
1014
02:05:29,039 --> 02:05:35,920
going to set up our array you know space for linear graphing so it
1015
02:05:35,920 --> 02:05:42,399
I start where do I end and how many points do I have so we see we
1016
02:05:42,399 --> 02:05:50,479
and then I get my x value so this saves us the time of having to
1017
02:05:50,479 --> 02:05:55,839
for us here's all the graphs and we're going to talk about how to
1018
02:05:55,840 --> 02:06:03,600
in a minute so now I'll just I like to define my x value up there
1019
02:06:03,600 --> 02:06:11,200
in the range so I have my y value and for our purposes here we'll
1020
02:06:11,199 --> 02:06:19,599
it y equals but you can graph multiple things on the same axis and
1021
02:06:19,600 --> 02:06:26,240
whatever you'd like so I just define this relatively simple linear
1022
02:06:27,119 --> 02:06:37,119
when I plot I'll plot x and y and if you remember before we were
1023
02:06:37,119 --> 02:06:46,559
in this case with only one element but here you see I define my x
1024
02:06:46,560 --> 02:06:55,039
and therefore y becomes an array of y values so I can just
1025
02:06:55,039 --> 02:07:03,439
they each do represent an array in this case then I decided to
1026
02:07:03,439 --> 02:07:15,599
quotes so there we go and when we graph this then we can see I
1027
02:07:15,600 --> 02:07:23,280
about like that would be 2x plus 1 with the red line all right so
1028
02:07:23,279 --> 02:07:33,119
things we can customize here now yes r g b work well you know I
1029
02:07:33,119 --> 02:07:48,559
line r g for green and if I want it to be a black line then I will
1030
02:07:49,359 --> 02:07:55,039
those all work as you know simplified ways to define the color of
1031
02:07:55,039 --> 02:08:02,800
put anything python will actually assign a color to each line and
1032
02:08:02,800 --> 02:08:07,199
you plot a few lines they each get a different color but if you
1033
02:08:07,199 --> 02:08:12,239
want it specifically to be this line for this color you can define
1034
02:08:12,239 --> 02:08:23,039
those major colors you can actually just write in colors then you
1035
02:08:23,039 --> 02:08:30,239
abbreviation for pink but if I want my line to be pink I can write
1036
02:08:30,239 --> 02:08:36,639
every color that will be acceptable here but it's going to be a
1037
02:08:36,640 --> 02:08:41,920
a line of a particular color type it in try it and there we go so
1038
02:08:41,920 --> 02:08:49,199
to define the color of line because remember this plot when this
1039
02:08:49,199 --> 02:08:56,399
it's a line so if I want it to be a point then I would have to
1040
02:08:56,399 --> 02:09:05,199
array but as each an array of one value and then the the letter
1041
02:09:05,199 --> 02:09:13,119
circle or the carrot for a triangle or something like that so or a
1042
02:09:13,119 --> 02:09:18,640
if we just wanted to be a point we'll see that in a second here so
1043
02:09:18,640 --> 02:09:25,119
and our line but we're you know we're not done customizing it
1044
02:09:25,119 --> 02:09:31,519
a look at these tick marks you know zero and then every 2.5 maybe
1045
02:09:31,520 --> 02:09:37,120
we'll change some of these things and maybe you know this seems
1046
02:09:37,119 --> 02:09:43,279
the grid lines so here's some other things we can do all right I'm
1047
02:09:44,640 --> 02:09:48,800
certainly matplotlibrary but I'm also doing numpy because we use
1048
02:09:48,800 --> 02:09:56,720
graphing and same thing I'll define you know the window up here
1049
02:09:56,720 --> 02:10:05,600
window so for now I'll keep this you know the same axis I just
1050
02:10:05,600 --> 02:10:18,560
now notice when we do up here figure and axis so the labels would
1051
02:10:20,000 --> 02:10:27,039
axe dot set x label axe dot set y label axe dot set title there we
1052
02:10:27,039 --> 02:10:33,920
graph and I didn't mean that some graph like whatever I meant more
1053
02:10:33,920 --> 02:10:44,079
charlotte's web or some graph so anyway so we have these and I
1054
02:10:44,079 --> 02:10:53,600
later and I have a few other things here so I still have one y
1055
02:10:54,560 --> 02:11:01,200
now notice this I'm going to define this as a label you know it
1056
02:11:01,199 --> 02:11:07,760
rather than a color but notice no color I can also do a color but
1057
02:11:07,760 --> 02:11:14,720
what color python assigns to us and then I decided to plot a point
1058
02:11:14,720 --> 02:11:20,720
zero red or that's actually oh the lower case o so it's going to
1059
02:11:20,720 --> 02:11:26,960
this one's going to have a label too and I'm going to plot
1060
02:11:26,960 --> 02:11:36,239
then notice I can define the y value up here and then say y right
1061
02:11:36,239 --> 02:11:42,159
in here directly either way whichever you feel like doing I don't
1062
02:11:42,159 --> 02:11:51,359
options here and again we have this label also so let's just take
1063
02:11:51,359 --> 02:11:57,359
late set x label y label and the title and then we'll see these
1064
02:12:00,880 --> 02:12:06,960
so there we go and you know we get nice orange a different shade
1065
02:12:06,960 --> 02:12:13,119
and I define that as a red dot so there we go but what if all
1066
02:12:13,119 --> 02:12:22,800
what if I want the axis to show the grid it looks kind of plain
1067
02:12:22,800 --> 02:12:26,159
when I comment that out and this one notice true is a capital T
1068
02:12:29,439 --> 02:12:35,759
it will actually show the grid lines and you see it does line up
1069
02:12:35,760 --> 02:12:42,400
there every 2.5 but there we go so if we want to see the grid
1070
02:12:42,399 --> 02:12:47,199
and we have this and now we have our x you know our labels x
1071
02:12:48,880 --> 02:12:56,640
you could actually put the graph and in one of the later units
1072
02:12:56,640 --> 02:13:03,280
to even automatically if I wanted to graph one line and have the
1073
02:13:03,279 --> 02:13:10,479
but you know you could always just type that in you know instead
1074
02:13:10,479 --> 02:13:18,239
just type that in as a string you know the equation of the line
1075
02:13:18,239 --> 02:13:29,439
again and in this case let's say the 2.5 in each direction is not
1076
02:13:29,439 --> 02:13:39,359
have x dot and we're going to set x ticks and set y ticks so
1077
02:13:39,359 --> 02:13:48,399
so it's a different sort of array I'm going to do num mp dot
1078
02:13:48,399 --> 02:13:54,719
very similar to the way we did x values I get my minimum my
1079
02:13:54,720 --> 02:14:02,880
I want to tick mark every two numbers so that's what we're going
1080
02:14:02,880 --> 02:14:08,640
you see again basing it off of those original variables if the
1081
02:14:08,640 --> 02:14:15,360
will update automatically so there we go so let's just take a look
1082
02:14:15,359 --> 02:14:24,159
tick marks and we see then now every two and maybe that's a little
1083
02:14:24,800 --> 02:14:36,800
and we see these now if I wanted it every one then I'm going to
1084
02:14:36,800 --> 02:14:44,159
this is just for the tick marks along the side but up here when we
1085
02:14:44,159 --> 02:14:51,760
going to just follow whatever tick marks we've assigned so now we
1086
02:14:51,760 --> 02:14:57,760
and now we get this sort of graph where I definitely can count the
1087
02:14:57,760 --> 02:15:04,239
let's take a look at the slope of each line let's see these and
1088
02:15:04,239 --> 02:15:08,000
so that way it doesn't get in the way of anything that's in the
1089
02:15:10,000 --> 02:15:17,119
all right there we go so we can keep this that's that's pretty
1090
02:15:17,119 --> 02:15:25,119
we have all these labels but we didn't see them anywhere so if you
1091
02:15:25,119 --> 02:15:37,920
add this other plt dot legend here we go and we can see these
1092
02:15:37,920 --> 02:15:44,159
each of these labels we can have you know this line we labeled
1093
02:15:44,159 --> 02:15:49,279
just wrote the word point but you could put anything and the other
1094
02:15:49,279 --> 02:15:57,759
some more steeper line so we could always do this and in the same
1095
02:15:57,760 --> 02:16:02,000
assigns it you'll see the matching you know which line are we
1096
02:16:02,000 --> 02:16:08,479
referencing so some good things that we can do with these we can
1097
02:16:08,479 --> 02:16:14,479
can change how often they come up we can have the grid or not we
1098
02:16:14,479 --> 02:16:21,279
all right and I encourage you just to get in and you know tinker
1099
02:16:21,279 --> 02:16:27,840
all some of the different ways you can you know match up different
1100
02:16:27,840 --> 02:16:35,280
different things and we will get into even more graphing but
1101
02:16:35,280 --> 02:16:43,200
systems of equations and some other more complex graphs so then
1102
02:16:43,200 --> 02:16:47,920
you know go a little bit deeper try a few more things with the
1103
02:16:47,920 --> 02:16:53,760
will get you to be able to display any function you have and you
1104
02:16:53,760 --> 02:16:58,719
way that you say yeah this is exactly how I wanted it to look
1105
02:16:58,719 --> 02:17:05,519
all right so yeah get in there and tinker with this and see see
1106
02:17:11,040 --> 02:17:20,320
so let's talk about slope how can I describe this line that's on
1107
02:17:20,319 --> 02:17:29,760
how it goes up and over so that's what slope is picturing these
1108
02:17:29,760 --> 02:17:35,280
that they go on some sort of angle but we're going to describe
1109
02:17:35,280 --> 02:17:42,640
much am I going up and how much am I going over up and over up and
1110
02:17:43,680 --> 02:17:48,720
two points and if I have the graph that I'm looking at that's
1111
02:17:48,719 --> 02:17:53,840
that's great I can just count you know looking at two nice points
1112
02:17:53,840 --> 02:18:03,360
makes it easier to count so I can say from this point to this
1113
02:18:03,360 --> 02:18:12,159
three and then over one so up three over one well then my slope is
1114
02:18:12,159 --> 02:18:18,799
you know from that to the next point I can go up three over one
1115
02:18:19,760 --> 02:18:26,880
plot a point etc and it would be the same slope anywhere on the
1116
02:18:26,879 --> 02:18:34,559
equation it's a perfectly straight line so that's great I can
1117
02:18:34,559 --> 02:18:39,840
you know just have things like this but if I have the points that
1118
02:18:39,840 --> 02:18:47,840
up that's the change in y because y tells me if I'm going up or
1119
02:18:47,840 --> 02:18:54,799
up I just counted three but I could also subtract taking a look at
1120
02:18:55,920 --> 02:19:02,559
or then how much am I going over and it's always over to the right
1121
02:19:02,559 --> 02:19:09,680
so from one then to two two minus one how much am I going over so
1122
02:19:10,319 --> 02:19:16,159
in this case it's positive because left to right it's going up if
1123
02:19:16,719 --> 02:19:22,879
then my second y value would be less and when I subtract then it'd
1124
02:19:22,879 --> 02:19:27,439
always going to the right but y would be positive if it's going up
1125
02:19:27,440 --> 02:19:35,120
and so if I had these and I can count but looking at this I know I
1126
02:19:35,120 --> 02:19:43,280
formula look like well I can write out the formula here slope m
1127
02:19:44,719 --> 02:19:52,799
m for slope because it's how much we move on the graph so somebody
1128
02:19:52,799 --> 02:19:59,119
caught on so we're gonna use m for slope how much we move on the
1129
02:19:59,120 --> 02:20:07,760
much am I going up so that's the change in y and I can subtract
1130
02:20:07,760 --> 02:20:15,200
a little subscripts you know y2 y1 and that indicates my second y
1131
02:20:15,200 --> 02:20:24,560
then the change in x would be very similar x2 minus x1 and again
1132
02:20:24,559 --> 02:20:32,479
x value minus the first one okay so now that I have this formula
1133
02:20:32,479 --> 02:20:39,680
and see so we'd have four minus one or minus one I'm subtracting
1134
02:20:39,680 --> 02:20:45,760
two minus one subtracting the x values and what do I get four
1135
02:20:46,319 --> 02:20:55,520
two minus one is one and three over one any whole number over one
1136
02:20:55,520 --> 02:21:01,840
a whole number I don't have to write over one so I can just write
1137
02:21:01,840 --> 02:21:08,479
see anytime you see a slope that just is a whole number it's that
1138
02:21:08,479 --> 02:21:15,439
so we have counting if I have the graph subtracting if I just have
1139
02:21:16,159 --> 02:21:22,479
you know I'm using that formula so this is great it's the same
1140
02:21:22,479 --> 02:21:28,159
slope for a linear equation so let's take a look at how we can
1141
02:21:28,159 --> 02:21:33,520
you to get into the mindset that anytime we have a formula you can
1142
02:21:33,520 --> 02:21:39,200
and you know there we go input the numbers and output in this case
1143
02:21:39,200 --> 02:21:45,920
look at the code and we'll see how we can do this now this part is
1144
02:21:45,920 --> 02:21:54,000
want to show you that you can connect any formula if you know here
1145
02:21:54,000 --> 02:22:04,000
y1 x2 y2 and put that into the slope formula slope equals y2 minus
1146
02:22:04,959 --> 02:22:12,239
and really then this is a useful formula and others you can just
1147
02:22:12,239 --> 02:22:15,360
and run it through the formula here we're just going to output the
1148
02:22:15,360 --> 02:22:22,720
there we go all you need is the two points next we're going to
1149
02:22:23,360 --> 02:22:27,520
but then let's take a look at how that comes together on the graph
1150
02:22:31,200 --> 02:22:37,840
all right so we've already figured out that the slope is three in
1151
02:22:37,840 --> 02:22:42,880
we have this two points and we want to figure out the equation of
1152
02:22:42,879 --> 02:22:51,679
linear and I have these two points that we figured out that the
1153
02:22:51,680 --> 02:23:02,319
to the next we went up three and over one or I just subtract four
1154
02:23:02,879 --> 02:23:08,719
and then four minus one is three two minus one is one so three
1155
02:23:08,719 --> 02:23:16,559
slope is three and we want the full equation of of this line now
1156
02:23:17,200 --> 02:23:24,240
imagine here that it would cross the y-axis somewhere and that's
1157
02:23:24,239 --> 02:23:31,520
the intercept is where does it cross so we have a nice formula
1158
02:23:31,520 --> 02:23:43,760
intercept form is y equals mx plus b now we call the slope m
1159
02:23:43,760 --> 02:23:49,520
one point to the next and we'll call the other one b because
1160
02:23:50,000 --> 02:23:55,440
so many things happen in this first quadrant where everything's
1161
02:23:55,440 --> 02:24:00,480
we begin on the y-axis and then move in that direction of course
1162
02:24:00,479 --> 02:24:11,840
different directions but so I have this y equals mx plus b now
1163
02:24:11,840 --> 02:24:21,840
x y comes from any of these x y points so I'll pick one of these
1164
02:24:21,840 --> 02:24:29,200
y-intercept it works out that way so if we take a look at this I'm
1165
02:24:29,200 --> 02:24:35,760
points how about I take this this first one here because it's one
1166
02:24:35,760 --> 02:24:42,800
easy to calculate it works for either one so when I plug in this
1167
02:24:42,799 --> 02:24:49,279
and then the slope which we just figured out was three and then
1168
02:24:49,280 --> 02:24:54,239
put that in parentheses so notice mx you know in my math notation
1169
02:24:54,239 --> 02:24:58,399
multiplying just because they're next to each other so I'll do the
1170
02:24:58,959 --> 02:25:06,239
you know m and then plug in for x and now b I don't know so that's
1171
02:25:06,239 --> 02:25:12,639
that I know one point so that's four things that I know one point
1172
02:25:12,639 --> 02:25:17,920
two things I know three of them I can figure out the fourth one
1173
02:25:17,920 --> 02:25:24,879
equals three plus b and remember our one step equation subtract
1174
02:25:24,879 --> 02:25:32,879
negative two equals b so now that I have this I figured out that
1175
02:25:32,879 --> 02:25:39,839
that b is negative two then I put it together leaving x y open
1176
02:25:39,840 --> 02:25:50,960
line will work in this equation and my final equation is y equals
1177
02:25:50,959 --> 02:25:58,319
we go we've figured out this slope intercept and so now I know
1178
02:25:58,319 --> 02:26:07,680
so that coordinate point would be zero negative two and we can see
1179
02:26:07,680 --> 02:26:13,680
it shows up like this because when x is zero whatever I plug in as
1180
02:26:13,680 --> 02:26:21,280
going to zero out so three x three times zero it zeroes out and
1181
02:26:21,280 --> 02:26:27,760
and then I have minus two so we see that that works out so this is
1182
02:26:27,760 --> 02:26:36,000
and we can when we see this now if we know the slope we can
1183
02:26:36,000 --> 02:26:42,879
intercept if I had this line I could generate that equation we're
1184
02:26:42,879 --> 02:26:47,439
straight line but if I had this but if I had this line I could
1185
02:26:47,440 --> 02:26:52,880
it begin at negative two oh I know that that's b and then I can
1186
02:26:52,879 --> 02:26:58,559
one so then I know that the slope is three and I can go the other
1187
02:26:58,559 --> 02:27:03,680
didn't have the graph I could say oh I'm going to begin at
1188
02:27:03,680 --> 02:27:09,040
point and then the slope is three I would go up three over one
1189
02:27:09,040 --> 02:27:14,400
plot a point and if I was doing this by hand you know paper and
1190
02:27:14,399 --> 02:27:19,440
points and get out the roar and connect the dots but what we're
1191
02:27:19,440 --> 02:27:25,440
going to do here is take a look at how we can write the code to
1192
02:27:25,440 --> 02:27:30,000
would need is two points and I'm going to do more than calculate
1193
02:27:30,000 --> 02:27:35,360
the full equation so we're going to look at how to take two points
1194
02:27:35,360 --> 02:27:42,079
equation so now we're going to put it all together and develop the
1195
02:27:42,079 --> 02:27:49,360
going to define our x1 y1 x2 y2 from two different points and
1196
02:27:49,920 --> 02:27:56,559
which now we're going to call m that's been the go-to variable for
1197
02:27:56,559 --> 02:28:04,159
moves so same formula but now it's going to be m equals y2 minus
1198
02:28:05,440 --> 02:28:11,440
then I'm going to define the y intercept which is b and that's
1199
02:28:11,440 --> 02:28:16,880
things happen in the first quadrant where everything's positive so
1200
02:28:16,879 --> 02:28:24,559
axis somewhere where x is zero so we'll connect this with the
1201
02:28:24,559 --> 02:28:33,279
know how if how do I if if I know a point and an x so an x y value
1202
02:28:33,280 --> 02:28:46,560
I solve for b a couple steps of algebra so then b is you know y1
1203
02:28:46,559 --> 02:28:53,519
b solve print out the equation so this will just print out the
1204
02:28:54,879 --> 02:29:05,199
that it'll display nice y equals three x plus four and I still it
1205
02:29:05,200 --> 02:29:12,800
as a float variable so three point zero it's not worth trying to
1206
02:29:12,799 --> 02:29:16,719
this is going to work for any number and then that way does not
1207
02:29:17,520 --> 02:29:23,920
to to make this work so there we go knowing these calculate the
1208
02:29:23,920 --> 02:29:33,360
then put it all together in the formula so then let's graph it
1209
02:29:33,360 --> 02:29:40,960
y points and I just kept these same points here so develop the
1210
02:29:40,959 --> 02:29:45,919
because we want to print it out so that we're going to print out
1211
02:29:45,920 --> 02:29:54,079
to go back to the graph that we were doing before define our x min
1212
02:29:54,079 --> 02:30:02,000
this line I can graph I can find two other points so I'm going to
1213
02:30:02,719 --> 02:30:09,760
in the first line y3 I'm going to take the x minimum and I'm going
1214
02:30:09,760 --> 02:30:16,719
plus b that's going to be my y value and then I'm going to take
1215
02:30:16,719 --> 02:30:23,679
that's going to be my other y value so now I have these other two
1216
02:30:23,680 --> 02:30:31,360
same as we were doing before and we have now I'm going to plot
1217
02:30:31,360 --> 02:30:39,680
and my x values are going to be x min x max and my y values will
1218
02:30:39,680 --> 02:30:47,120
going to plot this as a red line so if I part if I put an o in
1219
02:30:47,120 --> 02:30:52,880
separate red points but just r makes it a red line and now when we
1220
02:30:55,280 --> 02:31:09,040
there we go we calculate the equation and we graph the line good
1221
02:31:09,040 --> 02:31:20,560
I can have any other two points there we go there we go two three
1222
02:31:20,559 --> 02:31:26,639
we know this actually some of this would break but it might still
1223
02:31:26,639 --> 02:31:35,199
not a function there so there we go six and I'll make this one
1224
02:31:35,200 --> 02:31:41,600
eight just to show that we can just change these and all the rest
1225
02:31:42,639 --> 02:31:50,000
solve for m and b get our equation plot them here and when I run
1226
02:31:51,680 --> 02:31:59,920
so 1.25 x plus 0.5 and we see then it must cross the y-axis at 0.5
1227
02:31:59,920 --> 02:32:09,600
up 1.25 over 1 there we go all right so now we can graph and
1228
02:32:12,399 --> 02:32:14,639
do whatever you want with the two points you find
1229
02:32:19,280 --> 02:32:24,400
now that we've worked through the core skills in this unit let's
1230
02:32:24,399 --> 02:32:30,000
and I'm going to work through extra problems using the CoLab
1231
02:32:30,000 --> 02:32:35,760
you can apply these resources that you're building and use these
1232
02:32:35,760 --> 02:32:40,960
might come up in a textbook or in day-to-day life so we're going
1233
02:32:40,959 --> 02:32:47,439
extra problems here so we're looking at how we can apply some of
1234
02:32:47,440 --> 02:32:55,360
to real life situations and use this information to predict things
1235
02:32:56,399 --> 02:33:00,959
and real life or things that show up in a textbook that hopefully
1236
02:33:01,760 --> 02:33:08,239
so let's take a look at some examples here and we'll work through
1237
02:33:08,239 --> 02:33:15,199
a town's population increased at a constant rate in 2010 the
1238
02:33:15,200 --> 02:33:23,600
population had increased to 76,000 if this trend continues predict
1239
02:33:23,600 --> 02:33:34,640
want to notice that these are two x y coordinates time and
1240
02:33:34,639 --> 02:33:45,519
going to be on the x-axis almost all the time so if we look at
1241
02:33:47,200 --> 02:33:59,760
or 2012 76,000 so when we when we do this we have I could make
1242
02:33:59,760 --> 02:34:07,600
hey this is the beginning of this situation I'll call it time zero
1243
02:34:07,600 --> 02:34:16,880
these are nice even thousand so I just might call it 55 so time
1244
02:34:16,879 --> 02:34:26,799
is when we have the next year so that's two years later so two and
1245
02:34:26,799 --> 02:34:33,199
that we're recognizing these as you know x y coordinates that we
1246
02:34:33,200 --> 02:34:40,240
going to use that we're going to predict in 2016 so let's take a
1247
02:34:40,239 --> 02:34:48,319
hopefully you've already been putting together some things that
1248
02:34:48,319 --> 02:34:54,239
you know your co-lab notebooks so that you would already have this
1249
02:34:54,239 --> 02:34:59,760
know graph you've already done the imports this is the only thing
1250
02:34:59,760 --> 02:35:05,200
this for the two points and then we're going to calculate the
1251
02:35:05,760 --> 02:35:18,960
so x1 0 y1 is 55 x2 I would want that to be 2 and y2 is 76 so you
1252
02:35:18,959 --> 02:35:31,919
0 55 2012 76 000 and these this would then be the only thing you
1253
02:35:31,920 --> 02:35:39,360
because all the rest of this you'd have this you know already set
1254
02:35:39,360 --> 02:35:43,920
you know we're going to calculate the slope we're going to use
1255
02:35:43,920 --> 02:35:51,680
now we happen to know because we have x1 is 0 so we know that the
1256
02:35:52,159 --> 02:36:00,239
but that's okay we're going to print out the equation and then our
1257
02:36:00,239 --> 02:36:09,520
normally have this set at you know negative x min negative 10 x
1258
02:36:09,520 --> 02:36:14,880
maximum 10 so this is the other thing that we would change because
1259
02:36:15,440 --> 02:36:26,239
an x minimum of negative 10 so in time that would be 10 years ago
1260
02:36:26,239 --> 02:36:33,039
to worry about going in the past and making that negative 10 so
1261
02:36:33,040 --> 02:36:39,600
I'll just keep it at zero and we can you know look at it from
1262
02:36:39,600 --> 02:36:44,559
that's probably just as good you know we're looking at the most
1263
02:36:45,200 --> 02:36:56,159
and y minimum I'll also make that zero actually because y is
1264
02:36:56,159 --> 02:37:00,159
than zero would just be weird negative population they're not
1265
02:37:00,159 --> 02:37:08,399
anything all right or y maximum and I picked 150 because we
1266
02:37:08,399 --> 02:37:13,600
going to 76 and we're predicting a few years in the future so I
1267
02:37:13,600 --> 02:37:20,159
didn't seem like enough so we could always change these so all we
1268
02:37:20,159 --> 02:37:25,680
notice all the other things for the line that we're going to graph
1269
02:37:25,680 --> 02:37:35,440
printing out this line I'm still just using these x min and max
1270
02:37:35,440 --> 02:37:41,360
this line and we're just doing the line that way there's other
1271
02:37:41,360 --> 02:37:46,079
for how we're going to display this line this this works for
1272
02:37:48,319 --> 02:37:53,920
and we still keep our basic setup now here's where we're also add
1273
02:37:53,920 --> 02:38:01,040
have these and you could also comment these out and then use them
1274
02:38:01,040 --> 02:38:08,080
commented out about setting the x ticks and the y ticks we'll see
1275
02:38:08,079 --> 02:38:15,200
to change that and you might have the default x label as x values
1276
02:38:15,200 --> 02:38:23,280
can change these here time and population and I like I like seeing
1277
02:38:23,280 --> 02:38:29,680
situation so I'm going to put that in as true so we have these
1278
02:38:29,680 --> 02:38:35,360
could have your setup and have these all commented out that all
1279
02:38:36,000 --> 02:38:42,879
as needed and then there we go we're going to plot this linear
1280
02:38:42,879 --> 02:38:51,119
like when we run it so we figured out the equation so it's going
1281
02:38:51,120 --> 02:38:58,960
so we see this trend and we see it starts at 55 increasing about
1282
02:39:01,200 --> 02:39:11,280
so year two we see yeah I'll estimate that as 76 year four and
1283
02:39:11,280 --> 02:39:23,040
now this might not be exactly 120 we could we could plug that in
1284
02:39:23,040 --> 02:39:31,120
the equation you know what what is the value at six years but also
1285
02:39:31,120 --> 02:39:34,960
I didn't worry about changing the tick marks because the default
1286
02:39:34,959 --> 02:39:44,479
actually ends up being pretty good so there we go as a good enough
1287
02:39:45,440 --> 02:39:52,480
for you know population estimates you know you know the fact that
1288
02:39:52,479 --> 02:39:59,439
or something like that you know our rough estimate is going to be
1289
02:39:59,440 --> 02:40:05,760
and then we have our dice labels time and population the grid
1290
02:40:05,760 --> 02:40:13,680
we want to do this we can you know we can set up this equation and
1291
02:40:13,680 --> 02:40:19,760
answer all these questions there we go we see the trend and we can
1292
02:40:19,760 --> 02:40:26,960
that's about 120,000 all right now here's another one the number
1293
02:40:26,959 --> 02:40:38,159
cold dropped steadily by 50 each year since 2004 until 2010 okay
1294
02:40:38,159 --> 02:40:48,399
here so dropped steadily then we're talking about a subtraction
1295
02:40:48,399 --> 02:40:59,119
since 2004 is the first not first year we we mentioned this now
1296
02:40:59,120 --> 02:41:04,640
life yes they wouldn't be perfectly linear but a lot of times that
1297
02:41:04,639 --> 02:41:10,399
enough approximation and that's that's the idea for some of these
1298
02:41:10,399 --> 02:41:18,879
so now we have in 2004 875 people were inflicted and notice even
1299
02:41:18,879 --> 02:41:28,159
definitely see there's your xy value year and then afflicted and
1300
02:41:29,440 --> 02:41:36,239
so one of the things that we can do here well this is find the
1301
02:41:36,239 --> 02:41:44,239
things we can do is I can make 2004 times zero and then that's
1302
02:41:46,559 --> 02:41:53,439
so if we take a look at this 2004
1303
02:41:55,120 --> 02:42:01,280
I'll make that time zero and then this one I'm going to make 875
1304
02:42:01,280 --> 02:42:16,159
875 all right so now if it drops steadily by 50 each year all we
1305
02:42:16,159 --> 02:42:23,680
more point if this is linear so we can just do the subtract you
1306
02:42:23,680 --> 02:42:37,920
here then if we have year one then it drops 50 so then that's
1307
02:42:37,920 --> 02:42:45,120
that's all we need two points and we'll be able to do everything
1308
02:42:45,120 --> 02:42:54,480
the intercept and display the equation I might even well now the
1309
02:42:54,479 --> 02:43:07,279
anything so you know number of people afflicted you know okay how
1310
02:43:07,280 --> 02:43:16,480
of cases of the flu there we go so there we go time cases and you
1311
02:43:16,479 --> 02:43:27,520
shift enter or click this and we see this trend negative 50 was
1312
02:43:27,520 --> 02:43:34,560
negative 50 x plus 875 and a lot of times you would see this
1313
02:43:34,559 --> 02:43:43,600
and then subtract but that's okay now also this notice that you
1314
02:43:43,600 --> 02:43:53,280
to show anything why because it started 875 and you see 140
1315
02:43:54,239 --> 02:44:01,760
x minimum and maximum that's fine y minimum that's fine but y
1316
02:44:01,760 --> 02:44:09,360
maybe I'll call it like 900 so now we can see
1317
02:44:11,840 --> 02:44:17,600
the graph and sometimes you know you graph it and you say well why
1318
02:44:17,600 --> 02:44:23,600
look and see oh it's the window out of bounds here so there's 875
1319
02:44:23,600 --> 02:44:31,280
so there we go and we can use this to predict you know in in any
1320
02:44:31,280 --> 02:44:35,840
to get the exact amount we can you know for any any year we can
1321
02:44:36,719 --> 02:44:46,559
and then solve so that works and remember that even works within a
1322
02:44:46,559 --> 02:44:50,879
you know so the interesting thing is this plot dot show
1323
02:44:52,879 --> 02:44:57,439
um that needs to be last so if I do another print statement I
1324
02:45:05,040 --> 02:45:11,040
you know the same place where I print this I could print so
1325
02:45:11,040 --> 02:45:24,000
print this I could print so what if the question was how many you
1326
02:45:24,000 --> 02:45:29,920
the flu we might say oh look at this two years later you know we
1327
02:45:29,920 --> 02:45:37,600
subtraction so let's say like five years and you see given our
1328
02:45:37,600 --> 02:45:44,239
trend we can estimate it but we don't know exactly you know it's
1329
02:45:44,239 --> 02:45:50,879
can say oh about in about five five years how many people were
1330
02:45:50,879 --> 02:46:00,479
I want that exact number so I can go back to this and then x is
1331
02:46:00,479 --> 02:46:08,479
is in the print statement you can actually just do do the math and
1332
02:46:08,479 --> 02:46:19,439
print statement if you want but we can just do our math here
1333
02:46:19,440 --> 02:46:29,440
so we see you know our negative 50 times five plus 875 and that
1334
02:46:29,440 --> 02:46:35,920
be the value what would be the number of people afflicted after
1335
02:46:35,920 --> 02:46:42,799
have a more elaborate print statement to say something but since
1336
02:46:42,799 --> 02:46:50,079
question is now that that's 625 that that means something to me
1337
02:46:50,719 --> 02:46:57,039
that that might be you know could I estimate it exactly oh that's
1338
02:46:57,040 --> 02:47:02,640
can plug in the number and get it so we see you know some
1339
02:47:02,639 --> 02:47:09,199
we can answer some questions do some math for you know some
1340
02:47:09,200 --> 02:47:21,120
to this now all right all right linear function so here's another
1341
02:47:21,120 --> 02:47:29,360
afflicted so we want to know looking at this graph when is the y
1342
02:47:29,360 --> 02:47:39,120
be zero now rather than now one of the things you could expand the
1343
02:47:39,120 --> 02:47:45,280
until it gets to zero we'll come back and do that in a second but
1344
02:47:46,079 --> 02:47:57,920
is if you already also have your setup to solve an equation so you
1345
02:47:57,920 --> 02:48:03,840
this was the whole setup to solve an equation and print the
1346
02:48:03,840 --> 02:48:09,440
to do here we keep this equation variable the only thing we need
1347
02:48:09,440 --> 02:48:22,640
this case i'll put it here h 75 minus 50 x and remember it's
1348
02:48:22,639 --> 02:48:34,719
so that's by default set equal to zero so when we run it so the
1349
02:48:34,719 --> 02:48:44,319
that gave us a fraction but there you go so that's 17.5 so 17.5
1350
02:48:44,319 --> 02:48:53,840
so yeah now again fictional numbers i feel like you know in 17.5
1351
02:48:53,840 --> 02:49:00,239
going to be that nobody has the flu or something like that but we
1352
02:49:00,239 --> 02:49:12,239
and we can change the x maximum to 18 and then we can see this
1353
02:49:12,239 --> 02:49:25,039
according to this trend you know time zero and that would be you
1354
02:49:25,040 --> 02:49:37,360
case according to these numbers who knows it may in some
1355
02:49:37,360 --> 02:49:50,079
or 18 years that would be like 2022 and yeah i feel like that
1356
02:49:50,079 --> 02:49:56,000
nobody afflicted with the common cold all right but anyway you see
1357
02:49:57,040 --> 02:50:02,640
the these are realistic enough that we can use these to take a
1358
02:50:02,639 --> 02:50:08,559
and this is what we want to use this math for predicting trends
1359
02:50:08,559 --> 02:50:16,959
have so here's another one where they even give you the partial
1360
02:50:18,159 --> 02:50:25,360
all right so this is showing profit so this figure one is showing
1361
02:50:25,360 --> 02:50:36,319
in a given year x and they also do x represents years since 1980
1362
02:50:36,319 --> 02:50:48,719
zero is 1980 so then 20 so so 20 that would be 2000 and 30 that'd
1363
02:50:48,719 --> 02:50:57,439
we go now given these we want to find the linear function all
1364
02:50:57,440 --> 02:51:03,760
want to look at these i just want to find two nice points that i
1365
02:51:03,760 --> 02:51:14,479
estimating the points so i like this first one at year five it was
1366
02:51:14,479 --> 02:51:27,520
because it says y in thousands so therefore 10 000 would be 10
1367
02:51:27,520 --> 02:51:35,840
thousands then 10 000 would be 10 million in which case they could
1368
02:51:35,840 --> 02:51:45,680
but that's okay and then we have so five i'm going to shift it to
1369
02:51:45,680 --> 02:51:57,360
y value 10 so five ten and then let's find another nice point i
1370
02:51:57,360 --> 02:52:05,520
and we can plug in in these so i don't have that zero value and
1371
02:52:05,520 --> 02:52:17,280
at some point so five years then we're talking 10 million and then
1372
02:52:19,760 --> 02:52:25,920
then we were talking two four
1373
02:52:34,239 --> 02:52:41,760
okay so there we go we have that point five years 10 million 25
1374
02:52:43,280 --> 02:52:53,680
since we already see this graph since i made them 10 i really
1375
02:52:53,680 --> 02:53:01,840
a look at this and say oh yeah 12 is probably fine as far as a y
1376
02:53:01,840 --> 02:53:14,000
this to 30 or you know we can take it further so when i go to
1377
02:53:14,000 --> 02:53:21,760
going to be enough maybe i'll just make it a nice round 50 y
1378
02:53:21,760 --> 02:53:27,040
would the scale would be so much it would this would just be in
1379
02:53:27,040 --> 02:53:34,640
so maybe we'll just call that 15 or something like that all right
1380
02:53:43,440 --> 02:53:48,720
like the space in there we could just delete this and we have i'm
1381
02:53:48,719 --> 02:53:59,039
the equation so when we run it so here's our equation negative
1382
02:53:59,040 --> 02:54:10,640
and we see this downward trend over time and here's another one
1383
02:54:11,680 --> 02:54:21,520
change these tick marks maybe i could change this to the x ticks
1384
02:54:21,520 --> 02:54:33,440
is two enough yeah yeah maybe and then i can change the y ticks is
1385
02:54:34,319 --> 02:54:44,959
and we'll run it so we see we get much many more lines all right
1386
02:54:44,959 --> 02:54:57,919
we see we get much many more lines all right and with that we see
1387
02:54:57,920 --> 02:55:06,479
now just because these end up being rectangles more i might change
1388
02:55:06,479 --> 02:55:12,159
i just like that better and you know in doing this you can you
1389
02:55:12,159 --> 02:55:22,559
go there we go so with this then we can really see the trend
1390
02:55:22,559 --> 02:55:33,439
this downward trend down 0.3 so it should go you know over 10 it
1391
02:55:33,440 --> 02:55:42,000
here we go and then 38 years later then they would have no profit
1392
02:55:42,000 --> 02:55:51,040
that we're saying there we go so whatever this company is this is
1393
02:55:51,840 --> 02:55:55,840
and then and then there we go um
1394
02:55:55,840 --> 02:56:04,960
um 38 years later then they would have no more profit so who knows
1395
02:56:04,959 --> 02:56:11,439
you know our fictional company is you know something would have to
1396
02:56:11,440 --> 02:56:18,560
the prediction lines you know the the the simplest prediction is
1397
02:56:18,559 --> 02:56:25,840
line whatever trend would continue in a straight line unless
1398
02:56:25,840 --> 02:56:30,880
uh normal business normal day-to-day life things do change and
1399
02:56:30,879 --> 02:56:38,879
perfectly straight but this gives a often enough of a prediction
1400
02:56:38,879 --> 02:56:51,759
cases then we would change that to profit okay just just to make
1401
02:56:52,799 --> 02:57:02,239
so there we go another another situation and we can see where it
1402
02:57:02,239 --> 02:57:11,600
profit declining and that's enough years that you know 11.5
1403
02:57:11,600 --> 02:57:17,200
and then profit declining and yeah so this this company is
1404
02:57:17,200 --> 02:57:25,200
there you know they were in uh in sad shape all right and we have
1405
02:57:25,200 --> 02:57:32,800
okay so we see another very very similar we'll do we'll do one
1406
02:57:32,799 --> 02:57:41,840
2004 school population was 1700 by 2012 the population had grown
1407
02:57:41,840 --> 02:57:50,559
again assume assume the population is growing linearly all right
1408
02:57:50,559 --> 02:57:57,680
now how much did the population grow so this a is really just the
1409
02:57:58,959 --> 02:58:09,359
so 2500 minus 1700 is 800 so it grew that much and then the
1410
02:58:10,719 --> 02:58:19,359
anything per year the rate that's the slope and we can divide that
1411
02:58:19,360 --> 02:58:26,239
just plug these numbers in and you'll see that we can see the
1412
02:58:26,239 --> 02:58:39,199
time zero 2004 1700 2012 2500 and i might even leave the hundreds
1413
02:58:39,840 --> 02:58:46,239
you know more exact we know that the population would be
1414
02:58:46,239 --> 02:59:03,680
so 1700 and then y minimum and then we have 2500 so then after
1415
02:59:03,680 --> 02:59:19,040
yes then my y maximum on the oh i put in the wrong so there you go
1416
02:59:19,040 --> 02:59:38,480
1500 and so in 2012 so time zero and then in 2012 so that's eight
1417
02:59:40,319 --> 02:59:42,959
so eight years later then it was 2500
1418
02:59:42,959 --> 02:59:50,959
so here we go okay so we'll have that and
1419
02:59:53,120 --> 03:00:00,720
x minimum and then the x maximum so let's just make it a nice even
1420
03:00:02,879 --> 03:00:09,439
and we could always change it if we need to y maximum 2500 but
1421
03:00:09,440 --> 03:00:14,960
further so let's make it 3000 and see if that's going to be
1422
03:00:20,559 --> 03:00:30,959
there we go and do i want the ticks for right now see if you
1423
03:00:30,959 --> 03:00:41,359
as we saw it will still give you the it will still give you the
1424
03:00:41,360 --> 03:00:47,440
default whatever python wanted to calculate and where you can
1425
03:00:47,440 --> 03:01:08,480
want there we go and for school population yeah all right so we
1426
03:01:15,360 --> 03:01:21,920
and maybe that's you know depending on what you wanted to estimate
1427
03:01:21,920 --> 03:01:32,079
the grid might be fine and you know if you wanted to you could
1428
03:01:32,079 --> 03:01:43,360
i think that works out so growing by 100 every year and we can use
1429
03:01:43,360 --> 03:01:51,680
probably growth per year was 100 there we go 100 x so the slope is
1430
03:01:51,680 --> 03:01:58,720
and there's the equation for the population for two years after
1431
03:02:02,239 --> 03:02:07,840
so we see you know we've done a few of these i think i think we
1432
03:02:07,840 --> 03:02:16,399
population model but there's some other form there's some other uh
1433
03:02:16,399 --> 03:02:21,359
in other tech all these all these are coming from that uh textbook
1434
03:02:21,360 --> 03:02:28,640
trigonometry because that's a lot of good business applications in
1435
03:02:28,639 --> 03:02:37,039
that just the notation g equals f of p the amount of garbage g
1436
03:02:37,040 --> 03:02:44,000
population p so we can go a g equals f of p and that's how we
1437
03:02:44,000 --> 03:02:51,040
of population and what that tells us is population is the
1438
03:02:51,040 --> 03:03:00,160
the dependent and population very often is an independent variable
1439
03:03:00,159 --> 03:03:07,119
trends so we look at that and we see the same type of thing the
1440
03:03:07,120 --> 03:03:14,800
thousand and produced 13 tons of garbage each week express this
1441
03:03:16,959 --> 03:03:28,079
so now if we have this one of the things that we would guess is
1442
03:03:28,079 --> 03:03:40,079
population then no people would mean no garbage so in our y equals
1443
03:03:40,079 --> 03:03:50,319
zero and notice we because we only get exactly one point here
1444
03:03:50,319 --> 03:03:56,479
so if we wanted to set this up you know we want to look you know
1445
03:03:57,520 --> 03:04:03,280
python scripts to solve this but if we want to set this up we want
1446
03:04:04,239 --> 03:04:09,119
how we're going to set this up 40,000 is going to be the
1447
03:04:09,120 --> 03:04:15,840
just call it in thousands and then 13,000 is going to be the
1448
03:04:15,840 --> 03:04:23,200
just call it in thousands and then 13 tons same thing i'll just
1449
03:04:25,680 --> 03:04:31,760
and then we say well that's one point where do i get the second
1450
03:04:31,760 --> 03:04:40,319
situation would i think that it would start at zero zero and if
1451
03:04:40,319 --> 03:04:51,600
back and say so here's zero zero and then remember our x values
1452
03:04:52,159 --> 03:05:00,639
so we'll call that 40 and then that's going to be 13 because it's
1453
03:05:00,639 --> 03:05:12,719
and therefore the x minimum zero fine but x maximum 40 is probably
1454
03:05:12,719 --> 03:05:19,199
um 40 is probably not even enough because we start with that and
1455
03:05:19,200 --> 03:05:31,760
and we can expect that it increases so then let's say the x
1456
03:05:31,760 --> 03:05:44,960
it 100 and we'll see y minimum zero now 13 maybe make it like 50
1457
03:05:44,959 --> 03:05:56,079
enough of a y maximum so there we go and we can just write this in
1458
03:06:06,319 --> 03:06:08,799
so thousands of people tons of garbage
1459
03:06:08,799 --> 03:06:22,399
so we have this trend here there we go 40,000 generates 13 tons of
1460
03:06:23,840 --> 03:06:35,200
and we can see this trend here so there's the rate here 0.325
1461
03:06:35,200 --> 03:06:47,600
0.325 x so remember the x value is in thousands so every thousand
1462
03:06:50,559 --> 03:06:59,840
according to this fictional scenario makes 300.325 tons so that
1463
03:06:59,840 --> 03:07:07,760
about tons 2,000 pounds so that times 2,000 would be about 650
1464
03:07:09,680 --> 03:07:20,800
but then if that's thousands of people so that's each person
1465
03:07:20,799 --> 03:07:36,479
less than a pound of garbage maybe so again this is this is not
1466
03:07:37,280 --> 03:07:43,040
you know a couple numbers that seem realistic and then what's the
1467
03:07:43,040 --> 03:07:53,680
would read this as f of five equals two so notice that the
1468
03:07:53,680 --> 03:08:01,200
that five is the input and any input or independent variable
1469
03:08:02,719 --> 03:08:10,559
even though we call them p and g here so that input five and then
1470
03:08:10,559 --> 03:08:20,479
so we would expect then that that means that when we're talking
1471
03:08:21,600 --> 03:08:29,920
then the 5,000 people would produce two tons of garbage so that's
1472
03:08:29,920 --> 03:08:37,600
five is the input two is the output so in our x y scenario here
1473
03:08:37,600 --> 03:08:43,520
that's what that would mean 5,000 people would produce two tons of
1474
03:08:46,879 --> 03:08:56,879
all right and so let's go over here to 89 and another one you see
1475
03:08:56,879 --> 03:09:02,879
alphabet soup of of this as people use different notation notice
1476
03:09:02,879 --> 03:09:12,079
of i would read this as g of a so it's a function of this input a
1477
03:09:12,079 --> 03:09:20,399
dirt d is needed to need to cover a garden with a square feet so d
1478
03:09:21,280 --> 03:09:29,280
and we read like that g of a and the common notation you'll see in
1479
03:09:29,280 --> 03:09:35,760
f for function and then often we just go through the alphabet fgh
1480
03:09:35,760 --> 03:09:42,000
talk about in python and pretty much across computer science your
1481
03:09:42,000 --> 03:09:48,399
have a much better name so you know that's something that computer
1482
03:09:49,360 --> 03:09:54,720
but nonetheless you'll see this all the time you know g of a so
1483
03:09:54,719 --> 03:10:05,840
input that's the area and then given that area then how much dirt
1484
03:10:07,200 --> 03:10:19,120
square feet area requires 50 cubic yards of dirt so that 5,000
1485
03:10:19,120 --> 03:10:27,680
to do any calculations to this but i just want to show you that it
1486
03:10:34,319 --> 03:10:41,760
so that's just how we would write that given that input you know
1487
03:10:41,760 --> 03:10:47,040
first then therefore how much dirt we need and that that would
1488
03:10:47,040 --> 03:10:53,520
write that there's we don't need to do any math to that right now
1489
03:10:53,520 --> 03:11:04,960
one so 100 cubic yards or 100 square feet of garden requires one
1490
03:11:04,959 --> 03:11:18,799
all right and number and question 90 we'll see just another
1491
03:11:18,799 --> 03:11:27,920
function the number of ducks in the lake after t years after 1990
1492
03:11:27,920 --> 03:11:38,639
five is the time years after 1990 so in 1995 there were 30 ducks
1493
03:11:38,639 --> 03:11:48,559
years so in 2000 there were 40 ducks in the lake and given these
1494
03:11:48,559 --> 03:11:54,319
find the overall equation plot the points graph it you know make
1495
03:11:54,319 --> 03:12:06,000
the notation here and this is what that means all right now 91 the
1496
03:12:06,000 --> 03:12:12,319
just answering these questions it this won't matter but this is
1497
03:12:13,200 --> 03:12:17,200
but we can still answer these questions because each of these is
1498
03:12:17,200 --> 03:12:24,079
each of these is still going to be the same now notice h of t and
1499
03:12:24,079 --> 03:12:34,319
you know again another way of expressing this so as x y values x
1500
03:12:34,319 --> 03:12:44,879
the h of one is 200 so that x value is t for time in seconds so
1501
03:12:44,879 --> 03:12:52,559
after two seconds it's 350 feet up and again this is not linear
1502
03:12:54,239 --> 03:12:58,799
the same things that we've been doing actually won't work for this
1503
03:12:58,799 --> 03:13:10,399
meaning of each statement here and 92 the one to one is this is
1504
03:13:10,399 --> 03:13:16,559
x value like each x value and y value pair up like that neither of
1505
03:13:16,559 --> 03:13:23,119
parabola because we see x squared and we'll talk about parabolas
1506
03:13:24,159 --> 03:13:31,039
that there's actually positive x values and negative x values that
1507
03:13:32,159 --> 03:13:35,280
so that's why it's just not one to one but it's still a function
1508
03:13:35,280 --> 03:13:38,960
i don't want to talk too much about that we'll get to these these
1509
03:13:38,959 --> 03:13:43,119
want to mention that in case you're looking at that and saying
1510
03:13:45,760 --> 03:13:54,319
so in number 60 now this is also not linear and you see the height
1511
03:13:54,319 --> 03:14:03,440
something like this after t seconds here's the function h of t is
1512
03:14:03,440 --> 03:14:08,800
seconds here's the function h of t equals negative 16 t squared
1513
03:14:10,319 --> 03:14:18,079
so that's showing that you know it isn't linear in fact it's a
1514
03:14:18,079 --> 03:14:26,000
around comes back down okay so the domain anytime we talk about
1515
03:14:26,000 --> 03:14:33,920
so the domain is all the x values that are possible here and then
1516
03:14:33,920 --> 03:14:46,879
the range is all the y values and this actually has a limited
1517
03:14:46,879 --> 03:14:54,799
parabola that goes up and then comes back down there's a maximum y
1518
03:14:54,799 --> 03:15:01,759
after that y value there's no more like y values beyond that are
1519
03:15:01,760 --> 03:15:09,360
it'll just never get to those numbers then the domain
1520
03:15:09,360 --> 03:15:19,680
numbers but realistically in the context of the problem time zero
1521
03:15:19,680 --> 03:15:26,159
domain so you see mathematically these other numbers exist and
1522
03:15:26,159 --> 03:15:33,840
but realistically if i'm launching something it starts at time
1523
03:15:33,840 --> 03:15:40,479
can talk about t minus whatever and talk about negative values
1524
03:15:40,479 --> 03:15:48,559
you know and this is second so if it's like t minus 10 then it's
1525
03:15:48,559 --> 03:15:56,319
10 and that's 10 seconds until the launch but realistically we're
1526
03:15:56,319 --> 03:16:03,199
and then the other one would be it does go up and comes back down
1527
03:16:03,200 --> 03:16:09,760
the ground again and beyond that it's not really within the scope
1528
03:16:09,760 --> 03:16:15,360
look at how we can solve this just because even though that's
1529
03:16:15,360 --> 03:16:21,360
i want to find out what that t value is when does it come back
1530
03:16:21,920 --> 03:16:31,680
negative 16 t plus 96 t we can go into this where we're going to
1531
03:16:31,680 --> 03:16:36,639
t we're going to make it x just because i already have x as a
1532
03:16:36,639 --> 03:16:52,479
and make a t that's fine so negative 16 and again we're going to
1533
03:16:54,959 --> 03:17:04,479
x and that's always the this is the equation set equal to zero and
1534
03:17:04,479 --> 03:17:17,920
makes the zero now negative six would not be
1535
03:17:20,639 --> 03:17:25,119
plus 96 t oh because i put minus
1536
03:17:30,079 --> 03:17:41,520
so it only gives us zero what if i have
1537
03:17:44,959 --> 03:17:53,519
so i was doing this with things that only had one solution so
1538
03:17:53,520 --> 03:18:01,840
just printed the first one but this does have two solutions you
1539
03:18:01,840 --> 03:18:06,479
could get really fancy here and then actually just make another
1540
03:18:06,479 --> 03:18:15,680
finite set it's not zero six as a coordinate it's x equals zero or
1541
03:18:15,680 --> 03:18:25,200
this zero and i could have another print statement
1542
03:18:28,239 --> 03:18:33,600
there we go to show the first one and but this is just a matter of
1543
03:18:33,600 --> 03:18:40,159
output to look okay so i'm going to go ahead and i'm going to go
1544
03:18:40,159 --> 03:18:45,600
show the first one and but this is just a matter of you know how
1545
03:18:49,360 --> 03:18:55,840
and we have these you know we also have the you know which we
1546
03:18:55,840 --> 03:19:02,159
you know loop through this to get solution to get multiple
1547
03:19:02,159 --> 03:19:09,680
x equals zero it's on the ground and then x equals six so that's
1548
03:19:09,680 --> 03:19:18,479
that we could graph this and we see that it back on the ground at
1549
03:19:18,479 --> 03:19:27,119
bit ahead because we'll talk about quadratics later so yes we will
1550
03:19:27,120 --> 03:19:33,440
graphing this because we'll get into this with quadratics but this
1551
03:19:33,440 --> 03:19:40,640
at six at six seconds later it's back on the ground so some
1552
03:19:40,639 --> 03:19:46,719
turned and i'll tell you this that you know halfway through these
1553
03:19:46,719 --> 03:19:58,719
through it's halfway through it's uh at its maximum point so we
1554
03:19:58,719 --> 03:20:06,719
what is that maximum point and we can do that math negative 16
1555
03:20:13,120 --> 03:20:20,320
so halfway through that so that would be three would be x and you
1556
03:20:20,319 --> 03:20:27,760
that you know we set up the situation where i have x and then i
1557
03:20:27,760 --> 03:20:37,600
zero six it's back on the ground so three seconds later it goes
1558
03:20:39,520 --> 03:20:48,079
so realistically then the domain for this function as that's
1559
03:20:48,079 --> 03:20:54,639
you know mathematically it exists but related to this situation
1560
03:20:54,639 --> 03:21:00,799
values that mean anything for this are anywhere between zero and
1561
03:21:02,079 --> 03:21:07,760
because everything else doesn't really mean anything for this
1562
03:21:07,760 --> 03:21:13,200
this then if it keeps going down like it doesn't go back down into
1563
03:21:13,200 --> 03:21:21,920
are between zero and 144 so that's my domain between zero and six
1564
03:21:21,920 --> 03:21:29,920
range between zero and 144 so you know these are some things we
1565
03:21:29,920 --> 03:21:33,280
when does it equal zero and plug in some various numbers
1566
03:21:37,600 --> 03:21:46,399
all right so if we look at 61 just again reading reading is these
1567
03:21:46,399 --> 03:21:52,479
any code for this we have this situation the cost of making x
1568
03:21:53,920 --> 03:22:00,479
and the fixed cost is determined when zero items are produced so
1569
03:22:00,479 --> 03:22:07,039
zero so then if x is zero that 10 x drops out and then we're left
1570
03:22:07,040 --> 03:22:15,840
it's b for begin you know when you know before we produce anything
1571
03:22:15,840 --> 03:22:23,200
now maybe this is some sort of business and 500 is like rent and
1572
03:22:23,200 --> 03:22:26,960
even if they're there they didn't make anything they still had to
1573
03:22:26,959 --> 03:22:30,319
and then they pay ten dollars for whatever you know for whatever
1574
03:22:30,319 --> 03:22:44,079
so then the cost of making 25 items would be 10 times 25 we just
1575
03:22:45,680 --> 03:22:55,360
all right and supposing the maximum cost allowed is 1500 what is
1576
03:22:55,360 --> 03:23:07,280
have to set this equal to 1500 now if we take a look at this and
1577
03:23:07,280 --> 03:23:18,960
so if we have 1500 equals 10 x plus 500 and notice i'm not this
1578
03:23:18,959 --> 03:23:26,879
worried about doing anything with this yet but then what do i want
1579
03:23:26,879 --> 03:23:39,119
to zero so if i subtract 1500 from both sides then i get zero
1580
03:23:39,120 --> 03:23:49,360
because if i subtract 1500 from both sides and so that's set equal
1581
03:23:50,319 --> 03:23:56,719
that's where i could plug this in here so you see you can work out
1582
03:23:56,719 --> 03:24:10,639
python code so 10 and then here i do need 10 x minus 1000 so if
1583
03:24:10,639 --> 03:24:16,799
one i know there's only one solution so if i keep the other one
1584
03:24:16,799 --> 03:24:24,000
i know there's only one solution so if i keep the other one that's
1585
03:24:25,920 --> 03:24:29,200
so whatever it is we know that we could only make a hundred
1586
03:24:30,719 --> 03:24:35,679
because you know maybe they only have that budget you know
1587
03:24:35,680 --> 03:24:43,280
hundred of them their total expenses were 15 total expenses were
1588
03:24:43,280 --> 03:24:49,760
you know then we have to go out and sell whatever they are i don't
1589
03:24:50,559 --> 03:24:53,920
whatever they're whatever else they're making all right
1590
03:24:56,879 --> 03:25:02,559
okay so we and we see these same types of things we i just want to
1591
03:25:02,559 --> 03:25:10,879
that at the number 44 at the start of the trip the odometer on a
1592
03:25:10,879 --> 03:25:17,599
at the end of the trip 13.5 hours later the odometer read 22 125
1593
03:25:18,959 --> 03:25:25,839
there we go assuming the scale is miles so average speed we want
1594
03:25:25,840 --> 03:25:31,760
anything like a rate like that that slope and we have two values
1595
03:25:31,760 --> 03:25:40,719
21 395 and then time 13.5 and then the miles and we can go through
1596
03:25:40,719 --> 03:25:45,760
about graphing this or not it still will output the slope which is
1597
03:25:45,760 --> 03:25:54,880
the average speed and that's where average speed it would be a
1598
03:25:54,879 --> 03:26:02,079
we know especially over 13.5 hours the speed's going up and down
1599
03:26:02,079 --> 03:26:09,440
sometimes faster sometimes slower but we get that average speed we
1600
03:26:09,440 --> 03:26:19,680
they're not going to that exact speed the entire time all right
1601
03:26:19,680 --> 03:26:25,040
gas station to fill up his tank and he looked at his watch the
1602
03:26:25,040 --> 03:26:32,160
started pumping gas in the tank exactly 344 the tank was full now
1603
03:26:32,159 --> 03:26:38,000
minutes especially with these prices these days i would be
1604
03:26:38,000 --> 03:26:47,040
money but he noticed he had pumped 10.7 gallons so surprisingly
1605
03:26:47,040 --> 03:26:54,880
but what is the average rate of flow of the gasoline so again time
1606
03:26:54,879 --> 03:27:03,359
we want to call it minutes we can call it four minutes and then
1607
03:27:03,360 --> 03:27:12,960
to gallons per minute or and again same thing plug it in you know
1608
03:27:12,959 --> 03:27:20,079
because we already did that subtraction is just 10.7 divided by
1609
03:27:20,079 --> 03:27:24,479
you have these scripts and everything available but some of these
1610
03:27:24,479 --> 03:27:29,279
even before you look at those or you could break it down into
1611
03:27:29,280 --> 03:27:36,640
in four minutes and you know the rate of flow per second but
1612
03:27:36,639 --> 03:27:43,279
gallons per minute is probably fine so we see all these situations
1613
03:27:43,280 --> 03:27:49,360
how we can set these up and the things that you're building that
1614
03:27:49,360 --> 03:27:54,800
an equation even if you know the equation is something else and
1615
03:27:54,799 --> 03:28:01,119
algebra you know because that's it you want to get it equal to
1616
03:28:01,120 --> 03:28:06,240
from earlier that one step of algebra so then you have it equal to
1617
03:28:06,239 --> 03:28:14,879
so you'll have these things set up solve any equation or you know
1618
03:28:14,879 --> 03:28:20,159
rate all that so you know if all you needed was the rate you know
1619
03:28:20,159 --> 03:28:26,319
bonus but it'll still also answer that question for you so we want
1620
03:28:26,319 --> 03:28:33,680
ways that we can interpret these questions and solve solve the
1621
03:28:33,680 --> 03:28:40,960
of some of the keywords and hopefully you see how you can apply
1622
03:28:40,959 --> 03:28:46,719
that you come across you know look look for situations in in your
1623
03:28:46,719 --> 03:28:56,799
you can apply these all right so hopefully that was pretty useful
1624
03:28:56,799 --> 03:29:04,479
factoring in algebra then we're going to talk about dividing out
1625
03:29:04,479 --> 03:29:10,319
something that we're multiplying and therefore i'm looking for
1626
03:29:10,319 --> 03:29:19,920
am i multiplying so when i see a number like six then i can say oh
1627
03:29:19,920 --> 03:29:28,079
times three and here i'll put the dot for multiplying to separate
1628
03:29:28,079 --> 03:29:37,120
know when i when i look at a number you know like 15 then what are
1629
03:29:37,120 --> 03:29:46,720
three and it's useful to be able to think about numbers and what
1630
03:29:46,719 --> 03:29:54,399
helps us reduce fractions and simplify other other terms so for
1631
03:29:54,399 --> 03:30:03,840
two numbers here supposing i had a fraction that was six out of 15
1632
03:30:03,840 --> 03:30:10,159
reduce that fraction to lowest terms there's a better way to write
1633
03:30:10,159 --> 03:30:18,719
that they both are divisible by three that three is a factor of
1634
03:30:18,719 --> 03:30:27,760
divided by three is two and fifteen divided by three is five and
1635
03:30:27,760 --> 03:30:35,360
is five and so this is the that reduced fraction and i got this by
1636
03:30:35,360 --> 03:30:41,520
factors and i divided out those common factors so just like other
1637
03:30:41,520 --> 03:30:48,399
thing to the left side of the equal sign and the right then it's
1638
03:30:48,399 --> 03:30:53,440
if i do the same thing to the top as i do to the bottom but that
1639
03:30:53,440 --> 03:31:01,200
and dividing adding or subtracting doesn't doesn't work so if i
1640
03:31:02,079 --> 03:31:11,280
reduce my factors i can even keep going supposing i had something
1641
03:31:13,760 --> 03:31:19,440
and supposing i didn't recognize that 20 that six was a factor of
1642
03:31:19,440 --> 03:31:30,560
were both even so i could then divide by two six divided by two is
1643
03:31:32,559 --> 03:31:39,359
i could start reducing again recognizing that common factor or
1644
03:31:39,360 --> 03:31:46,079
oh three and twelve both divisible by three and then i could say
1645
03:31:46,079 --> 03:31:53,520
twelve divided by three is four so again i factored things out and
1646
03:31:54,319 --> 03:32:00,479
now a lot of times you know we see things and we don't we see
1647
03:32:00,479 --> 03:32:04,959
especially bigger numbers we don't right away think about the
1648
03:32:04,959 --> 03:32:14,079
do long division in a couple minutes i'll show you how to how to
1649
03:32:14,079 --> 03:32:20,639
to find the common factors that way even if you don't see them or
1650
03:32:20,639 --> 03:32:24,719
do i go through all these possible factors i'll show you how to
1651
03:32:24,719 --> 03:32:31,039
to do that find those common factors but this is one of the big
1652
03:32:32,079 --> 03:32:40,079
and this is more related to other algebra topics we might not need
1653
03:32:40,079 --> 03:32:52,799
code but if i have something like you know 4x plus 16 something
1654
03:32:52,799 --> 03:32:57,920
the four the 16 have a common factor which is four and i can
1655
03:33:00,239 --> 03:33:04,799
and we can divide it out like this way so this is another use of
1656
03:33:04,799 --> 03:33:11,519
because i see these common factors and i divide it out 4x divided
1657
03:33:11,520 --> 03:33:21,200
put x and then 16 divided by 4 is 4 so and again this has more to
1658
03:33:21,200 --> 03:33:26,960
applications but i want to show you this because this is also
1659
03:33:26,959 --> 03:33:32,079
this i see the common factor and i can divide it out and it looks
1660
03:33:32,079 --> 03:33:40,000
the 4 4 times x is 4x 4 times 4 is 16 and get back to that so
1661
03:33:41,360 --> 03:33:45,840
one of the other things we're going to do is talk about factoring
1662
03:33:46,719 --> 03:33:51,119
and that also i'm going to show you how to do this but then we're
1663
03:33:51,760 --> 03:33:57,120
you know how to find common square factors and then factor them
1664
03:33:57,120 --> 03:34:03,360
if i have a square root and sometimes we have square roots that
1665
03:34:03,360 --> 03:34:08,239
not perfect squares but i can factor them and sometimes that helps
1666
03:34:08,239 --> 03:34:21,280
cancel out with other things later so if i have let's say the
1667
03:34:21,280 --> 03:34:27,520
5 that's great square root of 24 almost 5 it'll be some long
1668
03:34:28,079 --> 03:34:33,600
but if i can factor that out recognizing these common factors and
1669
03:34:33,600 --> 03:34:45,120
just any factor i want a square factor so if i remember that 24 is
1670
03:34:45,120 --> 03:34:52,160
4 is a perfect square and then i can say so i want to identify
1671
03:34:52,159 --> 03:34:56,879
the ones that are square factors and four square so the square
1672
03:34:59,760 --> 03:35:06,159
and then since i took the square root of four i still have that
1673
03:35:06,159 --> 03:35:13,119
if i can't square root the whole number i can square root part of
1674
03:35:13,120 --> 03:35:19,600
sometimes then even if i can't factor out something like the
1675
03:35:19,600 --> 03:35:24,720
something like this and that's the simplified square root this
1676
03:35:24,719 --> 03:35:31,599
that's really useful now again bigger numbers things that you
1677
03:35:31,600 --> 03:35:36,559
this a perfect square we'll talk about how to write the code to
1678
03:35:36,559 --> 03:35:44,639
divide them out and even use the simpy library to display it in a
1679
03:35:44,639 --> 03:35:49,840
the essence of what we want to do with factory recognizing factors
1680
03:35:49,840 --> 03:35:54,159
even if you're going to write code the more you remember your
1681
03:35:54,159 --> 03:35:59,680
things will be it just makes things you know come together a
1682
03:35:59,680 --> 03:36:04,720
looking at numbers thinking about what factors made that number
1683
03:36:04,719 --> 03:36:10,639
factors that we could possibly divide out and so let's take a look
1684
03:36:10,639 --> 03:36:18,559
the code so here we're going to do the same thing we were doing
1685
03:36:18,559 --> 03:36:24,479
the common factors dividing them out and it's going to work a lot
1686
03:36:24,479 --> 03:36:30,000
because it'll go through and easily find all the factors for you
1687
03:36:30,000 --> 03:36:37,840
the modules operator so modulus that is the percent symbol so on
1688
03:36:37,840 --> 03:36:44,559
five key so what that does is that finds the remainder so i
1689
03:36:44,559 --> 03:36:51,760
five modules three it's like five divided by three but the whole
1690
03:36:51,760 --> 03:36:56,960
want the remainder five divided by three three goes in there once
1691
03:36:56,959 --> 03:37:05,279
that's what it'll print out the two and if we want we'll just
1692
03:37:05,280 --> 03:37:14,079
just to show you another one so 31 module is 10 so 31 divided by
1693
03:37:14,079 --> 03:37:21,680
matter it's a remainder of one so when we run it it'll output one
1694
03:37:21,680 --> 03:37:28,479
for finding factors because a remainder means that it's not enough
1695
03:37:28,479 --> 03:37:33,760
but if the remainder is zero then it's a factor and that's what
1696
03:37:33,760 --> 03:37:40,399
find factors so i just picked this number 12 and we're going to
1697
03:37:41,440 --> 03:37:50,239
in our loop so i i made this variable just called test factor so
1698
03:37:50,239 --> 03:37:57,760
one to the number plus one because i'm dividing so i have to make
1699
03:37:57,760 --> 03:38:02,639
at zero it'll give me an error and i want to include that number
1700
03:38:02,639 --> 03:38:09,279
one otherwise it won't do that last number so for test factor in
1701
03:38:09,280 --> 03:38:18,880
here if number modulus test factor is zero then it must be a
1702
03:38:18,879 --> 03:38:25,359
out the test factor so that's what this is going to do given my
1703
03:38:25,360 --> 03:38:33,120
through that and try each number and see if it's a factor and
1704
03:38:33,120 --> 03:38:41,360
it see it prints there we go one two three four six and twelve all
1705
03:38:41,360 --> 03:38:52,079
12 so how can i reduce fractions to lowest terms so let's take a
1706
03:38:52,079 --> 03:39:00,079
variables here my numerator let's call it 12 denominator 24 now we
1707
03:39:00,079 --> 03:39:07,760
to reduce to one half and i'm going to define a variable called
1708
03:39:07,760 --> 03:39:14,880
a factor and who knows for some things that might be the greatest
1709
03:39:14,879 --> 03:39:23,119
my numerator to find the greatest common factor all right so for
1710
03:39:23,120 --> 03:39:27,600
plus one because that's really it i want to you know i want to go
1711
03:39:27,600 --> 03:39:38,399
denominator beyond that the numerator it's not going to really
1712
03:39:38,399 --> 03:39:45,520
module so we'll do this line here if the numerator modulus test
1713
03:39:45,520 --> 03:39:52,800
modulus test factor is zero so for each of those if it's a factor
1714
03:39:52,799 --> 03:40:00,159
now that's going to be my variable factor and then once i have
1715
03:40:01,120 --> 03:40:09,040
so i'm going to do numerator divided by factor and i want to cast
1716
03:40:09,040 --> 03:40:14,080
going to look nicer when we do you know the sense of this is that
1717
03:40:14,079 --> 03:40:21,200
factors so this is going to look nicer when we display it so once
1718
03:40:21,200 --> 03:40:26,960
you know it could stay at one or it's going to get you know the
1719
03:40:26,959 --> 03:40:32,879
i find that numerator divided by factor cast as an integer and
1720
03:40:32,879 --> 03:40:38,959
divided by that factor cast as an integer i'll call it d and then
1721
03:40:38,959 --> 03:40:47,679
original numerator divided by denominator and then the reduced
1722
03:40:47,680 --> 03:40:57,360
this and we see that the original was 12 over 24 and the reduced
1723
03:40:59,920 --> 03:41:06,000
any fraction and you can even copy this code and use it within
1724
03:41:06,719 --> 03:41:14,479
or you can put this as its own function and deal with it that way
1725
03:41:14,479 --> 03:41:22,479
functions out of a lot of this code later on in the course so the
1726
03:41:22,479 --> 03:41:30,559
adding it let's just do this so we had the decimal to fraction
1727
03:41:30,559 --> 03:41:36,719
we had an input rather than just have the number here i have this
1728
03:41:36,719 --> 03:41:44,879
a decimal number to convert and remember then that input gets
1729
03:41:44,879 --> 03:41:54,399
string and we've done this before converted to a fraction so i go
1730
03:41:54,399 --> 03:42:04,879
input you know how how many digits minus one well convert it to an
1731
03:42:04,879 --> 03:42:09,279
an and minus one because that it that will come in as a string
1732
03:42:09,840 --> 03:42:20,079
so there we go then that becomes my exponent and then i'll still
1733
03:42:20,079 --> 03:42:32,399
which is n and then as a fraction my numerator is going to be the
1734
03:42:32,399 --> 03:42:37,920
10 to that exponent so what that's doing is taking that value and
1735
03:42:40,000 --> 03:42:46,719
so there we go so the so n has all those digits including the
1736
03:42:46,719 --> 03:42:52,319
this line for the numerator moves the decimal place and then the
1737
03:42:52,319 --> 03:42:57,920
exponent so now i have an integer for the numerator this will end
1738
03:42:57,920 --> 03:43:05,440
the denominator and now what we're going to do is just like we
1739
03:43:05,440 --> 03:43:13,280
that fraction so same thing factor equals one everything else i
1740
03:43:13,280 --> 03:43:22,159
finding the greatest factor dividing it out and there we go
1741
03:43:22,159 --> 03:43:28,399
original number that the person entered and then print the
1742
03:43:29,200 --> 03:43:37,760
enter a decimal number to convert so let's convert something like
1743
03:43:40,559 --> 03:43:46,879
and it took it and it reduced it to one eighth which 0.125 is one
1744
03:43:46,879 --> 03:43:55,439
and we can run it again just to see that if i have a point zero
1745
03:43:58,159 --> 03:44:07,119
there we go the decimal and then that's one fiftieth as a fraction
1746
03:44:07,120 --> 03:44:11,680
into other things that we've been doing all right now we're going
1747
03:44:11,680 --> 03:44:20,559
factoring out square roots so this is all good to reduce the
1748
03:44:20,559 --> 03:44:29,439
root something now this one if i just print math that square root
1749
03:44:29,440 --> 03:44:36,319
the square root of 25 here is five great but what if i have
1750
03:44:36,319 --> 03:44:42,639
now that doesn't work out nicely and by default it'll just give me
1751
03:44:42,639 --> 03:44:49,920
if i want to factor it and this is how we want to factor it i use
1752
03:44:50,639 --> 03:44:57,279
square root of 12 because underneath the radical 12 is four times
1753
03:44:57,280 --> 03:45:04,239
square so the square root of four is two and that comes out and
1754
03:45:04,239 --> 03:45:08,799
else i can do with that so that's the factored square root we want
1755
03:45:09,360 --> 03:45:18,880
and divide them out the square root of that there we go so here we
1756
03:45:18,879 --> 03:45:28,000
make it user interface but i just put it here n equals 12 and max
1757
03:45:28,000 --> 03:45:34,879
that's the one that will change and here's i put this as the key
1758
03:45:34,879 --> 03:45:42,479
get to you know if i have my loop where do i start where do i stop
1759
03:45:42,479 --> 03:45:53,279
floor of math dot sqrt of n so i'm going to take the square root
1760
03:45:53,280 --> 03:45:59,680
that's going to be some weird decimal number now i just did this
1761
03:45:59,680 --> 03:46:06,479
one i probably could have done math dot ceiling also but i just
1762
03:46:06,479 --> 03:46:13,520
root and whatever you know math dot floor so drop all the decimal
1763
03:46:13,520 --> 03:46:20,479
drop them all and then add one so that's going to be the upper
1764
03:46:20,479 --> 03:46:30,159
here so for maybe factor in range again starting at one zero would
1765
03:46:31,200 --> 03:46:41,280
if n modulus maybe factor squared so you see i'm running through
1766
03:46:42,399 --> 03:46:49,119
you know each of these is the square root factor so if i square n
1767
03:46:49,120 --> 03:47:00,800
factor squared if that's zero then now that maybe factor is now my
1768
03:47:01,600 --> 03:47:07,440
and we're going to cycle through all these you know divided out
1769
03:47:08,000 --> 03:47:16,799
some factor that's what's going to be on the outside so then i
1770
03:47:16,799 --> 03:47:23,840
my original number the square rooted factor square factor and
1771
03:47:23,840 --> 03:47:28,880
of these out here like this because we're going to build upon this
1772
03:47:28,879 --> 03:47:37,439
step but to show that square rooted factor square factor max
1773
03:47:37,440 --> 03:47:48,720
that's left over so for 12 since we had that example earlier we
1774
03:47:48,719 --> 03:47:55,439
rooted factor is 2 square factor is 4 and the integer is 3 even
1775
03:47:55,440 --> 03:48:07,920
was just text it actually comes out as a float so what we have is
1776
03:48:07,920 --> 03:48:14,879
on the outside you know 4 was a part of our in-between step and
1777
03:48:14,879 --> 03:48:20,879
rooted factor and then the integer that matches up with 2 coming
1778
03:48:20,879 --> 03:48:29,519
factor that's the greatest one and then 3 is the integer still in
1779
03:48:29,520 --> 03:48:36,560
to use simpy to make this look nice import math import simpy and
1780
03:48:37,680 --> 03:48:48,880
so now i have this there we go and same variables i had before
1781
03:48:48,879 --> 03:48:57,439
square rooting it but then you know find a one more to see where
1782
03:48:57,440 --> 03:49:04,560
the like the greatest square factor i could possibly have so then
1783
03:49:04,559 --> 03:49:08,719
factor and then square they're all starting out as one and i'm
1784
03:49:09,840 --> 03:49:14,639
so slightly different variable strategy so if maybe for maybe
1785
03:49:14,639 --> 03:49:23,760
if n modules may be factor squared then we have the max factor is
1786
03:49:25,520 --> 03:49:40,079
all right and then the other factor is n divided by max factor so
1787
03:49:40,079 --> 03:49:50,639
the factor that i divide out because i'm squaring it here and then
1788
03:49:50,639 --> 03:49:58,239
the radical is that original number divided by max factor so then
1789
03:49:58,239 --> 03:50:05,680
this look nice we cast them all as integers so the square root of
1790
03:50:05,680 --> 03:50:11,760
want the square root of it cast as an integer and then that's the
1791
03:50:11,760 --> 03:50:19,200
square root other factor cast it as an integer there we go it i
1792
03:50:19,200 --> 03:50:26,320
we need to cast it as an integer here other factor and then the
1793
03:50:26,319 --> 03:50:37,119
variable output and we see it's square root times simpy dot square
1794
03:50:37,120 --> 03:50:46,160
that output looks like in simpy and this presentation here we
1795
03:50:46,159 --> 03:50:52,479
uh that might not make it look as nice but this simpy output so i
1796
03:50:52,479 --> 03:50:59,039
and then when i output it here there we go it factored out as two
1797
03:51:00,719 --> 03:51:10,399
and if i put it back to my other 24 that we were talking about
1798
03:51:10,399 --> 03:51:18,559
work out and so it factors that to two root six because it's six
1799
03:51:18,559 --> 03:51:22,479
root of four is two and that's what we're doing the types of
1800
03:51:22,479 --> 03:51:29,439
through we just want to translate that into code you know i'm
1801
03:51:29,440 --> 03:51:37,120
of that number and which ones are square perfect squares so 24 i
1802
03:51:37,120 --> 03:51:44,800
that are perfect square and i find that it's four and then the
1803
03:51:44,799 --> 03:51:53,279
the simpy makes it nice so we can do this to factor square roots
1804
03:51:53,280 --> 03:51:58,239
this we can divide out common factors we can reduce fractions we
1805
03:51:58,719 --> 03:52:03,840
and these are a lot of the things that you know we often do by
1806
03:52:04,799 --> 03:52:07,039
now you have the code that you you can do this
1807
03:52:07,040 --> 03:52:14,480
you can do this now that we've worked through the core skills in
1808
03:52:15,280 --> 03:52:18,400
let's look through some extra problems and i'm going to work
1809
03:52:18,959 --> 03:52:24,399
extra problems using the colab notebook so you can see how you can
1810
03:52:24,399 --> 03:52:29,920
you're building and use that use these to solve problems that
1811
03:52:30,479 --> 03:52:35,520
in day-to-day life so we're going to go through some more extra
1812
03:52:35,520 --> 03:52:43,360
to do a walkthrough of the first certification in foundational
1813
03:52:43,360 --> 03:52:49,040
there's five of them we'll do three of them for this course and
1814
03:52:50,159 --> 03:52:55,840
but they were i also designed them to be standalone that you know
1815
03:52:55,840 --> 03:53:01,520
you could walk through and be able to do all this still though i'm
1816
03:53:01,520 --> 03:53:06,159
uh maybe you already did this and you want to check some things or
1817
03:53:07,040 --> 03:53:11,680
uh turn out as you expected or you're stuck somewhere so you can
1818
03:53:11,680 --> 03:53:18,880
in in this video and see so each of these steps lead you towards
1819
03:53:18,879 --> 03:53:24,879
we've built upon each thing so the first thing you're going to do
1820
03:53:24,879 --> 03:53:30,559
notebook this notebook is read-only and this is what gets shared
1821
03:53:30,559 --> 03:53:34,079
so you make a copy and that copy is going to be in your google
1822
03:53:35,280 --> 03:53:41,280
uh and it will be in a folder called colab notebooks by default
1823
03:53:41,280 --> 03:53:47,360
it in whatever folder you'd want it to be you want it to be in and
1824
03:53:47,360 --> 03:53:51,200
for this course you're building your resources so you're going to
1825
03:53:51,200 --> 03:53:56,320
drive uh especially if you have other colab notebooks or something
1826
03:53:56,319 --> 03:54:03,039
folder for everything uh in foundational math one you know or
1827
03:54:03,040 --> 03:54:09,040
to call it that so you make your own folder you're putting all
1828
03:54:09,040 --> 03:54:14,080
have so you walk through as you work through these you'll
1829
03:54:14,639 --> 03:54:19,439
but then you also have some code that you can reference so you
1830
03:54:19,440 --> 03:54:29,440
i already did this and then each of these i have as a different
1831
03:54:29,440 --> 03:54:35,760
click on the triangle here to expand the next step and with each
1832
03:54:36,879 --> 03:54:45,039
then up here you have a table of contents that you can go through
1833
03:54:45,040 --> 03:54:51,840
you you can jump to whatever part you want you know you can add
1834
03:54:51,840 --> 03:54:58,960
making each of these a section heading so you do need to acquire
1835
03:54:58,959 --> 03:55:02,959
this is actually self-contained you're going to write the code and
1836
03:55:02,959 --> 03:55:10,879
code that you wrote and see if it's correct or not so this cell
1837
03:55:10,879 --> 03:55:15,679
maybe for other things you might do in the future you might take
1838
03:55:15,680 --> 03:55:25,840
this other library as this raw.py file in github and really save
1839
03:55:26,799 --> 03:55:34,959
and then you'll be able to access it so this i have the note here
1840
03:55:34,959 --> 03:55:40,000
at the beginning of every session and the only reason i said may
1841
03:55:40,000 --> 03:55:47,840
away for two minutes and come back don't count that as another
1842
03:55:47,840 --> 03:55:55,600
they do time out the runtime will time out after 30 minutes of
1843
03:55:55,600 --> 03:56:02,720
typing that means no running any cell or even if you are really
1844
03:56:02,719 --> 03:56:08,239
hours so then you you know you might say wait i haven't i've been
1845
03:56:08,239 --> 03:56:12,319
time out they have that time out too all these are security
1846
03:56:12,319 --> 03:56:20,079
leave it open for you know indefinite amounts of time all right so
1847
03:56:20,079 --> 03:56:27,840
this library and you're going to run it and we'll take a look at
1848
03:56:29,200 --> 03:56:34,320
and as this is going yep it'll save the library locally and then
1849
03:56:34,319 --> 03:56:42,879
so it'll say requirement already satisfied even though it said
1850
03:56:42,879 --> 03:56:49,759
i do this i already it was already okay that's just what it prints
1851
03:56:49,760 --> 03:56:57,200
test pass go on to the next step then you know you're good so it
1852
03:56:57,200 --> 03:57:05,200
you know now we have this library available and each step will use
1853
03:57:05,200 --> 03:57:09,760
four yes i do have add subtract multiply divide i know you know
1854
03:57:09,760 --> 03:57:13,280
know how to do them in python but it kind of walks you through
1855
03:57:13,280 --> 03:57:18,640
the notebook you might be already familiar with it but so you know
1856
03:57:18,639 --> 03:57:26,799
so we go through just you know two variables and then you're going
1857
03:57:28,000 --> 03:57:34,639
with the comment change the next line now this was just add so
1858
03:57:34,639 --> 03:57:44,799
a plus b and i'm going to click run and you see two plus one is
1859
03:57:44,799 --> 03:57:52,159
passed go on to the next step so we go to the next one subtract
1860
03:57:52,159 --> 03:58:01,840
c minus d and i could hit run or i can hit shift enter which i'll
1861
03:58:02,719 --> 03:58:08,639
so this is just getting you familiar and then each of these
1862
03:58:08,639 --> 03:58:16,319
so you've run that first cell and then you have the test and
1863
03:58:16,319 --> 03:58:24,719
code and tell you one of these steps in a little bit i'll do one
1864
03:58:24,719 --> 03:58:31,599
and you'll see what what it'll tell you so here we go so we'll
1865
03:58:31,600 --> 03:58:42,319
multiply in python like a lot of things is the asterisk same key
1866
03:58:42,319 --> 03:58:50,000
the eight so just hit shift and it's above the eight there we go e
1867
03:58:50,000 --> 03:58:59,360
passed and then we divide now when we divide here g and h now they
1868
03:58:59,360 --> 03:59:08,000
happens to work out but if i had them as numbers that didn't work
1869
03:59:08,000 --> 03:59:12,239
defined as integers then i would have to do something else because
1870
03:59:12,239 --> 03:59:17,840
and if i divide it won't work out the answer will be a float but
1871
03:59:17,840 --> 03:59:24,960
this you know i just define g equals h equals and when i divide
1872
03:59:24,959 --> 03:59:30,079
time about whether they're integers or not it's just going to
1873
03:59:33,680 --> 03:59:38,479
so you can and a lot of things that you might work through here if
1874
03:59:38,479 --> 03:59:42,479
you might just have things where you define your input or your
1875
03:59:48,079 --> 03:59:54,559
actually just prompt for input and so in that case you don't have
1876
03:59:54,559 --> 03:59:58,799
when when you run it it will prompt for input and then that could
1877
03:59:58,799 --> 04:00:04,159
that you want that way you don't have to worry about changing the
1878
04:00:04,159 --> 04:00:08,959
a positive integer it actually could for what we're doing here it
1879
04:00:08,959 --> 04:00:14,000
just put that there and then we just cast it because the input
1880
04:00:14,639 --> 04:00:17,840
and then i need to cast it in this case as an integer to do some
1881
04:00:17,840 --> 04:00:25,600
all right so i need to do an integer or a float and then the only
1882
04:00:25,600 --> 04:00:35,840
following that model i have string b and a lot of these have you
1883
04:00:35,840 --> 04:00:40,960
there that won't break the code but you do need to change it all
1884
04:00:40,959 --> 04:00:53,199
going to be this and you absolutely could just copy this and paste
1885
04:00:55,200 --> 04:00:59,280
what if i just change this now that's really all you need to do
1886
04:01:00,399 --> 04:01:06,879
just for me i feel like you entered one i want to say enter
1887
04:01:06,879 --> 04:01:23,599
and i want to cast it as a string as i want to cast as an integer
1888
04:01:23,600 --> 04:01:30,720
that now so i don't need to tinker with this at all so i might not
1889
04:01:30,719 --> 04:01:43,039
to another or something like that that you know we'll see all
1890
04:01:48,879 --> 04:01:56,959
there we go so what i was saying is if i wanted to change you know
1891
04:01:56,959 --> 04:02:04,799
not be central even if it gave an error it shouldn't stop you all
1892
04:02:04,799 --> 04:02:10,639
casting it as an integer and adding it we're fine if i cast each
1893
04:02:10,639 --> 04:02:18,479
divide it would give me an error oh but i didn't want to worry
1894
04:02:18,479 --> 04:02:22,559
defining them as integers we're just adding we'll cross that
1895
04:02:22,559 --> 04:02:32,959
and we can get input and cast it on the same line so notice just
1896
04:02:34,159 --> 04:02:37,520
i'm going to do the same thing here i'm going to copy this whole
1897
04:02:40,000 --> 04:02:42,399
because that's really what i want to do
1898
04:02:44,879 --> 04:02:50,000
all right now here's one where i really don't need to do anything
1899
04:02:50,000 --> 04:02:57,200
change that to another now just the way i have it
1900
04:03:04,079 --> 04:03:11,920
see it actually just tested a bunch of these things because you
1901
04:03:11,920 --> 04:03:20,239
part of the line and you know i really didn't need to change that
1902
04:03:20,879 --> 04:03:27,679
your into your input should be this now my point here is this will
1903
04:03:27,680 --> 04:03:33,360
from going on to the next step so you know maybe that's it maybe
1904
04:03:33,360 --> 04:03:39,040
in there that like why why did it say it was never it looks
1905
04:03:39,040 --> 04:03:44,000
and maybe you're watching this video because that's where you were
1906
04:03:44,000 --> 04:03:48,639
from going on to the next step and in fact you know that's fine
1907
04:03:48,639 --> 04:03:54,719
what was different i'm not worried about it on to the next step
1908
04:03:54,719 --> 04:04:01,519
okay well maybe i just should have just said this you know you
1909
04:04:01,520 --> 04:04:11,920
check it and then see there we go and then and then you can make
1910
04:04:11,920 --> 04:04:18,399
is that this is supposed to be just you know a teaching tool check
1911
04:04:18,399 --> 04:04:26,239
move on but you know not to get you caught in something that you
1912
04:04:26,239 --> 04:04:34,639
moving on all right now as i was mentioning about dividing casting
1913
04:04:34,639 --> 04:04:40,719
number allows for decimal places and most of the time i'm just
1914
04:04:40,719 --> 04:04:46,959
anyway because just in case somewhere along the way i need the
1915
04:04:46,959 --> 04:04:55,279
situations where i might definitely need an integer certain simpy
1916
04:04:55,280 --> 04:05:03,200
that soon enough and counting but other other numbers that i'm
1917
04:05:03,200 --> 04:05:13,040
to cast it as a float okay so again prompt and then cast as a
1918
04:05:13,040 --> 04:05:19,680
the same thing and that's okay you need you know if you copy you
1919
04:05:19,680 --> 04:05:26,800
and need to know exactly where to put it but there we go and we
1920
04:05:26,799 --> 04:05:33,119
number enter a number and see now we will divide so i definitely
1921
04:05:33,120 --> 04:05:38,560
i didn't even say integer i just said a number so this is going to
1922
04:05:38,559 --> 04:05:48,639
enters in and then when we take a look then you see it's waiting
1923
04:05:48,639 --> 04:05:57,599
three enter number four and 0.75 which is perfectly fine because
1924
04:05:59,760 --> 04:06:06,399
good times all right so order of operations and yes python knows
1925
04:06:07,440 --> 04:06:11,280
so in case you forgot you know here's the acronym PEMDAS
1926
04:06:11,280 --> 04:06:19,520
uh parentheses exponents multiplication and division addition and
1927
04:06:21,680 --> 04:06:31,760
you can and then remember the python syntax for exponents is the
1928
04:06:33,680 --> 04:06:38,559
what i wanted you to do is test your knowledge of order of
1929
04:06:38,559 --> 04:06:48,079
about actually writing code here then you're going to put your
1930
04:06:48,079 --> 04:06:52,559
really think about the code see if you can do this in your head
1931
04:06:53,600 --> 04:07:00,079
and then you're going to put that here well you're going to put
1932
04:07:00,079 --> 04:07:05,840
when you run it python is going to calculate the actual answer and
1933
04:07:05,840 --> 04:07:11,840
you'll see all right so let's look at order of operations
1934
04:07:12,559 --> 04:07:17,840
and then multiplication and division as they come up so
1935
04:07:20,399 --> 04:07:27,279
uh four times two and then we have 14 divided by two so you can
1936
04:07:27,280 --> 04:07:36,400
multiplying and dividing all day so as they come up four times two
1937
04:07:36,399 --> 04:07:48,399
divided by two is seven so then we're going to have one plus eight
1938
04:07:48,399 --> 04:07:56,399
eight is nine minus seven is two so then we take two now we're
1939
04:07:56,399 --> 04:08:01,680
two to the third power is eight and so there you go put your
1940
04:08:06,159 --> 04:08:10,399
and there we go actual answer is eight your answer is eight code
1941
04:08:14,159 --> 04:08:23,520
okay so all these things and remember you can just like the other
1942
04:08:23,520 --> 04:08:29,040
put print statements you know all whatever math you want just
1943
04:08:29,040 --> 04:08:35,360
statement python will do that for you so those are some simple
1944
04:08:37,040 --> 04:08:42,400
okay so remainder remember when we divide something that does not
1945
04:08:43,600 --> 04:08:51,040
and the modulus operator looks like a percent sign but if i'm
1946
04:08:51,040 --> 04:08:58,880
it tells me just what the remainder is there we go so as i have
1947
04:08:58,879 --> 04:09:09,119
four is two but with but as a remainder so two and then two left
1948
04:09:10,239 --> 04:09:18,479
would give me two because that's the remainder or 14 divided by
1949
04:09:18,479 --> 04:09:27,600
so if i do eight a modulus b and again it's the percent sign on
1950
04:09:27,600 --> 04:09:33,600
key as the five but you have to hit shift so 14 divided by six now
1951
04:09:33,600 --> 04:09:41,120
by six is two with a remainder of two so that's what we're
1952
04:09:41,120 --> 04:09:53,360
printout there we go now actually we could we don't need to do
1953
04:09:53,360 --> 04:10:04,319
well supposing if i had 15 divided by six so six times two is 12
1954
04:10:04,319 --> 04:10:11,600
and so a modules b would be three if you wanted to you can test
1955
04:10:12,159 --> 04:10:17,920
this particular code is testing did you do it correctly here so if
1956
04:10:17,920 --> 04:10:26,639
try some different things whereas then if i go to 18 that works
1957
04:10:26,639 --> 04:10:37,439
be zero there there would be no remainder and we can use that to
1958
04:10:37,440 --> 04:10:51,360
statement here so if i have 20 modulus five so that's 20 divided
1959
04:10:51,360 --> 04:11:01,120
so 20 modules five the remainder would be zero so if that zero
1960
04:11:01,120 --> 04:11:08,880
a factor so you see we're using the double equals to test it so
1961
04:11:08,879 --> 04:11:14,799
we're going to walk through this and we're going to cast this
1962
04:11:14,799 --> 04:11:20,719
factoring really only works with integers if you know we can
1963
04:11:22,239 --> 04:11:29,360
you know if it's a factor there's going to be a nice integer in
1964
04:11:29,360 --> 04:11:35,920
enter an integer so input cast it as int and that's going to be
1965
04:11:35,920 --> 04:11:42,879
next one enter an integer to see if it's a factor and again cast
1966
04:11:42,879 --> 04:11:51,119
to be test factor because i don't know if it's a factor yet and in
1967
04:11:51,120 --> 04:12:00,000
number now remember whatever this is if it's true it's going to do
1968
04:12:00,000 --> 04:12:09,520
it will then it's going to do this but we're going to change the
1969
04:12:09,520 --> 04:12:24,399
modulus test factor and then now if that divided by that gives you
1970
04:12:26,479 --> 04:12:32,079
then we can say true it is a factor and then or else it's false
1971
04:12:32,079 --> 04:12:44,159
it's false so there we go and enter an integer so let's do one
1972
04:12:49,840 --> 04:13:02,079
and we can run it again and let's say make it 12 3 true so there
1973
04:13:02,079 --> 04:13:09,120
things and we can use that to test if something is a factor that
1974
04:13:09,120 --> 04:13:14,000
but we're going to take that and we're going to build that into
1975
04:13:14,000 --> 04:13:20,159
factors all right finding all the factors of a number so very
1976
04:13:20,159 --> 04:13:28,639
not asking for second input here we have the first input and then
1977
04:13:29,760 --> 04:13:39,200
so now i have my for loop for test factor in range so i'm going to
1978
04:13:39,200 --> 04:13:44,320
let's look at this backwards here i'm going to take this range and
1979
04:13:44,319 --> 04:13:49,119
there it would start at zero but i can't have that because that'll
1980
04:13:49,120 --> 04:13:56,000
right away so i'm going to start the range at one and then end the
1981
04:13:56,799 --> 04:14:03,359
because normally the range it won't do that last number so i have
1982
04:14:03,360 --> 04:14:11,920
whatever that number is i want to include that all right so now
1983
04:14:12,879 --> 04:14:20,879
it's going to loop through everything every number in this range
1984
04:14:20,879 --> 04:14:25,920
is going to be one and then the next num next time through the
1985
04:14:25,920 --> 04:14:33,520
so it will just loop through how for that many times yeah for
1986
04:14:35,040 --> 04:14:43,280
all right and this is what we're going to change the if statement
1987
04:14:44,000 --> 04:14:51,200
so number is our in is the original number we want and each of
1988
04:14:51,200 --> 04:14:56,560
want to do with it we want to say if number modulus test factor
1989
04:15:01,200 --> 04:15:05,920
equals zero just like we were doing before we're just kind of
1990
04:15:06,879 --> 04:15:12,479
so i get this number and i'm going to loop through all these
1991
04:15:12,479 --> 04:15:19,680
and i'm going to loop through all these factors from one up to
1992
04:15:19,680 --> 04:15:28,079
by test factor gives me a remainder of zero then it is a factor so
1993
04:15:31,920 --> 04:15:39,680
all right so we run it and what do we have let's say 12 12 is a
1994
04:15:39,680 --> 04:15:47,600
and you see it'll print them all out 1 2 3 4 6 and 12 and we can
1995
04:15:47,600 --> 04:15:55,680
supposing enter like 17 1 and 17 because it's prime so that's what
1996
04:15:55,680 --> 04:16:02,000
the factors here this type of thing we will revisit this at
1997
04:16:02,000 --> 04:16:14,799
to lowest terms okay now what about prime numbers so a prime
1998
04:16:14,799 --> 04:16:24,159
are one in itself so we're going to and then anything that's not
1999
04:16:24,159 --> 04:16:31,920
so if i have you know five is prime because the only way you can
2000
04:16:31,920 --> 04:16:38,879
five but six as one you can do one times six but you can also do
2001
04:16:38,879 --> 04:16:47,519
you have those other factors it's composite so here now we're
2002
04:16:47,520 --> 04:16:53,360
and again integers because we're looking at factors and i'm going
2003
04:16:53,360 --> 04:17:06,239
variable prime or comp say being prime and then same thing range
2004
04:17:06,239 --> 04:17:12,639
two because one will go into everything and that's not what i
2005
04:17:12,639 --> 04:17:17,519
does that won't tell me anything so i'm going to start at two up
2006
04:17:18,159 --> 04:17:22,879
again not including the number because this this this time it
2007
04:17:22,879 --> 04:17:29,599
didn't add the one there because again same reason i didn't have
2008
04:17:29,600 --> 04:17:35,040
we know that those are factors but i want to find out from two
2009
04:17:35,040 --> 04:17:44,960
if it's a factor and very similar then if number we're going to do
2010
04:17:44,959 --> 04:17:57,199
always go back if number divided by test factor equals zero there
2011
04:17:57,200 --> 04:18:05,600
variables here you always double check just in case the variable
2012
04:18:05,600 --> 04:18:13,520
different way of doing things but yes if that test factor works oh
2013
04:18:13,520 --> 04:18:16,319
so this would have given me an error
2014
04:18:19,920 --> 04:18:25,360
and and that's the thing with with reusing code yes we know we're
2015
04:18:25,360 --> 04:18:31,760
and paste because that helps you know if it's a whole block of
2016
04:18:31,760 --> 04:18:38,000
it is exactly the variables and everything that match up correctly
2017
04:18:38,000 --> 04:18:44,319
people do too much copy and paste and then they're lost because
2018
04:18:45,920 --> 04:18:52,719
so this one we call it test number so if number divided by test
2019
04:18:52,719 --> 04:18:58,719
of zero then that means that is a factor which means all it has to
2020
04:18:58,719 --> 04:19:06,159
means the number is composite and it's only prime starts out that
2021
04:19:06,159 --> 04:19:14,479
prime only if it goes through and we never get a factor here
2022
04:19:14,479 --> 04:19:26,079
so let's take a look if we have this and enter a positive integer
2023
04:19:26,079 --> 04:19:34,399
composite right because i can also do two times two and then let's
2024
04:19:36,000 --> 04:19:43,360
prime and that way you can check all kinds of other things you
2025
04:19:43,360 --> 04:19:52,640
is it prime is a composite there we go and you know now that you
2026
04:19:52,639 --> 04:20:00,559
change any of the code when you run this it'll you know it'll uh
2027
04:20:00,559 --> 04:20:09,199
interesting things reciprocals so writing it in math it's the
2028
04:20:11,440 --> 04:20:18,800
reciprocal of two-thirds is three over two you see it just flipped
2029
04:20:18,799 --> 04:20:24,639
the reciprocal of five is one-fifth because any whole number it's
2030
04:20:24,639 --> 04:20:31,119
denominator of zero or sorry sorry denominator of one so that'd be
2031
04:20:31,120 --> 04:20:36,880
it's one-fifth as the reciprocal and you can multiply a number by
2032
04:20:36,879 --> 04:20:48,719
there we go pretty good so and there we go zero has no reciprocal
2033
04:20:50,399 --> 04:21:01,600
so we can write the reciprocal whatever the number is we can just
2034
04:21:01,600 --> 04:21:05,760
there that's actually all you need to do to find the reciprocal
2035
04:21:06,639 --> 04:21:12,239
and some of these might be decimals but nonetheless this will find
2036
04:21:16,479 --> 04:21:23,439
and we see our output here enter a number and what if i have the
2037
04:21:23,440 --> 04:21:30,880
um five see point two but that's the decimal equivalent of
2038
04:21:35,600 --> 04:21:42,960
all right so just putting this in there showing you what you can
2039
04:21:44,719 --> 04:21:50,639
other things we can do with the input is supposing i wanted to
2040
04:21:50,639 --> 04:21:58,159
and are two numbers separated by a comma oh well now but i want to
2041
04:22:00,079 --> 04:22:07,680
so i can split it so this i'll store it as the variable nums still
2042
04:22:08,319 --> 04:22:14,719
and then here this is actually going to be an array in this case
2043
04:22:14,719 --> 04:22:25,840
to split it at the comma and then now this array sp has two
2044
04:22:25,840 --> 04:22:35,600
i'll cast that as a float and then i have sp1 so that's it you
2045
04:22:35,600 --> 04:22:45,120
by a comma split the input and then then cast each of them
2046
04:22:45,680 --> 04:22:54,399
and notice the code here just says cast it as a float so float
2047
04:22:54,399 --> 04:23:07,920
over here there we go and then what do we want to do and that the
2048
04:23:07,920 --> 04:23:15,120
the two numbers so that's why we cast them as a float divide the
2049
04:23:15,120 --> 04:23:27,120
by b all right so there we go split it cast it and in this case
2050
04:23:29,200 --> 04:23:34,960
okay so and our two numbers separated by a comma and let's see how
2051
04:23:34,959 --> 04:23:45,519
um this one will be a repeating decimal of eight comma nine
2052
04:23:48,559 --> 04:23:54,479
there you go i'd notice if you have just one number repeating the
2053
04:23:55,040 --> 04:24:01,920
that number over nine so point one repeating would be one ninth
2054
04:24:01,920 --> 04:24:13,360
two ninth and this one eight over nine so there we go okay now
2055
04:24:14,159 --> 04:24:21,920
is building up to you being able to factor square roots but let's
2056
04:24:21,920 --> 04:24:32,479
so factor multiplied by itself is a square and it is kind of like
2057
04:24:32,479 --> 04:24:37,039
sides would be the same or all sides would be the same so when i
2058
04:24:37,040 --> 04:24:43,040
they're the same and so is that number times itself and we would
2059
04:24:43,040 --> 04:24:52,560
the second power okay so all we're doing here is you know we're
2060
04:24:53,600 --> 04:25:05,360
getting the square so in this case it's going to take the input as
2061
04:25:05,360 --> 04:25:16,480
it there we go okay there we go number square all right five i'll
2062
04:25:19,280 --> 04:25:26,480
okay so let's go the other way square root function so anything to
2063
04:25:26,479 --> 04:25:34,639
it's squared but what if i knew the result and i wanted to square
2064
04:25:34,639 --> 04:25:45,119
of my square yard but i want to know what's the side side measure
2065
04:25:45,120 --> 04:25:50,320
first thing we're encountering here that is not built into python
2066
04:25:50,319 --> 04:25:57,520
library and this is where colab really helps you out because a lot
2067
04:25:57,520 --> 04:26:04,880
through some other things to install things you know in other
2068
04:26:04,879 --> 04:26:10,559
math and you don't have it behind the scenes it works you just
2069
04:26:11,200 --> 04:26:16,240
all right so a number to find the square root definitely going to
2070
04:26:18,079 --> 04:26:23,920
all right and how do we get the square root of that once we import
2071
04:26:23,920 --> 04:26:27,920
sqrt and we call it a number n
2072
04:26:32,959 --> 04:26:37,279
especially you know think even if things don't come up
2073
04:26:37,280 --> 04:26:43,360
open parentheses one two close parentheses one two we got it so
2074
04:26:44,879 --> 04:26:51,679
and we see here and remember to find the square root so we'll do
2075
04:26:51,680 --> 04:27:02,159
about 16 square roots four and we can do another one that doesn't
2076
04:27:04,159 --> 04:27:06,079
and it'll give you a bunch of decimal places
2077
04:27:08,319 --> 04:27:14,959
i remember yep so 4.5 yeah about there we go okay
2078
04:27:14,959 --> 04:27:24,000
okay other cool functions the floor function this is another one
2079
04:27:24,000 --> 04:27:28,559
so the floor function so we have a floor function which just drops
2080
04:27:31,120 --> 04:27:38,960
and there we go drops any decimals and sometimes called integer
2081
04:27:38,959 --> 04:27:49,439
so even if it's like 3.9 it's going to drop and just go down to 3
2082
04:27:49,440 --> 04:27:54,319
we have the ceiling function which as you can imagine if floor
2083
04:27:54,319 --> 04:28:00,959
is no matter how many what decimals are even if it's 0.1 it goes
2084
04:28:00,959 --> 04:28:09,199
round the one we use possibly most often round remember 0.5 and
2085
04:28:09,680 --> 04:28:17,200
anything less than 0.5 0.4 and down rounds down so we're going to
2086
04:28:17,200 --> 04:28:22,079
function here all right enter a number decimal place and we're
2087
04:28:22,079 --> 04:28:35,039
math dot floor function here math dot floor of n so enter a number
2088
04:28:35,040 --> 04:28:45,920
to call it 5.99999 and when i hit enter yep and that's the floor
2089
04:28:45,920 --> 04:28:58,319
drops down to five so there we go and remember supposing you went
2090
04:28:58,319 --> 04:29:07,600
you know i'm upside down ceiling function supposing i wanted to do
2091
04:29:07,600 --> 04:29:19,360
um 7.1 because that should round it up to eight and so that code
2092
04:29:19,920 --> 04:29:25,920
what these directions are it'll tell you oh you should include
2093
04:29:25,920 --> 04:29:31,760
end up trying different things it doesn't prevent you from going
2094
04:29:31,760 --> 04:29:37,840
either if you spelled it wrong or something or you did something
2095
04:29:37,840 --> 04:29:45,360
floor and go nine point three
2096
04:29:48,479 --> 04:29:56,399
right good drops it okay so we're going to put some of this
2097
04:29:56,399 --> 04:30:03,199
all right so a few things we've already done we're going to import
2098
04:30:03,200 --> 04:30:10,159
we're going to enter an integer to define the greatest square
2099
04:30:12,879 --> 04:30:21,759
i'll call that max factor and right now it'll be one and then the
2100
04:30:21,760 --> 04:30:28,800
stacking on these functions here uh the math dot floor of math
2101
04:30:29,360 --> 04:30:34,880
but then we're going to add one to it so we want to find the
2102
04:30:34,879 --> 04:30:40,639
number you enter it in we're going to square root it that's going
2103
04:30:40,639 --> 04:30:48,879
decimal places and so we could do the math dot floor and then add
2104
04:30:48,879 --> 04:30:55,920
now i realize that i could have just done math that ceiling and
2105
04:30:57,440 --> 04:31:03,600
for whatever reason i did this i like it so i kept it but there we
2106
04:31:05,200 --> 04:31:11,360
so that gives us the upper limit square root of that number and
2107
04:31:11,360 --> 04:31:23,440
number now what do we have now in my range from one to upper limit
2108
04:31:23,440 --> 04:31:30,399
that was the square fact the square root factor i square rooted it
2109
04:31:30,399 --> 04:31:37,440
that range so it's going to go through and maybe factor is going
2110
04:31:37,440 --> 04:31:49,360
be two it's going to be three you know up to this upper limit so
2111
04:31:50,479 --> 04:31:58,079
equals zero so that's it these these factors if i square them is
2112
04:31:58,079 --> 04:32:07,840
that out and if that is then max factor you see it's not going to
2113
04:32:08,959 --> 04:32:14,399
you know that's and that's the idea with some of these change one
2114
04:32:14,399 --> 04:32:22,559
think about what you're doing then we see yep i'm going through
2115
04:32:22,559 --> 04:32:30,479
and then finding square factors if n divided by maybe factor
2116
04:32:30,479 --> 04:32:43,920
of zero then max factor equals maybe factor so that's what we
2117
04:32:43,920 --> 04:32:54,399
so and again knowing that these were the square rooted so for our
2118
04:32:54,399 --> 04:32:55,680
we're just printed out squared
2119
04:32:59,200 --> 04:33:04,159
so we'll see this here so if i have something like 12
2120
04:33:04,159 --> 04:33:15,119
all the greatest square factor is four because two you see it
2121
04:33:15,840 --> 04:33:23,680
that and that's a factor of 12 three squared is nine does not work
2122
04:33:23,680 --> 04:33:33,680
here okay so here we're going to build upon that code and then
2123
04:33:39,360 --> 04:33:45,520
because when we look at factoring out square roots that's kind of
2124
04:33:45,520 --> 04:33:52,400
when you have a square root that doesn't work out perfectly but
2125
04:33:52,400 --> 04:34:02,319
that's what we want to do here so i still have get the same
2126
04:34:02,319 --> 04:34:07,759
all these variables equal to one because we'll change those square
2127
04:34:08,880 --> 04:34:15,200
all right and then take a look at what this is doing same thing
2128
04:34:15,200 --> 04:34:22,720
got that same upper limit and so still maybe factor is going
2129
04:34:23,759 --> 04:34:26,399
check for square factors just like we did before
2130
04:34:32,000 --> 04:34:37,520
there we go and in this case max factor equals maybe factor
2131
04:34:37,520 --> 04:34:47,920
squared there we go and then other factor is n the original number
2132
04:34:54,319 --> 04:35:02,799
there we go so what we have is the result is going to be that
2133
04:35:02,799 --> 04:35:11,520
this times this and we're just looking at how that divides out so
2134
04:35:15,599 --> 04:35:20,559
you don't need to change anything because i i thought that this
2135
04:35:21,680 --> 04:35:27,200
a little bit complex to try to follow like what what i was
2136
04:35:27,200 --> 04:35:32,639
through so i didn't didn't want to have you have to change
2137
04:35:32,639 --> 04:35:40,079
going on here how we're dividing that out and then when you run it
2138
04:35:40,080 --> 04:35:49,760
to factor maybe i'll do the same 12 here see 12 equals four times
2139
04:35:49,759 --> 04:35:58,079
let's say 50 50 equals 25 times two and again that first part is a
2140
04:36:05,119 --> 04:36:10,479
there we go the last four steps prepares you for this so factoring
2141
04:36:10,479 --> 04:36:21,360
of what we want 12 if we look at the square root of 12 is four
2142
04:36:21,360 --> 04:36:26,639
perfect square the square root of four comes out and it becomes
2143
04:36:26,639 --> 04:36:33,119
kind of building as we're building this code to do is this
2144
04:36:33,119 --> 04:36:39,520
i'm finding the greatest square factor and then that comes out
2145
04:36:39,520 --> 04:36:47,119
two two is on the outside now all right and in doing this we're
2146
04:36:47,119 --> 04:36:55,919
we have square root and for our final output we're going to import
2147
04:36:55,919 --> 04:37:01,839
going to give us a nice output at the end that looks like this so
2148
04:37:01,840 --> 04:37:06,159
that's the thing you know python outputs a certain way and then if
2149
04:37:06,159 --> 04:37:14,959
that looks more like math symbols that's what we have symbolic
2150
04:37:17,680 --> 04:37:23,599
similar input without the radical and our square root factor using
2151
04:37:23,599 --> 04:37:35,439
dividing these same type of thing where we're finding maybe factor
2152
04:37:37,200 --> 04:37:44,240
now in this case i kept it like this maybe factor squared so the
2153
04:37:44,240 --> 04:37:56,560
max factor squared and then we divide so now we do the output so i
2154
04:37:57,360 --> 04:38:03,920
yes and i realized that up here there's maybe factor squared and
2155
04:38:03,919 --> 04:38:11,359
rooting it again and the key is casting it as an integer because
2156
04:38:11,360 --> 04:38:22,400
point oh did not want to do that there yeah because this will be
2157
04:38:27,360 --> 04:38:38,959
okay so that's the square root and then remember other factor out
2158
04:38:38,959 --> 04:38:46,239
that max factor and if there's anything left over other that's
2159
04:38:46,240 --> 04:38:54,880
that as an integer and you know that's it i'm just taking this
2160
04:38:54,880 --> 04:39:02,240
as an integer and you see that you can do that with variables so
2161
04:39:02,240 --> 04:39:15,760
and now the output is square root which was this variable up here
2162
04:39:15,759 --> 04:39:23,279
square root is different than math that square root and using this
2163
04:39:23,279 --> 04:39:34,079
be my last i want to be that to be my last thing is this output so
2164
04:39:35,439 --> 04:39:41,599
this for the test that's why output the word output shows up here
2165
04:39:41,599 --> 04:39:45,519
but notice it's not a print statement it just says output and the
2166
04:39:45,520 --> 04:39:52,000
and it will display it so these types of simpy displays sometimes
2167
04:39:57,840 --> 04:40:03,599
okay so what do we have uh let's take a look at our um
2168
04:40:05,840 --> 04:40:08,720
let's take a look at 50 as we were talking about before
2169
04:40:12,240 --> 04:40:20,560
so and just because this came first that's why it says test passed
2170
04:40:20,560 --> 04:40:24,960
but 50 factors out to five root two
2171
04:40:28,479 --> 04:40:37,439
and if we run it again then we have you know go back to our 12 12
2172
04:40:38,639 --> 04:40:42,799
and we can see how we can factor out these square roots
2173
04:40:42,799 --> 04:40:48,079
so there we go this is now one of the things that you can do
2174
04:40:49,200 --> 04:40:54,240
and this would be a bonus we could do this later is we already
2175
04:40:54,240 --> 04:40:57,280
you could put all this in a function
2176
04:40:59,439 --> 04:41:05,919
you know all you know you don't need to the testing part but the
2177
04:41:05,919 --> 04:41:13,279
the testing part but the output you could put this all in a
2178
04:41:13,279 --> 04:41:21,119
for you so just like you have math that square dot sqrt to output
2179
04:41:21,119 --> 04:41:27,759
decimal you could actually make your own function that would do
2180
04:41:28,560 --> 04:41:34,000
you know like this so some interesting things that you can do and
2181
04:41:34,000 --> 04:41:41,680
you to see the build-up of this and how we can use these you know
2182
04:41:41,680 --> 04:41:46,080
to factoring a square root which is something that's you know
2183
04:41:46,720 --> 04:41:50,479
useful for some math you get into and then you can write code to
2184
04:41:52,560 --> 04:41:59,280
all right here's some rounding just interesting things so if i
2185
04:41:59,279 --> 04:42:07,840
whole number if i have something like this if i round comma and
2186
04:42:07,840 --> 04:42:14,240
me how many decimal places and if i have this round and it's a
2187
04:42:14,240 --> 04:42:25,760
big numbers so that will give me that many zeros so there we go so
2188
04:42:25,759 --> 04:42:32,079
millions the second number rounded the sixth decimal places so and
2189
04:42:32,080 --> 04:42:42,720
my print statements print round and the first number six zeros so
2190
04:42:47,200 --> 04:42:51,200
and then the second one print round
2191
04:42:51,200 --> 04:42:56,720
be and i wanted three decimal places so it'd be three
2192
04:42:59,680 --> 04:43:07,680
there we go and we can print so that there's my six decimal places
2193
04:43:07,680 --> 04:43:15,439
i don't want it around to the next integer it already is an
2194
04:43:15,439 --> 04:43:25,919
14 million 500 thousand rounds to 15 million and then the next one
2195
04:43:27,759 --> 04:43:35,279
all right there we go and fractions decimals and percents
2196
04:43:35,279 --> 04:43:43,439
percents so we could see here and we've done some things like this
2197
04:43:45,200 --> 04:43:51,760
here we're going to take the input as a string see i'm going to
2198
04:43:51,759 --> 04:43:59,039
the input as a string and as a string every string has this
2199
04:43:59,040 --> 04:44:07,840
string so i want to take the length of that string and then i need
2200
04:44:09,200 --> 04:44:14,000
now remember the person who enters this in is going to put a
2201
04:44:14,000 --> 04:44:17,759
i have to subtract one because i don't want that decimal place i
2202
04:44:17,759 --> 04:44:26,000
without that dot all right so that's going to be the exponent and
2203
04:44:26,000 --> 04:44:38,479
now my input digits i'm going to cast that as a float so the
2204
04:44:39,599 --> 04:44:50,000
10 to that exponent and i wrote it all out just to make it clear
2205
04:44:50,000 --> 04:44:55,919
anything with three decimal places it's going to be times 10 to
2206
04:44:55,919 --> 04:45:01,359
going to move the decimal place over and then my numerator is
2207
04:45:02,159 --> 04:45:10,639
and the denominator is that 10 to the third oh 10 to the exponent
2208
04:45:10,639 --> 04:45:21,360
oh 10 to the exponent there we go so there's my fraction and this
2209
04:45:21,360 --> 04:45:24,479
anytime we're converting fractions but now we're just writing code
2210
04:45:25,040 --> 04:45:29,280
so how many decimal places that's really what this is essentially
2211
04:45:29,279 --> 04:45:35,599
how many decimal places am i talking about and then that number
2212
04:45:35,599 --> 04:45:42,159
places 10 to that exponent and the denominator is 10 to that
2213
04:45:43,520 --> 04:45:53,200
because now that i have it as numerator denominator now i actually
2214
04:45:53,200 --> 04:46:00,400
go back to n if i want or i could put numerator times numerator
2215
04:46:00,400 --> 04:46:09,360
one but i could do n times 100 which it's always times 100 because
2216
04:46:11,840 --> 04:46:16,319
and so that's it that's the first two digits are there are your
2217
04:46:16,319 --> 04:46:27,119
the percent and we can run it so if i have somebody enters in
2218
04:46:27,119 --> 04:46:35,119
five there we go so the decimal is point one two five the fraction
2219
04:46:35,680 --> 04:46:39,279
over a thousand and the percent is twelve point five percent
2220
04:46:42,000 --> 04:46:48,400
so there we go converting any input fraction decimal percent
2221
04:46:48,400 --> 04:46:57,120
percent and this is where i was saying that you could you could
2222
04:47:00,319 --> 04:47:07,279
this you can define a function here where you can execute a block
2223
04:47:07,279 --> 04:47:14,639
so you know here's the function definition d e f and then the name
2224
04:47:14,639 --> 04:47:22,799
open and close parentheses that may take input but they don't have
2225
04:47:22,799 --> 04:47:31,200
four spaces one two three four so d e f name of the function colon
2226
04:47:31,200 --> 04:47:37,040
it can be as many lines as you want and it can have comments just
2227
04:47:38,560 --> 04:47:43,280
and then there you go here's one something outside the function
2228
04:47:52,240 --> 04:47:56,159
it's then called it it won't do anything until it's called here
2229
04:47:58,479 --> 04:48:04,159
so i could have this function definition and if i took out this
2230
04:48:04,159 --> 04:48:14,959
again so now it'll have this is outside the function then it'll
2231
04:48:15,520 --> 04:48:17,040
and then back outside the function
2232
04:48:19,840 --> 04:48:23,439
there you go now change the name and remember to call it so
2233
04:48:25,919 --> 04:48:30,079
there we go and then we want to run it then change the name to
2234
04:48:30,080 --> 04:48:32,560
because it can't spell function without fun
2235
04:48:36,240 --> 04:48:42,960
so if i just change the name i'm gonna call it fun and now i'm
2236
04:48:46,080 --> 04:48:51,120
so that's what is the function call is when i you know when i tell
2237
04:48:51,119 --> 04:49:00,639
now there you go same thing to show you how to define a function
2238
04:49:02,479 --> 04:49:03,840
and then here's one with input
2239
04:49:06,159 --> 04:49:14,479
so it can take input any input we're going to call an argument so
2240
04:49:14,479 --> 04:49:23,279
um now right here it's telling me that it's uh you know called
2241
04:49:23,279 --> 04:49:27,840
it's going to take this input which will store its variable name
2242
04:49:27,840 --> 04:49:35,119
here and it's going to print hello whatever the name is now here
2243
04:49:36,400 --> 04:49:42,640
at the end of your function skip a line at least one line so then
2244
04:49:42,639 --> 04:49:51,919
definitely not in the function and then the input and casting it
2245
04:49:51,919 --> 04:49:58,239
and we'll keep it that that way what is your name and notice
2246
04:49:58,240 --> 04:50:06,480
indicate a new line so now when we run the greeting you see it's
2247
04:50:06,479 --> 04:50:12,880
and i'm going to pass that into the function so now that function
2248
04:50:12,880 --> 04:50:23,120
going to be this variable and then it'll do the greeting so here
2249
04:50:24,959 --> 04:50:31,680
hello there we go and now now that you see this working this is
2250
04:50:31,680 --> 04:50:37,040
this because it's like remembering where these are
2251
04:50:39,680 --> 04:50:47,840
so you know greeting and then when we call it i'm going to change
2252
04:50:51,200 --> 04:50:57,520
there we go so we see you know where these variables are
2253
04:50:57,520 --> 04:51:02,799
function like this so then you see you know this variable how do
2254
04:51:02,799 --> 04:51:08,880
as an argument there and then in the function definition it's
2255
04:51:08,880 --> 04:51:14,880
something with it but the function of this should actually be the
2256
04:51:20,080 --> 04:51:27,360
yep see all good and these functions which is kind of cool you
2257
04:51:27,360 --> 04:51:42,400
input so we have this so i can have multiple input in this
2258
04:51:42,400 --> 04:51:46,240
you know do something with it well we're just going to add them
2259
04:51:46,240 --> 04:51:52,080
for any formula you have you see like i just made this add but you
2260
04:51:52,080 --> 04:52:00,400
formula you have make a function out of it so notice here you know
2261
04:52:00,400 --> 04:52:09,920
as three and then it's going to expect three inputs a b c and then
2262
04:52:09,919 --> 04:52:28,079
c and now down here i have to call it with all three variables so
2263
04:52:28,080 --> 04:52:35,440
existed before but then it just stayed there floating not doing
2264
04:52:35,439 --> 04:52:43,919
here you know now that we have have this i'm going to call the
2265
04:52:43,919 --> 04:52:48,559
because the function is expecting three inputs and then it's going
2266
04:52:53,759 --> 04:52:59,119
so we see enter a number and i'll enter a number
2267
04:52:59,119 --> 04:53:06,159
and another number six another number seven oh because there you
2268
04:53:16,159 --> 04:53:24,959
hey fun with functions now all the this function and the ones we
2269
04:53:24,959 --> 04:53:32,639
statement as a way to show output and that's good but we could
2270
04:53:32,639 --> 04:53:45,279
value so notice this function here then it just returns that that
2271
04:53:47,360 --> 04:53:52,240
and what that does is it returns it right where you call the
2272
04:53:52,240 --> 04:53:59,120
right where you call the function so notice this if we're going to
2273
04:53:59,840 --> 04:54:06,639
you know there's our input it's the float i don't know stored as
2274
04:54:08,240 --> 04:54:15,120
what i print is your number multiplied equals and then right here
2275
04:54:15,119 --> 04:54:23,360
it's going to be that function i call that function with variable
2276
04:54:24,560 --> 04:54:26,960
and it's just going to take it times two
2277
04:54:32,080 --> 04:54:37,680
all right so notice some of these you run it and then we're going
2278
04:54:37,680 --> 04:54:45,279
it again so enter a number all right there you go 16 your number
2279
04:54:47,040 --> 04:54:53,680
so all we're doing here is changing the return statement multiply
2280
04:54:54,720 --> 04:55:01,120
everything else we actually can keep the same there you go enter a
2281
04:55:01,119 --> 04:55:11,599
enter a number 16 and it's 48 so that's the return statement is
2282
04:55:12,400 --> 04:55:16,240
that's where the number shows up your number multiplied equals and
2283
04:55:18,799 --> 04:55:24,319
returns that so that's pretty useful sometimes because we want
2284
04:55:24,319 --> 04:55:28,319
where do i want this output to be right there and so we put the
2285
04:55:28,319 --> 04:55:35,119
so that's the return statements good useful statement here so we
2286
04:55:35,119 --> 04:55:38,559
things we have all these functions we you know we're looking at
2287
04:55:38,560 --> 04:55:48,319
solving some things you can even just solve for x and there we go
2288
04:55:49,200 --> 04:55:54,479
now notice here we're importing simpy again or for our symbolic
2289
04:55:54,479 --> 04:55:59,919
it even further from simpy we're going to import symbols and from
2290
04:55:59,919 --> 04:56:11,759
import solve so all these now i'll just define it here x equals
2291
04:56:12,479 --> 04:56:18,479
in single quotes so that's telling us that we're going to use x as
2292
04:56:18,479 --> 04:56:26,319
and the way that simpy solve works is the equation has to be equal
2293
04:56:28,479 --> 04:56:33,119
so at what i'm going to do all right well we'll see
2294
04:56:35,360 --> 04:56:40,639
here's the output solve for x and i even have this here zero
2295
04:56:40,639 --> 04:56:52,319
enter it in now what this does simpy has this built in solve and
2296
04:56:52,319 --> 04:56:58,560
be right here so that solve we know that behind the scenes it has
2297
04:56:58,560 --> 04:57:09,520
equation using the variable x and this is just like a subtle thing
2298
04:57:09,520 --> 04:57:17,760
another time but this returns a finite set and for this we're
2299
04:57:17,759 --> 04:57:25,919
answer that we want equation zero so enter an equation and then
2300
04:57:25,919 --> 04:57:39,439
answer there we go all right enter an equation and so if i have
2301
04:57:42,560 --> 04:57:47,840
minus eight so we can see that x must be four
2302
04:57:47,840 --> 04:57:55,200
four and i'll put it there now if i didn't have this
2303
04:57:59,599 --> 04:58:04,000
i'll do the i'll do the exact same thing two times x minus eight
2304
04:58:07,119 --> 04:58:12,399
it just the way it displays it because it's a finite set now that
2305
04:58:12,400 --> 04:58:17,760
to possibly if i put in something that had more than one answer i
2306
04:58:17,759 --> 04:58:27,759
too if i have let's see i'll run it again so supposing i have now
2307
04:58:32,240 --> 04:58:36,400
even if it doesn't work out to a nice integer but i'm going to
2308
04:58:39,040 --> 04:58:46,000
you see negative three and three it does have two answers and
2309
04:59:03,919 --> 04:59:11,919
function x minus four so there we go
2310
04:59:14,639 --> 04:59:16,799
if you didn't get a syntax error you're ready for the project
2311
04:59:18,880 --> 04:59:24,960
so different things you can do so this is where we now can make
2312
04:59:26,720 --> 04:59:33,280
and this is where i leave it open to you how you could do this you
2313
04:59:33,279 --> 04:59:41,039
like you could take one of these functions here like the factoring
2314
04:59:48,560 --> 04:59:54,479
yeah so you could take this factoring the square root and copy all
2315
05:00:03,520 --> 05:00:10,080
all right so as an example of something something you could do and
2316
05:00:15,759 --> 05:00:24,399
this now what's interesting is you as defining the function here
2317
05:00:32,080 --> 05:00:39,200
and we definitely want input and i'm going to make it n
2318
05:00:39,200 --> 05:00:48,000
and i'm going to make it n so we could do this that
2319
05:00:49,919 --> 05:00:57,439
it factors the square root and you could make each of these then
2320
05:01:02,000 --> 05:01:13,840
indent everything now since we're factoring square and we don't
2321
05:01:13,840 --> 05:01:20,880
delete that and here we go use you know we can keep all these
2322
05:01:25,439 --> 05:01:27,599
and this is the thing with a function
2323
05:01:27,599 --> 05:01:37,439
is you do want everything to be and you can take out things like
2324
05:01:41,360 --> 05:01:48,240
there we go then this has to be indented
2325
05:01:48,240 --> 05:01:58,960
and this has to be indented there we go and all of these divide up
2326
05:02:03,840 --> 05:02:09,040
and we see that we have output okay
2327
05:02:17,759 --> 05:02:26,159
all right and this part we don't need you know
2328
05:02:29,599 --> 05:02:32,399
and what do we want to do we want to
2329
05:02:45,520 --> 05:02:51,119
yes this stuff does not have a test because this is so what you
2330
05:02:51,119 --> 05:02:59,840
square root and then down here later we could try to call it
2331
05:02:59,840 --> 05:03:08,880
square root and you know uh let's see 20
2332
05:03:14,159 --> 05:03:25,520
and oh maybe I have to return the output
2333
05:03:31,520 --> 05:03:34,159
it's actually kind of funny that just popped up but there we go
2334
05:03:34,159 --> 05:03:41,840
so you see the output but because it's in a function we have to
2335
05:03:45,680 --> 05:03:51,920
all right so this is you know this is not the part of the function
2336
05:03:51,919 --> 05:03:56,959
and these are some things you can do because then you can you know
2337
05:03:56,959 --> 05:04:05,599
just define them in your own you know colab code cell with some
2338
05:04:06,319 --> 05:04:11,200
you know you can make them all functions but that's the idea and
2339
05:04:11,200 --> 05:04:17,200
if you wanted to where you just have um
2340
05:04:19,119 --> 05:04:22,399
which one you know what function should you run
2341
05:04:22,400 --> 05:04:31,120
should you run you could do a table of contents there too and then
2342
05:04:31,119 --> 05:04:35,360
you're building this multi-function calculator you're putting all
2343
05:04:36,000 --> 05:04:42,639
a colab notebook that you're going to be able to use and it's
2344
05:04:42,639 --> 05:04:53,040
calculator and then as of making this video I can't tell you
2345
05:04:53,040 --> 05:04:59,360
but hold on to it and then you'll see where to put it together for
2346
05:05:01,279 --> 05:05:06,479
getting the credit for passing this part of the certification and
2347
05:05:06,479 --> 05:05:13,759
all right so hopefully this was useful you know how to work
2348
05:05:15,599 --> 05:05:24,639
how to put all this together into this certification project and
2349
05:05:24,639 --> 05:05:32,159
there's more than one way to do all this so find find a way that
2350
05:05:32,159 --> 05:05:38,400
making your own calculator all right and we'll go on to the next
2351
05:05:43,040 --> 05:05:49,120
so with graphing a system of equations we're looking at really
2352
05:05:49,119 --> 05:05:55,759
on the same x y axis and we want to see where do these two lines
2353
05:05:55,759 --> 05:06:02,479
two lines cross that's going to be the solution to our system of
2354
05:06:02,479 --> 05:06:09,840
have two equations and this one's y equals three x plus ten and
2355
05:06:09,840 --> 05:06:16,560
so let's say I don't know it's a place you like to go let's say
2356
05:06:16,560 --> 05:06:23,120
so four dollars times x which is every time you go then y would be
2357
05:06:23,119 --> 05:06:29,520
have a deal oh well if you pay ten dollar membership fee then your
2358
05:06:30,319 --> 05:06:37,439
so there you have the the decision like okay well with this
2359
05:06:37,439 --> 05:06:43,759
but when would these be the same price you know how many times
2360
05:06:43,759 --> 05:06:50,479
the same price so we want you know that's just one example of the
2361
05:06:50,479 --> 05:06:56,079
so i put these both in y equals because we're going to get into
2362
05:06:56,080 --> 05:07:02,960
but we're looking at just how this graph plays out here so if i
2363
05:07:02,959 --> 05:07:09,040
so without numbers here we're just going to estimate let's say 10
2364
05:07:09,040 --> 05:07:16,959
how we plot begin at 10 and then up three over over one and let's
2365
05:07:16,959 --> 05:07:26,399
like this and let's just say that's the line and then we have y
2366
05:07:26,400 --> 05:07:32,960
it begins at zero but it's a steeper slope you know be at zero
2367
05:07:32,959 --> 05:07:39,599
say you know it looks something like this and then they cross
2368
05:07:39,599 --> 05:07:46,719
intersect that's going to be the solution to our system of
2369
05:07:46,720 --> 05:07:55,120
there are numbers here and it was you know somewhere around 10 so
2370
05:07:55,119 --> 05:08:02,959
that that would be like 10 you know 40 something like that you
2371
05:08:02,959 --> 05:08:09,439
there so you see where these cross and depending on what you're
2372
05:08:10,000 --> 05:08:14,959
clearer to see might be harder to see but we can then always test
2373
05:08:14,959 --> 05:08:19,680
that's where that's where these lines intersect we can plug that
2374
05:08:20,240 --> 05:08:30,320
so if x is 10 so it would be three times 10 plus 10 and then y
2375
05:08:30,319 --> 05:08:37,040
that work three times 10 is 30 plus 10 is 40 yes that does work
2376
05:08:37,040 --> 05:08:47,280
you know four times 10 and y is 40 and then that works so that's
2377
05:08:47,279 --> 05:08:52,479
were doing this you know old school plotting a bunch of points i
2378
05:08:52,479 --> 05:08:58,319
y table and plot a bunch of points i was using graph paper and
2379
05:08:58,319 --> 05:09:03,520
and the reason why i didn't worry about getting this you know
2380
05:09:03,520 --> 05:09:10,000
drawn to scale is because i want to just you want you to see you
2381
05:09:10,000 --> 05:09:15,759
together two lines on the same graph my question is where do these
2382
05:09:15,759 --> 05:09:20,479
we're going to look at the code how can i set up a graph how can i
2383
05:09:21,200 --> 05:09:28,639
and you know for whatever the answer might be however you know
2384
05:09:28,639 --> 05:09:36,399
might be how we can find the solution each time so now let's take
2385
05:09:36,400 --> 05:09:44,080
you remember graphing one equation on a on a cartesian plane this
2386
05:09:44,080 --> 05:09:49,120
different one of the big things though is we're going to use the
2387
05:09:49,919 --> 05:09:55,119
so we'll talk about that more in a second but the first thing we
2388
05:09:55,119 --> 05:10:02,959
import numpy now you know this plt that makes it a lot shorter
2389
05:10:02,959 --> 05:10:09,279
dot pi plot numpy we shorten it you know it's just a little bit
2390
05:10:09,840 --> 05:10:14,639
you know the common abbreviation so we're going to do that and
2391
05:10:16,159 --> 05:10:22,720
throughout throughout this code so like before we are going to
2392
05:10:22,720 --> 05:10:31,280
our range x min x max y min y max there we go and one of the
2393
05:10:31,279 --> 05:10:38,000
instead of creating a loop like we were doing before what this
2394
05:10:38,000 --> 05:10:44,720
of x values and the first thing we need to do then is to find how
2395
05:10:44,720 --> 05:10:51,840
i'll take these x values you know notice x max minus x min so how
2396
05:10:51,840 --> 05:10:58,799
and that should give me an integer number but i'm going to say 10
2397
05:10:58,799 --> 05:11:04,079
that's how many points i want that's actually going to be for
2398
05:11:04,080 --> 05:11:08,960
need that many they it displays very nicely for anything with a
2399
05:11:08,959 --> 05:11:17,040
probably plenty and for some more complicated graphs you might do
2400
05:11:17,040 --> 05:11:23,440
me the number of points i have and just again based on these so if
2401
05:11:23,439 --> 05:11:28,239
this updates automatically and then here's where i'm going to
2402
05:11:28,959 --> 05:11:37,119
so using that library np dot linspace and it gives it takes the
2403
05:11:37,119 --> 05:11:42,479
and then how many points so there we go it's just going through
2404
05:11:42,479 --> 05:11:47,279
and and how many points in between and i'm just storing that as x
2405
05:11:47,279 --> 05:11:55,919
as my x values hopefully this is looking familiar setting up you
2406
05:11:55,919 --> 05:12:03,199
for x and y and here's where we're going to plot line one so in
2407
05:12:03,840 --> 05:12:09,680
two times x there we go and what it does is that will take each of
2408
05:12:09,680 --> 05:12:16,880
needing to create a loop it'll go through each of these x values
2409
05:12:16,880 --> 05:12:24,720
dot plot x and then y1 so here we go i have this and the second
2410
05:12:24,720 --> 05:12:30,800
y2 equals and this one i took it beyond linear i just made x
2411
05:12:30,799 --> 05:12:37,840
it up a little bit and so there we go that's my second y value and
2412
05:12:37,840 --> 05:12:49,520
plot here x the x values and then y2 so there we go to find the x
2413
05:12:51,119 --> 05:13:00,159
when we run this there we have it we have our each axis that first
2414
05:13:00,159 --> 05:13:10,799
light blue line and y2 was the parabola now that's a pretty good
2415
05:13:10,799 --> 05:13:20,479
had fewer points let's just say even two times this yeah that's
2416
05:13:20,479 --> 05:13:27,599
still going to see this become choppy yeah wasn't that bad but if
2417
05:13:27,599 --> 05:13:35,759
one times this then it really becomes a lot choppier because i'm
2418
05:13:35,759 --> 05:13:43,119
and there's a lot more going on here but you see how that linear
2419
05:13:43,119 --> 05:13:57,039
out just fine but this one yeah so that's why just as a default
2420
05:13:57,040 --> 05:14:05,360
we go and then to graph anything else all we have to do is change
2421
05:14:05,360 --> 05:14:13,279
oh okay well how about if i make this like negative negative 3x
2422
05:14:19,040 --> 05:14:25,680
three times x there we go if you write it by hand you know doing
2423
05:14:26,240 --> 05:14:32,159
you forget the multiplying so that's the key python syntax you
2424
05:14:32,159 --> 05:14:39,119
um and let's take a look at this and maybe we'll make this one um
2425
05:14:40,720 --> 05:14:47,040
there we go just to the third power how about that so there we go
2426
05:14:48,000 --> 05:14:53,439
and this one here cubic and we'll run this
2427
05:14:57,200 --> 05:15:00,400
you know even this yep the curve looks nice
2428
05:15:02,000 --> 05:15:07,840
so there we go all you have to do is change y1 and y2 and you
2429
05:15:07,840 --> 05:15:13,200
two but a lot of times we're going to do linear equations and have
2430
05:15:13,200 --> 05:15:27,440
questions where do they intersect so there we go numpy and use
2431
05:15:27,439 --> 05:15:32,639
the core skills in this unit let's look through some extra
2432
05:15:33,200 --> 05:15:38,560
extra problems using the colab notebook so you can see how you can
2433
05:15:38,560 --> 05:15:45,600
you're building and use these to solve problems that might come up
2434
05:15:45,599 --> 05:15:50,799
life so we're going to go through some more extra problems here
2435
05:15:50,799 --> 05:15:56,079
few other things you can do with graph with graphing and one of
2436
05:15:56,080 --> 05:16:04,320
lines or just in general above and below so if you have an
2437
05:16:04,319 --> 05:16:09,040
below the line we see we don't need to import anything different
2438
05:16:09,040 --> 05:16:16,240
the graphs you've been doing set up x min and maximum how many
2439
05:16:16,240 --> 05:16:23,200
for your array and we've been doing this before here's the line
2440
05:16:23,200 --> 05:16:30,159
now this one if you're doing an inequality you could also add the
2441
05:16:30,159 --> 05:16:38,079
a dashed line but this might be hard to see this line but here's
2442
05:16:38,880 --> 05:16:48,240
so we're going to say from x at still the same x values and then
2443
05:16:48,240 --> 05:16:55,840
two y values from y1 up to 10 and you could define that as a
2444
05:16:55,840 --> 05:17:03,840
already set our maximum or you could actually say up to y max like
2445
05:17:03,840 --> 05:17:09,439
this one we call it you know we want to make this red so that
2446
05:17:09,439 --> 05:17:14,719
give you a default but you know you can define these and that
2447
05:17:14,720 --> 05:17:20,960
go the fill between same x value and then you have the range of y
2448
05:17:20,959 --> 05:17:28,319
to work and we'll do a few lines here we'll make make some art so
2449
05:17:28,319 --> 05:17:34,880
familiar define the line and then plot there we go but then we're
2450
05:17:34,880 --> 05:17:42,560
between that x and y2 and y1 so you see you can define it even you
2451
05:17:42,560 --> 05:17:50,880
up to the top this one i'm going to go up to the other line and
2452
05:17:50,880 --> 05:18:02,479
line and here we go so fill line three very similar and there we
2453
05:18:02,479 --> 05:18:09,599
different face color and this one's going to be green where am i
2454
05:18:09,599 --> 05:18:15,919
between this one that we've defined up here y3 and y2 so that's so
2455
05:18:15,919 --> 05:18:24,319
are just going to be a band and here we go i can do this one
2456
05:18:24,319 --> 05:18:29,360
notice all these are just simple linear equations to show you this
2457
05:18:29,360 --> 05:18:37,600
two so what happens when we run this so we see we get the first
2458
05:18:37,599 --> 05:18:47,519
and then from there to there from there to there and there we go
2459
05:18:48,799 --> 05:18:55,040
let's say all right we see this red we see this yellow so if the
2460
05:18:55,040 --> 05:19:08,479
there i went up to y max it would just overlap and i know you
2461
05:19:08,479 --> 05:19:13,759
thinking hey you might have might turn orange you know yellow
2462
05:19:13,759 --> 05:19:23,039
it's the order of things that it graphs this that was red but then
2463
05:19:23,040 --> 05:19:35,360
it overwrote the red and if i wanted to i still call it a line one
2464
05:19:35,360 --> 05:19:41,520
down here so now this is yellow and then this whole thing would be
2465
05:19:45,200 --> 05:19:52,159
and remember because the yellow started down lower so the red will
2466
05:19:52,159 --> 05:19:59,439
but it didn't go down this far so the red didn't cover this so we
2467
05:20:01,439 --> 05:20:08,959
you know the yellow line was x plus three and then the red line
2468
05:20:08,959 --> 05:20:14,319
had that little gap that you know when the red went on it didn't
2469
05:20:14,319 --> 05:20:23,200
right but then we can you know y1 and now this one i definitely
2470
05:20:23,200 --> 05:20:29,840
y1 wasn't defined yet so you see it gave me that little error
2471
05:20:30,720 --> 05:20:32,880
make this official before we go on to the next thing
2472
05:20:35,919 --> 05:20:41,759
and we can see so since i've moved a few things around before we
2473
05:20:41,759 --> 05:20:48,159
let's change something else here i was saying that we need we
2474
05:20:48,159 --> 05:20:55,279
the red line and the yellow line the dashed line and it might be
2475
05:20:55,279 --> 05:21:01,199
can always hope here so single quotes and then i'm going to make
2476
05:21:01,200 --> 05:21:06,639
thing with this one the other argument single quotes and i'll make
2477
05:21:06,639 --> 05:21:17,200
two would be dashed lines instead of a solid line it's hard to see
2478
05:21:17,919 --> 05:21:25,439
there we go and because these you know with the shading sometimes
2479
05:21:25,439 --> 05:21:30,399
the exact line i mean mathematically you might just be in the
2480
05:21:30,400 --> 05:21:36,800
line but the way it shows up on the graph you know it's not you
2481
05:21:36,799 --> 05:21:42,639
it's nice but sometimes you might say oh okay if i'm making some
2482
05:21:42,639 --> 05:21:47,840
want or need that extra line so there we go so there's some
2483
05:21:50,639 --> 05:21:56,720
draw lines shade above and below and you can be you can get
2484
05:21:56,720 --> 05:22:04,479
of all sorts of things and this is essentially you know what
2485
05:22:04,479 --> 05:22:09,200
you know defining each individual pixel but defining the lines
2486
05:22:09,200 --> 05:22:18,080
equations and then that way you can scale things because let's say
2487
05:22:18,080 --> 05:22:25,680
change the dimensions of my graph i could scale this line with the
2488
05:22:25,680 --> 05:22:32,000
so that's the advantage vector graphics you can make larger things
2489
05:22:32,000 --> 05:22:38,080
size because it's all defined on equations anyway so there we go
2490
05:22:38,080 --> 05:22:44,400
with that other cool things you can create an interactive graph
2491
05:22:44,400 --> 05:22:49,680
interactive we're going to set up some sliders this one's called
2492
05:22:49,680 --> 05:22:54,720
across some python code that defines sliders that actually uses
2493
05:22:54,720 --> 05:23:02,800
works too but here's what we're going to import there we go in
2494
05:23:02,799 --> 05:23:08,000
to get us to be able to adjust these sliders and see the effect on
2495
05:23:09,040 --> 05:23:16,240
so there we go and then this interactive widget so i'm going to
2496
05:23:16,240 --> 05:23:26,000
is going to happen within this function so i'm going to define
2497
05:23:26,000 --> 05:23:32,799
a simple slope intercept so i'm going to define the function of m
2498
05:23:32,799 --> 05:23:40,559
for zoom so notice all of your dimensions here are based on that
2499
05:23:40,560 --> 05:23:54,640
and then we still have the points and the plot that's my y value
2500
05:23:54,639 --> 05:24:02,959
takes these inputs and here's the slider it's really the most of
2501
05:24:02,959 --> 05:24:10,319
is right here on this line so interactive plot now i can make that
2502
05:24:10,319 --> 05:24:18,239
just decided to call it that and interactive open parentheses so
2503
05:24:18,240 --> 05:24:26,000
am i going to run and i made it f and the main reason i made it f
2504
05:24:26,000 --> 05:24:32,240
of code was not that long but there you go what function am i
2505
05:24:32,240 --> 05:24:41,440
some ranges here m will go from negative 99 b will go from
2506
05:24:42,319 --> 05:24:49,840
so notice the zoom i could make it really small and x min max you
2507
05:24:50,400 --> 05:24:57,360
it's still going to be square but i could zoom it really into just
2508
05:24:57,360 --> 05:25:03,440
or i could zoom it out to 100 and i could change that number as i
2509
05:25:03,439 --> 05:25:10,239
we have is this and when we run that interactive plot it's going
2510
05:25:10,240 --> 05:25:17,600
sliders and then run this function so let's see how that works so
2511
05:25:18,560 --> 05:25:20,000
puts everything right in the middle
2512
05:25:20,000 --> 05:25:30,000
so my slope is zero and b is zero so you might be able to see that
2513
05:25:30,000 --> 05:25:35,439
this blue line is on there because it's a slope of zero zero what
2514
05:25:35,439 --> 05:25:45,919
see look at that now i have a slope of three and as i move up b
2515
05:25:45,919 --> 05:25:53,039
different place it begins right there now we see it starts right
2516
05:25:53,040 --> 05:25:59,040
bring this down and you see i can zoom in
2517
05:26:03,680 --> 05:26:11,040
pretty cool and see this is what i zoom if i'm so zoomed in one
2518
05:26:11,040 --> 05:26:17,840
so that's off the graph now i'd have to move that back now you
2519
05:26:20,959 --> 05:26:24,639
and these are some cool things you can do with your graph you can
2520
05:26:24,639 --> 05:26:28,159
even if you you know you're graphing all kinds of things you just
2521
05:26:28,720 --> 05:26:34,319
this is a nice way to zoom and you know you might see some things
2522
05:26:34,319 --> 05:26:37,680
where you can zoom and here's how you can write the code you can
2523
05:26:37,680 --> 05:26:45,200
graph that zooms in and out and you can adjust some other things
2524
05:26:45,200 --> 05:26:49,280
cool things you can do and i just want to you know it's a good way
2525
05:26:50,000 --> 05:26:56,639
slope and intercept as they change how does the graph change you
2526
05:26:56,639 --> 05:27:05,200
and therefore across the y-axis down here and i can change the
2527
05:27:05,200 --> 05:27:12,799
all the way so now i'm really zoomed out and it it looks like this
2528
05:27:12,799 --> 05:27:19,919
because it's so tiny it only crosses at negative three and my
2529
05:27:19,919 --> 05:27:26,479
go some interesting things you can do with zooming and you see
2530
05:27:26,479 --> 05:27:30,720
interactive plot and then your function all the graphing happens
2531
05:27:30,720 --> 05:27:37,920
okay so here's another interesting way to graph we can actually
2532
05:27:37,919 --> 05:27:44,959
to lead you to working with data science so let's just get a
2533
05:27:44,959 --> 05:27:53,759
else created this library this mediostat library for getting just
2534
05:27:53,759 --> 05:28:00,319
um here's you know the weather information that they take time
2535
05:28:00,319 --> 05:28:10,799
temperature maximum temperature precipitation snow wind direction
2536
05:28:11,919 --> 05:28:18,239
the maximum wind gusts air pressure and the amount of sun so there
2537
05:28:18,240 --> 05:28:24,640
solar panels you can calculate the hours of sun at a particular
2538
05:28:25,599 --> 05:28:33,199
wind turbines you can calculate wind speed at different places and
2539
05:28:33,200 --> 05:28:39,520
this one you do need to install this and so we're going to run pip
2540
05:28:39,520 --> 05:28:47,520
install this and so we're going to run pip install and i just made
2541
05:28:49,840 --> 05:28:54,720
it's a its own separate code block and there we go we just see
2542
05:28:55,919 --> 05:29:01,599
that installed this so there's a lot of things already built into
2543
05:29:01,599 --> 05:29:09,680
we've imported some things but didn't need to install anything
2544
05:29:09,680 --> 05:29:16,159
therefore it's not already built in so some of those newer
2545
05:29:16,159 --> 05:29:23,599
really pretty straightforward pip install mediostat done so
2546
05:29:23,599 --> 05:29:30,239
we can import it date time that was our i was already at python
2547
05:29:30,240 --> 05:29:38,080
do need to import that and then now we still need to import this
2548
05:29:38,080 --> 05:29:44,720
this data so that's why we import that and then the install
2549
05:29:45,759 --> 05:29:51,119
these i've included the link here you know for all the
2550
05:29:52,959 --> 05:29:58,639
all right so here's how it works start we'll define these
2551
05:29:58,639 --> 05:30:08,479
time year month day year month day so i decided let's do like the
2552
05:30:10,959 --> 05:30:21,599
so we have uh uh created a point now the point you create this is
2553
05:30:22,400 --> 05:30:26,000
so they don't have really built in like type in the name of a
2554
05:30:26,000 --> 05:30:31,040
you want to have an idea like let you know where you live you can
2555
05:30:31,040 --> 05:30:37,920
and longitude of where you are you can find latitude longitude you
2556
05:30:37,919 --> 05:30:42,879
you want a particular city somewhere in the city so the example
2557
05:30:42,880 --> 05:30:50,639
look this up you know somebody uh did this for british columbia so
2558
05:30:50,639 --> 05:30:56,159
philadelphia so there we go so here's a point in the middle of the
2559
05:30:57,919 --> 05:31:05,519
we can just get the data here so from that point so there we go
2560
05:31:06,959 --> 05:31:13,119
um there's my data point philly and start and end so there we go
2561
05:31:13,119 --> 05:31:20,639
you know start date end date location and then collect the data it
2562
05:31:22,159 --> 05:31:29,040
this does work using the same variable data equals this data
2563
05:31:29,680 --> 05:31:35,920
it works out and this one i just said hey let's just plot the
2564
05:31:35,919 --> 05:31:45,839
it looks very similar data dot plot and then down here we have plt
2565
05:31:45,840 --> 05:31:50,560
we need to do it actually all the rest of it the dimensions and
2566
05:31:50,560 --> 05:31:56,560
labels graph happen automatically so there we go we just have y
2567
05:31:56,560 --> 05:32:07,280
these three things so when i run it we see the average temperature
2568
05:32:08,319 --> 05:32:14,479
so all these things we know in a previous video we were talking
2569
05:32:14,479 --> 05:32:21,840
legend how to label the axis and everything this already does all
2570
05:32:21,840 --> 05:32:29,119
it'll just graph what you have here all right so there we go and
2571
05:32:29,119 --> 05:32:35,119
celsius so there you go if you're in philly you're like hey it
2572
05:32:35,119 --> 05:32:42,000
time but yes this is celsius so notice it's going way above that
2573
05:32:42,000 --> 05:32:51,680
and then we can just change this that we can have temperature
2574
05:32:51,680 --> 05:33:12,720
that and maybe we'll do one of the other ones precipitation prcp
2575
05:33:12,720 --> 05:33:20,159
and we see so average temperature and then precipitation
2576
05:33:22,240 --> 05:33:31,680
there we go pretty cool and we can see and of course then you know
2577
05:33:31,680 --> 05:33:39,360
here snow now what you can see is all right if there's average
2578
05:33:39,360 --> 05:33:47,440
and then precipitation then you'd expect hey maybe there's going
2579
05:33:57,360 --> 05:34:04,720
so there we go snow is in green and you'd think look at that
2580
05:34:04,720 --> 05:34:12,560
and there's precipitation and below average temperatures but no
2581
05:34:12,560 --> 05:34:18,960
average temperatures but no snow or below zero temperatures and
2582
05:34:18,959 --> 05:34:28,079
happened but just there we go here beginning january some snow
2583
05:34:28,080 --> 05:34:37,040
we go that's it so interesting things you can do and you know even
2584
05:34:37,040 --> 05:34:44,560
this on your you know having the colab app on your phone you could
2585
05:34:44,560 --> 05:34:50,080
something you know related to uh you know write write another line
2586
05:34:50,080 --> 05:34:58,320
today's date or yesterday's date and sort you know use that as the
2587
05:34:58,319 --> 05:35:04,720
app and click on click on something run it and you know see the
2588
05:35:04,720 --> 05:35:12,159
wind up till now if that's interesting you could do some other
2589
05:35:12,159 --> 05:35:17,439
things we can do with graphing and you see just getting a little
2590
05:35:17,439 --> 05:35:24,719
python is so good for data science because a lot of people make
2591
05:35:24,720 --> 05:35:31,040
a few lines of code and get the get the data you need and
2592
05:35:31,040 --> 05:35:37,680
powerful like that and you see the the graphing that we end up
2593
05:35:37,680 --> 05:35:46,319
library so pretty good some some cool things you can do with
2594
05:35:46,319 --> 05:35:52,799
theme that you know next we'll look at solving equations and
2595
05:35:52,799 --> 05:35:59,119
which ends up being tricky but we'll show you how to do it okay so
2596
05:35:59,119 --> 05:36:07,360
with it you know set up some you know some you know weather
2597
05:36:08,880 --> 05:36:17,040
okay now we're going to look at how to solve a system of equations
2598
05:36:17,759 --> 05:36:23,759
and you can still picture the graph the idea that that's that's
2599
05:36:23,759 --> 05:36:30,000
equate these are two equations two functions that you could graph
2600
05:36:30,000 --> 05:36:35,840
to get the solution and sometimes for solutions that it might not
2601
05:36:35,840 --> 05:36:40,959
then you know maybe it's you know not in a nice integer solving
2602
05:36:40,959 --> 05:36:47,200
time so we're going to look at how to do this just on paper or on
2603
05:36:47,200 --> 05:36:54,080
code on how to do this and set it up to be able to solve anything
2604
05:36:54,720 --> 05:37:01,760
so if i have these two equations one of the ways to solve this and
2605
05:37:01,759 --> 05:37:10,639
is if we notice if this equals y and this equals y then they can
2606
05:37:10,639 --> 05:37:21,599
ten equals four x so we see that if that equals y and that equals
2607
05:37:21,599 --> 05:37:27,279
three x plus ten equals four x and that's a little bit of the
2608
05:37:27,279 --> 05:37:36,079
so now we can solve these what can i do to solve for x i can
2609
05:37:39,439 --> 05:37:48,239
and then i get ten equals x now once i solve that x is ten well i
2610
05:37:48,240 --> 05:37:56,320
i need my y value and i can plug this in to either equation so i
2611
05:37:56,319 --> 05:38:05,200
to plug it into here so y equals four x then i could take that and
2612
05:38:06,319 --> 05:38:08,560
and that gives me y equals 40
2613
05:38:11,119 --> 05:38:15,599
and then that's how we would get the solution we can set these
2614
05:38:15,599 --> 05:38:24,319
and then solve solve usually for x and then plug that in either
2615
05:38:24,319 --> 05:38:29,520
get our y value now this is very similar to how this is going to
2616
05:38:30,479 --> 05:38:36,479
one of the things that makes uh sim the simpy library and solving
2617
05:38:36,479 --> 05:38:44,000
bit better is this works out nicely when they're equal to y and
2618
05:38:44,000 --> 05:38:52,159
equations that were not equal to y or something like that with the
2619
05:38:52,159 --> 05:38:58,240
and we would do the same thing with this is the idea that i would
2620
05:38:58,240 --> 05:39:09,040
equal to zero so i would end up subtracting y here so i would get
2621
05:39:09,919 --> 05:39:16,799
and i subtract y from both sides equals zero and that's the
2622
05:39:16,799 --> 05:39:24,880
when i solve it with the code and then the same thing here you
2623
05:39:26,639 --> 05:39:33,439
and then with each of them set equal to zero then you will see how
2624
05:39:33,439 --> 05:39:40,159
simpy library but that's that's kind of the method that python
2625
05:39:40,159 --> 05:39:45,439
advantages of this is they could be in whatever form they want
2626
05:39:45,439 --> 05:39:50,399
side of the equal sign just subtract it over and then now you have
2627
05:39:50,400 --> 05:39:55,680
you can solve it so you know and there's many other ways to solve
2628
05:39:55,680 --> 05:40:00,959
that's kind of the couple ways i want to show you you know this
2629
05:40:00,959 --> 05:40:04,719
set these equations equal to each other solve for one variable and
2630
05:40:05,840 --> 05:40:11,119
and then we'll take a look at it now so let's take a look at the
2631
05:40:11,119 --> 05:40:17,680
simplest way to solve a system of equations now this is especially
2632
05:40:18,319 --> 05:40:25,200
so you want to set each equation equal to zero but as far as
2633
05:40:25,200 --> 05:40:31,360
you know it doesn't have to be simplified just as long as it
2634
05:40:31,360 --> 05:40:37,760
use simpy our symbolic math library and i'm just importing
2635
05:40:37,759 --> 05:40:45,039
so that's the asterisk there and we're going to define x and y as
2636
05:40:45,680 --> 05:40:55,760
there we go x y symbols and now here's the equation set equal to
2637
05:40:56,400 --> 05:41:02,240
and the second one here then i just defined it as first and second
2638
05:41:02,240 --> 05:41:13,600
solution so this is the lin solve is the is the formula from simpy
2639
05:41:13,599 --> 05:41:19,759
the extra brackets first comma second so it takes this as
2640
05:41:19,759 --> 05:41:27,919
equations and then the next argument comma x y in an additional
2641
05:41:27,919 --> 05:41:36,000
symbols so linear solve these two equations because after each set
2642
05:41:36,000 --> 05:41:42,880
them equal to each other and use these symbols and when you run
2643
05:41:42,880 --> 05:41:51,120
comes out as a finite set now again the simplest way is there we
2644
05:41:51,119 --> 05:41:58,559
one line that puts it all together you can just change you know
2645
05:41:58,560 --> 05:42:05,680
run it and you know you see your answer it's pretty clear it's a
2646
05:42:05,680 --> 05:42:12,880
three supposing i want it to look a little bit nicer so still
2647
05:42:14,080 --> 05:42:20,240
and these symbols still have the same i'm going to use the same
2648
05:42:20,240 --> 05:42:30,960
now here where i have this solution here that's the same line but
2649
05:42:30,959 --> 05:42:37,759
variable is going to be a finite set but there's things i can do
2650
05:42:37,759 --> 05:42:47,039
another variable x solution here and i'm going to take this
2651
05:42:47,040 --> 05:42:52,959
behind the scenes it's a two-dimensional array so i want the first
2652
05:42:53,840 --> 05:43:01,040
also a two-dimensional array solution dot args zero one so having
2653
05:43:02,240 --> 05:43:09,840
a coordinate pair so there you all print the parentheses x
2654
05:43:09,840 --> 05:43:17,759
closing parentheses and then when i run this there we go it will
2655
05:43:17,759 --> 05:43:27,759
three in parentheses and i can do other things with that now there
2656
05:43:27,759 --> 05:43:34,719
want to see the graph now this gets tricky because we can't graph
2657
05:43:34,720 --> 05:43:43,520
that we would otherwise because going through loops doesn't really
2658
05:43:43,520 --> 05:43:51,200
through numpy doesn't really work with simpy but simpy has its own
2659
05:43:51,200 --> 05:43:56,639
we go it doesn't work with the others but it has its own so from
2660
05:43:56,639 --> 05:44:04,720
import plot and so this is the simpy plot and slightly different
2661
05:44:04,720 --> 05:44:16,960
here var x y here then this one is similar to what we were doing
2662
05:44:17,840 --> 05:44:21,360
that looks pretty similar to what we were just doing same with the
2663
05:44:21,360 --> 05:44:32,000
and so this part i'm still going to go through the same thing you
2664
05:44:32,000 --> 05:44:39,840
solution get the x solution the y solution and print so this is
2665
05:44:39,840 --> 05:44:46,959
what we just did before but what the other things that we can do
2666
05:44:46,959 --> 05:44:55,360
that these are equations set equal to zero now simpy syntax for
2667
05:44:55,360 --> 05:45:02,240
if i want to get it ready to factor so my y value for the first
2668
05:45:02,240 --> 05:45:10,080
so in simpy we're going to define this as an equation first and
2669
05:45:10,080 --> 05:45:16,080
that's that first equation and i'm just spelling it out that it
2670
05:45:16,080 --> 05:45:26,160
need that so now y first is that set equal to zero and then y1 i'm
2671
05:45:27,360 --> 05:45:37,680
which solves that first equation you see y first comma y so i'm
2672
05:45:39,119 --> 05:45:44,559
spell it out that it's set equal to zero and then do my algebra
2673
05:45:44,560 --> 05:45:50,080
and solve for y and then store it as this variable y1 i'm going to
2674
05:45:50,080 --> 05:46:01,120
equation so set it as an equation second the second equation is
2675
05:46:01,119 --> 05:46:07,119
i'm going to solve it y second comma y i'm going to solve it for y
2676
05:46:08,240 --> 05:46:14,000
i can print them because that might be interesting so it's just
2677
05:46:14,000 --> 05:46:23,759
y equals that i will display exactly comma and then here's the
2678
05:46:23,759 --> 05:46:31,679
zero again because you know the index of the array so we have
2679
05:46:31,680 --> 05:46:37,439
but we were talking about graphing this so let's do that next but
2680
05:46:37,439 --> 05:46:46,479
the solution i will display these you know y equals equations and
2681
05:46:48,080 --> 05:46:53,600
i didn't just factor it to see that as y equals though that is
2682
05:46:53,599 --> 05:47:00,159
that but to plot the solution here see now i'm going to just
2683
05:47:00,159 --> 05:47:09,680
as a symbol and then take a look at this i'm going to plot but
2684
05:47:09,680 --> 05:47:21,119
is just plot within simp i plot and what am i plotting this y
2685
05:47:21,119 --> 05:47:31,119
so there we go so when we factored it into y equals that helped us
2686
05:47:31,680 --> 05:47:38,319
but put this into here that this is what i'm plotting these two y
2687
05:47:38,319 --> 05:47:44,799
the x value notice also a little bit different the way we display
2688
05:47:44,799 --> 05:47:50,079
to 10 i could you know make these other variables but that's going
2689
05:47:51,200 --> 05:47:58,959
so then when we run this i see the solution i have it as y equals
2690
05:47:59,599 --> 05:48:06,000
and then i see the graph and we see where the solution is negative
2691
05:48:06,000 --> 05:48:17,599
so we can do this for you know any other ones here there we go
2692
05:48:17,599 --> 05:48:27,279
it negative 2x you know i don't know minus two and maybe this one
2693
05:48:27,279 --> 05:48:36,799
x and i don't know like plus eight change it up a little bit and
2694
05:48:36,799 --> 05:48:46,639
we'll solve it print out the solution factor it show the y equals
2695
05:48:49,840 --> 05:48:56,560
and now we have this new one two six is the solution here are my
2696
05:48:56,560 --> 05:49:05,440
two times x plus two and y equals x plus four so we see these two
2697
05:49:06,000 --> 05:49:10,720
the two times x has a steeper slope so that's got to be this one
2698
05:49:11,759 --> 05:49:16,239
and then x plus four the slope is only one so that's got to be
2699
05:49:16,240 --> 05:49:19,840
and we see that they intersect here at two six
2700
05:49:19,840 --> 05:49:27,840
all right so we see how we can solve and we can solve and graph
2701
05:49:27,840 --> 05:49:34,639
linear equations for equations beyond linear we'll cross that
2702
05:49:34,639 --> 05:49:43,840
to be in the upcoming sections now that we've worked through the
2703
05:49:43,840 --> 05:49:48,959
now that we've worked through the core skills in this unit let's
2704
05:49:48,959 --> 05:49:54,879
and i'm going to work through extra problems using the colab
2705
05:49:54,880 --> 05:50:00,560
apply these resources that you're building and use that use these
2706
05:50:00,560 --> 05:50:06,240
come up in a textbook or in day-to-day life so we're going to go
2707
05:50:06,240 --> 05:50:12,800
here so here again is where we're going to put together all the
2708
05:50:12,799 --> 05:50:19,680
learning into your calculator so that you'll have these as a
2709
05:50:20,319 --> 05:50:26,479
where you should already have proportions set up so the text to
2710
05:50:26,479 --> 05:50:33,599
to enter it in and solve your proportion and remember we made this
2711
05:50:33,599 --> 05:50:40,799
that there we go and we already did this converting decimals to
2712
05:50:40,799 --> 05:50:49,200
code there and that's also section heading solve for x so each
2713
05:50:49,200 --> 05:50:55,360
we're building and then we're going to take like the final product
2714
05:50:55,360 --> 05:51:02,880
one if you just have a an equation you want to solve for x pretty
2715
05:51:02,880 --> 05:51:11,760
there and factoring so we can solve or we could factor you know
2716
05:51:11,759 --> 05:51:17,199
something like that we have we have that and each of these you
2717
05:51:17,200 --> 05:51:24,400
because you just have this the solving solving for x we did put a
2718
05:51:25,279 --> 05:51:29,520
it's going to prompt for the input and then you see that the
2719
05:51:29,520 --> 05:51:37,200
whereas the factoring one it's just this equation that you know
2720
05:51:38,159 --> 05:51:47,439
simpy dot factor okay so that's also a section heading then
2721
05:51:47,439 --> 05:51:54,639
solving for a variable so not just set solve for x but even if
2722
05:51:54,639 --> 05:52:00,319
rewrite it you know like y equals a over b or something like that
2723
05:52:00,319 --> 05:52:09,759
numbers this will do that for you and we defined a lot of our
2724
05:52:09,759 --> 05:52:14,959
it's not going to be an error to put them in there and not use
2725
05:52:14,959 --> 05:52:21,919
what variables you use you can always edit that part and then
2726
05:52:21,919 --> 05:52:28,159
the involving numbers or a bunch of letters and variables you know
2727
05:52:28,159 --> 05:52:36,319
equal sign and then we have this then we're just going to define
2728
05:52:36,319 --> 05:52:42,880
pick what variable you want to solve for set it as an equation
2729
05:52:42,880 --> 05:52:52,720
going to solve and this loop runs through all possibilities for s
2730
05:52:53,279 --> 05:53:02,319
we have that that we can solve for a variable like again it's
2731
05:53:02,319 --> 05:53:07,200
therefore in the table of contents so we're going to add the other
2732
05:53:07,200 --> 05:53:14,799
intercept from two points because this in itself is a very common
2733
05:53:14,799 --> 05:53:28,079
going to define the two points there we go x you know x and y and
2734
05:53:28,720 --> 05:53:36,000
solve for b we're going to get m and b and having those two we're
2735
05:53:36,000 --> 05:53:41,919
and then we're going to use that for the graph and you can keep
2736
05:53:41,919 --> 05:53:52,000
know you could always change this x min negative 10 and we could
2737
05:53:52,000 --> 05:53:59,599
could always change them to 10 in every direction if you wanted to
2738
05:53:59,599 --> 05:54:07,759
these you know for the graph and the setup the details could
2739
05:54:07,759 --> 05:54:14,719
these and you see for things that we might use we might want to
2740
05:54:14,720 --> 05:54:19,760
there so you don't have to really think about you know the exact
2741
05:54:19,759 --> 05:54:25,679
this you remember it but it's just there and it's commented out so
2742
05:54:25,680 --> 05:54:31,279
and then that way here we just plot the function as a red line so
2743
05:54:31,279 --> 05:54:36,559
of these you have a lot of things that are there by default that
2744
05:54:36,560 --> 05:54:43,680
you could solve whatever you wanted to solve and graph it so we
2745
05:54:43,680 --> 05:54:50,639
section heading then we can double click and remember it's this
2746
05:54:50,639 --> 05:54:56,959
because it's in the text not in the code now that became a section
2747
05:54:56,959 --> 05:55:04,159
of contents so we have that now the section heading goes all the
2748
05:55:04,159 --> 05:55:11,360
bottom so that one we can minimize now this one if we minimize it
2749
05:55:11,360 --> 05:55:22,240
document here so besides that i might just want to graph something
2750
05:55:22,240 --> 05:55:28,640
this the other code as you're building it remember the slope
2751
05:55:28,639 --> 05:55:35,439
then other ways to customize the graph came from some of the extra
2752
05:55:35,439 --> 05:55:42,079
in week four where we have you know again all the different things
2753
05:55:42,080 --> 05:55:53,360
labels as well as setting the tick marks and this one you know we
2754
05:55:53,360 --> 05:56:03,440
here you know and added a remember we customized it and added this
2755
05:56:03,439 --> 05:56:10,319
this for yours we're going to put all these as well as the zoom
2756
05:56:10,959 --> 05:56:19,200
so this function then does all the graphing and i'm going to skip
2757
05:56:20,159 --> 05:56:27,840
the slider remember that interactive plot we're going to run this
2758
05:56:27,840 --> 05:56:33,520
we're going to have is to zoom and that's going to be our
2759
05:56:33,520 --> 05:56:42,240
hundred that's good and then taking that so whatever that
2760
05:56:43,599 --> 05:56:49,439
what we have for our x min and x max and then once we have those
2761
05:56:49,439 --> 05:56:58,959
for our np dot linspace to graph and there we go and i just put
2762
05:56:58,959 --> 05:57:03,840
two lines as by default you know maybe you want to have two lines
2763
05:57:03,840 --> 05:57:09,920
see where they where they intersect so this graphs two different
2764
05:57:09,919 --> 05:57:16,319
a linear equation as long as you're using python syntax whatever
2765
05:57:16,319 --> 05:57:22,239
i commented this out but again you could have it if you want to
2766
05:57:22,240 --> 05:57:29,840
and i just happen to have this one fill between same x values so
2767
05:57:29,840 --> 05:57:38,240
y max so that would shade above and it would make it green and the
2768
05:57:38,240 --> 05:57:45,280
values from y2 down to y min and make it blue so that would shade
2769
05:57:45,279 --> 05:57:52,239
these here in case you need them we're making these default
2770
05:57:52,240 --> 05:58:01,280
okay i do want to shade above or below uncomment it and then we
2771
05:58:01,279 --> 05:58:10,639
can change now for this one i kept this the tick marks in there
2772
05:58:10,639 --> 05:58:17,599
lot of this is based on the zoom so then how many ticks do i want
2773
05:58:17,599 --> 05:58:25,519
difference the how you know from x max to x min divided by 20 i
2774
05:58:25,520 --> 05:58:32,560
to be a good number to display nicely so we're going to get that
2775
05:58:33,279 --> 05:58:40,000
and then cast it as an integer so the number of ticks has to be an
2776
05:58:40,000 --> 05:58:46,959
then that way no matter what the zoom is you'll see that we can
2777
05:58:46,959 --> 05:58:53,520
grid so this will give us a few things that we can graph you know
2778
05:58:53,520 --> 05:58:59,840
given these equations that we have in here a lot of times i like
2779
05:58:59,840 --> 05:59:04,000
than just like make that line blank so if you run the code it
2780
05:59:04,000 --> 05:59:11,040
something so here we have this graph and we see the default zoom
2781
05:59:11,040 --> 05:59:19,680
but i could move this back down and you see everything adjusts the
2782
05:59:21,919 --> 05:59:27,599
the graph zooms in and then you can see you know or we could zoom
2783
05:59:34,400 --> 05:59:39,040
so yeah pretty good i like kind of for this particular graph i
2784
05:59:39,680 --> 05:59:45,599
and then you can see you know about where they where they cross so
2785
05:59:45,599 --> 05:59:54,399
want to graph something and there there we have that and there we
2786
05:59:54,400 --> 05:59:59,520
and you could have the whole every all the directions don't have
2787
05:59:59,520 --> 06:00:08,639
could have that and you could put an html break right after that
2788
06:00:09,759 --> 06:00:12,639
words underneath that would not become a part of the heading
2789
06:00:14,880 --> 06:00:17,600
but for this we can just put the heading here
2790
06:00:17,599 --> 06:00:22,399
here we go i remember there's really no entering we just put it on
2791
06:00:22,400 --> 06:00:29,920
somewhere else and now that's also a part of the table of contents
2792
06:00:32,240 --> 06:00:40,240
solve and graph a system and this is nice it brings it all
2793
06:00:40,240 --> 06:00:43,840
you can put in as long as you have python syntax whatever you have
2794
06:00:43,840 --> 06:00:51,680
and second equation and i even have an extra one here just to be
2795
06:00:51,680 --> 06:00:59,520
this will even work if you have a square root just to have
2796
06:00:59,520 --> 06:01:09,200
the linsolve before to solve uh using simpy the linsolve to solve
2797
06:01:09,200 --> 06:01:14,880
is actually another one non-linsolve i like this one because it
2798
06:01:14,880 --> 06:01:20,639
in there it can be linear or non-linear it works out so just
2799
06:01:20,639 --> 06:01:26,880
mean that you have to have you know something different if one of
2800
06:01:28,080 --> 06:01:32,000
but there we go the comments just so you know here's where you
2801
06:01:32,000 --> 06:01:39,680
and then you already have the code that you would have copied this
2802
06:01:41,759 --> 06:01:51,439
eight uh yeah from from uh the recent week to solve and graph you
2803
06:01:52,319 --> 06:01:57,759
tinker with them a little bit you know as we went through and
2804
06:01:57,759 --> 06:02:04,399
uh blocks of code you know take the last one that brings it all
2805
06:02:05,599 --> 06:02:10,799
over here you know that's what you're doing you're building your
2806
06:02:10,799 --> 06:02:16,000
the system of equations and then this will work solve and graph
2807
06:02:16,880 --> 06:02:18,720
i just want to show you some of these
2808
06:02:18,720 --> 06:02:28,080
so even if it's non-linear and you see it'll give you the solution
2809
06:02:28,080 --> 06:02:37,360
solutions notice because we had the uh the loop the four loop here
2810
06:02:37,360 --> 06:02:45,119
solutions so it'll have the two solutions then also show the two y
2811
06:02:45,119 --> 06:02:52,479
graph them so that's pretty complete that's a good good one you
2812
06:02:52,479 --> 06:03:01,599
thing in your toolbox double click and let's make this one a
2813
06:03:03,040 --> 06:03:10,240
and i've added one more thing here and we could still make this a
2814
06:03:10,240 --> 06:03:16,400
notice this code isn't complete but i put one thing in here they
2815
06:03:16,400 --> 06:03:22,159
so you certainly you would recognize that that's import so that
2816
06:03:23,119 --> 06:03:29,439
you see this you would also it would be something you already
2817
06:03:30,240 --> 06:03:35,840
but notice you have this dot save fig and you're going to give it
2818
06:03:35,840 --> 06:03:41,599
notice you have this dot save fig and you're going to give it a
2819
06:03:41,599 --> 06:03:50,399
to use notice that'll come before the plt dot show and that
2820
06:03:50,400 --> 06:03:56,319
i've tried this if you put this after it actually will save
2821
06:03:56,319 --> 06:04:02,079
and what's interesting is this download can come after so that's
2822
06:04:02,080 --> 06:04:07,920
that'd be fine too but it can come after because it doesn't
2823
06:04:08,880 --> 06:04:14,319
and this is a way to download this to your computer or your phone
2824
06:04:14,319 --> 06:04:20,880
because sometimes you might have have something that you wanted to
2825
06:04:20,880 --> 06:04:29,920
this and you would put if you wanted to up here you import that
2826
06:04:29,919 --> 06:04:38,559
you know you would just do save fig and files download so there we
2827
06:04:38,560 --> 06:04:46,000
have all of this and one of the things you can do is in the view
2828
06:04:47,119 --> 06:04:52,159
all right and now you have all these in your table of contents and
2829
06:04:52,159 --> 06:04:58,319
if you need to there you go you have all the sections collapsed
2830
06:04:58,319 --> 06:05:10,079
for x do i need to solve for variable you know i i like i like
2831
06:05:12,000 --> 06:05:15,439
and down save graph and download it
2832
06:05:20,639 --> 06:05:22,799
there you go because that's what it does is it downloads an image
2833
06:05:22,799 --> 06:05:31,279
so already we have so much of the core algebra that you're able to
2834
06:05:31,279 --> 06:05:39,919
the code for it and now you have this at the ready so one of the
2835
06:05:39,919 --> 06:05:48,079
to quadratics and more complicated graphs we kind of hinted at
2836
06:05:48,080 --> 06:05:53,680
if you haven't seen a lot of these and you say oh wow okay now
2837
06:05:53,680 --> 06:05:59,680
getting interesting so we'll get into quadratics parabolas you
2838
06:05:59,680 --> 06:06:09,360
curve to them and things beyond that so we'll add more to this all
2839
06:06:09,360 --> 06:06:19,119
to being able being able to solve a lot of algebra problems in
2840
06:06:21,439 --> 06:06:29,680
so when working with word problems not just here's a math formula
2841
06:06:29,680 --> 06:06:34,479
problems or some people call them story problems that's when a lot
2842
06:06:34,479 --> 06:06:39,840
translating that into a math equation that we can solve so what i
2843
06:06:39,840 --> 06:06:48,000
keywords that you can find in the word problems in the sentences
2844
06:06:48,000 --> 06:06:55,439
to use and this is not all of them but this is a lot of the main
2845
06:06:55,439 --> 06:07:00,239
with this these are the things you're looking for and then after
2846
06:07:00,240 --> 06:07:05,520
we'll go through a bunch of examples in the code and how to use
2847
06:07:05,520 --> 06:07:13,600
into math equations but let's take a look at these keywords so how
2848
06:07:13,599 --> 06:07:19,359
some of the words are going to be if i just actually see plus some
2849
06:07:20,400 --> 06:07:29,120
more so if i have something and then i got more how much do i have
2850
06:07:29,119 --> 06:07:37,200
money i had increased it might even just be and you know i have
2851
06:07:37,200 --> 06:07:43,280
cards how many cards do i have received because a lot of times
2852
06:07:43,840 --> 06:07:50,159
up something goes up and a lot of times calculating elevation up
2853
06:07:50,799 --> 06:07:58,719
it might even just come up and say added to sum also and sum means
2854
06:07:58,720 --> 06:08:04,319
might see some of we might see these you know the sum of three and
2855
06:08:04,319 --> 06:08:10,880
plus four so these are some of the ones if you're looking and you
2856
06:08:10,880 --> 06:08:19,360
adding okay and a lot of this it's not so exact that you could
2857
06:08:19,360 --> 06:08:24,000
find one of these keywords and then automatically translate it to
2858
06:08:24,000 --> 06:08:31,680
use a little bit of your human intuition there but it it's very
2859
06:08:31,680 --> 06:08:35,520
numbers what which one of these words are around there and that's
2860
06:08:35,520 --> 06:08:41,200
of the path operation so let's take a look at subtraction so
2861
06:08:41,200 --> 06:08:47,760
minus less anytime i have less than i'm subtracting or it
2862
06:08:47,759 --> 06:08:54,879
decreased so i subtract gave because a lot of times things if i
2863
06:08:54,880 --> 06:08:59,040
it becomes added to what i have or if i gave then it becomes
2864
06:09:00,400 --> 06:09:07,120
down and that also goes again with looking at elevation it might
2865
06:09:07,119 --> 06:09:12,639
subtracted and then anytime it says the word difference or i know
2866
06:09:12,639 --> 06:09:19,840
between two numbers that's subtraction you know we just find the
2867
06:09:19,840 --> 06:09:24,240
be a negative difference might be a positive might be absolute
2868
06:09:24,240 --> 06:09:30,720
or if i want to find the difference then i'm going to subtract all
2869
06:09:32,159 --> 06:09:37,599
so how do i know that i'm multiplying obviously things are
2870
06:09:37,599 --> 06:09:43,039
we want to look for that general trend things are increasing and
2871
06:09:43,040 --> 06:09:47,200
since things are increasing you know it's multiplying or adding so
2872
06:09:47,200 --> 06:09:54,000
it would be multiplying by just the word by because if i'm
2873
06:09:54,000 --> 06:10:00,000
three by five and then i've won't you know also then just seeing
2874
06:10:00,000 --> 06:10:09,200
means the area would be three times five of so just the word of is
2875
06:10:09,200 --> 06:10:14,240
of something you have the percent and then you multiply times
2876
06:10:15,840 --> 06:10:23,439
factor because two things you multiply together are factors times
2877
06:10:23,439 --> 06:10:29,599
you know it might just come out and say times and even if it
2878
06:10:29,599 --> 06:10:34,319
dimensions and say what's the area and anytime i'm calculating the
2879
06:10:35,680 --> 06:10:42,080
so there we go again not this is not all the numbers that lead to
2880
06:10:42,080 --> 06:10:50,400
of the main one all right so divide out of so notice of would be
2881
06:10:50,400 --> 06:10:58,240
so you know four out of five that would be a fraction four divided
2882
06:10:59,200 --> 06:11:05,360
per same actually per pretty much means out of but that's another
2883
06:11:06,000 --> 06:11:12,959
of miles per hour i would divide miles divided by hours or
2884
06:11:12,959 --> 06:11:21,360
hours quotient we don't see this word that often but that quotient
2885
06:11:21,360 --> 06:11:28,240
means that i'm dividing and actually that's the answer when i
2886
06:11:28,240 --> 06:11:34,000
you know you know kilometers per hour or something like that but
2887
06:11:34,000 --> 06:11:39,680
be some sort of dividing something divided by something else
2888
06:11:39,680 --> 06:11:45,040
related to time but it's not always so anytime i have a rate i
2889
06:11:45,040 --> 06:11:50,720
and again it might just come out and say divided by so you know
2890
06:11:50,720 --> 06:11:58,479
put the word each here because that actually could go for multiply
2891
06:11:58,479 --> 06:12:06,079
of it you know if i have if i have 20 students in the class and i
2892
06:12:06,080 --> 06:12:12,160
each how many pencils do i need so then that's multiplying because
2893
06:12:12,880 --> 06:12:20,319
but if i have if i know how many pencils i have and then you know
2894
06:12:20,319 --> 06:12:27,040
and i you know how many can i how many can each of them get you
2895
06:12:27,040 --> 06:12:33,600
20 and then i have 20 students how many can each of them get i'm
2896
06:12:33,599 --> 06:12:39,439
we have to get the sense of it and dividing like subtraction if i
2897
06:12:39,439 --> 06:12:45,520
to be a smaller number then i know it's dividing or subtracting
2898
06:12:45,520 --> 06:12:50,400
further you know what's the sense of it am i is it something you
2899
06:12:50,400 --> 06:12:57,280
it out among different things or is it just a subtraction okay so
2900
06:12:57,279 --> 06:13:07,119
things and the one that carries over a lot is or some version of
2901
06:13:07,119 --> 06:13:13,039
equals so that's where we get the equal sign coming into our
2902
06:13:13,040 --> 06:13:20,319
then i can translate you know this is was will be something like
2903
06:13:20,319 --> 06:13:25,919
so looking at these keywords you know we get the numbers from the
2904
06:13:25,919 --> 06:13:33,279
these keywords and we can put together an equation and so i wanted
2905
06:13:33,279 --> 06:13:37,119
in the code what we're going to do is we're going to look at a lot
2906
06:13:38,720 --> 06:13:43,280
and translating them into math equations and then of course
2907
06:13:43,279 --> 06:13:46,719
we want to be able to translate this you know you're not always in
2908
06:13:46,720 --> 06:13:51,120
the math problem it's going to be you know some words and we have
2909
06:13:51,119 --> 06:13:56,639
problem so let's take a look at how to do this let's let's apply
2910
06:13:56,639 --> 06:14:02,559
into math problems all right so let's take a look at the code so
2911
06:14:02,560 --> 06:14:07,840
practice some of the math we've been talking about with the linear
2912
06:14:07,840 --> 06:14:14,880
especially and some of the python developing equations finding
2913
06:14:14,880 --> 06:14:22,720
let's put all this together and use that to solve some problems
2914
06:14:22,720 --> 06:14:29,920
can see that y equals mx plus b pattern for a linear equation show
2915
06:14:29,919 --> 06:14:35,119
ways you know sometimes we just change out the letters a little
2916
06:14:35,119 --> 06:14:43,279
that pattern so if we take a look at number one and this all comes
2917
06:14:43,279 --> 06:14:51,520
i have listed as textbook two algebra and trig so you know there
2918
06:14:52,639 --> 06:14:56,399
find these because we're just going to pick a few of these and i
2919
06:14:56,959 --> 06:15:03,119
you know what we can do with these so if we take a look terry is
2920
06:15:05,279 --> 06:15:09,680
terry's elevation e of t that's how i'd write that that's the
2921
06:15:09,680 --> 06:15:17,360
um instead of just y equals we'll call it e of t elevation as a
2922
06:15:18,159 --> 06:15:26,639
in feet after t seconds is given by this so e of t equals 3000
2923
06:15:26,639 --> 06:15:34,479
instead of x we're using t because it's time and we have 3000
2924
06:15:34,479 --> 06:15:44,799
e of t that's the function and so we see the slow the intercept
2925
06:15:44,799 --> 06:15:53,919
she terry begins at 3000 feet up and then goes down the slope at
2926
06:15:53,919 --> 06:16:02,239
that that is the slope the slope of our equation on the slope and
2927
06:16:02,240 --> 06:16:09,600
is going down there we go so we can see the slope we can see where
2928
06:16:10,560 --> 06:16:17,520
um and there we go just uh finding that slope we just look at it
2929
06:16:18,080 --> 06:16:24,480
now we have jessica walking home from a friend's house after two
2930
06:16:25,200 --> 06:16:30,880
12 minutes after leaving she's 0.9 miles from home what's her rate
2931
06:16:30,880 --> 06:16:37,600
miles per hour well right here we have distances in miles but the
2932
06:16:38,959 --> 06:16:45,439
so if the question asks for miles per hour we definitely see also
2933
06:16:45,439 --> 06:16:51,680
have a time and a distance and then another time and distance so
2934
06:16:51,680 --> 06:17:00,479
distance and having these two points we can go to our calculator
2935
06:17:00,479 --> 06:17:06,560
something that you've already created you know remember we might
2936
06:17:06,560 --> 06:17:13,440
calculator and then hopefully you know then you would have created
2937
06:17:13,439 --> 06:17:18,559
for the different things that we want to be able to do and we can
2938
06:17:18,560 --> 06:17:24,159
equation from two points because even though the that question
2939
06:17:24,159 --> 06:17:29,119
and everything we're going to do more but the first thing it's
2940
06:17:29,119 --> 06:17:34,799
for us and hopefully you know that's it you know we have these
2941
06:17:34,799 --> 06:17:45,279
make use of it so you would have had all this and then we would
2942
06:17:45,279 --> 06:17:50,959
is 1.4 but that x value it's two minutes and we have to remember
2943
06:17:51,759 --> 06:17:58,719
it's two minutes and there's 60 minutes in an hour so it's two out
2944
06:17:58,720 --> 06:18:03,520
this if you want but you don't even have to python will take care
2945
06:18:03,520 --> 06:18:13,760
steps and the y value 1.4 miles so the second x value 12 minutes
2946
06:18:13,759 --> 06:18:20,479
an hour so it's 12 out of 60 again that reduces but you don't you
2947
06:18:20,479 --> 06:18:29,520
0.9 so having all this you can just put in these four values here
2948
06:18:29,520 --> 06:18:35,119
we'll print that out so you see the equation and then we'll also
2949
06:18:35,119 --> 06:18:39,119
what the question is but this will give you an idea of some things
2950
06:18:39,119 --> 06:18:46,399
this and all we needed to do is recognize what these values were
2951
06:18:46,400 --> 06:18:57,920
run it all right so this i absolutely would take this slope as
2952
06:18:57,919 --> 06:19:06,479
python calculates things it might be this 0.9999 it's three and if
2953
06:19:06,479 --> 06:19:13,840
you know you could always go back and put a round function in in
2954
06:19:13,840 --> 06:19:21,119
with this you could always round it to two decimal place to one
2955
06:19:22,479 --> 06:19:30,239
but either way we see that remember our first point was two
2956
06:19:30,240 --> 06:19:36,080
zero at two minutes she was 1.4 miles from home but at time zero
2957
06:19:36,080 --> 06:19:45,760
1.49 or 1.5 it might round so we get our values here and you know
2958
06:19:45,759 --> 06:19:52,559
function in there but i'm not worried about that right now and
2959
06:19:52,560 --> 06:19:58,240
but it's still ran occasionally that happens just the the way it
2960
06:19:58,240 --> 06:20:05,680
some things you know we get a warning you know some value maybe
2961
06:20:05,680 --> 06:20:12,639
what we were working on gives us this warning but it's still ran
2962
06:20:12,639 --> 06:20:21,520
and then we also have this graphed now if we have you know the x
2963
06:20:21,520 --> 06:20:28,000
so this is her time from home
2964
06:20:31,200 --> 06:20:41,440
so this y value notice it seems like this graph is completely
2965
06:20:41,439 --> 06:20:47,279
only goes down to net 9.6 we want it down to zero and then we have
2966
06:20:47,279 --> 06:20:54,959
know what's that all about so remember mathematically a lot you
2967
06:20:55,520 --> 06:21:02,639
these values exist you know we make this equation here negative 3x
2968
06:21:03,840 --> 06:21:09,920
but that whole equation exists so we can actually change the graph
2969
06:21:09,919 --> 06:21:16,879
you know later on in this document is you know we can graph you
2970
06:21:17,599 --> 06:21:24,079
but we can just change the graph here and our x minimum if x is
2971
06:21:24,080 --> 06:21:30,400
because negative time you know she was still at her friend's house
2972
06:21:30,400 --> 06:21:40,080
the walking and the x maximum i mean we can really zoom in now
2973
06:21:40,080 --> 06:21:46,000
going three miles an hour and she only had half a mile to go like
2974
06:21:46,000 --> 06:21:53,439
small i don't know i'll maybe i'll just reduce it to five for this
2975
06:21:53,439 --> 06:22:05,919
um is zero and the y maximum i don't even need that to be 10 i can
2976
06:22:05,919 --> 06:22:12,559
it five but we don't even need to that much we can really zoom in
2977
06:22:12,560 --> 06:22:24,400
short distance all right so now when we have this now we have
2978
06:22:24,400 --> 06:22:32,560
you know this is the only part we needed so we could look at this
2979
06:22:32,560 --> 06:22:39,120
a half miles away and so therefore you know she's walking about
2980
06:22:39,119 --> 06:22:48,079
about a half hour to get home and there we go we see you know the
2981
06:22:48,639 --> 06:22:55,360
whole equation we see the graph and then we can graph the the trip
2982
06:22:55,360 --> 06:23:02,639
know change these you know if you really needed to explain this
2983
06:23:02,639 --> 06:23:09,279
always put you know x values you could change that to time y value
2984
06:23:10,720 --> 06:23:15,360
there we go so we have these calculators that you know we're
2985
06:23:15,360 --> 06:23:23,520
about it here a lot now but if you had this at the ready you might
2986
06:23:23,520 --> 06:23:30,400
just you know see this oh i see my two values plug them in click
2987
06:23:30,400 --> 06:23:38,640
you know move on in a few seconds here so some things we can do
2988
06:23:38,639 --> 06:23:43,520
similar and maybe we'll do number three you know a lot quicker a
2989
06:23:43,520 --> 06:23:52,560
marina sailing directly at it at 10 miles per hour so now we
2990
06:23:52,560 --> 06:24:00,080
because it's a hundred miles away so that's where we begin at 10
2991
06:24:00,080 --> 06:24:10,480
the distance from the marina then it's a negative 10 100 minus 10
2992
06:24:10,479 --> 06:24:17,040
that's the equation 100 minus 10 x and we could always go to
2993
06:24:17,040 --> 06:24:23,280
and see you know just the trend how long does how long will it
2994
06:24:23,279 --> 06:24:29,840
marina there you go 10 miles an hour you might even be able to do
2995
06:24:30,639 --> 06:24:35,520
10 hours to get there and that's the thing we have the setup for
2996
06:24:35,520 --> 06:24:43,439
difficult but sometimes you can just calculate it yourself all
2997
06:24:43,439 --> 06:24:50,559
these and remember a linear function we'll get into the other
2998
06:24:50,560 --> 06:24:58,880
beyond that but a linear function has no exponents so there we go
2999
06:24:58,880 --> 06:25:06,319
linear seven is linear eight is not because we have x squared nine
3000
06:25:06,319 --> 06:25:13,279
squared nine is linear ten is not we have x squared eleven we have
3001
06:25:14,720 --> 06:25:22,880
not even a function like the ones we've been doing so that's
3002
06:25:22,880 --> 06:25:32,240
function like the ones we've been doing and certainly not linear
3003
06:25:32,240 --> 06:25:38,960
denominator then that would not be linear but with just a five in
3004
06:25:40,240 --> 06:25:46,080
so there we go and increasing or decreasing we would just look at
3005
06:25:46,080 --> 06:25:50,640
positive it's increasing if the slope is negative it's decreasing
3006
06:25:50,639 --> 06:25:56,959
coefficient so slopes four it's increasing 15 slope is five it's
3007
06:25:56,959 --> 06:26:04,079
and 16 the slope is negative two so it's decreasing 17 it's
3008
06:26:04,080 --> 06:26:12,400
that and just like we were doing with these other problems you
3009
06:26:12,400 --> 06:26:20,080
could just plug these in two four four ten there you go run it and
3010
06:26:20,080 --> 06:26:27,440
equation and see the graph so a lot of these you know once you
3011
06:26:27,439 --> 06:26:36,159
becomes a lot easier there you go same thing a line if we have two
3012
06:26:36,159 --> 06:26:46,479
in there all right now let's take a look at 37 so these two lines
3013
06:26:46,479 --> 06:26:51,439
of equations are they parallel perpendicular or neither well one
3014
06:26:51,439 --> 06:26:59,680
we can look at one of our other notebook sections and we can graph
3015
06:26:59,680 --> 06:27:07,760
a look at this 4x minus 7y equals 10 so let's take a look at this
3016
06:27:07,759 --> 06:27:11,599
how about this graph lines and zoom in or out remember you would
3017
06:27:11,599 --> 06:27:25,680
too and we defined our function so that we can zoom in or out and
3018
06:27:26,799 --> 06:27:34,159
i could just graph this now also so one of the things we can do to
3019
06:27:35,439 --> 06:27:40,959
if you wanted to is put it and this would be something that you
3020
06:27:40,959 --> 06:27:49,040
of these in the y equals version because they're not in y equals
3021
06:27:49,040 --> 06:27:56,880
to graph you see it's it's going to be y equals and they are going
3022
06:27:58,560 --> 06:28:09,040
well let's go to another one solve and graph a system because this
3023
06:28:09,040 --> 06:28:14,880
equal to y in fact we just make it equal to zero so i actually
3024
06:28:15,599 --> 06:28:22,239
four four times x minus seven times y and the only thing we need
3025
06:28:22,240 --> 06:28:29,680
that equals ten subtract ten from both sides you see much quicker
3026
06:28:29,680 --> 06:28:37,520
second one seven x plus four y equals one just subtract one from
3027
06:28:37,520 --> 06:28:45,760
have here so it underlines these but the moments we run it'll be
3028
06:28:45,759 --> 06:28:49,919
well because as long as you have to set equal to zero just
3029
06:28:49,919 --> 06:28:56,239
over and remember you would have already made this hopefully and
3030
06:28:56,240 --> 06:29:07,440
your second set equal to zero and remember we're solve then we
3031
06:29:07,439 --> 06:29:13,919
solution and then we're going to also convert it to y equals here
3032
06:29:13,919 --> 06:29:23,039
and then graph it print the y equals version
3033
06:29:27,919 --> 06:29:35,279
and when we run it we see we have the solution and it's not even
3034
06:29:35,279 --> 06:29:40,479
than the question asked but if we already had the code you know we
3035
06:29:40,479 --> 06:29:47,200
and yes these are two very weird fractions that you know it would
3036
06:29:47,200 --> 06:29:56,400
were calculating this by hand we get the solution and so we also
3037
06:29:56,400 --> 06:30:06,640
or perpendicular and we see where they intersect at this value
3038
06:30:06,639 --> 06:30:14,559
almost negative one little bit off and then a fraction there and
3039
06:30:17,040 --> 06:30:24,240
four times x over seven minus ten over seven so we see this one
3040
06:30:24,240 --> 06:30:33,840
and this one has a slope of negative seven over four oh then they
3041
06:30:33,840 --> 06:30:45,920
what this graph shows so let's try to change this because the
3042
06:30:45,919 --> 06:30:52,239
even though we're multiplying by x that coefficient is four over
3043
06:30:52,240 --> 06:30:58,000
seven over four and that's what makes them perpendicular the
3044
06:30:58,000 --> 06:31:04,799
seven negative seven over four that if you multiplied them
3045
06:31:04,799 --> 06:31:10,639
change the scale on this we can probably it'll probably look more
3046
06:31:15,040 --> 06:31:23,600
so this just naturally scales it this way all right so we have but
3047
06:31:23,599 --> 06:31:27,599
in this same window the y value goes up to 15
3048
06:31:31,520 --> 06:31:37,840
so the you know it perpendicular this intersection would be at a
3049
06:31:38,720 --> 06:31:44,639
and the you know we just can't see that right angle because of the
3050
06:31:44,639 --> 06:31:56,399
all right so that work i would work for any of these now you know
3051
06:31:56,400 --> 06:32:04,240
just add y to both sides you know subtract 12 on the first one and
3052
06:32:04,240 --> 06:32:11,840
and we can use that same thing same with 39 maybe we'll do another
3053
06:32:19,919 --> 06:32:27,359
yeah if we have this let's just do yeah we'll do one more here
3054
06:32:27,919 --> 06:32:37,359
so if we go back to this then i'll make the first equation then
3055
06:32:37,360 --> 06:32:46,720
y plus x minus 12 because that i would have to equal zero three
3056
06:32:46,720 --> 06:32:52,479
have to put the three times y whereas algebra you won't see that
3057
06:32:53,040 --> 06:33:00,799
so three three y plus x minus 12 equals zero and then on the
3058
06:33:00,799 --> 06:33:05,840
y so on the second equation we'll have eight x
3059
06:33:09,279 --> 06:33:20,239
eight x eight times x plus one plus y and see i don't even for
3060
06:33:20,240 --> 06:33:27,200
you know for other ones you don't have to worry about factoring it
3061
06:33:27,200 --> 06:33:35,119
zero we will get the solution and then we're going to show the y
3062
06:33:36,319 --> 06:33:45,759
so yep these do have a solution where a point where they intersect
3063
06:33:45,759 --> 06:33:53,119
perpendicular because the slope is negative one third you know one
3064
06:33:53,119 --> 06:34:00,799
slope is negative eight so a steep slope at negative eight and
3065
06:34:00,799 --> 06:34:10,239
not as steep so they will meet at this point there we go so pretty
3066
06:34:10,240 --> 06:34:15,120
system of equations solving it factoring it graphing it remember
3067
06:34:15,119 --> 06:34:22,159
you don't build these calculators for yourself then you have it
3068
06:34:23,520 --> 06:34:31,680
some other things and so we see you know the similar things lines
3069
06:34:31,680 --> 06:34:41,920
in any of these you could build for yourself you know a notebook
3070
06:34:41,919 --> 06:34:50,639
do this for two for two point uh two lines or you could actually
3071
06:34:51,279 --> 06:34:57,919
and you could use the slope intercept equation for the one line
3072
06:34:59,599 --> 06:35:04,319
later and then you could use the slope intercept equation again
3073
06:35:04,319 --> 06:35:10,239
it in so that's what we have here like this one you know you have
3074
06:35:10,240 --> 06:35:22,560
always could then take it and you know copy that and write it in
3075
06:35:22,560 --> 06:35:27,760
and do the other one copy it as line two so that you know that
3076
06:35:27,759 --> 06:35:37,199
do if you wanted to you know take take something like that and
3077
06:35:37,200 --> 06:35:43,680
one but nonetheless you know right now as i have it it was it was
3078
06:35:43,680 --> 06:35:47,040
get the equation and you could if you wanted to copy it into the
3079
06:35:47,680 --> 06:35:56,400
so all these yep same thing two points you get the equation two
3080
06:35:57,200 --> 06:36:03,440
and there we go just looking at that equation you know parallel
3081
06:36:03,439 --> 06:36:07,919
perpendicular then you could multiply the slopes together to get
3082
06:36:08,959 --> 06:36:14,879
and neither is anything else as long as they have different slopes
3083
06:36:14,880 --> 06:36:20,080
things you can calculate and i'll leave this to you if you want to
3084
06:36:20,080 --> 06:36:27,920
practice some of these see some of these you don't have to have
3085
06:36:27,919 --> 06:36:34,559
or you don't have to have the the note jupiter notebook or co-lab
3086
06:36:34,560 --> 06:36:42,000
pattern that slope intercept equation here what's the y-intercept
3087
06:36:42,560 --> 06:36:48,800
for this particular one you can actually count you know oh wow
3088
06:36:48,799 --> 06:36:54,959
five over four so the slope would be negative five over four so it
3089
06:36:54,959 --> 06:37:03,919
y equals negative five over four x plus five or if you wanted to
3090
06:37:03,919 --> 06:37:09,679
and plug you know go back to the notebook plug them in and see it
3091
06:37:09,680 --> 06:37:17,040
see that that'll work for any of these you know having this you
3092
06:37:17,040 --> 06:37:25,280
so b is one and then from that to the next nice point it looks
3093
06:37:25,279 --> 06:37:31,279
three there you go there's your slope so you can you know work on
3094
06:37:34,000 --> 06:37:37,040
so some of these again any of these you want to see a graph
3095
06:37:38,799 --> 06:37:42,959
we could just plug any of these into that other notebook section
3096
06:37:42,959 --> 06:37:46,479
the graph all right sketch a line
3097
06:37:48,560 --> 06:37:55,360
good and again you can practice all these if you want the tables
3098
06:37:56,959 --> 06:38:01,840
so really just remember x and then whatever you want to call it g
3099
06:38:01,840 --> 06:38:08,400
and so if i want the equation then what we want is we can just
3100
06:38:16,159 --> 06:38:23,439
so that's you know x is zero y is five and the next one x is five
3101
06:38:25,200 --> 06:38:31,840
and we can get that equation but then also if you wanted to you
3102
06:38:31,840 --> 06:38:40,000
and see if it's the same slope so that's how we would determine if
3103
06:38:40,000 --> 06:38:47,759
always just plot any of these points and and see what it comes out
3104
06:38:47,759 --> 06:38:53,679
just plot these points as their own array and see if it looks like
3105
06:38:53,680 --> 06:39:05,599
another interesting way to do it and there we go so so yeah let me
3106
06:39:05,599 --> 06:39:17,519
that on on one of these and so if the x values are 0 5 10 and 15
3107
06:39:17,520 --> 06:39:25,680
in one of these where you're going to graph so if we have
3108
06:39:28,880 --> 06:39:33,040
yeah here and we'll even keep the zoom in so one of these where
3109
06:39:33,040 --> 06:39:47,760
we have all this for the zoom but what you can do is you could
3110
06:39:47,759 --> 06:40:03,199
all right so we could get x equals and make it you know 0 comma 5
3111
06:40:04,479 --> 06:40:12,000
and we can just make that the array 10 15 and then
3112
06:40:12,000 --> 06:40:27,040
and then you could now we could just comment out all of this
3113
06:40:27,040 --> 06:40:40,080
and take this and this first one we could put you know comment out
3114
06:40:40,080 --> 06:40:54,080
and we could have y1 and put your y values 5 negative 10 negative
3115
06:40:59,919 --> 06:41:12,879
negative 25 negative 40 so remember that you know that that numpy
3116
06:41:12,880 --> 06:41:25,200
of values and we could just put our own array and if you wanted to
3117
06:41:25,200 --> 06:41:33,520
you know make them make them dots i'll say ro so we'll make them
3118
06:41:34,799 --> 06:41:41,840
for the points so we could have the x array have the y array and
3119
06:41:42,880 --> 06:41:45,840
there we go we just commented all these out and
3120
06:41:45,840 --> 06:41:54,639
so we have this looks to be that they're in line and we can change
3121
06:41:56,319 --> 06:42:01,840
you know yep it definitely looks like they're in a line
3122
06:42:01,840 --> 06:42:11,920
so we could you know there we go we could say that yep that's that
3123
06:42:11,919 --> 06:42:18,799
works that is linear so some some of these you might just notice
3124
06:42:19,439 --> 06:42:26,319
in in that table but also i wanted to show you for this or for
3125
06:42:26,319 --> 06:42:34,079
in in that table but also i wanted to show you for this or for you
3126
06:42:34,080 --> 06:42:39,200
to do for that little question but also just showing you what you
3127
06:42:39,200 --> 06:42:45,440
more complicated sets because all of these that you know this this
3128
06:42:46,080 --> 06:42:52,720
and just a few values just to show you but remember this is this
3129
06:42:52,720 --> 06:42:57,520
toward data science if you want to continue following this path
3130
06:42:57,520 --> 06:43:03,200
four values you might have like you know four thousand and so we
3131
06:43:03,200 --> 06:43:11,119
do this we'll have other ways rather than having to you know write
3132
06:43:11,119 --> 06:43:17,200
those values if there was like a thousand of them and then store
3133
06:43:17,200 --> 06:43:22,240
other y values but then you know can i do this can i just take
3134
06:43:22,240 --> 06:43:27,920
what it looks like now these are the things we want to be able to
3135
06:43:28,959 --> 06:43:34,799
some some things you know and and it answers a very simple
3136
06:43:36,000 --> 06:43:40,959
because otherwise you know they might get some of these that the
3137
06:43:40,959 --> 06:43:47,520
could not say that they're they all line up nicely so that's it
3138
06:43:47,520 --> 06:43:53,200
know missing values of a linear function and remember you can
3139
06:43:53,200 --> 06:43:58,159
a table of values too if you wanted to so you know those are some
3140
06:44:10,080 --> 06:44:20,320
we would have to put the slope formula so remember the slope
3141
06:44:20,319 --> 06:44:27,119
looking at the code you know find the equation of the line goes to
3142
06:44:27,119 --> 06:44:34,879
at the code the y values b plus one and then the other y values b
3143
06:44:34,880 --> 06:44:43,680
up one you see the y value went from b to b plus one but then look
3144
06:44:43,680 --> 06:44:53,360
didn't change so a minus a is zero so we have it's actually not a
3145
06:44:53,360 --> 06:45:02,000
x value x equals a so these are some of the things just you know
3146
06:45:02,000 --> 06:45:10,560
the slope and you could always do some of this with you could
3147
06:45:11,360 --> 06:45:18,880
if you look at the the other one that we were doing here solve and
3148
06:45:18,880 --> 06:45:26,400
have to comment out the graph probably wouldn't do too well but
3149
06:45:26,400 --> 06:45:33,760
you know you if you define more variables you could still take
3150
06:45:34,959 --> 06:45:41,599
again the solution might not be uh really possible but you could
3151
06:45:41,599 --> 06:45:52,639
actually solve and this solves it for zero but you could actually
3152
06:45:52,639 --> 06:46:00,319
for y or whatever value you want so simpy will do that for you so
3153
06:46:00,319 --> 06:46:04,079
you could have a make another section in your notebook that just
3154
06:46:04,080 --> 06:46:19,040
factoring all right so there we go and so we have some other ones
3155
06:46:19,040 --> 06:46:24,720
now this we have at noon the barista knows she has twenty dollars
3156
06:46:24,720 --> 06:46:30,080
average of fifty cents more from each customer so remember that's
3157
06:46:30,080 --> 06:46:36,640
customers tipping more some tipping less and then it averages out
3158
06:46:36,639 --> 06:46:44,319
because we would right away see the equation we begin with 20 and
3159
06:46:44,319 --> 06:46:52,239
because we know she's getting something more 50 cents from each
3160
06:46:54,400 --> 06:46:58,880
so we see that equation then we you know right away we have that
3161
06:46:59,439 --> 06:47:03,520
and we can do something with that we could like graph it we could
3162
06:47:06,479 --> 06:47:08,799
this particular question we just says n more
3163
06:47:08,799 --> 06:47:15,200
so it would be 20 plus 0.5 n you know we just change that variable
3164
06:47:16,000 --> 06:47:24,000
she can plug in a number for n figure out you know how many tips
3165
06:47:25,279 --> 06:47:30,239
and this 115 these are some of the things that you know you can
3166
06:47:30,880 --> 06:47:35,760
a gym membership with two personal training sessions and a gym
3167
06:47:35,759 --> 06:47:41,919
training sessions cost 125 while gym membership with five personal
3168
06:47:42,880 --> 06:47:50,720
what's the cost per session so we take it as the membership itself
3169
06:47:51,439 --> 06:47:58,719
and then you could have like you know each of these so really we
3170
06:47:58,720 --> 06:48:07,760
many training sessions and then the y value would be the cost and
3171
06:48:07,759 --> 06:48:15,199
we don't it's not asking us to graph we absolutely could go back
3172
06:48:16,240 --> 06:48:24,640
and then five sessions was 260 so we could go back to this and
3173
06:48:24,639 --> 06:48:32,559
you know slope intercept from two points and we could say you know
3174
06:48:33,759 --> 06:48:42,399
cost 125 you know how many sessions and then dollar amount and
3175
06:48:42,400 --> 06:48:53,680
would be then 260 and oh now this we need to change this the x
3176
06:48:53,680 --> 06:49:02,799
fine for five but let's take a look at this and let's see what we
3177
06:49:02,799 --> 06:49:12,000
go up to 10 y minimum zero is probably fine but the y maximum and
3178
06:49:12,000 --> 06:49:20,959
like you know 500 we're going to go beyond that but that's fine
3179
06:49:20,959 --> 06:49:27,279
can see that we're going to go beyond that we're going to go
3180
06:49:27,279 --> 06:49:39,599
that but that's fine and when we see the graph so we see the
3181
06:49:39,599 --> 06:49:52,399
itself must be 35 dollars and each session must be 45 dollars and
3182
06:49:52,400 --> 06:49:59,920
there we go you know and we see where we see the cost 45 you know
3183
06:50:00,479 --> 06:50:05,840
and then we see the increase okay if somebody wants to plan you
3184
06:50:05,840 --> 06:50:11,040
how many training sessions do i want maybe this is in a month the
3185
06:50:11,040 --> 06:50:17,600
it might be about eight in a month and can calculate oh there we
3186
06:50:17,599 --> 06:50:26,239
that'd be four hundred dollars or you know do i want to just try
3187
06:50:27,040 --> 06:50:31,440
and not get any training sessions and you know there we go then
3188
06:50:31,439 --> 06:50:38,479
at the zero value and that's what we want we want to you know use
3189
06:50:38,479 --> 06:50:47,840
some different things you know the cost like 116 here so the
3190
06:50:47,840 --> 06:50:52,560
there's a linear relationship between the number of shirts it can
3191
06:50:54,560 --> 06:51:00,880
price p that it can charge for sure so there you go selling and
3192
06:51:00,880 --> 06:51:07,440
and this is you know things that people want to find out because
3193
06:51:07,439 --> 06:51:12,479
what price you know they definitely start out like can't you know
3194
06:51:12,479 --> 06:51:20,399
have to make money i can't lose money but then beyond that we see
3195
06:51:20,400 --> 06:51:27,360
different prices are possible so somebody says that finds this
3196
06:51:27,360 --> 06:51:33,279
from somewhere else some other people selling shirts oh okay i can
3197
06:51:34,400 --> 06:51:41,280
if the price is thirty dollars but three thousand shirts if the
3198
06:51:43,360 --> 06:51:48,639
so there we go again that classic y equals mx plus b but we just
3199
06:51:48,639 --> 06:52:00,479
change the letters p of n you know the price based on n shirt n
3200
06:52:03,200 --> 06:52:10,720
there we go we can we can look at this you know n shirts now
3201
06:52:11,279 --> 06:52:17,360
i might take that the price is the independent variable because
3202
06:52:17,360 --> 06:52:24,639
you can buy and so we might you know do something like that and
3203
06:52:24,639 --> 06:52:31,599
units here we'll get into other things where we can then based on
3204
06:52:32,400 --> 06:52:39,440
we can find that that you know that equation for price and then
3205
06:52:39,439 --> 06:52:44,319
it a step further and say what would be my profit because just as
3206
06:52:44,319 --> 06:52:50,479
so a thousand shirts at thirty dollars so it'd be thirty thousand
3207
06:52:50,479 --> 06:53:02,239
shirts thirty dollars each but three thousand shirts at twenty two
3208
06:53:02,240 --> 06:53:11,200
thousand is forty four uh uh sixty six thousand dollars so just
3209
06:53:11,200 --> 06:53:17,360
selling more shirts but the price that it had to lower or reduce
3210
06:53:17,360 --> 06:53:24,319
much different and so it sells three thousand shirts so instead of
3211
06:53:24,799 --> 06:53:32,799
sixty six thousand dollars look at that almost uh more than twice
3212
06:53:32,799 --> 06:53:42,079
less and some people who don't look at the math of this would say
3213
06:53:42,080 --> 06:53:49,520
you know reducing it eight dollars is that going to double my
3214
06:53:49,520 --> 06:53:53,920
the revenue we don't know the cost of making the shirts but it
3215
06:53:54,639 --> 06:53:58,319
just lowering that a little bit because it reached so many people
3216
06:53:58,319 --> 06:54:03,360
and so that's what people are looking at you know and in again in
3217
06:54:03,360 --> 06:54:10,560
math behind you know how to how to get this how to find that
3218
06:54:10,560 --> 06:54:18,800
value and you know what you know what are we looking at here how
3219
06:54:18,799 --> 06:54:31,840
you know ideal shirt price so there we go there we go all these
3220
06:54:31,840 --> 06:54:38,639
equation we're trying to maximize things if we look at number 18 a
3221
06:54:38,639 --> 06:54:44,399
relationship between the number of bean stalks she uh she plants
3222
06:54:44,400 --> 06:54:51,520
that each plant produces so 30 stalks each plant yield you know
3223
06:54:52,720 --> 06:55:02,720
so 30 stocks each plant yields 30 ounces of beans but then 34
3224
06:55:02,720 --> 06:55:08,560
beans you know they're all competing for some of the same
3225
06:55:08,560 --> 06:55:14,720
you know they're all competing for some of the same resources so
3226
06:55:14,720 --> 06:55:21,840
equation and then we can try to find so what would be the maximum
3227
06:55:22,799 --> 06:55:29,520
what would maximize the bean yield so you know it'd be really
3228
06:55:33,759 --> 06:55:46,719
um yes so notice this uh and the yield would be 30 ounces that
3229
06:55:48,799 --> 06:55:59,520
30 stocks times 30 ounces see then 30 times 30 so that's 900 or
3230
06:55:59,520 --> 06:56:06,799
and i'm not going to do that in my head but we can see some
3231
06:56:06,799 --> 06:56:13,520
these in some of the other business applications later on so some
3232
06:56:13,520 --> 06:56:21,520
population and like number 120 drawing linearly we can write an
3233
06:56:21,520 --> 06:56:29,760
another one where we often do this all the time converting
3234
06:56:29,759 --> 06:56:40,479
and we have these two values zero degrees celsius is 32 degrees
3235
06:56:41,360 --> 06:56:47,920
100 degrees celsius is when water boils and the corresponding temp
3236
06:56:47,919 --> 06:56:55,919
can do is we could just take these now we could also use this to
3237
06:56:57,680 --> 06:57:06,319
but we could also take this you know slope intercept from an
3238
06:57:06,319 --> 06:57:15,599
there we go still better sub equation from two points and
3239
06:57:19,279 --> 06:57:23,199
we can say all right so we have zero and then 32
3240
06:57:25,360 --> 06:57:31,360
and celsius would be 100 and fahrenheit would be 212
3241
06:57:31,360 --> 06:57:36,560
here we go and see the see the graph
3242
06:57:37,919 --> 06:57:42,799
now the graph in this case okay and i'm not even worried about
3243
06:57:42,799 --> 06:57:50,719
the main thing we wanted was this equation here 1.8 x minus 32
3244
06:57:50,720 --> 06:57:59,520
fraction that's nine over five so there we go that's and remember
3245
06:57:59,520 --> 06:58:07,279
the x value was celsius so that's how we can convert celsius to
3246
06:58:09,840 --> 06:58:19,599
and so if we look at the increase you know 1.8 is almost two so
3247
06:58:21,919 --> 06:58:28,399
degree increases almost two degrees fahrenheit increase so we can
3248
06:58:28,400 --> 06:58:34,319
so if we take a look at this you know we you could always you can
3249
06:58:34,319 --> 06:58:43,279
another function for yourself that you could you know you could
3250
06:58:44,880 --> 06:58:53,200
celsius to fahrenheit fahrenheit to celsius you know that make
3251
06:58:53,200 --> 06:59:00,959
you know put a heading to it because remember as soon as you have
3252
06:59:00,959 --> 06:59:05,599
because we're not in the code but if it's in there then it becomes
3253
06:59:05,599 --> 06:59:13,039
of contents so you can always make some of these things for
3254
06:59:13,040 --> 06:59:17,200
want to give you some of these practice problems you know if some
3255
06:59:17,200 --> 06:59:23,040
want to combine some of the things you know you have room to
3256
06:59:24,720 --> 06:59:31,040
so there we go and then once you have that equation you can find
3257
06:59:31,040 --> 06:59:38,319
that function of 28 degrees what's that become in celsius or
3258
06:59:38,319 --> 06:59:48,639
uh that's a good one because negative 40 celsius is negative 40
3259
06:59:48,639 --> 06:59:56,720
they actually agree it's got to be really cold but when it's that
3260
06:59:57,200 --> 07:00:02,799
having a thermometer would probably agree too yes it's cold so
3261
07:00:02,799 --> 07:00:09,840
some of some of these and hopefully this is you know find this
3262
07:00:09,840 --> 07:00:17,200
interpret some of the word problems and use some of the notebooks
3263
07:00:17,200 --> 07:00:23,280
solve problems answer questions and yeah you can continue you know
3264
07:00:23,279 --> 07:00:28,799
know make make it your calculator anytime you have different
3265
07:00:28,799 --> 07:00:36,880
might be useful make a function pick a formula another notebook
3266
07:00:36,880 --> 07:00:46,400
on to the next thing now that we've worked through the core skills
3267
07:00:46,400 --> 07:00:52,800
some extra problems and i'm going to work through extra problems
3268
07:00:52,799 --> 07:00:59,040
see how you can apply these resources that you're building and use
3269
07:00:59,040 --> 07:01:04,799
come up in a textbook or in day-to-day life so we're going to go
3270
07:01:04,799 --> 07:01:14,319
here for these extra problems we're going to look at just ways to
3271
07:01:14,319 --> 07:01:19,919
you have different situations word problems how can we decode
3272
07:01:19,919 --> 07:01:26,959
then use python to solve them so just here's some examples and all
3273
07:01:26,959 --> 07:01:35,279
first textbook you have the link so let's look at number 10 on
3274
07:01:35,279 --> 07:01:42,079
canadians work 39.5 hours per week so if the typical adult
3275
07:01:42,080 --> 07:01:46,240
what's the percentage of hours in a single week left over for
3276
07:01:46,240 --> 07:01:53,600
so we need a few things here 30 so we need the number of hours in
3277
07:01:55,439 --> 07:02:02,719
even just going through your python colab notebook we have all
3278
07:02:02,720 --> 07:02:11,440
i'm going to click on solve and graph which we're not doing yet
3279
07:02:11,439 --> 07:02:21,759
the blank you know line of code here and even in the print
3280
07:02:23,040 --> 07:02:31,600
first of all we can have the number of hours per week and that
3281
07:02:31,599 --> 07:02:43,759
and then if we want to look at the number of hours that canadians
3282
07:02:43,759 --> 07:02:51,919
from that and python knows the word of operation so i can just put
3283
07:02:51,919 --> 07:03:04,719
you really don't need it 39.5 so there we go uh 24 hours a day
3284
07:03:05,759 --> 07:03:16,239
and then we actually can also subtract eight hours a day eight
3285
07:03:16,240 --> 07:03:26,240
times seven so we have how many total hours in the week and then
3286
07:03:26,240 --> 07:03:41,440
the sleep hours again all this in in python shift enter and we
3287
07:03:41,439 --> 07:03:50,639
72.5 hours is you know and it works out look at look at that you
3288
07:03:50,639 --> 07:03:57,200
of time to go out and do things and we can do all this just know
3289
07:03:57,200 --> 07:04:01,280
step you can break this up into different steps and put variables
3290
07:04:01,279 --> 07:04:10,639
this all right and let's take a look at another one that number 14
3291
07:04:10,639 --> 07:04:17,840
for the first half of 20 2009 we're down 46.733 percent we'll talk
3292
07:04:17,840 --> 07:04:29,360
second from 2008 when 1500 new homes were started so from 2008 to
3293
07:04:29,360 --> 07:04:38,479
would be that times one or times 100 which would be times 1.00 so
3294
07:04:38,479 --> 07:04:46,720
that times one but then since it went down we want to think one
3295
07:04:46,720 --> 07:04:56,800
percent it's the 100 minus this 46.733 and then the original was
3296
07:04:56,799 --> 07:05:12,399
so we can just go right back to this and we have 1500 new homes
3297
07:05:12,400 --> 07:05:27,680
46.733 as a decimal is going to be 0.46733 and you see that we
3298
07:05:27,680 --> 07:05:37,040
so one or you know 100 i mean it's not going to mess up the code
3299
07:05:37,040 --> 07:05:43,520
but so you know that's 100 so if it was that 1500 times one that
3300
07:05:43,520 --> 07:05:50,319
year and since it went down it's times one minus this rate you
3301
07:05:52,639 --> 07:06:00,399
and these are number of homes so we're going to round it down and
3302
07:06:00,400 --> 07:06:08,480
you know that 0.005 is you know i don't know that's what five
3303
07:06:08,479 --> 07:06:14,959
know they put a few boards there or something on the lot said i
3304
07:06:14,959 --> 07:06:19,759
going to call it 799 and that's how we get this times you know one
3305
07:06:19,759 --> 07:06:24,479
went down and in later weeks we're going to talk a lot more about
3306
07:06:24,479 --> 07:06:32,000
so this is not the only time you're going to see this and in that
3307
07:06:32,000 --> 07:06:38,080
these other percent increase or decrease but on page 73 i want to
3308
07:06:40,720 --> 07:06:51,280
so if 999 changed to 1049 so the amount of change we would just
3309
07:06:51,279 --> 07:06:56,239
and we see you know we can do that you can do that in your head
3310
07:06:57,599 --> 07:07:01,759
but then the percent changes we take that difference over the
3311
07:07:01,759 --> 07:07:10,239
so if it started at 999 that's the that's the difference so that's
3312
07:07:10,240 --> 07:07:21,760
and again we can look at percent change so that 50 cents 0.50
3313
07:07:24,000 --> 07:07:32,319
so that's we get that difference divided by the original number
3314
07:07:32,319 --> 07:07:41,599
we're going to multiply it by 100 because it's the first two
3315
07:07:41,599 --> 07:07:49,359
the next number is a zero so it's really a five percent change
3316
07:07:49,360 --> 07:07:58,400
it to sometimes people like to put that into the formula times 100
3317
07:07:58,400 --> 07:08:05,840
there we go as a percent I mean if it's just for your own
3318
07:08:05,840 --> 07:08:12,560
make it fancier if you're doing this to explain you know costs and
3319
07:08:12,560 --> 07:08:18,479
business proposal yeah it's nice to have the extra bit you know
3320
07:08:19,119 --> 07:08:23,119
people can see oh this is exactly what you're talking about for
3321
07:08:23,119 --> 07:08:33,279
put it all in the print statement and you know see see the output
3322
07:08:34,080 --> 07:08:40,640
1999 lowered by 10 percent so we're looking at these keywords
3323
07:08:41,439 --> 07:08:47,840
we need that formula one minus the rate again might be new to
3324
07:08:47,840 --> 07:08:54,479
we're going to talk a lot more about it in later weeks but 1999
3325
07:08:56,880 --> 07:08:59,600
we're not decreasing by an amount so we're not subtracting
3326
07:09:07,360 --> 07:09:14,240
one minus three and I can even you know convert this as I'll just
3327
07:09:14,240 --> 07:09:23,760
10 remember 0.10 so I put that in there with the extra zeros but
3328
07:09:23,759 --> 07:09:28,479
get this one minus three if it didn't change it would be that
3329
07:09:28,479 --> 07:09:37,119
one but it's times one minus three and then that's the new number
3330
07:09:37,119 --> 07:09:45,039
any practical connection it was just what's the number if it's a
3331
07:09:45,040 --> 07:09:53,360
to two decimal places it's 17.99 so that'd be something like you
3332
07:09:53,360 --> 07:10:01,040
1999 and it was on 10 off so you end up paying 17.99 and knowing
3333
07:10:01,040 --> 07:10:07,600
you have calculator so you can do this you know right there on
3334
07:10:07,599 --> 07:10:14,799
this app you can set up different things for percent increase and
3335
07:10:14,799 --> 07:10:21,680
in the store oh what would the actual price be and at that point
3336
07:10:21,680 --> 07:10:33,200
we go and here we have this what about when increased by 40 is
3337
07:10:34,400 --> 07:10:39,840
before I even get to what we're going to calculate I'm going to
3338
07:10:41,200 --> 07:10:47,119
because I don't want the code I just want to show you the math of
3339
07:10:47,119 --> 07:10:55,919
I'm going to call x increased by 40 percent so if it increased
3340
07:11:01,279 --> 07:11:04,639
and then that would equal that new amount
3341
07:11:08,319 --> 07:11:15,599
so you know the the beginning amount or you know x or we can call
3342
07:11:15,599 --> 07:11:19,279
times one plus the rate equals the new amount and I just put this
3343
07:11:20,000 --> 07:11:25,279
just looking at this formula and so if I have this
3344
07:11:27,759 --> 07:11:34,319
then the question is what amount number six here what amount when
3345
07:11:35,040 --> 07:11:41,520
so that would be x times and when it's one plus three that makes
3346
07:11:41,520 --> 07:11:52,400
point four I put the zero if I wanted to equals 3500 because one
3347
07:11:53,759 --> 07:12:00,559
and then in doing this we remember solving for x I'm multiplying
3348
07:12:00,560 --> 07:12:11,200
the print statement I'm doing this 3500 divided by 1.4 and we see
3349
07:12:11,200 --> 07:12:17,440
you could write your math in here some notes for yourself the
3350
07:12:17,439 --> 07:12:23,039
plug in the numbers so then we see what's the actual math that
3351
07:12:23,040 --> 07:12:29,520
oh dividing by 1.4 so we'll do that and that's the one thing that
3352
07:12:29,520 --> 07:12:40,959
others are comments there you go 2500 so we have some of these all
3353
07:12:43,599 --> 07:12:49,359
I actually want to skip over to this baseball one I skipped over
3354
07:12:49,360 --> 07:12:54,319
are more straightforward now let's take a look at making use of
3355
07:12:54,319 --> 07:13:00,560
this notebook for yourself let's make use of the system of
3356
07:13:00,560 --> 07:13:08,240
15 the local baseball team sells tickets with two price zones
3357
07:13:08,240 --> 07:13:14,640
to third are priced at twenty dollars per ticket all the other
3358
07:13:14,639 --> 07:13:22,239
dollars a ticket and last night's game 5332 fans were in
3359
07:13:22,240 --> 07:13:31,760
worth 71,000 how many tickets were in each zone so let's call x
3360
07:13:31,759 --> 07:13:39,199
those the twenty dollar tickets and let's call y the ones that are
3361
07:13:39,200 --> 07:13:46,000
things we want we want to know how many tickets in each zone so
3362
07:13:46,000 --> 07:13:55,200
so twenty dollars for the good tickets ten dollars for the lower
3363
07:13:55,200 --> 07:14:03,360
seventy one thousand seven fifty so if we go to our solvent graph
3364
07:14:03,360 --> 07:14:10,080
you might have your table of contents jump right to it solvent
3365
07:14:10,080 --> 07:14:15,760
and y and you can even write some more stuff in here and you know
3366
07:14:15,759 --> 07:14:25,679
a look at this if our two equations are twenty dollars times x
3367
07:14:26,560 --> 07:14:35,920
times y how many of those tickets did we sell equals that total
3368
07:14:35,919 --> 07:14:46,000
sure we get it exact seventy one thousand seven fifty so now we
3369
07:14:46,000 --> 07:14:51,200
twenty dollars times this many tickets the good tickets plus ten
3370
07:14:51,200 --> 07:14:58,319
that are further out equals this how much this much money that but
3371
07:14:58,319 --> 07:15:06,720
i want to solve this i need another equation so what about that
3372
07:15:06,720 --> 07:15:15,040
three hundred thirty two fans were in attendance so x and y were
3373
07:15:15,040 --> 07:15:28,400
section so x plus y must equal five thousand three hundred thirty
3374
07:15:29,439 --> 07:15:35,840
in the way we have this set up here we can just set this equal to
3375
07:15:35,840 --> 07:15:44,959
equation and we're just going to put this twenty times x plus ten
3376
07:15:44,959 --> 07:15:55,119
x plus ten times y and then equal to zero i just subtract that
3377
07:15:56,080 --> 07:15:57,920
and then that would be that equal to zero
3378
07:16:00,799 --> 07:16:11,119
all right and the second equation set equal to zero so x plus y so
3379
07:16:11,119 --> 07:16:20,000
five three three two that would make that set equal to zero and
3380
07:16:20,000 --> 07:16:27,279
other things here if you want to factor and then just setting up
3381
07:16:27,279 --> 07:16:34,159
way to set it up because remember we already set this up to solve
3382
07:16:34,159 --> 07:16:45,040
and the graph you know just might help visualize it and when we
3383
07:16:47,759 --> 07:16:59,039
see the solution here and 1843 and 3489 so that's how many of each
3384
07:16:59,040 --> 07:17:08,400
because when we add these up then that's going to be five three
3385
07:17:08,400 --> 07:17:18,800
we know how many of each each ticket so 1843 people sat you know
3386
07:17:18,799 --> 07:17:25,759
and 3489 as we expect that's there's more room out there in the
3387
07:17:25,759 --> 07:17:29,119
that's how many people sat out there and now and now we can figure
3388
07:17:33,439 --> 07:17:36,479
and we see the graph just to see the comparison here
3389
07:17:39,759 --> 07:17:43,679
so pretty cool we can we can figure out given this information
3390
07:17:43,680 --> 07:17:49,040
how many people sat in each place and who knows maybe if it wasn't
3391
07:17:49,040 --> 07:17:57,600
breakdown all right and you know some other applications we'll
3392
07:17:57,599 --> 07:18:07,519
increase maybe we'll take a look at this one here so number 15
3393
07:18:07,520 --> 07:18:15,200
for her trail mix recipe let's talk about but the by weight her
3394
07:18:15,200 --> 07:18:24,639
30 percent cheerios 20 peanuts and she wants to make two kilograms
3395
07:18:25,200 --> 07:18:35,040
just calculate how much of each she's mixing so pretzels cheerios
3396
07:18:37,040 --> 07:18:42,639
we could just go right to right to here and before i even get to a
3397
07:18:42,639 --> 07:18:50,159
we could just define some variables in python we like to use the
3398
07:18:53,040 --> 07:19:04,880
pretzel weight maybe we'll do pretzel uh pretzel there we go
3399
07:19:04,880 --> 07:19:13,200
times two because it was 50 percent pretzels and she wants to make
3400
07:19:13,200 --> 07:19:29,760
going to be 30 percent and peanuts 20 percent so cheerios equals
3401
07:19:29,759 --> 07:19:42,319
uh peanuts equals 0.2 times two now we have now we're going to we
3402
07:19:42,319 --> 07:19:48,000
each of these and you can put comments in there for yourself if
3403
07:19:48,000 --> 07:20:01,840
uh talk about the cost so there we go if we have the the cost so
3404
07:20:01,840 --> 07:20:17,920
9.999 and so if we have this our cost equals pretzel times 9.99
3405
07:20:17,919 --> 07:20:28,639
kilograms at 9.99 a kilogram plus and we'll look at cheerios 6.99
3406
07:20:46,159 --> 07:20:58,639
so now we have the total cost here and that should be then the
3407
07:21:02,159 --> 07:21:08,319
fine but the question then asks what's the average cost per 100
3408
07:21:08,319 --> 07:21:19,360
so 100 grams compared to two kilograms is divided by 20 and we
3409
07:21:19,360 --> 07:21:27,760
to also bring it up to the proportion earlier on in this notebook
3410
07:21:27,759 --> 07:21:38,479
kilograms 100 grams and so it's we can just put this in the print
3411
07:21:38,319 --> 07:21:46,319
because that's the cost for 100 grams there we go so how many of
3412
07:21:47,119 --> 07:21:52,479
but then the final question uh we need to divide it by 20 we only
3413
07:21:52,479 --> 07:21:57,200
100 grams and there we go 80 cents
3414
07:21:59,759 --> 07:22:04,719
which makes sense because if we take a look at the total cost for
3415
07:22:06,159 --> 07:22:11,439
yeah when we when we're buying this full two kilograms you know
3416
07:22:11,439 --> 07:22:18,959
16 dollars worth of trail mix i mean you know hopefully two
3417
07:22:18,959 --> 07:22:25,119
it'll last a while so she just wants to make 100 grams so that's
3418
07:22:27,759 --> 07:22:31,359
100 grams you know so that people can eat it before it goes stale
3419
07:22:33,599 --> 07:22:41,840
there you go 80 cents all right not bad so some other things that
3420
07:22:41,840 --> 07:22:49,840
making use of these calculators that we have we can take a look at
3421
07:22:49,840 --> 07:22:56,319
options for things like green energy and so i i put in here you
3422
07:22:57,279 --> 07:23:04,079
one thing you know one thing and it was i think i did one solar
3423
07:23:04,080 --> 07:23:10,560
you know you want to buy this you know live live off the grid or
3424
07:23:10,560 --> 07:23:17,120
for somewhere so here's a solar panel charges up a battery and the
3425
07:23:17,919 --> 07:23:28,159
and then the output is 110 watt hours now 111 so you can certainly
3426
07:23:28,159 --> 07:23:34,799
possible that's just you know that output i normally would then
3427
07:23:34,799 --> 07:23:42,719
111 watts for an hour and 111 watts that should be enough to
3428
07:23:42,720 --> 07:23:53,520
charge a phone few light bulbs also so you know that's something
3429
07:23:53,520 --> 07:24:00,400
make use of 111 watts like i said laptop charge phone power a few
3430
07:24:00,400 --> 07:24:11,200
and then that way so what what this would be is so the uh
3431
07:24:11,200 --> 07:24:15,760
hours because we use so much and that's like 15 cents i think is
3432
07:24:16,319 --> 07:24:27,360
so 111 watts that's you know 10 of that a little bit less so yes
3433
07:24:27,360 --> 07:24:36,080
you know this 111 watt hours and i was thinking you use 111 watts
3434
07:24:37,279 --> 07:24:45,520
a 1.5 cents okay now beyond the savings if you're also doing this
3435
07:24:45,520 --> 07:24:50,880
grid or you know uh you want to run run some stuff like out in the
3436
07:24:50,880 --> 07:24:57,600
really plug it in well that's the value of this but let's just say
3437
07:24:57,599 --> 07:25:06,399
electricity cost so you know that 245 dollars and if you run this
3438
07:25:07,680 --> 07:25:15,439
all you're making full use of all this for an hour then it'd be 16
3439
07:25:15,439 --> 07:25:24,079
um rough estimate you know doing a little bit of rounding here
3440
07:25:24,080 --> 07:25:32,720
you know a little bit less than three years and if you do that you
3441
07:25:33,520 --> 07:25:37,439
in a thousand days which for a lot of investments that's not that
3442
07:25:37,439 --> 07:25:44,959
and then after that free electricity you know you paid for this
3443
07:25:44,959 --> 07:25:49,919
you're saving this money for the thousand thousand days and then
3444
07:25:49,919 --> 07:25:57,679
already saved enough money to pay for it and you get the free
3445
07:25:57,680 --> 07:26:05,360
another comparison so this wind turbine i find all these nice you
3446
07:26:05,360 --> 07:26:13,520
isn't it you know it's kind of interesting so uh did that not
3447
07:26:13,520 --> 07:26:22,080
wind turbine that can handle like low winds and it's rated for you
3448
07:26:23,119 --> 07:26:29,840
the idea is that if it's low wind it might be a whole lot less and
3449
07:26:29,840 --> 07:26:36,400
you know it can say 2.5 meters per second low wind speed which
3450
07:26:37,439 --> 07:26:42,479
and even at that point it'll turn it'll generate some electricity
3451
07:26:42,479 --> 07:26:50,479
like this and this one was 270 dollars 400 watts but low low wind
3452
07:26:50,479 --> 07:26:58,000
okay so let's just say you can generate 40 watts for 24 hours
3453
07:26:58,000 --> 07:27:04,080
not dependent on the sun you know you could have wind blowing
3454
07:27:04,080 --> 07:27:11,680
kilowatt per day 40 watts it'd be like you know 960 watts we'll
3455
07:27:11,680 --> 07:27:18,799
just an estimate anyway so that one kilowatt hour you know on
3456
07:27:19,360 --> 07:27:26,880
so if you have it somewhere where it's low wind there we go that
3457
07:27:26,880 --> 07:27:33,920
gives you how many days 1800 days so this one would be if it was
3458
07:27:33,919 --> 07:27:40,559
five years to pay for itself and then after that you know free
3459
07:27:40,560 --> 07:27:46,560
not so bad as a return on your investment but i just happen to
3460
07:27:46,560 --> 07:27:51,280
a windy area and let's say you can produce a constant 400 watts
3461
07:27:51,279 --> 07:27:59,599
places you know especially if you're near like a body of water
3462
07:28:00,639 --> 07:28:07,919
wide river you could definitely get a consistent wind and if
3463
07:28:10,080 --> 07:28:15,760
and it would only take about half a year to pay for itself because
3464
07:28:15,759 --> 07:28:23,840
watts that's 9.6 kilowatt hours per day or dollar 44 and then just
3465
07:28:23,840 --> 07:28:33,279
divided by a dollar 44 187 days you know just over half a year and
3466
07:28:33,279 --> 07:28:41,759
space hey by three of them and because you're making you know
3467
07:28:41,759 --> 07:28:48,000
uh three of them is probably enough to power you know somebody's
3468
07:28:49,360 --> 07:28:52,880
you know you're you're you're saying you would be saving all that
3469
07:28:52,880 --> 07:29:01,120
of the three of them and power the whole house yeah about six
3470
07:29:01,119 --> 07:29:07,119
that it would be that about that same yeah so really interesting
3471
07:29:07,119 --> 07:29:14,399
you can do these calculations i just wrote them here but you can
3472
07:29:14,400 --> 07:29:23,440
co-lab and do these different calculations graph different things
3473
07:29:24,560 --> 07:29:29,280
that that that's the idea with having all all you know all the
3474
07:29:29,279 --> 07:29:34,559
fingertips you can count you can calculate things and figure out
3475
07:29:34,560 --> 07:29:41,920
spend this much money and then you know generate this for
3476
07:29:41,919 --> 07:29:48,159
say it's not a priority right now and you know that's it but you
3477
07:29:48,159 --> 07:29:55,200
numbers so that's that's really some of the some of the uses of of
3478
07:29:55,919 --> 07:29:59,439
and you know also making use of you know the co-lab
3479
07:29:59,439 --> 07:30:07,919
uh graphing some different things or solving some problems so
3480
07:30:07,919 --> 07:30:14,079
and hopefully this gives you ideas of other things you can do once
3481
07:30:14,080 --> 07:30:19,520
notebooks and you have the ability to calculate and graph some
3482
07:30:19,520 --> 07:30:25,840
use of it to see what you can do to make money or save yourself
3483
07:30:25,840 --> 07:30:35,439
the next unit then so let's talk about quadratics so the word quad
3484
07:30:36,560 --> 07:30:42,880
why would we have you know quad square but then it's and we call
3485
07:30:42,880 --> 07:30:49,840
two so where does the square come from the square in quadratics
3486
07:30:49,840 --> 07:30:56,319
so where does the square come from the square in quadratics comes
3487
07:30:56,319 --> 07:31:07,119
to the original algebra back with al-khorizmi so the if i have a
3488
07:31:07,119 --> 07:31:14,639
each side i'm just going to call them x but then the area of that
3489
07:31:14,639 --> 07:31:20,639
be x squared and that's where that's really where this notion of
3490
07:31:21,919 --> 07:31:28,399
actually tied to physical area the area of a square but there's a
3491
07:31:28,400 --> 07:31:34,480
and this comes up so often that we get beyond even the the actual
3492
07:31:34,479 --> 07:31:43,680
this for a lot of other things so we look at the our equation y
3493
07:31:43,680 --> 07:31:47,119
graph this and when we get into the code we're going to get into
3494
07:31:47,119 --> 07:31:52,559
look at some of those applications too but when i'm going when i
3495
07:31:52,560 --> 07:31:58,720
quadratic it's going to be a parabola and you know it'll probably
3496
07:31:58,720 --> 07:32:05,680
than that but it'll be a parabola so that means you know and if we
3497
07:32:05,680 --> 07:32:12,159
values for x give me you know i square them and give me some y
3498
07:32:12,159 --> 07:32:17,040
when i square that negative times the negative makes it a positive
3499
07:32:17,040 --> 07:32:23,280
around and so you know we keep going up and then these two ends go
3500
07:32:25,119 --> 07:32:29,439
but yeah the the negative x values get squared so then the y
3501
07:32:30,400 --> 07:32:36,480
i still can get negative y values because if in my graph i
3502
07:32:36,479 --> 07:32:41,919
subtract you know five or something like that so there's
3503
07:32:41,919 --> 07:32:46,799
squared are less than five so when i subtract i get a negative y
3504
07:32:47,360 --> 07:32:54,479
but you see the the general trend of the parabola here and they
3505
07:32:55,680 --> 07:32:59,840
but if you have if you have a negative x value
3506
07:32:59,840 --> 07:33:11,920
you so any negative x value it looks like a frown so our
3507
07:33:11,919 --> 07:33:17,359
be negative so let's yeah let's take a look at this if i had any
3508
07:33:20,319 --> 07:33:27,360
quadratic and this is the general form so if i have the general
3509
07:33:27,360 --> 07:33:38,400
y equals ax squared plus bx plus c and that covers all the
3510
07:33:38,400 --> 07:33:44,400
any quadratic equation so a would be my coefficient for the x
3511
07:33:44,400 --> 07:33:52,880
be my coefficient for the x term and then c would be the constant
3512
07:33:52,880 --> 07:34:00,159
a has a number then i can have a quadratic b and c can be zero
3513
07:34:00,159 --> 07:34:06,880
oh well there's no x term b is zero c was zero and then the other
3514
07:34:06,880 --> 07:34:13,520
five so then c would be minus five b would still be zero so there
3515
07:34:13,520 --> 07:34:20,000
any quadratic and as long as a has a number to it then it's a
3516
07:34:20,000 --> 07:34:26,560
then it's some some other type so if we take a look at this and
3517
07:34:26,560 --> 07:34:32,159
down like a frown a is positive opens up like a smile and the
3518
07:34:32,159 --> 07:34:44,479
is they're all symmetrical so the vertex is the point at the
3519
07:34:44,479 --> 07:34:52,159
how it turns up of where the gravel turns around so since it's
3520
07:34:53,840 --> 07:35:04,720
is going to be this definite formula negative b over 2a so what i
3521
07:35:04,720 --> 07:35:13,760
i can plug in my four my values for a and b and get the x value
3522
07:35:13,759 --> 07:35:19,359
the x value i would plug that x value in to get the y value and
3523
07:35:19,360 --> 07:35:26,000
that would be the point that if i had my parabola that would be
3524
07:35:26,000 --> 07:35:33,040
it turns around and also just looking at that x value remember
3525
07:35:33,040 --> 07:35:42,720
divide the parabola nicely so we're going to look at doing this in
3526
07:35:43,520 --> 07:35:49,200
and then finding the vertex finding a lot of other things so we're
3527
07:35:49,200 --> 07:35:55,119
be able to do that so i'm not going to worry about all the
3528
07:35:55,119 --> 07:36:00,959
you is one other thing that we're also going to look at the code
3529
07:36:00,959 --> 07:36:07,919
this formula is a lot of times when i graph this if i were to
3530
07:36:07,919 --> 07:36:14,719
my x y and you know let's say i have a parabola there i might also
3531
07:36:14,720 --> 07:36:24,639
where does the parabola cross the x-axis and so when it crosses
3532
07:36:24,639 --> 07:36:33,840
because you know on the axis i'm not going up or down at all so if
3533
07:36:33,840 --> 07:36:38,959
would talk about solving for x but if i have something like this
3534
07:36:38,959 --> 07:36:43,919
i have one variable which is x how would i solve it we approach it
3535
07:36:44,560 --> 07:36:49,920
than we would the other the other ones because when i square root
3536
07:36:49,919 --> 07:36:56,159
to happen as a part of the process when i square root something
3537
07:36:56,720 --> 07:37:04,560
positive or negative possibilities because if i had if i had the
3538
07:37:05,200 --> 07:37:12,639
four and then the square root that it's positive four or negative
3539
07:37:12,639 --> 07:37:21,119
positive two because if i had two squared that equals four but if
3540
07:37:22,000 --> 07:37:27,439
that would also equal positive four so if i'm going the other way
3541
07:37:27,439 --> 07:37:33,680
square rooting yes it could be positive two or it could have been
3542
07:37:33,680 --> 07:37:39,360
finding the roots for a quadratic you know setting this equal to
3543
07:37:39,360 --> 07:37:44,319
involve square rooting which gives me a possibility of a positive
3544
07:37:44,319 --> 07:37:54,159
where we have you know our two possible answers and so that's how
3545
07:37:54,159 --> 07:38:00,639
quadratics you know the way they cross they're going to cross the
3546
07:38:01,439 --> 07:38:05,520
to find the roots i want to find out those two values and the
3547
07:38:05,520 --> 07:38:09,680
so again knowing a b and c the quadratic formula
3548
07:38:12,319 --> 07:38:15,040
all right so and notice it's that
3549
07:38:18,000 --> 07:38:25,840
that vertex plus or minus something and then that's how we use
3550
07:38:25,840 --> 07:38:37,840
b squared minus four a c all over two a again so this is the
3551
07:38:37,840 --> 07:38:44,880
because i have plus or minus it will give it will give me two
3552
07:38:44,880 --> 07:38:49,840
the code we would run through this once for plus get that answer
3553
07:38:49,840 --> 07:38:57,119
there we go but also since i'm square rooting something we're just
3554
07:38:57,119 --> 07:39:04,239
the real numbers here and if i have a negative value under this
3555
07:39:04,240 --> 07:39:12,240
solution so you know we could get into imaginary numbers and you
3556
07:39:12,240 --> 07:39:17,120
why should we let that stop us but for our purposes we're not
3557
07:39:17,119 --> 07:39:21,439
we're going to say that if it's negative then there's no real
3558
07:39:21,439 --> 07:39:28,159
just stop there so in doing this i would often test this we call
3559
07:39:28,159 --> 07:39:36,240
discriminant and i would often test this you know b squared minus
3560
07:39:36,880 --> 07:39:41,920
actually that can be zero which is fine because that'd be plus or
3561
07:39:41,919 --> 07:39:47,439
it would have one root it would just touch the x-axis that's fine
3562
07:39:47,439 --> 07:39:56,239
means i have no roots and i would have a parabola that just never
3563
07:39:56,240 --> 07:40:02,000
that's perfectly fine it's possible and in that case i would test
3564
07:40:02,000 --> 07:40:07,360
then that would save me some time you know not having to do all
3565
07:40:07,360 --> 07:40:12,799
this old school and just factored it all out you know right right
3566
07:40:12,799 --> 07:40:17,759
it takes a while we're going to look at how to make this a lot
3567
07:40:17,759 --> 07:40:21,519
we're going to put these formulas in and then we're going to find
3568
07:40:22,240 --> 07:40:29,280
oh you know maybe we'll even graph them too so this is the formula
3569
07:40:29,279 --> 07:40:36,239
they're both had the same denominator so i could i could make this
3570
07:40:40,720 --> 07:40:44,240
you know do the adding or subtracting in the numerator all over
3571
07:40:46,000 --> 07:40:51,200
and mathematically that works out you know it's another way to
3572
07:40:51,200 --> 07:40:57,280
this is the quadratic formula as we would often see it just like
3573
07:40:57,279 --> 07:41:06,399
all over 2a and so for as complex as this could be there's only a
3574
07:41:06,400 --> 07:41:14,640
i get a b and c formula for the vertex formula for the roots we
3575
07:41:14,639 --> 07:41:19,919
we'll you know then we can look at some of the applications but
3576
07:41:19,919 --> 07:41:27,279
the essence of looking at quadratics here and so now let's take a
3577
07:41:27,279 --> 07:41:32,879
um well you know how to solve these formulas and everything so
3578
07:41:33,439 --> 07:41:38,879
so solving a quadratic equation is much easier with code because
3579
07:41:38,880 --> 07:41:43,360
talking about that we would work out by hand we're just going to
3580
07:41:43,360 --> 07:41:52,159
so you can just define a b and c once and then run those values
3581
07:41:52,799 --> 07:41:59,279
and output your answer roots vertex and whatever else you need so
3582
07:41:59,279 --> 07:42:05,840
that work out uh nicely a b and c and what do we want to do let's
3583
07:42:05,840 --> 07:42:14,959
so we'll print out what our function is then we'll calculate the
3584
07:42:14,959 --> 07:42:22,879
variable and that's the negative b over 2a that's going to
3585
07:42:22,880 --> 07:42:28,960
no order of operations but this 2a does need to be in parentheses
3586
07:42:30,000 --> 07:42:35,279
so we get that x value and then we're going to take that x value
3587
07:42:35,279 --> 07:42:47,360
for the y value a times and my x value vx and then square it plus
3588
07:42:49,840 --> 07:42:57,920
so i get i plug all that in get the y value and just like before
3589
07:42:59,439 --> 07:43:03,359
there we go we just print the equation now we have the vertex as a
3590
07:43:03,360 --> 07:43:10,560
and we'll go on to the roots and the roots remember the quadratic
3591
07:43:10,560 --> 07:43:14,880
but it's actually d is for determinant here that's the part that's
3592
07:43:14,880 --> 07:43:21,680
because if that's negative then i won't have any real roots and so
3593
07:43:21,680 --> 07:43:27,360
under the square root b squared minus 4ac and then i'll test it
3594
07:43:27,360 --> 07:43:34,319
zero because if it's not then i'm going to print out no real roots
3595
07:43:34,319 --> 07:43:38,799
than or equal to then we're going to calculate the roots and
3596
07:43:38,799 --> 07:43:47,680
quadratic formula so since i already figured out d i'll make use
3597
07:43:47,680 --> 07:43:52,639
so we're going to run through this twice for the first root
3598
07:43:52,639 --> 07:43:59,200
and then all that's over 2a and notice parentheses for the
3599
07:43:59,200 --> 07:44:04,959
and then the second root negative b minus the square root of d and
3600
07:44:05,759 --> 07:44:13,279
so i'll print this out calculate the roots print it out or you
3601
07:44:13,279 --> 07:44:22,559
and there we go so i actually already ran this and what do we have
3602
07:44:22,560 --> 07:44:29,120
x2 plus 5x plus 6 and then we have the vertex is this negative 2.5
3603
07:44:29,759 --> 07:44:34,479
and then the roots x equals 2 negative 2 and x equals negative 3
3604
07:44:36,560 --> 07:44:42,479
so there we go if all you need to do is solve it it's nice to have
3605
07:44:42,479 --> 07:44:49,439
just change a b and c and run it again so if we want to graph it
3606
07:44:49,439 --> 07:44:55,359
do everything we were doing plus the graphing part remember our
3607
07:44:55,360 --> 07:45:02,639
numpy i'm also going to import math for some things that we'll do
3608
07:45:02,639 --> 07:45:10,880
i just pick different numbers here and i'm going to print out a b
3609
07:45:10,880 --> 07:45:17,680
i'm going to print this out calculate the vertex print that out
3610
07:45:17,680 --> 07:45:26,400
so notice i didn't do the roots yet and we just have x min x max
3611
07:45:26,400 --> 07:45:35,680
else we were doing for graphing define the x values set up the
3612
07:45:35,680 --> 07:45:39,920
parabola i just called it y1 even though i probably won't have a
3613
07:45:41,200 --> 07:45:47,200
ax squared plus bx plus c there we go i'm going to graph that
3614
07:45:47,200 --> 07:45:55,200
so i'm going to plot x and y1 then i'm going to plot the vertex as
3615
07:45:55,200 --> 07:46:03,520
here for the the plotting parabola the vertex point and then
3616
07:46:03,520 --> 07:46:12,000
it's going to be a line and here i'm defining two arrays each of
3617
07:46:12,000 --> 07:46:18,400
that's going to be a red dot so then we're going to find and plot
3618
07:46:18,400 --> 07:46:25,360
doing with calculating the roots from before but i'm going to add
3619
07:46:26,240 --> 07:46:33,280
and once i get the plot i'm going to plot root one root one zero
3620
07:46:33,279 --> 07:46:39,119
you know the array of my x values and then the y values and this
3621
07:46:39,119 --> 07:46:44,239
so that's why it's good so it's going to be a green circle so i'm
3622
07:46:44,240 --> 07:46:48,720
i'm also going to print out the roots because i want to see that
3623
07:46:54,560 --> 07:47:01,040
it'll have your equation here there you go x squared plus four x
3624
07:47:01,040 --> 07:47:06,639
and give you the roots now these roots are irrational you know
3625
07:47:06,639 --> 07:47:14,000
wacky decimal we could you know do quite a few more lines of code
3626
07:47:14,000 --> 07:47:20,799
wacky radical answer but we're not going to worry about that now
3627
07:47:20,799 --> 07:47:23,919
if you're writing this down somewhere you might round it to a
3628
07:47:24,639 --> 07:47:30,959
but here we go we plot the vertex as a red dot the roots as green
3629
07:47:30,959 --> 07:47:40,639
the x-axis and then we graph the parabola and so i can redo this
3630
07:47:40,639 --> 07:47:49,840
that we were doing before one five there we go six and that's all
3631
07:47:52,000 --> 07:47:57,520
and it'll run through and calculate all this there we go x squared
3632
07:47:57,520 --> 07:48:04,880
and here's the vertex negative two point five negative point two
3633
07:48:04,880 --> 07:48:12,159
two and negative two and negative three there we go now there we
3634
07:48:12,159 --> 07:48:19,439
where it crosses the x-axis and see the y value of that vertex is
3635
07:48:19,439 --> 07:48:30,159
two five so it's just below it but just barely and there we go so
3636
07:48:30,159 --> 07:48:36,079
we can graph it we can get our roots in our vertex and for most
3637
07:48:36,080 --> 07:48:44,480
quadratics that's what you want to do so let's take a look at how
3638
07:48:44,479 --> 07:48:50,560
graph so i'm going to show you some sliders here and that's going
3639
07:48:50,560 --> 07:48:59,680
other notebooks so how a b and c so the first thing is we're going
3640
07:48:59,680 --> 07:49:05,920
map plot live in line and we're going to write that first and then
3641
07:49:05,919 --> 07:49:12,799
widgets and interactive the same and then the same other things
3642
07:49:12,799 --> 07:49:19,759
so the way that these widgets work is we're going to put all the
3643
07:49:19,759 --> 07:49:25,199
we're going to connect again with functions here i still defined
3644
07:49:25,200 --> 07:49:30,080
later on i wanted that to be a short name for that line but you'll
3645
07:49:30,080 --> 07:49:36,160
this f but it's the function of a b and c i'm going to take those
3646
07:49:36,159 --> 07:49:44,799
now you could always make this say quadratic and you know do
3647
07:49:45,520 --> 07:49:50,880
with the quadratic roots vertex we could actually take everything
3648
07:49:51,599 --> 07:49:57,759
with the plotting and with solving and put all that in this
3649
07:49:57,759 --> 07:50:02,319
it more than just that if i might say quadratic and take the
3650
07:50:02,319 --> 07:50:07,439
you need so kind of cool that you can do that but here we're just
3651
07:50:07,439 --> 07:50:14,719
so my function there we go x min x max all those i'm going to
3652
07:50:14,720 --> 07:50:23,360
remember a b and c would be the input so we would have those and
3653
07:50:23,360 --> 07:50:32,959
plot the the parabola plot uh the vertex as a point plot the roots
3654
07:50:34,479 --> 07:50:43,040
there we go this all of this here is really just extra for the
3655
07:50:43,040 --> 07:50:49,440
title of the graph i did that instead of printing it out which i
3656
07:50:49,439 --> 07:50:53,840
could have done but i wanted to show you we could set it as the
3657
07:50:53,840 --> 07:51:04,000
needs to be a string so here i'm going to take a b and c and
3658
07:51:04,000 --> 07:51:11,680
i'm going to take all of this and i was you know this doesn't
3659
07:51:11,680 --> 07:51:18,159
but i was thinking of that h1 for the heading so i'm just going to
3660
07:51:18,159 --> 07:51:24,560
all these that exact y equals combined with sa that string and i'm
3661
07:51:24,560 --> 07:51:32,560
as h1 but if i just leave it at that it'll still display in a
3662
07:51:32,560 --> 07:51:37,760
like extra quotes and i don't like that so i'm going to just find
3663
07:51:38,560 --> 07:51:42,560
it's just blank with quotes and that's going to be a string and
3664
07:51:42,560 --> 07:51:52,240
for w in h1 you know w like for word in h1 and then h2 equals h2
3665
07:51:52,240 --> 07:51:59,680
these two strings put it all together as h1 but then i still
3666
07:51:59,680 --> 07:52:08,159
this way combining these now h2 is a nice unified string without a
3667
07:52:08,159 --> 07:52:16,000
you know again it's a lot to just it all leads up to the sake of
3668
07:52:16,000 --> 07:52:25,360
as the title okay and you know we'll see hopefully you know it
3669
07:52:25,360 --> 07:52:31,200
that was you say oh that was worth it all right so here's where
3670
07:52:31,200 --> 07:52:39,440
this interactive plot now that's just the variable that i chose
3671
07:52:39,439 --> 07:52:46,799
really happening this interactive function so if we take a look at
3672
07:52:46,799 --> 07:52:51,119
so that's where the name of your function goes and that's where
3673
07:52:51,119 --> 07:52:57,200
i wanted this to be short so i just that's why i called it f so it
3674
07:52:57,200 --> 07:53:07,760
that function and then it defines a with a range from one to nine
3675
07:53:07,759 --> 07:53:17,199
to nine and c also with a range from negative nine to nine a i
3676
07:53:17,200 --> 07:53:23,280
was zero that's actually not a quadratic and i want to illustrate
3677
07:53:23,279 --> 07:53:30,159
at one so we just define this interactive plot and then notice
3678
07:53:30,880 --> 07:53:34,880
then if i just say interactive plot it's going to print it's going
3679
07:53:36,080 --> 07:53:39,600
so we'll see this interactive how that makes the sliders here
3680
07:53:42,400 --> 07:53:48,240
there we go and it default shows them in the middle and see this
3681
07:53:48,240 --> 07:53:55,920
that when it starts out you see the title of the graph y equals
3682
07:53:55,919 --> 07:54:04,799
zero you see that's it just and if i go if i make that down to one
3683
07:54:04,799 --> 07:54:10,559
basic parabola you know x squared and i don't have to put the plus
3684
07:54:10,560 --> 07:54:20,720
going to write that every time and then we can see what happens if
3685
07:54:22,720 --> 07:54:25,840
i can move c and it'll adjust the graph it'll adjust the title
3686
07:54:26,959 --> 07:54:33,599
of the graph there we go and then we can see what happens if i
3687
07:54:33,599 --> 07:54:40,879
b you see it moves it along here and now
3688
07:54:44,159 --> 07:54:48,799
it got to this point that now where it is i do have roots in the
3689
07:54:51,599 --> 07:54:58,239
and then if i have i can see where b as i move that around
3690
07:54:58,240 --> 07:55:08,159
affects this whole graph and i can see then how a affects the
3691
07:55:15,119 --> 07:55:22,239
so we see some different things that we can do and all these are
3692
07:55:22,240 --> 07:55:28,159
you can tinker with these but this is all you know it was just i
3693
07:55:28,159 --> 07:55:33,360
that you can set up sliders and in this case to display the
3694
07:55:37,040 --> 07:55:40,080
display the graph see the roots in the vertex
3695
07:55:42,639 --> 07:55:48,000
you see and i move that down so we display the graph see the roots
3696
07:55:48,000 --> 07:55:56,959
with sliders you can see how a b and c affect the graph so knowing
3697
07:55:56,959 --> 07:56:03,119
this code at your disposal you can really see you know most
3698
07:56:03,119 --> 07:56:10,959
do with quadratics you know find the roots in the vertex see the
3699
07:56:10,959 --> 07:56:17,759
you know do some other things so there we go this and some
3700
07:56:19,040 --> 07:56:28,400
um now that we've worked through the core skills in this unit
3701
07:56:28,400 --> 07:56:34,319
and i'm going to work through extra problems using the colab
3702
07:56:34,319 --> 07:56:39,919
apply these resources that you're building and use that use these
3703
07:56:39,919 --> 07:56:45,679
come up in a textbook or in day-to-day life so we're going to go
3704
07:56:45,680 --> 07:56:53,840
here so here we're going to walk through the foundational math
3705
07:56:53,840 --> 07:57:00,560
have not already done it please give this a try on your own this
3706
07:57:00,560 --> 07:57:07,920
done that and you're stuck or if you just had a question about one
3707
07:57:07,919 --> 07:57:16,799
hopefully answer all those and just like the other certifications
3708
07:57:16,799 --> 07:57:23,680
and put this in your uh in your google drive so you know file save
3709
07:57:24,240 --> 07:57:30,159
and this one we're going to focus on building cartesian graphs so
3710
07:57:30,159 --> 07:57:33,680
deal with graphing we're going to look at some different functions
3711
07:57:33,680 --> 07:57:40,639
so you make a copy in your google drive it might be in your google
3712
07:57:40,639 --> 07:57:47,200
you can put it wherever you want and now hopefully you know i
3713
07:57:47,200 --> 07:57:54,959
you're now working from your copy and we need to acquire the
3714
07:57:54,959 --> 07:58:00,319
write just like the certification one the code do you write when
3715
07:58:00,319 --> 07:58:05,520
it'll run through these tests to see if the code is what it's
3716
07:58:05,520 --> 07:58:11,920
some feedback so this first cell you don't need to do anything and
3717
07:58:11,919 --> 07:58:19,039
what you need to do here for future reference in case you want to
3718
07:58:19,040 --> 07:58:27,120
you know you include in your colab notebook so this custom library
3719
07:58:27,119 --> 07:58:34,319
code is going to get that and save it here in a work in a local
3720
07:58:34,319 --> 07:58:44,000
need to run this for each new session as i mentioned before it'll
3721
07:58:45,040 --> 07:58:52,639
because of an activity after 30 minutes at the most or even if
3722
07:58:52,639 --> 07:59:00,559
out so each new session run this and it'll go through and then
3723
07:59:00,560 --> 07:59:09,680
to run yep and see just a few seconds code test passed so there we
3724
07:59:11,840 --> 07:59:17,840
so let's take a look at some coordinates here cartesian
3725
07:59:17,840 --> 07:59:25,599
renee decart because that's part of his name cart and you know
3726
07:59:25,599 --> 07:59:32,399
in life when your last name becomes an adjective so he among other
3727
07:59:32,400 --> 07:59:38,319
coordinate system that we're familiar with with zero zero in the
3728
07:59:38,319 --> 07:59:44,479
horizontally positive to the right negative to the left and y
3729
07:59:44,479 --> 07:59:51,279
down so then each x y coordinate tells you you know how much
3730
07:59:51,279 --> 08:00:00,159
going up and we can plot all these points our go-to library is
3731
08:00:01,200 --> 08:00:06,959
and as we were talking about importing your own personal library
3732
08:00:08,400 --> 08:00:12,800
to do that in a little bit different ways a few more lines but a
3733
08:00:12,799 --> 08:00:20,000
uh i say commonly you know reasonably used i've been around a
3734
08:00:20,000 --> 08:00:25,919
google colab already did that install part so you just need to
3735
08:00:25,919 --> 08:00:33,439
we have that nice benefit you know things just work in the google
3736
08:00:33,439 --> 08:00:37,840
and we're importing this library yeah that's a mouthful so we're
3737
08:00:37,840 --> 08:00:44,400
that way every time i reference it plt.plt. i don't have to
3738
08:00:45,840 --> 08:00:52,400
okay so this is going to be the first thing is the basic just
3739
08:00:53,840 --> 08:00:59,040
you probably could change these variables but i don't this is
3740
08:00:59,759 --> 08:01:05,919
in the documentation for matplot library so i keep these and it
3741
08:01:05,919 --> 08:01:13,599
assigning two different variables to this but it's you could have
3742
08:01:13,599 --> 08:01:19,359
going to worry about that right here but you could have multiple
3743
08:01:19,360 --> 08:01:26,159
could have like nine little graphs in it if you wanted or
3744
08:01:26,159 --> 08:01:31,680
would put numbers in there but we're not worried about that now
3745
08:01:31,680 --> 08:01:36,799
exists and then plt.show that's always going to be our last thing
3746
08:01:38,720 --> 08:01:43,760
you run it and there's our basic graph notice we didn't add
3747
08:01:45,919 --> 08:01:51,199
so there's not nothing going on here and zero zero instead of
3748
08:01:51,200 --> 08:01:57,520
bottom left because we're just showing the positive quadrant here
3749
08:01:57,520 --> 08:02:04,479
values up to one positive y values up to one and that's it and
3750
08:02:06,639 --> 08:02:09,919
test and yes code test passed if you click the button correctly
3751
08:02:11,919 --> 08:02:18,159
so we'll go to step two all right so now we have the standard
3752
08:02:18,159 --> 08:02:25,040
axis and we're still going to go through import this establish
3753
08:02:25,040 --> 08:02:34,400
something here so this gives us the size of the graph and i just
3754
08:02:35,919 --> 08:02:39,439
this would be better we're going to modify this as we go on but
3755
08:02:39,439 --> 08:02:44,159
that'll give us the size of the graph 10 in every direction so
3756
08:02:47,040 --> 08:02:50,400
so you see it does give us 10 in the direction and if you follow
3757
08:02:50,400 --> 08:02:58,800
the zero zero exists in the middle here even if you don't see the
3758
08:02:58,799 --> 08:03:04,559
positive to the right up to 10 negative to the left down to
3759
08:03:04,560 --> 08:03:10,800
in the middle positive up to 10 negative down to negative 10 so
3760
08:03:10,799 --> 08:03:18,559
here somewhere all right and this one was one of these that i ask
3761
08:03:18,560 --> 08:03:23,840
rerun so it's run this to see what it looks like then change the
3762
08:03:24,400 --> 08:03:33,120
so we go through here and we can just move this 20 20 in each
3763
08:03:35,680 --> 08:03:41,040
now we notice from this even the one where we only went up to one
3764
08:03:41,040 --> 08:03:48,080
change but we see the lines on the outside do and the tick marks
3765
08:03:48,080 --> 08:03:58,160
in each direction there we go code test passed so some more graph
3766
08:03:58,159 --> 08:04:05,439
i was saying we're going to modify this this is really what we
3767
08:04:05,439 --> 08:04:15,359
plt.axis so what were those numbers it really was an array of x
3768
08:04:15,360 --> 08:04:24,240
as just one group notice the parentheses and then the open
3769
08:04:24,240 --> 08:04:31,520
was that defines the window size so that's why it's plt.axis so i
3770
08:04:31,520 --> 08:04:40,080
sense to define those as variables up here so this line here the
3771
08:04:40,080 --> 08:04:44,880
and then it's really easy for you to then change the window size
3772
08:04:44,880 --> 08:04:52,639
numbers so there we go and this one is not one oh yeah this one is
3773
08:04:54,639 --> 08:04:59,119
notice it should still do the same thing there we go and then
3774
08:05:01,119 --> 08:05:10,639
20 you know and again we see 20 in each direction
3775
08:05:12,159 --> 08:05:19,599
so this is going to be our go-to way to set up the graph and as we
3776
08:05:21,119 --> 08:05:27,520
those axis lines that you might be making and we're going to
3777
08:05:27,520 --> 08:05:35,920
so we have those axis lines that you might be missing i know i was
3778
08:05:35,919 --> 08:05:44,239
want to display these well we have our basic graph and we have the
3779
08:05:44,240 --> 08:05:50,960
were doing this on your own that the b that we're going to see
3780
08:05:50,959 --> 08:05:58,959
so we have this dimensions that we're building upon and these
3781
08:05:58,959 --> 08:06:11,599
subplots the window size so now we have the plt.plot and that's
3782
08:06:11,599 --> 08:06:21,359
points now in this case we have this array here from x min to x
3783
08:06:21,919 --> 08:06:29,359
what this is is a an array of the x values and then the y values
3784
08:06:29,360 --> 08:06:40,240
so we have it starts from x min zero and then goes to x max zero
3785
08:06:42,319 --> 08:06:48,000
and rather than plot to those two points it plots a line from that
3786
08:06:48,000 --> 08:06:53,840
and with this the line is going to be blue if you don't put
3787
08:06:53,840 --> 08:07:01,040
python will pick the color of the line for you and then for the
3788
08:07:03,919 --> 08:07:10,799
then we're going to plot zero zero y min y max so what is this
3789
08:07:11,520 --> 08:07:21,119
the x value of zero to the y value of y min so from zero y min to
3790
08:07:21,119 --> 08:07:27,680
draw that line and again i'm forcing it into be this this space
3791
08:07:27,680 --> 08:07:36,560
space or not doesn't matter so there we go so these two plot
3792
08:07:36,560 --> 08:07:43,200
plot statements define whether you know define that it's going to
3793
08:07:43,200 --> 08:07:49,280
and i even have the comments here so then you see blue x-axis blue
3794
08:07:49,279 --> 08:07:53,599
y-axis so that's it we're going to show this plot and
3795
08:08:01,439 --> 08:08:07,759
we also see again the the value of defining everything up here
3796
08:08:07,759 --> 08:08:18,079
of these the size of the graph and then where these lines go to
3797
08:08:18,080 --> 08:08:24,000
this up top so if i change the dimensions of this then everything
3798
08:08:24,000 --> 08:08:29,279
the axis lines will still go to the ends so we run it and then
3799
08:08:49,439 --> 08:08:52,639
so you can make it whatever you want
3800
08:08:55,520 --> 08:09:02,720
i just happen to like blue so there we go changing these so now
3801
08:09:02,720 --> 08:09:09,600
to plot a point like we saw that we did that into define a line
3802
08:09:09,599 --> 08:09:17,680
well see as we continue to build this define these values here and
3803
08:09:17,680 --> 08:09:26,720
just going to end up keeping all of this as the window size and
3804
08:09:26,720 --> 08:09:35,520
it blue so how do i plot exactly one point so notice this array of
3805
08:09:35,520 --> 08:09:47,840
only one in there and y values so it's five four now here's what
3806
08:09:47,840 --> 08:09:55,040
it a point in fact a circular dot so if i have just b with nothing
3807
08:09:55,040 --> 08:09:59,760
if i actually just had r with nothing that would make it a line
3808
08:09:59,759 --> 08:10:10,079
too so that would be weird but ro makes it a point and we'll see
3809
08:10:12,959 --> 08:10:16,959
so keeping all that the same and just plotting this one point
3810
08:10:16,959 --> 08:10:28,000
one point there we go one point and it is five at five four over
3811
08:10:29,919 --> 08:10:36,479
now we could put the grid lines in but that'll be another story so
3812
08:10:38,080 --> 08:10:41,520
so the directions run it then change the location to negative five
3813
08:10:41,520 --> 08:10:49,520
one okay so then we just change this to negative five and change
3814
08:10:52,000 --> 08:10:53,919
there we go and when we run it
3815
08:10:58,479 --> 08:11:09,119
all right so plotting a point we indicate that it's a point this
3816
08:11:12,479 --> 08:11:16,399
plotting a line we have other ways to indicate that
3817
08:11:20,159 --> 08:11:21,759
so how would i plot several points
3818
08:11:21,759 --> 08:11:32,239
well let's take a look all right so a ray is to plot each point
3819
08:11:37,360 --> 08:11:44,799
and we can still define it as an array here i'm just going to
3820
08:11:44,799 --> 08:11:55,919
the array here an array of x values and an array of y values so if
3821
08:11:57,840 --> 08:12:09,200
we go down here so notice all that's still the same and here i can
3822
08:12:09,200 --> 08:12:15,360
because you know x values and y values and i did not use exactly x
3823
08:12:15,360 --> 08:12:19,360
so we're okay i mean you really could name these arrays whatever
3824
08:12:21,680 --> 08:12:25,920
but there we go we have what am i plotting the array of x values
3825
08:12:25,919 --> 08:12:37,279
and then here i have red points for each of them now right here i
3826
08:12:37,279 --> 08:12:44,000
so we can add so that's the assignment for this step add two
3827
08:12:44,000 --> 08:12:52,400
one one and two five okay so the x value would be one and the y
3828
08:12:52,400 --> 08:13:00,960
so i have point four two and then point one one and the next one
3829
08:13:00,959 --> 08:13:14,959
y value would be five and there we go all right and changing those
3830
08:13:14,959 --> 08:13:24,239
don't have to change this code plot that array and we see three
3831
08:13:24,240 --> 08:13:33,360
because each of them i made a red point so let's mix it up let's
3832
08:13:34,959 --> 08:13:40,000
okay so that's it hopefully you are noticing the subtle difference
3833
08:13:40,000 --> 08:13:44,959
each plot statements takes an array of x values an array of y
3834
08:13:44,959 --> 08:13:50,799
you what you're plotting so the default plot is a line if you
3835
08:13:50,799 --> 08:14:01,439
it would give you a line and python would pick the color rbg
3836
08:14:01,439 --> 08:14:07,039
also work as just letters and beyond that there's actually a few
3837
08:14:07,040 --> 08:14:14,240
write in the word for the color give it a try you know i'm not
3838
08:14:14,240 --> 08:14:21,440
but yeah give it a try and so these are the colors so then we have
3839
08:14:22,000 --> 08:14:29,759
ro the o indicates a dot rs you could plot a square and then r
3840
08:14:30,720 --> 08:14:36,800
would be a triangle so that if you have different things you're
3841
08:14:36,799 --> 08:14:41,919
dots or squares or triangles and then of course that combined with
3842
08:14:41,919 --> 08:14:49,519
plot a lot of different things on one graph so notice we've
3843
08:14:50,799 --> 08:14:59,599
and i'll call this one line x line y point x point y so yeah not
3844
08:15:01,200 --> 08:15:07,600
and there we go so we have these we'll keep all these defining the
3845
08:15:07,599 --> 08:15:17,039
and let's plot so if i wanted to plot so the directions are a lot
3846
08:15:17,040 --> 08:15:32,720
squares so if i plot here so line x comma line y and we want it to
3847
08:15:32,720 --> 08:15:46,319
we go and point x point y and it's a green square gs
3848
08:15:49,759 --> 08:15:56,239
so you see if you've been working through the course hopefully
3849
08:15:56,240 --> 08:16:01,760
coming at this you know relatively new hopefully it's seeming
3850
08:16:01,759 --> 08:16:08,079
more you do this the more you just get familiar with with graphing
3851
08:16:08,080 --> 08:16:11,920
be able to do this right off the top of your head so we graph
3852
08:16:15,279 --> 08:16:24,719
and we will see so there's the red line from that point to that
3853
08:16:24,720 --> 08:16:35,200
here so there we go so we see how we can graph a line and
3854
08:16:37,360 --> 08:16:43,760
okay so here's a scatter plot game and i call this making a
3855
08:16:46,080 --> 08:16:54,560
but i kind of made the game so but we could take a look so this is
3856
08:16:54,560 --> 08:17:01,040
want to look through this code how can i plot a random point and
3857
08:17:02,000 --> 08:17:10,880
try to guess the point i made the i made this uh you know a
3858
08:17:12,639 --> 08:17:20,559
and we'll define this once and here's what we're doing each time
3859
08:17:20,560 --> 08:17:30,720
if we are we're going to get an x point which is going to be a
3860
08:17:30,720 --> 08:17:36,880
this is going to be good for different games or different things
3861
08:17:36,880 --> 08:17:46,880
a whole library of randomness and random dot rand int and it gives
3862
08:17:46,880 --> 08:17:56,479
max from x min to x max and actually the way most ranges work in
3863
08:17:56,479 --> 08:18:08,319
x max is x max it will won't go to that it'll go to the number
3864
08:18:10,159 --> 08:18:16,079
so there we go so you see again if i change these dimensions it
3865
08:18:16,080 --> 08:18:29,520
that so now if x point is the random integer then i'm going to
3866
08:18:30,639 --> 08:18:37,599
store this as my y value and you see essentially it is an array
3867
08:18:37,599 --> 08:18:47,439
you know but then and i might have been able to skip this step but
3868
08:18:47,439 --> 08:19:01,039
you know what what this is and now we go here i'm going to apply
3869
08:19:01,040 --> 08:19:09,200
uh gives the grid now this is we you know we had their axis lines
3870
08:19:10,560 --> 08:19:17,040
that'll help because the game is going to be here's the point you
3871
08:19:18,240 --> 08:19:24,800
so that's what this is yes and we're going to prompt for input
3872
08:19:24,799 --> 08:19:36,239
red point and that's going to be an x y with a comma so we're
3873
08:19:37,680 --> 08:19:41,040
and that's going to be an array with two elements so then
3874
08:19:43,200 --> 08:19:49,920
yes array zero so the first element cast as an integer that's
3875
08:19:49,919 --> 08:19:55,359
and the second element is the y value cast as an integer that's
3876
08:19:57,279 --> 08:20:08,399
and this is part of why i like to break it up here because i have
3877
08:20:09,279 --> 08:20:18,479
this defines it as an array but this is the point that we wanted
3878
08:20:18,479 --> 08:20:24,639
point and y guess equals y point then that's going to increment
3879
08:20:28,080 --> 08:20:32,160
and there we go all this in the loop and then if statements in the
3880
08:20:33,119 --> 08:20:41,840
and you know in range zero to three we really because we're
3881
08:20:41,840 --> 08:20:50,400
need that zero the range will start at zero by default so there we
3882
08:20:51,840 --> 08:20:55,360
it's going to go through it three times because it'll be zero one
3883
08:20:55,360 --> 08:21:02,159
again python ranges if it's range three it won't do three it'll do
3884
08:21:02,159 --> 08:21:11,919
it so we go through and guess it three times and then print out
3885
08:21:13,599 --> 08:21:21,680
was way at the top initialize it at zero and we'll see see what
3886
08:21:21,680 --> 08:21:33,279
with the grid lines we can see so zero and look at these four five
3887
08:21:33,279 --> 08:21:53,360
point would be zero five and here we have zero negative three zero
3888
08:21:53,360 --> 08:21:57,200
why i made it eight in every direction because it actually the
3889
08:21:57,200 --> 08:22:06,319
bit better so what's the coordinate of this point so looks like
3890
08:22:06,319 --> 08:22:22,000
three so that would be three negative three all right and there we
3891
08:22:22,000 --> 08:22:25,840
it'd be a good way to test your understanding of coordinates
3892
08:22:28,159 --> 08:22:35,360
all right and step nine so now if i want to graph a whole linear
3893
08:22:35,360 --> 08:22:39,520
define these two points and i can draw a line between them but
3894
08:22:39,520 --> 08:22:48,880
the whole linear equation so numpy is the library we're going to
3895
08:22:48,880 --> 08:22:58,000
import numpy as np now that one i mean numpy is not that big of a
3896
08:22:58,000 --> 08:23:02,400
just seems to be a common thing so you will see np dot this or np
3897
08:23:02,400 --> 08:23:12,240
functions all right and then we have the linspace function so that
3898
08:23:12,240 --> 08:23:18,320
an array of values when we're talking about functions we can you
3899
08:23:18,319 --> 08:23:24,479
this gives us that array and we're going to plot the function with
3900
08:23:27,119 --> 08:23:34,000
so if we take a look at this all these so after we import numpy
3901
08:23:34,000 --> 08:23:40,560
same setup for the graph and then linspace
3902
08:23:43,520 --> 08:23:50,159
we give this now i purposefully made it a little bit less you
3903
08:23:51,200 --> 08:23:57,040
we'll get to some other things that we can do with this that'll
3904
08:23:57,040 --> 08:24:05,520
purposefully a little bit less than the maximum values here on the
3905
08:24:05,520 --> 08:24:12,560
argument so it goes from it's the x values is what we want for
3906
08:24:12,560 --> 08:24:21,920
negative nine to nine and in that there are 36 points so believe
3907
08:24:21,919 --> 08:24:29,919
actually going to be enough which is you know four points you know
3908
08:24:31,919 --> 08:24:38,879
that's actually going to be enough and notice then what we're
3909
08:24:39,919 --> 08:24:47,279
and you see that's the array of x values numpy gives us that array
3910
08:24:47,279 --> 08:24:58,079
given this i can just put this equation in here as that's the y
3911
08:24:58,080 --> 08:25:05,200
through this array of x values that y value is going to it
3912
08:25:05,200 --> 08:25:15,040
what it's going to plot so then when we run this we see that it
3913
08:25:15,040 --> 08:25:23,360
this graph there we go two x minus three and yep looks like it
3914
08:25:23,360 --> 08:25:33,920
and looks like about up two over one etc okay so there we go um
3915
08:25:33,919 --> 08:25:45,519
um and we have this run it and then change it to graph negative x
3916
08:25:45,520 --> 08:25:55,520
the same now in this case since this was cut off here we didn't
3917
08:25:55,520 --> 08:26:14,959
then change this to negative x plus three now we see the the
3918
08:26:14,959 --> 08:26:27,599
here because it cut cut off there so what can we do here well we
3919
08:26:27,599 --> 08:26:35,599
already defined x min and x max we could actually make this go
3920
08:26:35,599 --> 08:26:46,479
this come up in the next things we do all right so we can create
3921
08:26:49,599 --> 08:26:59,199
so in this case we've been talking about linear equations let's
3922
08:26:59,200 --> 08:27:07,840
slider so we're going to import all these things here now you know
3923
08:27:08,799 --> 08:27:16,000
matplot library for the graph for the plot and then we have we're
3924
08:27:16,000 --> 08:27:26,479
and then the widgets so we can make all the graphing happen in a
3925
08:27:26,479 --> 08:27:35,040
there we go function of m and b and if you're if you're working
3926
08:27:35,040 --> 08:27:41,120
in this course this might be familiar and then we'll see just you
3927
08:27:41,119 --> 08:27:46,799
different about what we're doing here with this function so if i
3928
08:27:48,080 --> 08:27:54,480
everything happens in the function defining the x values y the
3929
08:27:54,479 --> 08:28:01,360
y the maximum defining all this and in this case we're going to
3930
08:28:01,360 --> 08:28:04,959
we already know that this is going to be a slope intercept
3931
08:28:04,959 --> 08:28:18,079
title all right and then we have there we go np.lin space and we
3932
08:28:18,080 --> 08:28:27,680
time i also rewrote the numbers but you could always make this
3933
08:28:27,680 --> 08:28:35,279
else here so what are we going to do here we're going to plot x
3934
08:28:37,360 --> 08:28:45,360
because these m and b values are going to come from slider and
3935
08:28:45,360 --> 08:28:50,720
take that so here's our interactive plot i mean i could have made
3936
08:28:50,720 --> 08:29:00,319
but the function is interactive and then it takes f what's what
3937
08:29:00,319 --> 08:29:09,599
it a range and b equals and we give it a range and we run this
3938
08:29:16,080 --> 08:29:22,800
to plot now notice it default goes to zero so as soon as i
3939
08:29:22,799 --> 08:29:31,200
with the slope of two line with the slope of four and then b is
3940
08:29:31,200 --> 08:29:45,440
up and i can move it down and we see that i can adjust my graph so
3941
08:29:45,439 --> 08:29:56,559
that we can adjust a graph all right and then if i'm graphing a
3942
08:29:56,560 --> 08:30:04,960
graphing system of equations that then hopefully this is a good
3943
08:30:04,959 --> 08:30:13,680
a look at here's one way to graph a system of equations all right
3944
08:30:13,680 --> 08:30:21,840
these now here's where we make it a lot better so how many points
3945
08:30:21,840 --> 08:30:29,759
it also based on this x max minus x min so that's going to give me
3946
08:30:29,759 --> 08:30:38,879
the negative so that's going to give me you know this range and
3947
08:30:38,880 --> 08:30:45,920
enough times 10 that might be plenty for even more complicated
3948
08:30:45,919 --> 08:30:53,439
have that you know there's the range and then times two and then
3949
08:30:53,439 --> 08:30:59,119
here we are defining this linspace from x min to x max and then
3950
08:31:01,040 --> 08:31:06,560
so we see again we're building these i have this comment in there
3951
08:31:08,240 --> 08:31:11,920
pretty soon then you won't even need that and now we again we
3952
08:31:11,919 --> 08:31:18,159
our complete uh our base of what we're importing and then the
3953
08:31:20,560 --> 08:31:31,760
so then i can plot two lines you know define y1 in terms of x
3954
08:31:33,279 --> 08:31:46,399
and what what am i plotting x and then y1 there we go and in line
3955
08:31:46,400 --> 08:31:52,560
linear this this plot works you know x squared minus three and
3956
08:31:52,560 --> 08:32:03,600
and then y2 and we can see these so there we go all right change
3957
08:32:05,680 --> 08:32:14,959
so y2 we're going to make it negative x minus three so we're just
3958
08:32:14,959 --> 08:32:25,840
negative x minus three and we see there we go and with these you
3959
08:32:25,840 --> 08:32:32,080
want these lines to be but without that python gives me the colors
3960
08:32:32,080 --> 08:32:39,840
know it'll go through a few colors and then we'll go through a few
3961
08:32:39,840 --> 08:32:49,119
light blue then orange you know it'll go through a few colors and
3962
08:32:51,919 --> 08:32:57,759
two points so systems of equations you know so there we go that
3963
08:32:58,720 --> 08:33:05,040
two equations and you can graph more if you want systems of
3964
08:33:05,040 --> 08:33:14,479
so the simpy library and we probably don't need to import
3965
08:33:14,479 --> 08:33:19,919
example so the import asterisk is going to import everything from
3966
08:33:19,919 --> 08:33:26,959
to define these symbols so now i'm going to here i'm going to
3967
08:33:26,959 --> 08:33:35,200
going to use to solve so i could define these separately and
3968
08:33:35,200 --> 08:33:43,440
do but what do i have i have lin solve and then notice open
3969
08:33:43,439 --> 08:33:52,399
for lin solve and then what do i have i have this array of these
3970
08:33:52,400 --> 08:33:59,120
zero so that's what you know it would be this two times x plus y
3971
08:34:00,240 --> 08:34:07,600
and then the other one x minus two times y plus seven equals zero
3972
08:34:07,599 --> 08:34:13,039
up if i want to solve these two it would be those set equal to
3973
08:34:13,040 --> 08:34:26,959
variables x and y and what happens when i run it it gives me this
3974
08:34:29,279 --> 08:34:36,799
as a point that's the solution there we go so one way to solve
3975
08:34:36,799 --> 08:34:49,520
and if we change these to 2x plus y minus 15 equals zero so 2x
3976
08:34:49,520 --> 08:34:59,040
change that and then 3x so remember three times x you know we'll
3977
08:34:59,040 --> 08:35:04,639
have to remember to put the multiplying symbol in there minus y so
3978
08:35:04,639 --> 08:35:15,040
over and that's it just 3x minus y equals zero so there we go and
3979
08:35:20,720 --> 08:35:27,120
so there you go one way one of the ways to solve a system of
3980
08:35:27,119 --> 08:35:35,279
equations solving a system of equations and you may have already
3981
08:35:35,279 --> 08:35:43,680
code to solve and graph and output you know make the output even
3982
08:35:45,680 --> 08:35:49,200
if you haven't already gotten to that you will
3983
08:35:49,200 --> 08:35:58,319
so now we can get the solutions as coordinates so as we saw there
3984
08:36:00,240 --> 08:36:07,840
but given that set we can convert that into an x y coordinates so
3985
08:36:09,599 --> 08:36:16,479
i split out first and second as two different as a way to put
3986
08:36:16,479 --> 08:36:24,000
solution i don't have to change this code then solve first second
3987
08:36:24,000 --> 08:36:26,000
sometimes that's a little bit easier
3988
08:36:28,799 --> 08:36:37,759
now we know that that solution is going to be a finite set so this
3989
08:36:37,759 --> 08:36:45,679
i'll call this variable x solution is solution dot args zero zero
3990
08:36:45,680 --> 08:36:53,200
solution dot args zero one and so there we go you don't have to
3991
08:36:53,200 --> 08:36:57,840
ways that that's organized especially since you know you think
3992
08:36:58,400 --> 08:37:06,319
one x y solution but there's a lot going on here so now i have
3993
08:37:06,319 --> 08:37:12,880
so now i have these as x solution y solution and i'm going to
3994
08:37:14,319 --> 08:37:18,639
and just for kicks i'll also print it out as a coordinate pair
3995
08:37:24,240 --> 08:37:29,760
so see zero zero i mean it works out
3996
08:37:29,759 --> 08:37:39,359
because x plus y and x minus y so they would cross a zero zero
3997
08:37:46,319 --> 08:37:50,319
so there we go again another way to then elevate that and solve
3998
08:37:52,479 --> 08:37:55,840
just showing you different different ways that you can parse these
3999
08:37:55,840 --> 08:38:07,119
now we can even get the system from user input so i'm going to
4000
08:38:08,240 --> 08:38:15,680
you know this remember to use python syntax and then notice how
4001
08:38:15,680 --> 08:38:24,159
to zero because i'm going to prompt for the input here first and
4002
08:38:24,159 --> 08:38:34,000
and the second equation and i'm not even casting these as anything
4003
08:38:34,639 --> 08:38:42,720
linsolve works out like that there you go first second and then
4004
08:38:45,279 --> 08:38:52,079
let's do this as long as as long as two things set equal to zero
4005
08:39:01,599 --> 08:39:09,439
plus four minus y so if you think about things in terms of y
4006
08:39:10,400 --> 08:39:16,640
put a minus y here so three x plus four minus y okay
4007
08:39:16,639 --> 08:39:25,599
and i just hit enter and it jumped down so now the second equation
4008
08:39:29,759 --> 08:39:36,719
all right so what if i have five times x
4009
08:39:46,880 --> 08:39:53,600
plus five here we go and notice the space minus y
4010
08:39:53,599 --> 08:40:05,199
here we go hit enter it jumps down and there we go we have an x
4011
08:40:13,520 --> 08:40:15,840
all right and then solving graph which
4012
08:40:15,840 --> 08:40:24,240
which in in this whole course the solving graph we have the
4013
08:40:28,479 --> 08:40:33,759
you'll see as we build and you know you get more and more familiar
4014
08:40:33,759 --> 08:40:41,759
ways to solve and graph then you'll see that we can get more and
4015
08:40:41,759 --> 08:40:51,759
here we're going to import matplot library and simpy and numpy so
4016
08:40:53,520 --> 08:41:03,760
so this one here we're just doing this with linear equations and
4017
08:41:03,759 --> 08:41:16,639
notice i'm only asking for m and b separated by a comma so i'll
4018
08:41:19,040 --> 08:41:28,000
i'm going to split that and make that an array and from that i'm
4019
08:41:28,000 --> 08:41:36,639
the first one and that must be m and then the next one that must
4020
08:41:36,639 --> 08:41:44,479
this input i wanted it separated by a comma so then we're going to
4021
08:41:44,479 --> 08:41:55,919
input is a string splitting the string makes the array and then
4022
08:41:55,919 --> 08:42:07,759
array the first element element zero i'm going to cast it as a
4023
08:42:07,759 --> 08:42:13,679
the second element i'm going to cast it as a float and that's
4024
08:42:13,680 --> 08:42:20,479
the same thing for the second one m and b and then everything's
4025
08:42:20,479 --> 08:42:29,040
split it at the comma makes that array and then that array the
4026
08:42:29,040 --> 08:42:34,479
second element cast as a float b2 and now that i have these
4027
08:42:37,200 --> 08:42:45,119
i can solve it so here we're using simpy to solve it because i'm
4028
08:42:45,119 --> 08:42:50,959
i'm going to give it this variable first is this because i know it
4029
08:42:50,959 --> 08:42:57,439
mx plus b so it'd be m1 times x plus b1 and then minus y that
4030
08:42:59,599 --> 08:43:13,680
and then linsolve first second and then i'm going to just in case
4031
08:43:16,000 --> 08:43:20,880
just in case there's a weird solution i want to take that
4032
08:43:20,880 --> 08:43:29,520
to three decimal places so i'll take that solution cast as a float
4033
08:43:29,520 --> 08:43:39,760
places for many things you know i might not need it but i give
4034
08:43:39,759 --> 08:43:47,759
comes up it works so there we go solution i'm going to find these
4035
08:43:47,759 --> 08:43:54,639
um three decimal places round them and now i have these the x
4036
08:43:56,639 --> 08:44:02,079
so then to make sure the window includes it rather than give it to
4037
08:44:04,799 --> 08:44:11,360
my normal window and this is a float so if i cast as an integer
4038
08:44:11,360 --> 08:44:20,639
and then i can add 20 subtract 20 you know i gave it each of these
4039
08:44:20,639 --> 08:44:25,599
solutions i cast it as an integer and i know that my graph is
4040
08:44:26,799 --> 08:44:32,319
and then given these you know points how many points do i want and
4041
08:44:32,319 --> 08:44:40,159
and then graph x because i already used x in other places so graph
4042
08:44:41,279 --> 08:44:44,719
for my x values so there we go min max how many points
4043
08:44:47,200 --> 08:44:57,440
and here's my y1 is m1 times graph x plus b1 and everything here
4044
08:44:57,439 --> 08:45:11,840
graph x plus b2 so then when we set up the graph and line one
4045
08:45:13,680 --> 08:45:23,439
and the point so now i'm going to plot the point which is x
4046
08:45:23,439 --> 08:45:34,000
okay so that way whatever equations we have and then print out the
4047
08:45:40,080 --> 08:45:46,480
so if we take a look at this x solution y solution we run this
4048
08:45:46,479 --> 08:45:56,799
this first equation all right so let's see let's call it three
4049
08:46:06,639 --> 08:46:13,680
one oh because i didn't put the comma
4050
08:46:17,360 --> 08:46:22,799
so three five and negative one
4051
08:46:36,159 --> 08:46:47,759
so we have these and we see these points this is the solution even
4052
08:46:47,759 --> 08:46:53,359
as not a nice integer decimal numbers but then we see the graph
4053
08:46:53,360 --> 08:47:00,240
they intersect and these are kind of the things that we want to
4054
08:47:00,240 --> 08:47:11,120
good way to plot and graph where if you know that it's linear then
4055
08:47:12,880 --> 08:47:19,760
and we can do that for other types of types of functions you know
4056
08:47:22,080 --> 08:47:25,200
when we get to all the parent graphs and all the different types
4057
08:47:25,200 --> 08:47:30,639
you see that this is one way we can prompt for you know if it's
4058
08:47:30,639 --> 08:47:37,279
coefficients and then that works out to solve use those
4059
08:47:37,279 --> 08:47:44,239
simpy to solve and use them again in that plot library to graph
4060
08:47:44,880 --> 08:47:48,080
display the answer all right pretty good
4061
08:47:54,400 --> 08:48:03,440
so the next thing we have is quadratic functions when it's not a
4062
08:48:03,439 --> 08:48:11,919
anymore not not a nice straight line so anything that involves x
4063
08:48:11,919 --> 08:48:18,719
is a quadratic so x squared because it could be the area of a
4064
08:48:18,720 --> 08:48:25,440
the side but i know that the area would be that side times itself
4065
08:48:25,439 --> 08:48:32,879
there there's going to be a parabola and here's the simplest
4066
08:48:32,880 --> 08:48:42,080
plus bx plus c so b and c could be zero they can be any number
4067
08:48:42,080 --> 08:48:44,880
because if a was zero then i don't have a quadratic
4068
08:48:47,919 --> 08:48:56,719
so then you know there's the simplest one so now let's take a look
4069
08:48:56,720 --> 08:49:03,520
back to our graphing setting up our points you know range our
4070
08:49:03,520 --> 08:49:12,000
up the graph and i'm just going to have a basic y equals x squared
4071
08:49:12,000 --> 08:49:24,560
squared and if we run this that's the most basic parabola so a in
4072
08:49:24,560 --> 08:49:31,440
a in that case would be one and you see it does touch it zero zero
4073
08:49:33,360 --> 08:49:41,840
so now quadratic function abc's let's take a look at abc and let's
4074
08:49:44,000 --> 08:49:49,200
and we're going to use these widgets so
4075
08:49:49,200 --> 08:49:57,600
so this one here all right you have a and b but we forgot c and we
4076
08:49:58,880 --> 08:50:05,360
put the values on you know in a different way but just did it this
4077
08:50:07,279 --> 08:50:16,079
now notice here it's our interactive that we want ab and c so
4078
08:50:16,080 --> 08:50:22,880
f and we see function here of ab but i want ab and c so
4079
08:50:24,959 --> 08:50:28,239
that's that's going to be your that'd be your assignment add c to
4080
08:50:31,040 --> 08:50:42,159
so there we go out here comma c equals and then i'll do the same
4081
08:50:42,159 --> 08:50:51,840
nine okay so there we go so now i have this interactive i'm going
4082
08:50:51,840 --> 08:51:05,200
for a one for b one for c and then when we define the function abc
4083
08:51:05,200 --> 08:51:15,920
and the plot is going to be ax squared plus bx and then we have to
4084
08:51:20,799 --> 08:51:27,119
so now when we run it now it's all zeros that doesn't look like
4085
08:51:27,119 --> 08:51:35,919
as soon as a is something now we have a parabola whether it be one
4086
08:51:35,919 --> 08:51:42,239
what does a do to the parabola you see as a gets bigger the
4087
08:51:44,560 --> 08:51:54,080
and zero we don't have a parabola but negative values it flips it
4088
08:51:54,080 --> 08:52:04,000
negative like a frown and there we go so let's let's have a
4089
08:52:04,000 --> 08:52:10,080
i'm going to skip over b for a second what does c do notice the
4090
08:52:11,599 --> 08:52:16,639
and c just moves it up or down
4091
08:52:16,639 --> 08:52:22,000
and could be zero that's fine it just touches it zero zero so
4092
08:52:22,000 --> 08:52:35,200
down the y-axis and then b is the most interesting it moves it
4093
08:52:35,200 --> 08:52:43,040
little bit now watch what happens when we move it so that was a
4094
08:52:43,040 --> 08:52:55,360
but now when b if b is zero it's symmetrical on the y-axis but
4095
08:52:56,159 --> 08:53:03,279
positive b value stretches on this side so there we go some
4096
08:53:03,279 --> 08:53:06,479
the a b and c and what they each do to the graph
4097
08:53:06,479 --> 08:53:12,159
so this bottom part or if it's flipped over that'd be the top part
4098
08:53:12,159 --> 08:53:22,720
that's the vertex so that's the point where the parabola turns
4099
08:53:22,720 --> 08:53:31,440
you the formula here negative b over 2a so the parabola turns
4100
08:53:31,439 --> 08:53:39,199
negative b over 2a so then given those inputs
4101
08:53:43,200 --> 08:53:50,240
then we're going to create the parabola now this i even have the
4102
08:53:51,520 --> 08:53:58,959
because certainly i can print x with the two asterisks for the
4103
08:53:58,959 --> 08:54:04,479
um just another fancier way to output this and you'll see it'll
4104
08:54:04,479 --> 08:54:11,520
it'll look like an exponent so supposing then we just prompt for
4105
08:54:13,040 --> 08:54:18,639
we know we know we're doing a parabola so we just prompt for these
4106
08:54:18,639 --> 08:54:30,239
then what would be the vertex well the x value was negative b over
4107
08:54:30,240 --> 08:54:37,920
going to do negative b divided by and the 2a both all that needs
4108
08:54:37,919 --> 08:54:46,799
need the parentheses so negative b over 2a because if i don't
4109
08:54:46,799 --> 08:54:56,319
do an order of operations now if i have that value then given that
4110
08:54:56,319 --> 08:55:06,319
x value so we have a times and remember the general form of
4111
08:55:06,319 --> 08:55:22,159
i have i have vx is my x value squared plus b x so that'd be vx
4112
08:55:22,159 --> 08:55:32,000
vertex plus c so there we go so i use this a b and c to get the x
4113
08:55:32,000 --> 08:55:37,680
and then i'm going to plug that in to get the y value of the
4114
08:55:39,599 --> 08:55:47,840
and then x minimum so for whatever we enter we'll just make sure
4115
08:55:48,639 --> 08:55:55,840
so counting whatever these values are and you know there you go
4116
08:55:55,840 --> 08:56:03,840
take it as an integer and that's 10 minus 10 there we go and it's
4117
08:56:04,400 --> 08:56:11,120
so notice just that x value just that y value as a red point and
4118
08:56:13,520 --> 08:56:18,560
i probably could have done this based on x min x max but just
4119
08:56:18,560 --> 08:56:26,560
the lin space just giving us that enough before and after it and
4120
08:56:26,560 --> 08:56:32,400
we plot x y without the third argument by default it's going to be
4121
08:56:32,400 --> 08:56:40,400
the color so let's see let's take a look so it's going to show us
4122
08:56:40,400 --> 08:56:47,040
that little two that was the whole idea to get it to be that fancy
4123
08:56:47,040 --> 08:57:05,680
one a is one and b is let's say negative negative five and c is
4124
08:57:05,680 --> 08:57:16,799
so we see the vertex and the vertex is 2.5 negative 0.25 and we
4125
08:57:16,799 --> 08:57:28,159
we see the vertex plotted so pretty cool and that's it just same
4126
08:57:28,159 --> 08:57:34,720
those coefficients and run it through those formulas we can plot
4127
08:57:34,720 --> 08:57:41,520
we did the linear equation plotted for m and b we can do a
4128
08:57:45,040 --> 08:57:52,479
so you know we could we could do this again and see some different
4129
08:57:52,479 --> 08:58:01,599
at how to apply these parabola qualities to projectile motion and
4130
08:58:01,599 --> 08:58:08,959
through the air is a projectile and they all actually make the
4131
08:58:09,680 --> 08:58:17,439
pretty interesting it can't not be a parabola so as we look at
4132
08:58:18,880 --> 08:58:23,200
the graph of this that we're going to look at is going to be for
4133
08:58:24,560 --> 08:58:30,400
straight up in the air so in this case the a value is going to be
4134
08:58:30,400 --> 08:58:36,080
because it accounts for gravity and that would be in meters per
4135
08:58:36,080 --> 08:58:42,640
the a value stays the same the b value represents the initial
4136
08:58:42,639 --> 08:58:49,680
on how hard you throw the ball up in the air or launch something
4137
08:58:49,680 --> 08:58:55,680
velocity is b and then the c value is the initial height so c
4138
08:58:55,680 --> 08:59:02,959
the ground you know like kicking kicking a ball and if it was on
4139
08:59:02,959 --> 08:59:09,200
the ball is a parabola and then in that case c would be zero the
4140
08:59:10,000 --> 08:59:17,439
we have our classic quadratic ax squared plus bx plus c and in
4141
08:59:17,439 --> 08:59:25,919
seconds and then y is the height at any given time so let's take a
4142
08:59:25,919 --> 08:59:33,439
what we were just doing but a little bit different so a stays
4143
08:59:33,439 --> 08:59:38,399
prompt for that if it's a projectile that's going to stay the same
4144
08:59:39,360 --> 08:59:45,360
i'm going to prompt for it and cast it as a float because remember
4145
08:59:45,360 --> 08:59:53,119
so rather than just say oh what's b i'll prompt it as initial
4146
08:59:54,880 --> 09:00:04,639
now once we have those you can and i already did copy the vx and
4147
09:00:04,639 --> 09:00:13,360
the equations for the vertex are exactly the same so you know once
4148
09:00:13,360 --> 09:00:24,400
same formulas vx and vy then if i'm going to graph it i'm going to
4149
09:00:24,400 --> 09:00:30,319
always 10 in every direction just seems like a good starting point
4150
09:00:30,319 --> 09:00:35,759
to be concerned about positive values here so i made x min
4151
09:00:35,759 --> 09:00:43,279
negative just so that you can see the axis same with y min made a
4152
09:00:43,279 --> 09:00:51,840
can see the axis but any negative values won't apply here now
4153
09:00:51,840 --> 09:01:02,159
up here so how do i get these well the x value i'll tell you this
4154
09:01:02,639 --> 09:01:07,599
so the x value of the vertex is exactly right down the middle
4155
09:01:07,599 --> 09:01:13,279
the middle sometimes we call it the line of symmetry so it's
4156
09:01:13,279 --> 09:01:18,719
we know we're dealing with all positive values here so whatever
4157
09:01:18,720 --> 09:01:25,840
i'm going to double it so that's why i have two times vx so there
4158
09:01:25,840 --> 09:01:33,040
it i should be at the end but i just added 20 just to be sure we
4159
09:01:33,040 --> 09:01:39,840
maybe a little bit more it just gives a good perspective on the
4160
09:01:39,840 --> 09:01:44,720
x value double it i decided to add 20 but then we have to cast it
4161
09:01:44,720 --> 09:01:53,680
ones came in as float values and your dimensions here have to be
4162
09:01:53,680 --> 09:02:00,560
sit with the y value i'll take that vy and yep that's the vertex
4163
09:02:00,560 --> 09:02:07,840
point of our projectile and i'm just going to add 10 to it i
4164
09:02:07,840 --> 09:02:13,840
you can see see this and it's not right at the edge also casting
4165
09:02:13,840 --> 09:02:21,920
need to be integers so this should look familiar we don't need to
4166
09:02:21,919 --> 09:02:29,199
changed this to four just to give you know four times this just
4167
09:02:29,200 --> 09:02:33,920
graph isn't choppy two might even have been enough but there you
4168
09:02:33,919 --> 09:02:40,000
to the graph and there we go we define the x values same function
4169
09:02:40,000 --> 09:02:50,240
then that that that will work again we need these to be integers
4170
09:02:50,240 --> 09:02:59,520
value as our quadratic ax squared plus bx plus c so now we're
4171
09:02:59,520 --> 09:03:08,479
been doing plot and then we're also going to plot you know a red
4172
09:03:08,479 --> 09:03:13,119
so all this is going to be very similar but you'll see the
4173
09:03:13,119 --> 09:03:18,399
then the graph the scale will be a little bit different so when we
4174
09:03:18,400 --> 09:03:27,680
uh let's call it 40 and initial height two so this could be
4175
09:03:27,680 --> 09:03:32,639
up in the air you know you could probably throw it at 40 meters
4176
09:03:32,639 --> 09:03:41,360
by the time you release it yeah it's about two meters off the
4177
09:03:41,360 --> 09:03:48,560
see these and you could always round these i didn't for this but
4178
09:03:48,560 --> 09:03:57,360
but we get the value of the vertex now what this means in time is
4179
09:03:57,360 --> 09:04:04,479
you throw the ball up in the air it will hit its maximum height of
4180
09:04:04,479 --> 09:04:14,959
83.6 meters so there we go if you could throw a ball you know that
4181
09:04:14,959 --> 09:04:20,959
reason i have the negatives you see the blue for the for the axis
4182
09:04:20,959 --> 09:04:27,119
a ball at 40 meters per second then uh straight up and you know
4183
09:04:27,119 --> 09:04:37,439
you know 83 meters in the air and then time wise you know four set
4184
09:04:37,439 --> 09:04:42,479
where it's going to hit its highest point and then a little more
4185
09:04:42,479 --> 09:04:48,880
ground so there we go we can see what our parabola would be and
4186
09:04:48,880 --> 09:04:54,240
different things relating to parabolas whether it be a ball thrown
4187
09:04:54,240 --> 09:05:03,520
yeah there we go so see i i just broke this out as you know see if
4188
09:05:03,520 --> 09:05:14,560
see just shifts the graph and here we're going to import all these
4189
09:05:14,560 --> 09:05:23,600
than put a slider just decided to make this and i made it a
4190
09:05:23,599 --> 09:05:34,799
take a look uh our x values and then we plot we decided to make
4191
09:05:36,000 --> 09:05:42,080
and if we take a look so what do we want in in this range
4192
09:05:43,680 --> 09:05:49,599
i'm going to actually didn't use c itself as a as a variable
4193
09:05:49,599 --> 09:05:58,879
this range then i made it negative x squared plus c and then what
4194
09:05:58,880 --> 09:06:08,480
plot it you know to find the x values ones up here and here's the
4195
09:06:09,040 --> 09:06:14,959
and this just i did that just for the sake of setting the title
4196
09:06:14,959 --> 09:06:21,199
so you'll see how you'll see how that comes up in the title and
4197
09:06:23,199 --> 09:06:33,759
and this little this little display here you'll see how that that
4198
09:06:33,760 --> 09:06:48,880
the notice i don't have the defining x min max y min y max this uh
4199
09:06:48,879 --> 09:06:58,639
just make the graph fit and each time so here's a python sleep
4200
09:06:58,639 --> 09:07:02,800
just in seconds sometimes sleep methods are in milliseconds this
4201
09:07:02,800 --> 09:07:12,160
so i wanted to display that and then wait a half a second then
4202
09:07:14,800 --> 09:07:22,240
and then wait so you'll see it'll display this and then clear the
4203
09:07:25,680 --> 09:07:35,599
so all those different c values we can see it grow and we can run
4204
09:07:36,480 --> 09:07:50,160
so all those different c values and notice the the y-axis changed
4205
09:07:50,160 --> 09:07:58,720
the larger graph so we can see that value all i have to do is you
4206
09:07:59,279 --> 09:08:03,680
and it's the same shape it just moves up there we go
4207
09:08:06,160 --> 09:08:13,120
okay so we found the vertex but the quadratic formula since we're
4208
09:08:13,120 --> 09:08:19,360
equations what does this do this gives you the roots now if it was
4209
09:08:19,360 --> 09:08:25,520
now if it was a projectile that would be when it hits the ground
4210
09:08:25,519 --> 09:08:31,279
think about it you know ground level is the x-axis and then you
4211
09:08:31,279 --> 09:08:36,879
then you know like roots of anything growing you know wants to go
4212
09:08:36,879 --> 09:08:42,959
roots they are the x-intercepts because it's where the line
4213
09:08:42,959 --> 09:08:51,599
the zeros because y equals zero so you'll see it come up with all
4214
09:08:51,599 --> 09:09:02,159
if i know a b and c here's the formula if i were to write it not
4215
09:09:02,160 --> 09:09:09,200
what x value makes y zero that's the question so that x value
4216
09:09:09,199 --> 09:09:16,639
the square root of b squared minus four ac and all of that over
4217
09:09:16,639 --> 09:09:23,120
minus because somewhere along the way deriving this you do a
4218
09:09:23,120 --> 09:09:28,959
you have two possible answers so that and that's what it gives you
4219
09:09:30,160 --> 09:09:37,680
but also notice this is the common way you write it but this it's
4220
09:09:37,680 --> 09:09:45,519
so we often write it like this you know all over one denominator
4221
09:09:45,519 --> 09:09:57,279
vertex you recognize that formula plus this and then the vertex
4222
09:09:57,279 --> 09:10:02,159
another just another way to write it whether you split it into two
4223
09:10:02,160 --> 09:10:08,160
together over one denominator but when you write it this way then
4224
09:10:08,160 --> 09:10:15,680
plus or minus something and again we were saying that x value of
4225
09:10:15,680 --> 09:10:22,000
so it would make sense that that value right in the middle and
4226
09:10:22,000 --> 09:10:26,639
value minus something you know that's where we get our two roots
4227
09:10:26,639 --> 09:10:35,040
you know they're symmetrical all right so given a b and c we have
4228
09:10:40,000 --> 09:10:43,519
i have again here i'm just going to import math because i need
4229
09:10:44,559 --> 09:10:51,599
and i have it printed out like this where i just have the comment
4230
09:10:51,599 --> 09:10:57,599
prints two as an exponent i think that's just a little bit nicer
4231
09:10:57,599 --> 09:11:04,000
found how to print that out nicer so you're going to print this
4232
09:11:04,000 --> 09:11:10,480
all right ax squared plus bx plus c equals zero and given that
4233
09:11:10,480 --> 09:11:23,200
b and c so there we go now here this is where you're going to
4234
09:11:23,199 --> 09:11:27,199
we'll define these variables here they're zero but we're going to
4235
09:11:27,199 --> 09:11:35,599
a little bit later because i want to define these variables that
4236
09:11:35,599 --> 09:11:42,959
statement but i want to run it through this if statement here now
4237
09:11:42,959 --> 09:11:52,559
minus four times a times c because remember that's what's
4238
09:11:54,239 --> 09:12:01,519
and if that was negative then your answer is imaginary because you
4239
09:12:01,519 --> 09:12:08,079
number now certainly you know some mathematicians you know years
4240
09:12:08,080 --> 09:12:15,279
that stop us if they're not real but for our purposes here we
4241
09:12:15,279 --> 09:12:21,199
the square root we're not going to go into imaginary numbers so
4242
09:12:22,400 --> 09:12:28,880
is less than zero then we're going to print no real roots and this
4243
09:12:28,879 --> 09:12:36,399
this stuff that's underneath the radical here and that's the
4244
09:12:36,400 --> 09:12:43,040
minus four ac if that was less than zero then there's no real
4245
09:12:43,040 --> 09:12:48,959
zero then this plus or minus doesn't mean anything because plus
4246
09:12:48,959 --> 09:12:54,000
so if that equals zero then there would be one root and then any
4247
09:12:54,000 --> 09:13:00,160
two roots and i think that still comes out the most common it's
4248
09:13:00,160 --> 09:13:06,320
these other options come out often enough no real roots what that
4249
09:13:06,319 --> 09:13:12,480
is a parabola that does not touch or cross the x-axis so you could
4250
09:13:13,680 --> 09:13:20,959
just parabola and it opens up and crosses early you know at some
4251
09:13:20,959 --> 09:13:27,120
you so that's the discriminant and knowing that tells us you know
4252
09:13:27,120 --> 09:13:32,560
than zero then there's no real roots it if it if we only have one
4253
09:13:32,559 --> 09:13:39,439
only one root we're just going to print that out twice and not
4254
09:13:39,440 --> 09:13:48,480
to translate this this quadratic formula into this well we're
4255
09:13:48,480 --> 09:13:52,400
going to do the very similar thing just one's going to be plus in
4256
09:13:52,400 --> 09:14:02,959
minus so let's try this so we have negative b let's do the plus
4257
09:14:15,360 --> 09:14:26,480
c all right now all of that remember was in the numerator so i'm
4258
09:14:26,480 --> 09:14:34,319
all this as the numerator and then divided by our vertex
4259
09:14:38,319 --> 09:14:52,480
okay so order of operations all this stuff python will know but
4260
09:14:52,480 --> 09:14:56,560
denominator i'll put everything in the numerator in parentheses
4261
09:14:56,559 --> 09:15:06,000
denominator in parentheses and then the second root i can really
4262
09:15:06,000 --> 09:15:11,839
and paste it here but the difference is it's going to be minus
4263
09:15:14,959 --> 09:15:25,360
there we go so now a lot of things you can do that you know in
4264
09:15:25,360 --> 09:15:29,599
we already did the vertex and that and finding the roots these are
4265
09:15:29,599 --> 09:15:36,959
you need to do with a quadratic formula so having this there we go
4266
09:15:36,959 --> 09:15:45,519
so let's just try numbers that work out pretty nicely one and we
4267
09:15:45,519 --> 09:15:54,319
try that look at that the roots are negative two and three good
4268
09:15:54,319 --> 09:16:05,040
nice integers but this will still work if you have you know like
4269
09:16:08,400 --> 09:16:15,599
you see it does have roots definite real roots but since it
4270
09:16:15,599 --> 09:16:18,799
and there's actually like a more complicated square root answer
4271
09:16:18,800 --> 09:16:24,880
this that could be a bonus bonus thing to do to output that square
4272
09:16:26,480 --> 09:16:32,400
so there we go the roots are this and this and you could always
4273
09:16:33,360 --> 09:16:39,120
expecting you know that you might have some weird irrational roots
4274
09:16:39,120 --> 09:16:46,000
three or four decimal places and i'll leave it up to you if you
4275
09:16:46,000 --> 09:16:52,800
all together and have something where whatever the application you
4276
09:16:54,000 --> 09:17:00,160
get the roots in the vertex and graph it you know as well as
4277
09:17:00,959 --> 09:17:07,440
so you know just to show you you know we can put these two things
4278
09:17:07,440 --> 09:17:15,279
interesting things you can try so sometimes the graph i like the
4279
09:17:15,279 --> 09:17:23,519
i'm much more interested in just a table of values so in this case
4280
09:17:25,279 --> 09:17:31,040
i made this linear so here we go we have this now notice i didn't
4281
09:17:32,080 --> 09:17:39,840
a fig dot or a comma x i just have x equals so i'm not going to
4282
09:17:39,839 --> 09:17:50,239
here the graph i just want this because this plt dot subplot in
4283
09:17:50,239 --> 09:17:58,720
going to give us a table and access off right because i just want
4284
09:17:58,720 --> 09:18:03,680
we're going to we're going to give it a title we're going to run
4285
09:18:03,680 --> 09:18:11,120
and notice how this works i can define my columns and i could use
4286
09:18:11,120 --> 09:18:22,800
it cols for columns so i can define my column headings and then
4287
09:18:22,800 --> 09:18:33,360
tuple of values so in this case in the first row x is zero and y
4288
09:18:35,680 --> 09:18:44,879
and then what i can do is in this case since i have this for a in
4289
09:18:44,879 --> 09:18:55,199
it from one to ten here's what we do rows dot append and then i'm
4290
09:18:55,199 --> 09:19:02,000
values you see so x is my a value whatever that's going to end up
4291
09:19:02,000 --> 09:19:09,440
then two then three and then two a you know just something simple
4292
09:19:09,440 --> 09:19:18,639
is how you can get a table of values rather than graph it you can
4293
09:19:18,639 --> 09:19:30,959
row so you set the columns set the first row and then append each
4294
09:19:32,400 --> 09:19:37,680
x dot set title i've already defined it up there and then take a
4295
09:19:37,680 --> 09:19:45,840
and it takes the argument cell text equals rows column label
4296
09:19:45,839 --> 09:19:55,839
know i feel like that's uh that location's you know okay this goes
4297
09:19:55,839 --> 09:20:08,159
just close the parentheses there just to show you so it's still
4298
09:20:08,160 --> 09:20:15,520
what we're showing is a table instead of a graph and you see how
4299
09:20:15,519 --> 09:20:24,000
both so you know that would be that would always be something you
4300
09:20:24,000 --> 09:20:30,319
table on the graph but who knows maybe you want one or the other
4301
09:20:30,319 --> 09:20:37,199
data science this is like an introduction there's some things you
4302
09:20:37,199 --> 09:20:45,199
or things like that but as you get into you know in the next math
4303
09:20:45,199 --> 09:20:50,559
when we get into the stats course we're going to look at like all
4304
09:20:50,559 --> 09:20:55,360
so this is just one way and you can we'll see even more ways but
4305
09:20:55,360 --> 09:21:00,879
there we go and you could always make this quadratic or whatever
4306
09:21:01,760 --> 09:21:07,680
again just for simplicity to illustrate the table itself i wanted
4307
09:21:07,680 --> 09:21:15,599
equals 3x plus 2 and where do i need to put this well this is just
4308
09:21:15,599 --> 09:21:26,159
correct thing so that's going to be the title and here i this is
4309
09:21:26,160 --> 09:21:36,720
a is my x value so it would be three times a plus two there we go
4310
09:21:36,720 --> 09:21:54,639
it you know and zero zero five ah now zero zero actually should
4311
09:21:55,519 --> 09:22:03,519
now one of the things you can do is you could keep this and then
4312
09:22:03,519 --> 09:22:10,079
and remember for the range at zero you don't need to put anything
4313
09:22:10,879 --> 09:22:19,439
or you could just say oh i know what this initial value is going
4314
09:22:20,480 --> 09:22:22,480
so you know a couple different options there
4315
09:22:27,120 --> 09:22:38,000
so there we go we have our table okay so different ways to display
4316
09:22:38,800 --> 09:22:45,840
have a nice an interesting uh mini project here so we have the
4317
09:22:45,839 --> 09:22:53,839
projectiles so we could have you know we could we could you could
4318
09:22:53,839 --> 09:23:01,199
um so what this would be is remember knowing where you're you're
4319
09:23:02,400 --> 09:23:09,520
randomize the height and location of a wall and you have a toy
4320
09:23:11,680 --> 09:23:16,000
so you can you know the game would be determined what initial
4321
09:23:16,000 --> 09:23:23,199
would get the rocket over the wall and you could take it even
4322
09:23:23,199 --> 09:23:31,279
path or you could you know there's some other things you could do
4323
09:23:31,279 --> 09:23:35,680
to write but i'm going to show you here's one thing you know one
4324
09:23:37,279 --> 09:23:44,080
so we imported all this stuff and actually a lot of the things i
4325
09:23:44,080 --> 09:23:52,080
uh one of the earlier steps where you're graphing a projectile so
4326
09:23:52,559 --> 09:24:06,000
and i'm also going to import random and import math so here i just
4327
09:24:06,000 --> 09:24:15,279
so this is the what it will print out it just has to land so many
4328
09:24:15,279 --> 09:24:22,639
randomize also like h for the height of the wall i just made it
4329
09:24:23,519 --> 09:24:30,879
so here's this random integer between one and a hundred and then
4330
09:24:30,879 --> 09:24:39,199
rocket has to land this many meters away and then we'll go through
4331
09:24:40,959 --> 09:24:49,919
so input initial velocity and instead of it it's zero zero it
4332
09:24:50,559 --> 09:24:57,919
you know just because but it really could be zero and then same
4333
09:24:57,919 --> 09:25:11,040
the vertex here and the x min what i would do is x max now i just
4334
09:25:11,040 --> 09:25:18,000
i know that the wall is going to be you know anywhere between
4335
09:25:18,000 --> 09:25:25,440
i just left it as that so and the y maximum i left it so that you
4336
09:25:25,440 --> 09:25:37,200
projectile goes but we could always go back to what we were doing
4337
09:25:37,199 --> 09:25:51,839
and y maximum the same thing where we get this that where we get x
4338
09:25:51,839 --> 09:26:01,919
we could always copy these because that's what we want to do here
4339
09:26:03,760 --> 09:26:08,880
and that was that was the idea i want you to you know make use of
4340
09:26:08,879 --> 09:26:14,079
these these later steps that's really what what it is i want you
4341
09:26:14,080 --> 09:26:23,120
have and then maybe modify it a little bit there we go we could
4342
09:26:23,120 --> 09:26:29,120
because wherever that wall ends up being or the the finish line
4343
09:26:29,120 --> 09:26:37,680
print everything and that'll be fine there you go path to the
4344
09:26:37,680 --> 09:26:45,680
the lot the line for the distance and i'll just make it a red line
4345
09:26:46,400 --> 09:26:54,160
i just have it go all the way up to the top here location my two x
4346
09:26:54,160 --> 09:27:05,120
y maximum so that's just going to be a line if you wanted to also
4347
09:27:05,120 --> 09:27:11,840
you know h equals and we'll do the same random integer
4348
09:27:16,319 --> 09:27:20,000
where do i want this to be i want this to be i don't want um
4349
09:27:21,120 --> 09:27:25,760
a hundred's probably plenty you could even make it a thousand
4350
09:27:28,239 --> 09:27:31,680
um you'd be surprised you know these rockets um
4351
09:27:43,120 --> 09:27:50,880
so many meters away and there we go so if h would be the height
4352
09:27:50,879 --> 09:28:01,599
the height of the wall would just be h so that's the slight thing
4353
09:28:01,599 --> 09:28:09,519
times the wall the scale of us the wall end up being so tiny but
4354
09:28:09,519 --> 09:28:22,159
that there so there we go so the line and plot the parabola now
4355
09:28:22,160 --> 09:28:30,400
pick just one of them and as it turns out because of the way you
4356
09:28:30,400 --> 09:28:36,160
b minus is the root that we want that's the one that's going to
4357
09:28:36,160 --> 09:28:41,280
that's the one that's going to be greater than the parabola so
4358
09:28:41,279 --> 09:28:49,440
quadratic formula again and the way it displayed i wanted to round
4359
09:28:49,440 --> 09:28:58,880
places so here we have if root two is greater than or equal to
4360
09:28:58,879 --> 09:29:07,839
distance i wanted to print out the distance and then tell you
4361
09:29:07,839 --> 09:29:21,119
much here we go all right so this is it there is actually no test
4362
09:29:21,120 --> 09:29:27,760
here we go a rocket has to clear a wall 85 meters away initial
4363
09:29:27,760 --> 09:29:45,360
my initial velocity 300 and then we see that initial velocity is
4364
09:29:45,360 --> 09:29:55,599
then we're still we didn't clear it so missed it by that much and
4365
09:29:55,599 --> 09:30:02,479
things you can do with this so 19 meters away i'm still going to
4366
09:30:02,480 --> 09:30:12,720
velocity of 250 let's make sure we clear it you see and we see the
4367
09:30:12,720 --> 09:30:21,919
did clear it now some of the other things you can do is you could
4368
09:30:21,919 --> 09:30:31,040
that distance take that as your x value of your vertex and you
4369
09:30:31,040 --> 09:30:40,400
always make a parabola that perfectly that perfectly clears this
4370
09:30:40,400 --> 09:30:48,480
interesting or you could modify this game to say that it has to
4371
09:30:48,480 --> 09:30:55,040
um not necessarily that distance or more but maybe you say all
4372
09:30:55,040 --> 09:31:02,400
exactly 50 meters away and you don't want to miss so that would be
4373
09:31:02,400 --> 09:31:08,959
you could you could actually write the code and i'll leave that to
4374
09:31:08,959 --> 09:31:18,799
as for something you could write the code to calculate the
4375
09:31:20,720 --> 09:31:31,599
so there we go now for this you know upward motion one of the ways
4376
09:31:31,599 --> 09:31:36,639
you know whatever the distance half of that and then that's your x
4377
09:31:36,639 --> 09:31:46,080
of the of the vertex and you can use that to calculate you can you
4378
09:31:46,080 --> 09:31:51,919
some formulas and as i said we'll get even better formulas as we
4379
09:31:51,919 --> 09:31:58,559
we will do things to adjust the angle and such to get it to be
4380
09:31:58,559 --> 09:32:05,199
so showing you how to make a projectile game i think it's pretty
4381
09:32:05,199 --> 09:32:09,599
you know that you could and you could even make it you know like
4382
09:32:09,599 --> 09:32:19,199
have to how many ones do you get correct but there you go the
4383
09:32:19,199 --> 09:32:23,119
the this is going to be more like the open-ended part all the
4384
09:32:23,120 --> 09:32:33,920
you you should put this together in a function that will graph or
4385
09:32:33,919 --> 09:32:39,199
a table solve a system of equations now if you've been working
4386
09:32:39,199 --> 09:32:48,559
you might have some of this already put together and that's where
4387
09:32:48,559 --> 09:32:54,559
here is you know hopefully you've built up to this so you know you
4388
09:32:54,559 --> 09:33:00,319
i know how to do this and i have some of this stuff in place so
4389
09:33:00,319 --> 09:33:04,959
organize it use some of the code that you've already made you know
4390
09:33:04,959 --> 09:33:13,919
different functions because then you get to the certification
4391
09:33:13,919 --> 09:33:18,799
display you know this is what you want to do build the calculator
4392
09:33:18,800 --> 09:33:26,080
and a table for any y equals input cool and you can make that
4393
09:33:26,080 --> 09:33:31,919
very clear in the code that you know here's where the equation is
4394
09:33:31,919 --> 09:33:40,239
graphing graph two equations and plot the point of intersection so
4395
09:33:40,239 --> 09:33:46,720
pretty big you know graphing the two solving and graphing and
4396
09:33:46,720 --> 09:33:53,200
in the vertex so that'd be some things you know we've been doing
4397
09:33:53,199 --> 09:33:59,599
do some things with quadratics enter a b and c see the graph plot
4398
09:33:59,599 --> 09:34:05,040
maybe also print them out you know solving and graphing systems of
4399
09:34:06,000 --> 09:34:10,400
showing the table and then you have you know these projectile
4400
09:34:10,400 --> 09:34:16,000
game you have the scatter plot game you can even modify that
4401
09:34:16,000 --> 09:34:21,120
you know something else that might be interesting so there you go
4402
09:34:21,120 --> 09:34:26,480
working on you put it all together to build this graphing
4403
09:34:26,480 --> 09:34:34,480
certification project and by now you're even deeper you know what
4404
09:34:35,839 --> 09:34:41,279
we're about to then have some more twists and see some more
4405
09:34:43,279 --> 09:34:52,959
so what do we mean by parent graphs and we'd have heard this in
4406
09:34:53,599 --> 09:34:57,199
child graphs have everything that the parent graphs have plus some
4407
09:34:57,839 --> 09:35:06,719
additions and so these paragraphs are the basic patterns that
4408
09:35:06,720 --> 09:35:13,120
so let's take a look at this the one the most basic would be y
4409
09:35:13,120 --> 09:35:21,920
just call c here and so that would be this blue line here just a
4410
09:35:21,919 --> 09:35:26,400
y equals three or y equals four or something like that it could
4411
09:35:27,199 --> 09:35:34,639
nothing else and whatever the constant is it's always going to be
4412
09:35:34,639 --> 09:35:40,879
call it a parent graph and whatever the constant is that graph's
4413
09:35:41,680 --> 09:35:46,559
you know flat no slope you know nothing else going on just y
4414
09:35:47,120 --> 09:35:52,319
and that's why it's a parent graph because that's like the basic
4415
09:35:52,319 --> 09:35:59,120
things like y equals mx plus b well the paragraph for that is y
4416
09:35:59,120 --> 09:36:06,880
b is zero and just that basic it's not y equals a constant because
4417
09:36:07,760 --> 09:36:14,480
right the paragraph is just y equals x and then we can get like y
4418
09:36:14,480 --> 09:36:21,440
or anything like that we can have other things so this wouldn't
4419
09:36:21,440 --> 09:36:26,880
things you know i have a slope or i could have a different
4420
09:36:26,879 --> 09:36:32,239
this so that's the parent graph another one i wanted to show here
4421
09:36:32,239 --> 09:36:37,360
of this works better than somehow sometimes how it plays out with
4422
09:36:37,360 --> 09:36:43,680
function and so it's this step function some people call it step
4423
09:36:43,680 --> 09:36:48,720
greatest integer but the floor is when you're not rounding you're
4424
09:36:48,720 --> 09:36:54,559
it's 0.9 doesn't matter we're just dropping all the decimals so
4425
09:36:54,559 --> 09:37:02,720
these decimals it's zero until i get to one now it's one and then
4426
09:37:02,720 --> 09:37:09,840
until i get to two so that's it there there are no in between
4427
09:37:10,480 --> 09:37:16,720
and then at the next integer it jumps up so again that's a parent
4428
09:37:16,720 --> 09:37:22,959
the ceiling function where no matter what it is i go up to the
4429
09:37:22,959 --> 09:37:27,919
they're all very similar looking graphs just shifted a little bit
4430
09:37:27,919 --> 09:37:36,639
a parent graph we talked about x squared as a parabola and i
4431
09:37:36,639 --> 09:37:42,239
even the axes for these because i want to get the idea of this
4432
09:37:42,239 --> 09:37:48,720
it's kind of like half this parabola bends down now the reason why
4433
09:37:48,720 --> 09:37:55,279
as you get into like x to the fourth x to the fifth all the even
4434
09:37:55,279 --> 09:38:01,760
graph look more like this all the odd ones look more like this but
4435
09:38:01,760 --> 09:38:09,520
going on in that graph so remember x squared could have ax squared
4436
09:38:09,519 --> 09:38:13,759
had other things going on it's still a parabola but it's a little
4437
09:38:13,760 --> 09:38:18,880
maybe it's like a little bit narrower a little bit wider or it
4438
09:38:18,879 --> 09:38:29,439
still be a parabola the x to the third if i end up with x to the
4439
09:38:30,720 --> 09:38:34,239
then that those curves get a little bit deeper
4440
09:38:34,239 --> 09:38:44,159
or you know that's you know again paragraph and then beyond that
4441
09:38:44,160 --> 09:38:49,600
and we'll take a look at some of this in the code too and the same
4442
09:38:51,199 --> 09:38:56,079
so x to the fourth is going to look more like this maybe a little
4443
09:38:56,080 --> 09:39:01,520
but if i had x to the fourth plus a bunch of other things in there
4444
09:39:01,519 --> 09:39:08,159
something else times x you know all these other things that could
4445
09:39:08,160 --> 09:39:15,680
most you know x to the fourth could turn around one two three
4446
09:39:15,680 --> 09:39:23,680
always perfectly symmetrical but if all the if all the exponents
4447
09:39:23,680 --> 09:39:29,440
symmetrical kind of cool it works out that way so these other
4448
09:39:29,440 --> 09:39:35,440
we could have other things going on and i didn't want to draw a
4449
09:39:35,440 --> 09:39:40,800
talk mostly about it when we get to the code because that way we
4450
09:39:40,800 --> 09:39:44,639
way python displays the graph is going to be much better than my
4451
09:39:44,639 --> 09:39:50,639
parent graphs these are the basic patterns the simplest pattern of
4452
09:39:50,639 --> 09:39:57,279
and then we can look at what what else we can change or add to to
4453
09:39:57,279 --> 09:40:02,799
that affects the graph so let's take a look at the code so here
4454
09:40:02,800 --> 09:40:09,360
parent graphs and the code to create them and they're all going to
4455
09:40:09,360 --> 09:40:17,520
setup we've had so far for setting up any plot mat plot library
4456
09:40:17,519 --> 09:40:27,519
our points set up the graph so this simplest one is a just a
4457
09:40:27,519 --> 09:40:35,519
equaled any constant number notice x is not even in there just y
4458
09:40:35,519 --> 09:40:46,479
this in the same way that i'm plotting the x-axis i'm just going
4459
09:40:46,480 --> 09:40:51,200
minimum to the maximum and then y is just always going to be five
4460
09:40:51,199 --> 09:40:58,799
a red line and that's what it looks like it's a flat line there's
4461
09:40:58,800 --> 09:41:08,639
that whole part of the equation no x value and y is just always
4462
09:41:08,639 --> 09:41:15,279
y equals you know seven point five or y equals two or you know
4463
09:41:15,279 --> 09:41:17,760
no slope so that's a constant graph
4464
09:41:20,720 --> 09:41:24,880
and then the linear graphs we were talking about linear graphs but
4465
09:41:24,879 --> 09:41:35,360
the simplest linear graph y equals x so anything else i do with
4466
09:41:35,360 --> 09:41:43,680
in this case it's y equals one x so the slope is one plus zero so
4467
09:41:43,680 --> 09:41:49,919
so again the simplest and then anything else i do that is an
4468
09:41:51,919 --> 09:41:58,400
so there's our simplest and notice everything else i do to set
4469
09:41:58,400 --> 09:42:08,880
my x value and then the y value is x so there we go x x and
4470
09:42:08,879 --> 09:42:14,399
the slope is one and it just goes on the diagonal like this there
4471
09:42:15,199 --> 09:42:20,000
so every point here you know three three four four five five etc
4472
09:42:23,680 --> 09:42:30,400
so the quadratics we were looking at quadratics this is this basic
4473
09:42:30,400 --> 09:42:39,760
y equals x squared so before i do anything else to it that's just
4474
09:42:40,080 --> 09:42:46,400
and here we're plotting this my x values and then the y value is x
4475
09:42:49,440 --> 09:42:59,760
so our parabola so in this case you know x squared so a is one b
4476
09:43:00,639 --> 09:43:07,680
and then any other thing we do to the x squared you know add other
4477
09:43:08,480 --> 09:43:15,120
uh three x plus four or something like that or some you know
4478
09:43:15,120 --> 09:43:22,959
is uh an offshoot of this paragraph so there we go and i can make
4479
09:43:24,720 --> 09:43:33,120
and we see the negative a flips it upside down so we have you know
4480
09:43:33,120 --> 09:43:41,520
like a smile so i'll go back to the smile there we go again the
4481
09:43:41,519 --> 09:43:50,079
x squared and then a cubic graph y equals x to the third so the
4482
09:43:50,080 --> 09:43:56,480
it's like the area of a square if i know the sides the cubic x to
4483
09:43:56,480 --> 09:44:04,480
volume of a cube if i know the sides so setting up the graph here
4484
09:44:04,480 --> 09:44:12,800
about later just starting out with the basic x to the third and we
4485
09:44:14,800 --> 09:44:22,319
so some you know some of these you know i could sketch it out
4486
09:44:22,319 --> 09:44:27,519
kind of looks like a parabola with the left side flipped down but
4487
09:44:27,519 --> 09:44:38,319
simplest cubic graph so what i wanted to show you is also
4488
09:44:38,959 --> 09:44:45,680
have other things so plot the x values and supposing i had like x
4489
09:44:45,680 --> 09:44:51,599
squared minus three x plus four you see i can have all these other
4490
09:44:51,599 --> 09:44:57,760
and this is how it affects the cubic graph you see it gets these
4491
09:44:57,760 --> 09:45:08,160
kind of flattened out before but x to the third is going to turn
4492
09:45:08,160 --> 09:45:14,960
we go we see these possibilities here all right so again you know
4493
09:45:14,959 --> 09:45:21,360
this is you know a more complex graph the parent graph still is x
4494
09:45:21,360 --> 09:45:30,239
so we go x to the fourth and yes they have a name too quartic so x
4495
09:45:30,239 --> 09:45:39,040
even exponents so we see i'm just plotting x to the fourth all the
4496
09:45:39,040 --> 09:45:52,400
this so x to the fourth if i also had like x to the sixth notice
4497
09:45:52,400 --> 09:45:57,599
need more points to make this look smoother but you get the idea
4498
09:45:57,599 --> 09:46:03,760
beyond what i can graphs what i can draw so i like showing showing
4499
09:46:03,760 --> 09:46:10,959
even exponent graphs uh we might be able to do x to the eighth and
4500
09:46:11,519 --> 09:46:16,559
that looks kind of horrible so x to the fourth is probably the
4501
09:46:18,480 --> 09:46:25,920
other than that then we have to change you know how many points
4502
09:46:25,919 --> 09:46:31,519
it a lot smoother but that's where it kind of looks like a problem
4503
09:46:31,519 --> 09:46:39,839
around zero and all of the even exponent parent graphs will look
4504
09:46:39,839 --> 09:46:44,159
x to the fourth plus other things and then the graph would look
4505
09:46:44,160 --> 09:46:50,960
go up and down as many as three times i could have as many as
4506
09:46:50,959 --> 09:46:55,519
you thought we were going to run out of names but nope x to the
4507
09:46:55,519 --> 09:47:04,159
quintic all right so x to the fifth and when we look at this there
4508
09:47:07,040 --> 09:47:15,440
looks a lot like x to the third so all the odd exponent graphs are
4509
09:47:16,400 --> 09:47:22,560
but again just a little bit more flattened out and if it's just
4510
09:47:22,559 --> 09:47:28,639
other things then the graph could be all all over and it could
4511
09:47:29,919 --> 09:47:38,400
but there we go so all the even graphs are like x to the second or
4512
09:47:38,400 --> 09:47:46,720
the y-axis and kind of looks like a flattened parabola all the odd
4513
09:47:46,720 --> 09:47:53,279
the third the fifth all the odd numbers look like this you know
4514
09:47:53,279 --> 09:47:57,680
then with you know as they get more complex with other things
4515
09:47:57,680 --> 09:48:04,000
beyond the parent graphs then we have all they can actually have
4516
09:48:04,000 --> 09:48:08,400
value graphs and there's a lot of patterns with absolute value
4517
09:48:09,040 --> 09:48:15,440
as they would be for x squared graphs the way the vertex can move
4518
09:48:15,440 --> 09:48:20,720
value graph is just this absolute value of x but like the other
4519
09:48:20,720 --> 09:48:25,599
something here inside the absolute value or outside i can add or
4520
09:48:26,480 --> 09:48:32,400
so this is how i would write absolute value with the two vertical
4521
09:48:32,400 --> 09:48:41,599
parentheses and here's how i would put this in code abs and notice
4522
09:48:41,599 --> 09:48:49,360
anything that's part of the core python library so that's the
4523
09:48:50,959 --> 09:48:57,279
then it looks like this because absolute value means it's just the
4524
09:48:57,279 --> 09:49:05,040
negative doesn't matter it's just the number so it would be like
4525
09:49:05,040 --> 09:49:12,239
would be in the positive direction but y equals negative x so for
4526
09:49:12,239 --> 09:49:17,759
y value is positive because it's absolute value so that's why
4527
09:49:17,760 --> 09:49:27,360
the y equals x graph it comes to a point and makes a v so there we
4528
09:49:27,360 --> 09:49:33,440
whatever x is it's going to end up being positive when you square
4529
09:49:33,440 --> 09:49:38,160
all it just doesn't do anything except make it positive and so
4530
09:49:38,160 --> 09:49:42,640
similar patterns to some of these but there you go perfectly
4531
09:49:42,639 --> 09:49:49,279
that's the absolute value graph and then i can have square root
4532
09:49:49,279 --> 09:49:56,879
how i write the square root if i was writing it out and if i'm
4533
09:49:56,879 --> 09:50:04,079
now there's math dot square root and there you know and other ways
4534
09:50:04,080 --> 09:50:10,000
going to use numpy dot square root because we're already using the
4535
09:50:10,000 --> 09:50:15,279
else so since i'm already using numpy for everything else that i'm
4536
09:50:15,279 --> 09:50:23,919
want to use np dot square root so the the comment we'll talk about
4537
09:50:23,919 --> 09:50:32,559
square root graph and we can start talking a little bit about
4538
09:50:32,559 --> 09:50:43,040
is the inverse of x squared and that's why i also included this
4539
09:50:43,040 --> 09:50:51,040
it you see now just the square root it's just going to be positive
4540
09:50:51,040 --> 09:50:59,120
negative part then that's not a function these x values have two
4541
09:50:59,120 --> 09:51:04,319
them together i see that it looks like a parabola on its side and
4542
09:51:04,319 --> 09:51:11,919
the inverse of x squared because i want to do the opposite i
4543
09:51:11,919 --> 09:51:19,919
helps us see it but the full graph the true square root graph is
4544
09:51:19,919 --> 09:51:28,000
function all these x values have one y value and then there is
4545
09:51:28,000 --> 09:51:34,800
beyond this all right so there we go so there's the square root
4546
09:51:35,839 --> 09:51:41,839
is with a rational exponent now overall for this graphing python
4547
09:51:42,800 --> 09:51:47,280
so i'm going to do this here and i'm going to show you that this
4548
09:51:47,279 --> 09:51:54,319
x to the one half exponent but if you try this for any pretty much
4549
09:51:54,319 --> 09:51:59,199
half it's just not going to work it's just going to give you an
4550
09:51:59,199 --> 09:52:07,680
there you go that's the same that same graph so x to the one half
4551
09:52:07,680 --> 09:52:14,080
graphing it you know it works out nicely the denominator is your
4552
09:52:14,080 --> 09:52:21,680
so square root denominators two or if i had a cube root the
4553
09:52:21,680 --> 09:52:30,160
to write it like this here x to the one third so that's the cube
4554
09:52:30,160 --> 09:52:35,920
times itself three times gets me x so like the cube root of eight
4555
09:52:35,919 --> 09:52:44,479
two times two is eight so we're getting the cube root and i don't
4556
09:52:44,480 --> 09:52:52,720
exponent here because numpy just like there's a square root
4557
09:52:54,639 --> 09:53:03,839
so that gets the cube root and this one i can have negative values
4558
09:53:03,839 --> 09:53:09,679
up three times i can have negative negative negative so that works
4559
09:53:09,680 --> 09:53:16,720
the cube root of x there we go so somewhere around here i have
4560
09:53:18,879 --> 09:53:26,639
you know there we go and then we get the cube root so the all
4561
09:53:26,639 --> 09:53:31,199
the other ones i could have other things going on in this equation
4562
09:53:31,199 --> 09:53:36,159
that would shift it up you know i can move it around but you know
4563
09:53:36,160 --> 09:53:42,240
paragraphs these types of shapes and then other graphs are just
4564
09:53:43,360 --> 09:53:50,080
all right so the floor function now there's the floor notice it
4565
09:53:50,080 --> 09:53:57,040
value but the it does have feet at the bottom that go underneath
4566
09:53:57,040 --> 09:54:03,919
to show you the floor the uh other function that's similar that's
4567
09:54:03,919 --> 09:54:10,400
and the floor function is the one where you drop all the decimals
4568
09:54:10,400 --> 09:54:19,680
like 5.9 and it doesn't round you just drop it and the answer is
4569
09:54:19,680 --> 09:54:24,959
just drops the decimals and just takes the whole number other
4570
09:54:24,959 --> 09:54:30,000
integer function or the integer part function same idea there's
4571
09:54:30,000 --> 09:54:34,239
matter what the decimal goes up to the next one and we have round
4572
09:54:40,559 --> 09:54:47,759
and to plot the floor function now i want to show you this this is
4573
09:54:47,760 --> 09:54:58,160
the function np.floor but there's a reason why i didn't do that
4574
09:54:58,959 --> 09:55:07,279
in a loop to graph this as a bunch of points because i feel like
4575
09:55:07,279 --> 09:55:11,919
function a lot better it does give these steps and sometimes on
4576
09:55:11,919 --> 09:55:20,479
a step function so it's the same value until you get to the next
4577
09:55:20,480 --> 09:55:23,120
and it's that same value until you get to the next integer
4578
09:55:24,879 --> 09:55:30,479
so all these are just sudden jumps once it gets to the next
4579
09:55:30,480 --> 09:55:40,400
change because if it was 3.1 the floor is 3 if it was 3.5 the
4580
09:55:40,400 --> 09:55:48,080
values if the floor is 3 and then when it gets to 4 boom then it
4581
09:55:48,080 --> 09:56:00,880
went through all of that is that the actual floor function i feel
4582
09:56:00,879 --> 09:56:11,360
show you you see it gives these values but these vertical lines
4583
09:56:12,800 --> 09:56:20,400
because it's not continuous like that and so it's just what you
4584
09:56:20,400 --> 09:56:27,279
but that's what the floor function looks like in numpy but truly
4585
09:56:27,279 --> 09:56:32,159
it looks like so that's why i wanted to do the loop and show you
4586
09:56:32,160 --> 09:56:43,200
floor function exponential functions so now we go from things like
4587
09:56:43,199 --> 09:56:49,599
is the exponent so what happens when the base doesn't change but
4588
09:56:49,599 --> 09:56:55,839
so that's two to the first to the second to the third well we can
4589
09:56:55,839 --> 09:56:58,959
value is going to get really big really quickly
4590
09:57:01,919 --> 09:57:12,479
and so here to the exponent of x so we have we see it gets really
4591
09:57:14,160 --> 09:57:21,440
and then when we think about our exponent rules when x is zero
4592
09:57:21,440 --> 09:57:29,600
so all these exponential functions cross the y-axis at zero one
4593
09:57:29,599 --> 09:57:35,680
flips it to the denominator so two to the negative first is one
4594
09:57:35,680 --> 09:57:41,360
negative is one fourth and so the negative exponents for negative
4595
09:57:41,360 --> 09:57:49,520
get smaller and smaller so it has that curve but it's not at all
4596
09:57:49,519 --> 09:57:56,879
that just gets smaller and smaller but actually it will never
4597
09:57:56,879 --> 09:58:01,839
where you can keep zooming in you'll see that it just gets smaller
4598
09:58:01,839 --> 09:58:07,839
zero and then over on the right it just has that upward curve and
4599
09:58:07,839 --> 09:58:14,799
is never perfectly vertical it's just really steep and so that's
4600
09:58:14,800 --> 09:58:22,639
functions we use this a lot of times in percent increase compound
4601
09:58:23,440 --> 09:58:25,840
but there we go that's a lot of the exponential functions here
4602
09:58:27,519 --> 09:58:31,599
all right so there we go so these are all the key parent graphs
4603
09:58:34,000 --> 09:58:40,879
all the other graphs you're going to look at in algebra are going
4604
09:58:40,879 --> 09:58:46,159
graphs oh it's like this graph but then with some some other
4605
09:58:47,440 --> 09:58:54,639
uh later on when we get into or another course in trigonometry the
4606
09:58:55,199 --> 09:58:59,039
and one of the big differences is they keep repeating these are
4607
09:58:59,040 --> 09:59:04,480
thing and then that's it but we'll get to those graphs but for
4608
09:59:04,480 --> 09:59:10,240
the parent graphs so when you look at a graph and you want to
4609
09:59:10,239 --> 09:59:16,479
be that generated that graph you you say well which parent graph
4610
09:59:16,480 --> 09:59:22,480
like this so it could be you know an exponential oh it has that
4611
09:59:22,480 --> 09:59:26,640
different one so you know that's why you want to get a sense of
4612
09:59:27,839 --> 09:59:33,599
develop equations to fit different curves later on and we'll get
4613
09:59:33,599 --> 09:59:39,760
so there we go and you will have this as a resource too to consult
4614
09:59:39,760 --> 09:59:49,120
different parent graphs now that we've worked through the core
4615
09:59:49,120 --> 09:59:54,240
through some extra problems and i'm going to work through extra
4616
09:59:54,720 --> 10:00:00,559
so you can see how you can apply these resources that you're
4617
10:00:00,559 --> 10:00:05,919
use these to solve problems that might come up in a textbook or in
4618
10:00:05,919 --> 10:00:12,000
go through some more extra problems here so now that we see these
4619
10:00:12,000 --> 10:00:18,000
little twist here let's look at the these sliders we can add to
4620
10:00:18,000 --> 10:00:26,319
that's it that they're meant to be modified so that first one y
4621
10:00:26,319 --> 10:00:34,000
value just it's that horizontal line if we add a slider now notice
4622
10:00:34,639 --> 10:00:43,040
that you know we're going to import this in line and it's a widget
4623
10:00:43,040 --> 10:00:50,160
our graphing is going to be in this function that we redefine here
4624
10:00:50,160 --> 10:00:57,840
f because i wanted a shorter function name f of and then it's
4625
10:00:57,839 --> 10:01:05,199
in this case we're going to also also going to zoom so all these
4626
10:01:05,199 --> 10:01:11,119
slider so you can zoom in and out and we still have these points
4627
10:01:11,120 --> 10:01:19,600
here within the function set the plot and notice all this same
4628
10:01:19,599 --> 10:01:26,959
all this and so mathematically you know if i if i wasn't writing
4629
10:01:26,959 --> 10:01:34,239
y equals a but we're going to put it here i'm going to have two y
4630
10:01:34,239 --> 10:01:39,759
perfectly horizontal line we kind of have to do it this way and
4631
10:01:41,040 --> 10:01:47,279
horizontal line just like we did with each axis you know the x
4632
10:01:47,279 --> 10:01:55,199
y values y one and y two which are both the same which is whatever
4633
10:01:55,199 --> 10:02:02,479
slider you know run this function f a goes from negative nine to
4634
10:02:02,480 --> 10:02:14,560
we run this so there we go and as i increase the slider so we see
4635
10:02:14,559 --> 10:02:22,799
in a little bit but that's what we get like y equals some constant
4636
10:02:22,800 --> 10:02:30,080
that parent graph it's still the same look that horizontal line
4637
10:02:30,080 --> 10:02:40,000
graph to the child graph it just it just changes where it is see
4638
10:02:40,000 --> 10:02:47,360
then the zoom that becomes even more interesting when i have our
4639
10:02:48,319 --> 10:02:56,559
now i have y equals mx plus b what happens when i use sliders and
4640
10:02:56,559 --> 10:03:00,319
m b and i'm you know i like the zoom in there so i'll just keep
4641
10:03:01,040 --> 10:03:07,279
so we have everything for the zoom now here and these next few we
4642
10:03:07,279 --> 10:03:15,279
numpy linspace and that's the array that i want to graph for my x
4643
10:03:16,800 --> 10:03:24,240
i have y equals mx plus b so look at that m and b are still
4644
10:03:24,239 --> 10:03:31,040
is going to affect it and then that function is going to take that
4645
10:03:31,040 --> 10:03:37,520
slider change the m value change the b and i still have the zoom
4646
10:03:39,120 --> 10:03:45,040
so it's right here because the slope is zero but what happens as
4647
10:03:46,319 --> 10:03:53,120
now i start to see my graph and i can see the slope and then as b
4648
10:03:53,120 --> 10:04:02,560
we can see it the y intercept moves up and down there we go and
4649
10:04:03,839 --> 10:04:11,439
you know now we have some more that we can see when we zoom in
4650
10:04:11,440 --> 10:04:18,720
one i didn't put the grid on there but just to show you that as
4651
10:04:18,720 --> 10:04:23,840
you know that's really just that's the paragraph y equals x
4652
10:04:23,839 --> 10:04:31,439
i can change the slider and see the negative values and from that
4653
10:04:31,440 --> 10:04:37,040
two values makes it its own graph but it still is that linear
4654
10:04:37,040 --> 10:04:44,720
graph still has those core features but then we modify it a little
4655
10:04:44,720 --> 10:04:50,959
i can change the slope i can change where it crosses the x-axis
4656
10:04:50,959 --> 10:05:00,799
illustrate this so we have now three variables for our quadratic
4657
10:05:02,239 --> 10:05:06,959
and so my function i'll take a b and c and zoom in
4658
10:05:06,959 --> 10:05:18,159
so then my y value is just this standard quadratic i remember x
4659
10:05:18,160 --> 10:05:24,240
a is one and then just x squared that would be the parent graph
4660
10:05:24,239 --> 10:05:30,799
parabola but then when i have these three it still has that core
4661
10:05:30,800 --> 10:05:38,080
parabola but then i change and we can see what a b and c do to
4662
10:05:38,080 --> 10:05:49,279
i'm going to adjust a b and c and as well as the zoom and so we
4663
10:05:49,279 --> 10:05:58,080
middle so let's just put a now that's one but we can use these
4664
10:05:58,080 --> 10:06:08,560
to the graph when a increases you see it gets narrower and then
4665
10:06:08,559 --> 10:06:16,079
parabola anymore but then as it's negative it flips it down there
4666
10:06:16,080 --> 10:06:24,000
affect you know we'll bring it back up to positive like a smile
4667
10:06:24,000 --> 10:06:33,599
jump to c next because that's the easiest it just same shape it
4668
10:06:33,599 --> 10:06:41,919
negative same shape and it moves it down and see each time i move
4669
10:06:41,919 --> 10:06:48,479
again and then recalibrates it with these new values and then b i
4670
10:06:48,480 --> 10:06:58,880
interesting because i move it as b increases it dips down to the
4671
10:06:59,680 --> 10:07:07,360
and then i can bring it back and then as b decreases it dips down
4672
10:07:07,360 --> 10:07:18,800
it dips down to the right so just some interesting things that you
4673
10:07:18,800 --> 10:07:29,360
this would be x squared minus 5x minus 5 that'd be the equation
4674
10:07:29,360 --> 10:07:45,199
minus 6 and we can zoom in and see you know i i didn't put the
4675
10:07:45,199 --> 10:07:52,079
you could always do that too so we see these sliders now the
4676
10:07:52,080 --> 10:07:59,840
want you to notice with absolute value how similar those patterns
4677
10:07:59,839 --> 10:08:06,479
value because remember whatever x is if you square it it's
4678
10:08:06,480 --> 10:08:17,360
makes it positive but the core absolute value function so you see
4679
10:08:17,360 --> 10:08:23,520
in three different values here from my absolute value parent graph
4680
10:08:24,080 --> 10:08:32,400
because i have a times the absolute value and then inside the
4681
10:08:32,400 --> 10:08:39,680
that's where the b shows up and that shifts it left or right and
4682
10:08:39,680 --> 10:08:49,840
so we see that plus c shifting it up or down and let's take a look
4683
10:08:49,839 --> 10:08:56,479
got nothing as soon as i change it now i have my absolute value
4684
10:08:56,480 --> 10:09:03,920
this is linear each line is linear but then it comes to a point
4685
10:09:03,919 --> 10:09:11,599
were negative the absolute value makes it positive so we see some
4686
10:09:11,599 --> 10:09:19,919
as a increases a times the absolute value this gets narrower just
4687
10:09:19,919 --> 10:09:32,319
and c keeps the same shape but just moves it directly up or moves
4688
10:09:36,720 --> 10:09:45,360
we have b this is this just moves it exactly side to side so
4689
10:09:45,360 --> 10:09:53,919
the parabola there's no other deeper curve to it it just moves it
4690
10:10:02,639 --> 10:10:06,639
you know c was more it's still it still moves it side to side
4691
10:10:06,639 --> 10:10:17,519
it still moves it side to side so b is negative eight so the if we
4692
10:10:26,879 --> 10:10:31,360
then we see that that is the x value
4693
10:10:31,360 --> 10:10:43,279
value so it's at negative eight and then because it's b it's x
4694
10:10:44,800 --> 10:10:52,080
is the is the formula so b is negative eight then that means
4695
10:10:52,080 --> 10:10:58,160
makes it a positive that's x plus b in the inside the absolute
4696
10:10:58,160 --> 10:11:04,560
and then c is three then we go up three so we can see again you
4697
10:11:06,239 --> 10:11:11,519
and we see the basic absolute value and then what each of these
4698
10:11:11,519 --> 10:11:18,559
similar to the quadratic but that has its own its own things and
4699
10:11:18,559 --> 10:11:25,599
the most useful i feel like for a lot of algebra you know more
4700
10:11:25,599 --> 10:11:28,319
functions can have a slider too
4701
10:11:31,279 --> 10:11:38,639
and this one it gives a runtime warning which i just left in there
4702
10:11:40,319 --> 10:11:46,480
the you can't take the square root of a negative number so you
4703
10:11:46,480 --> 10:11:52,800
zoom values that i could you know at some point i get a negative
4704
10:11:52,800 --> 10:11:58,160
compute it won't show up but it actually that doesn't break this
4705
10:11:58,160 --> 10:12:08,720
but then that's it so here if i take a look at b and i make b zero
4706
10:12:10,879 --> 10:12:16,479
so again everything zeroes out where is it but if a is anything
4707
10:12:16,480 --> 10:12:25,040
and we can zoom in a little bit see this curve a little bit better
4708
10:12:25,040 --> 10:12:37,840
and then we see b it moves it but remember it's because like the
4709
10:12:37,839 --> 10:12:46,079
so when b increases it's really x minus three moves it three to
4710
10:12:48,160 --> 10:12:55,280
and then c also you know moves it up and again we're looking at
4711
10:12:56,080 --> 10:13:04,480
where that square root function starts whereas if b was zero and c
4712
10:13:04,480 --> 10:13:11,920
we start at the origin zero zero so we see you know your basic
4713
10:13:11,919 --> 10:13:19,279
these different values you can have a times the square root and
4714
10:13:19,279 --> 10:13:25,199
b and then i still have plus c outside that can shift it up or
4715
10:13:25,199 --> 10:13:29,360
parent graphs all these key things and we start hopefully you're
4716
10:13:29,360 --> 10:13:35,520
how this comes up and you can have these sliders with all
4717
10:13:36,800 --> 10:13:47,040
now all four sliders and we can see you know x to the third now
4718
10:13:47,040 --> 10:13:56,480
as this to show this is what happens you know a increases this you
4719
10:13:56,480 --> 10:14:06,880
bit narrower but b is even zero c is negative d is even zero
4720
10:14:06,879 --> 10:14:13,439
set up you know that's where you get you know some deeper dips in
4721
10:14:14,559 --> 10:14:19,680
so and it's usually some mix of positive and negative coefficients
4722
10:14:19,680 --> 10:14:28,080
dips and you can do the same thing x to the fourth and you can
4723
10:14:29,360 --> 10:14:36,160
x to the fourth would also have a times x to the fourth and then b
4724
10:14:36,160 --> 10:14:43,520
c times x squared d times x to the first and then the constant e
4725
10:14:43,519 --> 10:14:56,079
the zero so there we go and having these you know we can adjust
4726
10:14:56,080 --> 10:15:02,800
always symmetrical but i picked one that actually could make it
4727
10:15:02,800 --> 10:15:13,840
notice where the zeros are because x to the fourth a is the
4728
10:15:13,839 --> 10:15:23,679
b is the coefficient i made that zero x squared c is the
4729
10:15:23,680 --> 10:15:31,120
first i mean that zero it's symmetrical because all of the even
4730
10:15:31,120 --> 10:15:39,680
the odd exponents zero out so these even functions happen only if
4731
10:15:41,519 --> 10:15:48,319
and notice i can have an e value because e is x to the zero and
4732
10:15:49,760 --> 10:15:57,920
so there we go so some things you can see when we have sliders you
4733
10:15:57,919 --> 10:16:09,839
floor function this is just kind of cool and so what i did here is
4734
10:16:10,480 --> 10:16:13,280
but i made this floor function i did this
4735
10:16:17,440 --> 10:16:25,200
to make these a bunch of dots because i like how that displays the
4736
10:16:25,199 --> 10:16:31,599
that's really like this is really the floor function and i made
4737
10:16:31,599 --> 10:16:36,639
the points instead of lines and you know they're big enough that
4738
10:16:36,639 --> 10:16:43,519
between but that's really this is really the floor function as we
4739
10:16:43,519 --> 10:16:51,599
know if a increases it just gets steeper and a could be negative
4740
10:16:51,599 --> 10:17:00,879
but it still has that step look to it so and then c it's almost i
4741
10:17:02,480 --> 10:17:08,000
but that's it so this is the floor function we have the different
4742
10:17:08,000 --> 10:17:13,360
have that's the parent function just the floor function but then
4743
10:17:13,360 --> 10:17:22,080
parent function would be yes i would have a times this so i keep
4744
10:17:22,080 --> 10:17:28,880
nothing else going on that would be the parent function and then
4745
10:17:28,879 --> 10:17:34,799
these you know that taking it beyond the parent functions you can
4746
10:17:34,800 --> 10:17:45,360
kinds of other things for you know there we go some some other
4747
10:17:47,919 --> 10:17:57,759
oh this was the uh exponential function we'll end it on this here
4748
10:17:57,760 --> 10:18:05,120
my a coefficient and then b to the exponent of something cx minus
4749
10:18:06,400 --> 10:18:12,639
nothing going on because a is zero but if a is at least one but
4750
10:18:13,760 --> 10:18:22,639
i have uh b has to be a value it has to be one won't do it it has
4751
10:18:22,639 --> 10:18:34,400
it has to be greater than one and then c it's c times x this won't
4752
10:18:34,400 --> 10:18:39,200
the exponent zero out so again it would be a constant that has to
4753
10:18:40,720 --> 10:18:43,120
and there we go we can zoom in a little bit
4754
10:18:43,120 --> 10:18:53,600
a little bit there we go and you know d that could shift it and e
4755
10:18:53,599 --> 10:19:01,279
doing before but you see these there's a few of these that needed
4756
10:19:01,279 --> 10:19:08,400
show something so we see you know again general parent graph of
4757
10:19:08,400 --> 10:19:18,319
the things we can do to shift it so applying some of the formulas
4758
10:19:19,040 --> 10:19:25,120
in algebra we can use these for business applications like demand
4759
10:19:25,120 --> 10:19:32,560
would be how many would i be able to sell so imagine if we're
4760
10:19:32,559 --> 10:19:40,239
and i find out that you know an average price of like six hundred
4761
10:19:42,400 --> 10:19:54,080
will get me you know i might sell like 84 million computers so we
4762
10:19:54,720 --> 10:20:01,599
you know this might be the case and then maybe i find some some
4763
10:20:01,599 --> 10:20:07,919
oh well you know what our average price is going to be triple it's
4764
10:20:07,919 --> 10:20:13,919
the neighborhood of 1800 hundred dollars but then maybe they'll
4765
10:20:16,400 --> 10:20:22,720
and then we look at this and we say okay well what should my price
4766
10:20:22,720 --> 10:20:32,000
we can find this we can use these two as you know an x value for
4767
10:20:32,000 --> 10:20:39,760
how many sold and we can do the slope formula and we can get an
4768
10:20:39,760 --> 10:20:46,800
being linear and i can take a look at what the demand might be so
4769
10:20:46,800 --> 10:21:00,800
84 minus 8 over 600 minus 1800 so remember our slope formula from
4770
10:21:00,800 --> 10:21:13,040
if we have 76 over and then the the denominator happens to be
4771
10:21:13,040 --> 10:21:20,959
get that into an exact decimal that would be my slope and you know
4772
10:21:20,959 --> 10:21:31,360
something like negative 0.06 so then i could get that into a y
4773
10:21:31,360 --> 10:21:42,879
um you know somewhere around there negative you know 0.06 x plus
4774
10:21:44,080 --> 10:21:48,800
what would be my y intercept i could i could go through that same
4775
10:21:48,800 --> 10:21:55,440
the code i'll show you that we can just bring in these formulas
4776
10:21:55,440 --> 10:22:03,200
a couple points getting our slope intercept form and then i would
4777
10:22:04,879 --> 10:22:11,199
there we go and yeah it's probably you know i'm gonna just rough
4778
10:22:12,959 --> 10:22:18,080
so let's let's just say that that would be it and then that would
4779
10:22:18,080 --> 10:22:28,480
as the price gets higher you know we would graph this as you know
4780
10:22:30,319 --> 10:22:34,639
and we would see that as the price gets higher then the number
4781
10:22:35,360 --> 10:22:42,319
you know less and less and at some point actually the why are some
4782
10:22:42,319 --> 10:22:49,919
and at some point you know we the price would be so high that
4783
10:22:49,919 --> 10:22:58,879
that as the general estimate now let's just say that's the
4784
10:22:58,879 --> 10:23:04,319
be the demand equation and a lot of times economists are looking
4785
10:23:04,319 --> 10:23:12,639
um business owners too what would be my ideal price point well
4786
10:23:12,639 --> 10:23:24,080
i do to figure out my revenue well my revenue how many sold would
4787
10:23:24,080 --> 10:23:34,639
as i was saying is defined as the x value so at every point i
4788
10:23:45,680 --> 10:23:54,480
the demand and in this case that price is always going to be x and
4789
10:23:54,480 --> 10:24:05,280
times negative 0.06 x plus 50 and you see that would be my y value
4790
10:24:07,360 --> 10:24:11,040
quick distributive property we recognize that this is
4791
10:24:11,040 --> 10:24:20,319
a quadratic with a negative a value so that means it's going to
4792
10:24:23,680 --> 10:24:26,959
and so when we look at this then
4793
10:24:29,839 --> 10:24:34,479
if i have you know the price but then instead of the number sold
4794
10:24:34,480 --> 10:24:44,000
i want to have revenue so of course if the price is zero i have no
4795
10:24:44,000 --> 10:24:51,760
there's some other price that is so high that nobody buys it so i
4796
10:24:51,760 --> 10:25:00,880
of this graph is going to be a parabola that opens down so then i
4797
10:25:00,879 --> 10:25:12,639
parabola that opens down so then i see that there is some middle
4798
10:25:13,199 --> 10:25:18,159
and that's kind of the thing that we want to look for you know
4799
10:25:18,160 --> 10:25:24,240
the slope formulas we're using the formulas we've developed to
4800
10:25:24,239 --> 10:25:31,599
this would always be true revenue is price times demand so then we
4801
10:25:31,599 --> 10:25:38,159
quadratic and we can graph these we can find out what these what
4802
10:25:40,000 --> 10:25:46,639
so pretty interesting then we could also apply this to profit so
4803
10:25:46,639 --> 10:25:54,479
we could do this and then subtract subtract the total cost we
4804
10:25:54,480 --> 10:26:02,160
some of the applications that we want to get to that you know
4805
10:26:02,720 --> 10:26:09,599
based on some data you know what should my price point be to
4806
10:26:09,599 --> 10:26:14,559
if i already established a price point what would you know can i
4807
10:26:14,559 --> 10:26:20,479
are things people put in their business plans so we see these
4808
10:26:21,440 --> 10:26:28,240
and i when we look at the code i have two other examples so we can
4809
10:26:28,239 --> 10:26:32,799
together that you you know you can use your math skills you can
4810
10:26:32,800 --> 10:26:37,600
to make some business predictions and these are some of the good
4811
10:26:37,599 --> 10:26:45,519
of of all this math and writing code so let's take a look at the
4812
10:26:45,519 --> 10:26:53,199
to give you an another example or two to show how you can write
4813
10:26:53,599 --> 10:27:02,799
and for this example i'm just saying we're selling t-shirts and
4814
10:27:02,800 --> 10:27:08,160
they seem kind of realistic but you could define the price here
4815
10:27:08,160 --> 10:27:13,440
here so if we define the price and in this case we're going to say
4816
10:27:13,440 --> 10:27:21,040
dollars each and then we have the demand as our next variable and
4817
10:27:21,040 --> 10:27:25,760
giving away t-shirts maybe you could give away 50 you know this is
4818
10:27:25,760 --> 10:27:33,760
not really going to give them away but then your demand decreases
4819
10:27:33,760 --> 10:27:41,760
time the price increases increases now in this case again if the
4820
10:27:41,760 --> 10:27:48,400
away 50 right here the price is five and then so two times the
4821
10:27:48,400 --> 10:27:55,040
be 40 but you see how it just cascades we just define the price
4822
10:27:55,040 --> 10:28:02,879
about demand and then revenue is going to be price times demand
4823
10:28:03,919 --> 10:28:10,879
standard formula the price you're selling it four times how many
4824
10:28:10,879 --> 10:28:16,319
we've you know once we've defined these then we have these other
4825
10:28:16,319 --> 10:28:22,720
on them and then the total cost so this is another one that you
4826
10:28:22,720 --> 10:28:32,080
uh made it so i said four times the demand so if we have four you
4827
10:28:32,080 --> 10:28:38,639
it cost four dollars to make each t-shirt all right and i'm sure
4828
10:28:38,639 --> 10:28:43,199
but i just said four dollars so that's where the total cost would
4829
10:28:44,080 --> 10:28:51,279
you know however many we sold and then that's the total cost so
4830
10:28:51,279 --> 10:28:57,680
minus total cost makes sense what's the rev how much money do we
4831
10:28:59,279 --> 10:29:05,199
and how you see how we have all these we can just define these
4832
10:29:05,199 --> 10:29:13,119
formula for for profit revenue minus cost and this is a standard
4833
10:29:13,120 --> 10:29:19,200
demand and some of these then we could develop these equations if
4834
10:29:19,199 --> 10:29:25,360
data so if you're making things to sell you would definitely have
4835
10:29:25,360 --> 10:29:32,720
how much does it cost to make but there you go all these then if
4836
10:29:32,720 --> 10:29:41,440
demand equation we can calculate all these and we would output you
4837
10:29:41,440 --> 10:29:49,279
and revenue because five times forty and then the total cost we
4838
10:29:49,279 --> 10:29:57,119
dollars and then having these this is where people can do some
4839
10:29:57,120 --> 10:30:01,280
oh well let's say supposing i decided to make the price ten
4840
10:30:04,319 --> 10:30:11,279
and we take a look at this the price increases the demand
4841
10:30:11,279 --> 10:30:19,680
but the revenue increases and so given that cost we still have a
4842
10:30:21,440 --> 10:30:27,279
of more than double so the price of each doubled i went from five
4843
10:30:27,279 --> 10:30:35,040
profit more than doubled it more than quadrupled so just
4844
10:30:35,040 --> 10:30:44,959
here and how does this happen well it might be it might be helpful
4845
10:30:46,239 --> 10:30:52,720
we're going to graph these things import matplot library and i'm
4846
10:30:52,720 --> 10:30:57,919
going to remind you here that the price is x and the demand is y
4847
10:30:57,919 --> 10:31:08,479
that the demand later is going to be the revenue now this is where
4848
10:31:08,480 --> 10:31:16,160
you would have you know if i have at what at a certain price what
4849
10:31:16,800 --> 10:31:24,880
and i had in mind here you know that this was you know i don't
4850
10:31:24,879 --> 10:31:33,599
you're buying two dollars 46 so it would it might not be t-shirts
4851
10:31:33,599 --> 10:31:41,279
but let's just say you know i don't know bottle of water and you
4852
10:31:41,279 --> 10:31:47,040
maybe you hype it up and tell people it's just this amazing bottle
4853
10:31:47,040 --> 10:31:52,160
or if it's really hot that day and water's cold you know you still
4854
10:31:52,160 --> 10:31:58,960
something else that you you might have but there we go so we can
4855
10:31:58,959 --> 10:32:04,400
one so if it was two dollars then the demand is 46 if it's ten
4856
10:32:04,400 --> 10:32:12,480
to 30 as an example if just having some of this data from some
4857
10:32:12,480 --> 10:32:19,120
these formulas we did back with linear equations because this is
4858
10:32:19,120 --> 10:32:25,680
demand or x and y so i'm going to calculate the slope based on
4859
10:32:25,680 --> 10:32:37,279
intercept and then this becomes a y equals mx plus b equation so
4860
10:32:37,279 --> 10:32:44,400
you know some examples of some data that we have that we can we
4861
10:32:44,400 --> 10:32:50,080
that's going to be my demand equation and i'm going to go through
4862
10:32:50,080 --> 10:32:56,319
now notice this x minimum and y minimum i'm going to make zero
4863
10:32:56,319 --> 10:33:03,040
aren't going to really have any practical meaning i'll make the x
4864
10:33:05,360 --> 10:33:10,800
there we go the number of points that's all fine so after i define
4865
10:33:10,800 --> 10:33:17,200
i'm going to do a couple other things i'm going to do the x label
4866
10:33:18,160 --> 10:33:23,680
and then i'm going to give my graph a title so notice both these
4867
10:33:24,319 --> 10:33:32,559
there we go and then for this one line one i'm going to have so
4868
10:33:32,559 --> 10:33:44,399
equation y equals m the demand equals m x plus b and so we figured
4869
10:33:46,080 --> 10:33:52,240
and so i can use those but i'm going to use x because that's the
4870
10:33:52,239 --> 10:34:01,040
defined so we have our demand equation and then i'm going to plot
4871
10:34:01,040 --> 10:34:05,520
label is still going to be price but for this one y label is going
4872
10:34:05,519 --> 10:34:11,519
to plot x and then the demand i commented this out we'll get to
4873
10:34:13,839 --> 10:34:18,879
so here we go so i have my graph and then we see yes if i was
4874
10:34:18,879 --> 10:34:25,759
give away 50 the demand decreases as the price increases so at
4875
10:34:25,760 --> 10:34:34,080
um you know whatever i'm selling here that started out as two
4876
10:34:34,080 --> 10:34:42,000
something you know some people still want those if i have 25
4877
10:34:42,000 --> 10:34:50,239
nobody wants it and then somewhere in there we have the ideal now
4878
10:34:50,239 --> 10:34:59,839
linear in real life but this is a good estimate so given these
4879
10:34:59,839 --> 10:35:08,239
equation and as we were saying before i can build upon that and i
4880
10:35:11,839 --> 10:35:17,839
revenue equals x time demand because as long as i keep that
4881
10:35:17,839 --> 10:35:26,559
and then so now i'm going to plot my x value and then revenue as y
4882
10:35:26,559 --> 10:35:41,279
my y label to revenue so we see that we have a way to do this and
4883
10:35:41,279 --> 10:35:46,000
of course i'm going to make no revenue if the price is zero and
4884
10:35:46,000 --> 10:35:51,279
going to sell none so i'll make no revenue but this is how the
4885
10:35:51,279 --> 10:35:58,159
interesting that i can have some you know low prices and i think
4886
10:35:58,160 --> 10:36:04,800
best i might sell the most but the revenue actually there's some
4887
10:36:04,800 --> 10:36:16,720
that gives me my maximum revenue and you see it looks like now if
4888
10:36:16,720 --> 10:36:23,120
and at 25 these parabolas are symmetrical so it's exactly 1250
4889
10:36:23,919 --> 10:36:31,040
or if people like round numbers you know 12 or 13 so there we go
4890
10:36:31,040 --> 10:36:40,559
use all of this and we can see that the you know the reason why
4891
10:36:40,559 --> 10:36:47,279
where the demand would be zero so this is probably the more the
4892
10:36:47,279 --> 10:36:56,879
one but having given getting some research of given prices demand
4893
10:36:56,879 --> 10:37:04,159
a couple values here then i could plot this out and i can plan oh
4894
10:37:04,160 --> 10:37:09,120
research that i've heard what should i make my price you know and
4895
10:37:09,760 --> 10:37:14,880
that people can do you know you have some new product how can you
4896
10:37:16,239 --> 10:37:23,040
all right and there you also then if you're making a business plan
4897
10:37:23,040 --> 10:37:30,239
download or export these images you know you've you've written the
4898
10:37:30,239 --> 10:37:35,279
the graph as an image to include in your business plan so there we
4899
10:37:35,279 --> 10:37:43,279
examples of how we can make use of these you know formulas the
4900
10:37:44,080 --> 10:37:48,720
generate some graph or some image and some data that we can really
4901
10:37:48,720 --> 10:37:58,000
okay so let's apply some of these graphs to some other economic
4902
10:37:59,040 --> 10:38:10,800
python your math to plan predict you know look at trends in
4903
10:38:10,800 --> 10:38:21,360
profit and if we take on that marginal cost revenue or profit if
4904
10:38:21,360 --> 10:38:28,080
when making and selling one more product and for some of our
4905
10:38:28,080 --> 10:38:37,040
equations and for that the marginal cost revenue is the result of
4906
10:38:37,040 --> 10:38:44,239
and for that the marginal if cost is linear the marginal cost is
4907
10:38:44,879 --> 10:38:52,639
wherever you are but sometimes we have costs or we saw that
4908
10:38:52,639 --> 10:39:01,360
revenue that are not linear and therefore we have some times when
4909
10:39:01,360 --> 10:39:12,239
from a cost revenue profit perspective to make one more and
4910
10:39:12,239 --> 10:39:19,040
sometimes you know oh that one more is only going to get me a tiny
4911
10:39:21,599 --> 10:39:28,239
and cost sometimes it goes the other way you know setting up
4912
10:39:28,239 --> 10:39:34,639
be a really high cost but now it's all set up so making two three
4913
10:39:35,199 --> 10:39:42,639
you know might make that worth it you know things like newspapers
4914
10:39:43,199 --> 10:39:51,279
you know there's a big setup for the printer and so the marginal
4915
10:39:51,279 --> 10:39:57,360
it now there's definitely you know other methods printers but for
4916
10:39:57,360 --> 10:40:04,559
big printers like a newspaper marginal cost it'd be a whole lot
4917
10:40:04,559 --> 10:40:10,319
going to print thousands and thousands so the marginal cost after
4918
10:40:10,319 --> 10:40:17,040
a hundred thousand newspapers printing one more is almost nothing
4919
10:40:17,040 --> 10:40:22,800
things you know what what's it cost to make one more and you know
4920
10:40:22,800 --> 10:40:32,880
and profit the same thing and so if we have revenue you know and
4921
10:40:32,879 --> 10:40:38,639
comes up but you know toward the end of the day people say oh what
4922
10:40:38,639 --> 10:40:45,440
make one more sale you know maybe it's a store should i stay open
4923
10:40:45,440 --> 10:40:54,480
tired to make one more sale that might be you know a lot more cost
4924
10:40:54,480 --> 10:40:58,960
little bit of revenue not worth it and so they say okay these are
4925
10:40:59,760 --> 10:41:06,080
so these are some deeper analyses as we get into things beyond
4926
10:41:07,519 --> 10:41:12,079
we can do even more than that makes that even more interesting but
4927
10:41:12,080 --> 10:41:19,279
know as we talk about this the marginal is that at any given point
4928
10:41:19,279 --> 10:41:26,479
to make one more all right and let's look at some other things
4929
10:41:27,040 --> 10:41:34,400
and here again i'm going to give some simple numbers and make it
4930
10:41:34,400 --> 10:41:39,040
supply and demand graph it's not going to you know and in real
4931
10:41:39,040 --> 10:41:45,360
linear there might even be a little curve to it but even at that
4932
10:41:45,919 --> 10:41:53,839
it might be you know a little bit of a bumpy line but we have
4933
10:41:53,839 --> 10:41:58,959
definitions are at supply how much are people making you know
4934
10:41:58,959 --> 10:42:03,919
i'm looking for and the demand how much will do people want how
4935
10:42:03,919 --> 10:42:13,040
so you know if you're looking at you know a movie the movie
4936
10:42:13,040 --> 10:42:18,080
theater the supplies there's only so many seats you know only so
4937
10:42:18,080 --> 10:42:24,400
a play or a concert always so many seats only so many showings so
4938
10:42:24,400 --> 10:42:29,520
and then the demand could increase if it's something really good
4939
10:42:29,519 --> 10:42:35,039
so a lot of times we see that you know that affects the price and
4940
10:42:35,040 --> 10:42:40,239
look at supply demand and price and we're going to graph supply
4941
10:42:41,440 --> 10:42:47,440
we'll see some similarities some familiar things here for the
4942
10:42:47,440 --> 10:42:53,920
values as old demand and new demand and i just gave them this
4943
10:42:53,919 --> 10:43:00,400
x values as old demand and new demand and i just gave them this
4944
10:43:00,400 --> 10:43:08,720
it reminds you that it's an x value so we have old demand and new
4945
10:43:09,440 --> 10:43:22,639
the demand increase and then i have old price and new price so now
4946
10:43:22,639 --> 10:43:30,559
we'll see this on the graph but the price is also going to be the
4947
10:43:31,120 --> 10:43:38,080
i'm going to have supply old supply and new supply i made that you
4948
10:43:38,639 --> 10:43:47,599
as i was mentioning you could potentially get data from a table
4949
10:43:47,599 --> 10:43:54,080
data you could have one table that has you know a particular price
4950
10:43:54,959 --> 10:44:00,400
and you know make all these numpy notice i did not import numpy
4951
10:44:01,120 --> 10:44:05,120
putting a few variables here and you know to illustrate the graph
4952
10:44:05,120 --> 10:44:11,040
get that data from a table and you know make each of these numpy
4953
10:44:11,680 --> 10:44:15,440
that would be really interesting too and that's something that
4954
10:44:15,440 --> 10:44:24,639
course so given these and then i have a basic graph set up adding
4955
10:44:24,639 --> 10:44:30,239
going to make the x label quantity just general quantity and the y
4956
10:44:32,160 --> 10:44:40,480
and i have this title which i already graphed but we'll get to
4957
10:44:40,480 --> 10:44:50,480
and i'm going to plot this as a red line just because all right so
4958
10:44:50,480 --> 10:44:57,200
i'm just making this just like i do it with the axis i'm going to
4959
10:44:57,839 --> 10:45:06,239
and these two y values and make you know make that a red line so
4960
10:45:06,239 --> 10:45:10,879
not going to even put an equation to it i'm just graphing this
4961
10:45:10,879 --> 10:45:18,479
to this point and i'm going to do the same thing for supply as a
4962
10:45:18,480 --> 10:45:24,240
just going to use this data that i had these numbers that i came
4963
10:45:24,239 --> 10:45:33,919
um and this graph we can take a look at this again it's simplified
4964
10:45:34,720 --> 10:45:41,840
of supply and demand so if i made green supply red demand then we
4965
10:45:41,839 --> 10:45:49,519
quantity so the green that would be quantity supplied and the red
4966
10:45:49,519 --> 10:45:55,919
supplied and the red that would be quantity demanded and then on
4967
10:45:55,919 --> 10:46:03,680
so graphing them both on price we take a look at this and we see
4968
10:46:05,760 --> 10:46:15,040
then the quantity demanded is going to be low and a lot of times
4969
10:46:15,040 --> 10:46:21,760
um an independent variable on the x axis and we think cause and
4970
10:46:21,760 --> 10:46:33,120
correlations so i'm not saying necessarily one causes the other
4971
10:46:33,120 --> 10:46:45,520
so uh at the when uh x is let's say one and y is 14 so we look at
4972
10:46:45,519 --> 10:46:55,119
low quantity of demand when the price is high and then as the
4973
10:46:55,120 --> 10:47:04,319
increase as the price decreases so that's what happens oh you know
4974
10:47:04,319 --> 10:47:10,159
you know $14 no i don't i don't think i want it but as the price
4975
10:47:11,120 --> 10:47:18,080
you know the demand increases more people would want this now
4976
10:47:18,080 --> 10:47:25,440
this they have a different incentive they want to make money so
4977
10:47:26,879 --> 10:47:36,639
the and when the price and when the price is low then nobody
4978
10:47:36,639 --> 10:47:44,400
into this so you see we have low demand but we also have low when
4979
10:47:44,400 --> 10:47:50,880
is low here then nobody wants to get into this what you know why
4980
10:47:50,879 --> 10:47:58,479
if i'm you know whatever i'm selling is not going to be you know
4981
10:47:58,480 --> 10:48:07,600
the green line the quantity supplied will increase as the price
4982
10:48:07,599 --> 10:48:16,080
industries that you know oh you know why why are people you know
4983
10:48:16,080 --> 10:48:22,720
because they all see they can make money oh this is the hot item
4984
10:48:22,720 --> 10:48:31,279
you know uh make money so that's what we have that the supply
4985
10:48:31,279 --> 10:48:39,919
increases so there we go so we have these two opposite trends and
4986
10:48:39,919 --> 10:48:45,839
core of economics because as you know i get different data this is
4987
10:48:45,839 --> 10:48:52,719
as an example but these graphs could shift you know maybe there's
4988
10:48:52,720 --> 10:49:00,239
this that maybe you know instead of uh the supply increasing like
4989
10:49:00,239 --> 10:49:07,119
causes it to increase a little bit steeper or maybe you know if we
4990
10:49:07,120 --> 10:49:15,280
supplied is low here for this price but maybe you know for
4991
10:49:15,279 --> 10:49:21,440
level was even at a higher price and this whole thing shifts so
4992
10:49:21,440 --> 10:49:30,720
of economists are trying to do and then if this is quantity across
4993
10:49:30,720 --> 10:49:36,480
where these lines intersect and then that would be the point of
4994
10:49:36,480 --> 10:49:45,600
saying is the quantity here supplied and the quantity demanded
4995
10:49:45,599 --> 10:49:52,159
that's ideal you know you know let's say you have a bakery and you
4996
10:49:52,160 --> 10:49:59,280
morning and then at the end of the day you have it all sold
4997
10:50:00,000 --> 10:50:03,919
on the left you know and we'll say let's say that you know for our
4998
10:50:03,919 --> 10:50:11,199
at six but let's say a little bit before that so it's still to the
4999
10:50:11,199 --> 10:50:18,719
so the demand's not really there the price is increasing but not
5000
10:50:18,720 --> 10:50:27,360
not really there and we still have a gap between demand and supply
5001
10:50:27,360 --> 10:50:38,480
line is higher there's more of a demand but not enough of a supply
5002
10:50:38,480 --> 10:50:48,080
side of that we have more of a supply but not as much demand and
5003
10:50:48,080 --> 10:50:56,000
be on the right that would be the one that's dangerous for anybody
5004
10:50:56,000 --> 10:51:01,040
because you know they're getting into this trying to make money
5005
10:51:01,040 --> 10:51:05,360
where somebody's happy oh good the price is going up i'll make
5006
10:51:05,360 --> 10:51:11,840
the demand drops off so now they really have to scramble for
5007
10:51:12,720 --> 10:51:20,639
the price here or on the left for the people who want this product
5008
10:51:20,639 --> 10:51:27,360
supply and that's part of what keeps the price higher because the
5009
10:51:27,360 --> 10:51:33,040
supply well then the price increases you know things like you know
5010
10:51:33,040 --> 10:51:40,239
about this stuff all day anytime somebody wants to too many people
5011
10:51:40,239 --> 10:51:47,040
oh well then you know the supply increases too many and we go to
5012
10:51:47,040 --> 10:51:53,440
sell this you know then other people notice that you're oh you're
5013
10:51:53,440 --> 10:51:59,840
and then the demand kind of goes down you know what's wrong with
5014
10:51:59,839 --> 10:52:07,519
and on the left then we have the price is too high because there's
5015
10:52:08,800 --> 10:52:14,400
and you know that sometimes causes oh there's you know there's not
5016
10:52:14,400 --> 10:52:20,239
sell that you know this must be good and then that kind of
5017
10:52:20,239 --> 10:52:29,919
bit so you see this one simple graph describes all these
5018
10:52:29,919 --> 10:52:37,199
know our goal all around is you know finding these points of
5019
10:52:37,839 --> 10:52:43,599
you know therefore everybody you know making whatever products are
5020
10:52:43,599 --> 10:52:49,839
for these products are finding them you know and you know fair
5021
10:52:49,839 --> 10:52:55,279
prices we're all trying to get to that but we see all these things
5022
10:52:56,319 --> 10:53:02,319
and it's not just one direction of cause and effect it's multiple
5023
10:53:02,319 --> 10:53:10,559
as just general correlations all things happening together so we
5024
10:53:10,559 --> 10:53:16,720
say we say the trend is like as the price goes down how does how
5025
10:53:16,720 --> 10:53:23,680
it goes the other way too as the price goes up how does that
5026
10:53:23,680 --> 10:53:37,120
that is elasticity so elasticity is how quickly does uh demand
5027
10:53:37,120 --> 10:53:43,120
and we can look at this there's the formula percent change in
5028
10:53:44,160 --> 10:53:48,720
and this is again all these economic formulas i'm just going to
5029
10:53:49,279 --> 10:53:56,159
that when you have these formulas you can use this you know get
5030
10:53:56,160 --> 10:54:01,600
then use it to calculate these formulas to answer these questions
5031
10:54:01,599 --> 10:54:09,439
how elastic is that price because if things change if the price
5032
10:54:09,440 --> 10:54:16,560
changes demand then we can say it's a very elastic like it like an
5033
10:54:16,559 --> 10:54:25,279
bounces that you know it stretches and changes easily or things
5034
10:54:25,279 --> 10:54:32,159
it does not change demand you know things like uh gasoline you
5035
10:54:32,160 --> 10:54:36,880
price goes up we don't like to pay it but if the price went up a
5036
10:54:36,879 --> 10:54:43,919
car so that demand would not be very elastic the price could
5037
10:54:44,720 --> 10:54:51,680
and you know we can so we can see that if the percent change in
5038
10:54:51,680 --> 10:54:58,080
know some significant number but then the percent change in demand
5039
10:54:58,080 --> 10:55:02,319
calculate that you know the total value of that fraction is going
5040
10:55:04,000 --> 10:55:09,120
um and we're going to say that's not very elastic but maybe some
5041
10:55:10,480 --> 10:55:17,920
you know a concert ticket you know there's ones i've seen where oh
5042
10:55:17,919 --> 10:55:23,519
i'd like to go see this but the price is too much no i won't go
5043
10:55:23,519 --> 10:55:28,399
oh i heard the price went down that would absolutely change the
5044
10:55:28,400 --> 10:55:33,680
i i won't go oh the price went down now i want to go and that
5045
10:55:33,680 --> 10:55:41,040
that aren't essential and we would say that that would be very
5046
10:55:41,040 --> 10:55:46,639
and you know down the road you could always combine all these into
5047
10:55:46,639 --> 10:55:51,599
just going to show you like just old demand new demand old price
5048
10:55:51,599 --> 10:55:58,000
calculate the percent change so remember then that's you know the
5049
10:55:58,000 --> 10:56:03,919
there's their difference divided by the old price and it's going
5050
10:56:03,919 --> 10:56:10,400
to a percent so you see again and we want to get in the habit like
5051
10:56:10,400 --> 10:56:16,160
you know colab that oh i have a formula i want to use you know
5052
10:56:16,639 --> 10:56:22,720
and then now all we have to do is change these values up here and
5053
10:56:22,720 --> 10:56:29,440
that we need so price change and that's the ends up being the
5054
10:56:29,440 --> 10:56:37,040
with demand the new demand minus the old demand and that's the
5055
10:56:37,040 --> 10:56:42,400
and that gives you a percent it will give you a decimal that you
5056
10:56:42,959 --> 10:56:50,000
elasticity number is demand change divided by price change so what
5057
10:56:50,000 --> 10:56:58,000
print that number and here's some of the analysis so again
5058
10:56:58,000 --> 10:57:04,400
what's the cutoff point you can always just put these in you know
5059
10:57:04,400 --> 10:57:11,599
statement and so if the number is greater than one then i'm going
5060
10:57:12,959 --> 10:57:21,599
and notice this is you know else if so i just continue this on you
5061
10:57:21,599 --> 10:57:29,680
one then it's unitary or proportional so sometimes you know we we
5062
10:57:29,680 --> 10:57:37,599
increase i think that that proportional increase increases demand
5063
10:57:39,599 --> 10:57:44,159
and then if it's less than one then that's inelastic that those
5064
10:57:44,160 --> 10:57:51,040
you know again it the demand hardly changes based on price and i
5065
10:57:51,040 --> 10:57:58,319
and so you see this is how you can you know i i like to when i do
5066
10:57:58,319 --> 10:58:04,319
tag on one more thing at the end you know for whatever reason
5067
10:58:04,319 --> 10:58:08,080
capture everything if it's it's either greater than one equals one
5068
10:58:08,080 --> 10:58:14,319
really but capture one other like grab bag you know what you know
5069
10:58:15,040 --> 10:58:22,239
very often we'll have if and lf without you know exhausting every
5070
10:58:22,239 --> 10:58:29,040
easily just put an else there at the end so i have some sample
5071
10:58:29,760 --> 10:58:36,319
and it would print out so we get this negative 2.2 and then demand
5072
10:58:37,519 --> 10:58:47,119
so as that example and we can do the same thing with supply so
5073
10:58:47,120 --> 10:58:53,280
um as price change because people say oh hey i want to this is a
5074
10:58:53,279 --> 10:59:01,680
into this or then people say oh nope it's uh you know this is
5075
10:59:03,919 --> 10:59:10,080
so in uh it you know in the united states kind of recently the
5076
10:59:10,080 --> 10:59:17,120
market uh was hot and that's supply like okay not everybody
5077
10:59:17,120 --> 10:59:22,639
house or try to be a realtor or try to sell some property but when
5078
10:59:23,440 --> 10:59:30,560
more people decide to get into it like oh maybe i will sell this
5079
10:59:30,559 --> 10:59:36,479
that if the price is good and people see oh opportunities to make
5080
10:59:36,480 --> 10:59:46,080
so price elasticity of supply answers that question how how
5081
10:59:47,440 --> 10:59:53,520
to changes in price so very similar formula percent change in
5082
10:59:54,959 --> 11:00:04,479
and just a few values to sample and very similar formula you know
5083
11:00:04,480 --> 11:00:13,440
divided by the old price and uh new supply minus old supply
5084
11:00:14,800 --> 11:00:21,360
and we're going to go through the same thing elasticity number and
5085
11:00:21,360 --> 11:00:28,000
greater than one it's elastic which remember as a fraction greater
5086
11:00:28,000 --> 11:00:36,239
that this percent change in supply is much greater than the change
5087
11:00:37,040 --> 11:00:43,360
and we have to do percent change because if we just do you know
5088
11:00:43,360 --> 11:00:50,239
number of things supplied that really doesn't always give us a
5089
11:00:50,239 --> 11:00:57,360
in general are low cost so a change of a dollar might be a whole
5090
11:00:57,360 --> 11:01:04,000
high cost like you know a change for a car that a price change of
5091
11:01:04,000 --> 11:01:10,639
at all so same thing with supply you know what what's what's the
5092
11:01:10,639 --> 11:01:19,199
relevant to the previous supply so that's why we do the percent
5093
11:01:20,080 --> 11:01:24,880
you know a certain percent but supply change is a lot more related
5094
11:01:24,879 --> 11:01:34,159
oh wow that's elastic people are noticing these trends and we can
5095
11:01:34,160 --> 11:01:41,440
analysis either supplies elastic unitary or any elastic and i just
5096
11:01:41,440 --> 11:01:52,560
there we go this number and it's inelastic because it's this tiny
5097
11:01:52,559 --> 11:02:00,079
everything you know supply cannot always be you know elastic and
5098
11:02:00,720 --> 11:02:07,760
and given the old prices and old supply you could always take
5099
11:02:07,760 --> 11:02:18,000
something like this so that therefore you could graph and if you
5100
11:02:18,000 --> 11:02:25,040
other numbers so notice this i mean even though these numbers
5101
11:02:25,040 --> 11:02:34,400
bit of research that you just had a few values here you can get
5102
11:02:34,400 --> 11:02:46,560
you know six things calculate you know the graph and elasticity of
5103
11:02:46,559 --> 11:02:52,720
and really just get a handle on you know where where you are in
5104
11:02:52,720 --> 11:03:00,959
potential changes you know is it you know these graphs i kind of
5105
11:03:00,959 --> 11:03:05,360
proportional but you know very often it's going to be bumpier and
5106
11:03:05,360 --> 11:03:15,360
graph and what's what's what's going on if you really wanted to
5107
11:03:15,360 --> 11:03:23,040
there's other plugins for other uh data especially things like
5108
11:03:23,599 --> 11:03:31,839
use this uh to calculate elasticity for various stock prices you
5109
11:03:33,279 --> 11:03:39,839
um and a lot of these it'll work within colab there's a lot of
5110
11:03:39,839 --> 11:03:47,279
that are a lot of things that'll work within your google drive and
5111
11:03:47,279 --> 11:03:55,680
to update things like stock prices maybe like every 15 minutes at
5112
11:03:55,680 --> 11:04:00,879
going to be enough to give some sort of analysis you know for an
5113
11:04:00,879 --> 11:04:07,519
different things you know that's kind of what we want to take this
5114
11:04:07,519 --> 11:04:17,359
formulas and build upon these so that you know you can uh build
5115
11:04:18,400 --> 11:04:25,680
at some reasonably regular level have all the formulas and
5116
11:04:26,400 --> 11:04:30,959
you know have this output at some sort of report for you let's see
5117
11:04:30,959 --> 11:04:37,279
time you know pretty much real time let's run through some
5118
11:04:37,279 --> 11:04:43,279
thinking about investing in this what's it looking like oh it's
5119
11:04:43,279 --> 11:04:51,040
elastic so you know you really have to take notice of the price or
5120
11:04:51,680 --> 11:04:56,480
i see this trend maybe you know a supply of something that maybe i
5121
11:04:57,760 --> 11:05:04,560
all these things we want to you know use this information to uh
5122
11:05:04,559 --> 11:05:09,119
want to invest in yeah and you can do this all right here in colab
5123
11:05:09,120 --> 11:05:18,959
drive so uh we'll get in some more some some more math now and you
5124
11:05:18,959 --> 11:05:28,959
journey so let's talk about calculating interest and usually
5125
11:05:28,959 --> 11:05:34,879
bank or in some investment or sometimes it's going to be money
5126
11:05:34,879 --> 11:05:41,360
am i paying so the simple interest formula is exactly that simple
5127
11:05:41,919 --> 11:05:49,919
it's good for you know not a lot of money if it's long term but
5128
11:05:49,919 --> 11:05:55,839
the less accurate it's going to be and we'll see why that is but
5129
11:05:55,839 --> 11:06:03,279
rate times time it gives you the interest so if i was borrowing
5130
11:06:03,279 --> 11:06:09,440
you know i have borrowed you know a hundred dollars and the rate
5131
11:06:11,519 --> 11:06:20,000
0.05 so the rate's always a percent converted to a decimal so the
5132
11:06:20,000 --> 11:06:27,199
and as a decimal it'd be 0.05 and then the time would be always in
5133
11:06:27,199 --> 11:06:36,079
i borrowed a hundred dollars for two years then what in what extra
5134
11:06:36,080 --> 11:06:40,000
so there we go that would be another ten dollars
5135
11:06:40,000 --> 11:06:50,000
so what i would then say is okay well you know given this rate if
5136
11:06:50,559 --> 11:06:55,839
and it's going to take me two years to pay it off you know maybe
5137
11:06:55,839 --> 11:07:02,479
years to pay off a hundred dollars maybe calculating interest
5138
11:07:03,040 --> 11:07:08,639
if you know i could calculate oh how much extra would that cost me
5139
11:07:08,639 --> 11:07:15,040
the total amount that i would pay i would take that interest and i
5140
11:07:15,040 --> 11:07:21,680
principle because i have to pay that hundred dollars back plus the
5141
11:07:21,680 --> 11:07:30,319
take a look at this you know if time is one like let's say one
5142
11:07:30,319 --> 11:07:37,760
compounding that's the notion of compounding that i'm taking that
5143
11:07:37,760 --> 11:07:43,360
the principle so let's say the time was one year and so
5144
11:07:45,440 --> 11:07:52,160
so this would be times point zero five times one then the interest
5145
11:07:53,839 --> 11:07:59,199
and then what am i going to do i'm going to i'm going to add that
5146
11:07:59,199 --> 11:08:02,639
you know the principle plus the interest
5147
11:08:02,639 --> 11:08:13,199
um is is going to be five dollars now the reason why we compound
5148
11:08:13,199 --> 11:08:21,119
a year so then i have that new principle plus the interest but
5149
11:08:21,120 --> 11:08:30,560
interest that's my new amount and then that would then generate
5150
11:08:30,559 --> 11:08:38,079
generate another five percent in interest so you see that becomes
5151
11:08:38,080 --> 11:08:43,919
percent gives me my new amount of interest and then i'd have to
5152
11:08:43,919 --> 11:08:52,000
that you know times that point oh five there we go and then i take
5153
11:08:52,000 --> 11:09:01,279
new new bit so that could potentially be a lot you know every time
5154
11:09:01,279 --> 11:09:07,119
add it to the principle again and then recalculate it but let's
5155
11:09:07,120 --> 11:09:14,800
what's really happening here so if i have this the original
5156
11:09:14,800 --> 11:09:21,360
and i probably don't even need the parentheses here so the
5157
11:09:24,879 --> 11:09:30,239
plus but remember the interest was principle times rate times
5158
11:09:32,400 --> 11:09:37,760
so we're doing a little bit of substitution there so the
5159
11:09:38,480 --> 11:09:44,000
but the interest remember that was this formula so i'll just put
5160
11:09:44,000 --> 11:09:49,760
factor out p so you see the things we were doing before with
5161
11:09:50,239 --> 11:10:05,279
then i factor out p times one plus rt but supposing t is one if t
5162
11:10:06,879 --> 11:10:11,439
which you know times one i really don't have to write that and
5163
11:10:11,440 --> 11:10:20,240
so we see a nice algebraic way to write this where i have the
5164
11:10:20,239 --> 11:10:25,360
then also adding it now we're not going to stop there what makes
5165
11:10:26,160 --> 11:10:34,080
because that is now my principle calculating the interest for that
5166
11:10:34,080 --> 11:10:38,800
new amount what happens when i have to calculate it for the next
5167
11:10:38,800 --> 11:10:46,720
original principle i did principle is what i started out with and
5168
11:10:46,720 --> 11:10:52,319
the rate so if i had to do it again for the next year it would be
5169
11:10:53,599 --> 11:10:58,319
because that's what i did to get the principle plus the interest
5170
11:10:58,319 --> 11:11:06,480
the rate and when we think about this in another way it really
5171
11:11:06,480 --> 11:11:14,480
really makes sense because we're saying that that principle times
5172
11:11:14,480 --> 11:11:21,840
saying you know this original principle 100 or whatever it is if
5173
11:11:21,839 --> 11:11:29,439
you know then that's 1.05 so you know what do i have i have a
5174
11:11:29,440 --> 11:11:38,080
five percent and then doing that you know that 105 percent every
5175
11:11:39,760 --> 11:11:47,200
that that principle times one plus the rate because if that's what
5176
11:11:47,199 --> 11:11:54,079
how can i simple that with an exponent and that's where time comes
5177
11:11:54,080 --> 11:12:01,599
time because every year then i'm doing that times one plus the
5178
11:12:02,319 --> 11:12:08,959
now we get from simple which is nice principle times rate times
5179
11:12:09,519 --> 11:12:15,359
and again good for a short term but you see on long term this is
5180
11:12:16,000 --> 11:12:22,559
compound interest because that accounts for every time it goes a
5181
11:12:22,559 --> 11:12:27,279
but then that becomes a part of that new principle and then that's
5182
11:12:28,080 --> 11:12:33,599
and if this was my money in the bank that's great that's good news
5183
11:12:33,599 --> 11:12:39,599
that i'm borrowing then the bank is going to be wanting to do this
5184
11:12:39,599 --> 11:12:44,319
that they get all the money that they that that they deserve you
5185
11:12:44,319 --> 11:12:49,519
sure that i pay that extra interest so that's where we get the
5186
11:12:49,519 --> 11:12:56,319
interest and then we get to this so then that's the you know
5187
11:12:56,319 --> 11:13:05,440
gives you you know your new amount so there we go a new amount and
5188
11:13:05,440 --> 11:13:09,680
we're going to talk about that new amount we're going to call it
5189
11:13:09,680 --> 11:13:16,080
a maybe as a variable a for amount but then it'll be annuity which
5190
11:13:16,080 --> 11:13:21,840
that we end up with so there we go the connection with simple and
5191
11:13:21,839 --> 11:13:26,399
this a little bit further when we get into the code so let's take
5192
11:13:26,400 --> 11:13:36,000
look at the code so we're looking at simple interest as the well
5193
11:13:36,000 --> 11:13:41,440
because it's good for short term and for some things that might be
5194
11:13:41,440 --> 11:13:48,400
but we just get principle times rate times time equals the amount
5195
11:13:48,400 --> 11:13:53,599
again short term because we're going to do some other things to it
5196
11:13:53,599 --> 11:14:00,080
and that's what we'll get to here so the principle if we just put
5197
11:14:00,080 --> 11:14:06,080
dollars let's say i borrowed money from the bank a thousand
5198
11:14:06,080 --> 11:14:12,240
always the percent the annual rate converted to a decimal and then
5199
11:14:12,239 --> 11:14:16,959
borrowed a thousand dollars from the bank they said okay it's five
5200
11:14:16,959 --> 11:14:24,319
years i'll pay it back here's the formula interest equals prt and
5201
11:14:24,319 --> 11:14:31,040
a hundred and fifty dollars in interest so i'd pay back that
5202
11:14:31,040 --> 11:14:37,040
but right away then that tells me the cost of borrowing that i
5203
11:14:37,040 --> 11:14:44,160
so that's going to cost me 150 dollars so then i want to find out
5204
11:14:44,160 --> 11:14:50,240
the new amount is just that principle plus the interest and there
5205
11:14:50,239 --> 11:14:57,759
the interest just like we did before and then this new amount is
5206
11:14:57,760 --> 11:15:03,920
so there we go and we add that that hundred and fifty plus the
5207
11:15:03,919 --> 11:15:10,879
now i have that new amount okay so most of the time we're going to
5208
11:15:10,879 --> 11:15:16,399
and then adding it to the new amount it's very rare that i'm
5209
11:15:16,400 --> 11:15:21,919
just the amount and not worrying about interest so here's what we
5210
11:15:21,919 --> 11:15:29,199
amount is that new amount is principle plus the interest and if
5211
11:15:29,760 --> 11:15:36,720
principle plus for one year that would be p times r times t which
5212
11:15:36,720 --> 11:15:44,080
it so that would be the new amount principle plus the interest so
5213
11:15:44,080 --> 11:15:52,080
if i divide that out i get p times one plus r and if i do the
5214
11:15:52,080 --> 11:16:02,720
this so p times one is is p and p times r is p r now this is going
5215
11:16:02,720 --> 11:16:11,919
out this p because now i have that new amount just that original p
5216
11:16:11,919 --> 11:16:16,559
and the rate is always going to be some decimal that it's going to
5217
11:16:16,559 --> 11:16:21,360
one one plus point oh five is one point oh five you can do that in
5218
11:16:21,360 --> 11:16:28,559
like a step and then this is what you're going to enter in the
5219
11:16:29,599 --> 11:16:34,479
one step that you automatically would do in your head and you're
5220
11:16:34,480 --> 11:16:40,480
calculator for these so that was what you would enter in the
5221
11:16:40,480 --> 11:16:51,120
now again this is for one year and 50 so if we go back to that
5222
11:16:51,120 --> 11:16:59,120
year just to show you that this works one year that'd be fifty
5223
11:16:59,120 --> 11:17:07,360
year then then the new amount would be 1050 so that what we're
5224
11:17:07,360 --> 11:17:13,199
to the principal that's compounding and compounding is exactly
5225
11:17:13,199 --> 11:17:18,959
principal and then calculating the percent interest from this new
5226
11:17:18,959 --> 11:17:26,479
happens over a few years so if my original amount is p so then the
5227
11:17:26,480 --> 11:17:36,400
r but now that's my new amount so so again the next year so p is
5228
11:17:36,400 --> 11:17:42,639
after one year i multiply times one plus r and after another year
5229
11:17:44,239 --> 11:17:51,759
and we'll just do this one more and again p after one year after
5230
11:17:54,160 --> 11:18:00,400
then that's just the same as making this an exponent p times one
5231
11:18:00,400 --> 11:18:09,440
because i'm multiplying this factor one plus r three times and now
5232
11:18:09,440 --> 11:18:18,560
that instead of having to go back and every time calculate the
5233
11:18:18,559 --> 11:18:26,959
then do it again you know in some loop i have one formula that
5234
11:18:26,959 --> 11:18:34,959
to do is add the exponent for how many years so now the annuity
5235
11:18:34,959 --> 11:18:45,440
r exponent t so that's 1157 now it's not an error that this is
5236
11:18:46,239 --> 11:18:54,319
was 1150 when i did this by hand i just you know calculated the
5237
11:18:54,319 --> 11:19:00,959
and then added it but that's after three years that was 1150 and
5238
11:19:00,959 --> 11:19:09,360
good for short term but the longer it goes the less accurate it is
5239
11:19:09,360 --> 11:19:15,440
i'm compounding it every year notice that's every year that i'm
5240
11:19:15,440 --> 11:19:23,760
next year so remember after after one year it was 1050 so then for
5241
11:19:23,760 --> 11:19:31,360
that five percent interest on not on a thousand but on 1050 and on
5242
11:19:31,360 --> 11:19:36,879
percent interest on that new amount so that's the compounding it's
5243
11:19:36,879 --> 11:19:43,599
the hill and accumulates more snow and gets bigger and bigger as
5244
11:19:43,599 --> 11:19:49,360
every time we're compounding because i'm still taking that rate
5245
11:19:49,360 --> 11:19:57,760
larger amount so compounded i get 1157 just that same amount over
5246
11:19:57,760 --> 11:20:05,040
seven dollars just because the formula was better so time is
5247
11:20:05,040 --> 11:20:13,760
every year but we also have a formula supposing compounding
5248
11:20:13,760 --> 11:20:22,080
us this more complicated formula but that's okay we see how it
5249
11:20:22,080 --> 11:20:30,880
of r we're doing r over n because this is happening n times per
5250
11:20:30,879 --> 11:20:36,479
annual rate so i have to divide it by how many times i'm
5251
11:20:36,480 --> 11:20:44,240
every year was the exponent the exponent becomes nt how many times
5252
11:20:44,239 --> 11:20:51,439
so then i'm compounding however many times as an example here i
5253
11:20:51,440 --> 11:21:00,319
common monthly we know recalculate compounding 12 times a year so
5254
11:21:00,319 --> 11:21:06,639
these parentheses gets smaller but then the exponents larger and
5255
11:21:06,639 --> 11:21:10,479
if this is money now if this is money you're paying back it ends
5256
11:21:10,480 --> 11:21:16,080
more but if this is money you're putting in the bank earning
5257
11:21:16,080 --> 11:21:23,680
benefit so that thousand dollars five percent for three years but
5258
11:21:23,680 --> 11:21:31,840
per year i use the extra parentheses for any fraction so there you
5259
11:21:31,839 --> 11:21:36,319
it was one plus r over n i put that in parentheses also and you
5260
11:21:36,319 --> 11:21:44,879
to make sure that stays because that is the whole exponent nt and
5261
11:21:44,879 --> 11:21:49,519
know in math we might skip the multiplying symbol because we're
5262
11:21:49,519 --> 11:21:56,079
python have to put that asterisk there so there's the annuity the
5263
11:21:56,080 --> 11:22:02,160
about this instead of just amount that's annuity and principle is
5264
11:22:02,160 --> 11:22:10,800
out with and annuity is the word for the amount we end up with so
5265
11:22:10,800 --> 11:22:22,800
monthly look at that 1161 so we go back from that simple interest
5266
11:22:22,800 --> 11:22:33,760
annual 1157 much better to 1161 because we're compounding it
5267
11:22:33,760 --> 11:22:40,959
better but first i'm going to start talking about this irrational
5268
11:22:40,959 --> 11:22:46,959
these very practical money in the bank things that we can
5269
11:22:46,959 --> 11:22:54,720
about this irrational number e and yes it's e but it's a number
5270
11:22:54,720 --> 11:23:01,440
the next formula all right so just a quick note about e we're
5271
11:23:01,440 --> 11:23:10,560
import math because e is a weird number and so when i print math
5272
11:23:11,680 --> 11:23:17,840
there we go and as a good estimate you can just call it 2.7 but in
5273
11:23:17,839 --> 11:23:22,959
want to use this whole number so that's why i want to import math
5274
11:23:22,959 --> 11:23:29,199
you know say 2.7 and call it good another interesting thing about
5275
11:23:29,199 --> 11:23:36,159
we see it's 1828 and then the 1828 repeats again that's kind of
5276
11:23:36,160 --> 11:23:46,080
a couple times and then it just all falls apart so math dot e use
5277
11:23:46,080 --> 11:23:54,000
and it's e because it's euler's number his name began with an e
5278
11:23:54,000 --> 11:24:01,919
logarithms and other things when he came up with this number he
5279
11:24:01,919 --> 11:24:08,639
mathematician that you liked euler so sometimes people call it
5280
11:24:09,760 --> 11:24:19,599
now if we're talking about compounding n times per year we go from
5281
11:24:19,599 --> 11:24:26,559
about e to being very rational well what if i just keep
5282
11:24:26,559 --> 11:24:36,959
we get to continuous growth so in that previous formula n could be
5283
11:24:36,959 --> 11:24:43,839
it 100 because we're going to do some things with this uh you know
5284
11:24:43,839 --> 11:24:51,679
every week you know i just made it a nice round number 100 could
5285
11:24:51,680 --> 11:25:04,239
and bigger number then we get the annuity becomes this formula p e
5286
11:25:04,239 --> 11:25:14,239
talking about e so i get this irrational number e and then the
5287
11:25:14,239 --> 11:25:23,680
i'll just demonstrate this so let's say n is 100 and if we do that
5288
11:25:23,680 --> 11:25:31,599
52 so compounding every week and then here i'm going to compare
5289
11:25:31,599 --> 11:25:37,360
i call the variable n times so there's the there's our other
5290
11:25:37,360 --> 11:25:44,639
nt and then we're going to compare that with our continuous growth
5291
11:25:45,519 --> 11:25:48,319
and then we're going to print it this one or this one
5292
11:25:48,319 --> 11:25:59,680
one so n times we remember that from before 1161 that should be
5293
11:26:02,239 --> 11:26:11,839
and then the continuous growth 1161.83 so it's pretty close but
5294
11:26:11,839 --> 11:26:20,399
1161.75 1161.83 it's pretty close but the continuous growth gives
5295
11:26:21,919 --> 11:26:26,559
and if n gets to be a much larger number like a thousand
5296
11:26:28,879 --> 11:26:37,439
you'll see it gets really close 1161.829 or 1161.834
5297
11:26:37,440 --> 11:26:42,240
so we see if we took it to two decimal places they actually round
5298
11:26:44,639 --> 11:26:51,440
and that's the idea with continuous growth you see it it's not
5299
11:26:51,440 --> 11:26:58,400
than this it's that as n gets larger it approaches this value so
5300
11:26:58,400 --> 11:27:05,760
a lot or other things beyond money in the bank or things like that
5301
11:27:05,760 --> 11:27:12,959
growth applications you know population increase or things like
5302
11:27:13,839 --> 11:27:19,679
and you know i can call it annuity i can call it the you know the
5303
11:27:19,680 --> 11:27:25,680
this formula so it's very useful for anything continuous growth it
5304
11:27:25,680 --> 11:27:33,840
throughout math and calculus some version of this comes up a lot
5305
11:27:33,839 --> 11:27:40,559
formula so i have this continuous growth formula if i want to
5306
11:27:46,239 --> 11:27:54,079
the mortgage formula and the mortgage payment formula is if i have
5307
11:27:54,800 --> 11:28:00,080
and that's usually a mortgage you know as an example i think this
5308
11:28:00,080 --> 11:28:08,880
close to the average mortgage these days 240 000 so that's a large
5309
11:28:08,879 --> 11:28:14,799
is 30 years that's a long amount that's a long time so for such a
5310
11:28:14,800 --> 11:28:23,440
such a long period of time then it actually really makes a
5311
11:28:23,440 --> 11:28:30,000
little bit you know every month the fact that i'm paying you know
5312
11:28:30,000 --> 11:28:36,559
principle reduces just a little then the next month i'm earning
5313
11:28:36,559 --> 11:28:43,919
principle well that really makes a difference so if we use any of
5314
11:28:43,919 --> 11:28:50,239
mortgage payments it's going to be a lot more than you know you
5315
11:28:50,239 --> 11:28:55,279
how can i afford that but when we use this more complicated
5316
11:28:55,279 --> 11:29:02,000
that we're paying it off gradually and looking at all that then we
5317
11:29:02,000 --> 11:29:10,559
amount of time what would my monthly payment be so that it'll work
5318
11:29:10,559 --> 11:29:17,759
paying over 30 years times 12 months that's 360 payments so i can
5319
11:29:17,760 --> 11:29:26,160
this amount of money after exactly 360 payments my balance is zero
5320
11:29:26,160 --> 11:29:32,240
given that i can figure out the payment and then we'll look at you
5321
11:29:32,239 --> 11:29:37,519
being a complicated formula if we want to write code for this and
5322
11:29:37,519 --> 11:29:43,359
to you this you don't even usually enter this into your calculator
5323
11:29:43,360 --> 11:29:49,520
that you can plug in the numbers here so that's what we're going
5324
11:29:49,519 --> 11:29:57,839
to break that down i just took the numerator that r over 12 one
5325
11:29:57,839 --> 11:30:08,319
numerator i made it a variable and we see r over 12 times one plus
5326
11:30:08,319 --> 11:30:15,919
and they did the same thing with the denominator so just the
5327
11:30:15,919 --> 11:30:23,519
over 12 so the exponent 12 t and then minus one separate from that
5328
11:30:23,519 --> 11:30:29,119
two separate variables so then the payment see i didn't forget
5329
11:30:29,120 --> 11:30:35,280
the capital p for principle so i'll talk about the so i'm going to
5330
11:30:35,279 --> 11:30:44,159
going to be a weird number and the first part is p times numerator
5331
11:30:44,160 --> 11:30:52,080
my mortgage payment so p times numerator divided by denominator
5332
11:30:52,080 --> 11:30:57,599
because that's going to be a very long decimal i'm going to round
5333
11:30:57,599 --> 11:31:04,959
argument and then the second one how many decimal places there we
5334
11:31:04,959 --> 11:31:17,120
and when we run it mortgage payment 1362 and 69 cents so given
5335
11:31:18,400 --> 11:31:27,440
that will make this work out that after 360 payments of this so
5336
11:31:27,440 --> 11:31:33,600
still accruing interest and we're still making a payment and it's
5337
11:31:33,599 --> 11:31:40,400
to see how that plays out we call it the amortization schedule so
5338
11:31:40,400 --> 11:31:48,000
that's the mortgage payment schedule and yes all these have the
5339
11:31:48,000 --> 11:31:54,400
means death you know kind of like you know what's what's true life
5340
11:31:54,400 --> 11:31:59,440
and i guess mortgage but yeah it was very morbid when people first
5341
11:31:59,440 --> 11:32:05,680
came up with this word but it stuck we will end this after this
5342
11:32:05,680 --> 11:32:11,919
so you know don't worry i don't want to leave you in the more
5343
11:32:11,919 --> 11:32:19,759
schedule if i take this there we go given these three things i
5344
11:32:19,760 --> 11:32:25,840
all this how we're going to calculate the payment all right so i'm
5345
11:32:25,839 --> 11:32:31,839
like what i did before so that's all the same as what we just did
5346
11:32:32,559 --> 11:32:38,399
is i want to have a loop to show the interest amounts and we can
5347
11:32:38,400 --> 11:32:45,279
that's pretty common and later on in the course we'll talk about
5348
11:32:45,279 --> 11:32:50,879
a loop so i'm going to set this new variable called balance and
5349
11:32:50,879 --> 11:32:58,959
to be that original p principle okay then i'm going to print this
5350
11:33:00,080 --> 11:33:06,400
month i'm going to put a tab there balance put a tab and then
5351
11:33:06,400 --> 11:33:11,840
the number you know what month am i talking about what's the
5352
11:33:11,839 --> 11:33:20,399
the interest that i'm paying for that month so here's what we have
5353
11:33:20,400 --> 11:33:31,840
and how many months 12 t okay so the interest is round so again
5354
11:33:31,839 --> 11:33:36,799
because calculating these you know it's going to be a lot of weird
5355
11:33:36,800 --> 11:33:43,440
two decimals dollars and cents so the interest that we're going to
5356
11:33:44,000 --> 11:33:50,160
again because that short term this is only for one month and then
5357
11:33:50,160 --> 11:33:57,520
it here in this loop so i do want simple interest it still has
5358
11:33:57,519 --> 11:34:05,359
p for that month times r and then t is 1 12th so i'm not just
5359
11:34:05,360 --> 11:34:09,279
going to divide by 12 but that's what it is this is the original
5360
11:34:10,000 --> 11:34:16,160
the balance is the principle for that month rate and then time is
5361
11:34:16,160 --> 11:34:22,960
by 12 so there we go and all that i'm going to round it to two
5362
11:34:22,959 --> 11:34:32,319
the interest this will still calculate the interest and i just put
5363
11:34:32,319 --> 11:34:42,159
of the displaying is that i only want if a is divisible by 24 you
5364
11:34:42,160 --> 11:34:50,400
a remain a divided by 24 if the remainder is zero then or if a is
5365
11:34:50,400 --> 11:34:57,599
almost the last month so these are the ones so i'm rather than
5366
11:34:57,599 --> 11:35:02,159
would just want to skip a few normally if i know if i put this in
5367
11:35:02,160 --> 11:35:09,040
schedule and i'd print out all 360 months but only for these we're
5368
11:35:09,040 --> 11:35:18,080
so i want a and then tab so that you know a is going to be what
5369
11:35:18,080 --> 11:35:27,200
range and then tab balance tab and then interest so there we go
5370
11:35:27,199 --> 11:35:37,759
to line up month balance interest so then after i do this so i put
5371
11:35:37,760 --> 11:35:43,680
first time through i want it to be the current amount and then i'm
5372
11:35:44,400 --> 11:35:49,200
so you see what i'm doing to increase the balance here all right
5373
11:35:52,080 --> 11:35:59,279
balance plus interest minus payment so you see that's what's
5374
11:35:59,279 --> 11:36:04,319
so we're manually compounding it the balance at that month plus
5375
11:36:04,319 --> 11:36:11,519
month minus the payment and then round it to two decimal places so
5376
11:36:14,720 --> 11:36:23,360
so we have the payment is 1362 just so we figured and then here we
5377
11:36:23,360 --> 11:36:31,199
balance interest so month zero we start out owing 240 000 as we
5378
11:36:31,199 --> 11:36:39,360
why it makes a difference you're paying 1100 in interest just for
5379
11:36:40,400 --> 11:36:48,720
and you know that's it it's you know it's almost the whole
5380
11:36:48,720 --> 11:36:53,599
at first after you do this enough times you come to terms with it
5381
11:36:53,599 --> 11:37:02,639
paying almost all interest at the beginning you know and then 1362
5382
11:37:02,639 --> 11:37:12,800
notice that only 262 is going toward the payment now we could see
5383
11:37:12,800 --> 11:37:19,760
but at month 24 we've paid down some things but it's probably not
5384
11:37:19,760 --> 11:37:24,319
you'd think like oh i'm paying so much i'd expect this balance to
5385
11:37:24,319 --> 11:37:29,599
just chip away at it and even then you're paying less interest but
5386
11:37:29,599 --> 11:37:39,519
dollars and that's you know month 24 so after two years and you
5387
11:37:39,519 --> 11:37:44,799
little bit less interest we do see this moving in the right
5388
11:37:44,800 --> 11:37:51,120
and you're paying a little bit less interest but probably not
5389
11:37:51,680 --> 11:37:56,720
and that's why i just wanted to skip ahead you know every two
5390
11:37:57,599 --> 11:38:02,080
and you know how much interest we're paying you know we take a
5391
11:38:04,639 --> 11:38:14,080
now you know we take and we look at this so if we have just over
5392
11:38:14,080 --> 11:38:23,360
borrowed 240 still a 140 but at this point now that difference we
5393
11:38:23,360 --> 11:38:29,440
start start building equity in in you know if this is a mortgage
5394
11:38:29,440 --> 11:38:35,760
the house is worth is worth a lot more than what we owe and so you
5395
11:38:36,319 --> 11:38:40,080
you know home equity loans that's where that comes in as you start
5396
11:38:40,080 --> 11:38:48,400
and you know the the value of the house is worth a certain amount
5397
11:38:48,400 --> 11:38:54,080
amount the difference you know you can actually borrow money
5398
11:38:54,080 --> 11:39:02,000
for another time so we have this and finally now it's still a lot
5399
11:39:02,000 --> 11:39:08,720
you know to think about wow i'm still you know look at that 20
5400
11:39:08,720 --> 11:39:15,680
than five hundred dollars a month just in interest you know it but
5401
11:39:15,680 --> 11:39:20,319
dollars a month and you know we're getting the vast majority of
5402
11:39:20,319 --> 11:39:29,120
point to paying off the mortgage and now when we take a look you
5403
11:39:29,120 --> 11:39:35,520
instead of three digits thirty thousand and then the amount of
5404
11:39:35,519 --> 11:39:46,079
and forty one dollars so uh i wanted to skip ahead and then just
5405
11:39:46,080 --> 11:39:53,760
now the balance at that point is just under what the mortgage
5406
11:39:53,760 --> 11:40:02,959
is this tiny amount and that would be if you know month 360 when
5407
11:40:02,959 --> 11:40:08,720
up being like four or five dollars more than the normal mortgage
5408
11:40:08,720 --> 11:40:15,840
so it works out that that that monthly payment you know using that
5409
11:40:15,839 --> 11:40:24,479
payment 1362 and 69 cents and that monthly payment did work out
5410
11:40:24,480 --> 11:40:33,840
as you know we're look at the amortization table at 360 months it
5411
11:40:34,400 --> 11:40:37,919
and there we go for an extra five dollars the last month i'm not
5412
11:40:38,559 --> 11:40:44,959
so these are you know interesting things to think about seeing how
5413
11:40:44,959 --> 11:40:51,760
payments applied to loans how that plays out how you're paying off
5414
11:40:51,760 --> 11:41:02,240
of the simple interest and then paying down this balance so this
5415
11:41:02,239 --> 11:41:08,239
for any large amount of money over a significant amount of time we
5416
11:41:08,239 --> 11:41:13,279
have to be a mortgage car payments not always because a lot of
5417
11:41:13,839 --> 11:41:19,839
if it was a car payment for like particularly expensive car or
5418
11:41:19,839 --> 11:41:27,119
of time then we might use this doesn't have to go to 30 years that
5419
11:41:27,680 --> 11:41:35,919
this you know paying off this debt over time so let's use
5420
11:41:35,919 --> 11:41:46,000
it around and have something positive retirement account
5421
11:41:46,000 --> 11:41:51,519
money you know this p is not money that i'm borrowing it's money
5422
11:41:51,519 --> 11:41:59,439
into an account and instead of owing money every month i'm going
5423
11:41:59,440 --> 11:42:10,560
formula for this that i'm just going to estimate this oh okay
5424
11:42:10,559 --> 11:42:16,239
see you'll see how this plays out and i just picked these numbers
5425
11:42:16,239 --> 11:42:21,680
principle is a thousand and this is just estimation here well
5426
11:42:21,680 --> 11:42:28,319
dollars now this is where the estimation comes in most of the time
5427
11:42:28,319 --> 11:42:34,879
any decent fund manager is going to be able to get you point eight
5428
11:42:34,879 --> 11:42:40,559
so now this is your money growing in an account this isn't you
5429
11:42:40,559 --> 11:42:46,559
growing in an account so if you had a thousand dollars and we
5430
11:42:46,559 --> 11:42:55,759
percent per year that's great and i made this time 38 years as you
5431
11:42:55,760 --> 11:43:05,680
just thought like age 22 till age 60 38 years so you start it put
5432
11:43:05,680 --> 11:43:13,519
account and then you start saving that you know from that point
5433
11:43:13,519 --> 11:43:21,919
you put away 350 every month in this account okay and i'm going to
5434
11:43:21,919 --> 11:43:30,799
annuity which i'm going to start out the original is p so now
5435
11:43:30,800 --> 11:43:40,880
and the percent growth so again 38 years so for a in range 12 t so
5436
11:43:40,879 --> 11:43:49,839
we're contributing something so notice what we're doing with this
5437
11:43:49,839 --> 11:43:55,759
that we already have plus the monthly contribution and then that's
5438
11:43:59,519 --> 11:44:09,439
one plus r over 12 because that's a monthly notice that percent
5439
11:44:09,440 --> 11:44:20,080
so the exponent if it was nt the exponent n would be 12 and t
5440
11:44:20,080 --> 11:44:25,120
so i don't need to write the exponent of one but that's where this
5441
11:44:25,120 --> 11:44:34,720
formula r over n to the nt but nt and is n is 12 t is one over 12
5442
11:44:34,720 --> 11:44:40,959
so each month then if we take this and that's why i wanted to
5443
11:44:41,680 --> 11:44:47,919
because i want to allow for this contribution here the annuity
5444
11:44:47,919 --> 11:44:55,360
we want that to happen each time and then it's going to grow so in
5445
11:44:55,360 --> 11:45:01,440
to grow so at the end we're going to print this out and i'm going
5446
11:45:01,440 --> 11:45:10,240
that'll end up being a weird decimal annuity okay so now the
5447
11:45:10,239 --> 11:45:17,279
but this is what we want to break this down if we're if our rate
5448
11:45:18,959 --> 11:45:25,839
let's say it's still earning eight percent when you start taking
5449
11:45:25,839 --> 11:45:34,799
interest you see and so that's annuity times the rate that's it
5450
11:45:34,800 --> 11:45:41,760
places but that so if i have this this amount of money that i'm
5451
11:45:43,599 --> 11:45:50,720
then the idea is that money now is yours in the bank or in this in
5452
11:45:50,720 --> 11:45:57,840
that the annual income is just that percentage rate
5453
11:46:04,319 --> 11:46:14,319
so take a look at this annuity here so one zero six one five nine
5454
11:46:14,319 --> 11:46:23,199
million dollars and if it continues to earn that eight percent the
5455
11:46:23,199 --> 11:46:31,839
interest is eighty four thousand dollars or almost eighty five
5456
11:46:32,480 --> 11:46:39,280
this money in the bank or in some investment not not in the bank
5457
11:46:39,279 --> 11:46:45,119
bank is going to get you this eight percent interest that makes
5458
11:46:45,120 --> 11:46:52,080
investment if you're you know you have this and you can contribute
5459
11:46:52,080 --> 11:46:59,680
constantly contributing and it's growing so at some point then you
5460
11:46:59,680 --> 11:47:09,760
million dollars that earns this amount of interest and i just
5461
11:47:11,760 --> 11:47:19,920
the earlier you start the better and the later you stop start uh
5462
11:47:19,919 --> 11:47:28,479
can grow even more that you could take the money out at you know
5463
11:47:28,480 --> 11:47:36,640
estimated did age 22 to 60 you know if you if you start as early
5464
11:47:37,199 --> 11:47:43,039
you know till 68 if you look at that that'd be like 50 years that
5465
11:47:43,040 --> 11:47:49,279
because remember this snowball so that eight percent in those
5466
11:47:49,279 --> 11:47:56,799
of larger and larger amounts of money and then if you get it to
5467
11:47:56,800 --> 11:48:04,960
of a million is more than 80 000 so that's that's the idea we want
5468
11:48:04,959 --> 11:48:11,519
of money that just the interest on that you know if this
5469
11:48:11,519 --> 11:48:16,399
on that is enough to live on and you take the interest and then
5470
11:48:16,400 --> 11:48:22,880
which will earn interest the next year so we want to leave you
5471
11:48:22,879 --> 11:48:29,919
we can use all this you know that's that's what use all all these
5472
11:48:29,919 --> 11:48:38,080
to you know turn that into money in the bank that's that's the
5473
11:48:38,080 --> 11:48:42,800
hopefully then it works out and if you have these this code you
5474
11:48:42,800 --> 11:48:47,760
know how much do you start out with you know keep this rate maybe
5475
11:48:47,760 --> 11:48:53,440
you know my fund manager is doing really well change the time
5476
11:48:53,440 --> 11:49:01,120
tinker with these and run it and you know see the results so you
5477
11:49:01,120 --> 11:49:10,160
you need to do to invest for retirement so let's look at some more
5478
11:49:10,160 --> 11:49:17,680
mortgage formulas here now like we were doing before i'm going to
5479
11:49:18,400 --> 11:49:24,639
formula as its own function so there we go uh def and then payment
5480
11:49:24,639 --> 11:49:32,639
pr t run it through this formula and i'll just return the payment
5481
11:49:32,639 --> 11:49:37,760
we can use this and all of these you know we're going to apply
5482
11:49:37,760 --> 11:49:45,360
know you're looking for a house you're comparing different things
5483
11:49:45,360 --> 11:49:52,800
to run this and there we go and i don't need to run that again now
5484
11:49:53,440 --> 11:49:59,920
so i'm going to do a similar function and i get something
5485
11:49:59,919 --> 11:50:06,879
show you this one i'm just going to define it pmt and i'm only
5486
11:50:06,879 --> 11:50:13,680
because i'm going to just give a set rate and time so with this
5487
11:50:14,400 --> 11:50:20,319
taking the input as whatever the principle is i'm going to
5488
11:50:20,319 --> 11:50:26,239
i'm doing this and we see these imports is because i'm going to
5489
11:50:26,239 --> 11:50:36,239
i'm just going to go from zero to three hundred thousand and see
5490
11:50:36,959 --> 11:50:40,559
that principle of course the slider shows it somewhere in the
5491
11:50:41,599 --> 11:50:45,760
four hundred and fifty thousand the monthly payment would be eight
5492
11:50:46,559 --> 11:50:52,159
and we can see how this goes up and here's something you can do
5493
11:50:52,160 --> 11:50:58,960
comparing different mortgages or houses you can see how does this
5494
11:51:00,080 --> 11:51:04,639
you know and we look at this oh two hundred and twenty one
5495
11:51:05,680 --> 11:51:10,319
should i buy a house it's more expensive i know my payment will go
5496
11:51:10,319 --> 11:51:18,959
much you see and we can look at this now that's great to see these
5497
11:51:18,959 --> 11:51:28,159
to see the trend maybe there's i want to graph it so notice our
5498
11:51:28,160 --> 11:51:36,320
case i just define my x maximum is three hundred thousand and my y
5499
11:51:36,319 --> 11:51:43,199
going to be plenty all these standard things you would already
5500
11:51:43,199 --> 11:51:49,839
points you're going to use for np dot linspace and everything
5501
11:51:52,000 --> 11:51:58,480
something that i don't always put in there plt dot grid just to
5502
11:51:59,839 --> 11:52:06,639
axe dot set x label and set y label so the x will be the amount
5503
11:52:06,639 --> 11:52:15,120
from zero to 300 000 and the y will be the monthly payment so now
5504
11:52:15,120 --> 11:52:23,440
earlier i can just use that as my y value i only need the x that
5505
11:52:23,440 --> 11:52:32,160
here and i'm still going to give it just a consistent rate and
5506
11:52:32,160 --> 11:52:37,120
the input all these are going to given the same rate and time how
5507
11:52:37,120 --> 11:52:46,720
monthly payment and when we run this we can see that the payment
5508
11:52:46,720 --> 11:52:54,080
that same rate and time and this would be realistic maybe you get
5509
11:52:54,080 --> 11:53:02,800
you would know your interest rate and you would know the time so
5510
11:53:03,440 --> 11:53:10,560
it is linear how much would it increase you know for how much
5511
11:53:10,559 --> 11:53:16,559
for increases in the amount borrowed well all right this is a good
5512
11:53:16,559 --> 11:53:21,439
get down to the numbers so it's linear i'm just going to do the
5513
11:53:21,440 --> 11:53:28,240
and i'm just going to pick two values you know and you know x1 and
5514
11:53:28,239 --> 11:53:34,400
this i just put rate and time here and i define them up here just
5515
11:53:34,400 --> 11:53:37,840
i'm using the same numbers consistently throughout this i feel
5516
11:53:38,400 --> 11:53:44,560
for the consistent example and just pick two x values calculate
5517
11:53:44,559 --> 11:53:52,479
values and calculate the slope formula and what we'll find so
5518
11:53:52,480 --> 11:54:05,200
this is you know dollars and cents so really it would go up you
5519
11:54:05,199 --> 11:54:13,680
of you know price increase or we can you know multiply it by a
5520
11:54:13,680 --> 11:54:19,440
go up six dollars you know because 5.99 i'll round up it would go
5521
11:54:19,440 --> 11:54:26,800
six dollars for every thousand extra dollars you borrow and now
5522
11:54:27,760 --> 11:54:31,760
an extra thousand that's going to be an extra six dollars in the
5523
11:54:31,760 --> 11:54:36,560
and you know you can put things in perspective do i like it that
5524
11:54:36,559 --> 11:54:43,519
thousand it's only six more dollars so we see some things we can
5525
11:54:43,519 --> 11:54:49,519
formulas that we we've been working with and we can define them as
5526
11:54:50,080 --> 11:54:59,200
use them in sliders we can graph them and finding aspects of the
5527
11:54:59,199 --> 11:55:05,199
and finding aspects of the graph we can do other analysis this is
5528
11:55:05,199 --> 11:55:13,119
building upon for our data analysis so this is all good and i want
5529
11:55:13,120 --> 11:55:19,360
here beyond the python i know this is almost all python but i want
5530
11:55:19,360 --> 11:55:26,959
do this in a spreadsheet because that will give you like that full
5531
11:55:26,959 --> 11:55:32,959
you also how to build that because these are some good spreadsheet
5532
11:55:32,959 --> 11:55:39,519
the balance here is a formula but we'll get to that in a second so
5533
11:55:39,519 --> 11:55:45,519
i picked this two hundred and fifty thousand that's somewhere
5534
11:55:45,519 --> 11:55:50,959
in the united states right now i want it to be some realistic
5535
11:55:50,959 --> 11:55:58,000
down payment it's going to be we want 20 percent so notice if i
5536
11:55:58,879 --> 11:56:10,000
up here is the formula and i just did 20 times g2 0.02 times g2 so
5537
11:56:10,000 --> 11:56:18,800
and i make g2 you know 300,000 instead click somewhere else then
5538
11:56:18,800 --> 11:56:24,319
calculate the down payment i think i do want to go back to 250,000
5539
11:56:24,319 --> 11:56:28,319
i feel like that's a good middle of the road number for us to use
5540
11:56:30,080 --> 11:56:36,400
and click and it'll adjust again now then the borrowed amount i
5541
11:56:36,400 --> 11:56:44,400
going to double click in this and equals g2 minus g3 actually
5542
11:56:44,400 --> 11:56:52,480
sometimes google will prompt you will give you that and notice
5543
11:56:52,480 --> 11:56:59,360
can see the borrowed amount and then up here this is the formula
5544
11:56:59,360 --> 11:57:09,919
minus the down payment all right so let's just say the interest
5545
11:57:09,919 --> 11:57:13,759
now i'm going to write the word years here i'm not going to use
5546
11:57:14,400 --> 11:57:22,160
but here the interest rate i will all right now monthly payment we
5547
11:57:22,160 --> 11:57:34,080
to this and calculate the monthly payment so we see here i just
5548
11:57:34,080 --> 11:57:44,000
you go six percent 30 years and i already have this so what if i
5549
11:57:44,959 --> 11:57:52,080
which was 200,000 even and i can just go to this borrowed amount
5550
11:57:52,080 --> 11:58:03,279
oh 200,000 now i could actually also just make another since i
5551
11:58:05,680 --> 11:58:11,760
i could actually right under here write print
5552
11:58:11,760 --> 11:58:22,480
payment 250 uh 200 comma 0.06 comma 30
5553
11:58:26,480 --> 11:58:29,680
so you see i could just actually just put this in here
5554
11:58:32,160 --> 11:58:37,760
output the monthly payment all right there we go 11.99 and 10
5555
11:58:40,480 --> 11:58:46,160
so monthly payment will be 11.99 and 10 cents
5556
11:58:48,639 --> 11:58:54,559
so now notice here this is just a couple of things that we can do
5557
11:58:54,559 --> 11:59:04,479
and 10 cents so now notice here this is just a good reference for
5558
11:59:04,480 --> 11:59:10,000
price down payment and everything but these notice i already had
5559
11:59:11,040 --> 11:59:17,120
the monthly payment and if you'll notice i have these dollar signs
5560
11:59:17,120 --> 11:59:23,360
some things we're going to do later i mean i don't need them over
5561
11:59:23,360 --> 11:59:29,120
things later we're going to drag these formulas down and it's
5562
11:59:29,120 --> 11:59:38,080
the row and the dollar sign will keep that the same so dollar sign
5563
11:59:38,080 --> 11:59:43,200
if i ever adjust this that's not going to change it's going to
5564
11:59:43,199 --> 11:59:50,559
that cell g4 and same with the payment that's always going to
5565
11:59:50,559 --> 11:59:56,639
that's what i want now the interest we've been doing all these
5566
11:59:56,639 --> 12:00:00,959
actually this is going to be monthly each of these is going to be
5567
12:00:00,959 --> 12:00:08,000
going to be a month so for monthly interest we can just do simple
5568
12:00:08,000 --> 12:00:19,440
balance which is a2 times the rate which is 0.06 times the time
5569
12:00:19,440 --> 12:00:25,120
so one month is one twelfth of a year so i'm just going to say
5570
12:00:27,440 --> 12:00:34,240
and this works out i mean you know that's very nice but it's not
5571
12:00:34,879 --> 12:00:40,959
so what i want to do is i want to add another function around here
5572
12:00:40,959 --> 12:00:53,360
round open parentheses and i will put you know so it rounds this
5573
12:00:53,919 --> 12:01:00,559
you see it'll round it to the whole number but i want to put comma
5574
12:01:00,559 --> 12:01:08,159
to two decimal places and this is google sheets if you you do this
5575
12:01:08,160 --> 12:01:14,000
have that comma and then however many decimal places even if it's
5576
12:01:14,000 --> 12:01:21,120
that it'll just round it to the whole number so there we go so
5577
12:01:21,120 --> 12:01:30,639
then my new balance equals the original balance which was a2 plus
5578
12:01:30,639 --> 12:01:43,599
so that's b2 minus the payment which is c2 and i want to take this
5579
12:01:43,599 --> 12:01:49,279
a thousand dollars in interest you know just you know just
5580
12:01:49,279 --> 12:01:55,519
about that and all that the paid you just took a little bit off
5581
12:01:55,519 --> 12:02:02,239
dollars in interest and then the payment was only 11.99 so a
5582
12:02:02,239 --> 12:02:09,759
to the paying down the original principle so i want to take this
5583
12:02:10,400 --> 12:02:15,279
it accrues interest i make a payment new balance and i want to
5584
12:02:16,000 --> 12:02:20,319
so that was cell d2 so i'm just going to put equals d2 here
5585
12:02:20,319 --> 12:02:27,519
here and here now notice if i drag this down
5586
12:02:30,160 --> 12:02:36,640
it changed because it's calculating the interest now based on this
5587
12:02:37,199 --> 12:02:45,279
times 0.06 divided divided by 12 and then here when i drag that
5588
12:02:45,279 --> 12:02:51,040
because i put the dollar sign in there it won't adjust anything
5589
12:02:52,239 --> 12:03:00,159
and we see again doing that it adjusts it for this row now
5590
12:03:00,160 --> 12:03:06,240
two everything here is based on row three and we got that by
5591
12:03:06,239 --> 12:03:13,360
hand corner you get a little tiny plus sign and this is magnified
5592
12:03:13,360 --> 12:03:19,840
the that thin plus sign and you click and drag that but we're
5593
12:03:20,639 --> 12:03:26,239
so i'm holding down shift in the arrow key to highlight the entire
5594
12:03:26,239 --> 12:03:31,919
over that i get that thin plus sign and i'm going to click and
5595
12:03:31,919 --> 12:03:40,799
amateurization table now notice my mouse is down below the bottom
5596
12:03:40,800 --> 12:03:45,280
that's 360 months so somewhere around there is where i'll stop
5597
12:03:48,160 --> 12:03:56,480
and these are all negatives so i'm going to take this highlight
5598
12:03:56,480 --> 12:04:12,240
then just delete them so now here this is you know after this the
5599
12:04:12,239 --> 12:04:28,639
so we can just make this 11.99 plus that additional dollar 13 and
5600
12:04:28,639 --> 12:04:48,639
decimals like that and that should be yes 10 cents negative 10
5601
12:04:48,639 --> 12:04:58,879
three and that should be enough to make that we're just going to
5602
12:04:58,879 --> 12:05:06,719
we're going to call it zero and what we have the row number is
5603
12:05:06,720 --> 12:05:17,360
first row as headings so three given that mortgage payment it
5604
12:05:17,360 --> 12:05:31,040
months you have a balance of zero so we're going to take take this
5605
12:05:31,040 --> 12:05:35,760
amateurization table and you know you can look through it and
5606
12:05:36,959 --> 12:05:42,559
the payment stays the same but what happens is the amount of
5607
12:05:42,559 --> 12:05:49,919
gradually because for such a large amount of money for such a long
5608
12:05:49,919 --> 12:05:56,959
fact that you're paying interest on just that little bit less that
5609
12:05:57,760 --> 12:06:02,720
and then that means that look you know that same payment a little
5610
12:06:02,720 --> 12:06:06,959
more of it goes to the principal so you know you're you're making
5611
12:06:06,959 --> 12:06:20,559
paying this off but it takes a while until see look at this i mean
5612
12:06:20,559 --> 12:06:32,399
to go into you know 225 months you know we're coming up on 20
5613
12:06:32,400 --> 12:06:38,959
payment goes to interest or less than half of your payment goes to
5614
12:06:38,959 --> 12:06:46,319
interesting to see that whole table and then this balance here at
5615
12:06:46,319 --> 12:06:50,319
amount you know supposing you come into some money and you say oh
5616
12:06:50,319 --> 12:06:58,080
it you know that that's the balance that's your payoff amount and
5617
12:06:58,080 --> 12:07:05,680
showing you the spreadsheet and how you can set this up and how we
5618
12:07:05,680 --> 12:07:13,519
other cells and how we can add formulas and how we can drag all
5619
12:07:13,519 --> 12:07:21,680
and you know mortgage mort you know it does sound like death
5620
12:07:21,680 --> 12:07:32,160
mort so let's do something more positive with a very similar type
5621
12:07:32,160 --> 12:07:44,960
i set up the same thing balance interest i'll capitalize it and
5622
12:07:44,959 --> 12:08:01,440
contribution and then new balance so let's look at this in a more
5623
12:08:01,440 --> 12:08:09,120
this was this amount that you owed that you're paying off but
5624
12:08:09,120 --> 12:08:15,520
account that you're adding to so i don't know let's let's start by
5625
12:08:15,519 --> 12:08:21,919
five thousand dollars and a lot of retirement accounts you know
5626
12:08:22,720 --> 12:08:30,160
you know get like eight percent interest that's pretty reasonable
5627
12:08:30,160 --> 12:08:44,000
so we have equals so this is column i two times zero point zero
5628
12:08:47,599 --> 12:08:53,919
eight percent interest and then for one month so then you know one
5629
12:08:53,919 --> 12:09:04,879
by 12 there we go and maybe you know we could do this we could do
5630
12:09:04,879 --> 12:09:11,839
i'll round it that might that might work out it'll just look nicer
5631
12:09:11,839 --> 12:09:20,959
to two decimal places again dollars and cents okay now monthly
5632
12:09:20,959 --> 12:09:29,760
you know you can contribute a few hundred dollars let's start with
5633
12:09:29,760 --> 12:09:40,880
start with like 200 and we're going to change that later so with
5634
12:09:40,879 --> 12:09:54,079
and you contribute so it's all plus equals i2 plus j2 plus k2
5635
12:09:57,919 --> 12:10:02,799
and then we're going to carry that around so that's l2 equals l2
5636
12:10:02,800 --> 12:10:10,960
l2 and we're going to do the same thing drag this down one drag
5637
12:10:12,000 --> 12:10:20,319
drag this down one and what we have is you know given that you
5638
12:10:20,319 --> 12:10:27,839
given the contribution you could always add more different times
5639
12:10:27,839 --> 12:10:33,199
for about the same amount of time so if we drag this down
5640
12:10:35,839 --> 12:10:41,439
now this being a retirement account a lot of times people will
5641
12:10:41,440 --> 12:10:49,600
so we don't really even have to stop at 360 let's stop with like
5642
12:10:49,599 --> 12:11:02,400
um there we go uh 401 because the first rose so what we have is
5643
12:11:03,440 --> 12:11:11,200
you know this amount that you have is 469 thousand dollars and the
5644
12:11:11,199 --> 12:11:20,559
this 3000 so you could easily like take that interest and then
5645
12:11:20,559 --> 12:11:27,360
you take that 3106 out every month and live on that and then
5646
12:11:27,360 --> 12:11:32,319
so you know it it you know goes from this and then back to this
5647
12:11:32,319 --> 12:11:39,120
back to this that's one way to do it i just want to show you so
5648
12:11:39,120 --> 12:11:46,880
here and say then we contribute something like you know 400
5649
12:11:46,879 --> 12:11:57,919
that down in a little bit and this one let's say you know 0.085 i
5650
12:11:57,919 --> 12:12:06,400
more optimistic on the there we go drag that down a little bit and
5651
12:12:06,400 --> 12:12:11,599
correct and we'll drag this down and the other thing i'm going to
5652
12:12:11,599 --> 12:12:25,919
longer maybe even like uh 450 months or something like that 40
5653
12:12:25,919 --> 12:12:35,199
so we can take this even further and you'll see that just you know
5654
12:12:36,239 --> 12:12:46,559
some poss some nice possibilities here all right and because look
5655
12:12:46,559 --> 12:12:55,680
because look at this final number here so yes that one is one
5656
12:12:55,680 --> 12:13:03,599
we're talking about here you know one million dollars and the
5657
12:13:03,599 --> 12:13:11,439
eight hundred eighty five dollars so this is something you know
5658
12:13:11,440 --> 12:13:15,840
take this same math and turn it around and make it positive
5659
12:13:15,839 --> 12:13:23,519
to and then at this point you have this money you know in this
5660
12:13:23,519 --> 12:13:29,759
out every month or or less and you know not have to worry about it
5661
12:13:29,760 --> 12:13:35,680
take that out and then you're still left with this you know more
5662
12:13:35,680 --> 12:13:40,319
live off the interest and you still have this every month take
5663
12:13:40,319 --> 12:13:45,599
to generate interest the next month and these are some of the
5664
12:13:45,599 --> 12:13:52,319
that you know from the other side of it you know you owe all this
5665
12:13:52,319 --> 12:13:59,680
but then you own this house and on the same time you're
5666
12:13:59,680 --> 12:14:04,239
have money that you can live off of and you know these you know
5667
12:14:04,239 --> 12:14:12,639
want to do with our math skills look at how we can manage manage
5668
12:14:12,639 --> 12:14:21,760
in life then have this you know property that has equity and you
5669
12:14:21,760 --> 12:14:27,040
in the bank that you can live off of and there we go you know
5670
12:14:27,519 --> 12:14:33,039
and seeing how you can make this work for you seeing the trends
5671
12:14:33,040 --> 12:14:39,599
now you might be working hard and owing a lot and not having that
5672
12:14:39,599 --> 12:14:45,199
many years you build things and then you have things oh i have
5673
12:14:45,199 --> 12:14:51,199
they've built over decades and can live off of it so that's really
5674
12:14:51,199 --> 12:14:57,199
some of this with the other uh python you know generating just
5675
12:14:57,199 --> 12:15:02,479
like these you know these are some of the ways you can make this
5676
12:15:02,480 --> 12:15:09,840
at the trends and hopefully this helps you make some decisions
5677
12:15:09,839 --> 12:15:15,599
whether it be real estate or borrowing money or other retirement
5678
12:15:15,599 --> 12:15:22,720
just you know some bonus and there we go we're in the home stretch
5679
12:15:22,720 --> 12:15:26,959
this all come together you know skills that you're building
5680
12:15:31,919 --> 12:15:37,119
so let's talk about exponents and logarithms so the exponential
5681
12:15:38,720 --> 12:15:45,360
is this two to the exponent three two to the third power equals
5682
12:15:45,919 --> 12:15:53,279
we've been doing this so far in algebra then logarithm is the same
5683
12:15:53,279 --> 12:16:04,319
so this same information the log base two of eight equals three so
5684
12:16:04,319 --> 12:16:12,159
exponent that's what we want to know that's what we want to know
5685
12:16:12,160 --> 12:16:17,360
far and in most calculators you know two to the third no problem i
5686
12:16:17,360 --> 12:16:23,919
calculator in python they don't even have to import anything but
5687
12:16:23,919 --> 12:16:30,720
and i know what i often call the result if i know the base i know
5688
12:16:30,720 --> 12:16:36,400
is what i don't know then that sometimes becomes a problem
5689
12:16:36,400 --> 12:16:43,760
nicely like this works out but supposing you know it wasn't a nice
5690
12:16:43,760 --> 12:16:48,959
even nice exponent like three supposing you know two to what
5691
12:16:50,080 --> 12:16:56,959
it's going to be some weird decimal but how do i how do i get that
5692
12:16:56,959 --> 12:17:02,319
to appreciate that you know uh john napier you know spent like
5693
12:17:02,319 --> 12:17:06,480
20 years of his life figuring this out and making tables and now
5694
12:17:06,480 --> 12:17:12,000
button on the calculator and we're going to look at also how to
5695
12:17:12,000 --> 12:17:18,080
logarithms we do have to import something but you know we'll
5696
12:17:18,080 --> 12:17:24,400
than spending 20 years years of your life figuring this out so if
5697
12:17:24,400 --> 12:17:31,680
um you know the the base is always going to be whatever you know
5698
12:17:31,680 --> 12:17:37,840
what i call the base so if i have you know log base two of eight
5699
12:17:37,839 --> 12:17:44,799
now what's interesting is our count in our calculators we you know
5700
12:17:44,800 --> 12:17:57,200
you'll see a log button now if i have the log if i just say the
5701
12:17:57,199 --> 12:18:03,119
i don't see any number there if i don't see a number then it's
5702
12:18:03,120 --> 12:18:09,120
and we call that the common log because our number system is base
5703
12:18:09,120 --> 12:18:15,440
write that and so the log of a hundred is two because 10 to the
5704
12:18:16,480 --> 12:18:22,720
and we're going to use this a lot of times for working with
5705
12:18:22,720 --> 12:18:29,040
converting decimals so that you know that's that's where a lot of
5706
12:18:29,040 --> 12:18:34,480
the common log and then i might even if i'm doing things like
5707
12:18:34,480 --> 12:18:42,080
the floor function because if you know what's the log uh you know
5708
12:18:42,080 --> 12:18:47,040
two point something but then for converting it to scientific
5709
12:18:47,040 --> 12:18:52,879
the two because then that tells me to move the decimal place too
5710
12:18:52,879 --> 12:19:02,639
1.5 times 10 to the second you see you know different things that
5711
12:19:02,639 --> 12:19:08,479
converting this for scientific notation all right other
5712
12:19:10,000 --> 12:19:17,279
that exponents and logarithms they're inverses of each other so if
5713
12:19:17,279 --> 12:19:29,680
um if i have the log base two of two to the third then or actually
5714
12:19:29,680 --> 12:19:36,160
a definite number i'm going to call this x because then anytime
5715
12:19:37,120 --> 12:19:45,760
the log of the exponent anytime you have a function of its inverse
5716
12:19:45,760 --> 12:19:55,120
now notice then what we're saying here the log base two so two to
5717
12:19:55,120 --> 12:20:04,319
x oh x is the exponent you know makes sense and the same type of
5718
12:20:04,319 --> 12:20:18,720
to the log base two of x exponent same thing that's exponent and
5719
12:20:18,720 --> 12:20:27,360
look at this log base two of x so it's two to what exponent gets
5720
12:20:27,360 --> 12:20:32,160
want the exponent two to what exponent gets me x and whatever the
5721
12:20:32,160 --> 12:20:41,360
am and then in fact taking two to that exponent so i would end up
5722
12:20:41,360 --> 12:20:48,160
we're going to use these inverses and this is where it becomes
5723
12:20:48,160 --> 12:21:00,960
for whatever base i have if i'm solving something if i have three
5724
12:21:01,680 --> 12:21:07,760
that doesn't work out nicely if it was 27 x is three that's nice
5725
12:21:07,760 --> 12:21:13,520
on the calculator what am i going to put on the calculator well
5726
12:21:13,519 --> 12:21:23,359
x equals something well if it's three to the x then if i take the
5727
12:21:25,040 --> 12:21:34,239
of this three to the x and then on the other side it's going to be
5728
12:21:35,440 --> 12:21:40,319
so in algebra in the things you know i do the same thing to both
5729
12:21:40,319 --> 12:21:44,559
do well one of the things i can do to both sides is take the log
5730
12:21:44,559 --> 12:21:51,759
same base so if i take the log and i pick base three because of
5731
12:21:51,760 --> 12:21:57,599
down to x and then over here i have the log base three of 25 which
5732
12:21:57,599 --> 12:22:03,760
calculator and we'll see in the code you know we're going to
5733
12:22:03,760 --> 12:22:11,360
able to do this you know no problem on the calculator or in the
5734
12:22:11,360 --> 12:22:17,520
thing is if you're on a calculator or you know you want to do
5735
12:22:19,360 --> 12:22:26,000
i could just do the common log for this it actually works out also
5736
12:22:26,000 --> 12:22:34,959
divided by the log of three so the log of this divided by the log
5737
12:22:34,959 --> 12:22:38,879
use common log or whatever i'd want for that so you know that's
5738
12:22:41,440 --> 12:22:47,120
you know what another way that like that works so change of base
5739
12:22:47,120 --> 12:22:53,440
in a situation where you don't have the ability to do the log of
5740
12:22:53,440 --> 12:23:00,000
you can use whatever logarithm you have and do this so that's
5741
12:23:00,000 --> 12:23:05,680
we use that inverse property when we're solving and that comes up
5742
12:23:05,680 --> 12:23:09,840
to look at things you know things that are growing exponentially
5743
12:23:10,639 --> 12:23:16,800
sometimes it's you know radioactive decay for dating carbon all
5744
12:23:16,800 --> 12:23:22,560
in this situation exponent my unknowns in the exponent and so i
5745
12:23:22,559 --> 12:23:31,279
figure that out the other log is going to be the so we have all
5746
12:23:32,400 --> 12:23:36,000
the common log which is base 10 but then i also have the natural
5747
12:23:38,959 --> 12:23:44,720
and if i was writing this it's i'm going to i'm going to write it
5748
12:23:44,720 --> 12:23:53,440
the logarithm functions in python they actually if i just say log
5749
12:23:53,440 --> 12:23:58,400
not base 10 so that that's really interesting in python the
5750
12:23:58,400 --> 12:24:06,319
another base there but if i was writing it out it's l n for
5751
12:24:06,319 --> 12:24:17,599
natural log of of anything so the natural log means that it's base
5752
12:24:18,879 --> 12:24:28,559
e is about equal to that 2.71828 1828 and then after that it's
5753
12:24:28,559 --> 12:24:42,559
it just that pattern stops so oh 2.71828 so he's about 2.71828
5754
12:24:42,559 --> 12:24:49,919
for a lot of continuous growth formulas so if i have you know the
5755
12:24:51,040 --> 12:24:54,959
well then my answer is going to be you know about one it's going
5756
12:24:54,959 --> 12:25:04,080
it's like 0.99 or something like that you know 0.99 and i can you
5757
12:25:04,080 --> 12:25:08,080
for for some other things and we'll see some of the applications
5758
12:25:08,080 --> 12:25:17,919
code but that's where if i have base e so if if it's base e i just
5759
12:25:17,919 --> 12:25:22,559
i can just write log and if it's any other base and the bases we
5760
12:25:22,559 --> 12:25:27,839
whole numbers but if it's any other base then i'm just going to
5761
12:25:29,519 --> 12:25:37,279
so okay so we take a look at this we'll see how we can actually
5762
12:25:37,279 --> 12:25:42,400
in the code and that's going to be pretty useful for some of the
5763
12:25:42,400 --> 12:25:50,480
so let's take a look at the code so when using logarithms in
5764
12:25:50,480 --> 12:25:59,440
library and now we have math dot log there we go math dot log and
5765
12:25:59,440 --> 12:26:07,920
and then the base so this is math dot log of 10 000 base 10 so
5766
12:26:07,919 --> 12:26:16,080
four this works out nicely for things that we know are going to be
5767
12:26:16,080 --> 12:26:24,000
show you that python weirdness sometimes even when you think it's
5768
12:26:24,000 --> 12:26:30,480
math dot log of a thousand base 10 so i expect this to be exactly
5769
12:26:31,279 --> 12:26:38,000
it gives me this long decimal so any of these even when you think
5770
12:26:38,000 --> 12:26:48,239
the way that this works behind the scenes you might want to just
5771
12:26:49,279 --> 12:26:56,000
so i'm going to round all this math dot log of a thousand base 10
5772
12:26:56,000 --> 12:27:02,639
to four decimal places so you just might want to build build that
5773
12:27:02,639 --> 12:27:06,800
get that answer and notice i still said four decimal places but
5774
12:27:06,800 --> 12:27:12,080
not rounding not needing decimal places it didn't have to give me
5775
12:27:12,959 --> 12:27:20,400
there we go so that's just the usefulness of it that it's just
5776
12:27:20,400 --> 12:27:27,040
in there all right so that said i have a few of these that i don't
5777
12:27:27,040 --> 12:27:33,599
just to show you what the exact answer might be so if i have base
5778
12:27:33,599 --> 12:27:42,400
and then we're going to do math dot log in this case 16 base 2 so
5779
12:27:42,400 --> 12:27:51,279
four and i don't have the log in there so if i have something like
5780
12:27:51,279 --> 12:27:55,760
rounding so you see it'll give you all that if you need these
5781
12:27:55,760 --> 12:28:01,760
for something it will give you that but there you go just whatever
5782
12:28:01,760 --> 12:28:09,440
natural log i'm going to import math again and notice here i can
5783
12:28:10,480 --> 12:28:15,600
and if i don't give it that second argument of what the base is
5784
12:28:16,319 --> 12:28:25,599
and e is about 2.7 so if we we do this we see you know it gives it
5785
12:28:25,599 --> 12:28:32,559
want to show you is as we were talking about before uh so math dot
5786
12:28:32,559 --> 12:28:37,919
math dot e is going to be the most exact you know it'll give you
5787
12:28:37,919 --> 12:28:46,239
have to just you know guess at it but also e to the fourth then
5788
12:28:47,120 --> 12:28:53,600
so if i have e to the fourth and then i take the log which is the
5789
12:28:53,599 --> 12:29:04,319
four because the log of that exponent or if i have e to the third
5790
12:29:04,319 --> 12:29:12,159
i use that math dot e to get the most exact uh approximation of e
5791
12:29:13,919 --> 12:29:19,839
argument then it will cancel out and that'll that'll work out the
5792
12:29:19,839 --> 12:29:26,239
you know 10 to the fifth and then log you know base 10 you know
5793
12:29:27,440 --> 12:29:33,440
just just to show you this all right so other good uses of log or
5794
12:29:34,080 --> 12:29:36,959
answering the question how long will it take for an investment to
5795
12:29:38,080 --> 12:29:44,000
and i still wanted to put the algebra in here so if we have our
5796
12:29:44,000 --> 12:29:50,639
so i have p and then i have the annuity what number p what what it
5797
12:29:50,639 --> 12:29:57,360
what number it ends up so if it's doubling then whatever i have
5798
12:29:58,080 --> 12:30:04,720
whatever the number is so i can divide both sides by p and then i
5799
12:30:06,080 --> 12:30:13,120
so as we were looking before about getting to exponents if my
5800
12:30:13,120 --> 12:30:19,520
it what's my base and then i'm going to take that log of both
5801
12:30:19,519 --> 12:30:25,439
take the natural log so on the left i have the natural log of two
5802
12:30:25,440 --> 12:30:32,160
of e to the rt as we just saw is going to be that exponent so
5803
12:30:32,160 --> 12:30:38,800
i'll take natural log and then they will cancel out the function
5804
12:30:38,800 --> 12:30:46,720
want to solve for t now i have rt divide by r so i would have this
5805
12:30:46,720 --> 12:30:54,080
by r gives me how long it would take money to double so we can
5806
12:30:54,080 --> 12:31:02,080
just define r as the rate here you know two percent you know sort
5807
12:31:02,080 --> 12:31:10,000
natural log of two divided by the rate so i am going to round this
5808
12:31:10,959 --> 12:31:16,799
argument there log two and divided by r and also the rounding is
5809
12:31:16,800 --> 12:31:23,840
whole number there we go and we get it to be 35 years so if
5810
12:31:23,839 --> 12:31:29,919
35 years from now it'll be double and like i said as a low
5811
12:31:29,919 --> 12:31:37,040
whatever now 35 years from now it'll be about double that price so
5812
12:31:37,040 --> 12:31:43,680
you know some investment you know oh nine you know nine percent
5813
12:31:43,680 --> 12:31:47,919
to be doing okay i put money in this investment how long will it
5814
12:31:49,360 --> 12:31:56,639
in this case eight years so there we go so you know some people
5815
12:31:56,639 --> 12:32:04,159
for what they invest in and there we go answering that question
5816
12:32:04,160 --> 12:32:10,240
i want to show you this pattern of graphing the exponent and the
5817
12:32:10,239 --> 12:32:18,559
all the usual imports for any graph we're going to do all the
5818
12:32:18,559 --> 12:32:26,799
dimensions here and we've done this before when we use numpy i
5819
12:32:26,800 --> 12:32:35,280
points here because then i'm going to create my numpy array np dot
5820
12:32:35,279 --> 12:32:41,199
using this many points so there's my array now for this i also
5821
12:32:41,199 --> 12:32:50,639
array specifically because my x min i don't want it to go down to
5822
12:32:50,639 --> 12:32:58,639
at 0.01 and we'll see that in a second and then again set up all
5823
12:32:59,839 --> 12:33:06,479
i'm going to graph this first line here y1 equals math dot e to
5824
12:33:06,480 --> 12:33:13,120
i imported math just for this using math dot e so if i'm graphing
5825
12:33:13,760 --> 12:33:21,680
and then line two so then if it's e to the x i want to do the
5826
12:33:21,680 --> 12:33:28,639
and i didn't use the math one here i wanted to use the np dot log
5827
12:33:28,639 --> 12:33:34,639
graphing so numpy has log built in also so i want to use that
5828
12:33:34,639 --> 12:33:42,879
with with the numpy array and that's this is why i wanted x2 as my
5829
12:33:42,879 --> 12:33:49,680
can't be zero and they can't be negative so i didn't this actually
5830
12:33:49,680 --> 12:33:56,800
but it would still graph it just with that error and i didn't feel
5831
12:33:56,800 --> 12:34:06,639
that other array starting at 0.01 so there we go so now i have e
5832
12:34:07,760 --> 12:34:16,160
it's just y equals x all right so this is what this looks like and
5833
12:34:16,160 --> 12:34:22,240
upward that's the exponential function and going to the left it
5834
12:34:22,239 --> 12:34:28,720
it just gets really really close beyond what this display can show
5835
12:34:29,519 --> 12:34:36,879
and then this orange line that logarithm it the x value can't be
5836
12:34:36,879 --> 12:34:43,599
has this curve to it as x gets bigger this increases but it not so
5837
12:34:43,599 --> 12:34:50,400
goes on and on and then the green line is y equals x so if it
5838
12:34:50,400 --> 12:34:57,599
each other across that line that's true like any inverse functions
5839
12:34:57,599 --> 12:35:05,360
the line y equals x so kind of cool how that works out so we see
5840
12:35:06,239 --> 12:35:14,000
e to the x natural log of x and just as a slight comparison i
5841
12:35:14,000 --> 12:35:20,959
two to the x and i'm going to use this and comment out this other
5842
12:35:20,959 --> 12:35:30,639
have two to the x all right there you go two exponent x and then
5843
12:35:31,360 --> 12:35:37,919
and again i'm going to use numpy and you see numpy's log instead
5844
12:35:37,919 --> 12:35:43,119
have different functions so this is so log is natural log log two
5845
12:35:43,120 --> 12:35:50,000
there's log 10 so those are the main ones you'd you'd want to be
5846
12:35:50,000 --> 12:35:56,480
gonna have log two here and then the line y equals x so if i run
5847
12:35:56,480 --> 12:36:07,200
different because two is not as big as 2.7 but very similar and
5848
12:36:07,199 --> 12:36:11,759
drawing i i wouldn't be able to draw the subtle differences so i
5849
12:36:11,760 --> 12:36:20,080
look the same you know exponential logarithmic y equals x there we
5850
12:36:20,080 --> 12:36:28,000
good good estimates here all right we can also use logs for
5851
12:36:28,000 --> 12:36:35,279
it print out 3.2 times 10 to the fifth now i wrote that in
5852
12:36:35,279 --> 12:36:44,159
with with all the zeros here and here i have it as a negative
5853
12:36:44,160 --> 12:36:50,160
second there we go and you might be wondering about that comment
5854
12:36:50,160 --> 12:36:58,720
why that's an important thing and there we go uh we see the output
5855
12:36:58,720 --> 12:37:06,319
three gets weird very interesting because the exponent of positive
5856
12:37:06,319 --> 12:37:13,919
know got a little weird too and you see just the way it works
5857
12:37:13,919 --> 12:37:18,479
we would think that it would stop there and that'd be fine but it
5858
12:37:18,480 --> 12:37:25,120
and then a five at the end unnecessary but as i was mentioning
5859
12:37:25,120 --> 12:37:32,720
will solve a lot of these problems so you know i just use this
5860
12:37:32,720 --> 12:37:41,919
so i have this 10 4.5 times 10 to the negative four and i'm going
5861
12:37:41,919 --> 12:37:48,159
places so if i have a negative exponent let's say negative four
5862
12:37:48,160 --> 12:37:54,720
decimal places and then that gives all of these because it'd be
5863
12:37:54,720 --> 12:38:05,760
place to show that so you see rounding rounding again works out
5864
12:38:05,760 --> 12:38:13,680
negative five and greater it forces the scientific notation so as
5865
12:38:13,680 --> 12:38:18,959
going to print this out i already have it in scientific notation i
5866
12:38:18,959 --> 12:38:26,080
decimal places doesn't matter the output python wants to put in
5867
12:38:26,080 --> 12:38:35,760
this e is not e 2.7 but it's 4.5 times 10 to this exponent so
5868
12:38:35,760 --> 12:38:41,520
calculators use that notation also we can convert something to
5869
12:38:41,519 --> 12:38:50,000
if i take this so i want to get the number of decimal places so if
5870
12:38:50,000 --> 12:38:58,639
variable a so if i take the log of a and base 10 so this one i'm
5871
12:38:58,639 --> 12:39:07,440
take the log but since it's not 0.001 it's not going to work out
5872
12:39:07,440 --> 12:39:12,319
it's going to be like one point you know it's going to be like uh
5873
12:39:12,319 --> 12:39:18,080
is going to be four point something so that's why i want to do
5874
12:39:18,879 --> 12:39:26,159
exponent i want to chop off all the the extra decimals in my
5875
12:39:26,160 --> 12:39:33,040
that the floor of that is going to be the exponent so that's
5876
12:39:33,040 --> 12:39:44,000
four and then if i take n i'm going to round that 10 divided by
5877
12:39:44,000 --> 12:39:52,480
works for larger numbers too but if i take that and then round it
5878
12:39:52,480 --> 12:39:59,200
two decimal places that's fine that's n i could stop there but i
5879
12:39:59,199 --> 12:40:06,399
in case there's rounding errors because it could work out
5880
12:40:06,400 --> 12:40:13,840
greater than 10 you know that that happens and so in that case
5881
12:40:13,839 --> 12:40:19,839
i still get true scientific notation one number than the decimal
5882
12:40:19,839 --> 12:40:25,439
if it's greater than i'm going to increase the exponent now for
5883
12:40:25,440 --> 12:40:35,920
point zero zero zero five and there we go it gives you point zero
5884
12:40:35,919 --> 12:40:43,519
ten to the negative four and then this should work for all kinds
5885
12:40:43,519 --> 12:40:48,639
converting it to scientific notation if you wanted to so these are
5886
12:40:48,639 --> 12:40:52,400
logarithms you know we can see the graph that's pretty interesting
5887
12:40:52,400 --> 12:40:59,120
the applications the solving sometimes if my unknowns in the
5888
12:40:59,120 --> 12:41:06,000
to and from scientific notation so these are a few applications of
5889
12:41:06,000 --> 12:41:14,000
you will find even more so you can make use of make use of this
5890
12:41:14,000 --> 12:41:22,400
here we have the foundational math three certification three and
5891
12:41:22,400 --> 12:41:29,440
going to make a copy first of all and work through this whole
5892
12:41:29,440 --> 12:41:38,880
google drive and then from your copy we'll do first step like
5893
12:41:38,879 --> 12:41:48,799
testing library and later on in this unit or the next unit we'll
5894
12:41:48,800 --> 12:41:57,920
and how you can set up your own virtual your own library hosted on
5895
12:41:57,919 --> 12:42:05,279
into whatever notebooks you want so you know as you can see here
5896
12:42:05,279 --> 12:42:12,239
whatever notebooks you want so you know as we get through this
5897
12:42:12,239 --> 12:42:19,040
of setting it up and then you'll learn how to set up all these
5898
12:42:19,040 --> 12:42:28,720
comments here you know install requests here's the library and
5899
12:42:28,720 --> 12:42:39,919
library take it uh as as a new file locally here uh behind the
5900
12:42:39,919 --> 12:42:50,400
it and it's imported there we go and this last thing says that yes
5901
12:42:50,400 --> 12:43:00,560
on to the next step there we go and remember the runtime run uh it
5902
12:43:01,599 --> 12:43:08,319
consecutively at the most or about a half hour of inactivity so
5903
12:43:08,319 --> 12:43:14,239
you know working on part of this you leave come back then you go
5904
12:43:14,239 --> 12:43:22,959
so we were looking a lot of into graphing before now we're going
5905
12:43:22,959 --> 12:43:32,479
i have let's say y is greater than or equal to 2x well if i have
5906
12:43:32,480 --> 12:43:40,480
do i shade that well we have this argument here fill between and
5907
12:43:40,480 --> 12:43:48,480
so we're going to go here import matplot library and import numpy
5908
12:43:50,080 --> 12:43:59,360
and we're going to set our window like we were doing before how
5909
12:43:59,839 --> 12:44:08,239
linspace give our points setting up the graph all this is very
5910
12:44:08,239 --> 12:44:16,959
fancy put a title on there so we have the plot title y1 just like
5911
12:44:16,959 --> 12:44:25,120
i was graphing this just as a line we see all the similarities
5912
12:44:25,120 --> 12:44:34,480
and remember this we have plot these two and then we have this
5913
12:44:34,480 --> 12:44:43,200
we had this third argument so if you're working through this and
5914
12:44:43,199 --> 12:44:47,279
watching this video maybe hopefully you already did work through
5915
12:44:48,800 --> 12:44:55,360
you know double checking anything you did or if you want any
5916
12:44:55,360 --> 12:45:07,919
we have the second arguments are the fill between so this one
5917
12:45:07,919 --> 12:45:17,040
fill between so we still have one x value and the y values are
5918
12:45:17,040 --> 12:45:27,840
zero and i'm just going to run this to show you you see it fills
5919
12:45:29,919 --> 12:45:34,559
that doesn't matter you know that's not a consistent you know over
5920
12:45:35,360 --> 12:45:42,959
is up top and over on the right it's down to zero but thinking
5921
12:45:42,959 --> 12:45:50,080
oh what if i just change that to if i want to shade above what if
5922
12:46:00,879 --> 12:46:10,319
and then we're always shading above between that line and the
5923
12:46:10,319 --> 12:46:17,680
below you can change it to y min and there we go and when we do
5924
12:46:18,800 --> 12:46:28,319
so part two well we had this one is a nice solid line and remember
5925
12:46:28,319 --> 12:46:40,080
to but what if i wanted you know not that solid line so we have
5926
12:46:40,080 --> 12:46:51,279
here we know the logic of this so now if i have y min now that's
5927
12:46:51,279 --> 12:46:59,680
below and this is the only thing we're going to change if i have
5928
12:46:59,680 --> 12:47:12,559
gives me a line until i do the fill between but what if i wanted
5929
12:47:14,000 --> 12:47:26,160
so we see you know see if i have b dash dash r dash dash gives it
5930
12:47:26,160 --> 12:47:34,080
and we run this so now we see and sometimes i'll do that i'll make
5931
12:47:34,080 --> 12:47:40,560
stands out if i made the blue just blend in so now we know this
5932
12:47:44,080 --> 12:47:50,880
and there we go yes and knowing now that we can make some lines
5933
12:47:50,879 --> 12:47:57,919
you can define these lines we can make art for example we can do
5934
12:47:57,919 --> 12:48:04,639
fill between two different graphs two different functions oh that
5935
12:48:05,919 --> 12:48:09,439
this defaulted to notice i didn't even define the color blue here
5936
12:48:10,400 --> 12:48:16,959
but i can define that face color what color do i want to do i want
5937
12:48:16,959 --> 12:48:23,599
so if you know like a lot of your basic colors you actually can
5938
12:48:23,599 --> 12:48:29,760
that you know i want to be green put it in green in quotes single
5939
12:48:29,760 --> 12:48:39,599
color names this will work out so that'll work so the directions
5940
12:48:39,599 --> 12:48:50,639
and then reverse the order so we see here like before here's the
5941
12:48:50,639 --> 12:49:01,440
plotting and remember we defined the x value up here once so
5942
12:49:01,440 --> 12:49:07,200
i'm not worried about making a particular line so two arguments
5943
12:49:07,199 --> 12:49:18,639
between and see what i have x y1 and between that and 10 or i
5944
12:49:18,639 --> 12:49:27,680
max but that's fine and then i add the other argument face color
5945
12:49:28,959 --> 12:49:36,639
and fill between now notice between y2 and y1 so you know we can
5946
12:49:36,639 --> 12:49:42,159
you know between other values that's this is this will come up
5947
12:49:42,720 --> 12:49:47,279
you can define your lines and then fill between these lines i mean
5948
12:49:49,040 --> 12:49:55,440
so then change this you know we have this color and same thing all
5949
12:49:56,319 --> 12:50:03,279
you know this line y3 and i'm going to fill between y3 and y2 next
5950
12:50:03,279 --> 12:50:12,959
function fill between y4 and y3 and so when we run this see that
5951
12:50:12,959 --> 12:50:19,199
there up to the top and then i did not decide to have another one
5952
12:50:19,199 --> 12:50:26,319
just left it here so if we take this and reverse the colors so
5953
12:50:26,319 --> 12:50:38,080
colors and make the first one blue there we go and we'll reverse
5954
12:50:38,080 --> 12:50:49,200
red at the end so the next one will be green and the next one will
5955
12:50:49,199 --> 12:50:59,680
be red there we go so now we have this and we see when we run it
5956
12:51:02,559 --> 12:51:09,040
so there we go interesting things you can do and if you were
5957
12:51:09,040 --> 12:51:14,319
whatever formulas you want remember you know we were looking at
5958
12:51:14,319 --> 12:51:20,480
you know quadratic you know uh exponential functions so if you
5959
12:51:20,480 --> 12:51:26,880
and you can just define that you want it to be between something
5960
12:51:28,319 --> 12:51:36,800
where i define this linspace here once so that's the reason why
5961
12:51:36,800 --> 12:51:43,200
but you could always for each of them you could define lines you
5962
12:51:43,199 --> 12:51:51,039
within certain values and you can make all kinds of shapes and
5963
12:51:51,040 --> 12:51:57,919
with other graphing i kept these axis lines but you could always
5964
12:51:57,919 --> 12:52:05,360
you just keep your window size but then you could always eliminate
5965
12:52:05,360 --> 12:52:14,720
again you can get creative with this make some different art all
5966
12:52:15,839 --> 12:52:25,519
looking further into factoring into representing equations so
5967
12:52:25,519 --> 12:52:36,399
mono is one and then it actually overlaps n o m is name that exact
5968
12:52:36,400 --> 12:52:47,200
and then i al just makes it a noun so one thing one term so each
5969
12:52:47,199 --> 12:52:55,519
and variable and an exponent we don't think about that all the
5970
12:52:55,519 --> 12:53:01,439
definitely i see a negative sign i see the coefficients three x to
5971
12:53:02,000 --> 12:53:13,599
but if i have you know all of these the term x also has that so
5972
12:53:13,599 --> 12:53:19,199
first power just things to think about because that really comes
5973
12:53:19,199 --> 12:53:28,719
that we do with factoring etc even even a constant like five is
5974
12:53:28,720 --> 12:53:37,360
five x to the zero because x to the zero is one and this will help
5975
12:53:37,360 --> 12:53:43,919
each of these you can have a monomial and just make sure that you
5976
12:53:43,919 --> 12:53:53,279
sometimes these values might be one or zero and you might not
5977
12:53:53,279 --> 12:53:59,839
now this is just a very interesting within simp i we have eq which
5978
12:53:59,839 --> 12:54:08,879
and you see how this equation is eq and then in parentheses i'm
5979
12:54:09,919 --> 12:54:14,479
and then what's on the right so i define it as an equation and
5980
12:54:14,480 --> 12:54:26,080
by a comma so you see what we have here so just showing you that
5981
12:54:26,080 --> 12:54:32,880
could use this within simp i for some other things that you might
5982
12:54:32,879 --> 12:54:39,839
of this course you know if you wanted to make sure you have a nice
5983
12:54:39,839 --> 12:54:47,199
up eq you know use your variables that you already have and you
5984
12:54:47,199 --> 12:54:56,399
symbol here so we could do this and then just display it and then
5985
12:55:00,879 --> 12:55:06,479
and so we have monomials one thing binomial bi is two trinomial
5986
12:55:08,239 --> 12:55:13,599
is three and after that we kind of stop counting so polynomial is
5987
12:55:13,599 --> 12:55:22,000
three and we'll usually put them in order so we take x as the
5988
12:55:22,000 --> 12:55:28,000
the highest exponent and if we want to graph this then it would be
5989
12:55:29,279 --> 12:55:38,559
so there we go here's your example and it continued on to the next
5990
12:55:38,559 --> 12:55:46,159
know this i this is the normal standard standard form setup so you
5991
12:55:46,160 --> 12:55:54,160
coefficients and then display them and so there's what we have
5992
12:55:54,160 --> 12:56:04,800
so we're going to use this display and we're also going to use
5993
12:56:04,800 --> 12:56:12,400
to import everything from simpy so now we have these symbols and
5994
12:56:12,400 --> 12:56:18,080
i do want to cast it as an integer though i mean realistically the
5995
12:56:18,080 --> 12:56:28,560
integers so there's our coefficient and a and b continue to prompt
5996
12:56:28,559 --> 12:56:47,279
you can do is you can copy this and make this c input coefficient
5997
12:57:02,160 --> 12:57:08,800
all right so we've done that and now we want to display the full
5998
12:57:08,800 --> 12:57:21,840
display ax to the third bx squared and then we do the rest plus c
5999
12:57:24,000 --> 12:57:32,319
plus d and notice we you might have remembered this from before
6000
12:57:32,319 --> 12:57:39,599
i just put these right next to each other ax means i'm multiplying
6001
12:57:40,319 --> 12:57:50,879
notation i have to put that multiplying in there so it is ax to
6002
12:57:50,879 --> 12:58:00,079
go now we have this this is great we have this in python notation
6003
12:58:00,080 --> 12:58:08,000
we want to display this in a nice way oh well i have to convert
6004
12:58:10,800 --> 12:58:17,440
way we're going to you know to display math terminal math formulas
6005
12:58:18,800 --> 12:58:26,319
i'm going to convert that python to there you go so if we have
6006
12:58:37,519 --> 12:58:46,639
so you see we can take this and convert it that way you have all
6007
12:58:46,639 --> 12:58:54,400
thinking ahead we're building things that you can use you have all
6008
12:58:54,400 --> 12:59:01,919
coefficients you could do other math to this here and then maybe
6009
12:59:04,160 --> 12:59:12,160
this this formula in a nice way so there we go that's what we have
6010
12:59:14,559 --> 12:59:21,519
so this is going through so interactive polynomial so now we're
6011
12:59:21,519 --> 12:59:28,879
this you know here's well quadratic but there we go and given this
6012
12:59:30,480 --> 12:59:36,400
we're going to adjust each of these coefficients so again in doing
6013
12:59:37,760 --> 12:59:44,160
certification notebook you should see that this is coming up you
6014
12:59:44,959 --> 12:59:49,519
and hopefully you've already worked through this and you know
6015
12:59:49,519 --> 12:59:56,959
you were stuck on or if you forgot so remember we were doing
6016
12:59:57,680 --> 13:00:05,199
and we're going to bring in the interactive from the widgets there
6017
13:00:06,319 --> 13:00:14,959
and remember these the function of a b and so for this one we're
6018
13:00:14,959 --> 13:00:23,680
third slider so there we go so my function needs to include c
6019
13:00:26,959 --> 13:00:33,919
because i need these three inputs great and then all the rest of
6020
13:00:34,480 --> 13:00:39,120
ax squared plus bx i have to add this plus c
6021
13:00:39,120 --> 13:00:46,959
c and so that will show the plot and then we want to make all
6022
13:00:48,400 --> 13:00:53,440
i'm going to run this function a b i just need c
6023
13:00:58,319 --> 13:01:00,480
so we can just copy that comma
6024
13:01:07,919 --> 13:01:15,199
so now we will have three sliders a b and c and we have the
6025
13:01:15,199 --> 13:01:24,399
display the interactive plot so there we go so that's how we can
6026
13:01:24,400 --> 13:01:33,760
you know using the same thing you can modify this to have four
6027
13:01:33,760 --> 13:01:39,680
looks like nothing because everything is zeroed out but as soon as
6028
13:01:41,360 --> 13:01:49,199
then we have a quadratic you know negative all right so that's
6029
13:01:49,199 --> 13:01:54,319
and it's always interesting to move these and see what this does
6030
13:01:55,199 --> 13:02:03,839
so you can tinker with this and see remember that just moves it up
6031
13:02:08,080 --> 13:02:13,120
there we go so you can take these and you can tinker with you know
6032
13:02:13,120 --> 13:02:19,280
code test pass but these notebooks you can always tinker with
6033
13:02:19,279 --> 13:02:24,159
you know you've learned that step you can go back in there and
6034
13:02:24,160 --> 13:02:30,480
see let's see what it looks like so now we're going to do
6035
13:02:30,480 --> 13:02:40,080
our exponential function y equals a times b to the x and there we
6036
13:02:40,080 --> 13:02:49,200
zero then we'll have an upward or as long as a is greater than one
6037
13:02:49,199 --> 13:02:58,879
thing as long as b is greater than one we'll curve upward all
6038
13:02:58,879 --> 13:03:05,599
some of the exponential functions the so what we're going to do is
6039
13:03:05,599 --> 13:03:11,599
see the sliders and then change the slider so that a actually does
6040
13:03:11,599 --> 13:03:21,199
instead of positive so here we have all these importing same
6041
13:03:21,199 --> 13:03:27,839
minimum and y maximum a lot bigger things grow exponentially so
6042
13:03:27,839 --> 13:03:35,759
decent graph here we just have a and b and you see one to nine we
6043
13:03:37,440 --> 13:03:40,639
so when we run this we're just going to see what this looks like
6044
13:03:45,760 --> 13:03:56,160
either one you see as i increase this it gets to be steeper
6045
13:03:56,480 --> 13:04:03,680
but we see the general shape of this it just gets to be steeper
6046
13:04:03,680 --> 13:04:11,040
it just gets to be steeper and then if i change a
6047
13:04:14,160 --> 13:04:17,280
i'll even make this low because it don't it still will be
6048
13:04:19,279 --> 13:04:25,279
so that's that's really all these you know they kind of do the
6049
13:04:25,279 --> 13:04:35,040
thing maybe b has a little more of an effect but then you see it's
6050
13:04:35,040 --> 13:04:44,319
upward curve and then as the x values get negative this really
6051
13:04:44,319 --> 13:04:50,000
get it's beyond what the resolution of any computer screen could
6052
13:04:50,000 --> 13:04:55,360
in you know it looks like it doesn't touch and then it looks like
6053
13:04:55,360 --> 13:05:05,040
then it doesn't so you know that's the general trend so if we make
6054
13:05:05,040 --> 13:05:14,000
need to do one more thing because this interactive graph takes
6055
13:05:14,000 --> 13:05:20,720
net making it negative negative one is not the lowest we have to
6056
13:05:21,519 --> 13:05:27,519
is the low value and negative one is the high value remember
6057
13:05:27,519 --> 13:05:36,479
we don't switch those also then we would get an error so we get
6058
13:05:36,480 --> 13:05:44,319
see just making the a value negative would make the whole graph go
6059
13:05:45,120 --> 13:05:51,040
b to the x would be positive still so then a being negative there
6060
13:05:52,319 --> 13:05:57,919
and just a note making b negative i'm not going to even worry
6061
13:05:57,919 --> 13:06:04,559
we did that it works for integer values of the exponent but since
6062
13:06:04,559 --> 13:06:10,239
it would be integer it would be work it would work and it would be
6063
13:06:10,239 --> 13:06:16,079
an even exponent negative if it's an odd exponent and it would go
6064
13:06:16,080 --> 13:06:24,880
those in between values because that would be mathematically
6065
13:06:24,879 --> 13:06:29,360
would actually be imaginary they wouldn't they would not
6066
13:06:29,360 --> 13:06:35,760
sometimes if we had you know some of them would and it would just
6067
13:06:35,760 --> 13:06:42,480
not even going to mess with that changing b to negative it just
6068
13:06:42,480 --> 13:06:48,080
anything but behind the scenes that's what's happening it works
6069
13:06:48,080 --> 13:06:54,480
doesn't work out nicely for others and you know a graph would be a
6070
13:06:54,480 --> 13:07:01,360
that does work out nicely percent increase so hopefully you
6071
13:07:02,319 --> 13:07:08,480
working through it in the previous unit but then we have you know
6072
13:07:08,480 --> 13:07:13,120
and if i were to graph this so we have a equals p times one plus r
6073
13:07:13,839 --> 13:07:20,079
and a is annuity and that would be the y value if you were
6074
13:07:20,080 --> 13:07:26,319
p and you would know r so t would be time in years but that would
6075
13:07:26,319 --> 13:07:33,680
graphing it and so we have all this yes p is the principal the
6076
13:07:33,680 --> 13:07:46,800
rate converted to a decimal and t is time in years and just the
6077
13:07:46,800 --> 13:07:52,160
capitalized so it's just interesting in in my variables i kept
6078
13:07:52,160 --> 13:07:56,080
times you'll see that written you know they're lowercase but p
6079
13:07:59,760 --> 13:08:04,720
um all right so you have your starting amount so you can prompt
6080
13:08:04,720 --> 13:08:09,440
worry about changing the code well we are going to change this
6081
13:08:09,440 --> 13:08:15,760
amount as input and converting all these to float numbers so you
6082
13:08:15,760 --> 13:08:23,279
numbers percentage rate converted to a decimal and how many years
6083
13:08:23,279 --> 13:08:29,760
going to take this equation and put it down here in python terms
6084
13:08:29,760 --> 13:08:38,800
gotten from here so p times and remember i have to put the times
6085
13:08:38,800 --> 13:08:48,160
one plus the rate and all that to the exponent of time and there
6086
13:08:49,360 --> 13:08:57,760
equation to to python and then we'll print out the annuity so when
6087
13:08:57,760 --> 13:09:08,880
one thousand just take these nice even numbers all right and we
6088
13:09:08,879 --> 13:09:17,519
that'd be five percent and how many years then let's see uh let's
6089
13:09:19,120 --> 13:09:22,800
and i didn't worry about putting in another function around this
6090
13:09:22,800 --> 13:09:28,960
but there you go to two decimal places this is what the annuity
6091
13:09:28,959 --> 13:09:38,639
percent for seven years and then we have percent decrease very
6092
13:09:38,639 --> 13:09:47,519
subtracting inside the parentheses because it's one minus three
6093
13:09:47,519 --> 13:09:54,319
does happen we have car value values of cars or some other
6094
13:09:54,319 --> 13:10:00,879
certain percentage rate every year the decay of some elements so
6095
13:10:00,879 --> 13:10:07,119
certain elements like carbon 14 that are very predictable so that
6096
13:10:07,919 --> 13:10:11,279
knowing how much that we can measure how much that is we can
6097
13:10:12,160 --> 13:10:16,800
the age of something some sales discounts maybe there's something
6098
13:10:16,800 --> 13:10:22,319
at a percentage you know every week if it's not sold so you have
6099
13:10:23,839 --> 13:10:30,719
and notice we're going to do same thing prompt for pr and t and
6100
13:10:31,279 --> 13:10:39,919
very similar p times and then in parentheses one minus r close the
6101
13:10:39,919 --> 13:10:47,119
so there we go and we see you know the jupyter notebook the colab
6102
13:10:47,120 --> 13:10:54,800
us tool tips and advice on what variable and everything so there
6103
13:10:54,800 --> 13:11:04,400
run it all right so there you go so let's just say i had my you
6104
13:11:04,400 --> 13:11:17,680
that uh decreases at 0.09 which might be the you know rate of
6105
13:11:18,720 --> 13:11:21,680
how many years will decrease you know let's just say 10
6106
13:11:21,680 --> 13:11:29,599
so there you go that twenty thousand car twenty thousand dollar
6107
13:11:30,160 --> 13:11:35,920
depreciation is nine percent so it loses nine percent of its value
6108
13:11:35,919 --> 13:11:41,839
then ten years later that car is worth seventy seven hundred
6109
13:11:41,839 --> 13:11:48,719
that might be the case i mean you know this is not uh don't quote
6110
13:11:48,720 --> 13:11:51,760
for the sake of practicing it that that rate's probably realistic
6111
13:11:54,480 --> 13:11:59,360
all right so now we have compound interest which is very much like
6112
13:12:00,160 --> 13:12:05,520
but we're taking it you know we could use compound interest we
6113
13:12:05,519 --> 13:12:14,959
before if it's compounded once a year so now we have this formula
6114
13:12:15,760 --> 13:12:21,599
but it's r divided by n and then the exponent is nt so if it was
6115
13:12:22,160 --> 13:12:26,800
and is one so that doesn't that goes back to that formula we were
6116
13:12:26,800 --> 13:12:34,639
but where n is multiple times per year you know this is the
6117
13:12:35,199 --> 13:12:40,399
and remember that that's really and that's why we wanted for any
6118
13:12:40,400 --> 13:12:46,639
wanted to convert it to that formula that it's something that's a
6119
13:12:47,440 --> 13:12:53,040
easily adjust the rate of decrease that's why we wanted to convert
6120
13:12:53,040 --> 13:13:03,440
and we can then easily adjust this for how many years something
6121
13:13:03,440 --> 13:13:10,639
and in this case now we had the other twist also then for how many
6122
13:13:10,639 --> 13:13:15,760
every year i mean n being 12 that's pretty common you know a lot
6123
13:13:15,760 --> 13:13:22,720
you know they calculate things you know once a month so we're
6124
13:13:22,720 --> 13:13:29,360
amount all the rest very similar and then we're going to add this
6125
13:13:29,360 --> 13:13:42,080
compounded so using this formula then we'll do p times and in
6126
13:13:42,080 --> 13:13:48,400
r over n i'd rather use extra parentheses just to make sure that
6127
13:13:48,400 --> 13:13:56,080
uh r divided by n and all that to the
6128
13:13:58,480 --> 13:14:05,440
so you see r over n in the extra parentheses to the nt but again
6129
13:14:05,440 --> 13:14:15,040
in parentheses n times t in parentheses so that way it stays
6130
13:14:15,040 --> 13:14:20,559
python might not but i want to make sure it doesn't accidentally
6131
13:14:21,279 --> 13:14:27,279
you know well then multiply by t so there we go p times one plus r
6132
13:14:28,400 --> 13:14:34,080
and that's going to give us our annuity so
6133
13:14:36,720 --> 13:14:42,480
just to be interesting let's use the same one we did two steps ago
6134
13:14:42,480 --> 13:14:52,319
converted to a decimal and we were saying that that was at 5.05
6135
13:14:54,000 --> 13:14:58,800
and and 12 is pretty common but i'm going to say 52 let's say it
6136
13:14:59,680 --> 13:15:01,919
you know every every week all year
6137
13:15:01,919 --> 13:15:14,639
here so what do we get 14 18 and 82 cents and let's just quick go
6138
13:15:19,599 --> 13:15:27,680
increase 1407 and 10 cents so look at that just that little amount
6139
13:15:27,680 --> 13:15:38,080
made us another 11 because it was compounded that often it's a
6140
13:15:38,959 --> 13:15:46,159
you have that little bit extra advantage this is money growing and
6141
13:15:46,160 --> 13:15:52,880
percent for that little bit more time you know gets you a few more
6142
13:15:52,879 --> 13:16:01,599
well okay 52 then maybe 365 would give you a little bit more
6143
13:16:01,599 --> 13:16:12,799
quick do that so remember that was 1418 and if we did this so that
6144
13:16:12,800 --> 13:16:24,000
we're going to do the same 0.05 the same seven years but then this
6145
13:16:24,000 --> 13:16:34,800
every day so you see 1419 it gave you another dollar so compared
6146
13:16:34,800 --> 13:16:41,040
made about 11 more dollars doing this every week but from every
6147
13:16:41,040 --> 13:16:48,160
one more dollar so there is a point to where it doesn't really get
6148
13:16:48,160 --> 13:16:55,040
we start thinking about well okay can I compound it multiple times
6149
13:16:55,040 --> 13:17:05,120
into continuous growth and continuous growth if i use that formula
6150
13:17:05,120 --> 13:17:12,240
times a day if i compounded that like three times a day and who
6151
13:17:12,239 --> 13:17:19,839
make n like an even thousand it starts approaching this other
6152
13:17:19,839 --> 13:17:26,479
recap so there you go that's you know money compounding annually
6153
13:17:26,480 --> 13:17:35,840
increase but we take it as annually and then n times per year we
6154
13:17:35,839 --> 13:17:41,519
n gets to be really big like i said like a thousand or something
6155
13:17:41,519 --> 13:17:52,719
formula pe to the rt and this is useful because as we see later
6156
13:17:52,720 --> 13:17:58,319
what the rate or the time would be if i know these other values so
6157
13:17:58,319 --> 13:18:06,080
complicated to i actually think this is a little bit easier
6158
13:18:06,080 --> 13:18:19,040
e is not just a random variable e is this constant equal to about
6159
13:18:19,040 --> 13:18:25,760
through that twice the next time it's not exact so it's not just
6160
13:18:25,760 --> 13:18:31,680
that would make it even easier but it actually after that second
6161
13:18:31,680 --> 13:18:42,239
different okay so we give the code that we're already going to
6162
13:18:43,360 --> 13:18:47,840
we're going to add one more import statement we're going to import
6163
13:18:47,839 --> 13:18:53,599
math.e you know you don't have to worry about typing in this
6164
13:18:53,599 --> 13:19:00,559
to take it to even more decimal places so we have the same thing
6165
13:19:03,599 --> 13:19:08,879
there you go time and that can be an integer that doesn't have to
6166
13:19:11,040 --> 13:19:16,239
and is going to be an integer because you can you can't like maybe
6167
13:19:16,239 --> 13:19:21,199
do you compound it you can't say like oh one time i kind of like
6168
13:19:22,000 --> 13:19:29,199
okay so now we're going to use these these same formulas we did
6169
13:19:29,199 --> 13:19:41,759
annual so that's going to be p times times one plus r exponent t
6170
13:19:41,760 --> 13:19:54,319
and then this one is going to be p times one plus the extra
6171
13:19:55,040 --> 13:20:07,279
exponent of nt so these are those two formulas and now this one
6172
13:20:07,279 --> 13:20:20,479
math.e so that's going to be p times math.e to the exponent of r
6173
13:20:23,040 --> 13:20:26,879
so there we go we see pe to the rt
6174
13:20:26,879 --> 13:20:36,239
t and now we have these three so we can prompt and let's compare
6175
13:20:37,199 --> 13:20:46,559
compounded n times per year i'm going to put an extra space in
6176
13:20:46,559 --> 13:21:04,079
so let's take something here and let's just say a principle of
6177
13:21:06,080 --> 13:21:14,959
and time and let's just say you know 15 years n and we only need
6178
13:21:14,959 --> 13:21:27,120
but let's say n is a normal 12 so given this compounded annually
6179
13:21:27,680 --> 13:21:40,959
2632 compounded 12 times a year 26,995 so wow that made you know
6180
13:21:40,959 --> 13:21:58,959
just by compounding it but look at that compounded continuously
6181
13:21:58,959 --> 13:22:04,959
see from here from once a year to multiple times we're talking
6182
13:22:04,959 --> 13:22:11,040
but then from that to compounding it continuously you know
6183
13:22:11,040 --> 13:22:31,760
up to about 700 more and it kind of evens out that oh and this one
6184
13:22:31,760 --> 13:22:40,800
it gave this error because i used the parentheses so if you're
6185
13:22:40,800 --> 13:22:47,120
you know these errors messages are supposed to be hints just to
6186
13:22:47,120 --> 13:22:55,440
parentheses and that is okay because python does no word of
6187
13:22:55,440 --> 13:23:04,000
it should give us not the error so there we go and should give us
6188
13:23:04,000 --> 13:23:22,559
so 11,000 rate 0.06 time 15 years and and we said it was 12 so we
6189
13:23:22,559 --> 13:23:31,519
message saying you know maybe i'll go in and change that that the
6190
13:23:31,519 --> 13:23:41,519
right so there we go prompting once and comparing these three
6191
13:23:41,519 --> 13:23:54,079
interest so now some of this comes in where we have you know some
6192
13:23:54,080 --> 13:24:02,959
often you know something you might be contributing to for
6193
13:24:02,959 --> 13:24:12,400
value so we have any of these formulas but we also contribute
6194
13:24:12,400 --> 13:24:18,239
will say month monthly that's that's kind of a normal normal thing
6195
13:24:18,239 --> 13:24:24,159
about like all the different values that that could be okay so we
6196
13:24:24,160 --> 13:24:31,680
to increase by a percentage and we're using just that simple
6197
13:24:31,680 --> 13:24:41,599
principal times rate times time so that is just simple interest
6198
13:24:42,480 --> 13:24:50,400
and for one month t equals one over 12 because time in years but
6199
13:24:50,400 --> 13:25:04,880
by 12 so here if i have this we can set up a loop here so prt but
6200
13:25:04,879 --> 13:25:16,079
ask for the monthly contribution all right now this annuity at the
6201
13:25:16,080 --> 13:25:25,279
have i have this i have this amount done so we'll keep that but
6202
13:25:25,279 --> 13:25:33,199
that we're going to keep updating so somebody said time in years
6203
13:25:34,000 --> 13:25:40,559
12 times t so monthly contributions for this long for a and range
6204
13:25:40,559 --> 13:25:48,959
t and now let's see we're just going to say first of all the
6205
13:25:50,160 --> 13:25:56,800
all right so now that annuity value is greater and then now we
6206
13:25:57,440 --> 13:26:06,959
so that's why simple interest is just the interest equals annuity
6207
13:26:06,959 --> 13:26:15,760
time and then times one over 12 and i'm just going to say divide
6208
13:26:17,120 --> 13:26:23,360
in principle times rate times time and then 1 12 is divided by 12
6209
13:26:23,360 --> 13:26:27,919
and now again i'm going to update annuity annuity equals annuity
6210
13:26:27,919 --> 13:26:37,439
annuity plus interest and because i'm making this a loop then you
6211
13:26:37,440 --> 13:26:41,920
are useful for not having to do a loop but we also wanted to add
6212
13:26:42,639 --> 13:26:48,559
and then there we go so you know we have a few things going on in
6213
13:26:48,559 --> 13:26:55,279
the loop it's going to go through and each time you know add the
6214
13:26:55,279 --> 13:27:06,080
percentage for that little bit of time you know now update annuity
6215
13:27:06,080 --> 13:27:17,279
this so starting amount maybe we can say 5 000 and annual
6216
13:27:17,279 --> 13:27:27,040
for you know some uh you know retirement account 0.08 and then
6217
13:27:27,040 --> 13:27:34,800
some of the things you might contribute and then have it grow for
6218
13:27:34,800 --> 13:27:47,760
like long amount of time 35 years there we go monthly contribution
6219
13:27:47,760 --> 13:27:53,360
we go so that's that's what we have you start out and then every
6220
13:27:53,360 --> 13:27:55,919
and you know we hope it's growing at that rate
6221
13:27:55,919 --> 13:28:06,000
so given this notice how notice what this number is that's a
6222
13:28:06,000 --> 13:28:13,599
is and to get some of these the the rate it it changes that's
6223
13:28:14,959 --> 13:28:21,199
it's a reasonable very reasonable estimate so putting money away
6224
13:28:21,199 --> 13:28:30,159
put five thousand dollars away and some good account for as eight
6225
13:28:31,599 --> 13:28:39,119
then each you know each paycheck you're contributing contributing
6226
13:28:39,120 --> 13:28:47,840
with a million dollars there you go things to think about that you
6227
13:28:47,839 --> 13:28:54,959
that you can put away this little bit forget about it for 35 years
6228
13:28:55,839 --> 13:29:02,639
and you know have this because if it's earning if it still is
6229
13:29:02,639 --> 13:29:08,639
estimate eight percent of that million is eighty thousand dollars
6230
13:29:08,639 --> 13:29:14,559
thousand dollars interest you can live on that and it still has
6231
13:29:14,559 --> 13:29:18,159
keep generating more interest so there you go
6232
13:29:20,720 --> 13:29:27,279
okay so we go from the positive saving money and having a million
6233
13:29:27,279 --> 13:29:35,919
payments and yes more like the word for death somebody originally
6234
13:29:35,919 --> 13:29:45,199
this death payment but nonetheless mortgage for any large amount
6235
13:29:45,199 --> 13:29:52,000
of time those other percent increase formulas won't quite do it
6236
13:29:52,000 --> 13:30:00,639
paying a lot more than is reasonable so this is the much more
6237
13:30:00,639 --> 13:30:04,319
that's the value of you know setting these up and writing the code
6238
13:30:04,319 --> 13:30:10,879
remember this formula or you know plug the numbers in every time
6239
13:30:10,879 --> 13:30:16,959
we were doing before pr and t and figure out what your monthly
6240
13:30:19,599 --> 13:30:26,400
so given that some large some huge amount of money and how banks
6241
13:30:26,400 --> 13:30:34,800
um something else but knowing how much you're going to borrow and
6242
13:30:34,800 --> 13:30:38,880
it through this formula and figure out what would your monthly
6243
13:30:38,879 --> 13:30:46,399
useful you and again this applies to mortgage or possibly car
6244
13:30:47,360 --> 13:30:55,360
large enough sum and a long enough time that this is a much better
6245
13:30:55,360 --> 13:31:02,239
this is the formula and again p is principal r is rate t is time
6246
13:31:02,239 --> 13:31:10,239
but n would be 12 each time so i just put 12 in there so it kind
6247
13:31:10,239 --> 13:31:17,599
formula but n is 12 each time you know there's no other setup you
6248
13:31:17,599 --> 13:31:23,519
payments or yearly no it's it's always monthly all right there we
6249
13:31:23,519 --> 13:31:32,799
so now i gave you a hint to do this use other variables i like
6250
13:31:32,800 --> 13:31:44,160
look at this r over 12 comes up a few times so you know we can
6251
13:31:44,160 --> 13:31:52,880
um there you go r over 12 is uh you know multiplier or if you
6252
13:31:52,879 --> 13:32:02,159
other variables you can do this there we go and since i don't have
6253
13:32:03,120 --> 13:32:11,200
um i could have i might have like just like math n for numerator
6254
13:32:11,199 --> 13:32:19,919
and so the payment would be n divided by d because that just might
6255
13:32:21,919 --> 13:32:30,879
um and then it would be p times n divided by d so i could have
6256
13:32:30,879 --> 13:32:42,719
r over 12 times and then in parentheses one over r over 12
6257
13:32:44,959 --> 13:32:52,080
oh one oh sorry one plus r over 12
6258
13:32:52,080 --> 13:33:03,520
12 and all that to the exponent in parentheses 12 times t
6259
13:33:07,760 --> 13:33:17,279
so r over 12 times one plus r over 12 to the exponent 12 t there
6260
13:33:17,279 --> 13:33:34,239
not bad and then i can have the denominator equals so one plus r
6261
13:33:34,239 --> 13:33:45,759
12 put up with some parentheses 12 t and now when i subtract one
6262
13:33:47,360 --> 13:33:49,279
you see then that's definitely not a part of that
6263
13:33:51,760 --> 13:33:57,040
so yeah and again you could add other variables you can make r
6264
13:33:57,040 --> 13:34:03,840
something like that you can make one plus r over 12 its own
6265
13:34:03,839 --> 13:34:09,279
do that i feel i felt like this wasn't that bad so but breaking up
6266
13:34:10,080 --> 13:34:13,040
and then payment times numerator over denominator
6267
13:34:15,599 --> 13:34:23,439
so we take a look at this and the amount borrowed we could just
6268
13:34:23,440 --> 13:34:34,800
uh annual percentage rate 0.07 you know some of the rates have
6269
13:34:34,800 --> 13:34:45,040
to say that for now and number of years 30 is pretty common and so
6270
13:34:45,040 --> 13:34:53,919
there we go so 1330 and change and this helps because then you say
6271
13:34:53,919 --> 13:34:58,080
the cost of the house and i have a down payment you know you get
6272
13:34:58,720 --> 13:35:05,120
that's one thing okay but what's really going to make the
6273
13:35:05,120 --> 13:35:16,319
your monthly payment be that's the important thing and you know
6274
13:35:16,319 --> 13:35:22,639
whatever your income is the monthly payment should be for mortgage
6275
13:35:22,639 --> 13:35:31,919
fourth of your income or less so just to remember you know if
6276
13:35:31,919 --> 13:35:38,000
month you should be making at least four times that or if you're
6277
13:35:38,000 --> 13:35:42,800
house because sometimes you might say oh yeah i'm making more than
6278
13:35:42,800 --> 13:35:46,960
end up being house poor yes you can afford your your mortgage
6279
13:35:46,959 --> 13:35:55,599
else all right so let's go on to exponents and logarithms with
6280
13:35:55,599 --> 13:36:04,000
they're inverse functions they're the same information rearranged
6281
13:36:04,000 --> 13:36:12,400
here two to the fourth power equals 16 so there you go two base
6282
13:36:12,400 --> 13:36:21,040
and then the log base two of 16 equals four there we go both of
6283
13:36:21,040 --> 13:36:26,000
rearranged and that's what logarithms are you know picture
6284
13:36:26,000 --> 13:36:32,080
sign oh two to the fourth power i know how to do that plug that
6285
13:36:32,080 --> 13:36:38,880
it's the exponent you don't know the log base two of 16 the answer
6286
13:36:38,879 --> 13:36:49,599
exponent gets me to that so uh this guy john napier like 400 years
6287
13:36:49,599 --> 13:36:55,439
400 years ago he realized that that was a missing piece that that
6288
13:36:57,120 --> 13:37:00,800
wanted to know the exponent for different things and he spent like
6289
13:37:00,800 --> 13:37:07,600
developing this and it was you know very useful you know the
6290
13:37:07,599 --> 13:37:14,080
you could like look them up now we have this at the benefit of you
6291
13:37:14,080 --> 13:37:19,840
and we're going to take it one more we're going to even write the
6292
13:37:19,839 --> 13:37:30,959
couple numbers and it'll calculate it so if you use the math
6293
13:37:30,959 --> 13:37:39,120
numpy library that's another way but if you use the math library
6294
13:37:39,120 --> 13:37:44,480
and then the arguments are you know the log of what so 16 and then
6295
13:37:45,839 --> 13:37:51,599
so there we go and if you don't have that first argument or if you
6296
13:37:51,599 --> 13:37:57,760
if you just say the log of 16 it takes it as base e but we'll get
6297
13:37:57,760 --> 13:38:06,560
we go the log base two of 16 so here's the code we're going to
6298
13:38:06,559 --> 13:38:12,799
always call the the exponent the result just because it reminds me
6299
13:38:12,800 --> 13:38:21,520
what i want so there we go so or you know that's the the result of
6300
13:38:22,559 --> 13:38:29,680
i had somebody input the base and we're going to input cast as a
6301
13:38:29,680 --> 13:38:41,919
but usually it's an integer and the result and cast that as a
6302
13:38:41,919 --> 13:38:53,439
change the next line okay math dot log and we were just saying
6303
13:38:53,440 --> 13:38:58,000
and it'll import this for it and it'll do this for you so that's
6304
13:38:58,000 --> 13:39:08,239
and we'll run it and this should check it for you there we go base
6305
13:39:08,800 --> 13:39:23,040
three result 81 so it should return four there we go nice you
6306
13:39:23,040 --> 13:39:29,919
in your head but if you have you know base you know three to what
6307
13:39:29,919 --> 13:39:34,799
you can do that in your head that's four but this is useful three
6308
13:39:34,800 --> 13:39:43,600
or gets you 85 you know when it becomes some weird decimal all
6309
13:39:43,599 --> 13:39:54,959
talked about e so uh this is the this is another use of a
6310
13:39:56,000 --> 13:40:04,160
if you have this formula annuity equals pe to the rt there we go
6311
13:40:05,040 --> 13:40:11,919
how long it will take for something to double and you'll see the
6312
13:40:11,919 --> 13:40:18,559
you know whatever i start out with p the annuity needs to be
6313
13:40:19,040 --> 13:40:25,840
then whatever p is and annuity is twice then i could cancel it out
6314
13:40:26,319 --> 13:40:33,599
so it simplifies to this and then now one of the many situations i
6315
13:40:33,599 --> 13:40:43,360
exponent well i have base e so math terms i would say natural log
6316
13:40:43,360 --> 13:40:49,360
the natural log of two on the left and the natural log of e to the
6317
13:40:49,360 --> 13:40:56,000
the natural log of e to the rt because that says e the natural log
6318
13:40:56,000 --> 13:41:07,120
this so e to what exponent gets me e to the rt well it's obviously
6319
13:41:07,120 --> 13:41:12,720
we know that take the natural log of both sides now we're in this
6320
13:41:12,720 --> 13:41:19,680
of two good thing i have a calculator to do this and then if i
6321
13:41:19,680 --> 13:41:29,519
double if i know the rate then i would just divide by the rate and
6322
13:41:29,519 --> 13:41:38,000
that math dot log and you see no other argument necessary if i
6323
13:41:38,000 --> 13:41:46,239
as what base it is it takes it as base e natural log so there we
6324
13:41:46,239 --> 13:41:56,239
rate as a decimal and for this one i just put the end just it's
6325
13:41:56,800 --> 13:42:02,960
the input comes in as a new line on a new line and once the person
6326
13:42:02,959 --> 13:42:10,479
just math dot log of two divided by r is time and we'll print out
6327
13:42:10,480 --> 13:42:17,040
this is pretty useful so you can run this now this one remember
6328
13:42:25,519 --> 13:42:34,959
let's say i have some investment growing at eight percent and it
6329
13:42:34,959 --> 13:42:41,040
six six years so some of the you know you might say all right if
6330
13:42:41,040 --> 13:42:47,680
percent and we can even round this down to eight and a half and
6331
13:42:47,680 --> 13:42:53,360
okay well eight and a half years it'll double 17 years it'll
6332
13:42:54,879 --> 13:43:02,159
and you know you could use this to estimate some outcomes all
6333
13:43:02,160 --> 13:43:07,280
10 it's the common log if you were writing this in math notation
6334
13:43:07,279 --> 13:43:15,599
log so uh with without the little number because then you know if
6335
13:43:15,599 --> 13:43:21,599
then oh we'll take it as base 10 because that's our number system
6336
13:43:21,599 --> 13:43:27,199
we're going to be using when we want to have you know how many
6337
13:43:27,199 --> 13:43:39,439
things for scientific notation so in the code you see we'll just
6338
13:43:41,519 --> 13:43:50,159
so you see uh if i don't say the base it's e but 10 even though
6339
13:43:50,160 --> 13:43:57,360
base there we go so if we have this and our number with several
6340
13:43:58,319 --> 13:44:04,159
and this one i just separated into two lines to show you can do
6341
13:44:06,639 --> 13:44:13,040
you know cast it as n the other reason to put this into two lines
6342
13:44:13,040 --> 13:44:19,279
line over here maybe even before writing python you know you might
6343
13:44:19,279 --> 13:44:23,680
you only want the lines to be so long you don't have to scroll
6344
13:44:23,680 --> 13:44:30,720
a design decision if i continued beyond this line it would still
6345
13:44:30,720 --> 13:44:37,360
that code but just as a convention for writing python code we
6346
13:44:37,360 --> 13:44:44,959
80 characters brings it over to that line so there we go i have
6347
13:44:44,959 --> 13:44:50,720
want to go further on that line so i just made it a separate line
6348
13:44:51,680 --> 13:45:02,879
all right now we have the round the code so this one we have math
6349
13:45:02,879 --> 13:45:16,559
take the log of that but i'm not gonna round but instead of
6350
13:45:16,559 --> 13:45:22,559
of this because i don't want the decimals i don't i don't want to
6351
13:45:23,199 --> 13:45:29,439
and i would just you know drop the decimals math dot floor that's
6352
13:45:29,440 --> 13:45:39,520
and that's actually what what we really want and this is a weird
6353
13:45:39,519 --> 13:45:44,399
exactly three it sometimes doesn't give you the answer you want i
6354
13:45:44,400 --> 13:45:51,840
python quirk so just bonus insight here after doing this enough
6355
13:45:51,839 --> 13:46:01,279
if statement here all right and we're going to print the exponent
6356
13:46:03,440 --> 13:46:13,920
there we go several digits so if i have point you know zero zero
6357
13:46:23,199 --> 13:46:27,519
there we go and if we remove the math dot four function
6358
13:46:30,080 --> 13:46:38,959
then it will just give us it'll be you know negative four point
6359
13:46:38,959 --> 13:46:50,000
just do that there we go so you can see and i'll just to compare
6360
13:46:50,000 --> 13:47:05,839
zero zero five all right and that's it now notice in positive
6361
13:47:05,839 --> 13:47:10,639
something or three if this was positive three point something and
6362
13:47:10,639 --> 13:47:17,120
it'd be down to three but with negative numbers the floor from
6363
13:47:17,120 --> 13:47:24,000
floor of that is negative four so just interesting insight and
6364
13:47:24,000 --> 13:47:31,680
because if you've gone through the the foundational math three and
6365
13:47:31,680 --> 13:47:35,840
on something you're what we want some other insight into some of
6366
13:47:36,480 --> 13:47:43,440
this helps all right now all that you know we can use these
6367
13:47:43,440 --> 13:47:51,840
something to double you know things like this uh number of decimal
6368
13:47:51,839 --> 13:47:58,079
exp for exponent because well first of all that's what we're
6369
13:47:58,080 --> 13:48:04,160
but also that leads to scientific notation you know how can i
6370
13:48:04,160 --> 13:48:11,760
numbers without all those zeros so if i had like 45 million oh but
6371
13:48:11,760 --> 13:48:20,639
to the seventh or point zero zero zero all these could be 4.5
6372
13:48:20,639 --> 13:48:26,800
and there we go so it's always n times 10 to an exponent and n is
6373
13:48:27,599 --> 13:48:36,000
so that's what we want you know because 4.5 that's i want that one
6374
13:48:36,000 --> 13:48:47,919
that that's the true scientific notation now this is just changing
6375
13:48:47,919 --> 13:48:55,680
not actually writing code this is determine the value by just by
6376
13:48:55,680 --> 13:49:03,120
just to see so you know as we count so how many decimal place how
6377
13:49:03,120 --> 13:49:11,360
five six seven eight nine ten eleven because it has to be down to
6378
13:49:11,360 --> 13:49:19,760
one is 1.56 that's where the decimal would go and a2 would be 11
6379
13:49:19,760 --> 13:49:33,520
out a that that is a1 times 10 to a2 so then we'll do this for
6380
13:49:33,519 --> 13:49:44,559
so the decimal point would be there so then it's yeah so then we
6381
13:49:44,559 --> 13:49:59,279
five six seven eight nine ten so it would be 4.13 and we have to
6382
13:49:59,279 --> 13:50:08,159
so it'd be to the negative 10 and so then that would print b is
6383
13:50:09,519 --> 13:50:16,319
there we go and we run it there we go now
6384
13:50:16,319 --> 13:50:32,400
now this one works displays nicely this one how we want to display
6385
13:50:32,400 --> 13:50:37,760
automatically and this is fine you know you go on the next step
6386
13:50:37,760 --> 13:50:49,360
this one a positive 11th power fine it didn't see a reason to
6387
13:50:49,360 --> 13:50:58,959
the python notation 4.13 e negative 10 so and this is not the same
6388
13:50:58,959 --> 13:51:07,360
so times 10 to the negative 10 so there we go in this you know
6389
13:51:07,360 --> 13:51:14,800
watching this it's you know illustrating like why there's some of
6390
13:51:14,800 --> 13:51:22,960
so we can use these logs for scientific notation because if i want
6391
13:51:22,959 --> 13:51:34,879
this to scientific notation in an easy way so what do i do so i
6392
13:51:34,879 --> 13:51:43,119
together the things we did in the last two exercises so for a i'm
6393
13:51:44,639 --> 13:51:55,599
of the log of a base 10 there we go and now i'm going to round it
6394
13:51:55,599 --> 13:52:11,040
so it was a i called it x1 for exponent one and so if i have this
6395
13:52:15,760 --> 13:52:25,200
and it rounds it to two decimal places so if that's the if that's
6396
13:52:25,199 --> 13:52:32,719
multiply this times 10 to the negative x1 and it's going to print
6397
13:52:34,800 --> 13:52:40,400
i'll just show you the code and then we'll run it and you'll see
6398
13:52:40,400 --> 13:52:48,160
what i want x2 and i want to show you that this actually works for
6399
13:52:56,319 --> 13:53:10,080
so if we have so but this one i want this for b so take the log of
6400
13:53:10,080 --> 13:53:20,000
and if i have this then i'm going to round that so i'm going to
6401
13:53:26,080 --> 13:53:28,000
again referencing b this time
6402
13:53:33,279 --> 13:53:43,599
to there we go so it's what exponent got me there but then when i
6403
13:53:45,279 --> 13:53:50,879
then that will divide it out that's why it's that that's why it
6404
13:53:50,879 --> 13:53:59,599
because i want to divide it out to get that early number there all
6405
13:53:59,599 --> 13:54:10,479
and this just took those so you see we get a is 2.34 times 10 to
6406
13:54:12,000 --> 13:54:17,120
and b is 1.23 times 10 to the 13th
6407
13:54:21,360 --> 13:54:27,040
so pretty cool how you could just take this and whether i wanted
6408
13:54:27,040 --> 13:54:32,720
a decimal so a negative exponent or a huge number with the
6409
13:54:33,360 --> 13:54:42,639
this this works take the log base 10 and the floor of that and
6410
13:54:42,639 --> 13:54:52,159
that's how we get n1 you know then we're then multiplying it by
6411
13:54:52,160 --> 13:54:58,320
and we can display so this way now you have it you can have a code
6412
13:54:58,319 --> 13:55:02,000
to scientific notation pretty cool
6413
13:55:05,199 --> 13:55:13,680
and that's what we get into step 19 there we go now this one very
6414
13:55:13,680 --> 13:55:20,879
before and we're just added one more thing of entering a number to
6415
13:55:20,879 --> 13:55:31,919
notation so see this is where you can make it as your calculator
6416
13:55:31,919 --> 13:55:51,119
this and it works either way i'll copy this code that we had from
6417
13:55:51,120 --> 13:55:53,840
i don't need the number ones because i'm only doing one thing
6418
13:55:53,839 --> 13:56:05,039
right and in that case if we want to print you see i even left
6419
13:56:09,120 --> 13:56:16,240
so we can reuse this and this is the key with copying and reusing
6420
13:56:16,239 --> 13:56:20,559
be aware to notice these little things if you just copy and paste
6421
13:56:20,559 --> 13:56:26,959
there there might be a little subtle things that don't line up you
6422
13:56:26,959 --> 13:56:32,720
good you have to understand the code well enough to know these
6423
13:56:32,720 --> 13:56:42,160
oh okay i needed to delete the ones here all around and you know
6424
13:56:42,160 --> 13:56:50,560
copy paste with the follow-up editing now that works and see what
6425
13:56:51,680 --> 13:56:57,680
standalone uh you know input you didn't have to like define the
6426
13:56:58,879 --> 13:57:07,839
and there you go enter in whatever number all right so one two
6427
13:57:07,839 --> 13:57:14,559
three there we go there we go
6428
13:57:25,519 --> 13:57:38,639
two three i got to one point two three ah look at this it see as i
6429
13:57:38,639 --> 13:57:46,319
i didn't delete the one there and that variable was still in in
6430
13:57:46,319 --> 13:57:56,800
so it gave me this you know exponent that i was not expecting one
6431
13:58:04,319 --> 13:58:10,559
all right pretty good so anything that you have now now we have
6432
13:58:10,559 --> 13:58:16,479
and then later on what we're going to do is and then maybe i'll
6433
13:58:16,480 --> 13:58:27,040
put all of this code within one function and so then now you can
6434
13:58:27,040 --> 13:58:33,680
convert to scientific notation and all this code is within that
6435
13:58:33,680 --> 13:58:43,760
then that function we can use wherever all right so let's go on to
6436
13:58:43,760 --> 13:58:52,959
graphing exponents and logarithms so just connecting with the math
6437
13:58:54,559 --> 13:59:00,399
putting the adjective first natural log if i was just writing it
6438
13:59:00,400 --> 13:59:09,680
and that would be base e and so comparing y equals e to the x and
6439
13:59:10,160 --> 13:59:17,200
those two are the inverse functions and mirrored over the line y
6440
13:59:17,199 --> 13:59:24,399
we'll see these and then we'll see the line y equals x so we were
6441
13:59:24,400 --> 13:59:34,480
library if i just want to calculate a logarithm i'll use math.log
6442
13:59:34,480 --> 13:59:41,120
using numpy and we're using the linspace function to create an
6443
13:59:41,120 --> 13:59:53,680
graph so i have to keep with numpy which i usually import as np so
6444
13:59:53,680 --> 13:59:58,639
you see if i want to do one thing yeah that works if i'm using the
6445
13:59:58,639 --> 14:00:14,080
i'm using np.log and np has it slightly different np has np.log 10
6446
14:00:14,080 --> 14:00:24,319
base 2 and if i just do np.log it's going to be base e
6447
14:00:24,319 --> 14:00:32,319
other base because we have the change of base formula which i'll
6448
14:00:32,319 --> 14:00:42,239
we go so we have the positive x values now e to the if i was
6449
14:00:42,239 --> 14:00:49,759
all my x values whatever i want but when i do natural log then the
6450
14:00:49,760 --> 14:00:55,440
because remember they're inverses so in this case e to whatever
6451
14:00:55,440 --> 14:01:04,480
zero as the inverse here the x value will never be zero so when i
6452
14:01:04,480 --> 14:01:13,280
familiar from other graphing we might have done i'm going to
6453
14:01:13,279 --> 14:01:24,159
minimum maximum you know based on here what i did here that's fine
6454
14:01:26,080 --> 14:01:31,440
log i need i'm going to use a different linspace i won't do zero
6455
14:01:31,440 --> 14:01:41,440
tiny number 0.001 and that should be enough to illustrate this
6456
14:01:41,440 --> 14:01:50,000
so i'm graphing these i'll use x1 is my array of x values and
6457
14:01:50,800 --> 14:01:57,680
and then within that range i want a thousand points i mean you'll
6458
14:01:57,680 --> 14:02:03,840
smooth graph even if you don't have a thousand points all right
6459
14:02:04,639 --> 14:02:11,599
and i'll just write the y value here instead of separating it out
6460
14:02:12,080 --> 14:02:20,720
and then that to the to that exponent there we go and i'll make
6461
14:02:20,720 --> 14:02:33,279
the red line for y equals x then x1 and we see if i have this x1 i
6462
14:02:33,279 --> 14:02:38,319
it's y equals x so i don't need to define a new y value which i
6463
14:02:38,319 --> 14:02:52,559
and here now for my log y equals log of x i'll do this linspace
6464
14:02:54,160 --> 14:03:00,960
all right so we're just going to run this and then change it so we
6465
14:03:00,959 --> 14:03:10,159
and there we go so we have the blue line e to the x exponential
6466
14:03:10,160 --> 14:03:18,880
y equals x or y equals the log of x and there we go and this works
6467
14:03:18,879 --> 14:03:23,519
there are mirror images across the line y equals x but this there
6468
14:03:23,519 --> 14:03:30,239
it illustrates it nicely all right now change the blue line and
6469
14:03:30,239 --> 14:03:42,799
make these log base two so here instead of math dot e i'm going to
6470
14:03:42,800 --> 14:03:54,160
you know that's fine and this one instead of np dot log i'll do np
6471
14:03:57,040 --> 14:04:00,400
now we're not going to notice that much of a difference here
6472
14:04:01,279 --> 14:04:09,919
i went from a base of 2.7 to a base of 2 but there we go that's
6473
14:04:09,919 --> 14:04:17,599
one i don't want to include some applications here if you have the
6474
14:04:18,480 --> 14:04:26,080
as a decimal number that's really where the ph comes in so
6475
14:04:27,680 --> 14:04:33,040
so the way this this works it's the negative log of the hydrogen
6476
14:04:33,040 --> 14:04:40,800
so if we have 0.007 as scientific notation that would be seven
6477
14:04:41,360 --> 14:04:49,040
which would be a ph of three and then we see that as we got more
6478
14:04:49,599 --> 14:04:58,400
you know a really tiny decimal number then that would be ten to
6479
14:04:58,400 --> 14:05:05,840
know ten to the negative ten you know really tiny number and that
6480
14:05:07,279 --> 14:05:14,479
ten to the negative ten would be a ph of ten you know we get the
6481
14:05:14,480 --> 14:05:20,720
just taking this and if you knew the hydrogen concentration i was
6482
14:05:20,720 --> 14:05:28,319
in as like going into the chemistry and finding hydrogen
6483
14:05:28,319 --> 14:05:35,120
the those of you that want to uh you know pursue the chemistry
6484
14:05:35,120 --> 14:05:42,400
actually get you know various uh hydrogen concentrations of
6485
14:05:43,360 --> 14:05:49,520
work it out from there okay but nonetheless so what we want to do
6486
14:05:49,519 --> 14:06:00,799
concentration so it's the negative log and for this one i will use
6487
14:06:00,800 --> 14:06:14,319
going to make this negative math dot uh log and i'm going to log
6488
14:06:14,319 --> 14:06:24,159
ten there we go so that's that's really it and now that log i get
6489
14:06:25,519 --> 14:06:30,159
and what do i want to do i want the ceiling so i'll do math dot
6490
14:06:37,440 --> 14:06:47,120
perfect all right so there we go when we run this end of the
6491
14:06:47,919 --> 14:06:57,680
and what if i put your point two three four and there you go and
6492
14:07:11,279 --> 14:07:19,440
i would take this as we we look at this and yeah this is the
6493
14:07:19,440 --> 14:07:24,720
is and then do the math dot ceiling so that's what we'll do we'll
6494
14:07:24,720 --> 14:07:32,559
and these are the things that i wanted to put in here as you know
6495
14:07:33,199 --> 14:07:36,639
we see why this this ended up being wrong because then it gave a
6496
14:07:36,639 --> 14:07:39,199
putting the math dot ceiling in the wrong spot
6497
14:07:41,519 --> 14:07:44,239
all right so i'll do the same same one here point
6498
14:07:46,639 --> 14:07:51,120
i'll put a one that's okay there we go now that gives it a ph of
6499
14:07:51,120 --> 14:07:58,080
there we go now that gives it a ph of five you see how that makes
6500
14:07:58,080 --> 14:08:05,840
first with the negative log then doing the math dot ceiling there
6501
14:08:09,440 --> 14:08:13,120
there we go all right so now with functions here
6502
14:08:13,120 --> 14:08:20,959
calc these are some of the things how could we write a function
6503
14:08:21,760 --> 14:08:30,720
you're going to define the function and calculating mortgage
6504
14:08:30,720 --> 14:08:44,400
i'll call it mort pay and now notice you would think that it when
6505
14:08:44,400 --> 14:08:51,520
indent automatically but for other things that i do or i might use
6506
14:08:51,519 --> 14:09:00,639
four spaces so i backspace i delete that and then i want to make
6507
14:09:00,639 --> 14:09:08,000
can i do i can define this function here so and and this is i'll
6508
14:09:08,000 --> 14:09:15,440
you can do more here so if i have the mortgage payment now we also
6509
14:09:15,440 --> 14:09:23,040
um table of contents i can jump right to mortgage payments so
6510
14:09:30,080 --> 14:09:36,080
and then i will define these in here
6511
14:09:38,260 --> 14:09:48,099
here so i'm going to just copy this and actually um
6512
14:09:53,860 --> 14:09:58,419
there we go so i'm going to show you one way to do this and then
6513
14:09:58,419 --> 14:10:07,059
okay there we go and more functions here so one of the things that
6514
14:10:10,900 --> 14:10:13,220
is just put everything in here
6515
14:10:32,099 --> 14:10:41,220
you probably don't need that extra line and same here so this
6516
14:10:43,139 --> 14:10:49,459
the payment maybe that's all you need you want to be able to then
6517
14:10:49,459 --> 14:10:59,459
print out the answer so that works another way is
6518
14:11:02,419 --> 14:11:09,619
what i'm going to do i'm going to copy this and i'm going to show
6519
14:11:25,300 --> 14:11:34,500
p r t and for this one i'm going to require input input p r t
6520
14:11:55,540 --> 14:12:02,660
and i'm going to return payment
6521
14:12:08,660 --> 14:12:17,860
so this one's nice if that's the if and you know there we go so
6522
14:12:17,860 --> 14:12:25,940
prompt you know this could this could go a lot of different places
6523
14:12:27,940 --> 14:12:35,459
maybe then just put this function in and return the payment like
6524
14:12:35,459 --> 14:12:43,059
it's going to go so two different situations and that's why you
6525
14:12:43,059 --> 14:12:48,500
that's why you know i'll make it you know p r t so we know what
6526
14:12:49,300 --> 14:12:52,100
is different so there we go so that's that's one one way
6527
14:12:53,779 --> 14:13:00,819
and i have here more functions now the interactive polynomial
6528
14:13:00,819 --> 14:13:13,620
with that too i'm going to do one more up here because i wanted to
6529
14:13:15,459 --> 14:13:30,659
enter a number to convert to scientific notation so if we have
6530
14:13:30,660 --> 14:13:45,620
convert so if i have a as my variable so there's my scientific
6531
14:13:45,620 --> 14:14:04,180
and if i take that and convert this i could create a function to
6532
14:14:04,180 --> 14:14:17,540
a there we go and maybe it just takes that input of a
6533
14:14:47,940 --> 14:14:54,740
there we go so we take this and move around um
6534
14:14:54,739 --> 14:15:06,419
um oh but i would probably have it as a string here so i could go
6535
14:15:15,059 --> 14:15:18,500
uh i could instead of printing it
6536
14:15:46,980 --> 14:15:52,900
and so we may you know i could just make that a string and then
6537
14:15:58,580 --> 14:16:03,540
so i probably don't need this a equals
6538
14:16:11,379 --> 14:16:25,059
and it should give you n times 10 to the x so just to give you
6539
14:16:25,940 --> 14:16:31,540
i want you to be able to you create the functions and then the
6540
14:16:31,540 --> 14:16:38,580
graph with sliders we we have that so turn that into a new turn
6541
14:16:39,860 --> 14:16:45,940
but here's the examples how you can just take and and that's the
6542
14:16:45,940 --> 14:16:52,020
to you know through this course you learn and you're practicing
6543
14:16:52,019 --> 14:16:59,939
parts that now you know and you can turn just the important parts
6544
14:16:59,940 --> 14:17:06,660
into their own functions and you can you know give them other
6545
14:17:07,379 --> 14:17:14,739
and there you go uh create a function for you know how long it
6546
14:17:16,019 --> 14:17:20,339
go back to that other one again turn that into a function and all
6547
14:17:20,339 --> 14:17:31,059
is going to be in a financial app that you'll make so what you can
6548
14:17:33,459 --> 14:17:43,779
all of these and you could have this work out that it's within all
6549
14:17:43,779 --> 14:17:51,779
have it within uh within google co-lab where you have text that
6550
14:17:51,779 --> 14:17:58,419
calculate mortgage payment number two retirement account balance
6551
14:17:58,739 --> 14:18:09,139
the text there and then require input which option do you want and
6552
14:18:09,139 --> 14:18:15,300
that's that's one way to do it defining all the functions having
6553
14:18:15,300 --> 14:18:21,780
the menu and then when you pick your option then it runs that
6554
14:18:22,339 --> 14:18:29,619
want to get to is that you're putting all this together and it
6555
14:18:29,620 --> 14:18:38,180
you can use this for other things you know calculating your own
6556
14:18:38,180 --> 14:18:46,260
with what you're doing certifications one and two see now where
6557
14:18:46,260 --> 14:18:53,540
the end of this and you have understand the math and you have all
6558
14:18:53,540 --> 14:18:59,700
you know calculate things graph things solve problems and then you
6559
14:19:01,459 --> 14:19:09,779
the next unit which i call it week 15 is going to be the wrapping
6560
14:19:14,180 --> 14:19:19,459
so we reached the home stretch in our algebra journey here and now
6561
14:19:19,459 --> 14:19:24,979
all the different things we've been doing with math we've been
6562
14:19:25,620 --> 14:19:34,980
taking things that turn into x lists of x y values that we can
6563
14:19:34,980 --> 14:19:42,900
at how we can get the get that data from the web from the cloud
6564
14:19:42,900 --> 14:19:51,139
and bring that data in whether it be columns in a table or all
6565
14:19:51,139 --> 14:19:57,300
in those x y coordinates and then we can do math to it so really
6566
14:19:57,300 --> 14:20:01,700
been working with all the math content and now pretty much
6567
14:20:01,699 --> 14:20:08,819
beyond this we're going to bring that math content and into the
6568
14:20:08,819 --> 14:20:15,699
into the code and do a lot more code how can i get this data turn
6569
14:20:16,339 --> 14:20:24,339
then do whatever graph i can do and you know analyze the data so
6570
14:20:24,339 --> 14:20:33,379
get to the code so now this is some ways you can bring in data
6571
14:20:33,379 --> 14:20:41,619
do other things so let's talk about the other sources pandas is
6572
14:20:41,620 --> 14:20:50,580
with data frames tables columns rows everything like that so we're
6573
14:20:50,580 --> 14:20:56,580
the matplot library we've done that before and we're also going to
6574
14:20:56,580 --> 14:21:04,819
going to import files and that's also going to give our file
6575
14:21:04,819 --> 14:21:12,500
io input output there we go i separate these out because you can
6576
14:21:12,500 --> 14:21:19,540
takes a few seconds i already did it so run it once and that saves
6577
14:21:19,540 --> 14:21:26,099
because we want to go through you'll see test some things now we
6578
14:21:26,099 --> 14:21:31,779
ways that we can get the files all right here's one option if you
6579
14:21:32,500 --> 14:21:41,779
you can upload it and because we imported that google dialogue or
6580
14:21:42,500 --> 14:21:50,260
this is all we need files dot upload and we're going to upload
6581
14:21:50,260 --> 14:21:57,060
file dialogue you can search for on your computer and that's what
6582
14:21:57,059 --> 14:22:05,299
that as that variable uploaded and then so i have my file name
6583
14:22:05,300 --> 14:22:13,540
take that uploaded file and iteration so iter and the argument is
6584
14:22:13,540 --> 14:22:20,580
the next one and what that is going to do is just one time you
6585
14:22:20,580 --> 14:22:29,700
going to select that and store it as file name and here that file
6586
14:22:29,699 --> 14:22:38,500
know that it's a csv so pandas has this nice building pd dot read
6587
14:22:38,500 --> 14:22:45,459
get to and don't worry about this it's because i already stored
6588
14:22:45,459 --> 14:22:55,299
for you know whatever file you upload so uploaded file name and it
6589
14:22:55,300 --> 14:23:03,380
it will store it as this table so there we go these three lines
6590
14:23:03,379 --> 14:23:12,419
you know give you the file dialogue upload it from your computer
6591
14:23:12,419 --> 14:23:24,180
when you select that file it's stored as table one awesome so
6592
14:23:24,180 --> 14:23:32,500
in in a minute here another way is you can get a csv from a url so
6593
14:23:32,500 --> 14:23:41,300
looking at different websites and you found you know this uh url
6594
14:23:42,900 --> 14:23:52,180
uh yeah this this guy uh seems to put put out a few good examples
6595
14:23:52,180 --> 14:24:02,500
dot csv old faithful geyser you know it rups for a little you know
6596
14:24:02,500 --> 14:24:07,779
regular basis that's why it's called old faithful and that just
6597
14:24:07,779 --> 14:24:13,860
can look at so i'll just store it as this variable url which is
6598
14:24:13,860 --> 14:24:20,099
the csv there you go plenty you could also and i didn't include
6599
14:24:20,099 --> 14:24:26,739
you wanted to you know make your own like you know input statement
6600
14:24:26,739 --> 14:24:31,540
somebody else using you know you made this program for somebody
6601
14:24:31,540 --> 14:24:38,419
to just copy and paste the url and store it you know that works
6602
14:24:38,419 --> 14:24:47,860
so you just put the url here store it as variable url now same
6603
14:24:47,860 --> 14:24:55,139
dot uh because we imported pan does it as pd pd dot read csv and i
6604
14:24:55,139 --> 14:24:57,779
and that's enough and i'll store it as table one
6605
14:25:01,059 --> 14:25:08,899
okay and yes those imports and everything that you run i just even
6606
14:25:08,900 --> 14:25:16,099
you so that's good for maybe 20 minutes google colab will uh have
6607
14:25:16,099 --> 14:25:26,580
on their server and you know colab has a runtime once we started
6608
14:25:26,580 --> 14:25:35,060
30 minutes of inactivity or even if you're active like you know
6609
14:25:35,059 --> 14:25:42,819
busy day i think it's like about 12 hours of running it'll time
6610
14:25:42,819 --> 14:25:47,139
well wait i haven't been inactive but there's still an absolute
6611
14:25:47,139 --> 14:25:53,220
start it again so that gives that gives you time you can import
6612
14:25:53,220 --> 14:26:00,580
to go through and then run a few of these and tinker with it okay
6613
14:26:00,580 --> 14:26:07,459
to repeat those steps and again you know importing you know
6614
14:26:07,459 --> 14:26:13,779
few seconds to run it and then prompting you know if we want to do
6615
14:26:13,779 --> 14:26:18,419
test some things you don't have to upload it every time that saves
6616
14:26:20,500 --> 14:26:27,779
so there we go now we have this what do we want to do with it you
6617
14:26:27,779 --> 14:26:33,139
we're going to eventually determine what columns we want and
6618
14:26:33,139 --> 14:26:40,180
remember numpy arrays that's what we're that's what we end up
6619
14:26:40,180 --> 14:26:48,019
i even still commented this out but you could display the whole
6620
14:26:49,379 --> 14:26:54,500
especially the the more you get into big data you know that's
6621
14:26:54,500 --> 14:27:01,139
resource consuming and so i i include that in there you know just
6622
14:27:01,139 --> 14:27:07,459
but what else might we want to do i might just want to print out
6623
14:27:07,459 --> 14:27:14,739
as table one for this example so i might just want to print out
6624
14:27:14,739 --> 14:27:23,860
one dot head and if i don't put a number in parentheses it will
6625
14:27:23,860 --> 14:27:29,860
put a number in there and it's going to give me the headings and i
6626
14:27:29,860 --> 14:27:36,180
that give me the headings in two rows that might be enough you
6627
14:27:36,180 --> 14:27:41,139
you've seen the column you might want to see the see it here or
6628
14:27:41,139 --> 14:27:47,379
to take a look at it i want to see the heading i want to see the
6629
14:27:47,379 --> 14:27:54,180
two rows give me an idea of what kind of data because if i start
6630
14:27:54,180 --> 14:28:00,580
know that i'm not going to be able to convert that to a numpy
6631
14:28:01,139 --> 14:28:10,099
store column names as a variable because if i have table one in
6632
14:28:10,099 --> 14:28:18,260
one dot columns there you go so now this column names is a list of
6633
14:28:18,260 --> 14:28:24,020
um and again i can i only need to do this once and now that i have
6634
14:28:24,019 --> 14:28:32,180
them all right instead of printing out the heading i could and i
6635
14:28:32,180 --> 14:28:42,419
new line column names and then i could loop through them so i'll
6636
14:28:42,419 --> 14:28:50,739
range length column names so column names i'm going to get the
6637
14:28:50,739 --> 14:28:59,139
then each time i'll print that number the space and then that
6638
14:28:59,139 --> 14:29:06,739
way to do it or another way i could actually just loop through
6639
14:29:06,739 --> 14:29:16,500
and just print that each time so let's see what that looks like
6640
14:29:16,500 --> 14:29:29,220
benefits here so notice this is the first one we did uh there you
6641
14:29:29,220 --> 14:29:34,739
print statement that head statement gave me these but this table
6642
14:29:34,739 --> 14:29:41,699
and notice their index starts at one so that's just something to
6643
14:29:42,660 --> 14:29:52,740
and eruption wait time so there we go and notice these quotes are
6644
14:29:53,779 --> 14:30:00,019
with within the name of the call you know that's something the
6645
14:30:00,019 --> 14:30:06,659
more you get into uh working with data and maybe other people you
6646
14:30:06,660 --> 14:30:12,020
everything i'll tell you this you really want column names without
6647
14:30:12,019 --> 14:30:17,619
without spaces but you know there's ways to deal with that we can
6648
14:30:17,620 --> 14:30:23,940
usually makes it easier for this stuff and for like some of the
6649
14:30:23,940 --> 14:30:31,620
an idea of what i have and here again you see the column names you
6650
14:30:33,379 --> 14:30:40,099
and the the other way we did it index eruption length eruption
6651
14:30:40,099 --> 14:30:51,939
these exact column names so you know i could now this is how i did
6652
14:30:51,940 --> 14:30:59,220
here and i can see them so table one and then in those square
6653
14:30:59,220 --> 14:31:08,660
of that column i want and then also that name in single quotes to
6654
14:31:08,660 --> 14:31:16,740
that to a numpy array and then eruption length in minutes so again
6655
14:31:16,739 --> 14:31:23,699
square brackets and remember that extra space and those quotes
6656
14:31:23,699 --> 14:31:30,500
i include them and convert that to a numpy array so now i have my
6657
14:31:30,500 --> 14:31:38,180
can plot there you know going through each of them you know it's
6658
14:31:38,180 --> 14:31:53,860
x is 3.6 y is 779 x is 1.8 y is 54 oh no actually i had it as
6659
14:31:53,860 --> 14:32:02,340
1.8 i can graph the eruption length or i can do it for eruption
6660
14:32:02,339 --> 14:32:13,939
to the index again x is 1 y is 79 x is 2 y is 54 so i just graphed
6661
14:32:13,940 --> 14:32:21,139
can go back and do that for the second one also if you wanted to
6662
14:32:21,139 --> 14:32:30,099
numpy arrays i can call that function x.min and this you know if
6663
14:32:30,099 --> 14:32:36,099
like the entire table this just might be a good way i'll just take
6664
14:32:36,099 --> 14:32:42,659
because it's just a little bit of a buffer on the edge and store
6665
14:32:42,660 --> 14:32:51,620
five a little bit of a buffer y min y max so this goes back to
6666
14:32:51,620 --> 14:33:05,380
with graphing set my x min x max and each of these now notice i
6667
14:33:05,379 --> 14:33:11,779
doing in other other units we were defining the points here but i
6668
14:33:11,779 --> 14:33:22,500
defined as num numpy arrays so when i graph i can plot i can plot
6669
14:33:22,500 --> 14:33:39,779
you know the x refers to that array y refers to that array and i
6670
14:33:39,779 --> 14:33:50,099
so i have these here as numpy arrays and i can do them as a
6671
14:33:52,900 --> 14:33:54,980
all right let's see what this looks like
6672
14:33:58,180 --> 14:34:04,819
now i had it as both and it looks like a huge mess but one of the
6673
14:34:04,819 --> 14:34:14,180
i don't want the line graph is probably not useful so i'll just go
6674
14:34:14,180 --> 14:34:24,819
out right now and run it again and we see it seems to cluster it's
6675
14:34:24,819 --> 14:34:34,739
that's kind of interesting what if i change my x my y value maybe
6676
14:34:34,739 --> 14:34:42,259
what if i change this so what i can do is my y minimum and these
6677
14:34:42,260 --> 14:34:51,220
want to do now we know how to use your math graphing skills to
6678
14:34:51,220 --> 14:34:59,540
to get all this data into this graph and this is now where we get
6679
14:34:59,540 --> 14:35:06,500
do i can look at this and say all right you know they're all less
6680
14:35:06,500 --> 14:35:14,019
well actually they're all greater than zero so i can just make my
6681
14:35:14,019 --> 14:35:21,219
going to comment out the rest of this and i can make my y maximum
6682
14:35:21,220 --> 14:35:34,739
the rest of that and when we see that we might see it seems like
6683
14:35:34,739 --> 14:35:41,299
reason it's really rare for it to be around three and remember
6684
14:35:41,300 --> 14:35:50,420
here we are graphing the eruption length time so it really seems
6685
14:35:50,419 --> 14:36:02,739
minutes or about four minutes yeah interesting so we can look at
6686
14:36:02,739 --> 14:36:11,619
things that we can do now let's look at another twist on this you
6687
14:36:11,620 --> 14:36:20,900
names so remember earlier we made column names this array so i can
6688
14:36:20,900 --> 14:36:29,380
names one and that's my x name and my y name i'll make these
6689
14:36:29,379 --> 14:36:33,860
the actual names of your columns doing that once might save you
6690
14:36:34,500 --> 14:36:43,540
then you can reuse that variable here just yeah i don't have to
6691
14:36:43,540 --> 14:36:53,860
time now i have my x variable is that column to numpy my y
6692
14:36:53,860 --> 14:37:02,340
doing before but again reusing that variable save you some typing
6693
14:37:02,339 --> 14:37:10,419
why in a minute and i just want to show you that that same scatter
6694
14:37:10,419 --> 14:37:19,299
dimensions are there but you see using that as the column name i
6695
14:37:19,300 --> 14:37:28,260
and again without having to rewrite so now we have index and
6696
14:37:30,019 --> 14:37:41,699
there we go then if i wanted to talk about the eruption time or
6697
14:37:41,699 --> 14:37:48,579
the things that we were doing i can just change this i still want
6698
14:37:48,580 --> 14:37:58,260
uh columns one was the eruption length i'll change that to that
6699
14:37:58,260 --> 14:38:04,900
names everything else stays the same and again going to different
6700
14:38:05,699 --> 14:38:14,099
giving the dimensions of the graph based on that because these
6701
14:38:14,099 --> 14:38:20,739
i'll still have the same index because they did match but instead
6702
14:38:20,739 --> 14:38:30,180
and five i will have you know wait wait time in minutes you know
6703
14:38:30,180 --> 14:38:40,500
almost 100 minutes so we see that now again let's get to some
6704
14:38:40,500 --> 14:38:48,500
it looks like maybe i have this range of 40 minutes to you know
6705
14:38:48,500 --> 14:38:53,940
like let's say this is in yellowstone let's say you go to visit
6706
14:38:53,940 --> 14:38:59,220
i have to wait it just erupted i want to go do other things when
6707
14:38:59,220 --> 14:39:05,779
i come back in 40 minutes should i come back in 90 minutes you
6708
14:39:05,779 --> 14:39:11,860
could keep you you know waiting there almost an hour but let's
6709
14:39:11,860 --> 14:39:17,300
patterns here again the default i keep this index i want to zoom
6710
14:39:18,260 --> 14:39:25,459
so i'll go to that index that x value i'll keep the same minimum
6711
14:39:25,459 --> 14:39:37,059
value instead of that plus five maybe i'll make it like 50 and
6712
14:39:38,739 --> 14:39:46,019
that's interesting i'm just going to run this again doesn't help
6713
14:39:46,019 --> 14:39:56,579
see now instead of a scatter plot actually i'll keep the scatter
6714
14:39:57,220 --> 14:40:03,300
but i'll also make it a line graph and i'll make the dots red and
6715
14:40:07,940 --> 14:40:17,700
and you see that just looks nice and if i don't you know there's
6716
14:40:17,699 --> 14:40:27,779
want that then i can just make my x x minimum you know one that
6717
14:40:27,779 --> 14:40:38,339
comment that that way i don't even get distracted by that there we
6718
14:40:39,220 --> 14:40:46,500
now besides seeing the scatter pot that was a mess the line graph
6719
14:40:46,500 --> 14:40:52,739
interesting things with very few exceptions if it was a shorter
6720
14:40:52,739 --> 14:40:58,659
the next one's a longer weight closer to 90 and then the next
6721
14:40:58,660 --> 14:41:04,420
weight longer weight you see every so often you get one that it
6722
14:41:05,699 --> 14:41:12,019
but we get a shorter weight a longer weight a shorter weight you
6723
14:41:12,019 --> 14:41:21,779
that happens most of the time so what we can do is we could look
6724
14:41:21,779 --> 14:41:30,180
oh well how long was it last time and then therefore i can use
6725
14:41:30,180 --> 14:41:36,419
that from you know we get that from looking at the graph here so
6726
14:41:36,980 --> 14:41:42,980
you could probably then now connecting this to you know real-time
6727
14:41:42,980 --> 14:41:53,860
doing this then we could graph you know a certain amount of this
6728
14:41:53,860 --> 14:42:01,300
table that always just updates you know when it erupted and how
6729
14:42:01,300 --> 14:42:06,900
each time you know just you know maybe even we could get this to
6730
14:42:06,900 --> 14:42:11,779
erupted it stopped erupting and then do the calculations what was
6731
14:42:11,779 --> 14:42:20,900
eruption time add that new data and we could be looking at this
6732
14:42:20,900 --> 14:42:28,660
to give people you know real-time estimates of it just erupted
6733
14:42:28,660 --> 14:42:36,420
eruption and get it down even probably to some like you know uh
6734
14:42:36,419 --> 14:42:42,339
that you know the point is that you would want to be able to say
6735
14:42:42,339 --> 14:42:47,539
minutes later or 90 minutes later i want to be able to have i
6736
14:42:48,500 --> 14:42:55,220
you know if it just erupted and it was an 80 minute wait then you
6737
14:42:56,260 --> 14:43:03,220
you know 50 minutes so you get some range that you know when to
6738
14:43:03,220 --> 14:43:07,139
don't have to wait too long and that's really what we want to get
6739
14:43:07,139 --> 14:43:17,220
these patterns and be able to then predict the next one you know
6740
14:43:17,220 --> 14:43:23,860
if i go to here and i want to be able to predict and say oh all
6741
14:43:23,860 --> 14:43:31,059
of 60 minutes so i'm going to just predict that the next wait time
6742
14:43:31,059 --> 14:43:35,059
and if we really want we can just change this to like 55
6743
14:43:38,660 --> 14:43:48,180
so with the wait time of 50 minutes then the next one wasn't quite
6744
14:43:48,180 --> 14:43:53,300
of well i wouldn't go i wouldn't wait more than 80 minutes i might
6745
14:43:53,300 --> 14:44:02,740
up so there we go because remember the other graph the eruption
6746
14:44:02,739 --> 14:44:08,579
minutes you are two you know two minutes and it could be two
6747
14:44:08,580 --> 14:44:14,740
five minutes that's not even that long so you don't want to be you
6748
14:44:14,739 --> 14:44:21,619
going to miss it all so yeah just interesting we can use this to
6749
14:44:21,620 --> 14:44:27,620
math of it we have we you know once you have those column names
6750
14:44:31,620 --> 14:44:41,620
so once we have we get that table what once you have that table
6751
14:44:41,620 --> 14:44:46,180
we have those column names and then we can do other things with
6752
14:44:46,180 --> 14:44:53,940
whatever we want you know number them you know just loop through
6753
14:44:55,940 --> 14:45:03,459
pick certain ones and i'll use that as my x and y so that's the
6754
14:45:03,459 --> 14:45:10,580
minimum maximum we can try this because we want to make this
6755
14:45:10,580 --> 14:45:15,779
and maybe certain things you can comment out and certain things
6756
14:45:15,779 --> 14:45:24,819
modify just a little bit that what you can use the same code for
6757
14:45:24,819 --> 14:45:31,139
whatever table you have this is a good start you start getting
6758
14:45:31,139 --> 14:45:38,180
to compare what am i trying to graph and then as you get into it
6759
14:45:38,180 --> 14:45:46,019
you can always then copy all this and then you know do in here
6760
14:45:46,019 --> 14:45:52,579
some text to give you know yourself or whoever read this some some
6761
14:45:52,580 --> 14:45:58,819
this code cell and you know that that's the beauty of the colab
6762
14:45:58,819 --> 14:46:06,739
like you can delete things and retry things or you can keep that
6763
14:46:06,739 --> 14:46:12,900
this is interesting information keep that and then just do a new
6764
14:46:13,779 --> 14:46:21,779
you know let's do the next next analysis so here's another way to
6765
14:46:22,500 --> 14:46:30,980
then graph it this particular library so not a csv but the full
6766
14:46:30,980 --> 14:46:37,700
of weather data so yes may install need to only install once right
6767
14:46:38,739 --> 14:46:44,739
i just have this as its own cell there you go pip install medial
6768
14:46:46,099 --> 14:46:49,779
doing that i mean this actually might take almost 30 seconds
6769
14:46:49,779 --> 14:46:54,339
so sometimes that seems like forever so i already did that and
6770
14:46:54,339 --> 14:47:03,459
um successfully installed and then we go on to the next one and
6771
14:47:03,459 --> 14:47:11,540
else working with this you put put in some text areas here so now
6772
14:47:11,540 --> 14:47:20,580
columns i have in this library so time uh and all the other these
6773
14:47:20,580 --> 14:47:26,020
average temperature minimum temp maximum temperature the amount of
6774
14:47:26,019 --> 14:47:34,739
amount of snow wind direction wind speed the pressure so average
6775
14:47:34,739 --> 14:47:45,939
uh air pressure uh the wind gusts so uh after wind speed we have
6776
14:47:45,940 --> 14:47:52,580
and the last one is uh time in the sun so you know how many
6777
14:47:53,540 --> 14:47:58,500
would you get and these are really good i picked these because it
6778
14:47:59,459 --> 14:48:06,019
you know you can things like wind speed you know plan your uh wind
6779
14:48:06,900 --> 14:48:10,900
time in the sun plan for your solar panels and where to put them
6780
14:48:10,900 --> 14:48:18,900
um so i have these to remind me and then the reminder change start
6781
14:48:19,779 --> 14:48:26,419
and you know point we're going to use this a lot so what arguments
6782
14:48:27,059 --> 14:48:36,339
latitude longitude meters above the ground so now we have these
6783
14:48:36,339 --> 14:48:41,939
up for yourself and you don't use it for a while and then you
6784
14:48:41,940 --> 14:48:49,620
variables you can use so all this you know we can just keep this
6785
14:48:49,620 --> 14:48:54,660
because we have from numpy we're going to import mean because
6786
14:48:56,419 --> 14:49:02,979
and then the rest of these are from you know the media stat
6787
14:49:02,980 --> 14:49:11,380
daytime plot and for media stat we're going to just import these
6788
14:49:12,500 --> 14:49:17,860
it's useful put the documentation in you know that here's the
6789
14:49:17,860 --> 14:49:22,660
you know put that in there as a comment again just like the other
6790
14:49:22,660 --> 14:49:28,340
people good to keep track of these things so now we know what
6791
14:49:28,339 --> 14:49:35,059
period and what i wanted to do is i just picked you know sometime
6792
14:49:36,180 --> 14:49:45,220
start and end so i have eight time there we go year month day your
6793
14:49:46,339 --> 14:49:56,500
so the person who put out this one example online did this for
6794
14:49:56,500 --> 14:50:03,779
commented that out and i did one for philadelphia and i picked a
6795
14:50:03,779 --> 14:50:10,659
city because it you know the uh if you want to click places and
6796
14:50:10,660 --> 14:50:15,940
he had a lot of decimal places so i just wanted to round it to two
6797
14:50:15,940 --> 14:50:20,660
you know you know in philadelphia in general and then round it to
6798
14:50:20,660 --> 14:50:27,060
where we got so it's a some random street corner in the city and
6799
14:50:27,059 --> 14:50:34,180
how many meters above the ground so i put 10 because this could be
6800
14:50:34,180 --> 14:50:43,059
on top of a building and i wanted to compare this to somewhere in
6801
14:50:43,059 --> 14:50:49,379
closely packed buildings does that affect wind speed well we're
6802
14:50:49,379 --> 14:50:54,259
the ground so this is in you know residential neighborhood that is
6803
14:50:54,260 --> 14:51:00,340
buildings but i picked a point in the suburbs and i picked a point
6804
14:51:00,339 --> 14:51:11,299
open field as something to compare so now i have these two points
6805
14:51:11,300 --> 14:51:20,580
uh so daily so that's the function in in media stat and there we
6806
14:51:20,580 --> 14:51:26,660
you know these are arguments that point and then start time and
6807
14:51:26,660 --> 14:51:36,660
daily data dot fetch and i'm going to store it as my data now we
6808
14:51:36,660 --> 14:51:42,580
my data and which one do i want i want wind speed for this one and
6809
14:51:42,580 --> 14:51:50,260
dot to numpy and i'm going to store that so now num data is my
6810
14:51:50,260 --> 14:51:57,380
that we want to do this library requires this function here i'll
6811
14:51:57,379 --> 14:52:04,899
that variable uh got fetched that's also from media stat i'll
6812
14:52:04,900 --> 14:52:12,660
a numpy array so i want to make that a number i want to take that
6813
14:52:12,660 --> 14:52:19,460
that column and make that a numpy array so i'll print that you
6814
14:52:19,459 --> 14:52:30,339
to get the mean to compare so now i have the second one again i'll
6815
14:52:30,339 --> 14:52:39,379
function fetch the data convert it to a numpy array and in this
6816
14:52:39,379 --> 14:52:47,379
but remember num data and num data too they're my two numpy arrays
6817
14:52:48,660 --> 14:52:54,420
so we can plot the line plot the line there we go and
6818
14:52:54,419 --> 14:53:04,419
and so i have this you know these two things i have you know the x
6819
14:53:06,180 --> 14:53:15,699
since i know that i made my since i know that i made my start and
6820
14:53:15,699 --> 14:53:26,579
30 days i wanted to make the x value there you go same thing one
6821
14:53:26,580 --> 14:53:33,940
it includes the first one so there we go and then i can plot these
6822
14:53:38,660 --> 14:53:44,580
all right now i'll tell you why i have that commented out i'll
6823
14:53:44,580 --> 14:53:53,940
these because this works like uh i wanted to again connect it with
6824
14:53:53,940 --> 14:54:00,980
matplot library that we use i wanted to connect it to that same
6825
14:54:00,980 --> 14:54:07,780
using and show you that that's what you can do you know get those
6826
14:54:07,779 --> 14:54:17,059
matplot.show but i commented this out this works also just a
6827
14:54:18,019 --> 14:54:25,219
you can just take that my data dot plot and then in parentheses
6828
14:54:25,220 --> 14:54:32,099
these two work so i just wanted to show you i'll leave them in
6829
14:54:32,099 --> 14:54:38,580
to connect this with the same type of math and plotting we're
6830
14:54:38,580 --> 14:54:45,940
so i had it calculate and then just display you know the city mean
6831
14:54:45,940 --> 14:54:51,700
rounded it but and quite honestly this is why we do data analysis
6832
14:54:51,699 --> 14:54:57,299
i really thought the average wind speed in this suburban area that
6833
14:54:57,300 --> 14:55:05,300
field would have been significantly higher and it was definitely
6834
14:55:06,099 --> 14:55:11,939
um maybe you know a little bit of a tunnel effect maybe there is
6835
14:55:12,900 --> 14:55:19,139
you know the buildings maybe that wasn't high enough also at least
6836
14:55:19,699 --> 14:55:26,579
and if it's high enough that's a little bit closer to the river
6837
14:55:26,580 --> 14:55:31,380
gives off a little bit more wind and this was a little bit closer
6838
14:55:31,379 --> 14:55:40,819
effect but there we go so then we see the mean but beyond that we
6839
14:55:40,819 --> 14:55:47,300
to day and you know they're still these two points that i picked
6840
14:55:47,300 --> 14:55:52,260
so it tracks they're in the same area the wind speeds go up and
6841
14:55:52,260 --> 14:55:58,980
patterns but we see that not just the mean but at every single
6842
14:56:07,379 --> 14:56:11,699
you know we could take a look now i made this so that's good and
6843
14:56:11,699 --> 14:56:21,139
we can pick like any number of days so i could since all the rest
6844
14:56:21,139 --> 14:56:29,139
just pick this and say well what about over the course of the year
6845
14:56:29,139 --> 14:56:51,779
one and maybe i make that 12 31 and there we go so if it would
6846
14:56:51,779 --> 14:57:04,019
and 365 so i want to graph it this way so from one to 365 and 365
6847
14:57:04,019 --> 14:57:12,419
up perfectly then i might have to do one more or one less but we
6848
14:57:12,419 --> 14:57:36,900
oh value error and it was 365 357 oh that's really interesting all
6849
14:57:42,500 --> 14:57:52,580
and so we can see you know the scattering but also i liked this
6850
14:57:53,139 --> 14:57:58,900
you know not 365 days that seemed like that would be it i'm not
6851
14:57:58,900 --> 14:58:08,500
right now maybe there were some days that were missing but you
6852
14:58:08,500 --> 14:58:17,699
pattern but you know maybe that sometimes that happens we go and
6853
14:58:17,699 --> 14:58:23,939
know take out missing information or incomplete information but
6854
14:58:23,940 --> 14:58:31,139
the day that i picked happened to be slightly lower than average
6855
14:58:31,139 --> 14:58:41,540
bit you know 14 miles an hour 8 miles an hour and then we can see
6856
14:58:41,540 --> 14:58:49,540
wind speed you know the average then what you could do is you know
6857
14:58:49,540 --> 14:58:54,340
that average you actually don't need to plot it out because it
6858
14:58:54,339 --> 14:59:01,939
averages you can work on that so if your wind speed is you know in
6859
14:59:01,940 --> 14:59:08,980
almost it's like 14 miles an hour throughout the year then you can
6860
14:59:08,980 --> 14:59:15,540
wind turbine and it would be actually relatively small but what
6861
14:59:15,540 --> 14:59:22,419
you need for 14 mile an hour winds and you can do some
6862
14:59:22,419 --> 14:59:28,019
how much electricity would that generate for you over the course
6863
14:59:31,220 --> 14:59:36,900
and again you can you know you can do that with you know any other
6864
14:59:36,900 --> 14:59:41,139
you know maybe you know you're trying to plan something you know
6865
14:59:41,139 --> 14:59:50,739
temperatures just one other thing i did just was you know
6866
14:59:50,739 --> 14:59:56,339
for you know a month just to show you and and all the rest of this
6867
14:59:56,980 --> 15:00:09,220
and what i did is i just made it a loop so you know range 1 to 11
6868
15:00:09,220 --> 15:00:22,660
month and i have you know what month there we go and you know
6869
15:00:22,660 --> 15:00:29,620
this because i thought oh well is that does that change and these
6870
15:00:29,620 --> 15:00:37,220
um yeah the way that the x value displays sometimes it seems like
6871
15:00:37,779 --> 15:00:45,059
but we can see we have you know wind speed and we can just see you
6872
15:00:45,059 --> 15:00:55,459
over the course of it and you see each month i have the mean and
6873
15:00:55,459 --> 15:01:04,099
and and then the graph so we can just see it's just interesting
6874
15:01:04,099 --> 15:01:13,699
for each month the display it a little this might be a little
6875
15:01:14,580 --> 15:01:20,740
interest or you could have something that displays them all in
6876
15:01:20,739 --> 15:01:29,379
four the grid it gets to be small graphs though but nonetheless we
6877
15:01:30,980 --> 15:01:36,980
when it goes down so i just wanted to show you some of these
6878
15:01:36,980 --> 15:01:45,860
with this with this graph and you know beyond that that there's
6879
15:01:45,860 --> 15:01:55,860
to in you know any other data you find if you you know you're
6880
15:01:55,860 --> 15:02:03,779
them maybe it's a csv but maybe somebody you know put together an
6881
15:02:03,779 --> 15:02:09,779
not only have the data and then that's stored somewhere but you
6882
15:02:09,779 --> 15:02:16,339
so that you have all these already how can i get a point and how
6883
15:02:16,339 --> 15:02:24,979
from any of those points so things that you can make and things
6884
15:02:24,980 --> 15:02:32,500
somebody else made you know different ways that you can find this
6885
15:02:32,500 --> 15:02:39,459
to give you some more tools now you know now that you know math
6886
15:02:39,459 --> 15:02:42,580
you know some more tools and some more sources of data
6887
15:02:47,059 --> 15:02:51,540
so what i want to show you here is just a few more things that you
6888
15:02:52,260 --> 15:02:58,660
and we already looked at over here on the left the table of
6889
15:02:59,300 --> 15:03:06,340
get to appear disappear then we have the search you can even
6890
15:03:06,339 --> 15:03:14,179
and then we have this folder icon where you can click to mount
6891
15:03:14,819 --> 15:03:21,940
and then once you do that then you can also see give it permission
6892
15:03:21,940 --> 15:03:29,860
it's mounting the google drive once you do that then you'll see it
6893
15:03:29,860 --> 15:03:34,980
so you can unmount the google drive if you want if if you wanted
6894
15:03:34,980 --> 15:03:39,620
so this makes it easy to find things and move things back and
6895
15:03:40,900 --> 15:03:49,940
then the really big thing down here is the look at these tags you
6896
15:03:49,940 --> 15:03:56,020
that are already in the google colab you see adding form from
6897
15:03:56,900 --> 15:04:01,779
get the code right here you can copy it or even click it you know
6898
15:04:01,779 --> 15:04:07,379
right in the place where you want to put it you click insert all
6899
15:04:07,379 --> 15:04:15,219
and notice this even uses javascript within python interfaces this
6900
15:04:16,819 --> 15:04:22,099
again all these and some of these you know downloading files
6901
15:04:24,500 --> 15:04:30,099
from google drive from github all kinds of things importing
6902
15:04:30,099 --> 15:04:38,419
you know that are in co-laboratory all of these zip reader there's
6903
15:04:38,419 --> 15:04:43,379
can do open files from github from your google drive from your
6904
15:04:43,379 --> 15:04:52,899
just upload those so it even gets down in here into pandas data
6905
15:04:53,459 --> 15:04:59,540
we want to get our math skills too that we can take data from
6906
15:04:59,540 --> 15:05:04,099
pandas part and then bring it in and then do some different math
6907
15:05:04,980 --> 15:05:12,260
display it in different ways and that's what we want to take this
6908
15:05:12,260 --> 15:05:20,580
you'll see below this video there's other code that i'll include
6909
15:05:20,580 --> 15:05:24,900
every one of these but check these out i mean there's so many
6910
15:05:24,900 --> 15:05:31,300
into colab that you can you can do you know open up a sample you
6911
15:05:31,300 --> 15:05:36,420
colab notebook i just call it code tester and i just have
6912
15:05:36,419 --> 15:05:41,059
and you know let's try this let's try that and then you know you
6913
15:05:41,059 --> 15:05:45,860
of stuff that works but here's all these things available and then
6914
15:05:45,860 --> 15:05:52,739
another colab notebook of just a few other things you know to
6915
15:05:52,739 --> 15:05:59,299
continue you know some things that you can do with math and with
6916
15:05:59,300 --> 15:06:04,660
upon this leading to you know working with data and doing some
6917
15:06:04,660 --> 15:06:09,860
so check these out and you know tinker with them and enjoy
6918
15:06:14,180 --> 15:06:21,300
wow you made it so now having gone through this now you should
6919
15:06:21,300 --> 15:06:26,819
you should be familiar with all the key concepts and how to write
6920
15:06:26,819 --> 15:06:34,900
algebra you should have your at least one or however you organized
6921
15:06:34,900 --> 15:06:43,540
ready with all of your scripts for solving all different sorts of
6922
15:06:43,540 --> 15:06:52,180
through certification one two and three and you have the ability
6923
15:06:52,180 --> 15:06:56,660
problems and you know write the code or reference code that you've
6924
15:06:56,660 --> 15:07:03,540
to solve these problems so there you go you should be you should
6925
15:07:03,540 --> 15:07:09,139
foundational math because it is the math that we're going to use
6926
15:07:09,139 --> 15:07:14,819
so many other things in math including data science data science
6927
15:07:14,819 --> 15:07:22,260
formulas like this functions like you've been working on you know
6928
15:07:22,260 --> 15:07:28,260
graphing so now you have an understanding of all that and then you
6929
15:07:28,260 --> 15:07:38,580
for yeah statistics data science and a few other subjects too so
6930
15:07:38,580 --> 15:07:49,620
step we will do a pre-calc trig that type of topic so you know
6931
15:07:50,180 --> 15:07:53,779
other graphs we didn't get to in in algebra because they're a
6932
15:07:53,779 --> 15:08:01,699
other sorts of patterns dealing with locations of things and
6933
15:08:01,699 --> 15:08:07,779
triangles so that'll be something that we'll do next and again
6934
15:08:07,779 --> 15:08:16,659
you with statistics and data science because as you represent data
6935
15:08:16,660 --> 15:08:23,780
of mathematical analyses to see relationships among data points
6936
15:08:23,779 --> 15:08:32,500
get you to be able to detect more and more complex relationships
6937
15:08:32,500 --> 15:08:39,940
foundation i feel like you have a good foundation hopefully you're
6938
15:08:39,940 --> 15:08:47,300
you made it and on to on to the next adventure
699500
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.