# Dowling02.wxmx: Plots & Eqns. in Economics

load(draw)$  set_draw_defaults(line_width=2, grid = [2,2], point_type = filled_circle,
          head_type = 'nofilled, head_angle = 20, head_length = 0.5,
             background_color = light_gray,  draw_realpart=false)$   
  fpprintprec : 5$  ratprint : false$        

## Preface

Dowling02.wxmx is one of a number of wxMaxima files available in the section "Economic 
Analysis with Maxima" on my CSULB webpage. 

In Dowling02.wxmx, we use Maxima to discuss some simple models in Economics, based mainly
on  Ch. 2 of the supplemental text: Introduction to  Mathematical Economics, 3rd ed, (Schaum's 
Outline Series), by Edward T. Dowling (1992, 2001), McGraw-Hill.
 
This modestly priced text is a bargain with many worked out examples. You should compare the 
examples worked out "by hand" in this text with what we do using Maxima. 

We have changed some of the symbols used in particular problems.

An approximate pdf translation (using Microsoft print to pdf) is available as Dowling02fit.pdf. 
That pdf file can be searched using Ctrl-F.

Ted Woollett
https://home.csulb.edu/~woollett/
woollett@charter.net
April 21, 2022

## References

Introduction to  Mathematical Economics, 3rd ed, (Schaum's Outline Series), 
by Edward T. Dowling (1992, 2001), McGraw-Hill,

Introductory Mathematical Economics, 2nd ed., D. Wade Hands, 2004, Oxford Univ. Press.

Mathematical Economics, 2nd. ed., Jeffrey Baldani, James Bradfield, and Robert W. 
Turner, 2005, Thomson.

Macroeconomics, 5th ed., Olivier Blanchard, 2011, Prentice Hall.

Fundamental Methods of Mathematical Economics, 4th ed., Alpha C. Chiang and Kevin Wainwright,
2005, McGraw Hill.

(IEA) Introduction to Economic Analysis, R. Preston McAfee, Tracy Lewis, Donald J. Dale, 2009,
read on web:   https://saylordotorg.github.io/text_introduction-to-economic-analysis/
get pdf:  https://mcafee.cc/Papers/Introecon/ieav21.pdf

## Isocost Lines 

An isocost line represents the different combinations of two inputs or factors of production that  
can be purchased with a given expenditure. The word isocost means "constant cost" or budget.

In a context of purchasing units of capital K and units of labor L, given an available budget E 
(expenditure), we assume the budget constraint can be expressed in the form:
              pk*K + pl * L = E, 
where K and L are respectively units of capital and units of labor, pk and pl their respective per unit 
prices, and E the amount allotted to expenditures (budget). We can assume the prices pk and pl
are both positive.
 
In isocost analysis, the individual prices and the expenditure (also positive) are initially held 
constant; only the different combinations of inputs (K, L) are allowed to change. The constraint
can then be graphed by expressing one variable in terms of the other, as seen in the following 
example and Problems 2.5 and 2.6.

As an example, solve for K in terms of L holding the prices constant:

eqn : pk*K + pl*L = E$
soln : solve (eqn, K);

Now express this in the canonical straight line form y = m*x + b, with K on the vertical y-axis, 
L on the horizontal x-axis by expanding the right hand side:

soln, expand;

When L = 0, K = E/pk (all the expenditure goes for capital which is the "y intercept" b in the
equation y = m*x + b, and the maximum value of K.

The slope (rise over run) is m = - pl/pk. As L increases, the number of units of capital K
decreases in a straight line (an isocost line). If we compare the effects of two different 
expenditures E (keeping pl and pk constant), we get two parallel straight lines lines (same slope).

### Prob. 2.5

Prob. 2.5 
A person has $120 to spend on two goods (X, Y) whose respective prices are $3 and $5. 
(a)  Draw a budget line showing all the different combinations of the two goods that can be 
bought  with the given budget (B). What happens to the original budget line (b) if the budget 
falls by  25 percent, (c) if the price of X doubles, (d) if the price of Y falls to 4? 

a.)  With B = 120, px = 3, py = 5, 120 = 3*x + 5*y. When x = 0, y = ymax = 120/5 = 24. When
y = 0, x = xmax  = 120/3 = 40.

soln : solve (3*x + 5*y = 120, y);

ys : expand (rhs (soln[1]));

wxdraw2d (xlabel = "x", ylabel = "y", title = " (a.)  B = 120, px = 3, py = 5",
    yrange  = [0, 30], xrange = [0, 50], explicit (ys, x, 0, 40))$

b.)  What happens to this budget line when the budget is reduced by 25%?
First find the reduced budget Br, assuming  Br is a 25% reduction from 120.

soln : solve ( (120 - Br)/120 = 0.25, Br);

Br : at (Br, soln);

We have the same per unit prices, so with the reduced budget we have
  90 = 3*x + 5*y. When y = 0, x = xmax = 90/3 = 30. When x = 0, y = ymax = 90/5 = 18.
Let ysr be the solution for 'y' in case b.

soln : solve (3*x + 5*y = 90, y);

ysr : expand (rhs (soln[1]));

wxdraw2d (xlabel = "x", ylabel = "y", title = " (b.)  25% reduction in budget",
   yrange  = [0, 30], xrange = [0, 50], 
    key = "B = 120, px = 3, py = 5",  explicit (ys, x, 0, 40),
    color = red, key = "B = 90, px = 3, py = 5", explicit (ysr,x, 0, 30))$

With a reduced budget, less units of both x and y can be purchased, but the slope
(rise over run) of the budget line remains the same.

c.)  The budget remains B = 120, the price of x doubles from 3 to 6, the price of y remains
at py = 5, so 120 = 6*x + 5*y. When y = 0, x = xmax = 120/6 = 20. When x = 0, y = ymax = 120/5
= 24. Let the solution for y(x) be called syc.

soln : solve (120 = 6*x + 5*y, y);

syc : expand (rhs (soln[1]));

wxdraw2d (xlabel = "x", ylabel = "y", key = "B = 120, px = 3, py = 5",
    title = " (c.)  price of x doubles",
    yrange  = [0, 30], xrange = [0, 50], explicit (ys, x, 0, 40),
    color = red, key = "B = 120, px = 6, py = 5", explicit (syc,x, 0, 20),
    line_width = 1, color = black, key = "y = 15", explicit (15, x, 0, 15))$

Less units of x can be purchased for a given number of units of y purchased.

d.) The price of y falls to 4, with B and px remaining at 120 & 3 respectively, to
120 = 3*x + 4*y.  When x = 0, y = ymax = 120/4 = 30. When y = 0, x = xmax = 120/3 = 40. 
Let syd be y(x) in case (d).

