SAN JOSÉ STATE UNIVERSITY
ECONOMICS DEPARTMENT
Thayer Watkins
Econ 196E
Computer Applications in Economics
Course Green Sheet
Primer on HTML
Scripting languages
History of the Computer
- Hardware: Navigation and other fields required tables of logarithms and
trigonometric functions. The computation of this tables was repetitious and
tedious and human computers were prone to mistakes. People developed
mechanical aids for the computation of these tables. Charles Babbage's
attempt to build a mechanical computer in the early 19th century stemmed from
this need. Simpley calculating machines had been produced earlier by Blaise
Pascal (1623-1662) and G.W. Leibnitz (1646-1716).
The accuracy requirements of mechanical computers are very difficult to
satisfy and it was only with the development of electronics that computers
became technically feasible.
- The "differential analyzer" was built in the late 1920's at MIT
under the direction of Vannevar Bush. There was another line of development
of electromechanical computers called tabulating machines. Tabulation
machines were created by Herman Hollerith to meet the needs of the U.S.
Census Bureau. Hollerith's company was part of the foundation of IBM. The
punched card technology of tabulating machines had its antecedents in the
Jacquard loom.
- Software developments
The coding of information arose with the telegraph. Morse code is
essentially the binary coding of information.
- Early electronic computers
- Mark I Howard Aiken 1936 grant from IBM's Thomas Watson
- Konrad Zuse 1939
- Atanasoff-Berry Computer 1939
- ENIAC Electronic Numerical Integrator And Calculator (Computer) WWII
J. Presper Eckert and John Mauchly,
- John Von Neumann and the concept of an internally stored program
- EDVAC
Technology
- Electronics
-
Vacuum tube or valve Lee de Forest
- Transitor William Shockley John Bardeen Walter Bruttain
- Integrated Circuit IC Fairchild Semiconductor
Intel Chip Marcian "Ted" Hoff
- Magnetic tape
- Disk storage Seagate Alan Shugart
History of the development of the PC: Hardware and Software
- Ed Roberts (MITS Micro Instrumentation and Telemetry Systems) of Albuquerque, New Mexico advertised in the January 1975 issue of Popular Electronics a minicomputer kit called the Altair 8800 for $397. The input was via toggle switches on the front and output via a set of lights.
- 1975 Paul Allen and Bill Gates created an interpreter to run BASIC on the
Altair 8800 and then went on to found Microsoft.
- 1976 Gary Kildall of the Naval Postgraduate School in Monterey developed the
operating system CP/M and formed Digital Research to market it.
- Lee Felsenstein, freelance engineer and formerly the Man Friday of the
Berkeley Barb and Berkeley Tribe, served as the facilitator of the Homebrew
Computing Club in Palo Alto.
- 1977 Steven Jobs and Stephen Wozniak created Apple Computer.
- 1979 Seymour Rubinstein marketed WordStar through his company
- 1979 Daniel Bricklin marketed VisiCalc
- 1981 George Tate marketed dBaseII, a data base package created by Wayne
Ratliff who modeled it on software used at JPL for the space program. Tate
formed Ashton-Tate to market dBaseII, but the only Ashton involved in the
operation was Tate's parakeet.
- 1982 Mitchell Kapor introduced Lotus 123
Languages
- Machine specific languages
- Higher level languages FORTRAN, LISP, BASIC, COBOL, C, PASCAL, PL/I, APL,
FORTH, ALGOL, BASIC
- COMPILERS, INTERPRETERS
Basic structure of computer
- CPU: central processing unit
- buses
- Main memory RAM
( Volatile ROM)
- secondary memory hard disk floppy disk
nanoseconds vs. microseconds
History of operating systems
- Scheduled mainframe
- Batch operation
- SPOOLing
- Monitors
- TimeSharing, Multitasking (Multics)
- Operating systems
- Unix (Ken Thompson),
- CP/M (Gary Kildall),
- DOS (Bill
Gates),
- OS/2 (Microsoft)
Bill Gates Microsoft
- BASIC compiler (Paul Allen) DOS
References:
Fire in the Valley by Paul Freiberger and Michael Swaine
Hackers: Heroes of the Computer Revolution by Steven Levy
Programming Languages
- John Backus's team at IBM in New York brought out Fortran in 1957.
- Niklaus Wirth began developing Pascal in 1968 right after the debacle of
ALGOL68.
- Philippe Kahn came to the U.S. in 1982 with $2000 and the Pascal
compiler that became Turbo Pascal. He could not find a job, perhaps because
he had no permit to work here, so he decided to start his own business.
The Rudiments of Pascal
The basic structure of a Pascal program is:
A program typically consists of a part to obtain the input, a part to carry out the computation, and a part to provide output to the user.
Input is usually handled by means of the Pascal
readln statement.
A readln statement tells the computer what variables
are to be read in and in what order. The actual input
from the keyboard has to conform to the data types for
the variables.
It is usually necessary to prompt the user for data.
This is done by means of the writeln or write
statement. The difference between writeln and
write is that writeln moves to the next
line after the write operation whereas write
does not.
As the above program is written, the computer has
not been instructed as to the format for printing out
the discount factor df. It may print out 0.05 in the
form .500E-01, which means 0.5x10-1. To
make the format of df an 8 digit number with 6 digits
after the decimal one replaces
writeln('The discount factor equals ',df);
with writeln('The discount factor equals ',df:9:6);
The assignment of a value to a variable is achieved
by means of := (colon equal sign). The equal sign by
itself stands for testing for equality.
Pascal variables are strongly typed; i.e. care must
be taken to distinguish between variables which are
integers and variables which are floating point numbers
(reals). The aritmetic operations of addition,
subtraction, and multiplication are denoted by +,-,
and *, regardless of whether integers or reals are
involved. Division requires a little care. Division
of a real number by a real number or integer is handled
with slash (/). Division of integers requires two
special operations, denoted as div and
mod.
A div B stands for the quotient of A divided by B;
A mod B stands for the remainder when A is divided by
B.
Much of the computation in a program is handled by means of loops, sequences of instructions that are executed repeatedly.
In Pascal there are a variety of loops. The simplest is the FOR loop. It has the structure:
FOR i:=1 TO n DO
instructions;.
If there is more than one instruction then they must be enclosed between BEGIN and END statements.
The most frequent error in Pascal programming is losing track of BEGIN and END statements. It is good practice to always create the corresponding END statement when you create a BEGIN statement. For easier reading of the programs the BEGIN and END statements should be lined up.
Pascal is not case sensitive so BEGIN can be written as Begin, begin or any other variation. You can use this to keep the BEGIN and END statements matched up.
Another important instruction is the IF statement. It can have the structure:
IF (condition) THEN instruction1 ELSE instruction2;
Usually for readability it is written on several lines. The ELSE
clause is optional. If there is an ELSE clause then there should be no semicolon after instruction1.
Pascal has no instruction for exponentiation. One has to create the exponential out of other instructions.
Subprograms can be created in Pascal. They are called Procedures. A procedure takes parameters. In the specification of the parameters their types must be given. If the parameters are to be modified by the procedure they must be proceded by the term VAR.
Pascal has a data type called ARRAY. To indicate that a variable x is a vector of reals or M is a matrix of integers one uses
x:ARRAY[1..n] OF real;
M[1..m,1..n] OF integer;
Economics 196e
Programming problems
- 1. Write a Pascal program which will take an input of an integer n from the keyboard and compute the sum of the integers from 1 to n. Output the result as an integer.
(a) Modify the program to take two integers n and m from the KB and compute the sum of the integers from n to m.
(b) Modify the program to compute the sum of the odd integers from n to m.
- 2. Write a program to compute factorial(n), denoted as n!. Take the input of n from the KB and write out the result as
" (n)! = ".
(a) the product of all the odd integers from 1 to n is denoted as n!!. Modify your program for n! to compute n!!.
- 3. Write a program to compute x to the nth power, x is a real and n is an integer.
- 4. Write a program to solve the following simple macroeconomic model:
Y = C + I + G + X - M
C = a + bYD
YD = Y - NT
NT = -c + tY
M = m + nY,
where I,G, and X are to be provided from the KB.
- 5. Program the solution of a quadratic equation.
ax2 + bx + c = 0.
Take into account the possibility that a=0, and b=0.
- 6. Write a program that will take the parameters of supply and demand functions and give the market price and quantity.
- 7. Work out an algorithm for a computer to determine the maximum of two numbers.
- 8. Work out the algorithm for determining the price which would be charged by a monopolist given the demand function for the market and a cubic total cost function.
Econ 196e Spread Sheeets
Spreadsheets, along with word processors, are the most useful types of software for the general user.
This is an application of Excel to microeconomics. It involves computing revenue, costs, and profit as functions of output.
- 1. In row 3 create labels in columns for OUTPUT, PRICE, REVENUE,
COST, PROFIT, TAX, and AFTER TAX PROFIT.
- 2. In column A, under output, enter a 0 in row 4. In cell A5 enter
the formula =A4+10. Copy this formula into A6..A20.
- 3. In column B in row 4, under price, enter 10 (for $10). In cell B5
enter the formula =B4-0.2. Copy to B6..B20. This says that in order to
increase the sales by 10 units the price must decrease by $0.20.
- 4. In column C in row 4 enter the formula =A4*B4; i.e., revenue is
equal to price times quantity. Copy to C5..C20.
- 5. It is assumed that cost is fixed cost plus marginal variable cost
times output. In D4 enter the formula =50+5*A4. Copy to D5..D20.
- 6. Profit is revenue minus cost. Into cell E4 enter the formula =C4-D4. Copy to E5..E20.
- 7. Find the maximum profit using the MAX function. Into cell E22 enter
the formula MAX(E4..E20).
- 8. The profit calculated is before tax profit. Assume there is a 40
percent profit tax. Into F4 enter the formula =0.4*E4.
Copy into F5..F20.
- 9. Deduct tax from before tax profit to get after tax profit; i.e.,
into G4 enter =E4-F4 and copy to G5..G20. Find the maximum after tax profit.
-
1. Determination of the maximum profit and
the maximum profit output
level for a firm in different types of markets.
Determination of maximum
profit output as a function of parameters such
as price in a perfectly
competitive market or fixed cost.
- 2. Determining macroeconomic equilibria using
iteration.
- First Model:
- GNPt = Ct + It
+ Gt +
Xt - Mt
- DYt = GNPt - NTt
- NTt = -c + dGNPt
- Ct = a + b(DYt-1)
- It = I0,
- Gt = G0,
- Xt = X0
- Mt = m + nGNPt-1
- Second Model: same as the first except that
It = e + f(GNPt-1 - GNPt-2)
- 3. Determination of the Fibonacci numbers
Nt = Nt-1 + Nt-2 , N0
= 0, N1 = 1.
Computation of (( 5 + 1)/2)t + (( 5 - 1)/2)t.
- 4. Computation of the payment required to pay off a loan in a specified
number of periods.
- L = amount of the loan,
- r= interest rate per year,
- N = number of years of the loan,
- m = number of payments
per year,
- P= required payment,
- A= annuity factor.
- P/(1+r/m) + P/(1+r/m)2 + ... + P/(1+r/m)Nm = L
- P(1/(1+r/m) + 1/(1+r/m)2 + ... + 1/(1+r/m)Nm) = L
so P = L/A where
- A = 1/(1+r/m) + 1/(1+r/m)2 + ... + 1/(1+r/m)Nm.
- 5. Compute production as a function of the labor and capital inputs
using:
- 6. Simulate a random walk of stock prices
- 1. The additive model Pt = Pt-1 +
ut
where u is a random variable..
- 2. The multiplicative model Pt =
Pt-1(1+rt)
where r is a random variable.
- 7. Determination of equilibrium price from supply and demand
functions.
In Excel we will not be able to determine the price p
such that D(p)=S(p). Instead we will have to look for a
price at which the excess demand switches from positive to
negative.
FrontPage
To use FrontPage:
- Click on START and scroll up to PROGRAMS.
- Drag the cursor to the right and down to
Microsoft FrontPage and double click.
- Choose CREATE NEW FRONTPAGE WEB.
- Choose ONE PAGE WEB.
- Choose NEW and create the WEB in
C:\econ196e.
- From here you have many options. For example,
you can choose NORMAL and then INSERT from the
toolbar.
Microsoft Access