I have the following code:
a := 0; b := 5;
fxsquared[x_] := x^2;
Plot[fxsquared[x], {x, a, b}]
I would like to use Manipulate to vary the values of a and b and see the plot change.
Is there any way to do that?
I have the following code:
a := 0; b := 5;
fxsquared[x_] := x^2;
Plot[fxsquared[x], {x, a, b}]
I would like to use Manipulate to vary the values of a and b and see the plot change.
Is there any way to do that?
Do not set variables of constant values with :=, just use =
For the sake of Manipulate you do not need them at all. The following will give you the basic idea, and from there keep reading the documentation
Manipulate[Plot[Sin[x], {x, a, b}], {a, 0, 2 Pi}, {b, 3 Pi, 10 Pi}]
Thank you! That worked. I’m a novice and learning as I go. I now have this code functioning:
fxsquared[x_] := x^2
Manipulate[Plot[fxsquared[x], {x, a, b}], {a, 1, 5}, {b, 1, 5}]
I want to also show a point on the plot as a function of a and b. I’ve read through the documentation on Prolog and Point and this is what I’ve tried:
fxsquared[x_] := x^2
\[Xi] := (a + b)/2
Manipulate[
Plot[fxsquared[x], {x, a, b},
Prolog -> {Red, PointSize[0.02], Point[{\[Xi], fxsquared[\[Xi]]}]},
PlotRange -> {{0, 5}, {0, 25}}], {a, 1, 5}, {b, 1, 5}]
This lets me manipulate the fxsquared plot, but Xi shows as a fixed point that doesn’t change as I change the values of a and b.
Can you give me any guidance on how to do this? Again, many thanks for the help. I’m learning …
That’s perfect! Thank you so much!