soln : solve (120 = 3*x + 4*y, y);

syd : expand (rhs (soln[1]));

wxdraw2d (xlabel = "x", ylabel = "y", key = "B = 120, px = 3, py = 5",
    title = " (d.)  price per unit of y falls to 4 ",
    yrange  = [0, 40], xrange = [0, 50], explicit (ys, x, 0, 40),
    color = red, key = "B = 120, px = 3, py = 4", explicit (syd,x, 0, 40), color = black,
    line_width = 1, key = " x = 10", parametric (10, yy, yy, 0, 90/4))$

More units of y can be purchased for a given number of units of x.

## Production Possibilities Curves (PPC)

We adapt the example in Hammock and Wilson, Ch. 2, Sec. 1.

Rather than relate the goods x and y to prices per unit and an overall budget, as in the above
section, we consider a nonlinear relation between x and y given by:

        y = a  - b*x^2.5,

where we assume a > 0, b > 0, so the more units of good x produced, the less units of good y
can be produced by a given economy. The constants a and b reflect the production abilities of
the economy, including employment of labor and capital and the level of technology available.

Of course we assume both x and y are greater than or equal to zero.

ymodel : a - b*x^2.5;
casea : [a = 500, b = 0.01];
ya : at (ymodel, casea);

When y = 0, x = xmax. We can get an approximate value for xmax with a simple plot.

xm : 100$
wxdraw2d ( explicit (ya, x, 0, xm), color = black,
    explicit (0, x, 0, xm))$

The value of xmax is between 70 and 80. A purely numerical search for the location at which
ya is zero is provided by Maxima's find_root (expr, var, v1, v2) function, in which v1 and v2
must straddle the location of the root.

xma : find_root ( ya, x, 70, 80);

at (ya, x = xma);

An analytic solution to the equation ya = 0, or 0 = a - b*x^2.5 = a - b*x^(5/2), or x^(5/2) = a/b, 
is x = (a/b)^(2/5)

at (a/b, casea);

%^(2/5);

When x = 0, x^2.5 = 0 and y = a = 500.

0^2.5;

A simple plot for casea.

print (" a = 500, b = 0.01, y = a - b^(2/5)")$
wxdraw2d (xlabel ="x", ylabel = "y", xrange = [0,90], yrange = [0, 600],
    explicit (ya, x, 0, xma))$

xma;

Define two values of x, (x1 and x2), and a small change in x, (dx).

[x1, x2, dx] : xma/[5, 2, 20];

Let f(x) be a Maxima function whose x dependence is the same as that of the Maxima expression
ya. We need to place two single quotes (') in front of ya to define f(x).

f(x) := ''ya;

We can then define y1 = f(x1), y1d = f(x1+dx), etc. We then display the results in table form
using the Maxima matrix function.

[y1, y1d] : [f(x1), f(x1 + dx)]$
[y2, y2d] : [f(x2), f(x2 + dx)]$
matrix (["1st initial x", "2nd initial x", "change in x"], [x1, x2, dx],
["initial y", "post change y", "change in y"], [y1, y1d, y1d - y1],[y2, y2d, y2d - y2]);

We can show these four points on our plot using the points(xL,yL) function

print (" a = 500, b = 0.01, y = a - b^(2/5)")$
print ("x1 = ", x1, "  x2 = ", x2, "  dx = ", dx)$
wxdraw2d (xlabel ="x", ylabel = "y", xrange = [0,90], yrange = [0, 600],
    explicit (ya, x, 0, xma), color = black, points([x1,x1+dx,x2, x2+dx],[y1,y1d,y2,y2d]))$

### Opportunity Cost

More good x can be produced only at the cost of less units of good y and vice versa.

Let oc1 be the opportunity cost in increasing production of good x by dx, starting with production
level x1; that is the magnitude of the decrease in units of good y, with a similar definition for oc2.

[oc1, oc2] : - [y1d - y1, y2d - y2]/dx$
matrix (["Opportunity Cost at x1", "Opportunity cost at x2" ],
            [ oc1, oc2 ]);

An opportunity cost function oca(x) for casea can be defined, again using two single quote marks
(') in front of -diff(ya,x), which is the opportunity cost per unit increase of production of good x.

oca(x) := '' (- diff (ya, x));

[oc1, oc2 ] : [oca(x1), oca(x2)];

Here we plot both oca(x) and the points (x1,oc1), (x2,oc2).

wxdraw2d (xlabel ="initial x", ylabel = "oc(x)", xrange = [0,90], yrange = [0, 20],
    title  = "Opportunity Costs: Function and Points",
    explicit (oca, x, 0, xma), color = black, points ([x1,x2], [oc1, oc2]))$

The rising curve shows increasing opportunity costs as the initial x increases.

### Shifting PPC

An increase in resources (capital and/or labor) and improved technology can shift the
Production Possibilities Curve outward (more units of y for a given number of units of x). Here
is an example we call caseb.

If we consider case (b) to have the same value of a = 500, but the parameter b = 0.75*10^(-2), 

caseb : [a = 500, b = 7.5e-3];
yb : at (ymodel, caseb);

wxdraw2d (explicit (yb,x,0,100), color = black, explicit (0,x,0,100))$

xmb : find_root (yb, x, 80,90);

fb(x) := ''yb;

print ("           y = 500 - b^(2/5)")$
wxdraw2d (xlabel ="x", ylabel = "y", xrange = [0,90], yrange = [0, 600],
    title = " Shifting the PPC Outward with Smaller Parameter b",
  key = "b = 0.01",  explicit (ya, x, 0, xma), color = red, 
    key = "b = 0.0075", explicit (yb, x, 0, xmb), color = black, line_width = 1,
  key = "",  parametric (70, yy, yy, 0, fb(70)))$

The magnitude of the slope of the outward shifted PPC (in red) is smaller than that of casea.
The vertical line at x = 70 shows yb(70 > ya(70).

[f(70), fb(70)];

## Supply and Demand Analysis [2.2]

### Demand and Supply Notation: Qd, Qs, Pd, Ps

The "market demand curve" can be specified in two equivalent ways:
1.) Qd = quantity (number of units per unit time period) demanded by buyers as a function of 
the per unit price p,
2.)  Pd = the per unit price ($) buyers are willing and able to pay as a function of the number of
units supplied  per unit time period q.

For example if Qd = a*p^b, where a and b are parameters and p is price, then Pd = (q/a)^(1/b).
Pd is called the "inverse demand curve".

The "market supply curve" can likewise be specified in two equivalent ways:
1.) Qs = the quantity (the number of units per unit time period) producers are willing and able 
to supply as a function of the per unit price p.
2.)  Ps = the per unit price at which producers are willing to supply a given quantity of units per
unit time period q.

For example if Qs = b + c*p, where b and c are parameters and p is price, then  Ps = (q-b)/c.
Ps is called the "inverse supply curve".

Equilibrium in supply and demand analysis occurs when Qs = Qd (or Ps = Pd). By equating the 
supply and  demand functions, the equilibrium price and quantity can be determined. 
See Example 2 and Problems  2.1 to 2.4 and 2.11 to 2.16.

### What is a Demand Curve?

Quoting IEA, Sec. 2.1:

"Eating a French fry makes most people a little bit happier, and we are willing to give up something 
of value – a small amount of money, a little bit of time – to eat one. What we are willing to give up 
measures the value – our personal value – of the French fry."
 
"That value, expressed in dollars, is the willingness to pay for French fries. That is, if you are willing 
to give up three cents for a single French fry, your willingness to pay is three cents. If you pay a 
penny for the French fry, you’ve obtained a net of two cents in value." 

"Those two cents – the difference between your willingness to pay and the amount you do pay – 
is known as consumer surplus. Consumer surplus is the value to a consumer of consumption of 
a good, minus the price paid."

"..., an order of French fries might be worth $3 to a consumer, but because French fries are 
available for around $1, the consumer obtains a surplus of $2 in the purchase."

"How much is a second order of French fries worth? For most of us, that first order is worth more 
than the second one. If a second order is worth $2, we would still gain from buying it. Eating a 
third order of fries is worth less still, and at some point we’re unable or unwilling to eat any more 
fries even when they are free, which implies that at some point the value of additional French 
fries is zero."

"Many, but not all, goods have this feature of diminishing marginal value - the value of the last unit
consumed declines as the number consumed increases."

The marginal value function v(q) is the same as what we call the inverse demand function Pd(q).

qmax : 10$
wxdraw2d (xlabel = "quantity q", ylabel = "v(q)", yrange = [0, 6],   key_pos  = top_center,
    title = " A Demand Curve, v(q) = marginal value of quantity q",
    key = "v(q) = (10 - q)/2", explicit ((10 - q)/2, q, 0,qmax),  color = red,
    line_width = 1, key = " p = per unit price =  $3 = v(4)",  explicit (3, q, 0, 4), 
    key = "q0 = 4", color = brown, parametric (4, yy, yy, 0, 3), color = black, 
    key = "quantity demanded = 4 units ", points ([ [4, 3]]), 
    key = "", label (["p", 0.15, 2.85], ["q0", 3.8, 0.3] ))$

Again quoting IEA:
"...given the value p on the vertical axis, the corresponding q0 on the horizontal axis is the quantity
the consumer will purchase."

"It is often important to distinguish the demand curve itself – the entire relationship between price 
and quantity demanded – from the quantity demanded. Typically, “demand” refers to the entire 
curve, while “quantity demanded” is a point on the curve." 

"Given a price p, a consumer will buy those units with v(q) > p, since those units are worth more
than they cost. Similarly, a consumer should not buy units for which v(q) < p . Thus the quantity q0
that solves the equation v(q0) = p gives the quantity of units the consumer will buy."

### What is a Supply Curve?

From IEA Sec. 2.2:
"The supply curve gives the number of units, represented on the horizontal axis, as a function of 
the price on the vertical axis, which will be supplied for sale to the market."

"...Generally supply is upward sloping, because if it is a good deal for a seller to sell 50 units of a 
product at a price of $10 [per unit], then it remains a good deal [for the seller] to supply those 
same 50 [units] at a price of $11 [per unit]. The seller might choose to sell more than 50, 
but if the first 50 weren’t worth keeping at a price of $10, that remains true at $11.4."

The seller who has a cost c(q) for selling q units obtains a profit π, at price p per unit, of
 π =   p*q - c(q),  which is just revenue to seller minus cost to seller.
 
The quantity q which maximizes profit π for the seller is the quantity q satisfying the equation
 ∂π/∂q = 0,  or  p - ∂c(q)/∂q = 0, or p = c'(q). The first derivative of the cost function, c'(q), is the
 "marginal cost" to the seller (by definition). The (inverse) supply curve Ps(q) is thus the seller's 
marginal cost function c'(q). Every point (q,p) on the supply curve returns the maximum profit
attainable by the seller at that number of units q. The total cost of producing q units is the sum of
the small marginal costs Ps(q)*dq = c'(q)*dq from q = 0 to q = qfinal which is the definite integral
integrate (dc(x)/dx, x , 0, qfinal) = c(qfinal) - c(0) = c(qfinal), since the cost of producing zero units
is zero. Thus the cost of producing qf units is the area under the supply curve from q = 0 to qf.

The revenue from selling qf units at a price per unit p  is p*qf, and the profit from selling qf units 
at a price per unit p is profit = revenue - cost = p*qf - c(qf). The quantity p*qf is a rectangle and
c(qf) is the area under the supply curve, so profit is the area inside the rectangle and above the
supply curve. The profit is also called the "producer surplus".

Here is an example of an upward sloping nonlinear supply curve given by the equation
Ps(q) = 0.16*q^2 + 2. The cost of producing 5 units is the area under the curve from q = 0 to
q = 5.

Ps : 0.16*q^2 + 2;
p0 : at (Ps, q = 5);
Revenue : p0*5;
Cost : integrate(Ps, q, 0, 5), numer;
Profit : Revenue - Cost;

qmax : 6$
wxdraw2d (xlabel = "q", ylabel = "p",yrange = [0,12], key_pos = top_left,
    title = "A Supply Curve", color = red,
 key = "Ps(q) =  0.16*q^2 + 2",  explicit (Ps, q, 0, qmax), 
    color = blue,  line_width  = 1, key = "p = 6", explicit (6, q, 0, 5),
  key = "q0 = 5", color = brown,   parametric (5,yy, yy, 0, 6), 
  color = black,  key = "quantity supplied",   points ([ [5, 6] ]),
    label ( ["p", 0.15, 5.75], ["q0", 4.75, 0.45], ["PROFIT = 'Producer Surplus'", 2, 5],
        ["COST = c(q0)", 3, 1.5] ))$

"Anything that increases costs of production will tend to increase marginal cost and thus reduce 
the supply. For example, as wages rise, the supply of goods and services is reduced, because 
wages are the input price of labor. Labor accounts for about two-thirds of all input costs, and thus 
wage increases create supply reductions (a higher price is necessary to provide the same 
quantity) for most goods and services."
 
"Costs of materials of course increase the price of goods using those materials. For example, 
the most important input into the manufacture of gasoline is crude oil, and an increase of $1 in the 
price of a 42 gallon barrel of oil increases the price of gasoline about two cents – almost 
one-for-one by volume."
 
"Another significant input in many industries is capital, and as we will see, interest is cost of 
capital. Thus, increases in interest rates increase the cost of production, and thus tend to 
decrease the supply of goods."

### Example 2: Numerical Linear Demand Curve

An example in which both the demand and supply functions are linear is Qd = 10 - 2*p and 
Qs = - 5 + 3*p. The solution to Qd = Qs is the per unit equilibrium price p = $3/unit, and equilibrium
quantity q = 4 units.

Qs : -5 + 3*p;
Qd : 10 - 2*p;
soln : solve (Qs = Qd, p);

soln : soln[1];

qs : at (Qs, soln);

ps : at (p, soln);

For historical reasons, in Economics the per unit price p is placed on the vertical axis and the 
quantity  q is placed on the horizontal axis. To make such a plot using draw2d's explicit function we 
need the inverse demand function Pd(q) to draw the demand curve and we need the inverse 
supply function Ps(q) to draw the supply curve.

An alternative is to use the draw2d function implicit. Here is an example of using the implicit 
function, which has the syntax: implicit (f(x,y), x, x1, x2, y, y1, y2), and which attempts to draw 
curves such that f(x,y) = 0. The three quantities (x, x1, x2) refer to the horizontal axis.

qmax : 10$
wxdraw2d (xlabel = "quantity q", ylabel = "price per unit p", yrange = [0, 6],   key_pos  = top_center,
    title = "  Supply Demand Plot using implicit",
    key = "Qd = 10 - 2*p", implicit (q - 10 + 2*p, q, 0, qmax, p, 0, 5), 
    color = red, key = "Qs = -5 + 3*p", implicit (q + 5 - 3*p, q, 0, qmax, p, 0, 5),
    key = "", color = black, line_width = 1, explicit (ps, q, 0, qs), parametric (qs, yy, yy, 0, ps ))$

The alternative to using implicit is to use the inverse demand and supply curves, which for this
example are the per unit prices  Ps = (q+5)/3 and Pd = (10-q)/2 as a function of quantity q.

qmax : 10$
wxdraw2d (xlabel = "quantity q", ylabel = "price per unit p", yrange = [0, 6],   key_pos  = top_center,
    title = "  Supply - Demand Plot using explicit",
    key = "Qd = 10 - 2*p", explicit ((10 - q)/2, q, 0,qmax), 
    color = red, key = "Qs = -5 + 3*p",  explicit ((q + 5)/3, q, 0, qmax),
    key = "", color = black, line_width = 1, explicit (ps, q, 0, qs), parametric (qs, yy, yy, 0, ps ))$

### Numerical  Nonlinear Demand Curve Example

We consider an example from Hammock & Mixon, Ch.2, in which Qd = 1200/p^(5/2) and
Qs = - 5 + 10*p. For p close to zero, Qd becomes arbitrarily large, so we want to stay away
from the point p = 0. This model of Qd is unrealistic for small p.

### Graphical Exploration

We first map Qd onto a list of prices. To do this, one way is to first define fQd
as a formal Maxima function:

Qd is here defined as a Maxima expression depending on the parameter p.

Qd : 1200/p^(5/2);

Placing two single quotes (') in front of Qd allows the following method of defining a Maxima function
fQd(p).

fQd(p) :=  ''Qd;

Let pL be a list of prices.

pL : makelist (j, j, 1, 20);

QdL : map ('fQd, pL), numer;

wxdraw2d (xlabel = "p", ylabel = "Qd", xrange = [0,30],  yrange = [0, 100], points(pL, QdL))$

Qs : -5 + 10*p;

fQs(p) := ''Qs;

QsL : map ('fQs, pL);

wxdraw2d (xlabel = "p", ylabel = "Qs", xrange = [0, 30],   yrange = [0, 200], 
    color = red, points(pL, QsL))$

We first make a crude plot to locate the region where Qd = Qs.

wxdraw2d (xlabel = "p", ylabel = "q", yrange = [0,300],   key = "Qd", points(pL, QdL),
    color = red, key = "Qs", points (pL, QsL))$

We see that Qd = Qs at about p = 4. Now that we know the p region in which to look, we
make a plot over a small region of p.

wxdraw2d(xlabel = "p", ylabel = "q", yrange = [20, 70], key = "Qd",
    explicit (Qd, p, 3, 5), color = red, key = "Qs", explicit (Qs, p, 3, 5))$

We need to use find_root (f(x), x, x1, x2) to locate the root of the nonlinear equation
Qd - Qs = 0.

ps : find_root (Qd - Qs, p, 4, 4.3);

qs : at (Qs, p = ps);

So the equilibrium solution implies a per unit price p ~ 4.1 and q ~35.8 units per unit time period.

### Plot Using Inverse Demand and Supply Curves

With Qd = 1200/p^5/2, we get Pd = (1200/q)^(2/5). With Qs = -5 + 10*p, we get Ps = (q+5)/10.
We make a plot with prices ($ per unit) on the vertical axis and Quantity (units per unit time period)
on the horizontal axis.

Pd : (1200/q)^(2/5);

at (Pd, q = qs), numer;

wxdraw2d (xlabel = "Quantity: units per unit time period", ylabel = "$ per unit",
    yrange = [3.5, 4.6],
    key = "Pd", explicit ( Pd, q, 34, 37), color = red, key = "Ps",
    explicit ( (q + 5)/10, q, 34, 37 ),key = "", color = black, line_width = 1,
    explicit (ps, q, 34, qs), parametric (qs,yy,yy, 3.5, ps))$

With the equilibrium quantity qs ~ 35.76 units per unit time period, for q > qs the supply curve Qs lies
*above* the demand curve Qd (in a plot with price on the vertical axis and quantity on the horizontal
axis). The price per unit that producers would have to be paid in order to produce a quantity q > qs 
exceeds the price per unit that buyers are willing and able to pay for that  quantity.

For q < qs, the demand curve lies above the supply curve. 

### Prob. 2.1, 2.2, 2.3

Prob 2.1.
 A complete demand function is given by the equation  
                   Qd = - 30*p + 0.05*Y + 2*pr + 4*T  
where p is the per unit price of the good, Y is income, T is taste, and pr is the price of a related good.
The variable pr appears with a positive coefficient, which means if the price of the related good
increases, the quantity of the original good demanded increases. This means the original good
and the related good are "substitute goods" (think of Pepsi and Diet Coke).  

If the coefficient of pr is a negative number, a rise in price of the related good results in a decrease
in demand of the original good. This is an example of a "complementary good" (think rice and beans)
since demand for both goods rise and fall together.

Qd is the dependent variable. The other variables are independent variables. Can this function 
be graphed?  

Since the complete function contains four different independent variables (p, Y, pr, T), it cannot 
be graphed as is. In ordinary demand analysis, however, it is assumed that all the independent 
variables except price are held constant, so that the effect of a change in price on the quantity 
demanded can be measured under constant Y, pr, and T conditions. If the variables Y, pr, and T 
are held constant, then we can plot Qd vs. p, or Pd vs. q.

Prob 2.2 + 2.3
(a) Draw the graph for the demand function in Problem 2.1, assuming Y = 5000, pr = 25, and  T = 30. 
(b) What does the typical demand function drawn in part (a) show? 
(c) What happens to the graph if the price per unit of the good changes from 5 to 6? 
(d) What happens if any of the other variables change? For example, if income increases to 7400?  

a) We first define the demand function model as the expression Qs_gen.

Qd_gen : -30*p + 0.05*Y + 2*pr + 4*T;

The parameter values for case a are contained in the list case_a.

case_a : [ Y = 5000, pr = 25, T = 30 ];

Let Qd_a be the demand function expression for case a.

Qd_a : at (Qd_gen, case_a);

When Q = 0, p = 420/30 = 14, the maximum price per unit. When p = 0, Q = 420, the maximum 
quantity.

420/30;

psoln : solve (q = Qd_a, p);

Let Pd_a be the inverse demand curve depending on quantity q.

Pd_a : expand (rhs (psoln[1]));

qmax : 500$
wxdraw2d ( xlabel = "q", ylabel = "p", yrange = [0, 16], 
    title = "Case a: Y = 5000, pr = 25, T = 30",
    key = " inverse demand function Pd ", explicit (Pd_a, q, 0, qmax))$

b) What does the typical demand function drawn in part (a) show? 

The demand function graphed in part (a) shows all the different quantities of the good that will be  
demanded at different prices, assuming a given level of income, taste, and price of substitutes 
(here  5000, 30, 25) which are not allowed to change. 

c) What happens to the graph if the price per unit of the good changes from 5 to 6? 
 
