Quick Tour of Mathcad and Examples



Similar documents
Summary of important mathematical operations and formulas (from first tutorial):

1 Review of Least Squares Solutions to Overdetermined Systems

The Center for Teaching, Learning, & Technology

Brief Introduction to Vectors and Matrices

Excel Basics By Tom Peters & Laura Spielman

Curve Fitting with Maple

Prism 6 Step-by-Step Example Linear Standard Curves Interpolating from a standard curve is a common way of quantifying the concentration of a sample.

EXCEL Tutorial: How to use EXCEL for Graphs and Calculations.

Absorbance Spectrophotometry: Analysis of FD&C Red Food Dye #40 Calibration Curve Procedure

CURVE FITTING LEAST SQUARES APPROXIMATION

Lecture 2 Mathcad Basics

Review of Fundamental Mathematics

FREE FALL. Introduction. Reference Young and Freedman, University Physics, 12 th Edition: Chapter 2, section 2.5

An Introduction to Mathcad

USING EXCEL ON THE COMPUTER TO FIND THE MEAN AND STANDARD DEVIATION AND TO DO LINEAR REGRESSION ANALYSIS AND GRAPHING TABLE OF CONTENTS

Data Mining: Algorithms and Applications Matrix Math Review

The KaleidaGraph Guide to Curve Fitting

Dealing with Data in Excel 2010

Data representation and analysis in Excel

NCSS Statistical Software Principal Components Regression. In ordinary least squares, the regression coefficients are estimated using the formula ( )

Engineering Problem Solving and Excel. EGN 1006 Introduction to Engineering

November 16, Interpolation, Extrapolation & Polynomial Approximation

Tutorial on Using Excel Solver to Analyze Spin-Lattice Relaxation Time Data

Linear Algebra Notes for Marsden and Tromba Vector Calculus

1 Introduction to Matrices

MBA Jump Start Program

Mathematics Review for MS Finance Students

PTC Mathcad Prime 3.0 Keyboard Shortcuts

LAYOUT OF THE KEYBOARD

Scientific Graphing in Excel 2010

Arithmetic and Algebra of Matrices

Typical Linear Equation Set and Corresponding Matrices

Solving Systems of Equations Using Mathcad Charles Nippert Solving A System of Equations By Symbolically Figure 1 After Step 1

Below is a very brief tutorial on the basic capabilities of Excel. Refer to the Excel help files for more information.

5: Magnitude 6: Convert to Polar 7: Convert to Rectangular

2+2 Just type and press enter and the answer comes up ans = 4

A Guide to Using Excel in Physics Lab

Microsoft Excel 2010 Part 3: Advanced Excel

Using Excel (Microsoft Office 2007 Version) for Graphical Analysis of Data

AP Physics 1 and 2 Lab Investigations

Preface of Excel Guide

the points are called control points approximating curve

Tutorial for the TI-89 Titanium Calculator

Using Microsoft Excel to Plot and Analyze Kinetic Data

FX 115 MS Training guide. FX 115 MS Calculator. Applicable activities. Quick Reference Guide (inside the calculator cover)

Excel Level Two. Introduction. Contents. Exploring Formulas. Entering Formulas

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

Curve Fitting in Microsoft Excel By William Lee

MatLab Basics. Now, press return to see what Matlab has stored as your variable x. You should see:

Objectives. Materials

MATLAB Workshop 3 - Vectors in MATLAB

Plots, Curve-Fitting, and Data Modeling in Microsoft Excel

How Does My TI-84 Do That

Algebra 2 Chapter 1 Vocabulary. identity - A statement that equates two equivalent expressions.

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

Academic Support Center. Using the TI-83/84+ Graphing Calculator PART II

Separable First Order Differential Equations

Display Format To change the exponential display format, press the [MODE] key 3 times.

Formulas, Functions and Charts

Mathematics Pre-Test Sample Questions A. { 11, 7} B. { 7,0,7} C. { 7, 7} D. { 11, 11}

Spreadsheets and Laboratory Data Analysis: Excel 2003 Version (Excel 2007 is only slightly different)

Excel Guide for Finite Mathematics and Applied Calculus

Excel -- Creating Charts

Algebra and Geometry Review (61 topics, no due date)

Microeconomic Theory: Basic Math Concepts

