Message Boards Message Boards

1 Reply
0 Total Likes
View groups...
Share this post:

Can I use Manipulate[expr ] to plot AND calculate simultaneously?

Posted 9 years ago


I have multiple functions of $x$ that depend on specific parameters, say $f(x,a,b,c)$, $g(x,a,b,d)$, $h(x,b,c,d)$. I can plot these functions simultaneously and use Manipulate[] to set the range for the parameters $a,b,c,d,..$ etc., and look at how the functions behave simultaneously under a change in parameters (using the slide-bar). That's very neat. Then, I was interested in seeing the difference between, say, $g$ and $h$, so I plotted Abs[g[x,a,b,d]-h[x,b,c,d]]. Let's call that function $y(x,a,b,c,d)$.

All these functions are plotted on a certain domain ( $x$ from $0$ to $\pi$) and I would like to calculate $\int_{0}^{\pi}y(x,a,b,c,d) dx$. Given a set of parameters that I fix (say $a=1,b=1,c=1,d=1$), I should get a scalar output. But I would like to see this output at the same time I vary each slidebar in the Manipulate output. In other words, I want to be able to play with the parameters and see the plot change accordingly, and at the same time, see how the result of my definite integral varies. Is there a way to do this with Manipulate? If so, how?

I have tried to look in the documentation but there doesn't seem to be any way of manipulating multiple "tasks" at the same time. Thanks in advance!

You can add the integral values to the plot using something like

Plot[..., Epilog->Inset[Text[Row[{"integral 1 = ", N[code for integral 1]," integral 2 = ", N[code for integral 2]}]]]

See Wolfram documentation for placement of Inset near your plot.

POSTED BY: S M Blinder
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract