1
$\begingroup$

I'm doing a project about Moore's law, I'm trying to create a graph that which you can manipulate, but I want the x-values of the intersections with one the lines to be displayed; how would I go about doing this?

This is what I have (the first formula is 'real', the rest are placeholders for the sake of having intersections):

j0=1980;
Manipulate[LogPlot[{tj0*2^((j - j0)/2), -(b*2^((j - j0)/1.5) - 1000),     
-a*j + c}, {j, 1980, 2000},Frame -> True, PlotRange -> All, LabelStyle -> 
{FontFamily -> "Helvetica", FontSize -> 15}, FrameLabel -> {"Year", "Transistor Count"}],
{{tj0, 100, "Transistor Count First Year"}, 100, 200}, {{b, 100, "b-Value"}, 100, 200}, 
{{a, 100, "a-Value"}, 80,  120}, {{c, 250000, "c-Value"}, 250000, 300000}]

enter image description here

What I would like is something like this:

Manipulate[ If[(-M + M p + Ls z - Ls p z)/(-1 + z) <= M, Plot[{If[G <= M, (-G + M + G z - Ls z)/z], If[(-M + M p + Ls z - Ls p z)/(-1 + z) <= M, Exp[((1 - p)*Log[G] - p*Log[((M p - Ls p z)/z)] - (1 - p)* Log[((-M + M p + Ls z - Ls p z)/(-1 + z))])/-p]]}, {G, 0, 2000}, AxesLabel -> {" SubscriptBox[\"W\", \"G\"] ", " SubscriptBox[\"W\", \"B\"] "}, PlotRange -> {{0, 2500}, {0, 2500}}, AxesStyle -> Directive[Bold], LabelStyle -> Bold, Epilog -> {Thick, Dashed, Line[{{(-M + M p + Ls z - Ls p z)/(-1 + z), 0}, {(-M + M p + Ls z - Ls p z)/(-1 + z), (M p - Ls p z)/ z}}]}, Prolog -> {Thick, Black, Line[{{0, 0}, {2500, 2500}}]}, PlotStyle -> {{Thick, Blue}, {Thick, Purple}}, PlotLabel -> "Optimal Insurance Contract"], Plot[{If[G <= M, (-G + M + G z - Ls z)/z], G}, {G, 0, 2500}, AxesStyle -> Directive[Bold], AxesLabel -> {" SubscriptBox[\"W\", \"G\"] ", " SubscriptBox[\"W\", \"B\"] "}, PlotStyle -> {{Thick, Blue}, {Thick, Black}}, AxesOrigin -> {0, 0}, PlotRange -> {{0, 2500}, {0, 2500}}, AxesStyle -> Directive[Bold], Epilog -> {PointSize[Large], Red, Point[{M, M - Ls}]}, PlotLabel -> "Optimal Insurance Contract", LabelStyle -> Bold]], {{p, .5, "Probability of Bad State"}, .1, .9}, {{M, 1000, "Original Wealth"}, 500, 1250}, {{z, .52, "Insurance Premium"}, .3, .9}, {{Ls, 200, "Loss"}, 50, 900}, Text[Style[ "Wealth in the Good State = " Dynamic[ If[(-M + M p + Ls z - Ls p z)/(-1 + z) <= M, Dynamic[(-M + M p + Ls z - Ls p z)/(-1 + z)], M]], 12, "Label"]], Text[Style[ "Wealth in the Bad State = " Dynamic[ If[(-M + M p + Ls z - Ls p z)/(-1 + z) <= M, Dynamic[(M p - Ls p z)/z], M - Ls]], 12, "Label"]], Text[Style[ "Premium = " Dynamic[ If[(-M + M p + Ls z - Ls p z)/(-1 + z) <= M, Dynamic[M - (-M + M p + Ls z - Ls p z)/(-1 + z)], 0]], 12, "Label"]]]

enter image description here

I'd like thick dashed lines to go down to the x-axes from the intersections of any of the lines with the first blue line and the x (or j value here) to be displayed like in the second example.

$\endgroup$
1
$\begingroup$

How about this:

j0 = 1980;

Manipulate[
 f1[j_] := tj0 2^((j - j0)/2);
 f2[j_] := -(b 2^((j - j0)/1.5) - 1000);
 f3[j_] := -a j + c;
 j12 := j /. FindRoot[f1[j] == f2[j], {j, 1980}];
 j13 := j /. FindRoot[f1[j] == f3[j], {j, 1980}];
 LogPlot[{f1[j], f2[j], f3[j]}, {j, 1980, 2000},
  Frame -> True, PlotRange -> {.1, 10^6}, 
  LabelStyle -> {FontFamily -> "Helvetica", FontSize -> 15}, 
  FrameLabel -> {"Year", "Transistor Count"},
  Epilog -> {Dashed,
    Line[{{j12, -10}, {j12, Log@f1[j12]}}],
    Line[{{j13, -10}, {j13, Log@f1[j13]}}]},
  PlotLabel -> Row[{"Critical years: ", j12, " and ", j13 }]
  ],
 {{tj0, 100, "Transistor Count First Year"}, 100, 200},
 {{b, 100, "b-Value"}, 100, 200},
 {{a, 100, "a-Value"}, 80, 120},
 {{c, 250000, "c-Value"}, 250000, 300000}
 ]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Many thanks, but is there any way to dynamically display the x (or j here) values of those intersections as well? $\endgroup$ – John Jan 7 '14 at 20:39
  • $\begingroup$ @John. Yes, see edit above. You can also add this data to inside the plot. I am less familiar with the necessary commands but I am sure the Help can help you. Basically you can reuse any local variable in the plot layout. $\endgroup$ – A.G. Jan 7 '14 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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