Mathematical Economics: Homework: Alan G. Isaac August 29, 2020

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Mathematical Economics:

Homework

Alan G. Isaac

August 29, 2020


2

WARNING: This document is copyright 2020 by Alan G. Isaac, all rights reserved. Unau-
thorized sharing of this document is a copyright violation. For students of American University,
unauthorized uses of this document are additionally an Academic Integrity violation. The only
authorized duplication of this document is by Econ 705 students taking this course in 2020, who
may retain one (1) printed copy exculsively for their own personal use.

Collected Assignments Assignments will be listed below as they are assigned. Each assignment
is due before the start of the subsequent class, unless otherwise announced. Each assignment should
include a header that lists the homework number, your name, and an acknowledgment of your group
members (or anyone else who provided useful help).
Homework submissions must be typed in a Mathematica notebook and submitted in PDF for-
mat. (PDF Creation Hint: disable ”Dynamic Updating” (Menu/Evaluation/Dynamic Updating
Enabled) before printing to PDF.) Make sure you do a Mathematica tutorial before attempting
to write up your homework! A single file should contain your answers to all the exercises for a
homework. Computational problems should include helpful comments on your Mathematica code.

Discussion Sections Be sure to read the discussion sections for the computational problems. In
addition to providing hints, they sometimes include details about the problem requirements.

Computational Exercises: Some computational exercises below could easily be done with a
calculator or even by hand. In such cases you need to provide the code, however trivial.

WL Programming The online WL documentation is excellent. E.g., http://www.wolfram.


com/broadcast/video.php?channel=89&video=409.
3

Assignments
HW01
Assignments are due before the next class starts. Turn in a PDF file created from Mathematica.
Your filename should combine the homework number and your last name: e.g., hw01-Lastname.pdf.
(Never use spaces or any other punctuation in your file names.) Submit this PDF via Blackboard.
A crash upon PDF creation is rare but not unknown. So first save your work. Then, after saving
your work, try saving it as PDF. You may have better success saving as PDF if you first go to the
Evaluation menu and disable Dynamic Updating.
This homework includes some review of material from the math camp. Students who missed the
math camp may need to get notes from fellow students. However, the material is also covered fully
in the online notes (e.g., matrix1.pdf).
Before beginning this assignment, be sure to work through the first four sections of the Wolfram
U Video Class entitled Hands-On Start to Mathematica. Use a separate notebook subsection for
each problem.
To improve your Mma programming skills, read section 8.5 of the Torrence and Torrence book
(on reserve). The online Wolfram documentation is also excellent. E.g., http://www.wolfram.com/
broadcast/video.php?channel=89&video=409. Please pay attention to both the general and the
language-specific discussion that I append to many problems.
Exercise 1.1 Consider the following three sets: P1 = {1, 3, 5, 7, 9}, P2 = {1, 3, 5, 7, 11}, P3 =
{2, 4, 6, 8, 10}. Using set operations, produce
P1 ∪ P2 P1 ∩ P 2 P1 \ P2 P1 ∆ P2
P1 ∪ P3 P1 ∩ P3 P1 \ P3 P1 ∆ P3
P2 ∪ P3 P2 ∩ P3 P2 \ P3 P2 ∆ P3
Exercise 1.2 (Membership Table) Given two sets P and Q, create a membership table for
elements that are in the complement of P or are in Q. (Include an extra column for P c .) Create
another membership table for elements that are in the (P \ Q)c . (Include an extra column for P \ Q.)
Draw Venn diagrams for the two sets.
General Discussion: See http://cglab.ca/~discmath/sets-membershiptables.html.

WL Discussion: Create your table entries as a binary matrix. Format them with TableForm, using the TableHeadings
option. Do not worry about vertical separators in the table. (But you can instead use Grid if you really want them.)
Use Mathematica’s drawing tools to draw the Venn diagrams.

Exercise 1.3 (DeMorgan’s Laws) For any three sets R, P , Q, prove that

ˆ R \ (P ∩ Q) = (R \ P ) ∪ (R \ Q)

ˆ R \ (P ∪ Q) = (R \ P ) ∩ (R \ Q)

Prove each identity by proving mutual inclusion. Prove each identity with a membership table.
General Discussion: You are proving DeMorgan’s Laws, so you should not invoke them in your proof. Remember
that we prove set equality by proving mutual inclusion. To show equality between sets S1 and S2 , first show S1 ⊆ S2 ,
and then show S2 ⊆ S1 . To show S1 ⊆ S2 , consider an arbitrary element of S1 and show that it must be in S2 .

