2
$\begingroup$

I'm trying to make a dynamic demonstration involving the $\epsilon-\delta$ proof of the limit, $$\lim_{x\to c}(2x-1)=2c-1$$ with the following code. d and e correspond to $\delta$ and $\epsilon$.

d[e_]=e/2;
Manipulate[
    Row[{d[e], Plot[2x-1, {x,-1,4}]}],
    {c,0,3},
    {e,0,5},
    SaveDefinitions->True]

I've omitted the part of the code that contains c (it's a bunch of lines added via Epilog).

I would like to make the label to the left, currently the value of d given a fixed e, like d=(value of d), which I've tried using "d=" d[e]. However, this displays the value I want followed by the text d=. I can't seem to find anything that addresses this option in the documentation.

Edit: I'm now considering including the current values of c and e in a column to the right of the plot. I've changed the code as follows:

d[e_]=e/2;
Manipulate[
    Row[
        {Plot[2x-1, {x,-1,4}],
         Column[{{"e=",e}, {"d=",e/2}, {"c=",c}}]}
     ],
        {c,0,3},
        {e,0,5},
    SaveDefinitions->True]

but this gives me awkward labels that look like {e=,0} when e is $0$, for example.

$\endgroup$
  • 1
    $\begingroup$ Try "d=" <> ToString[d[e]] where you now have d[e]. $\endgroup$ – bill s May 13 '15 at 19:45
  • 1
    $\begingroup$ Just add a comma between "d = " and d[e], i.e. Row[{"d = ", d[e], Plot[2 x - 1, {x, -1, 4}]}]? $\endgroup$ – kglr May 13 '15 at 19:50
  • $\begingroup$ Thanks @kguler for the very simple fix :) $\endgroup$ – user170231 May 13 '15 at 19:51
  • $\begingroup$ Did you consider using the Appearance option: {e,0,5,Appearance->"Labeled"} ? The label appears at the end of the slider but is a bit less visible than the solution below. (This, of course, doesn't help with displaying d.) $\endgroup$ – JimB May 14 '15 at 0:04
2
$\begingroup$
d[e_] = e/2;

Manipulate[Row[{"d = ", d[e], Plot[2 x - 1, {x, -1, 4}, ImageSize -> 300]}, Spacer[5]], 
 {e, 0, 5}]

Mathematica graphics

Perhaps a better alternative is to use Labeled and to wrap the label with Pane to avoid jittering of the plot as the size of the label changes:

Manipulate[Labeled[Plot[2 x - 1, {x, -1, 4}], 
  Pane[Row@{"d = ", d[e]}, ImageSize -> 100], Left], 
 {e, 0, 5}]

Mathematica graphics

Update:

... including the current values of c and e in a column to the right of the plot.

Manipulate[Labeled[Plot[2 x - 1, {x, -1, 4}], 
  Pane[Column[Row /@ {{"e = ", e}, {"d = ", e/2}, {"c = ", c}}], 
   ImageSize -> {100, Automatic}], Right], {c, 0, 3}, {e, 0, 5}]

Mathematica graphics

Alternatively, instead of Column[Row /@ {{"e = ", e}, {"d = ", e/2}, {"c = ", c}}] use

Grid[{{"e = ", e}, {"d = ", e/2}, {"c = ", c}}]
$\endgroup$
  • $\begingroup$ Yes! I've been looking for way to stop the constant shifting. Do you have any suggestions regarding displaying the column of parameters? $\endgroup$ – user170231 May 13 '15 at 20:26
  • $\begingroup$ @user170231, I updated with a suggestion to display a column of parameters on the right. $\endgroup$ – kglr May 13 '15 at 20:36
  • $\begingroup$ Ah I see, I have to nest Row within Column. Thanks for the suggestion! $\endgroup$ – user170231 May 13 '15 at 20:38
  • $\begingroup$ @user170231, my pleasure. Thank you for the accept. You could also use Grid instead of Column/Row combination: Grid[{{"e = ", e}, {"d = ", e/2}, {"c = ", c}}] is perhaps more straightforward than Column[Row/@{...}]. $\endgroup$ – kglr May 13 '15 at 20:43
  • $\begingroup$ Grid introduces some alignment issues, but that's easily dealt with. $\endgroup$ – user170231 May 13 '15 at 20:45

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.