Introduction

This is the Mathematica Tutorial that we have peer leaders (undergraduate students who took the course the previous semester) present during the first three weeks to the students as an introduction to programming in Mathematica and examples of tools commonly used within Wolfram demonstrations. At the beginning of the semester, the students receive the blank tutorial called “Mathematica_Tutorial.nb” and complete the examples by following the peer leaders and receiving assistance from peer leaders or graduate student instructors when necessary. Once the tutorial has been completed, we give the students the “Mathematica_Tutorial-completed.nb” file (this file), which has all the examples completed along with the answers to the challenges. The “Mathematica_Tutorial-completed_and_annotated.pdf” file is the file the peer leaders use when presenting the tutorial, as it includes instructions on how to present certain topics and examples. 

More information about Compute-to-Learn can be found at our website: http://umich.edu/~pchem/about.html.

License

This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/.

Curriculum

Week 1

Get to know your peers, peer leaders, and GSIs.

Learn about the expectations of the course.

Read through the prompt options, and choose a project for the semester.

Begin Mathematica tutorial.

HW: Begin collecting information and studying your prompt.

HW: Type one page of notes about your topic

HW: Get your Mathematica trial!

Week 2

Continue Mathematica tutorial.

Have a conversation with a peer leader and GSI regarding your prompt.

HW: Take home exercise (complete manipulation of beaker).

HW: Continue collecting information about your prompt.

Week 3

Complete Mathematica tutorial.

HW: Continue studying your prompt.

HW: “Storyboard” what your Demo will look like.  Draw pictures and describe in words how you think you could organize your code.  See the expectations worksheet to ensure you present enough material.

Week 4

Informal presentation of storyboards.

Peer Review #1: Complete critique form 1 for each peer. Have a conversation with the peer leader and GSI regarding your ideas and how your project can be implemented.

Pizza party!!!! while requesting Mathematica Licenses if not done already.

HW: Continue gathering resources regarding your topic of interest, and begin exploring and understanding the material. Attempt to code some graphs or graphics associated with your prompt.

Week 5-8

Coding.

Meet with GSI and peer leader to discuss your progress.

HW: Continue coding. Prepare to informally present your progress to your peers in 5 minutes or less.

Week 9-10

Peer Review #2/#3: Complete critique form 2 for each peer. Have a conversation with the peer leader and GSI regarding your progress, questions, and future direction.

Complete Coding.

Make sure your demo fits the requirements of the Mathematica Demonstrations Project.

Begin writing a one page explanation of your demo as well as a ~5 sentence abstract detailing your demo. The ~5 sentence abstract will be published on your demonstration page.

Submit your demonstration with the one-page explanation AND ~5 sentence abstract to your peer leaders.

HW: Complete coding and prepare demonstration page.

Extra Credit: If you submit your Mathematica Demonstration to the demonstrations page by week 10, you will receive a free “upgrade” to any previous grade.

Week 11

Submit your Demonstration to the Mathematica Demonstrations Project website.

HW: Write a one-page homework assignment with multiple questions.  These questions must require use of your demonstration as a tool to answer the questions.

Week 12

Make edits based on review given by the Wolfram Demonstrations team.

HW: Get ready for formal presentation session.

Week 13

Formal presentation session and pizza party to celebrate everyone’s accomplishments!

Grading

The Grading for CHEM 230/260H largely depends on your commitment to the course, active attendance, and completion of assignments to your best ability.  (For example, if you stop showing up to the studio or give minimal to no effort on multiple assignments, you will not receive an H credit). You must receive an overall average of ✓ or ✓+ to receive the H at the end of the semester.

Assignments that will be graded on the ✓+, ✓, or ✓- scale:

One typed page of notes about chosen prompt (due Week 2) (worth 1 check)

Completion of Take-Home Assignment (Week 3) (worth 1 check)

Storyboard (Week 4) (worth 2 checks)

Attendance

You cannot miss more than one studio session without approval. (ಠ_ಠ)

If an important event comes up where you must miss one more session, you may get approval by the GSI at least 24 hours in advance of the studio session to be missed.

Overall engagement with Mathematica software and involvement with the peer review process. (worth ಠ_ಠ and 1 check per peer review session)

Involvement in the peer review process includes completing the critique form for your peers on weeks 4, 9, and 10, reading the critique form given to you by your peers, and giving a written description of the changes you made to your demo based on your peers advice (this can be written at the end or beginning of your one page explanation of your demo).

One-page explanation of demo (Week 9/10) (worth 1 check)

One-page homework assignment (Week 11) (worth 1 check)

Overall Final Mathematica Demonstration Page (worth 3 checks)

We want every individual involved in CHEM 230/260H to enjoy this course and leave with a published demo.  At the end of the semester, we hope that each of you will complete a demo that can actually be used by other students to help them understand concepts they are struggling with in CHEM 230 or 260.

Tutorial Guidelines

This is an interactive tutorial, make sure to save your work after adding notes to each slide so you can always come back and see your progress.

You can press “command+s” for Mac or “control+s” for Windows to save.

After each session, remember to email your saved tutorial to yourself. The school computers occasionally delete files so there is no guarantee the file will be there for you next week.

After each of the tutorial sessions, a completed tutorial through that day will be posted. This is meant to allow you to see some of the other options to completing certain examples and to check your in-studio exercises for any errors, if they cannot be found during studio. You still must be following along with the peer leaders throughout the tutorial.

Mathematica has a HUGE library of options and functions to evaluate different types of problems.

Our intent is to give you an introduction to those options you will need to make a demo.

Definitely continue to explore Mathematica’s huge library beyond what we show you.

When you need to solve a new problem, there are many ways to access documentation and get examples of code.

You can always go to the Mathematica website (or even a search engine such as Google) for an answer to your problem.

e.g. Search “how to make a scatter plot in Mathematica?”

or

1.  From within a Mathematica notebook:  Search for a particular built-in function name, e.g., ListPlot, by typing  the following and evaluating the cell:

?ListPlot

Note that Mathematica is case sensitive! If you try the following search, the error appears because the function name is not recognized with lower case letters:

?listplot

If you want further examples, click the “>>” link, and a separate Mathematica documentation page will pop up.

2.  From the web: Visit the Mathematica Documentation Center and enter a search term. You can either search for a specific built-in function name or a topic. E.g., searching for “scatter plot” will return a list of related topics (there is no built-in function called ScatterPlot).

3. From the web: Visit Mathematica StackExchange and enter a search term or click one of the “Explore our Questions” categories. This is a wonderful site for getting ideas and code samples for problems.

4. Mathematica has many powerful visualization tools. In addition to the Mathematica Demonstrations Project page, the Plot Themes page is a great place to get ideas and see what kinds of displays are possible.

Also, although we may show you one way to solve one type of problem, know that there are often multiple ways to solve that same problem.

While you create your own demonstration this semester, try to think creatively about what you can display with Mathematica.

In addition, after you finish writing your code, always try to go back and see if there is a way you could have written it even better!

The tutorial will last 3 weeks. After each week (except for today), you will have a small take home project that you can do collaborating with a group of your choice. YOU MUST DO YOUR OWN WORK AND SUBMIT YOUR OWN COPY. Your peer leaders will give you a ✓+, ✓, or ✓- based on your work.

Mathematica For Physical Chemistry Introductory Tutorial:

Chem 230/260 Honors Studio

Click on the following links to see cool examples of Mathematica demonstrations.  At the end of the course, you will have developed a physical-chemistry-related Mathematica demonstration.

Mathematica Demonstration: Hangman
Mathematica Demonstration: Electron in a Nanocrystal Modeled by a Quantum Particle in a Sphere
Mathematica Demonstration: Simulating Gas Exchange in a Model of Pulmonary Fibrosis

How to use Mathematica input and output to solve simple arithmetic and algebra

Basic Math: Addition, subtraction, multiplication, division, exponents

Example 1:

Place your cursor directly below the gray box at the end of these bullet points. Once your cursor turns horizontal, left click when your mouse is horizontal and use the keyboard shortcut “Alt+9” for Windows and “Cmd+9” for Mac.

An alternative option is once your cursor turns horizontal, right click (on a Mac laptop or with a Mac mouse, right click is “Ctrl+Click”).  Hover your mouse over "Insert New Cell" and left click from the drop down menu to choose "Input".

Now, use the keyboard signs + , - ,  * , / , and  ^  to show examples of addition, subtraction, multiplication, division, and exponents, respectively. Press Shift+Enter to compile your input.

As a first example, look at the text below with the white background.  After typing "2+1" and then pressing Shift+Enter, the outputted gray box appeared with the number "3".

2+1

2/3

2./3
N[2/3]

2^3

Variable: Text can be set equal to values or expressions known as variables. Variables are normally assumed to be "global", meaning that each time a variable is used, Mathematica assumes it is the same object each time. Local variables are defined for specific programs or modules.

Example 2: Add Z to F and then evaluate.  Then repeat the previous exercise, but first assign a value to each variable.

Z + F

Z = 1.5
F = 2
Z + F

Note: Think of variables as storage locations.  In the examples above, the value “1.5” was stored in the location named “Z”.

Example 3: Use a semicolon ( ; ) at the end of the lines defining Z and F to suppress the output.

Z = 1.5;
F = 2;
Z + F

Example 4:  Assignments are global and effective throughout the notebook unless cleared. Assign a value to U then add U to Z and F.

U = 24;
U + Z +F

Note: Be aware that some variable names are protected, since they correspond to built-in Mathematica functions. Assigning a value to these will produce an error:

D=7
N=9

Also remember that Mathematica is case-sensitive, so using d and n instead will work fine:

d=7
n=9

String: A series of characters that form text using quotation marks.

Example 1: Type a phrase in quotation marks; then evaluate.

"Hello"

Function: Mathematica has many built-in functions that will evaluate your mathematical problem or display your data in certain ways.

Functions are called by typing in the function name, followed by a pair of square brackets “[ ]”. In the square brackets are the arguments of the function, separated by commas.

Some examples are: Sin[ ], Cos[ ], or  Integrate[ ].

All built-in names in Mathematica (function names and constants) begin with capital letters.

They all require slight variations in the input syntax.

Example 1: Check that the value of Sin[Pi] is equal to zero.

Sin[Pi]

Argument: If you have a function, F((Subscript[x, 1]),(Subscript[x, 2]),....,(Subscript[x, n])), the argument is one of the n parameters or variables upon which the function depends.

In other words, for the single variable function f(y), the variable y is the argument. Similarly, for the multivariable function F((Subscript[x, 1]),(Subscript[x, 2]),....,(Subscript[x, n])), the arguments are the n variables (Subscript[x, 1]), (Subscript[x, 2]), ..., (Subscript[x, n]).

Example 2: Determine the value of (Subscript[log, 2])(1024).

Log[2,1024](* More than one argument *)

List

A list is an ordered set of elements.

To specify a list, put a pair of curly braces “{ }” around the elements, separated by commas.

Example 1: Define a variable equal to a list of the numbers 4, 9, and 8.

listNum = {4,9,8}

The elements of a list can be numbers, symbolic expressions, other lists, or a mixture of those.

Example 2: Define a variable equal to a trigonometric functions sin(θ), cos(θ), and tan(θ).

listExpr = {Sin[theta],Cos[theta],Tan[theta]}

A matrix is created by making a list of lists.

Example 3: Create the 3x2 matrix below by making a list of three lists.

(({{a, b}, {c, d}, {e, f}}))

matrix = {{a,b},
                      {c,d},(* Mention that assignments are global *)
                      {e,f}}

Operations thread over lists, meaning that they operate on each value in the list successively.

Example 4: Subtract 2 from the list of numbers you created in Example1.

listNum (* to remind ourselves what listNum is *)

listNum  - 2

Example 5: Multiply the list of numbers you created in Example1 by a list of 0, 1/3, and 1/10.

listNum * {0,1/3,1/10}

Example 6: Take the natural log of the list of numbers you created in Example1.

Log[listNum]

N[Log[listNum]]

A number of functions use lists within their arguments.

Example 7: Use the built-in function NIntegrate[ ] to evaluate the area under the mathematical line, y = x, between x = 0 and x = 1. Using the same range, integrate  (x^( 2)).

NIntegrate[x,{x,0,1}]

NIntegrate[x^2,{x,0,1}]

A number of functions return lists.

Range[ ] returns a list of numbers with specific starting and ending points, and the step size can also be specified.

Example 8: Evaluate the Range[ ] function three times with arguments of 10; 5, 10; and 5, 10, 0.5.

Range[10](* Default start from 1 *)

Range[5,10](* Default step size 1 *)

Range[5,10,0.5]

Table[ ] returns a list, where each element is generated using the same expression, but different values are plugged in.

Table[ ] takes in an expression and a list as its arguments.

Example 9: Evaluate the Table[ ] function with the expression (2^i) with i going from 0 to 10 in steps of 1.

(* Table[expression,
        {variableName, min, max, step}] *)
Table[2^i,
           {i, 0, 10, 1}]

Example 10: Repeat Example9 but with (j^i)instead of (2^i).

(* Table symbolic expressions *)
Table[j^i,
           {i, 0, 10, 1}]

Example 11: Define a variable equal to a table with a list of expressions i  and (i^2)with i going from 0 to 10 in steps of 1..

(* Table list *)
mat = Table[{i,i^2},
            {i, 0, 10, 1}]

Example 12: Build a pretty matrix out of the nested list we just generated.

MatrixForm[mat]

Comment: Used for placing notes in Mathematica, the text inside parentheses' and asterisks only helps describe the input.

Syntax: (* comment *)

A keyboard shortcut exists to quickly insert the comment syntax.  Press “command” + “/” to instantly create the following syntax, “(*cursor*)” , where your cursor will immediately be set between the asterisks. This is a preferred way to insert a comment to avoid placing unwanted input into the commented section.

Example 1: Evaluate the following input and observe the output. Is there a difference between the two functions?

1 + 2
1(*hello i am one *) + 2

Note: Comments are for the user only. The machine will completely ignore comments.

Mathematica Error Messages

When working with Mathematica, there are different types of elements that you must use to execute your program. In addition, we are all prone to writing programs with mistakes (bugs).  When we get an error message from a bug, sometimes confusing jargon will show up.  See the following input.

Table[{numbers, , numbers, 5,15}]

Hover your mouse over the red caret in the input to see the error message.

In Studio Exercise I

The following page has four exercises in basic math. Complete them with your group.

Exercise I

1.  Use a function to create a list of the first 20 integers cubed. (you should see in your output, “{1, 8, 27...}”)

Table[int^3,{int,1,20}]

Range[1,20]^3

(* Not done in class, but this can be done with a user-defined function. User-defined functions will be taught during Day 2 *)
getCube[int_] := int^3
getCube/@Range[20]

2.  Use basic arithmetic operations to determine if the order of operations is conserved in Mathematica.

5 + 2/3

(5+2)/3

5 + (2/3)

3.  Evaluate the following input and decide which formation correctly gives the output value of sin(60°)

Sin[60]

Sin[60 Degree]

Pi * 60/180

Sin[Pi/3]

4. What output/value do you get when you add together “1 + Pi”? How about “1+N[Pi]”?

1 + Pi

1 + N[Pi]

Note: Similar to the variable D, variables N and Pi are also protected.

End Day 1 (Remember, save your work and email it to yourself!)

Recap: How is Mathematica Structured?

Input: The text written by a human author, which is written under the “Input” format. (the In[ ] and Out[ ] will appear automatically when you evaluate a cell in Mathematica. The number inside the brackets is the number of evaluations that have happened in the current Mathematica session)

Output: The computer-generated evaluation of the “Input” text.

Brackets [ ]

Brackets are used to enclose function arguments.

Example 1: Use the built-in Mathematica function Sin[ ] to evaluate the sine of Pi.

Sin[π]

Braces { }

Braces are used to enclose lists.

Example 2: Evaluate the following List[ ] and Range[ ] functions, and view the braced format of the output.

List[1,2,3,4,5,6]

Range[10]

Parentheses ( )

These are used to organize expressions and determine the order of operations. For example, view the following:

(3+2)*(4+9)

3+(2*4)+9

Cells: Mathematica notebooks are organized using "cells", which are shown by the open-ended boxes on the far right side of the Mathematica window.

Example 3: Click to the right of your work and note how some cells are embedded within others.

Notebook: The type of file where most Mathematica codes are developed or where mathematical problems can be solved.

The file is saved with the extension ".nb"

Demonstration: A Mathematica file that dynamically demonstrates a concept that can be shown using Mathematica language, which can be published online under the Wolfram Demonstrations Project. A demonstration is presentable, and may include interactive elements to convey information.

User-defined functions

The Wolfram Language allows you to define functions of your own. These function definitions are essentially just assignments that provide transformation rules for specified patterns. To define functions you will use delayed assignments, so as to perform the defined calculation any time you call a function.  In other words, delayed assignments indicate that Mathematica will not evaluate the function until you provide the input for the function.

Before we continue any further, we should clear the memory of the variable x to avoid any confusion with the machine.

Clear[x]
Clear["Global`*"]
(* Use Clear["Global`*"] to clear all variables and functions *)

To define a function, you must first give it a name. These names are just symbols, so you should avoid starting them with capital letters to prevent confusion with built-in functions.

The assignment of a function involves the use of the operators Blank ( _ ) and SetDelayed ( := ), which will be further explained later in the tutorial.

Example 1: Define a simple function that squares an argument.

f[x_] := x^2

Example 2: Use the function to square 3.

f[3]

Example 3: Apply the function to an expression x + 1.

f[x+1]

Example 4: Apply the function to a list of expressions: x,  x + 1, and  x -1.

f[{x,x+1,x-1}]

What happens if you do not use the operators _ and := ?

The Blank ( _ ) operator tells Mathematica that x is not a variable, but instead an argument of the function to be defined.

Example 5: Try defining and then evaluating a new function without _ operator. What happens?

g[x] := x^2

g[5]

g[x]

The SetDelayed ( := ) operator is more subtle. It evaluates the RHS expression each time the function is called.

This is for most of the time what you would want, however on very rare cases you want the RHS to be evaluated only once when the function is defined.

Rule of thumb: Do not use “=” while defining functions unless you know exactly what you are doing.

Example 6: Evaluate the following input to see how the SetDelayed operator works.

randomOneTime[x_] = x*RandomReal[];(* RandomReal is called only once. *)
randomManyTimes[x_] := x*RandomReal[];(* RandomReal is called every time. *)

Table[randomOneTime[100],{i,1,10}](* Returns 10 identical numbers *)

Table[randomManyTimes[100],{i,1,10}](* Returns 10 different numbers *)

You can define a function to accept multiple arguments.

Example 7: Define a function to solve the Arrhenius equation, rate = A • (e^(-Ea / RT)), that accepts A, Ea, and T as arguments.

GasConstantR = 0.008314 (* kJ / mol•K *);
arrhenius[A_,Ea_,T_] := A*Exp[-Ea/(GasConstantR*T)]

Note: The semicolon ( ; ) at the end of the first line means the output for that line is suppressed. In this case, we suppressed it because we do not need the gas constant to show up as outputoutput; we only need it as a variable in the Arrhenius function. To see how this works, you can try evaluating the input both with and without the semicolon.

Example 8: Determine the rate constant for A = 1.03*10^12 (s^(-1)), Ea = 196.6 kJ/mol, T = 393 K.

arrhenius[1.03*10^(12),196.6,393]

Plots

Plot[ ] returns a plot object.

Example 1: Create a sine plot over the range 0 to 2π.

(* Plot[ expression,
        { varName, min, max}] *)
Plot[Sin[x],
         {x,0,2*Pi}]

Options can be added to Plot[ ] as additional arguments to change the behavior of the plot.

Options are special expressions with an arrows in them. To type an arrow, type in ->.

As functions require more and more elaborate arguments, it is useful to split single functions into multiple lines.

Example 2: Again Plot Sin[x] from zero to 2pi, but use options to set the PlotStyle to Red and add a PlotLabel.

(* Plot[ expression,
        {varName ,min ,max },
        option1,
        option2] *)
Plot[Sin[x],
        {x,0,2*Pi},

        (* options *)
         PlotStyle-> Red, 
         PlotLabel -> "Sin(x)"]

To plot multiple expressions on the same plot, pass the multiple expressions in a list. Keep in mind that functions like Plot[ ] thread through lists.

The same rule goes for some options such as PlotStyle.

Example 3: Plot Sin[x] and Cos[x] from zero to 2*Pi. Specify a solid red line for sine and a dashed blue line for cosine, and include a label.

(* Plot[ {
           expression1, 
           expression2,
           expression3 },
        {varName ,min ,max },
        option1,
        option2] *)

Plot[{
(* expressions *)
Sin[x],
Cos[x]},

(* range *)
{x,0,2*Pi},

(* options *)
PlotStyle ->{Red,
                       {Dashed,Blue}},
PlotLabel -> "Sin(x) vs Cos(x)"]

Remember, if you are unsure of the syntax for a function, you can either evaluate the function with a preceding “?” or simply hover your cursor over the function name and click the “i” icon.

?Plot

Graphics

Mathematica Graphics can either be imported from external files or created via built-in Mathematica functions.  Most Mathematica graphics come in 2D or 3D.

Graphics[ ]  Is the function that returns a 2D graphic. To tell it what to draw a shape is provided as its argument.

Some 2D shapes in Mathematica.

Graphics[ Disk[ {x , y }, r ] ]

Graphics[ Circle[ {x , y }, r ] ]

Graphics[ Triangle[ { (Subscript[p, 1]),  (Subscript[p, 2]), (Subscript[p, 3])} ] ]

Example 1: Draw a filled-in Disk at the origin.

Graphics[ Disk[{0,0},1] ]

To draw multiple shapes at the same time, include all the shapes in a list, akin to how multiple expressions are included in a plot.

Example 2: Draw a Mickey Mouse.

(*
Graphics[{
Disk1,
Disk2,
Disk3
}]
*)
Graphics[{
Disk[{0,0},0.8],
Disk[{Sqrt[0.5],Sqrt[0.5]},0.5],
Disk[{-Sqrt[0.5],Sqrt[0.5]},0.5]
}]

To change the shape, transparency, border, etc. of the shapes, directives can be added as additional elements of the list.

Directives are specific expressions such as Red or Opacity[0.5].

Directives have to be specified before the shape! This is unlike options, which are specified AFTER the main variables of the function.

Example 3: We will change the color and opacity of the disk graphic, simply by typing a color before the shape function. You can adjust the colors and opacities to see how the graphics change.

Graphics[{Blue,Opacity[0.5],Disk[{0,0}]}]

Graphics[{Opacity[0.3],RGBColor[0.77,0.28,0.5],Disk[{0,0}]}]

The graphics can become very elaborate when you combine various shapes with various directives. Try to structure your code to make it easier to read.

(*
Graphics[{
Directive,
Directive,
Shape1,

Directive,
Directive,
Shape2,

Directive,
Directive,
Shape3,

...
}]
*)
Graphics[{
Thick,
Green,
Rectangle[{0,-1},{2,1}],

Red,
Disk[],

Blue,
Circle[{2,0}],

Yellow,
Polygon[{{2,0},{4,1},{4,-1}}],

Black,
Dashed,
Line[{{-1,0},{4,0}}]
}]

Graphics3D[ ] → (x vs y vs z grid)

In a similar way to 2D graphics, we can draw 3D graphics.

Syntax: Same as Graphics[ ], but 3D shapes such as Sphere[ ] and Cone[ ] are used.

Each shape has a way to specify coordinates which you should read in the documentation.

Many of the same directives for 2D graphics can be applied to 3D graphics.

You can interact with 3D graphics and rotate them with your mouse.

Example 4: Draw a chocolate flavored ice cream in a cone from a sphere and a cone. Begin by drawing a yellow cone.  Then add a brown sphere. If you want, add a cherry on top!

Graphics3D[{
Yellow,
EdgeForm[{Thick, Yellow}],
Cone[{{0,0,1}, {0,0,0}},0.5],

Brown,
Sphere[{0,0,1.1},0.48], 

Red,
Sphere[{0,0,1.58},0.1]
},Boxed ->False]

To look at for fun...
Neat Examples from the Wolfram website.

Graphics[ ] and Graphics3D[ ] takes in a list as their argument. The list can be generated by functions such as Table[ ] in stead of being typed out. This allows you to do some arcane black magic.

Graphics[Table[{Hue[t/20],Circle[{Cos[2 Pi t/20],Sin[2 Pi t/20]}]},{t,0,20}]]

Graphics3D[Table[With[{p={i,j,k}/5},{RGBColor[p],Opacity[.75],Cuboid[p,p+.15]}],{i,5},{j,5},{k,5}]]

Challenge: Can you change the picture of the “cube of rainbow cubes” into a “cube of rainbow spheres”?
Double Challenge: Can you change this graphic into a Mathematica Demonstration? For example, use the manipulate function as well as a setter type controller in order to show three different versions of this rainbow cube.  One with a cube of rainbow cubes, another with a cube of rainbow spheres, and finally one with a cube of rainbow 3-D objects of your choice. Then add a slider to change the size of the cubes, spheres, and cones.

(* Answers to Challenges below *)