If nothing changes but the price of the good, the graph remains exactly the same since the graph  
indicates the different quantities that will be demanded at all the possible prices. A simple change 
in  the price of the good occasions a movement along the curve which is called a "change in quantity  
demanded."  When the price goes from 5 to 6, the quantity demanded falls from 270 to  240 ),
 a movement from A to B on the curve. A = ( Q = 270, p = 5)  →  B = ( Q = 240, p = 6).

q5 : at(Qd_a, p = 5);

q6 : at (Qd_a, p = 6);

qmax : 500$
wxdraw2d ( xlabel = "q", ylabel = "p", yrange = [0, 16], 
    title = "Case a: Y = 5000, pr = 25, T = 30",
    key = " inverse demand function Pd ", explicit (Pd_a, q, 0, qmax), color = black,
    key = "", points([ [270, 5], [240, 6] ]), label ( ["A", q5, 6] ) , label ( ["B", q6, 7] ),
    line_width = 1, explicit (5, q, 0, q5), parametric (q5, yy, yy, 0, 5), color = red,
    explicit (6, q, 0, q6), parametric (q6, yy, yy, 0, 6))$

(d) What happens if income increases to 7400?

If any of the other variables change, there will be a shift in the curve. This is called a 
"change in demand"  because it results in a totally new demand function (and curve) 
in response to the changed conditions.  If income increases to 7400, the new demand 
function becomes  Qd = -  30*p + 540, or Pd = -(q - 540)/30. This is graphed as a red line.

Call this case b.

case_b : subst (7400, 5000, case_a);

Qd_b : at (Qd_gen, case_b);

When p = 0, q = 540.

psoln : solve (q = Qd_b, p);

Let Pd_b be the inverse demand curve, depending on quantity q, for case b.

Pd_b : expand (rhs (psoln[1]));

When q = 0, p = 18.

If we compare the quantity demanded Qd in cases a and b for the price per unit fixed at p = 10.
Let qa and qb denote these quantities.

qa :  at (Qd_a, p = 10);

qb : at (Qd_b, p = 10);

The quantity demanded at p = 10 is doubled.

qmax : 550$
wxdraw2d ( xlabel = "q", ylabel = "p", yrange = [0, 20], 
    key = "Case a: Y = 5000, pr = 25, T = 30", explicit (Pd_a, q, 0, qmax),
    color = red,  key = "Case b: Y = 7400, pr = 25, T = 30", explicit (Pd_b, q, 0, qmax),
    color = black,
    key = "", points([ [270, 5], [240, 6] ]), label ( ["A", q5, 6] ) , label ( ["B", q6, 7] ),
    line_width = 1, explicit (5, q, 0, q5), parametric (q5, yy, yy, 0, 5), color = brown,
    explicit (10, q, 0, qb))$

With an increase in income Y the demand curve shift outward but maintains the same slope.

### Symbolic Linear Demand and Supply Analysis

We follow BBT, p. 3.
We assume a model in which the (inverse) demand and supply equations have the linear forms:
       Pd = a - b*q,  Ps = c + d*q,
in which a, b, c, and d are all greater than zero and a > c so that the equilibrium price will be given
by demand = supply, or Pd = Ps, which implies qs = (a - c)/(b + d) > 0, and ps  = (a*d+b*c)/(b+d).

Pd : a - b*q;
Ps : c + d*q;
soln : solve (Pd = Ps, q);

qs : rhs (soln[1]);

num(qs)/denom(qs);

Equilibrium quantity.

qs : %;

at (Pd, q = qs);

ratsimp(%);

Equilibrium price per unit.

ps : %;

We calculate the rate of change of qs and ps with a, ∂(qs)/∂a and ∂(ps)/∂a, holding b, c, and d
constant.

[diff(qs,a), diff(ps,a)];

The parameter a is the "demand intercept", the price when q = 0 (plotting p on the vertical axis and
q on the horizontal axis). We then see that an increase in the value of the demand intercept leads
 to an increase in both quantity and price (in general).

We next look at the effect of an increase in the parameter d, the slope of the supply curve, on qs
and ps by looking at the partial derivatives ∂(qs)/∂d and ∂(ps)/∂d, holding a,b, and c constant.

