A Poor Example of a Project - But Gives Some Direction

Similar documents
MSE 310/ECE 340. Instructor: Bill Knowlton. Initialize data Clear somedata, someplot. Place data in list somedata

Fitting Data in Mathematica

School of Materials Science & Engineering. Problem Set 3 Solutions

Concepts of Approximate Error: Approximate Error, Absolute Approximate Error, Relative Approximate Error, and Absolute Relative Approximate Error

School of Materials Science & Engineering

Alpha Decay. 1. Introduction. 2. Constants, Commands, and Functions. 2.1 Constants:

Problem Set 2 Solutions

Calculus I Homework: The Derivatives of Polynomials and Exponential Functions Page 1

Mathematica for Calculus II (Version 9.0)

M&M Exponentials Exponential Function

Lab 1 Uniform Motion - Graphing and Analyzing Motion

Chapter 9 Ingredients of Multivariable Change: Models, Graphs, Rates

5-Sep-15 PHYS101-2 GRAPHING

Introduction to MoLEs Activities Computer Simulations *

Mathematics Textbook Correlation to the 2016 Algebra I Standards of Learning and Curriculum Framework

Six Sigma Black Belt Study Guides

Quantum Mechanics using Matrix Methods

Mathematica for Rogawski's Calculus

Applied Calculus. Review Problems for the Final Exam

CURRICULUM GUIDE Algebra II College-Prep Level

Students should read Sections of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

A First Course on Kinetics and Reaction Engineering Example 14.3

1 Introduction to Minitab

Boyle s Law: A Multivariable Model and Interactive Animated Simulation

Introduction to ArcMap

Seymour Public Schools Curriculum

converges to a root, it may not always be the root you have in mind.

A First Course on Kinetics and Reaction Engineering Example 15.2

Lab #10 Atomic Radius Rubric o Missing 1 out of 4 o Missing 2 out of 4 o Missing 3 out of 4

Hit the brakes, Charles!

Linear Motion with Constant Acceleration

EXPERIMENT 7: ANGULAR KINEMATICS AND TORQUE (V_3)

Photosynthesis and Respiration. Evaluation copy

Nonlinear Regression. Summary. Sample StatFolio: nonlinear reg.sgp

Practice Midterm Exam 1 March, 2011

MS Algebra 1 Scope and Sequence Quarter 1 Overview

Reteach 2-3. Graphing Linear Functions. 22 Holt Algebra 2. Name Date Class

Prentice Hall Algebra 1, Oklahoma Edition 2011

1 A Review of Correlation and Regression

Algebra II Notes Quadratic Functions Unit Applying Quadratic Functions. Math Background

Math 253 Homework due Wednesday, March 9 SOLUTIONS

Saltwater Conductivity: Trends of the Periodic Table

STATE UNIVERSITY OF NEW YORK COLLEGE OF TECHNOLOGY CANTON, NEW YORK COURSE OUTLINE MATH INTERMEDIATE ALGEBRA

4:3 LEC - PLANNED COMPARISONS AND REGRESSION ANALYSES

Photosynthesis and Respiration

Algebra I Assessment. Eligible Texas Essential Knowledge and Skills

Utah Core State Standards for Mathematics Secondary Mathematics I

Instructional Calendar Accelerated Integrated Precalculus. Chapter 1 Sections and 1.6. Section 1.4. Section 1.5

Chapter 2. Review of Mathematics. 2.1 Exponents

An area chart emphasizes the trend of each value over time. An area chart also shows the relationship of parts to a whole.

ASSIGNMENT 3 SIMPLE LINEAR REGRESSION. Old Faithful

Sample Mathematica code for the paper "Modeling a Diving Board"

Determining the Conductivity of Standard Solutions

TIphysics.com. Physics. Bell Ringer: Determining the Relationship Between Displacement, Velocity, and Acceleration ID: 13308

PHYSICS LAB. Newton's Law. Date: GRADE: PHYSICS DEPARTMENT JAMES MADISON UNIVERSITY

Your work from these three exercises will be due Thursday, March 2 at class time.

East Penn School District Secondary Curriculum

Calculus I with Pre-Calculus. Algebra II or Pre-Calculus.

H. Diagnostic plots of residuals

Dept. of Materials Science and Engineering. Electrical Properties Of Materials

Correlation with College Board Advanced Placement Course Descriptions