Exercise 1.4 (Truth Table) Evaluate the truth conditions for (p =⇒ q) by filling in a truth
table. Your table should begin with the three-column header

p q p =⇒ q
4

followed by a 4x3 table of associated truth values.


Next, evaluate the truth conditions for (¬p ∨ q) by filling in a truth table. Your table should
begin with the four-column header

p q ¬p ¬p ∨ q

followed by a 4 × 4 table of associated truth values.


What do you conclude by comparing the two truth tables?
General Discussion: Velleman provides very good coverage of truth tables, but you may also find the Wikipedia
article on truth tables to be helpful.

WL Discussion: Create a truth table with the BooleanTable command. Format your table with TableForm, and
use the TableHeadings option to add a header.
Before starting, be sure you can explain the result of TableForm@BooleanTable[{p, q}, {p, q}]. (For a standard
truth table, the first two expressions should just be p and q.)
Note: you can also use TautologyQ to test for logical equivalence.
Current location of online resources:
Boolean operations: http://reference.wolfram.com/language/guide/LogicAndBooleanAlgebra.html

Python Discussion: Python does not have built-in commands for producing tables, but we can produce text tables
by printing Python strings. For this exercise, work with the special values True and False. (Alternatively, you might
work with 1 for True and 0 for False.) We will use the operators and and or to make comparisons between pairs of
truth values. For logical negation we will use not.
First we take up the issue of producing the truth-value combinations we need for p and q. With just these two,
it is simple enough to just list them: p = [True, True, False, False] and q = [True, False, True, False]. This
is absolutely fine, but we briefly illustrate an approach using the product function in the itertools module. (This
approach can be extended to any number of independent propositons by changing the value of repeat.)

import i t e r t o o l s
t f = ( True , F a l s e )
p , q = zip ( * i t e r t o o l s . p r o d u c t ( t f , r e p e a t =2) )

The following code produces a truth table for logical or.

h d r s = ' p ' , ' q ' , ' p or q '


print ( h d r s )
f o r i in range ( 4 ) :
print ( p [ i ] , q [ i ] , " | " , p [ i ] or q [ i ] )

When you execute this code, Python will print a the truth table for p ∨ q. Unfortunately, the lack formatting
makes this table a bit hard to read. If we take advantage of Python’s string formatting capabilities, we can make this
look nicer.

fmt = " {:^10} " * 3


h e a d e r = fmt . format ( "p" , "q" , "p or q" )
print ( h e a d e r )
f o r i in range ( 4 ) :
print ( fmt . format ( p [ i ] , q [ i ] , p [ i ] or q [ i ] ) )

Read about string formatting in the Python Library Reference section on String Formatting Operations. If you
are using Python interactively, you may want to put the print commands all on one line so that they will all be
executed together. (This is not necessary in a script file.) You can also add a print function with an empty argument
to give a blank line, to make the output a bit more readable.
Current locations of online resources:
Boolean operations: http://docs.python.org/reference/expressions.html#boolean-operations
String Formatting Operations: http://docs.python.org/lib/typesseq-strings.html
5

Exercise 1.5 (Based on Velleman (2019, p.24).)


Find a formula using only the conjunction (∧) and negation (¬) that is equivalent to the formula
p ∨ q. Justify your claim of equivalence with a truth table.
General Discussion: Velleman provides very good coverage of truth tables. You may additionally find the Wikipedia
article on truth tables to be helpful.

WL Discussion: It is certainly possible to create truth tables by hand, but most students will want to use
BooleanTable and TableForm.

Exercise 1.6 Velleman (3rd edition): p.43 #1, 9; p.66 #8, 9, 10 (with full explanations for all
three).
Computational Exercise 1.1 Consider the select algorithm in Listing 1.1, which is expressed
in a somewhat formal pseudocode. In your own words, explain what this algorithm does and how.
Very high level programming languages often provide some kind of builtin select functionality.
Discuss the availability of facilities for selective set building in a single programming language.
Explain how to build subsets with these facilities.
Create a boolean function named lucky7 that takes a single integer argument and determines
whether that argument is evenly divisible by 7.
Generate 100 random integers in [0, 1000], and use your selection facilities and lucky7 function
to find the subset of these numbers that is divisible by 7.
General Discussion: See sets.pdf for a description of how the algorithm works. Be sure that your answer uses
your own words.
Note: Modern languages often treat functions like any other object: they can be assigned to variables, passed as
arguments, or returned from other functions. Such languages are said to treat functions as first-class citizens and to
have first-class functions. Examples include Haskell, Mathematica, and Python.

WL Discussion: Review the help for WL’s built-in Select, Cases, and Pick commands. In your own words,
describe the difference between these commands. Read about the following WL commands: Set, Function, Union,
RandomInteger, and Mod.

Python Discussion: Reminder: use of Python in this course is optional and ungraded. Use of Mathe-
matica is required.
Review the help for Python’s built-in function filter function. Note that the order of the arguments. Read about
the % operator and Python function definition. Learn about the random-number facilities of the random module. Feel
free to use a list type or a set type.

Listing 1.1: Set Building


Function s e l e c t (
Ω : Set , #t h e i n p u t s e t f o r t h i s b u i l d e r
p : Callable #t h e p r e d i c a t e f o r t h i s b u i l d e r
) → Set :
s ← ∅ # i n i t i a l i z e w i t h empty s e t
for ω ∈ Ω:
i f p (ω) then:
s ← s e t U n i o n ( s , {ω } )
return s

Computational Exercise 1.2 Let x be the first 100 nonnegative integers, N100 . Use integer
division or the modulo (remainder) operation to produce two subsets of x: the set x3 whose elements
6

are the numbers divisible by 3, and the set x5 whose elements are the numbers divisible by 5. Produce
and print to screen the following:
x3 ∪ x5 , x3 ∩ x5 , x3 \ x5 , and x3 ∆x5 .
WL Discussion: Use the Range command to produce a list of the first n nonnegative integers. Note that a Mathe-
matica range does include its end value. (Evaluate ?Range to see the usage.) For the modulo operation, use the Mod
command. For integer division, use the Quotient command. (Evaluate ?Mod and ?Quotient to see the usages.) You
may also find Select or Pick to be a useful command for this exercise. (If you use Select you may want to read
about WL’s pure functions.) Mathematica does not have a separate set type: use lists. For the set operations, use
the commands described in the online documentation. To nicely format your answer, you can use StringForm and
ToString.
Current locations for online resources:
Sets: http://reference.wolfram.com/mathematica/tutorial/ListsAsSets.html
Pure Functions: http://reference.wolfram.com/mathematica/tutorial/PureFunctions.html

