ENSP 338 Homework 1

This is a warmup to get you used to using the notebook for calculations.

In this homework, you will get acquainted with the Jupyter Notebook, which we will be using extensively in this class. You will need to sign up on SageMathCloud and pay the fee for this semester to use the tool. If you find yourself stuck, please read the computing tutorial.

In [2]:
from numpy import sin, cos, pi
#this import allows you to use trigonomic functions for this notebook
#example:
sin(0.1) # note that computers expect radians, not degrees
Out[2]:
0.099833416646828155

Question 1

If $\phi$ equals 30 degrees and $a$ equals 10, what is the value of $$ a\sin\phi\cos\phi $$

Hint: this should not be negative.

The computer only understands radians, not degrees so I need to convert 30 degrees before I can do anything. $$ radians = degrees * \frac{pi}{180} $$

In [3]:
degrees = 30
radians = degrees * (pi/180)

radians
Out[3]:
0.5235987755982988
In [14]:
phi = 0.52
a = 10

a * sin(phi) * cos(phi)
Out[14]:
4.3120211362166927
In [13]:
A1 = 4.31 radians  # put your answer here

Question 2

If $f = 60$, $t= 1$ and $\phi = 0.785$ radians, what is the value of $$ sin(2\pi f t + \phi) $$

In [20]:
sin(2 * 3.14 * 60 * 1 + 0.785)
Out[20]:
0.55958217735771443
In [4]:
A2 = 0.56 # put your answer here

Question 3

If $r_1 = 10$ and $r_2 = 20$ what is the value of $$ \left(\frac{1}{r_1} + \frac{1}{r_2}\right)^{-1} $$

In [24]:
r1 = 10
r2 = 20
A3 = ((1/r1) + (1/r2))**-1
A3
Out[24]:
6.666666666666666
In [5]:
A3 = 6.67 # put your answer here

Question 4

If $r = 0.02$ and $n = 10$, what is the value of $$ \frac{1}{(1 + r)^n} $$

In [25]:
r = 0.02
n = 10
A4 = 1 / (1 + r)**n
A4
Out[25]:
0.8203482998751551
In [5]:
A4 = 0.82 # assign your answer to the variable A1
A4 # write out the contents of the variable A1
Out[5]:
0

Table

Enter a table with some new values here:

Degrees Radians
90 1.57
180 3.14
270 4.71

Homework Image

Replace the image below with one of your choosing. You will need to upload your own image file, choose a name, and change the link below.

https://github.com/dsoto/computing-tutorial/blob/master/8-images.ipynb

In [ ]: