Mathcad Lecture #8 In-class Worksheet Curve Fitting and Interpolation

Similar documents
Mathcad Lecture #7 In-class Worksheet "Smart" Solve Block Techniques Handout

Math 2142 Exam 1 Review Problems. x 2 + f (0) 3! for the 3rd Taylor polynomial at x = 0. To calculate the various quantities:

Some Basic Information about M-S-D Systems

System of Linear Differential Equations

23.2. Representing Periodic Functions by Fourier Series. Introduction. Prerequisites. Learning Outcomes

10. State Space Methods

t is a basis for the solution space to this system, then the matrix having these solutions as columns, t x 1 t, x 2 t,... x n t x 2 t...

dt = C exp (3 ln t 4 ). t 4 W = C exp ( ln(4 t) 3) = C(4 t) 3.

2.7. Some common engineering functions. Introduction. Prerequisites. Learning Outcomes

Two Coupled Oscillators / Normal Modes

Section 3.5 Nonhomogeneous Equations; Method of Undetermined Coefficients

23.5. Half-Range Series. Introduction. Prerequisites. Learning Outcomes

Math 106: Review for Final Exam, Part II. (x x 0 ) 2 = !

Chapter 2. First Order Scalar Equations

Linear Response Theory: The connection between QFT and experiments

Chapter 7: Solving Trig Equations

THE SINE INTEGRAL. x dt t

RC, RL and RLC circuits

Sterilization D Values

Matlab and Python programming: how to get started

ACE 562 Fall Lecture 5: The Simple Linear Regression Model: Sampling Properties of the Least Squares Estimators. by Professor Scott H.

Math 334 Test 1 KEY Spring 2010 Section: 001. Instructor: Scott Glasgow Dates: May 10 and 11.

Chapter 3 Boundary Value Problem

Chapter 6. Systems of First Order Linear Differential Equations

AP Chemistry--Chapter 12: Chemical Kinetics

Predator - Prey Model Trajectories and the nonlinear conservation law

Section 7.4 Modeling Changing Amplitude and Midline

Vehicle Arrival Models : Headway

5.1 - Logarithms and Their Properties

Solutions to Assignment 1

Y 0.4Y 0.45Y Y to a proper ARMA specification.

Navneet Saini, Mayank Goyal, Vishal Bansal (2013); Term Project AML310; Indian Institute of Technology Delhi

KINEMATICS IN ONE DIMENSION

Unit Root Time Series. Univariate random walk

Notes on Kalman Filtering

Diebold, Chapter 7. Francis X. Diebold, Elements of Forecasting, 4th Edition (Mason, Ohio: Cengage Learning, 2006). Chapter 7. Characterizing Cycles

ACE 562 Fall Lecture 4: Simple Linear Regression Model: Specification and Estimation. by Professor Scott H. Irwin

The average rate of change between two points on a function is d t

Let us start with a two dimensional case. We consider a vector ( x,

Echocardiography Project and Finite Fourier Series

Reading from Young & Freedman: For this topic, read sections 25.4 & 25.5, the introduction to chapter 26 and sections 26.1 to 26.2 & 26.4.

Math 315: Linear Algebra Solutions to Assignment 6

LabQuest 24. Capacitors

u(x) = e x 2 y + 2 ) Integrate and solve for x (1 + x)y + y = cos x Answer: Divide both sides by 1 + x and solve for y. y = x y + cos x

Lab #2: Kinematics in 1-Dimension

FITTING EQUATIONS TO DATA

CHAPTER 2: Mathematics for Microeconomics

Lecture 2-1 Kinematics in One Dimension Displacement, Velocity and Acceleration Everything in the world is moving. Nothing stays still.

ODEs II, Lecture 1: Homogeneous Linear Systems - I. Mike Raugh 1. March 8, 2004

Solutions from Chapter 9.1 and 9.2

The equation to any straight line can be expressed in the form:

3.6 Derivatives as Rates of Change

Sub Module 2.6. Measurement of transient temperature

Lab 10: RC, RL, and RLC Circuits

Hamilton- J acobi Equation: Explicit Formulas In this lecture we try to apply the method of characteristics to the Hamilton-Jacobi equation: u t

Final Spring 2007

5.2. The Natural Logarithm. Solution

Fishing limits and the Logistic Equation. 1

Ordinary dierential equations

Robust estimation based on the first- and third-moment restrictions of the power transformation model

Section 4.4 Logarithmic Properties

3.1.3 INTRODUCTION TO DYNAMIC OPTIMIZATION: DISCRETE TIME PROBLEMS. A. The Hamiltonian and First-Order Conditions in a Finite Time Horizon

15. Vector Valued Functions

4.1 - Logarithms and Their Properties

04. Kinetics of a second order reaction

Challenge Problems. DIS 203 and 210. March 6, (e 2) k. k(k + 2). k=1. f(x) = k(k + 2) = 1 x k

2. Nonlinear Conservation Law Equations

Designing Information Devices and Systems I Spring 2019 Lecture Notes Note 17

Chapter #1 EEE8013 EEE3001. Linear Controller Design and State Space Analysis

Guest Lectures for Dr. MacFarlane s EE3350 Part Deux

CHEMICAL KINETICS: 1. Rate Order Rate law Rate constant Half-life Temperature Dependence

MATH 31B: MIDTERM 2 REVIEW. x 2 e x2 2x dx = 1. ue u du 2. x 2 e x2 e x2] + C 2. dx = x ln(x) 2 2. ln x dx = x ln x x + C. 2, or dx = 2u du.

CHAPTER 12 DIRECT CURRENT CIRCUITS

6.003 Homework #8 Solutions

In this chapter the model of free motion under gravity is extended to objects projected at an angle. When you have completed it, you should

PET467E-Analysis of Well Pressure Tests/2008 Spring Semester/İTÜ Midterm Examination (Duration 3:00 hours) Solutions

Chapter 14 Chemical Kinetics

THE 2-BODY PROBLEM. FIGURE 1. A pair of ellipses sharing a common focus. (c,b) c+a ROBERT J. VANDERBEI

Advanced Integration Techniques: Integration by Parts We may differentiate the product of two functions by using the product rule:

Decimal moved after first digit = 4.6 x Decimal moves five places left SCIENTIFIC > POSITIONAL. a) g) 5.31 x b) 0.

MATH 4330/5330, Fourier Analysis Section 6, Proof of Fourier s Theorem for Pointwise Convergence

Week #13 - Integration by Parts & Numerical Integration Section 7.2

Math 333 Problem Set #2 Solution 14 February 2003

Chapter 14 Homework Answers

Physics 235 Chapter 2. Chapter 2 Newtonian Mechanics Single Particle

E β t log (C t ) + M t M t 1. = Y t + B t 1 P t. B t 0 (3) v t = P tc t M t Question 1. Find the FOC s for an optimum in the agent s problem.

R t. C t P t. + u t. C t = αp t + βr t + v t. + β + w t

Econ107 Applied Econometrics Topic 7: Multicollinearity (Studenmund, Chapter 8)

d 1 = c 1 b 2 - b 1 c 2 d 2 = c 1 b 3 - b 1 c 3

Solutions for homework 12

Chapter 2 The Derivative Applied Calculus 107. We ll need a rule for finding the derivative of a product so we don t have to multiply everything out.

LAPLACE TRANSFORM AND TRANSFER FUNCTION

The fundamental mass balance equation is ( 1 ) where: I = inputs P = production O = outputs L = losses A = accumulation

HOMEWORK # 2: MATH 211, SPRING Note: This is the last solution set where I will describe the MATLAB I used to make my pictures.

KEY. Math 334 Midterm III Winter 2008 section 002 Instructor: Scott Glasgow

Class Meeting # 10: Introduction to the Wave Equation

Simulation-Solving Dynamic Models ABE 5646 Week 2, Spring 2010

