Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to build an IS/LM model with sliders for a few things including the slope of the IS curve. I am stuck getting the equilibrium ticks and dashed lines to properly follow the intersection of the two lines when the slope is changed. I have tried incorporating my variable i in as many ways as I can think of into the ticks and dashed lines, but continually come up short. I am a newbie at Mathematica and the code is confusing the hell out of me and making the basic math more confusing for me. Help!

    Plot[Tooltip[s + .8 *q, "LM"], {q, 0, 150}, 
      AxesOrigin -> {0, 0}, PlotStyle -> {Thick, Blue}, 
      AxesLabel -> {"GDP", "Interest Rate"}, 
      PlotRange -> {{0, 100}, {0, 100}}, PlotLabel -> IS LM, 
      Ticks -> {{{0.77*d - (0.77*s), "GDP"}}, {{d - i*(0.77*d - (0.77*s)), "r"}}}, 
      BaseStyle -> {FontWeight -> "Bold", FontSize -> 12}], 
    Plot[Tooltip[d - i*q, "IS"], {q, 0, 200}, 
      AxesOrigin -> {0, 0}, PlotStyle -> {Thick, Green}], 
      Line[{{0.77*d - (0.77*s), 0}, 
            {0.77*d - (0.77*s), d - i (0.77*d - 0.5 (0.77*s))}}]}], 
      Line[{{0, d - i (0.77*d - (0.77*s))}, 
            {0.77*d - (0.77*s), d - i (0.77*d - (0.77*s))}}]}]], 
  {{d, 75, "Fiscal Policy"}, 50, 100, 2},
  {{s, 0, "Monetary Policy"}, 0, 100, 2}, 
  {{i, .5, "Interest Sensitivity"}, 0, 5, .1}]
share|improve this question
Glancing at your code, it looks like you are converting a previous static example with specific values for each of d, s, and i to the Manipulate. I think that several of your values that are numerical need to be expressed in terms of your three variables. Specifically I would look at 0.8 (in Plot), the ubiquitous 0.77, and the 0.5 should be i (in first Dashed Line. If you fix those instances with the appropriate formulas, my guess is that most of your worries will be fixed. – Andy Mobley Mar 10 '14 at 6:14
The second point in your first Dashed Line should be {0.77*d - (0.77*s), d - i (0.77*d - (0.77*s))} – qwerty Mar 10 '14 at 6:43
After esprit's fix, you can figure out what the 0.77 should be in terms of formula by setting the IS=LM and then solving for the q that is the intersection of the two lines. You'll find that the ratio q/d at init cond is 0.77. From there you should be able to figure out how to calculate a value for 0.77 that depends upon your variable i and the 0.8 that is in the LM equation. Plug that expression everywhere there is a 0.77. I don't know what that 0.8 means in terms of economics, but it is my guess you will want to be able to vary it as well. Also, your two ranges for q are different. – Andy Mobley Mar 10 '14 at 6:55
up vote 4 down vote accepted

I am uncertain if this is what you are after. A static baseline plot (reference) starting position I guess could be added. If the aim is simpler this may be helpful:

Manipulate[sol = q /. First@Solve[lm[s, q] == is[d, i, q], q];
 ysol = lm[s, sol];
 tcks = {{{sol, "GDP"}}, {{ysol, "r"}}};
 lns = {{Dashed, Line[{{sol, 0}, {sol, ysol}}]}, {Dashed, 
    Line[{{0, ysol}, {sol, ysol}}]}};
 Plot[{lm[s, q], is[d, i, q]}, {q, 0, 200}, Ticks -> tcks, 
  Epilog -> lns, PlotRange -> {0, 100}, 
  PlotStyle -> {{Thick, Blue}, {Thick, Green}}], {{d, 75, 
   "Fiscal Policy"}, 50, 100, 2}, {{s, 0, "Monetary Policy"}, 0, 100, 
  2}, {{i, .5, "Interest Sensitivity"}, 0, 5, .1}, 
 Initialization :> (lm[x_, y_] := x + .8*y;
   is[x_, y_, z_] := x - y*z)]

enter image description here

The tooltips and other style formatting can be adapted as desired.

share|improve this answer
Thanks, that is a lot simpler – Clay Mar 11 '14 at 4:04
@ubpdqn I saw answers like yours, with animated GIFs, a lot the last few days. Have you, or is there a tutorial for creating these GIFs from Mathematica? – Phab Mar 11 '14 at 10:13
@Phab Here are some useful resources (the first is free and makes life very easy): and and (these were just easy to find links and there are similar links on Mathematica Stackexchange that you can search) – ubpdqn Mar 11 '14 at 11:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.