Mathematica is not just an “Expensive Calculator” (pt. 1): Making a Few Small Widgets

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

Now we will reconstruct a basic, one-digit calculator. Here’s the code (link), and here’s the calculator in action (link). The process is listed below:

  1. create a grid of buttons using Column[], Row[], and Button[], and put a frame around it to make it look cool
  2. make 2 chosen variables equal “Null” (num1 and num2 for the two numbers that will be operated upon)
  3. make the button change the value of the 2 variables based on their value using If[]
  4. 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.

calculator

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:

  1. make a plot that will draw a given function
  2. 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[])
  3. the height of the rectangles should be able to shift from left to middle to right by shifting the inputted value
  4. use Show[] to plot the function with the rectangle graphics and add Manipulate[] to make it interactive

riemann

CASnope

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s