WEBVTT
00:00:00.030 --> 00:00:02.429
have you ever wondered how many ditches
00:00:02.429 --> 00:00:05.790
a pie we really need our two digits have
00:00:05.790 --> 00:00:11.400
high enough how about 3 5 10 20 how many
00:00:11.400 --> 00:00:12.870
digits up high you really need may
00:00:12.870 --> 00:00:14.839
depend on what you're trying to do
00:00:14.839 --> 00:00:17.490
imagine if NASA only used two digits of
00:00:17.490 --> 00:00:19.949
pi to calculate the orbit the results
00:00:19.949 --> 00:00:23.640
may not be so good it turns out nASA
00:00:23.640 --> 00:00:25.769
uses 15 digits of pi in their
00:00:25.769 --> 00:00:27.810
calculations resulting in the correct
00:00:27.810 --> 00:00:30.449
orbits every time let's explore what
00:00:30.449 --> 00:00:32.750
would happen if NASA used fewer digits
00:00:32.750 --> 00:00:35.340
let's assume that the true circumference
00:00:35.340 --> 00:00:37.530
of a circle can be calculated using pi
00:00:37.530 --> 00:00:40.649
out to 15 decimal places the formula for
00:00:40.649 --> 00:00:42.600
circumference is the diameter times pi
00:00:42.600 --> 00:00:45.239
so this formula will represent the best
00:00:45.239 --> 00:00:49.500
value of a circle circumference what we
00:00:49.500 --> 00:00:51.629
want to know is how big of an air do we
00:00:51.629 --> 00:00:53.820
get when we use fewer than 15 decimal
00:00:53.820 --> 00:00:56.250
places in other words if we calculate
00:00:56.250 --> 00:00:58.170
the orbit of the International Space
00:00:58.170 --> 00:01:01.350
Station using only 3.1 how big is the
00:01:01.350 --> 00:01:03.030
difference in both my house and
00:01:03.030 --> 00:01:05.040
percentage from the circumference when
00:01:05.040 --> 00:01:10.350
we use all 15 decimal places to do this
00:01:10.350 --> 00:01:13.170
we're going to use the math class so
00:01:13.170 --> 00:01:15.270
let's take a look at how we use the math
00:01:15.270 --> 00:01:19.049
class in the editor okay so let's take a
00:01:19.049 --> 00:01:21.630
look at how we use the math class we're
00:01:21.630 --> 00:01:23.700
going to first take a look at getting pi
00:01:23.700 --> 00:01:25.470
so we're going to print it out just so
00:01:25.470 --> 00:01:27.240
we get a look at it so that's so system
00:01:27.240 --> 00:01:30.450
dot out dot print line and we're just
00:01:30.450 --> 00:01:35.220
gonna print it PI and we're gonna kind
00:01:35.220 --> 00:01:38.610
of catenate it with hi and notice that
00:01:38.610 --> 00:01:42.240
we use a capital M for math and we use
00:01:42.240 --> 00:01:45.540
PI as capital P I when we run this we'll
00:01:45.540 --> 00:01:48.960
see we get what pi is in the system in
00:01:48.960 --> 00:01:51.180
PI Y and Java is actually sort out to 15
00:01:51.180 --> 00:01:53.369
digits in a lot of our computer systems
00:01:53.369 --> 00:01:55.740
that's how far we get out so now let's
00:01:55.740 --> 00:01:57.329
say that take a look at how we can use
00:01:57.329 --> 00:02:01.079
this to calculate a diameter of a circle
00:02:01.079 --> 00:02:02.880
or circumference of a circle given a
00:02:02.880 --> 00:02:05.640
diameter so let's just say that we have
00:02:05.640 --> 00:02:12.980
int diameter equals 5
00:02:12.980 --> 00:02:14.599
and we want to calculate our
00:02:14.599 --> 00:02:15.800
circumference so we're going to say
00:02:15.800 --> 00:02:20.569
double the circumference equals our
00:02:20.569 --> 00:02:26.390
diameter times pi and so we're going to
00:02:26.390 --> 00:02:30.830
use math dot pi okay and now let's print
00:02:30.830 --> 00:02:45.069
that out and we can see what we have
00:02:45.069 --> 00:02:52.670
okay and there you go we calculate our
00:02:52.670 --> 00:02:55.310
circumference using math Chi now it's
00:02:55.310 --> 00:02:57.290
your turn to explore this and compute an
00:02:57.290 --> 00:03:00.069
exercise on your own