[diff (qs, d), diff (ps, d) ], ratsimp;

Since a > c, ∂(qs)/∂d < 0 and ∂(ps)/∂d > 0 in general. The change in the equilibrium price ps is in 
the same direction as the change in the parameter d and the change in the equilibrium quantity qs
is opposite in sign to the direction of change in d. Thus a decrease in the supply slope d will
lead to an increase in the equilibrium quantity qs but to a decline in equilibrium price ps.

Quoting Baldani, Bradfield, & Turner, p. 6:
"A decrease in the supply curve slope d might result from such factors as improved production
technology, lowered input prices, or entry of new firms into the industry, all of which increase the
the quantity supplied."

## Income Determination Models  [2.3]

We consider the market for goods in which consumers, investors, and the government all 
compete for goods. Equilibrium in that market for goods requires that the quantity of goods 
supplied (GNP), which is the national income Y, be equal to the aggregate demand for goods, 
which, (neglecting exports and imports) is C + I + G ( a three-sector economy).

Income determination models which include export and import express the equilibrium level 
of (national) income Y in a four-sector economy as (each component measured in dollars):

               Y = C + I + G + (X - Z)
  
where Y = national income (GDP), C = (personal) consumption of goods and services, 
 I = investment in the means for future production (such as purchase of upgraded technology), 
G = government expenditures on goods and services (but not social security or welfare),  
X = exports of nationally produced goods and services, and Z = imports of goods and services 
produced in other countries. 

By substituting the information supplied in the problem, it is an easy matter to solve for the 
equilibrium level of income Y. Aggregating (summing) the variables on the right allows the
equation of be graphed in a two-dimensional space. 

See Example 3 and Problems 2.7 to 2.10 and 2.17  to 2.22.

### Example 3

--------------------------------------------
Example 3 considers a "two sector economy" in which only consumption (C) and investment (I)
in the means of future production are taken into account.  

We assume   
              Y = C + I, 

with C = C0 + b*Y, where b is the "marginal propensity to consume" (MPC) and I = I0 = constant 
independent of Y.

Solving for Y gives
         Y = (C0 + I0)/ (1 - b)  =  (C0 + I0)/ (1 - MPC).

The marginal propensity to consume (MPC) is the proportion of an aggregate raise in pay that a 
consumer spends on the consumption of goods and services, as opposed to saving (and hence 
investing) it.

In general the definition of MPC is:
      MPC = dC/dY = (first derivative of consumption with respect to Y). 

C is called the "consumption function" and the sum C + I is the "aggregate demand function" D.

MPC is the key determinant of the "Keynesian multiplier", which describes the 
effect of increased investment or government spending as an economic stimulus.

A numerical example is: C0 = 85, b = 0.9, and I0 = 55. Then C0 + I0 = 140, 1/(1-b) = 10, 
Y = 1400, C = 85 + 0.9*1400 = 1260, and C/Y = 0.9.

C0 and I0 are "autonomous expenditures", since they are constant and are not affected by the 
size of the national income Y. The factor 1/(1-b)  is the "autonomous expenditure multiplier" which 
is a measure of the multiple effect of each dollar of autonomous spending on the equilibrium level 
of national income. Y is an "endogenous variable", and C0, I0, and b are "exogenous variables".

### Prob. 2.7

Assume Y = C + I, with C = 50 + 0.8*Y = "consumption function", and I = I0 = 50.

(a) Plot the consumption function

wxdraw2d ( key_pos = top_left, key = "C = 50 + 0.8*Y ", yrange = [0, 600],
    explicit (50 + 0.8*Y, Y, 0, 600),   ylabel = "C", xlabel = "Y",   grid = [2,2] );

(b) plot the "aggregate demand function" C + I0.

Ans: C + I0 = 100 + 0.8 Y is a line parallel (same slope) to the consumption function

wxdraw2d (  xlabel = "Y", yrange = [0, 600], key_pos = top_left, 
    key = "C = 50 + 0.8*Y ",  explicit (50 + 0.8*Y, Y, 0, 600),    color = red,
    key = "C + I0, I0 = 50",  explicit (100 + 0.8*Y, Y, 0, 600) );

(c)  A graphical method to find the equilibrium value of Y is to use equal units for Y on the 
horizontal axis and aggregate demand C + I0 on the vertical axis, and then draw a 45 deg line 
from the origin and locate its intersection with the aggregate demand (C + I0) line. Thus find 
Y = 500. 

We use the proportional_axes = xy option for such a "graphical solution".

wxdraw2d ( xlabel = "Y",   yrange = [0, 600],  key_pos = top_left, proportional_axes =  xy,
      key = "C = 50 + 0.8*Y ",  explicit (50 + 0.8*Y, Y, 0, 600), color = red,
     key = "C + I0, I0 = 50",  explicit (100 + 0.8*Y, Y, 0, 600), key = "", color = black, 
    line_type = dashes, explicit (Y, Y, 0, 600), point_size = 1.5,   points ([[500, 500]]),
     line_width = 1,  explicit (500,Y,0,500), parametric (500, t, t, 0, 500) ), wxplot_size = [480,480];

In comparison with the graphical solution (some work) is the painless algebraic solution:

solve (Y = 100 + 0.8*Y);

### Prob. 2.9 Lump Sum Tax Effect

Consider the effects of a lump sum tax T (a tax independent of income) on national income Y in a 
two sector economy Y = C + I, with C = C0 + b*Yd, Yd = disposable income = Y - T. 

Without the tax, Yd = Y, Y = C0 + b*Y + I0, Y = (C0+I0)/(1 - b) = D0/(1-b).
With the tax Yd = Y - T, Y = C0 + b*(Y - T) + I0 = D0 - b*T + b*Y, Yt = (D0 - B*T)/(1-b) < Y.

For a numerical example, with C0 = 100, b = 0.6, I0 = 40, T = 50, 1-b = 0.4, D0 = 140, b*T = 30.
Without tax Y = 140/0.4 = 350. With tax Y = (140 - 30)/0.4 = 110/0.4 = 275.  The effect of the
lump sum tax T = 50 causes Y to decrease from 350 to 275.

wxdraw2d ( xlabel = "Y", xrange = [0, 600],  yrange = [0, 600],  
    key_pos = top_left, proportional_axes =  xy,
      key = "C + I = 140 + 0.6*Y ",  explicit (140 + 0.6*Y, Y, 0, 600), color = red,
     key = "C + I = 110 + 0.6*Y",  explicit (110 + 0.6*Y, Y, 0, 600), key = "", color = black, 
    line_type = dashes, explicit (Y, Y, 0, 600), point_size = 1.5, points ( [275, 350], [275, 350] ),
line_width = 1, explicit (275, Y, 0, 275), parametric (275, yy, yy, 0, 275),
explicit (350, Y, 0, 350), parametric (350, yy, yy, 0, 350) ), wxplot_size = [480,480];

### Prob. 2.10: Effects on Y of a Proportional + Lump Sum Tax

Explain with the aid of a graph how the incorporation of a proportional tax (a tax depending on
income) influences the parameters of the income determination model.
1. Without the tax,  Y = C + I, C = 85 + 0.75*Y, I0 = 30, Aggregate demand D = C + I,
D = 115 + 0.75*Y, Y = 115/(1 - 0.75) = 460.

solve (Y = 85 + 0.75*Y + 30);

2. With the tax, C = 85 + 0.75*Yd, Yd = Y - T, T  = 20 + 0.2*Y, Yd = Y - 20 - 0.2*Y = 0.8*Y - 20,
C = 85  + 0.75*(0.8*Y - 20) = 70 + 0.6*Y, Y =  C + I0 = 100 + 0.6*Y, Y = 100/(1 - 0.6) = 250.

T : 20 + 0.2*Y;
Yd : Y - T;
I0 : 30;
C : 85 + 0.75*Yd;
solve (Y = C + I0);

wxdraw2d ( xlabel = "Y", xrange = [0, 600],  yrange = [0, 600],  
    key_pos = top_left, proportional_axes =  xy,
      key = "C + I = 115 + 0.75*Y ",  explicit (115 + 0.75*Y, Y, 0, 600), color = red,
     key = "C + I = 100 + 0.6*Y",  explicit (100 + 0.6*Y, Y, 0, 600), key = "", color = black, 
    line_type = dashes, explicit (Y, Y, 0, 600), point_size = 1.5, points ( [250, 460], [250, 460] ),
line_width = 1, explicit (250, Y, 0, 250), parametric (250, yy, yy, 0, 250),
explicit (460, Y, 0, 460), parametric (460, yy, yy, 0, 460) ), wxplot_size = [480,480];

Incorporation of the proportional tax  lowers the slope (MPC) of the C + I line from 0.75 to 0.6. The
vertical intercept is also lowered because the tax structure includes a lump-sum tax of 20.Because 
of the tax structure, the equilibrium level of national income falls from 460 to 250.

### Prob. 2.21

(a.)  Find the reduced form for the equilibrium income in terms of C0, I0, T0, b, and t if
Y = C + I, I = I0, C = C0 + b*Yd, Yd = Y - T, T = T0 + t*Y.

In Maxima, define these quantities in reverse order:

kill(I0)$
T : T0 + t*Y;
Yd : Y - T;
C : C0 + b*Yd;
soln : solve (Y = C + I0, Y);

Ye : rhs (soln[1]);

num(Ye)/denom(Ye);

Ye : %;

(b.)  Evaluate Ye for I0 = 30, C0 = 85, b = 0.75, t = 0.2,T0 = 20.

at (Ye, [I0 = 30, C0 = 85, b = 0.75, t = 0.2, T0 = 20]);

(c.)  The multiplier is changed from 1/(1 - b) to 1/(1 - b + b*t). This reduces the size of the multiplier
because it makes the denominator larger and the fraction smaller.

at (1/(1-b), b = 0.75);

at (1/ (1 - b + b*t), [b = 0.75, t = 0.2] );

### Prob 2.22 Income Determination Model with a Foreign Sector

Assume Y = C + I + G + (X - Z), with C = C0 + b*Y, Z = Z0 + z*Y = imports, I = I0, G = G0, X = 
exports = X0.
(a.) Find the reduced symbolic form for Y in terms of a multiplier.

 Z : Z0 + z*Y;
C : C0 + b*Y;
soln : solve ( Y = C + I0 + G0 + X0 - Z, Y);

Ye : rhs(soln[1]);

num(Ye)/denom(Ye);

Ye : %;

(b.) Consider the following numerical inputs and find Ye.

case : [I0 = 90, G0 = 65, X0 = 80, C0 = 70, Z0 = 40, b = 0.9, z = 0.15]$
at (Ye, case);

(c.) Compare the multiplier without and with the inclusion of an import term proportional to Y.

at(1/(1-b), case);
at (1/(1 - b + z), case);

Introduction of the "marginal propensity to import" z into the model reduces the size of the
multiplier, in this example from 10 to 4.

## IS-LM Analysis  [2.4]

The "IS schedule" is the locus of points representing all the different combinations of interest rates 
and  income levels consistent with equilibrium in the goods (commodity) market. Equilibrium
in the goods market demands that planned "investment" and planned "saving" be equal, which
is where "IS" comes from.

The "LM schedule" is the locus of points representing all the different combinations of interest rates 
and income levels consistent with equilibrium in the money market. The "L" stands for
"liquidity preference" (as the demand for money is sometimes known) and the "M" stands for
the quantity of money supplied.

IS-LM analysis seeks to find the level of income and the rate of interest at which both the 
commodity  market and the money market will be in equilibrium simultaneously. This can  be 
accomplished with the techniques used for solving simultaneous equations. 

Unlike the simple  income determination model in Section 2.3, IS-LM analysis deals explicitly with the 
interest rate (i) and  incorporates its effect into the model. See Example 4 and Problems 2.23 
and 2.24. 

The commodity market for a simple two-sector economy is in equilibrium when Y = C +  I. 
The  money market is in equilibrium when the supply of money (Ms) equals the demand 
for money (Md). 
 
The demand for money (Md) is composed of the transaction-precautionary demand for 
money (Mt ) and the speculative demand for  money (Mz ).  
        Md = Mt + Mz.

### Example 4, Numerical Example

Assume a two-sector economy where national income Y = C + I,  personal consumption 
C = 48 + 0.8 Y,  investment  I =  98 - 75i,  the supply of money is  Ms = 250,  the transaction-
precautionary demand for money is Mt =  0.3Y, and the speculative demand for money is
 Mz = 52 - 150 i.  We use i for the (decimal) interest rate on money, following Dowling's notation.

Commodity equilibrium (IS) exists when Y = C + I, or Y  - C - I = 0.

Monetary equilibrium (LM) exists when Ms = Md = Mt + Mz, or Ms - Mt - Mz = 0.

We can solve these two equations for Y and interest rate i.