From Complex Fourier Series to Fourier Transforms

Physics 127b: Statistical Mechanics. Fokker-Planck Equation. Time Evolution

ACE 562 Fall Lecture 8: The Simple Linear Regression Model: R 2, Reporting the Results and Prediction. by Professor Scott H.

Transcription:

Mahcad Lecure #8 In-class Workshee Curve Fiing and Inerpolaion A he end of his lecure, you will be able o: explain he difference beween curve fiing and inerpolaion decide wheher curve fiing or inerpolaion should be used for a paricular applicaion inerpolae values beween daa poins using linerp and inerp wih cspline. fi equaions using line, regress, linfi, and genfi.. Inerpolaion and Curve Fiing Defined Background Thermophysical and ranspor propery daa are ofen needed in engineering calculaions. Quaniies such as he capaciies, hermal conduciviies, diffusiviies, densiies, and viscosiies are measured experimenally and he resuls are found in handbooks and journal aricles. Usually, he daa are no published for every condiion ha may be experienced in real life problems. For example, vapor pressures migh be published for a K and K, bu you may need he value a 5 K. In such siuaions, wo opions are available: inerpolaing and curve fiing. Inerpolaion is deermining a new poin beween wo exising poins. For example, if I measured he hea capaciy o be J/mol/K a K and J/mol/K a K, I migh reasonably esimae he hea capaciy a 5 K o be 5 J/mol/K. Curve Fiing is deermining a funcion ha closely maches he daa. For example, he daa may look like a sraigh line, so we can deermine he slope and inercep ha gives a line ha maches he daa he bes. The Anoine Equaion is a familiar funcion ha "fis" he emperaure dependence of vapor pressures well. A few noes:. Inerpolaion can really be hough of as a special case of curve fiing where he funcion is forced o pass hrough every daa poin.. Inerpolaion is generally done linearly or wih cubic splines. Cubic splines means a hird-order polynomial is generaed connecing he poins raher han a sraigh line.. Exrapolaion is defined as predicing values beyond he range of he available daa. For example, vapor pressures were measured a K and K, I could inerpolae o obain a value for a value beween K and K, bu I would be exrapolaing if I used he same poins o obain a value for 5 K or 5 K. Thus, he uncerainies are greaer for exrapolaed values compared o inerpolaed values.. You generally use curve fiing when you know a funcion ha maches he daa well. When you don' know a funcion, you inerpolae. (Funcions for fiing can come from simple observaion, experience, rial and error, or heory.. Inerpolaing Demonsraion Consider he following ime/emperaure measured in an experimen daa. I would like o know he values of he emperaure a all imes, no jus he whole minues. Time 5 7 8 9 min Temp 98 5 5 8 7 K

Linear Inerpolaion Linear inerpolaion is done by using he linerp funcion which has hree argumens. I akes he form: y new := linerp(xdaa,ydaa,x new ). For single values. emp new linerp( TimeTemp.5min) emp new 7.5 K Can creae funcions Temp_linerp( ) linerp( TimeTemp ) Temp_linerp(.5min) 7.5 K Key Poins:. The las argumen of linerp is he value of x a which you wan o esimae y.. The las argumen can be a variable if a funcion is defined. This allows you o use he inerpolaion over and over which is useful for graphing or inegraing daa. Cubic Spline Inerpolaion Insead of using a line o inerpolae beween daa poins, a cubic polynomial may be used o connec he poins. This is done by using he inerp and cspline funcions. For single values. emp new inerp( cspline( TimeTemp) TimeTemp.5min) emp new 7.5 K Can creae funcions Temp_spline( ) inerp( cspline( TimeTemp) TimeTemp ) Temp_spline(.5min) 7.5 K Alernaively, you can firs calculae cspline and hen feed he resuls o inerp. vs cspline( TimeTemp) Temp_spline( ) inerp( vstimetemp ) Temp_spline(.5min) 7.5 K

