1
$\begingroup$

I would like to use Manipulate to Plot a figure and also give me the result of an equation simultaneously. In my case, this is because the closed form expressions for the figure change as I vary the parameters, and including the equation will allow me to quickly know which set of expressions are being plotted.

I am able to do this by putting Plot and the function in brackets in the Manipulate expression, but this puts the output in brackets as well.

Is there a better way to do this?

Here is a MWE:

a[x_, y_] := x*y
b[x_] := Piecewise[{{1, 0 <= x < 0.5}, {2, 0.5 <= x}}]
Manipulate[{Plot[a[x, y], {y, 0, 1}], b[x]}, {x, 0, 1}]
$\endgroup$
0
$\begingroup$

Using Column Center DisplayForm

a[x_, y_] := x*y
b[x_] := Piecewise[{{1, 0 <= x < 0.5}, {2, 0.5 <= x}}]
Manipulate[
 Column[
  {
   Plot[a[x, y]
    , {y, 0, 1}
    , PlotTheme -> "Scientific"
    , PlotRange -> {-1, 1}
    ],
   DisplayForm[b[x]]
   }, Center]
 , {x, 0, 1}]

enter image description here

$\endgroup$
  • $\begingroup$ This is exactly what I needed - thank you! $\endgroup$ – vanitha Aug 10 '18 at 14:24

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.