WEBVTT
00:00:00.000 --> 00:00:02.879
hi in this video we'll go over how we
00:00:02.879 --> 00:00:05.490
can build mathematical models with Tracy
00:00:05.490 --> 00:00:09.570
the turtle so just as a review we've
00:00:09.570 --> 00:00:11.280
learned how to draw graphs with Tracy
00:00:11.280 --> 00:00:12.509
using four loops
00:00:12.509 --> 00:00:15.540
every time X updates a new value of y is
00:00:15.540 --> 00:00:18.330
calculated and then we move Tracy to the
00:00:18.330 --> 00:00:20.850
new XY position using the set position
00:00:20.850 --> 00:00:23.730
command Tracy leaves a trail when moving
00:00:23.730 --> 00:00:25.769
to a new location and that gives us a
00:00:25.769 --> 00:00:28.890
graph now let's talk about modeling with
00:00:28.890 --> 00:00:32.340
Tracy first let's go over some
00:00:32.340 --> 00:00:35.280
vocabulary a mathematical model is a
00:00:35.280 --> 00:00:37.980
description of a phenomenon process or
00:00:37.980 --> 00:00:42.059
problem using mathematical equations we
00:00:42.059 --> 00:00:44.160
build mathematical models to help us
00:00:44.160 --> 00:00:46.140
understand the world around us and
00:00:46.140 --> 00:00:49.379
predict future events on the left you
00:00:49.379 --> 00:00:51.510
can see a population model that might
00:00:51.510 --> 00:00:53.670
help an ecologist understand why an
00:00:53.670 --> 00:00:55.620
animal population is growing or
00:00:55.620 --> 00:00:58.260
shrinking on the right we have a weather
00:00:58.260 --> 00:01:00.480
model that predicts how a typhoon will
00:01:00.480 --> 00:01:03.120
progress both of these models were built
00:01:03.120 --> 00:01:05.519
by developing mathematical equations to
00:01:05.519 --> 00:01:08.909
describe real world relationships today
00:01:08.909 --> 00:01:10.740
we'll be developing our own real
00:01:10.740 --> 00:01:13.950
mathematical models with Tracy we can
00:01:13.950 --> 00:01:16.259
use Tracy to build models of real world
00:01:16.259 --> 00:01:18.900
situations we already know how to graph
00:01:18.900 --> 00:01:21.600
with Tracy so instead of graphing x and
00:01:21.600 --> 00:01:23.759
y we can graph any two variable
00:01:23.759 --> 00:01:26.520
relationship so we could graph interest
00:01:26.520 --> 00:01:27.479
earned over time
00:01:27.479 --> 00:01:29.939
ice cream singles over temperature or
00:01:29.939 --> 00:01:32.280
the energy production of a wind farm
00:01:32.280 --> 00:01:35.549
over wind speed let's take a look so
00:01:35.549 --> 00:01:39.329
here's a scenario Paula has $600 she
00:01:39.329 --> 00:01:41.340
invests her money in an account that has
00:01:41.340 --> 00:01:44.009
a 4% annual interest rate that is
00:01:44.009 --> 00:01:47.159
compounded continuously how will her
00:01:47.159 --> 00:01:50.340
savings grow over 60 years let's use
00:01:50.340 --> 00:01:52.770
Tracy to help Paula understand her
00:01:52.770 --> 00:01:55.649
savings to build our model we'll need to
00:01:55.649 --> 00:01:57.509
write an equation that describes the
00:01:57.509 --> 00:01:59.820
relationship between time and the amount
00:01:59.820 --> 00:02:01.680
of money that Paula has in her account
00:02:01.680 --> 00:02:04.049
because this is a compound interest
00:02:04.049 --> 00:02:06.210
problem it helps us to remember that the
00:02:06.210 --> 00:02:08.009
general equation for compound interest
00:02:08.009 --> 00:02:11.879
is a equals P times e raised to the RT
00:02:11.879 --> 00:02:13.330
power
00:02:13.330 --> 00:02:16.420
in this equation a represents the amount
00:02:16.420 --> 00:02:18.610
of money in the account at a given time
00:02:18.610 --> 00:02:24.610
period of money she initially invests in
00:02:24.610 --> 00:02:28.660
the account he is a famous irrational
00:02:28.660 --> 00:02:30.370
number sometimes called Euler's number
00:02:30.370 --> 00:02:32.890
after the swiss mathematician it's
00:02:32.890 --> 00:02:35.740
approximately 2.718 but because it's
00:02:35.740 --> 00:02:37.660
irrational the decimal will continue
00:02:37.660 --> 00:02:41.140
infinitely without repeating our
00:02:41.140 --> 00:02:42.730
represents the interest rate for the
00:02:42.730 --> 00:02:45.850
account and T represents the amount of
00:02:45.850 --> 00:02:48.520
time that has passed in years let's use
00:02:48.520 --> 00:02:52.750
this formula to write our model okay so
00:02:52.750 --> 00:02:54.430
let's look at the information that we
00:02:54.430 --> 00:02:57.370
have we know that our initial investment
00:02:57.370 --> 00:03:00.640
or principal is $600 so let's set our
00:03:00.640 --> 00:03:04.480
principal equal to 600 we also know that
00:03:04.480 --> 00:03:06.940
interest rate is 4% so we can go ahead
00:03:06.940 --> 00:03:09.610
and set the rate equal to point zero
00:03:09.610 --> 00:03:12.220
four be careful to make sure that you
00:03:12.220 --> 00:03:14.260
write the interest rate as a decimal and
00:03:14.260 --> 00:03:17.739
not as a percentage now instead of
00:03:17.739 --> 00:03:20.650
plotting X&Y we want to plot time and
00:03:20.650 --> 00:03:22.600
savings since we'll be calculating
00:03:22.600 --> 00:03:24.760
savings based on the time that has
00:03:24.760 --> 00:03:26.860
passed we'll write a for loop where we
00:03:26.860 --> 00:03:30.220
update time we want to calculate savings
00:03:30.220 --> 00:03:31.420
over 60 years
00:03:31.420 --> 00:03:34.680
so we'll say for time and range 60 and
00:03:34.680 --> 00:03:37.450
now in the for loop we can just write
00:03:37.450 --> 00:03:40.030
our equation now we need to write our
00:03:40.030 --> 00:03:42.040
equations so that Python can understand
00:03:42.040 --> 00:03:44.590
it in Python when we want to use the
00:03:44.590 --> 00:03:47.370
number e we need to write math II
00:03:47.370 --> 00:03:49.959
remember Python is very picky about
00:03:49.959 --> 00:03:53.410
typos and capitalization Python also has
00:03:53.410 --> 00:03:55.989
a special way of writing exponents we'll
00:03:55.989 --> 00:03:58.450
want to type two asterisks to show that
00:03:58.450 --> 00:04:00.880
we want to raise math to the power of
00:04:00.880 --> 00:04:01.980
rate times time
00:04:01.980 --> 00:04:04.420
we'll need parentheses to show that we
00:04:04.420 --> 00:04:06.459
want the product of rate in time as the
00:04:06.459 --> 00:04:07.150
exponent
00:04:07.150 --> 00:04:09.549
let's go code this so just like before
00:04:09.549 --> 00:04:12.250
our world is already set up so that our
00:04:12.250 --> 00:04:15.190
axes are labeled now I'll set my values
00:04:15.190 --> 00:04:18.250
for principal and rate and I want to
00:04:18.250 --> 00:04:20.109
define these outside of my function
00:04:20.109 --> 00:04:21.640
because it makes it easier for me to
00:04:21.640 --> 00:04:27.360
change these values if I need to later
00:04:27.360 --> 00:04:29.560
and I'll actually want to be careful
00:04:29.560 --> 00:04:32.350
because I noticed that my y axis is
00:04:32.350 --> 00:04:34.780
labeled savings in hundreds of dollars
00:04:34.780 --> 00:04:37.990
so instead of 600 I want my principal to
00:04:37.990 --> 00:04:40.540
actually just be six because that's how
00:04:40.540 --> 00:04:43.980
many hundreds of dollars I'm looking at
00:04:43.980 --> 00:04:46.930
now I'll write my for loop so for time
00:04:46.930 --> 00:04:51.310
in range sixty and then I'm going to
00:04:51.310 --> 00:04:55.800
type my equation
00:04:55.800 --> 00:04:59.580
and remember I used math da e instead of
00:04:59.580 --> 00:05:02.610
E and I used two asterisks because I
00:05:02.610 --> 00:05:05.490
wanted to raise ^ and if you need any
00:05:05.490 --> 00:05:08.129
reminders you have it in your left hand
00:05:08.129 --> 00:05:16.190
Docs alright let's try running this code
00:05:16.190 --> 00:05:18.560
okay can you see why nothing happened
00:05:18.560 --> 00:05:21.150
we're calculating the amount in our for
00:05:21.150 --> 00:05:23.639
loop but we're not telling Tracy to move
00:05:23.639 --> 00:05:26.879
after the amount is calculated so I want
00:05:26.879 --> 00:05:37.259
to say set position time okay all right
00:05:37.259 --> 00:05:39.449
that's a lot better now because I've
00:05:39.449 --> 00:05:41.490
used variables to set my principal and
00:05:41.490 --> 00:05:43.409
rate it's easy to see how my model
00:05:43.409 --> 00:05:45.539
changes if the interest rate is only 3%
00:05:45.539 --> 00:05:50.069
or if the initial amount is $800 here's
00:05:50.069 --> 00:05:51.990
a model that plots the temperature of a
00:05:51.990 --> 00:05:54.539
region over the course of a year you can
00:05:54.539 --> 00:05:56.370
see how the temperature is low in
00:05:56.370 --> 00:05:59.159
January goes up to its hottest around
00:05:59.159 --> 00:06:00.719
the middle of the year and then falls
00:06:00.719 --> 00:06:03.449
again towards the end of the year now
00:06:03.449 --> 00:06:04.979
it's your turn to create some
00:06:04.979 --> 00:06:08.060
mathematical models