Introduction to Uncertainty and Treatment of Data

Investigating Weather and Climate with Google Earth Teacher Guide

I. Pre-Lab Introduction

TEACHER NOTES SCIENCE NSPIRED

Student Guide: Chapter 1

Reactor Design within Excel Enabled by Rigorous Physical Properties and an Advanced Numerical Computation Package

EDF 7405 Advanced Quantitative Methods in Educational Research MULTR.SAS

Mathematica Project 3

Trinity Christian School Curriculum Guide

EXCELLING WITH BIOLOGICAL MODELS FROM THE CLASSROOM T0 RESEARCH

Investigation of Tangent Polynomials with a Computer Algebra System The AMATYC Review, Vol. 14, No. 1, Fall 1992, pp

2: SIMPLE HARMONIC MOTION

Green s Functions with Reflection

Chapte The McGraw-Hill Companies, Inc. All rights reserved.

Soc 63993, Homework #7 Answer Key: Nonlinear effects/ Intro to path analysis

Module 2A Turning Multivariable Models into Interactive Animated Simulations

Ratio of Polynomials Fit Many Variables

Ratio of Polynomials Fit One Variable

Calculus I Practice Test Problems for Chapter 2 Page 1 of 7

Package RootsExtremaInflections

MAT 17A - UHP - DISCUSSION #10 December 1, 2015

Computer simulation of radioactive decay

Northwood High School Algebra 2/Honors Algebra 2 Summer Review Packet

Adlai E. Stevenson High School Course Description

The EpH module. Table of Contents. Section 3

CURRICULUM CATALOG. Algebra I (3130) VA

Assignment 1: Molecular Mechanics (PART 1 25 points)

Chapter 3 Engineering Solutions. 3.4 and 3.5 Problem Presentation

Project 2 by Kayli-Anna Barriteau

Student Study Session Topic: Table Problems

Graphical Analysis and Errors MBL

Bilinear Transformations via a Computer Algebra System

Common Course Numbers, Titles, Rationale, Content

Remember that C is a constant and ë and n are variables. This equation now fits the template of a straight line:

Introduction to Computer Tools and Uncertainties

Prentice Hall Calculus: Graphical, Numerical, and Algebraic AP* Student Edition 2007

Static and Kinetic Friction

Linear Regression. Linear Regression. Linear Regression. Did You Mean Association Or Correlation?

Physicist's Introduction to Mathematica

Transcription:

A Poor Example of a Project - But Gives Some Direction Bill Knowlton Materials Science & Engineering Electrical & Computer Engineering Boise State Unversity The idea behind this example is two-fold: 1. To demonstrate some of the analytical capabilities of Mathematica for which the student may use to examine physical concepts when provided data and equations. 2. To demonstrate the below-minimum amount of computational work that is required for a project in this course Note: The comments and discussion on the data and results of the manipulation of the data in this example and the labeling (arrows, text,&/or legends) of the plots are below the minimum required. Ideal Gas Law Example In this example project, we will examine the ideal gas law [1] in several ways: - Plot the ideal gas law examining pressure as a function of volume and temperature (i.e., p=p(v,t) ) using several different approaches 1. Using the Range[ ] and Evaluate[ ] commands 2. Using the Table[ ] and Show[ ] commands 3. Using the Manipulate[ ] command - Fit ideal gas law data using several approaches 1. Using the Manipulate[ ] command 2. Using the NonlinearModelFit[ ] curve fitting command with several error analyses 1. Using the Range[ ] and Evaluate[ ] commands Here, the Ideal gas law defined as a function where p, v, n, and T are the pressure (atm), volume (liters), number of moles (moles), and temperature (K), respectively. The range of temperatures is defined using the command Range[ ]. The Evaluate[ ] command with the Range[ ] command allow a function to be plotted as a function of two variables. In the example below, pressure is plotted as a function of volume and temperature. The command is good for plotting 3 variables on a 2D plot.

2 Project Example.nb In[1]:= Clear v, R, T, p, n initialization of variables p v_, n_, T_ : n R T Ideal gas law defined as a function where p, v v, n, and T are the pressure, volume, number of moles, and temperature, respectively Constants R.826; ideal gas constant, atm L mol K imin 2; imax 5; step 5; T Range imin, imax, step ; defining the temperature range plots Plot Evaluate p v, 1, T, v, 1, 1, Frame True, GridLines Automatic, PlotRange, 1,, 5, PlotStyle RGBColor,, 1, FrameLabel "v L ", "p atm ", PlotLabel "p vs T for T 2 5K & n 1 mole" 5 4 Out[6]= p atm 3 2 1 2 4 6 8

