You can also create an interactive notebook element that calculates and displays the results of values you or your users input. In the previous video, you learned how to add a single control to manipulate. In this video, you will add a second control.
- [Instructor] Entering an expression or equation into Mathematica, let's you calculate a result or visualize data. You can also create an interactive notebook element, that calculates and displays the results that values you or your users input. In the previous movie, I showed you how to add a single control to manipulate. In this movie, I'll show you how to add a second control. I'm working in a blank Mathematica notebook, so I need to define the expression that I will use to manipulate a visualization. I'll start by typing the manipulate keyword.
Then I'll follow that with a left square bracket. Now, I need to define what will be manipulated. So I'll type, Plot, followed by another left square bracket and the expression that will be visualized within the plot. I'll make that x, and it's important that it be a lowercase x. Raised to the third power. Minus a, space, x to the second power, plus b. So this is slightly different from the equation I used in the last movie. The last term here was plus a, instead this time, I'm making it plus b, so we can see how two elements work or two manipulable variables.
Now I need to define the range for the x variable, that's in the expression and we'll give the range of the visualization. So I'll type a comma, then a left curly bracket to start my list, then x, comma, minus six for the minimum, comma, six for the maximum, then a right curly bracket. That's the end of the plot commands arguments, so I'll type a right square bracket. Now type a comma, and I need to define ranges over which I can manipulate the variables a and b.
So I'll start with a left curly bracket, type the variable a, comma, minus 15, comma, 25. So I've got my minimum and my maximum. Then a right curly bracket and then a comma, and then a left curly bracket, and that will work with b. So I'll type b and we'll have the minimum of 100, comma, 1000 for the maximum. Now I can close out this list with a right curly bracket and the manipulate keywords argument list with a right square bracket. And when I press shift + enter, I see my visualization and I have two different sliders.
One for a and one for b. If I want to display the controls for a, I can click it's Show Animation Controls button and I will go ahead and play that. So I see the plot changing exactly as it did in the previous movie. I'll click the pause button and now I will display the animation options or animation controls for b, and I'll go ahead and click play for that.
As you can see, I have a visualization that includes a linear addition in the range 100 to 1000. So it just goes up the y-axis. If I run them both, then you'll see that I get changes up and down the axis, although it's a little bit hard to follow. If I click pause, after I get back to 100, then you'll see variation for the variable a only and it allows me to see how that would vary with a constant being added of 234.041.
I'll go ahead and click pause for variable a. Manipulating a plot with two input variables, can be a little confusing if you let both variables change over time. If instead you fix one of the variables at a desired value, and let the other run, you can see how those settings will affect your equations, overall.
- Managing Mathematica notebooks
- Surveying basic Mathematica commands
- Manipulating lists
- Analyzing data using descriptive statistics
- Manipulating matrices
- Managing executable Mathematica scripts
- Visualizing and formatting data
- Creating interactive and animated visualizations