Graphics3D[Table[With[{p={i,j,k}/5},{RGBColor[p],Opacity[.75],Sphere[p,.15/2]}],{i,5},{j,5},{k,5}]]

Manipulate[Which[button==1,Graphics3D[Table[With[{p={i,j,k}/5},{RGBColor[p],Opacity[.75],Cuboid[p,p+size]}],{i,5},{j,5},{k,5}]],
 button==2,Graphics3D[Table[With[{p={i,j,k}/5},{RGBColor[p],Opacity[.75],Sphere[p,size/2]}],{i,5},{j,5},{k,5}]],
button==3,Graphics3D[Table[With[{p={i,j,k}/5},{RGBColor[p],Opacity[.75],Cone[{p,p+Sqrt[size^2/2]},size/2]}],{i,5},{j,5},{k,5}]]]


,
Control[{{button,1,"shape"},{1->"cube",2->"sphere",3->"cone"},ControlType->SetterBar}],
Control[{{size,0.1,"size"},0.05,0.2,Appearance->"Labeled"}]
]

Using Grid[ ] to organize the layout of your output

Grid is a function that formats expressions into a two dimensional grid. Grid can be used to organize numerical data, graphics, plots, etc.

Grid[ ]

Its argument is a list of rows, where the rows are lists themselves.

Syntax: Grid[ { {(Subscript[a, 11 ]),  (Subscript[a, 12]), (Subscript[a, 13]) } , {  (Subscript[a, 21 ]), (Subscript[a, 22 ]), (Subscript[a, 23 ])} } ]

(* General form of a grid, this one is 2x2 *)

(* Grid[{
{first row first element, first row second element},
{second row first element, second row second element}
},
options
] *)

Example 1: Use Grid to make a table of the following two columns and four rows of information.

