Sunday, May 18, 2008

Interactive Plots in Mathematica

To study the behavior of an analytical solution that has several control parameters, one would usually plot that function under different combinations of these parameters. There is a super nice function in Mathematica that allows the user to dynamically plot the solution by changing the control parameters using sliders. The function is called Manipulate and here's an example
Manipulate[Plot[Exp[-w x] Cos[a x], {x, 0, 3 Pi}, PlotRange -> Full], {w, 0, 10}, {a, 0,20}]
The Manipulate[] function performs a job similar to that of the Table[] function, but with a graphical user interface. In the above code, we are manipulating a plot subject to two control parameters, w and a. The Plot[] function follows the standard Mathematica syntax. Here's a screen recording of how the result looks like

Of course, you can plot as many functions and accomodate as many control parameters as you want. This also works with 3D plots. Of course, you will have to use Plot3D to do that.

For a complete description of the Manipulate function, you can visit its Mathematica documentation page

Cite as:
Saad, T. "Interactive Plots in Mathematica". Weblog entry from Please Make A Note.


  1. Sir
    how to plot the derivative of

  2. Plot[D[Exp[x]/(4*Exp[x]+1),x],{x,0,10}]

  3. This is very clever stuff, interesting point of view, I wonder if the results are measurable.
    Cheap Viagra Online