kill(Y,i)$
C : 48 + 0.8*Y;
I : 98 - 75*i;
IS : Y - C - I;
Ms : 250;
Mt : 0.3*Y;
Mz : 52 - 150*i;
LM : Ms - Mt - Mz;
soln : solve ([IS, LM]);

soln : soln[1];

float (soln);

Check solution.

at ([C, I, C+I, Mt, Mz], soln), numer;

The commodity and money markets will thus be simultaneously in equilibrium when
 Y = 700 and i = 0.08.

### Solution for a Symbolic IS-LM Model

Assume four exogenous variables are three levels of autonomous spending C0, I0, and G0, and the
constant stock of money Ms. The four endogenous variables to be determined by the model
are Y, C, I, and r (decimal rate of interest).

The  four equations ( the first three equations clear the goods market, and the fourth equation 
clears the money market):
       Y = C + I + G0,
       C = C0 + a Y,
       I = I0 + e r,
       Ms = f Y - g r,
imply two simultaneous equations for unknowns (Y, r).

The solution for Y and r will depend on C0, I0, G0, and will be expressed in terms of the 
parameters f, g, e, and a.

kill(Y, r )$
C : C0 + a*Y;
I : I0 + r*e;
eq1 : Y = C + I + G0;
eq2 : Ms = f*Y - r*g;
soln : solve ([eq1, eq2],[Y, r]);

soln :  soln[1];

Given the solutions for Y and r we can evaluate C and I.

at (C, soln), ratsimp;

at(I, soln), ratsimp;

## Multiple Plots, Changing Plot Sizes with wxplot_size

Examples of using gr2d function from the draw package.
Examples of using wxdraw with gr2d to make multiple plots in the same cell.
Examples of using the external modifying option wxplot_size to get larger than the default size.

The default is one column of plots.

sinplot : gr2d( color = blue, key="sin (x)",grid=[2,2],  explicit( sin(x), x,0,2*%pi ) )$
cosplot : gr2d( color = red, key_pos = top_center, key="cos (x)", explicit(cos(x), x,0,2*%pi ) )$
wxdraw ( sinplot, cosplot ), wxplot_size = [680,680]$

Here we use the default size, and force two column display of the plots.

wxdraw ( sinplot, cosplot, columns = 2);

Two column display with larger size.

wxdraw ( sinplot, cosplot, columns = 2), wxplot_size = [880, 480];

default size, one column default (two rows).

wxdraw ( sinplot, cosplot );

## Proportional Axes Plots

Proportional Axes plots are useful if the line y = x is to look like a 45 deg line.
First we use wxplot2d, which has its own syntax (see Manual under plot2d). 
plot2d need the option [same_xy, true] for a proportional plot.

wxplot2d ([x, 4 + 0.2*x, 4 + 0.4*x, [   parametric, 5, t, [t, 0, 5]], [parametric, 20/3, t, [t, 0, 20/3]] ],
    [x, 0, 10], [style, [lines,2]], [same_xy, true], [grid2d, true],
   [ gnuplot_preamble, "set key bottom right;"] )$

With wxdraw2d use proportional_axes = xy as an option.

wxdraw2d (key_pos = top_left, proportional_axes = xy,
    key = "y = x", explicit (x, x, 0, 10), color = red, key = "4 + 0.2*x",
    explicit (4 + 0.2*x, x, 0, 10), color = green, key  = "4 + 0.4*x",
    explicit (4 + 0.4*x, x, 0, 10), color = magenta, key = "x = 5",
    parametric (5, t, t, 0, 5), color = black, key = " x  = 20/3",
    parametric (20/3, t, t, 0, 20/3));

Increasing the size of the plot with wxdraw2d:

wxdraw2d (key_pos = top_left,  proportional_axes = xy,
    key = "y = x", explicit (x, x, 0, 10), color = red, key = "4 + 0.2*x",
    explicit (4 + 0.2*x, x, 0, 10), color = green, key  = "4 + 0.4*x",
    explicit (4 + 0.4*x, x, 0, 10), color = magenta, key = "x = 5",
    parametric (5, t, t, 0, 5), color = black, key = " x  = 20/3",
    parametric (20/3, t, t, 0, 20/3)), wxplot_size = [680, 680];

## Colors in Plots

Default plot2d colors using wxplot2d. plot2d ([discrete, points], options), displays a list of points, 
joined by segments by default. The default colors start with blue, then red...

wxplot2d ( [ [discrete, [ [0,0], [0,5] ] ],  [discrete,[[2,0],[2,5]]],
      [discrete,[[4,0],[4,5]]], [discrete,[[6,0],[6,5]]], [discrete,[[8,0],[8,5]]], [discrete,[[10,0],[10,5]]],
        [discrete,[[12,0],[12,5]]], [discrete,[[14,0],[14,5]]]    ],  [x,-2,20], [y, -2,8], 
    [style, [lines, 4] ] );

Here is an example of using the option [color, c1, c2, ...] with plot2d to customize the color rotation
to be used.

wxplot2d ( [ [discrete, [ [0,0], [0,5] ] ],  [discrete,[[2,0],[2,5]]],
      [discrete,[[4,0],[4,5]]], [discrete,[[6,0],[6,5]]], [discrete,[[8,0],[8,5]]], [discrete,[[10,0],[10,5]]],
        [discrete,[[12,0],[12,5]]], [discrete,[[14,0],[14,5]]]    ],  [x,-2,20], [y, -2,8], 
    [style, [lines, 4] ], [color, blue, red, green, magenta, black, cyan, "#259452", "#25cd62"] );

The wxdraw2d default color is blue. Any other color choice must be explicitly given in the form
color = a_color_choice_understood_by_draw2d. See the manual description of draw2d.

wxdraw2d ( line_width = 5, yrange = [0,30],  explicit (x,x,0,10), 
    color = dark_magenta, explicit (x^1.5,x,0,10),
    color = "#259452", explicit (x^1.8, x, 0, 10) )$

## Global & Local Variables with a Maxima Function

When using the block version of a Maxima function, the list [a,b,c] in our example lists the "local
atomic symbols" which are private to the function and not accessible outside the function. Notice
that the symbol d is not included in out list. d is defined inside the function and becomes a globally
known function (known outside the function). The global symbol abc is defined before executing the
function and that assignment is known and available inside the function. 

abc : 5;

kill(f,z)$
f(z) := block ([ a, b, c ],
    [a,b,c,d] : z*[1, 2, 3, 4 ]/abc,
    display (a,b,c,d, abc),
    done)$

f(2)$

print ("a = ",a,"  b = ",b,"  c = ",c,"  d = ",d,"  abc = ", abc)$

[a, b, c, d];