STATGRAPHICS Online. Statistical Analysis and Data Visualization System. Revised 6/21/2012. Copyright 2012 by StatPoint Technologies, Inc.

Algebra Cheat Sheets

The Method of Least Squares. Lectures INF2320 p. 1/80

Intro to Excel spreadsheets

Beginner s Matlab Tutorial

A.2. Exponents and Radicals. Integer Exponents. What you should learn. Exponential Notation. Why you should learn it. Properties of Exponents

Algebra I Vocabulary Cards

Statgraphics Getting started

Algebra I. In this technological age, mathematics is more important than ever. When students

Microsoft Excel 2010 Charts and Graphs

EL-9650/9600c/9450/9400 Handbook Vol. 1

Higher Education Math Placement

MATLAB Basics MATLAB numbers and numeric formats

Introduction to Matrix Algebra

0 Introduction to Data Analysis Using an Excel Spreadsheet

MATH Fundamental Mathematics IV

a. all of the above b. none of the above c. B, C, D, and F d. C, D, F e. C only f. C and F

Classroom Tips and Techniques: The Student Precalculus Package - Commands and Tutors. Content of the Precalculus Subpackage

Using Excel for Handling, Graphing, and Analyzing Scientific Data:

Basic Formulas in Excel. Why use cell names in formulas instead of actual numbers?

10.1. Solving Quadratic Equations. Investigation: Rocket Science CONDENSED

Excel 2007 Basic knowledge

Microsoft Excel 2010 Tutorial

GeoGebra Statistics and Probability

By Clicking on the Worksheet you are in an active Math Region. In order to insert a text region either go to INSERT -TEXT REGION or simply

1. Which of the 12 parent functions we know from chapter 1 are power functions? List their equations and names.

Basic Excel Handbook

How To Analyze Data In Excel 2003 With A Powerpoint 3.5

LS.6 Solution Matrices

MS Excel. Handout: Level 2. elearning Department. Copyright 2016 CMS e-learning Department. All Rights Reserved. Page 1 of 11

Florida Math for College Readiness

Linear and quadratic Taylor polynomials for functions of several variables.

December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B. KITCHENS

INTRODUCTION TO EXCEL

Calibration and Linear Regression Analysis: A Self-Guided Tutorial

Transcription:

Fall 6 Quick Tour of Mathcad and Examples Mathcad provides a unique and powerful way to work with equations, numbers, tests and graphs. Features Arithmetic Functions Plot functions Define you own variables and functions Visualize data in -D and 3-D Compute sums and integrals Do matrix computations Solve equations numerically symbolically Programming Curve fitting and data analysis functions Arithmetic, variables, constants, units, equal signs. The sign means to print the value The : sign means to define a variable [You type : but mathcad prints :] The ~ sign means to define a variable before the rest of the work sheet is evaluated The <cntrl>, evaluation., means to set equal "logically", that is without numerical The.. range operator defines the range in the toolbar or use a semicolon ( ; ) i,.5.. Typing @ generates a blank graph or use the X-Y Plot button in Graph (Insert or Toolbar). To separate expressions use the comma operator (, ).

Arithmetic, Functions, Calculus, Greek letters, Matrix, Symbolic, Programming etc... can be selected in the Toolbar. (View, then Toolbar) (a). Arithmetic To the right, type the following (NOT IN A TEXT REGION) [For tips on editing and typing expressions, see Editing below.] To add text Go to top menu and Insert and select Text Region /3 *3 ^3 compare /3: (b). Now type the following: x: y:3 x/y x*y x^y (c). Mathcad has several built-in constants. That is, Mathcad "knows" these constants. Find the values of the following constants by typing e p<ctrl-g> [This means type p and hold down the Ctrl key while you press g.] R Note that R is NOT the gas constant. Editing: Correcting a typing error: place the mouse just to the right of the wrong character or symbol. Click and press the delete (back arrow) key. Try this: change 3 to 9 in the math expressions you created at left. Editing: Whole mathcad expressions or text regions can be removed. Just select the desired region and press the delete or backspace key. There are two ways to select a region. Either click and drag into the region, or click once in the region and press <up arrow> repeating until whole region is outlined. Editing: Expressions can be edited for variables and constants or for operators. To remove (and replace) and operator, click on the expression and use the up-arrow or down-arrow to select the part of the expression that contains the offending operator. (blue editing line) Press the back-arrow to remove it and press the desired operator key to replace it. Arithmetic: 97.837 5.54 3 7 6.75 7 5 + 6 5.53 3

