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



Tutorial 12: Data
Tutorial 12: Data
R. Dover, IMSA
Plotting+Exercise
Plotting+Exercise
We will begin by using a table to create a list of points, and then we will show a few plots of these points. We have a list of lists:
onelist=Table[{x,2+Sin[x]+RandomReal[]},{x,0,6,.4}]
ListPlot[onelist]
This needs some work. Here are a couple of options:
ListPlot[onelist,PlotStyle{PointSize[Large],Red},AxesOrigin{0,0}]
ListLinePlot[onelist,PlotStyle{Thick,Red},AxesOrigin{0,0}]
Exercise
Exercise
Define a function . Now, name and create a table of ordered pairs , where values of are the integers from 1 to 50. Use numerical values. Not much of a pattern?
a(n)=cos(n)
(n,a(n))
n
Use on your table. Still not much of a pattern? Then increase the integer range to extend from 1 to 300. Plot this. Then add another option: . Now how is the pattern?
ListPlot
AspectRatio→1/3
Regression+Exercise
Regression+Exercise
We will begin with some more data:
somedata={{.1,3.1},{.6,3.7},{1.4,3.9},{1.9,3.2},{2.3,2.6},{2.5,2},{2.7,1.8},{3,1.2},{3.1,.5},{3.6,0},{4,-.3},{4.2,-.4},{5,.2},{5.3,.8},{5.7,1.4},{6,2.2}}
Use ListPlot to show this, naming the plot . Make the points big enough to see:
graphdata
graphdata=ListPlot[somedata,PlotStylePointSize[Medium]]
So how about a cubic? The following command will fit your data as well as possible to a polynomial with constant, linear, quadratic and cubic terms, where is the variable:
x
func1=Fit[somedata,{1,x,,},x]
2
x
3
x
We need to see how reasonable this is. Graph on the interval , naming the plot :
func1
[0,6]
graph1
graph1=Plot[func1,{x,0,6}]
We next want to show the two graphs together. The command is necessary to put two different types of graphics ( and ListPlot) together:
Show
Plot
Show[graphdata,graph1]
Exercise
Exercise
We will try a different regression now using some trig. We will do essentially the same thing, using and instead of some polynomial terms. But again, we are looking for a "linear combination" of the given terms. We will call this :
Sin[x]
Cos[x]
func2
func2=Fit[somedata,{1,Sin[x],Cos[x]},x]
Create the plot of .
graph2
func2
Show the graph of the data and together.
graph2
Then show all three graphs together. It may be good to change one or more of your graphs to add some formatting. Which is better?
One more step: The last two regressions were "linear combinations." This time, we will use the command . This allows you to ask Mathematica® to match the data to any function you create. We need to give the list of the data, the function and the parameters, and finally, you state your variable. Here, we will try to model a general sinusoidal function:
FindFit
FindFit[somedata,a+bSin[cx]+d,{a,b,c,d},x]
OK, now how do I reconstruct the function (easily)? A creative use of . Recall that tells Mathematica to replace the variables by the numbers after the arrows:
/.%
/.
func3=a+bSin[cx]+d/.%
As before, make a new graph of the function and then show the data and the function together. Not so hot in this case, but you get the idea.


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

Download

