When I open the file containing the following code I get a series of error messages. Once I evaluate the cell with the code the error messages disappear. What is Mathematica doing when it opens a file, or how can avoid creating this problem for myself in the future?
econmagic1[ ds_, di_, ss_, si_ ] := (
(* begin equilibrium calculation *)
A = { { 1, - 1 ds }, { 1, - ss } };
CC = Inverse[ A ].{ di, si };
Manipulate[
(* begin grid layout*)
Grid[{
(* begin first row *)
{Show[
(* begin initial supply curve *)
Plot[ ( 1 / ss ) ( x - si ), {x, 0, Part[ CC, 1] },
PlotStyle -> { Red, Dashed },
PlotLegends -> { "Initial Supply Set"}],
(* begin initial demand curve *)
Plot[ ( 1 / ds ) x + ( - di / ds) , {x, 0, di },
PlotStyle -> Dashed, PlotLegends -> { "Initial Demand Set"} ],
(* begin demand curve *)
Plot[ ( 1 / ds ) ( x - et ) + ( - di / ds) , {x, 0,
di + et}, PlotLegends -> { "Demand Set"} ],
(* begin supply curve *)
Plot[ ( 1 / ss ) ( x - si ), {x, 0,
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ]}, PlotStyle -> Red,
PlotLegends -> { "Supply Set"}],
(* begin horizontal for equilibrium *)
Plot[Part[
Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et, si },
2 ], {x, 0,
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ]}, PlotStyle -> { Dashed, Thick } ],
(* begin filling for consumer surplus *)
Plot[{ ( 1 / ds ) ( x - et ) + ( - di / ds),
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 2 ] }, {x, 0,
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ]}, Filling -> 1 -> {2},
FillingStyle -> Directive[ Opacity[ 0.1 ], Blue ] ],
(* begin filling for producer surplus *)
Plot[{ Part[
Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et, si },
2 ], ( 1 / ss ) ( x - si ) }, {x, 0,
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ] }, Filling -> 1 -> {2},
FillingStyle -> Directive[ Opacity[ 0.1 ], Red ] ],
(* begin equilibrium point *)
ListPlot[{ {
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ],
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 2 ] } }, PlotStyle -> Black,
PlotLegends -> { "Equilibrium Point" }],
(* begin dashed lines for market equilibrium *)
Graphics[{ Dashed,
Line[{ {
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ], 0 }, {
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ],
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 2 ]}}] }],
AxesOrigin -> { 0, 0 },
PlotRange -> { { 0, di + 10 }, { 0, ( - di / ds) + 10 }},
AxesLabel -> { "Quantity", "Price"}, ImageSize -> Large
]}, (* End Show *)
(* begin second row *)
{ Grid[{
(*
second row first column *)
{"QD Price Intercept:" TraditionalForm[ - ( di + et ) / ds ],
(* second row second column *)
"QD Quantity Intercept:" TraditionalForm[ di + et ] },
(*
third row first column *)
{"QS Price Intercept:" TraditionalForm[ - si / ss ],
(* third row second column *)
"The equilibrium point is:" TraditionalForm[ {
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ],
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 2 ] } ] },
(* fourth row first column *)
{"Consumer Surplus:" TraditionalForm[(
1 / 2 ) ( (- di / ds ) -
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{
di + et, si }, 2 ]) Part[
Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ] ],
(* fourth row second column *)
"Producer Surplus:" If[
(* Does the Supply Curve Intersect the Price Axis *)
( - si / ss ) >= 0,
(* Supply Curve Intersects Price Axis *)
TraditionalForm[ .5 (
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{
di + et, si }, 2 ] - ( - si / ss ) ) (
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{
di + et, si }, 1 ] )],
(* Supply Curve Does Not Intersect Price Axis *)
TraditionalForm[ 0.5 ( Part[
Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{ di + et,
si }, 1 ] - si ) (
Part[ Inverse[{ { 1, - 1 ds }, { 1, - ss } } ].{
di + et, si }, 2 ] )]
] }
},
Alignment -> Left, Frame -> All, Spacings -> { 4, 1 } ]
}
}, Alignment -> Left],
{ { et, 0 }, -4.5, 25 } ]
)
SaveDefinitions -> True
to hisManipulate
expression. $\endgroup$ – m_goldberg Jan 17 '13 at 15:36