Python Discussion: Reminder: use of Python in this course is optional and ungraded. Use of Mathe-
matica is required.
Use Python’s range command to produce a list of the first n nonnegative integers. Note that a Python range
does not include its end value. (In the interpreter, evaluate help(range) to see usage.) Python provides a modulo
operator (%) and an integer division operator (//). Python has a separate set type. For the set operations, use the
operators described in the online documentation.
Current locations for online resources:
Binary operators: http://docs.python.org/reference/expressions.html
Sets and set operations: http://docs.python.org/library/sets.html
Generator expressions: http://www.python.org/dev/peps/pep-0289/
Set comprehensions: http://en.wikipedia.org/wiki/List_comprehension#Set_comprehension

Exercise 1.7 (Matrix Review) Consider the following matrices:


     
1 7 15 8
A= b1 = b2 =
2 3 8 5

Write down the two equations represented by the matrix equality Ax = b1 . Next solve for x by
using a matrix inverse. Write down the two equations represented by the matrix equality Ax = b2 .
Next solve for x by using a matrix inverse.
General Discussion: Do this by hand. (See my Mathematica notes for typesetting matrices.)

Computational Exercise 1.3 (Matrix Review) Use a matrix inverse to find the solutions for
exercise 1.7.
Comment: Computing an inverse can be computationally expensive, and inverses often have
poor numerical accuracy. For real computational problem, you generally do not want to use an
inverse. (Many languages will provide a solution routine using, for example, Gaussian elimination.)
For most of our textbook exercises, however, you may use the inverse. So do it anyway this time.
WL Discussion: Remember, a Mathematica matrix is a rectangular lists of lists. Be sure your newly created symbols
begin with a lower-case letter! Use the Inverse and Dot commands. If A and B are WL matrices, you can form their
matrix product in the following ways: A.B or Dot[A,B]. Finally, you can also read about LinearSolve, if you wish.
In a Mathematica notebook, you can get help on any WL command by evaluating it with a preprended question
mark: for example, ?Inverse or ?Dot.

Python Discussion: Create your matrices as numpy arrays. Remember, you can create an array from a rectangular
lists of lists. Note: you can find the inverse of a square numpy array A as np.linalg.inv(A). (But read about
numpy.linalg.solve, if you wish.) If A and B are conformable numpy arrays, you can form their matrix product in
the following ways: np.dot(A,B), or A.dot(B). You can get help on a Python command by inputting it as an argument
to the help command. (E.g., after import numpy as np, you can evaluate help(np.dot).)

Exercise 1.8 (Matrix Review) Linear Comparative Statics:


Consider a very simple representation of a Keynesian IS-LM model given by
7

IS: y = f − br
LM: m = ky − h · (r + π)
with the real interest rate (r) and real income (y) as our endogenous variables, and real money
supply (m), expected inflation (π), and fiscal policy stance (f ) as our exogenous variables. All
parameters above are positive (so that the “responses” are the same as in class). Set up the matrix
representation of the comparative statics. Use the inverse of the coefficient matrix to solve for r and
y in terms of the exogenous variables. Explain how to find and sign the response of r to f .
Exercise 1.9 (Unconstrained Optimization Review) Unconstrained Optimization:
The so-called Laffer curve postulates that tax revenue is zero if the tax rate is 0% or 100% but is
positive in (0, 1). Typically the relationship between tax revenues and tax rates is assumed to be
concave. Here is a simple algebraic representation of a Laffer curve.

r = θ (t − t2 )

(Here r : [0, 1] → R, and θ > 0.) Plot the Laffer curve. (You can use θ = 10.) Use calculus to solve
for the maximum. (Be sure to show that you have found a maximum.)
WL Discussion: You may use WL’s D and Solve commands to work this problem.

Exercise 1.10 (Constrained Optimization Review) Suppose you want to maximize xy sub-
ject to the following constraint: 2x + y = k. (Here k is a fixed parameter.) Use the constraint to
solve for y in terms of x. Plug this expression for y into your objective function and solve for the
optimal value of x. (Have you found a maximum? How do you know?) Then use the constraint
again to solve for the optimal value of y. Solve for x and y. How do x and y respond to changes
in k? (Answer this by reporting proportional responses; that is, what is the elasticity of x w.r.t. k,
and what is the elasticity of y w.r.t. k?)
General Discussion: Be sure to review the concept of elasticity.

WL Discussion: Feel free to use Mathematica’s computational facilities, including the D and Solve commands.

OPTIONAL (ungraded, no credit) problems:


Note: Since these optional exercises are ungraded, you may share your efforts with classmates
without restriction. Just make sure your graded work is not visible if you share your computer
screen or a file.
Exercise 1.11 (Matrix Review) In the math camp, we defined matrix multiplication in a par-
ticular and useful way, so that     
a b x ax + by

c d y cx + dy
Suppose you are asked to multiply the 2 × 2 matrix A times the 2 × 1 matrix x1 , where
   
1 2 1 5
A= x =
3 4 6
8

You can compute Ax1 with the following explicit 4-step procedure:
  
1 2 5
Ax1 =
3 4 6
 
1×5+2×6
=
3×5+4×6
 
5 + 12
=
15 + 24
 
17
=
39

Let      
4 3 2 6 3 1
B= x = x =
2 1 5 2
Explicitly follow the same 4-step solution procedure to produce the following products: Ax2 , Ax3 ,
Bx1 , Bx2 , Bx3 .
Computational Exercise 1.4 Do all the matrix multiplications in exercise 1.11, and display your
answer in each case. (Format the display nicely, if your language makes that simple.)
WL Discussion: As an example, you can produce and print the product Ax1 as follows:

A = {{1 ,2} ,{3 ,4}}


x1 = { { 5 } , { 6 } }
Print [ "A x1 =" ]
Print [A. x1 ]
It might be nice to use a string template:

tmp = StringTemplate [ " `` = `` " ,


InsertionFunction => ToString @* TraditionalForm ]
tmp [ "A. x1 " ,A. x1 ]

Python Discussion: As an example, you can produce and print the product Ax1 as follows:

import numpy a s np
A = np . a r r a y ( [ [ 1 , 2 ] , [ 3 , 4 ] ] )
x1 = np . a r r a y ( [ [ 5 ] , [ 6 ] ] )
print ( "A x1 =" )
print ( np . dot (A, x1 ) ) # t r a d i t i o n a l
print ( A. dot ( x1 ) ) #g o o d a l t e r n a t i v e :
print ( A @ x1 ) #new a l t e r n a t i v e

Computational Exercise 1.5 In exercise 1.1, you explain what a particular select algorithm
does. Using a looping construct provided by your chosen language, implement this algorithm as a
function.
Does your language include features that already accomplish what your select function does?
If so, compare your select to those facilities.
Create a boolean function named lucky7 that takes a single integer argument and determines
whether that argument is evenly divisible by 7.
Generate 100 random integers in [0, 1000], and use your select and lucky7 functions to find the
subset of these numbers that is divisible by 7.
General Discussion: Do not use built-in filtering or selection facilities. However, if your language does not provide
an imperative looping construct, you may use mapping, set comprehension, or recursion.
9

You may find useful the Wikipedia discussion of the foreach loop construct.

WL Discussion: Read about the following WL commands: AppendTo, DeleteDuplicates, Do, Map, Table, RandomInteger,
SetDelayed, and Mod. Also, read the Wolfram Language tutorial entitled Specifying Type of Expressions in Patterns.
If your function body introduces new variables, read about With and Module, and make them local.
Hint: lucky7 = Function[Mod[#,7]==0] is one way to implement the predicate for this problem. (If you use this
code, be sure to add commentary explaining how it works.)
Comment: To mimic the pseudocode for select, it is natural to use AppendTo to add elements. However, it is usually
best to avoid repeated use of AppendTo. If you want to take a more efficient approach in Mathematica, you can use
Map or Table with If and Nothing. For an interesting exercies, can use Do with Sow and Reap.
WL provides selective setbuilding via the Select command (and in other ways as well). Of course, for this
exercise, you are are asked not to use built-in functionality. (But you can use it to check your work!)

Python Discussion: Read about Python’s for loop construct, its if statement, and its set data type. Also read
about randint function in NumPy’s random package.
Hint: def lucky7(x): return x%7==0 is one way to implement the predicate for this problem. (If you use this code,
be sure to explain how it works. You may also want to add a test that the argument is an integer.)
Python provides this functionality with filter (and other ways as well). Of course, for this exercise, you are are
asked not to use built-in functionality. (But you can use it to check your work!)

Computational Exercise 1.6 After setting a random seed of 314, create 100 random integers
between 1 and 1000. (Why are we setting a random seed?) This will be the background set, Ω.
Create two selection functions, named p and q. The first should select numbers evenly divisible
by 3. The second should select numbers evenly divisible by 7. Produce the corresponding sets P
and Q.
Produce the union, intersection, and set difference of P and Q in two ways. First, use set
operations on P and Q. Second, reuse your selection functions to appropriately select from Ω.
Comment on the relationship between set operations and logical operations.
WL Discussion: See the documentation for And, Complement, Intersection, Mod, Not, Or, RandomInteger, RandomSample,
SeedRandom, Span, and Union.
You may find useful the Wolfram Language Guide on Logic and Boolean Algebra.

Python Discussion: Use Python’s random module along with either set comprehension or the builtin filter com-
mand.

Computational Exercise 1.7 Here is some example Python code for list creation and manipu-
lation:
v1 = [ 0 , 1 , 2 ]
v2 = v1
v2 [ 1 ] = 99

Here is some example Mathematica code for list creation and manipulation:
v1 = { 0 , 1 , 2}
v2 = v1
v2 [ [ 1 ] ] = 99

After executing the Python code, what are the values of v1 and v2? After executing the Mathematica
code, what are the values of v1 and v2? Explain the differences.
Note: you do not need to submit a file showing this Python code. Just report the values you
observe.
Exercise 1.12 What is mathematical induction? (Provide a detailed description.) Prove by
mathematical induction that a set with n elements has 2n distinct subsets.
General Discussion: Be sure to provide an explicit citation of any resources you rely on when doing this problem,
including my notes or other internet resources. Even with citation, do not just copy a proof from my notes; use your
10

own words to provide detailed, step-by-step explanation. (And of course, never copy another student’s work, not even
with citation. This would be an Academic Integrity violation.)
To review proof by induction, you can read the Wikipedia article on mathematical induction. (Or better yet,
break out any good calculus text or discrete math text.) Then read Velleman (2019, section 6.1).
Remember that the subsets of a set S include ∅ and S.
Bibliography

Steindel, C. (1995, December). Chain-weighting: The new approach to measuring GDP. Current
Issues in Economics and Finance 1 (9), 1–6.

Velleman, D. J. (2019). How to Prove It: A Structured Approach (3rd ed.). Cambridge, UK:
Cambridge University Press.

11
12 BIBLIOGRAPHY

Past Assignments

You might also like