MATLAB FUNDAMENTALS: INTRO TO LINEAR ALGEBRA NUMERICAL METHODS HP 101 – MATLAB Wednesday, 11/5/2014 www.clarkson.edu/class/honorsmatlab.

Slides:



Advertisements
Similar presentations
An introduction to calculus…
Advertisements

Numerical Computation Lecture 4: Root Finding Methods - II United International College.
Linear Algebra Applications in Matlab ME 303. Special Characters and Matlab Functions.
4.5: Linear Approximations and Differentials
Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.
Slide deck by Dr. Greg Reese Miami University MATLAB An Introduction With Applications, 5 th Edition Dr. Amos Gilat The Ohio State University Chapter 3.
Chapter 4 Roots of Equations
Math Calculus I August 9 (but first, a quick review…)
MECH300H Introduction to Finite Element Methods Lecture 2 Review.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
GG313 Lecture 12 Matrix Operations Sept 29, 2005.
Slopes and Areas Frequently we will want to know the slope of a curve at some point. Or an area under a curve. We calculate area under a curve as the sum.
ECIV 301 Programming & Graphics Numerical Methods for Engineers REVIEW II.
2. Solving Schrödinger’s Equation Superposition Given a few solutions of Schrödinger’s equation, we can make more of them Let  1 and  2 be two solutions.
Notes, part 4 Arclength, sequences, and improper integrals.
FE Mathematics Review Dr. Scott Molitor Associate Professor
Modified Gary Larson Far Side cartoon
Recall that a square matrix is one in which there are the same amount of rows as columns. A square matrix must exist in order to evaluate a determinant.
CSEP 590tv: Quantum Computing Dave Bacon June 29, 2005 Today’s Menu Administrivia Complex Numbers Bra’s Ket’s and All That Quantum Circuits.
A quadratic equation is a second degree polynomial, usually written in general form: The a, b, and c terms are called the coefficients of the equation,
Chapter 1 Number Sense See page 8 for the vocabulary and key concepts of this chapter.
Exercise problems for students taking the Programming Parallel Computers course. Janusz Kowalik Piotr Arlukowicz Tadeusz Puzniakowski Informatics Institute.
First, some left-overs… Lazy languages Nesting 1.
Mathematical Fundamentals
Chapter 10 Review: Matrix Algebra
Video Game Rendering Mathematics
Chapter 5. Loops are common in most programming languages Plus side: Are very fast (in other languages) & easy to understand Negative side: Require a.
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
ECON 1150 Matrix Operations Special Matrices
Patrick Nichols Thursday, September 18, Linear Algebra Review.
Fall 2006AE6382 Design Computing1 Vectors and Matrices Lecture Basic vector & matrix concepts Creating arrays and matrices Accessing matrix components.
Mathematics for Computer Graphics (Appendix A) Won-Ki Jeong.
Solving Systems of Equations. Rule of Thumb: More equations than unknowns  system is unlikely to have a solution. Same number of equations as unknowns.
Chapter 9 Numerical Integration Flow Charts, Loop Structures Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 6 Finding the Roots of Equations
Formal Computational Skills Week 1: Functions. Overview By the end you should: Be able to evaluate a function Know how to visualise a function Know what.
Review of Matrices Or A Fast Introduction.
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
Numerical Methods Applications of Loops: The power of MATLAB Mathematics + Coding 1.
Array Addition  Two arrays can be added if and only if both arrays have exactly the same dimensions.  Assuming the dimension requirement is satisfied,
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
CMPS 1371 Introduction to Computing for Engineers MATRICES.
Lecture 28: Mathematical Insight and Engineering.
Loop Application: Numerical Methods, Part 1 The power of Matlab Mathematics + Coding.
Numerical Methods.
A string is an array of characters Strings have many uses in MATLAB Display text output Specify formatting for plots Input arguments for some functions.
CHAPTER 3 NUMERICAL METHODS
Newton’s Method, Root Finding with MATLAB and Excel
Numerical Analysis 3D Plots. A numerical method is a technique for computing a numerical approximation of the solution to a mathematical problem.
AUGUST 2. MATH 104 Calculus I Review of previous material…. …methods and applications of integration, differential equations ………..
Rule of 70 You have to know this for the test – and to compound daily interest on a savings account!
Applications of Loops: The power of MATLAB Mathematics + Coding
Numerical Methods Solution of Equation.
Algebra Problems… Solutions Algebra Problems… Solutions © 2007 Herbert I. Gross Set 17 part 2 By Herbert I. Gross and Richard A. Medeiros next.
§3.6 Newton’s Method. The student will learn about
4 Numerical Methods Root Finding Secant Method Modified Secant
Revision on Matrices Finding the order of, Addition, Subtraction and the Inverse of Matices.
Finishing up Chapter 5. Will this code enter the if statement? G=[30,55,10] if G
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
Linear Algebra Review Tuesday, September 7, 2010.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 3 - Chapter 8 Linear Algebraic Equations and Matrices.
Why do we need calculus in physics?
NUMERICAL ANALYSIS I. Introduction Numerical analysis is concerned with the process by which mathematical problems are solved by the operations.
EEE 244-3: MATRICES AND EQUATION SOLVING
MTH1150 Tangents and Their Slopes
Ch. 5 – Applications of Derivatives
Numerical Analysis Lecture 45.
EEE 244-3: MATRICES AND EQUATION SOLVING
Math review - scalars, vectors, and matrices
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM CISE301_Topic1.
Presentation transcript:

MATLAB FUNDAMENTALS: INTRO TO LINEAR ALGEBRA NUMERICAL METHODS HP 101 – MATLAB Wednesday, 11/5/2014

Quote and Video of The Week  “It’s a great party house guys… that’s why we bought it.” Jon Goss  

Linear (Matrix) Algebra Intro  Math with matrices is a bit different from regular math…  Addition and subtraction are the same.  Multiplication (“Row Column Rule”)  Syntax: A*B(No dot!)  Quick example…  Division and Powers… well, they don’t really exist in the classical sense. MATLAB can compute them, but we won’t worry about what they mean.

Dot Product  Dot Product is amount of vector A that lies in plane with vector B  Essentially, the sum of the results when you multiply two vectors together element by element  AB = ABcos( θ) A B A B = 0 B A B =

Dot Product Example  a = [ 1 2 3];  b = [ 4 5 6];  y = a.*b  y = [ ]  dot_product = sum(y) = 32  d_p = dot(a,b) = 32  Vectors must be same length – rows or columns

Cross Product  A measure of the orthogonality “perpendicular- ness” of two vectors  Opposite of a dot product  A x B = ABsin( θ) A B A x B = 2 B A x B = a = [ ]; b = [ ]; c = cross(a,b); c = [ ] Cross products are used a lot in statics, dynamics, and fluids

Systems of Linear Equations  Linear equations are big, nasty, and algebra can be really tricky  Sometimes, you can have tons of equations but actually solving them all by hand would be painful  Examples:  Complex Circuits  Simple Traffic Flow (or other flows)  “Who bought how much candy?”

 Suppose: 3x + 2y – z = 10 -x + 3y + 2z = 5 x - y - z = -1  We can say…. A*b = c A = b = c = 10 5 Solving Systems Linear Equations xyzxyz Sizes: 3 X 3 3 X 1 3 X 1

Example Continued  A = [3 2 -1; ; ];  c = [10; 5; -1];  b = A^(-1) * c; or b=inv(A)*c  Alternatively, can use Gaussian Elimination (preferred) :  b = A\c  You can also view the solution in matrix form:  b = rref[A,c]  Notes:  No dot before the multiplier  Matrix inner dimensions must agree  Gaussian Elimination is more efficient than inv function

Matrix Functions  After you have a Dif EQ or a Linear Algebra course, you can use MATLAB to:  Multiply or divide matrices together a*b a/b  Raise a matrix to a power a^2  Find determinants det( )  Create identity Matrices eye( )  Special matrices such as: pascal ( )magic ( )rosser ( )  help(gallery) for list of all special matrices

Numerical Methods

So What are Numerical Methods?  A tool for efficiently solving complex mathematical problems.  Discrete methods which repeat calculations until the correct answer is obtained.  Very complex… we will only touch the surface. For more, you should consider taking the Numerical Methods course in the math department.  Really, really cool!

Discretization  Numerical methods approximate solutions by treating continuous functions as a series of points.  Fortunately, this is how MATLAB works!  Your “step” (often a time-step) is very important. The smaller it is, the more accurate your results will be but the slower your program will run.

Iterative Methods  Numerical methods also require repeating calculations until the correct answer is found.  This can be accomplished in a few easy ways…  Loops which use a value or values from a previous run through the loop.  Loops which call a function and use one or more of its outputs as its inputs in the next loop.  Functions which recursively call themselves, giving information to the next level and passing information back down. These can be hard to conceptualize.

Why are Numerical Methods Useful?  First and foremost, they are very fast…  You may have noticed that using symbolics is pretty slow in MATLAB. If you have a large number of calculations to do, this can add up quickly.  Using numerical methods to solve equations, or to find say, the roots of an equation is much faster.  Some equations simply can’t be solved explicitly…  eg:

Numerical Integration  If we think of an integral as the area beneath a curve, we can approximate it in a few ways…  By taking two discrete points, we can calculate the area of the trapezoid formed by them and the axis.  Then we can add up all the trapezoids to get the total area.  If the distance between our points is small enough, the solution is almost exact!

Numerical Integration  That sounds like a bit of a pain… we could do it, but is there an easier way?  Yes! Because the MATLAB developers love you so much, they included the trapz function!  Note that trapz assumes a spacing of 1 between your elements. So we need to multiply the result by the spacing… Lets try some:  x=0:1:3; y=x.^2; 1*trapz(y)ans = 9.5  x=0:0.1:3; y=x.^2; 0.1*trapz(y)ans = 9.05  x=0:0.01:3; y=x.^2; 0.01*trapz(y)ans = 9.005

Numerical Differentiation  Differentiation gives the instantaneous slope of a function at a given point. We can come very close to that exact value by looking at a very small piece of the curve and treating it as a straight line…  This straight line (a secant) approaches the tangent line as the distance between the points gets small.

Numerical Differentiation  The formula for numerical differentiation is…  Where f(x) is some function and h is the step.  Lets find the derivative of sine at π/3:  y1=sin(pi/3); y2=sin(pi/3+0.01);  y_prime=(y2-y1)/0.01  ans = (The exact answer is.5)  Using a step of instead gives ….

Newton’s Method  Newton’s Method is useful to find a root or roots of an equation.  It requires knowledge of the function, the derivative of the function (numerical differentiation can come in handy here) and an initial guess of the answer.  It can be a bit picky about the initial guess… the iteration can get stuck “bouncing” or it can converge to a root which is not desired.  Good judgment is required on a case-by-case basis to determine if the method is appropriate and what the initial guess should be.

Newton’s Method  Newton’s Method uses the derivative of at an initial guess function to evaluate a new guess for the root of the function until the root is found.  We iterate the above equation until the following is satisfied:  Epsilon is referred to as the error bound. It should be determined by the function you are solving.

Example of Newton’s Method  How calculators do division:  We want to compute x=1/d without using a division operator… lets try Newton’s Method!  First, we need to rewrite our equation in a manner that the solution is zero when we find d:  Next, we need the derivative:  Now we can plug these into the Newton’s Method formula:

Continuing the Example…  Please go to the course website and download the skeleton code for the example.  We’ll go through it together. After class a detailed and highly commented version will be posted on the website with the skeleton code.