Visualizaion Temp Temp_linerp() Temp_spline() 9 Time. Curve Fiing Background Mahcad has several uiliies o fi daa o curves. These are: line (or slope and inercep) regress linfi genfi Each uiliy can fi cerain ypes of equaions. line will reurn he slope and inercep of he linear relaionship ha bes fi he daa. regress is used o reurn he polynomial ha bes represens he daa. linfi may be used o fi daa o expressions which are linear combinaions of funcions. genfi may be used o fi daa o funcions of any ype. Each fiing mehod can fi he funcions of hose above i in he lis. For example, regress can do he same hing ha line can because a line is jus a s order polynomial. Since a line is also a linear combinaion of funcions, linfi can also be used. Genfi can be used in any case.. Fiing Daa o a Line Synax line( xdaaydaa) Demonsraion Deermine he bes fi line o he ime/emperaure daa used above.

Time 5 7 8 9 8 8 5 s Temp 5 7 8 9 98 5 5 8 7 K Use he line funcion o ge he slope and inercep. line Time Temp min K 9..7 Inercep Slope K K/min Quesion: Wha are he unis on he inercep and he slope? Key Poins:. The argumens o he line funcion mus be dimensionless.. You mus deermine he unis yourself. Alernae Soluion: Use slope and inercep funcions. slope( TimeTemp).7 K min inercep( TimeTemp) 9. K Key Poin: You don' need o remove he unis on he inpu daa if you use slope and inercep insead of line. Can also creae a funcion o use laer. Temp_linear( ) slope( TimeTemp) inercep( TimeTemp)

Visualizaion Temp Temp_linerp() Temp_spline() Temp_linear(). Fiing Daa o a Polynomial Synax 9 Time vs := regress(xdaa,ydaa,order_of_polynomial) inerp(vs,xdaa,ydaa,xnew) Demonsraion The hea capaciy of waer as a funcion of emperaures has been measured in a calorimeer. The daa are found in he marices below. Fi he daa o a fourh order polynomial. D 5 7 8 9 7.5 7.7 9.5 7.5.5 7.5.5 7.5 5.5 7.55 7.5 7.595 9.5 7.5.5 7.75.5 7.8 5.5 7.98 kmol mol Temp exp D K Cpexp D J kmolk

The regress funcion will give he coefficiens of each erm in he polynomial. vs regress Temp exp Cp exp K J molk vs 7.7.9 8.5. 5 9.7 9 Key Poin: The oupu of regress is a marix. The firs hree rows are NOT he coefficiens, hey are values needed if inerp is going o be used. The fourh row is he coefficien on he x erm (he consan) The fifh row is he coefficien on he x erm. The las row is he coefficien on he x n erm. Usually, you feed he oupu of regress o he inerp funcion. Temp exp Cp exp Cp regress ( ) inerpvs K J molk Cp regress ( 5) 75.58 Quesion: Wha are he unis on he emperaure and hea capaciy? Key Poin: Using regress wih inerp means you canno include unis in he funcion. Can creae your own funcion o use unis. Cp regress () vs vs vs K 5 vs K vs K 7 K J molk Cp regress ( 5K) 75.58 J molk

Check he Resuls 95 9 Cp exp 85 Cp regress () 8 75 5 Temp exp. Fiing Daa o a Linear Combinaion of Funcions Ofen, he expression we wish o use o fi he daa is no a polynomial bu a linear combinaion of funcions. A linear combinaion of funcions is one where each erm only has one fiing parameer. For example, y = A Bsin( x) Cexp( x) is a linear combinaion of funcions. Only one fiing parameer is found in each erm and hey are muliplying he erm. The following are NOT linear combinaions of funcions. y = A sin( Bx) Cexp( x) y = A Bsin( x C) Dexp x E In he firs expression, B is inside he sine funcion. Thus, he B dependence is no linear. In he second equaion, muliple fiing parameers appear in he las wo erms. Synax Fx ( ) = erm erm erm_n β = linfi( xdaaydaaf) The erms in he F(x) marix are he funcional forms of each erm wihou he coefficien. For example, if he funcion o fis is y = A Bsin( x) Cexp( x) erm would be, erm would be sin(x) and erm would be exp(x).