5 j i j i 3.8 Functions: Complex numbers ( ) cos 3 5 π log 45.668 ( 5. + 4i) + e 3 i.65 +.536i Units: (to check or add new units use top menu Insert and Units) 5 km.5 hr 3.48 m s change units directly to mph Function and Plot: z :,.5.. 4 f( z) : sin( z) z fz ()..5..5..5 3. 3.5 4...479.84.997.99.598.4 -.35 -.757 fz ( ) 5 exp( f( z) ) z z 4 Variables and your own functions: a : 4 a 5 3 + a.587 Or f( x) : sin( x) x a 3 f () 53.854 f ( ) 3.48

Calculus: n n!.78 + 3 x x d.579 Matrix AA A : 4 5 5 8.4.3.6 A Inverse matrix.3..79.6.79.5. 6.939 7.776 7.388 7.. determinant 5.55 7.. A 64. B : C : 4 6 3 3 7 B 9. 8. 4. 44. BC 3. 3.. 5. B C 6. 6. 7. 8. B C.67.667.67.667 Solving Equations:(numerically, symbolically, using Symbolics, Root, Polyrrot and Given...Find build in functions) Numerically Given t : 3 v : ( ).594 root t cosh() t, t Find() v.93 v + 3v 5 Symbolically using "solve" x + x solve, x 5 5

i n i 3 ( n + ) 3 ( n + ) + n + 6 6 change the value of n in the Sum symbol Precautions. Numerical formatting: Under Format and Result there are three parameters that you have to be careful about. (a) Under Number Format--General (Number of Decimal Places and Exponential Threshold) Number of decimal places determines the number of figures displayed after the decimal (3 default). Exponential Threshold determines how large or how small a number can become before the program switches to exponential notation (3 default) (b) under Number Format, Tolerence determines the size of a number that will be displayed as decimal 9 and zero threshold 9 then change zero threshold to 5. Errors: h : 6.6675 34 h3 : h 3 h3.99 h3.99 9 Largest and smallest numbers are 37 and -37 R is Rankine-scale degree temperature NOT the gas constant g: acceleration of gravity NOT gram Second is sec NOT s Meter (unit of lenght SI system of unit) is m. In general you should not use (m, sec, gm and K) as variable names. Kelvin temperature is denoted K therefore if you need to use it as equilibrium constant add a subscript K eq for instance. Mathcad evaluates expression from left to right and top to bottom. Each sheet is indenpendent of the others. Default numbering system for subscripts begins with not. x, x,...

Fitting Functions I. Linear Regression: Suppose the data consists of paired points {x i }, {y i }. The regression refers to finding the coefficient c i of the following equation and to minimize the sum of squares of the deviations of the calculated and observed y. i where c i and f i (x) are the coefficient and arbitrary functions of x, respectively. Example : y c i f i ( x) "Fitting data to a linear function" of the form y ax + b where a is the slope and b the intercept. You need first to define the number of points N and then the range variable i (index): N : i :.. N Data: x i : y i : 5 4 8 3 6.5 4.3. 4 3 6. 4 7 5 8. a : slope( x, y) a.97 b : intercept( x, y) b.4 fit( z) : a z+ b z : 6, 4.5.. 6 y fit() z 5 5 x, z

II. Least Squares Fits: Suppose the dataset is {(xi,yi) with i,,3,... n}. And you need to find the best polynomial fit to these data points in the form of f(z): f( z) j d ( c j z j ) equivalent to with d 3 f( z) c + c z + c z + c 3 z 3 The best fit of y(x) to the data is found by minimizing the squared deviation function: M i n d y i j c j ( ) j x i equivalent to ( ) + ( y c + c x ) M y c + c x with n and d Define a function X such as X i, j ( x i ) j and a matrix M such as M X T X Then the values of cj that minimize M are given by c M X y Example : x :.5...5. 3.9 5.6 ( ) T y : ( 5..9..6 5.75 8 9 ) T n : length() x or n : rows() x i :.. n d : j :.. d Using the functions defined above ( ) j X i, j : x i and M : X T X

