I am putting the survey analysis on hold for a little while, because this is a bit more interesting. It’s quite different from what I have done on this blog up to this point.
People often joke that Mathematica is just an expensive calculator, even though it is capable of so much more. Here are a few small widgets just to humor these critics.
A Basic, One-Digit Calculator
- create a grid of buttons using Column, Row, and Button, and put a frame around it to make it look cool
- make 2 chosen variables equal “Null” (num1 and num2 for the two numbers that will be operated upon)
- make the button change the value of the 2 variables based on their value using If
- make operation buttons that will only act upon the variables if they are numbers
Here is a picture of the finished calculator, in case you can’t click the links. The second link (above) will show it in action.
Riemann Sum Finder
How about something more sophisticated, like a widget that will draw and find the Riemann sum of a function? Here’s the code (link), and here is are two demonstrations of the program (link 1, link 2). The process is listed below:
- make a plot that will draw a given function
- use Graphics to draw rectangles: the height should be based on the output of the function and the width should be 1 divided by the number of desired rectangles (tip: start with a constant number of rectangles before using Manipulate)
- the height of the rectangles should be able to shift from left to middle to right by shifting the inputted value
- use Show to plot the function with the rectangle graphics and add Manipulate to make it interactive