ECON526: Problem Set 1

Authors
Affiliation

Jesse Perla, UBC

Jesse Perla

University of British Columbia

Student Name/Number:

Instructions

  • Ensure you modify the field above with your name and student number above immediately
  • Modify directly and do not rename the file as Canvas will automatically append your name to it.
  • Submit both the .ipynb and an exported html version of this file.
  • See here for instructions.
  • Do not change the filenames. Canvas automatically appends your name/student number to submitted files.

Setup

import numpy as np
import matplotlib.pyplot as plt

Install Python (with Jupyter and VS Code)

  • See here for instructions and links.
  • VS Code is optional but recommended.

Question 1

Modify the next cell with some math text with the Pythagorean theorem (e.g. \(x^2 + y^2 = z^2\))

Answer:

(double click to edit your answer)

Question 2

Modify the next cell to create a function which takes the sides of the rectangle and calculates the hypotenuse (i.e., code up \(z(x,y) = \sqrt{x^2 + y^2}\)) then calculate \(z(3,4)\)

# modify here

Question 3

Take the following system of equations, build a matrix, and solve for the system of equations using numpy’s linalg.solve function.

\[ \begin{aligned} 2 x_1 + 3 x_2 &= 5 \\ 4 x_1 + 9 x_2 &= 20 \end{aligned} \]

# modify here

Question 4

Now take the following system

\[ \begin{aligned} x_1 + 2 x_2 &= 5 \\ 2 x_1 + 4 x_2 &= 10 \end{aligned} \]

Try this with linalg.solve. Why doesn’t it work? If this has a solution, find it and explain.

# modify here

Answer:

(double click to edit your answer)

Question 5

Plot \(f(x) = x^2\) for a grid of 20 points of \(x \in [0,1]\). Hint: You can make a grid with np.linspace(...) and use matplotlib’s plt.plot(...) function.

# modify here