M 7. 8.5 58.95.47 M.9.7 8.5 58.95 9.75.9.59. 58.95 9.75.78 3.7. 3.679 3 X i j,....... -.5 X........5...5. 3.9 5.6 6.5..4.5 4.84 5. 3.36 ----------------------------------------------------------------------------------------------------------------------------------- example: 3x3 matrix 4. 5...4.3.6 A TT 5... A.3..79.. 8..6.79.5 4. 5.. A T 5..... 8. A 64. nonsingular (invertible) determinant is not zero ------------------------------------------------------------------------------------------------------------------------------ Back to our problem, the coefficients c are given by c : M X T y Polynomial fitting function: 4 c.68.556.798 z : 5, 4.9.. 8 f( z) : j d ( c j z j ) 3 y fz () 5 5 x, z

Use of "linfit" function (MathCAD built in function) Here y(x) c o + c x + c x. We need to define a function Y(x) which gives the power of the variable x. The linfit(x,y,y) function returns a vector containing the parameters used to create a linear combination of the functions in vector Y that best approximates the data in x and y in the least-squares sense.there must be at least as many data points as there are terms in Y. Y(x) is a vector of functions; each element is one linear functional term in the fit function. In the case of a single linear function, Y is a scalar. Y( x) : x x c' : linfit( x, y, Y) fit' ( z) : Y( z) linfit( x, y, Y).68 c'.556 z : 5.798, 4.9.. y fit' () z 5 5 5 x, z More functions are defined in MathCAD. General least square such as genfit, linfit, regress with interp.. Specialized least square functions such expfit, lnfit, logfit, pwrfit, sinfit etc... Logarithmic Regression The use of Mathcad s linfit function to fit data to a logarithmic model is illustated bellow. Two specialized built-in fitting functions, logfit and lnfit, may also be used. The following Data Table contains a set of data that may be best approximated by a logarithmic model function.

data : 3 4 5 6 7 8 9 4.8 4.67 3 5.3 4 5.37 5 5.45 6 5.74 7 5.65 8 5.84 9 6.36 6.38 X : data Y : data Enter the vector of functions to fit. In this example, we fit this data to the model function y a ln( x) + b x+ c, where a, b, and c are unknown. F( x) : ln( x). Call the linfit function using the data and the vector of functions, F. x S : linfit( X, Y, F) Define a function that uses these newly found parameter values in the logarithmic model. Also, define a range variable over which to graph the function. f( x) : F( x) S z : min( X).. max( X) (range variable for plotting) A graph of the model function with the newly found parameter values and the original data points reveals a good fit. 8 Y fz ( ) 6 ( ).979 corr f( X), Y 4 3 4 X, z correlation coefficient

. A simpler way to perform a customized log fit is by using the lnfit function. The data is fitted with the model function y a ln( x) + b: T : lnfit( X, Y) T.88 4.73 h( x) : T ln( x) + T z.. last( X) : (range variable for plotting), a different way to set a range of values 8 7 Y hz () 6 5 4 3 4 X, z ( ).979 corr h( X), Y correlation coefficient 3. You can also use Mathcad s logfit function, which fits data to the model function. The model function used here is y a ln( x+ b) + c. Q : 4 M : logfit( X, Y, Q) M ( ) k( x) : M ln x + M + M guess vector.864.97 4.7

z.. last( X) : range variable for plotting 8 7 Y kz () 6 5 4 3 4 X, z ( ).979 corr k( X), Y correlation coefficient III. Polynomial Regression: Polynomial function that best fit the set of data points The function regress(x,y,k) returns a vector s which interp uses to find the k th order polynomial that best fits the x and y data values. The function interp(s,x,y,x) returns interpolated y value corresponding to x. X is a vector of real data values in ascending order (the x values). Y is a vector of real data values (the y values). s is a vector generated by the function regress. k is a positive integer specifying the order of the polynomial you want to use to fit the data. Usually you'll want k < 5. x is the value of the independent variable at which you want to evaluate the regression curve. Notes: Regress is useful when you have a set of measured y values corresponding to x values and you want to fit a single polynomial of any order to those y values. You should always use interp after using the regress function. Since regress tries to accommodate all your data points using a single polynomial, it will not work well when your data does not behave like a single polynomial.