Project Example.nb 3 Adding arrows and text to a plot can be done several ways. Below, I just copied and pasted the plot and then used Drawing Tools under the Graphics menu. 5 4 In[7]:= p atm 3 2 Increasing Temperature 1 2 4 6 8 1 v L 5 4 3 Increasing Temperature Out[7]= p atm 2 1 2 4 6 8 1 v L Comment on the plot: From the isotherm plot, it can be seen that pressure is inversely proportional to volume - that is, as volume increases, pressure decreases. Additionally, as temperature increases both pressure and volume increase demonstrating that pressure and volume are directly proportional to temperature. Note that labels and arrows have been added to help guide the reader.

4 Project Example.nb 2. Using the Table[ ] and Show[ ] commands - Good for plotting 3 variables on a 2D plot In the example below, pressure is plotted as a function of volume and temperature using the Table[ ] command, which allows a function generate data from an equation that is a function of one or more varialbes - in this case, two variables. The Table is named as another variable and then the Show[ ] command is used to plot the data in the table. In[8]:= Clear v, R, T, p, pressureplots p v_, n_, T_ : n R T v Constants R.826; atm L mol K pressureplots Table Plot p v, 1, T, v, 1, 1, Frame True, GridLines Automatic, PlotRange, 1,, 5, PlotStyle RGBColor,, 1, FrameLabel "v L ", "p atm ", PlotLabel "p vs T for T 2 5K & n 1 mole", T, 2, 5, 5 ; Show pressureplots 5 p vs T for T 2 5K & n 1 mole 4 Out[12]= p atm 3 2 1 2 4 6 8 Comment on the plot: The Table[ ] command produces the same isotherm plot as when using the Evaluate[ ] & Range[ ] commands. Note that labels and arrows need to be added to the plot to help guide the reader.

Project Example.nb 5 2. Using the Manipulate[ ] command - good for seeing trends in an equation and rough fitting of data with a particular equation A more interactive method to examine the effect of multiple variables in a plot is to use the Manipulate[ ] command. In the example below, the plot of Pressure versus Volume taken from above and wrapping the Manipulate[ ] command around it with the addition of both temperature and the number of moles results in the same P vs V plot plus two levers: temperature and moles. The levers of each can be moved and the plot will change accordingly. In[13]:= Clear v, R, T, p p v_, n_, T_ : n R T v Constants R.826; atm L mol K Plots Manipulate Plot p v, n, T, v, 1, 1, Frame True, GridLines Automatic, PlotRange, 1,, 5, PlotStyle RGBColor,, 1, FrameLabel "v L ", "p atm ", PlotLabel "p vs T for T 2 5K", T, 3, "Temperature K ", 1, 5, 5, n, 1, "n moles ",.1, 5,.1 both temperature and number of moles can be changed Temperature K n moles 5 p vs T for T 2 5K 4 Out[16]= 3 p atm 2 1 2 4 6 8 v L Comment : Increasing either the moles or the temperature by moving the slides from left to right increases the pressure. Note that by clicking on the + results in the actual value of the corresponding variable to be displayed.

6 Project Example.nb We can also import pressure versus volume data In[57]:= Clear v, R, T, p p v_, n_, T_ : n R T v Constants R.826; atm L mol K Importing data; Note: to insert the location of your file, use "Insert" from pull down menu and then select "File Path" data Import "D:\\Bill\\Bsu\\Courses\\MSE 51 ElecOptDielProps\\Projects Exams Quizzes MSE 51 \\Projects\\pressure.csv" Plots dataplot ListPlot data, Frame True, GridLines Automatic, PlotStyle RGBColor, 1, 1, AbsolutePointSize 1, FrameLabel "v L ", "p atm " Manipulate Show Plot p v, n, T, v,.1, 1, Frame True, GridLines Automatic, PlotRange, 1,, 14, PlotStyle RGBColor,, 1, FrameLabel "v L ", "p atm ", PlotLabel "p vs T for T 2 5K", dataplot, T, 3, "Temperature K ", 1, 5, 5, n, 1, "n moles ",.1, 5,.1 Out[6]=.42, 13.783,.98, 52.3133, 2.15, 26.1566, 3.17, 17.4378, 3.98, 13.783, 5.1, 1.4627, 7.99, 6.53916, 1, 5.23133 12 1 Out[61]= p atm 8 6 4 2 2 4 6 8 1