({{"gas pressure (atm)", "gas volume (L)"}, {2, 5}, {4, 10}, {3, 7.5`}})

Grid[{
{"gas pressure (atm)","gas volume (L)"},
{2,5},{4,10},{3,7.5}
}
]

Example 2: Now, make the elements to be right-aligned on the right column and left-aligned on the left column.  (You can also choose some alignment/style options by left-clicking below your output and choosing from the option bar that shows up.)

Grid[{
{"gas pressure (atm)","gas volume (L)"},
{2,5},{4,10},{3,7.5}
},
	Alignment -> {{Left,Right}}
]

Options: Like any other Mathematica function, there are multiple options you can add to this function.

Frame->All : Puts a frame around every element.

Frame->True : Frames the entire grid.

Example 3: Change the Frame to True, and observe what happens. Then change the FrameStyle to Red.  Observe the output.

Grid[{
{"gas pressure (atm)","gas volume (L)"},
{2,5},{4,10},{3,7.5}
}, 
	Frame->True, FrameStyle->Red
]

Dividers->{ input } : Enables drawing lines in a variety of positions based on the parameter you choose and the input.

Example 4: For the table from Example3, draw a vertical solid black line between two columns and a horizontal dashed gray line between the first and second rows. Also, change the frame color back to black.

Grid[{
{"gas pressure (atm)","gas volume (L)"},
{2,5},
{4,10},
{3,7.5}
},

 Frame->True,
 Dividers -> {{2->True},
                        {2->Blue,2->Dashed}}
]

Nested Grids

Example 5: Try reproducing the following.

({{"first row"}, {({{"second row, first column", "second row, second column"}})}, {"third row"}})

secondRow = Grid[{
{"second row, first column","second row, second column"}
},
Frame->All,
FrameStyle->Red
];

Grid[{
{"first row"},
{secondRow},
{"third row"}
},
Frame -> All
]

In Studio Exercise V

Make a grid of plotted sine, cosine and tangent functions. Arrange them as seen in the example output below. Use the plot variables defined below. This will require nested grids, which may be easier to handle by defining the internal grids as variables and creating the overall grid with the variables.

({{({{({{Sin(x)}, {}}), ({{Cos(x)}, {}})}})}, {({{Tan(x)}, {}})}})

sinPlot = Plot[Sin[x],{x,0,3},ImageSize -> 150];
cosPlot = Plot[Cos[x],{x,0,3},ImageSize -> 170];
tanPlot = Plot[Tan[x],{x,0,3},ImageSize -> 150];

topGrid = Grid[
{{"Sin(x)","Cos(x)"},
{sinPlot,cosPlot}},
Dividers-> {2->Dashed(* second vertical divider *) ,2->Dotted(* second horizontal divider *)}
];

bottomGrid = Grid[
{{"Tan(x)"},
{tanPlot}},
Dividers->{False (* no vertical dividers *),2->Dotted (* second horizontal divider *)}
];

Grid[
{{topGrid},
{bottomGrid}},
Dividers->{True (* both vertical dividers, the right and left side of the frame*),2->Dashed(* second horizontal divider *)},
Frame-> True (* complete the frame with top and bottom *)
]

(* Not done in class but is another way of tackling the problem *)
(* An additional function is defined to avoid repetitive code *)
gridPlot[title_,expr_] := Grid[
{{title},
{Plot[
expr,
{x,0,Pi},

ImageSize->{150,100}]
}},

Dividers->{{False},
                     {2->Dotted}}
];

(*To make life easier, It would be better to type in the solution in a Layer-by-layer manner*)
(* Layer 1
Grid[
{{top},
{Bottom}},

Frame->True,
Dividers->{{False},
        {2->Dashed}}
]
*)

(* Layer 2
Grid[
{{Grid[
{{gridPlot["Sin(x)",Sin[x]],gridPlot["Cos(x)",Cos[x]]}},

Dividers->{{2->Dashed},
        {False}}
]},
{gridPlot["Tan(X)",Tan[x]]}},

Frame->True,
Dividers->{{False},
        {2->Dashed}}
]
*)

Grid[
{{Grid[
{{gridPlot["Sin(x)",Sin[x]],gridPlot["Cos(x)",Cos[x]]}},

Dividers->{{2->Dashed},
                     {False}}
]},
{gridPlot["Tan(X)",Tan[x]]}},
Dividers->{{True},
                    {2->Dashed}},
Frame->True
]

How to make a demonstration with the Manipulate function

Manipulate: The function Manipulate[ ] allows you to make the output of your code into an interactive environment for the user.  The user can use sliders and click buttons and observe how your output changes as different variables are manually changed.

The Manipulate[ ] function is structured like the following:

Manipulate[
"Line one for calculation";
"Another line of calculation";

"Output"
(*Number, plot, graphics, etc. you would like to show*)
,

"Controls"
(*The variables defined here can change value interactively*)
,

ContentSize->{240,160}
(* Add any other options here *)
]

Here is a bare-minimum of an interactive demonstration. It takes a number as input, and shows a number that is 1 larger as the output.

Manipulate[
(*Calculations*)
y=x+1;

(*Output*)
y,

(*Define variables and controls*)
{{x,0,"input value"},0,10,Appearance->"Labeled"},
{{y,1},ControlType->None},

(*Options*)
ContentSize->{300,40}
]

In Studio Exercise III: The making of a demo

For this exercise you will make a demonstration for the ideal gas model of (Subscript[O, 2]). 
The ideal gas equation goes as follows:

PV=nRT

Where:

R=0.082057338  L atm  (mol^(-1)) (K^(-1))
		n=1 mol

We can rearrange this equation to give the ideal gas pressure as a function of volume and temperature:

P(V,T)=(nRT/V)

The specs of the demo is as follows:
Input:	The input would be the temperature of (Subscript[H, 2]), within the range of 100 K to 500 K.
Output:	The output would be a pressure - volume plot containing the curve at the input temperature. 
	Range for plotted pressure:	 0.1   to  75  atm 
	Range for plotted volume:	 0.1   to    1  L

Exercise: The making of a demo

1. We start by defining the constants and parameters:

(*Physics constants*)
nO2=1.0;(*mol*)
R=0.082057338;(*L atm mol^-1 K^-1 *)

(*Control/plot parameters*)
minV=0.1; (* L *)
maxV=1.0;  (* L *)
minP=0.1;  (* atm *)
maxP=75.0;  (* atm *)
minT=50.0;  (* K *)
maxT=500.0;  (* K *)

(*define functions*)
pressure[V_,T_]:=nO2*R*T/V;

2. For the actual demonstration, we start from the skeleton:

Manipulate[
"Line one for calculation";
"Another line of calculation";

"Output"
(*Number, plot, graphics, etc. you would like to show*)
,

"Controls"
(*The variables defined here can change value interactively*)
,

ContentSize->{240,160}
(* Add any other options here *)
]

3. Fill in the controls. For this demonstration, we only need controls for temperature:

Manipulate[
"Line one for calculation";
"Another line of calculation";

"Output"
(*Number, plot, graphics, etc. you would like to show*)
,
(*{T,minT,maxT}*) (* Basic slider *)
Control[{{T,298,"temperature"},minT,maxT}](* Descriptive slider *)
(*The variables defined here can change value interactively*)
,

ContentSize->{240,160}
(* Add any other options here *)
]

4. Fill in the calculations and output. For this demonstration, our output is a plot and we do not need additional calculations.

Manipulate[
(*No calculation is needed*)

Plot[
pressure[V,T],
{V,minV,maxV},

PlotRange->{{minV,maxV},{minP,maxP}}
]
(*Number, plot, graphics, etc. you would like to show*)
,

Control[{{T,298,"temperature"},minT,maxT}]
(*The variables defined here can change value interactively*)
,

ContentSize->{240,160}
(* Add any other options here *)
]

5.  After testing the code, we should tweak the appearance of the controls and outputs to make the demonstration more user-friendly.

Manipulate[
(*No calculation is needed*)

Plot[
pressure[V,T],
{V,minV,maxV},

PlotRange->{{minV,maxV},{minP,maxP}},
PlotLabel->"pressure of hydrogen in ideal gas limit",
AxesLabel->{"volume (L)","pressure (atm)"}
]
(*Number, plot, graphics, etc. you would like to show*)
,

Control[{{T,298,"temperature"},minT,maxT,Appearance->"Labeled"}]
(*The variables defined here can change value interactively*)
,

ContentSize->{400,300},
SaveDefinitions->True (*Important!*)
(* Add any other options here *)
]

6. Science check: We’ve created a nice looking demo showing the ideal gas limit with oxygen. However, we have some science bugs in our code. The boiling temperature of oxygen is ~90 K so we shouldn’t be looking at any temperatures below that. Also, we’re looking at some fairly high pressures  and low temperatures, so the ideal gas limit could be failing. Below, we’ve added in the van der Waals equation to attempt to better describe the behavior of the oxygen gas. 
Remember, bugs in your code can be programming or science problems and the science ones are often harder to notice, as the code will not give an error. Make sure to be checking the validity of your equations and limits as you are creating your demo.

Clear[minT];
minT = 100; (* K *)
aO2 = 1.36; (* (L^2) atm (mol^(-2)) *)
bO2 = 0.0318; (* L (mol^(-1)) *)
pVanderWaals[V_,T_] := nO2 * R * T/(V - nO2 * bO2) - nO2^2 * aO2/V^2;

Manipulate[
(*No calculation is needed*)

Plot[
{pressure[V,T],pVanderWaals[V,T]},
{V,minV,maxV},

PlotRange->{{minV,maxV},{minP,maxP}},
PlotLabel->"pressure of hydrogen in ideal gas limit",
AxesLabel->{"volume (L)","pressure (atm)"},
PlotLegends->{"ideal gas", "van der Waals"}
]
(*Number, plot, graphics, etc. you would like to show*)
,

Control[{{T,298,"temperature"},minT,maxT,Appearance->"Labeled"}]
(*The variables defined here can change value interactively*)
,

ContentSize->{550,300},
SaveDefinitions->True (*Important!*)
(* Add any other options here *)
]

Plot[ ] and Manipulate[ ] have a lot of additional options and the same goes for other functions that you may use in your project. 
While it is impossible to cover them all in this tutorial, you can always go to the Mathematica website for information.

Additional (and advanced) resource that you may find useful:
Intro to Manipulate[ ]
Control objects and Dynamic[ ]
Advanced Manipulate[ ]
Pure functions

Mathematica Demonstrations Project

All Mathematica Demonstrations Project demos use the function, Manipulate, once in the code.

At the end of this semester, you will have also created one Demo for the Mathematica Demonstrations Project, as well as for other Chem 230/260 students, that uses the Manipulate function.

In the following take home exercise, we will help you make your first Demo.

Take-Home Exercise

For the take-home exercise, you will create a beaker filled with blue liquid that can be manipulated in both its height in the beaker and in concentration of the color of the liquid. Your end demonstration should look like this, with minor modifications allowed for its appearance:

Some starting steps:
1. Open up the Initialization Code for the take-home assignment on Canvas. You can code input and do Shift + Enter to get the output in a notebook just like you do in the tutorial. 

2. Look back at the Graphics3D section and Example3 (the ice cream cone) on slide 11 to remember how to make 3D graphics. You should start by building a static beaker with liquid.  You will need to look at the Mathematica reference to understand how to build cylinders. 

3. Build the Manipulate[ ] function around the static beaker following the Manipulate section on slide 15 and In-Studio Exercise III.  

This should take you around an hour to complete. If it is taking longer than that,  that is definitely ok, just make sure to ask a peer leader or GSI for help on what you are stuck on! It is usually useful when asking for help via email to include your code as an attachment as well.

End Day 2 (Remember, save your work!)

Conditionals

Conditional expressions have values of either True or False.

The operators == , != , <= , >= , < and > compares the value of two numbers. Pay attention to the difference between set (or assignment) operator  =  and equal operator  == .

Example 1: Write your prediction of the following conditional expressions as a comment next to each line, then evaluate to see if you are right.

one=1;two=2;three=3;

one==1
two!=2
three≥3
three≤2
two>three
two<three

The operators && , || and ! are the logical And, Or and Not operators, respectively. They take conditional expressions and returns a value of True or False.

Example 2: Predict the result of the following code, then evaluate to see if you are right.

(one == 1) && (two ≠ 2)
(three ≥ 3) || (three ≤ 2)
!(two > three)

Functions that utilize conditional expressions in Mathematica include If[ ] and While[ ].

If[ ]

Syntax: If[condition, true_expr, false_expr].

Evaluates true_expr if the condition is True, or evaluates false_expr if the condition is False.

Example 3: Define a variable testVal as a number. Write an If statement that evaluates to “In bounds” if testVal is in between 10 and 20, or “Out of bounds” if otherwise.

testVal = 15;
(* Give testVal some value *)

If[testVal ≥ 10 && testVal ≤ 20, 
"In bounds", 
"Out of bounds"]

While[ ]

Syntax: While[condition, body]

Evaluates body repeatedly until the condition becomes False.

Watch out for infinite loops! Use Evaluation > Abort Evaluation to break an infinite loop.

Example 4: Calculate the sum of all the prime numbers that are smaller than 100. Use Prime[n] for the (n^th) prime number.

sum=0;n=1;
While[Prime[n]≤100,
sum = sum + Prime[n];(*May also introduce += *)
(* n = n + 1 *) (* same thing as n += 1 *)
n += 1;
]
sum

Which[ ]

Syntax: Which[(Subscript[test, 1]), (Subscript[value, 1]), (Subscript[test, 2]), (Subscript[value, 2]), ...  ]

Evaluates each test until one is true.

It will return the value from the first true test, even if multiple tests are true.

Example 5: Assign a variable to a Which statement using testVal and two true tests then evaluate.

(* want to remind ourselves what testVal is *)
"testVal is " testVal (* Mathematica will print variables before strings *)

(* this will put items in a row in the order listed *)
Row[{"testVal is ", testVal}]

testWhich = Which[
testVal == 10, "testVal equal to 10", 
testVal < 50, "testVal less than 50", 
testVal < 20, "testVal less than 20"
];

testWhich

Rules and Substitutions

Here is how to plug in a specific value to an expression.

x^2+10x+20 /. x->5

The general syntax for substitution: expr /. rule

A rule is a special expression with an arrow in it.

Technically, the options in Plot[ ] and Grid[ ] are also rules. However, those are used in another way and has nothing to do with our discussion here.

The ReplaceAll operator /. threads through lists, but some special syntax apply.

Example 1: Use replace all with a list of x,  (x^2) , and x + 1.

{x,x^2,x+1}/. x-> 5

Example 2: Evaluate the following input to see how the replacement works with lists.

x /. {x->14,x->19,x->10} (* Applies the replacements one by one *)
x1+x2+x3/.{x1->14,x2->19,x3->10}(* How this is meant to work *)

Example 3: Use ReplaceAll to create a list of 14, 19, and 10.

x /. {{x->14},{x->19},{x->10}} (* Thread through nested lists *)

How to Solve Mathematica Equations

Solve[ ] and NSolve[ ]

Solves basic (e.g. polynomial) equations and systems of equations analytically or numerically, respectively.

Syntax: Solve[exp, var]. The first argument being a conditional expression that stands for the equation.

Example 1: First define a function poly3(x) equal to (x^3) + 3(x^2) - 6x - 8= 0. Use Solve[ ] to find the three roots of this third-order polynomial.

Clear[x];
poly3[x_] := x^3 + 3x^2  - 6 x - 8 == 0
Solve[poly3[x], x]

The solution is given in the form of a nested list of rules, which can be used for replacement.

Example 2: Extract the numbers from the solution of the polynomial in Example1 using x /. {...}

roots= x /. Solve[poly3[x], x]

To get a specific element from the list, use listName[[ index ]]

The index starts from 1 (not 0).

Example 3: Retrieve the first root value.

roots[[1]]

Solving simultaneous equations.

Example 4: Solve (x^2) + (y^2) = 1  and x = 2y.

Clear[x,y];
Solve[x^2 + y^2 == 1 && x==2y, {x,y}]

FindRoot[ ]

Finds ONE root of a function numerically from a given starting point. It will automatically choose the root closest to the starting value.

Syntax: FindRoot[expr, {var, startpoint }]

Example 5: Use FindRoot[ ] on the third-order polynomial from earlier.

FindRoot[poly3[x], {x,0}]

Programming Style

Following a consistent, easy to read style makes your program easier to read and understand.

Use proper indentation

In most cases, you have nested functions with multiple brackets. Using proper indentation helps you to easily locate different functions and pieces of code. Reading the second example is far easier than the first one:

Unorganized style

Grid[{{Show[Plot[Sqrt["value 1"],{k,0,Pi},PlotRange->{{0, Pi}, {0, 150}},AxesLabel->{"θ (radians)","force (N)"},PlotStyle->{Red, Thickness[0.003]},ImageSize->250,PlotLabel->Style["total force on charge 1",FontSize->8]],Graphics[{PointSize[0.025],Point[Dynamic[ {k, Sqrt["value 2"]}]]}]]}}]

Better, Organized Style

Grid[{{
Show[
Plot[
Sqrt["value 1"],{k,0,Pi}, PlotRange->{{0, Pi}, {0, 150}},AxesLabel->{"θ (radians)","force (N)"},PlotStyle->{Red, Thickness[0.003]},ImageSize->250, 
			PlotLabel->Style["total force on charge 1",FontSize->8]
],
Graphics[{PointSize[0.025],Point[Dynamic[ {k, Sqrt["value 2"]}]]}]
 ]}
}]

(* Use notes so that a person new to your code can follow your work *)

Use consistent style. No matter which one you choose, stick to your choice.

Don’t make style an afterthought.

Use proper and meaningful names for defining your variables.

Don’t name your variables something incomprehensible such as  x, y, tt. Instead, use meaningful names like “initialTemp” or “inputVal”.

In Studio Exercise IV

Look at slide 24 and do not evaluate the cells until you skim through the code. With your group, spend 10 minutes and describe what each piece of the code is doing. After ten minutes, look at slide 25 and continue this exercise.  As a group discuss the benefits of having notes in your code.

Exercise IV
	
Code with no notes, poor variable names, and few indents:
	Also note that the demo changes size sometimes when moving the slider, which is not allowable for published demos. This is fixed in the 
	better code shown on the next slide by introducing the function NumberForm[], which allows you to control the number of decimal 
	places shown.

Eg=2.81*10^-19;
h=6.626*10^-34;
me=1.18*10^-31;
mh=4.09*10^-31;
c=3*10^8;

Manipulate[
e = (Eg+(h^2/(8*(r*10^-9)^2))*((1/me)+(1/mh)));
w=(h*c)/e; 
color=w *10^9;
bandgap = 6.2415*10^18*e;
Row[{Graphics3D[{ColorData["VisibleSpectrum"][color],Sphere[{0,0,0},r]},Axes->False,Boxed->False,PlotRange->6,ImageSize->{200,300}],Text[Style[Grid[{{"conduction band"},{},{Row[{"band gap = ",bandgap," eV"}]},{},{"valence band"}}],FontSize->12]],
Graphics[{Line[{{1.5,.4*bandgap},{-1.5,.4*bandgap}}],Line[{{1.5,-.4*bandgap},{-1.5,-.4*bandgap}}],Opacity[.95,Gray],PointSize[0.07],Point[{{0,.4*bandgap}}], Opacity[.4,Gray],PointSize[0.07],Point[{{0,-.4*bandgap}}],Opacity[0],EdgeForm[],Rectangle[{1.6, 2.2},{-1.6, -2.2}] },PlotRangePadding->0.5,ImageSize->{200,275}]}] ,Control[{{r,1,"radius (nm)"},1,5,Appearance->"Labeled"}],SaveDefinitions ->True
]

Code with notes, descriptive variable names, and indents and line breaks:
	This demo does not change size when moving the slider because of the function NumberForm[] around the outputted bandgap energy, 
	which allows you to control the number of decimal places shown.

energyGap=2.81*10^-19;  (* bulk band gap energy J *)
h =6.626*10^-34; (* Planck's constant Js *)
massElectron=1.18*10^-31;(* mass of electron kg *)
massHole=4.09*10^-31;   (* mass of hole kg *)
c=3*10^8; (* speed of light m/s *)

Manipulate[
(*equation that uses given radius to provide energy in J *)
energy = (energyGap+(h^2/(8*(radius*10^-9)^2))*((1/massElectron)+(1/massHole)));
(*equation that uses energy to provide wavelength in m *)
wavelength=(h*c)/energy; 
(*equation that converts wavelength in m to nm *)
color=wavelength *10^9;
(* equation that converts the band gap energy from J to eV *)
bandgap = 6.2415*10^18*energy; 

Row[{
(* Nanoparticle with color given by equation *)
Graphics3D[{
ColorData["VisibleSpectrum"][color],
Sphere[{0,0,0},radius]
},
Axes->False,Boxed->False,PlotRange->6,ImageSize->{200,300}
], 

(* Output of band gap value and labeling of conduction band and valence band *)
Text[
Style[
Grid[{
{"conduction band"},
{},
{Row[{"band gap = ",NumberForm[bandgap,{4,3}]," eV"}]},
{},
{"valence band"}
}],
FontSize->12]], 

Graphics[{
(* Conduction band *)
Line[{{1.5,.4*bandgap},{-1.5,.4*bandgap}}],
(* Valence Band *)
Line[{{1.5,-.4*bandgap},{-1.5,-.4*bandgap}}],
(* Dot on conduction band *)
Opacity[.95,Gray],PointSize[0.07],Point[{{0,.4*bandgap}}],
(* Dot on valence band *) 
Opacity[.4,Gray],PointSize[0.07],Point[{{0,-.4*bandgap}}], 
(* Invisible rectangle to maintain proportions with moving bands *)
Opacity[0],EdgeForm[],Rectangle[{1.6, 2.2},{-1.6, -2.2}] 
},
PlotRangePadding->0.5,
ImageSize->{200,275}
]  
}]
,
(* radius of the nanoparticle in nm *)
Control[{{radius,1,"radius (nm)"},1,5,Appearance->"Labeled"}],
SaveDefinitions-> True
]

Note: The input from Exercise IV is adapted from a demonstration describing the color tuning in CdSe Nanocrystals. View the demonstration and demonstration code here: Color Tuning of CdSe Semiconductor Nanocrystals

How to get your demonstration published

As alluded to previously, The Wolfram Demonstrations Project has some requirements to keep all of its published tutorials uniform.

Only capitalize proper nouns in the user-interface of your demonstration.

Make sure your demonstration does not change sizes when you play with sliders or change the size of your window.

Only use ONE Manipulate function (no nested Manipulate).

Keep in mind that there are size limitations.  Try to keep your demo pretty small in size, but still easy to read.

Make your variable very specific.  Some variables, such as D, N, E, are actually stored by Mathematica and you cannot use them in a demonstration.  If you encounter this, the solution to this problem is easy. Simply rename your variables.

Read the following link. When you are ready to publish your demonstration, check this link again to make sure you are following these guidelines.

In the meantime, don’t be afraid to be creative with your demo and push the boundaries.

Authoring Demonstrations

Extra Practice: Debugging a File

In each of the following four codes, “SuperpositionofWaves1.nb”, “SuperpositionofWaves2.nb”, and “SuperpositionofWaves3.nb”, “SuperpositionofWaves4.nb” there is one bug (Each of these files can be found in the CTools folder). If you would like extra practice with debugging, you can work on correcting the bugs and checking the solutions to see if you found them.

End

Fun Demo

End Day 3 (Remember, save your work!)