Example : Consider a matrix of X-Y data to be analyzed (X coordinate in first column, Y coordinate in second) data : 3 4 5 6 7 8 9 9. 7.3 3. 4.6 4.8.9 5.7 7. 8.8. X : data Y : data n : rows( data) n. Enter the degree of polynomial to fit, value of k: k : 3 Define the polynomial function that fit best the set of data points using "regress" as follows: 3. s 3. : regress( X, Y, k) 3. s 9.98 3.438.69.4 Use the function "interp" as the polynomial fitting function: ( ) fit ( x) : interp s, X, Y, x interpolation of y value corresponding to x to give a vector s x :,.. 5 Y fit ( x) 5 5 X, x

( ( ) ) coeffs : submatrix s, 3, length s,, coeffs The coefficients are given by: 9.98 3.438.69.4 coeffs T ( 9.98 3.438.69.4 ) (matrix transpose) Fit( x) : i k ( coeffs i x i ) cspline, pspline and lspline and interp functions for connecting X-Y data. Enter a matrix of X-Y data to be interpolated: M : 3 4 5 6 7 8 9 3 4 3 4 7.57 5 5 7 8 8 3.4 48 3 6 4 59.89 6 7.8 7 83 8 65 9 78 85 ( ) M : csort M, X M : Y : M Spline coefficients: S : lspline( X, Y) Sample interpolated values: fit () 3.64 fit ( 9.5) 4.3 Fitting function: ( ) fit( x) : interp S, X, Y, x z :,.5..

5 5 5 X-Y data Cubic spline interpolation Any ot the fiiting functions can then be used for calculations (integrals, derivatives etc...) Multivariate Regression using regress Assume you have the following data. In this example, X and Y are the independent variables, and Z is the dependent variable. i :.. 4 X i : Y i : Z i : 47 8 5 3 6 99 43 3 5 4 5 9 89 46 8 48 8 35 4 3 4 6 47 9 3 5 49 8 45 8 68 5 3 8 43 7 7 46 7

The higher dimensional form of regress takes three arguments: a real array, M, each column of which represents data corresponding to one of the independent variables a real vector, V, representing the data for the dependent variable a positive integer, n, specifying the degree of the polynomial function to which the data will be fit M : augment( X, Y) Combine the independent variables into a single matrix using the augment function n : Define the degree of the polynomial. (This value could also be passed directly to regress.) Define the regress function, and view the results. S : ( ) regress M, Z, n S 3. 3...56.9.53 4.76.69.98 3 Defining a function using interp You can use the interp function to define a two-variable polynomial function which uses these coefficients. interp is able to interpret the order of the coefficients and the monomial terms with which they are associated. In particular, it uses the first three terms of the vector, S, to determine the built-in function being called (3 for regress), the vector position of the first coefficient (always 3), and the degree of the fitting function (n). x f( x, y) : interp S, M, Z, y This definition will vary depending upon the number of independent variables. In this example, we have two independent variables, x and y. Call the function for specific values but do not use the function to extrapolate. It should be used for interpolation only.

f ( 9, ) 54.958 This function call will vary depending upon the number of independent variables you have. Here we are dealing with a D case of multivariate regression. Therefore, we can graph the result as a surface over ranges for x and y. F : CreateMesh( f, min( X), max( X), min( Y), max( Y),, ) The regression surface passes through the space minimizing the distance to each of the data points, shown in black on the graph. F, ( X, Y, Z) Quantum Mechanics Construction of the double well potential V(x) and calculation of the ten first energy levels of the system. Plot of the wavefunctions and probability densities. Tunneling effect. V( x) : if x < < if x < 4 if 4 x < 6 6 otherwise x :,.999.. V( x) 5 Differential Equation to solve H : h 8π m d dx 3 4 5 6 7 8 x

ev : e volt ev.677 9 J n :.. 9 h 6.66 34 : J s a : 5 9 m m : 9. 3 kg E( n ) : h n 8 m a E( n )..5.6.36.4.376.54.738.964. ev ε : 5 change the values of ε until to get tunneling about 8 y : D( x, y) v : rkfixed( y,, 6, 4, D) y : ( V( x) ε) y 5 v v 5 6 4 ( v) 6 4 v No tunneling is observed for ε less than 5. the particle tunnels through the potential barrier at ε greater than 6. At ε greater than 6, tunneling takes place and a wavefunction appears after x -.