Project Example.nb 7 Temperature K n moles 14 p vs T for T 2 5K 12 Out[62]= 1 p atm 8 6 4 2 2 4 6 8 Comment : Using the Manipulate[ ] command provides a means to understand the degree to which certan parameters affect a model or equation.

8 Project Example.nb For Non-linear curve fitting and output of various statistical error analysis parameters [2-5], one can use the NonlinearModelFit[ ] function. In[23]:= Clear SomeData, SomeDataplot, SomeDatafit, plotfit Place data in list SomeData,, 1, 1, 2, 4.1, 3, 8.9, 4, 16.1, 5, 24.9 Create scatter plot of data SomeDataplot ListPlot SomeData, Frame True, GridLines Automatic, PlotStyle RGBColor 1,,, PointSize.2`, FrameLabel "y data arb. Units ", "x data arb. Units " Perform fit and define the fitting function Print "y ", SomeDatafit NonlinearModelFit SomeData, a x^2 b x c, a, b, c, x Plotting the NonlinearModelFit data. Note that SomeDatafit has to show that it is a function of x; I.e., SomeDatafit x plotfit Plot SomeDatafit x, x,, 5, Frame True, GridLines Automatic, PlotStyle RGBColor, 1,, FrameLabel "x", "y" showing the plots pplot and plotpfit on the same graph Show SomeDataplot, plotfit, PlotLabel "Fit Green Line; Data Red Points" Out[24]=,, 1, 1, 2, 4.1, 3, 8.9, 4, 16.1, 5, 24.9 25 2 Out[25]= x data arb. Units 15 1 5 1 2 3 4 5 y FittedModel.714286.421429 x.989286 x 2

Project Example.nb 9 2 15 Out[27]= y 1 5 1 2 3 4 5 25 2 Out[28]= x data arb. Units 15 1 5 1 2 3 4 5 Comment : The Non Linear Curve fitting model shows very close agreement to the data. The degree of "goodness of fit" is examined in the next section. Note that labels and arrows need to be added to the plots to help guide the reader.

1 Project Example.nb Error analysis on Nonlinear Curve Fitting that includes: 1. Listing the Nonlinear Fit Model 2. Lising some of the parameters associated with the fit 3. Coefficient of Determination 4. Adjusted Coefficient of Determination 5. Residuals - listing and plotting 6. Confidence Intervals - listing and plotting Note: When using any of these parameters, it is insufficient to use one in a project without explaining what the parameter is and why it is being used. For discussion and definitions of data and error analyses, see referenced [2-5]. In[29]:= Use LinearModelFit command that is new to Mathematica 7 Print "y ", SomeDatafit NonlinearModelFit SomeData, a x^2 b x c, a, b, c, x Print "Model Parameter Table ", SomeDatafit "ParameterTable" Lists some parameters of the fit Print "R 2 ", SomeDatafit "RSquared" Provides the R 2 value Print "Adjusted R 2 ", SomeDatafit "AdjustedRSquared" Provides the adjusted R 2 value Print "Residuals ", SomeDatafit "FitResiduals" Lists the Residuals of the fit Print "Plot of Residuals" ListPlot SomeDatafit "FitResiduals", PlotRange.1,.1, Filling Axis, Frame True, PlotLabel "Residuals from Fit" Provides the Residuals of the fit ListPlot Table SomeDatafit "ParameterConfidenceIntervals", ConfidenceLevel p, p,.8,.85,.9,.95,.99, Frame True, GridLines Automatic, PlotLabel "Confidence Intervals: 8, 85, 9, 95, 99 " y FittedModel.714286.421429 x.989286 x 2 Model Parameter Table R 2.999966 Adjusted R 2.999932 Estimate Standard Error t-statistic P-Value a.989286.172763 57.2627.117322 b.421429.899915.468298.671496 c.714286.956716.74661.945185 Residuals.714286,.242857,.657143,.122857,.11,.357143 Plot of Residuals

Project Example.nb 11.1.5 Out[35]=..5.1 1..8 Out[36]=.6.4.2. Comment: When using any of these parameters, it is insufficient to use one in a project without explaining what the parameter is and why it is being used. For discussion and definitions of data and error analyses, see referenced [2-5]. Note that labels and arrows need to be added to the plots to help guide the reader.

12 Project Example.nb Calculus can be performed on the Nonlinear Fit Model: 1. Integration: with and without limits - 2 approaches 2. 1st Derivative - 3 approaches 3. 2nd Derivative - 3 approaches In[37]:= integration without limits 2 ways Integrate SomeDatafit x, x SomeDatafit x x integration with limits 2 ways Integrate SomeDatafit x, x, 2, 5 5 SomeDatafit x x 2 1st derivative 3 ways D SomeDatafit x, x x SomeDatafit x SomeDatafit' x Second Derivative 3 ways D SomeDatafit x, x, 2 x x SomeDatafit x SomeDatafit'' x Out[37]=.714286 x.21714 x 2.329762 x 3 Out[38]=.714286 x.21714 x 2.329762 x 3 Out[39]= 39.32 Out[4]= 39.32 Out[41]=.421429 1.97857 x Out[42]=.421429 1.97857 x Out[43]=.421429 1.97857 x Out[44]= 1.97857 Out[45]= 1.97857 Out[46]= 1.97857

Project Example.nb 13 Indefinite integrals and derivatives can be plotted: 1. Integration: with or without limits 2. 1st Derivative 3. 2nd Derivative In[47]:= Clear isomedatafit, dsomedatafit Defining functions to plot Assigning a function name to the integral of SomeDatafit isomedatafit x_ Integrate SomeDatafit x, x ; Assigning a function name to the derivative of SomeDatafit dsomedatafit x_ SomeDatafit' x ; Plotting the functions Plot isomedatafit x, x,, 1, Frame True, GridLines Automatic, PlotStyle RGBColor, 1,, FrameLabel "x", " y x", PlotLabel "First Derivative of Nonlinear Fit Model" Plot dsomedatafit x, x,, 1, Frame True, GridLines Automatic, PlotStyle RGBColor, 1,, FrameLabel "x", "y'", PlotLabel "Second Derivative of Nonlinear Fit Model" 3 25 2 Out[5]= y x 15 1 5 2 4 6 8 1

14 Project Example.nb 2 15 Out[51]= y' 1 5 2 4 6 8 1 x Comments: The Nonlinear Model is a 3rd order or degree polynomial fit. The first derivative should show a quadratic response while the second derivative should show a linear response. Indeed, this is what is observed in the plots above. Performing calculus on models can provide useful information including: o Differentiation Slope Max-Min Inflection points Curvature and radius of curvature Develop Differentials o Integration Sum under curve (y*x relationships) Within cycle where paths differ and hysteresis effects exist Develop State functions Thermodynamics - work and energy relations References: [1] W. Seese and G. Daub, Basic chemistry, 4th Ed. (Prentice Hall, 1985) p. 274-277. [2] D. Skoog, D. West, & F. Holler, Fundatmentals of Analytical Chemistry, 5th Ed., (Sauners College Publishing, New york; 1963) Ch. 1 [3] H. Motulsky & A. Christopoulos, Fitting Models to Biological Data using Linear and Nonlinear Regression -A practical Guide to Curve Fitting, Version 4 (GraphPad Prism; 23) p. 1-351. [4] Interpreting Regression Results, OriginLabs - Origin Software - http://www.originlab.com/ [5] H. Berendsen, A Student s Guide to Data & Error Analysis, (Cambridge Press, 211), p. 1-225 Note: [3] & [4] are posted

Project Example.nb 15 Work in Progress In[52]:= Clear v, R, T, p, nplots n T_, p_, v_ : p v R T Constants R.826; atm L mol K nplots Table Plot n T, 1, v, T, 273, 4, Frame True, GridLines Automatic, PlotRange.1,.1, PlotStyle RGBColor,, 1, FrameLabel "T K ", "n number of moles ", PlotLabel "n vs T for T 273 4K & p 1 atm", v,.5, 2,.25 ; Show nplots.1 n vs T for T 273 4K & p 1 atm.8 Out[56]= n number of moles.6.4.2 28 3 32 34 36 38