Introduction to Mathematica for High School Math (for Students and Teachers) #4
Author
Ruth Dover
Title
Introduction to Mathematica for High School Math (for Students and Teachers) #4
Description
Introduction to Mathematica for High School Math
Category
Educational Materials
Keywords
Mathematics, education
URL
http://www.notebookarchive.org/2021-09-6h1zkpf/
DOI
https://notebookarchive.org/2021-09-6h1zkpf
Date Added
2021-09-14
Date Last Modified
2021-09-14
File Size
36.06 kilobytes
Supplements
Rights
Redistribution rights reserved



Tutorial 4: Lists and Tables
Tutorial 4: Lists and Tables
R. Dover, IMSA
Lists and Tables
Lists and Tables
Curly braces are used a lot in Mathematica®. They are used primarily for lists of objects, but they are also used for indices and for domains of functions.
First, we will create a short list and name it. Then we will perform a few simple operations on it:
mylist={2,3,5,8,13}
2
mylist
mylist+1
Clearly, the need may come to generate a list. Here, this is called a :
Table
mytable=Table[3i,{i,1,5}]
Note that the result is in fact a list, since the output is in curly braces. Following is another type of command that is frequently used with lists. Try some other numbers besides 4 and be sure you understand what it does:
mytable[[4]]
By default, the step size for a Table is 1, though this may be controlled by an optional value within the iterator. Also, we make a table of two values in the following:
Table[{x,Cos[x]},{x,0,2π,π/4}]
This is rather difficult to view. Use the command on the last command. (Either type after the command or put around the entire command. Notice the capital letters on both words, with no space between them, since it is one Mathematica command.)
TableForm
//TableForm
TableForm[]
Of course, there are more possibilities on the palette: under Basic Commands, the fifth button is List. There is a button for a basic Table, some commands for lists, and there is a drop-down button for more possibilities.
Define a function of your choice. Then create a table that will show ordered pairs for by steps of 0.2, and display it with TableForm.
f
(x,f(x))
0≤x≤5
When you are done, be sure to clear , and .
f
mylist
mytable
More Numerics
More Numerics
Did you notice that the terms in the last table you created came out in decimal form? Curious. Previously, we had to tell Mathematica to give answers in decimal form. Here, note that you entered decimals for the step size. Decimals in, decimals out—just as your calculator does. Try this on a couple of other commands.
Another Option
Another Option
Here is another way to create a list—one that is often quite useful:
Range[6]
Range[1,10,2]
Displaying Lists: A Brief Intro
Displaying Lists: A Brief Intro
littlelist={1,2,4,4,5}
ListPlot[littlelist]
ListLinePlot[littlelist]
PieChart[littlelist]
BarChart[littlelist]
And as you can guess, all of these may be controlled in lots of ways: colors, labels, etc.
Vectors
Vectors
Now we are going to create and name two vectors, and . (The letters are not capitalized to distinguish them from built-in names.) Vectors are simply lists:
v
w
v={2,-5,1};w={1,2,-3}
Find the vector . Then find :
4v
2v−3w
4v
Execute the next cell. What does the program assume about ?
c
c+v
The dot product is denoted by , with a period between the two vectors. Try it. Then ask Mathematica if this operation on these vectors is commutative.
v.w
Try the cross product. As usual, this may be typed; or in the palette, under Basic Commands, choose the fifth button for List that you looked at previously. At the bottom right, find Vectors, with an assortment of commands:
Cross[v,w]
Alternatively, you may use a cute little "" created by Esc cross Esc. (That is not multiplication!):
vw
When finished, clear and .
v
w
Matrices
Matrices
Matrices may be expressed in two ways. Either way, Mathematica sees a matrix as a list of lists. First we will define by using the palette:
mat1
mat1=
3 | 5 |
-1 | 2 |
Curious output. This looks like the list of lists mentioned earlier with braces within braces. Select the cell by clicking the bracket on the right. Under the Cell menu, select Convert to and choose TraditionalForm. This will look nicer, but Mathematica is sometimes less confident of this notation. Note the new markings on the cell bracket. Alternatively, create as follows and, on another line, use the command :
mat2
MatrixForm[mat2]
mat2={{2,0},{3,1}}
Several commands work as expected on matrices. Find 3mat1: find the determinant by using , and then find , the third power of the matrix. Express these using . Also, you may type after any expression.
Det[mat1]
MatrixPower[mat1,3]
MatrixForm
//MatrixForm
Then find the and the of mat2.
Transpose
Inverse
Now find mat1+mat2 and mat1.mat2, using the period to represent multiplication as we did before. What happens if one enters ? Try it.
2
mat1
Check this out. What should the result be?
a | b |
c | d |
a | b |
c | d |
"Fix" that by using on the preceding command. Look better?
Simplify
Whatever Size You Want
Whatever Size You Want
Back to the palette. Under Basic Commands, choose the fourth button, the one that looks like a little matrix! Many buttons should be self-explanatory. Define mat3, and then click the basic 2×2 matrix. Then click Add Row or Add Column as you wish. Fill in the boxes.
Now determine what each of the following commands does. (Hopefully your matrix is not too small!):
mat3[[2]]
mat3[[3,2]]
Exercises
Exercises
1
.Define and . Create a table of values to show , and on the interval with a step size of 0.25. Use TableForm to display the results. What do you notice?
f(x)=sin(x)
g(x)=-.042+1.31x-0.05
2
x
x
f(x)
g(x)
−1≤x≤4
2
.Find the dot product of the vectors and . (What does the result tell you about the two vectors?)
〈6,–8〉
〈4,3〉
3
.Name and create a 4×2 matrix. Enter your own values. Then name and create a 2×3 matrix. Multiply the two matrices and display the result as a matrix.


Cite this as: Ruth Dover, "Introduction to Mathematica for High School Math (for Students and Teachers) #4" from the Notebook Archive (2021), https://notebookarchive.org/2021-09-6h1zkpf

Download