Demonsraion Experimenal daa for he liquid densiy of aceone is found in he marices below. Fi his daa o he following expression. T where Y A B C T T = T C T D C T E C.5 T T C The criical emperaure of aceone, Tc, is 58. K. D 8.5 5.79 98.5 5..97 5..5.9.5.75 T C 58. Temp exp D K ρexp D kmol m 5.79.7.5.5 7 5.5.7 8 55.7.5 9.5.8 Obain he coefficiens o he equaion using linfi. F( x) x T C x T C β linfi x T C x T C.5 Temp exp ρ exp K kmol m F β 5.7...88. Key Poin: Linfi does no like unis on is inpu daa so divide hem ou.

Creae a funcion wih he resuls of linfi..5 ρ() β β T C K β β T C K T C K β T C K kmol m Key Poin: Pu in he unis explicily when you define he funcion. Check he Resuls.. ρ exp ρ(). 8 5 Temp exp. Fiing Daa o an Expression of Any Form Using Genfi When he funcion o fi is no a line, polynomial, or linear combinaion, you mus use genfi. Key Poin: Only use genfi if you have o, genfi requires good guesses and i is easier o make errors wih genfi. Synax gxγ ( ) = yx ( ) δy( x) δγ δy( x) δγ δy( x) δγ n γ guess = guess A guess A guess An γ = genfi xdaaydaaγ guess g

Demonsraion Experimenal daa for he vapor pressure of aceone is conained in he marices below. Fi he daa o he Anoine Equaion: ln( Psa) = A B T C D.5 58.98.5 9.7 Temp exp D K Psaexp D Pa 5 7 8 9.5 797..5.58 5..8 59.8.7. 5.8 8..8 5..5 7.5.85 The Anoine Equaion mus be fi using genfi. The firs hing needed is he parial derivaives of he funcion wih respec o each parameer (consan). You can do he derivaives in your head or using Mahcad. RHS of Anoine Equaion a zero a one a wo Parial Derivaives of RHS of Anoine Equaion. d a zero da zero a one a wo d a zero da one a one a wo a wo Key Poin: If you use Mahcad o do he derivaives, you canno use [ noaion for he subscrips. d a zero da wo a one a wo a one a wo

Creae he g(x,a) marix. (Noe: his doesn' have o be called g.) ga ( ) a one a zero a wo a wo a one a wo Change he subscrips o [ noaion. g( a ) a a a a a a Key Poins:. Genfi requires a he consans be a marix variable. Use [ noaion.. One common misake is o inerchange he and he a order when defining g(,a). This mus no be done. Provide some guess values for a. 5 a g 5 Key Poin: You should have a guess value for each consan in your equaion. Use genfi o ge he correc consans. Temp exp a genfi ln K Psa exp Pa a g g a..997.7 Key Poins:. If genfi doesn' converge, ry a new guess value.. Noice ha he y daa is ln(psa) as required by he original equaion.. You canno have unis on he daa so divide hem ou.. The las argumen in genfi is he name of he marix conaining he parial derivaives. Do no pu g(,a); i is jus g.

Define he funcion wih he correc parameers. a Psa( ) expa K a Pa Psa( K). Pa Check he fi by ploing Key Poin: You mus always check o make sure he fi is good by ploing. If i doesn' fi well, change your guess and ensure you did no make a misake. 5 Psa exp Psa() 5 Temp exp Exra Pracice Fi he daa given in he marices o he righ o he following expression. yx ( ) = γ cos γ x γ x γ X 5 Y g( xγ ) γ cos γ x yx ( ) γ cos γ x cos γ x γ x γ γ xsin γ x γ γ x γ..5 γ g γ genfi XY γ. g g. γ.8..5.9

5 yxx ( ) Y xxx