MA/CS 375 Fall 2002 Lecture Summary Week 1  Week 7.

Slides:



Advertisements
Similar presentations
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 9 Instructor: Tim Warburton.
Advertisements

Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
CSE 123 Symbolic Processing. Declaring Symbolic Variables and Constants To enable symbolic processing, the variables and constants involved must first.
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.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 18 Sit in your groups.
MATH 685/ CSI 700/ OR 682 Lecture Notes
Linear Algebraic Equations
MECH300H Introduction to Finite Element Methods Lecture 2 Review.
Matlab Matlab is a powerful mathematical tool and this tutorial is intended to be an introduction to some of the functions that you might find useful.
MOHAMMAD IMRAN DEPARTMENT OF APPLIED SCIENCES JAHANGIRABAD EDUCATIONAL GROUP OF INSTITUTES.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 32.
EGR 105 Foundations of Engineering I Session 3 Excel – Basics through Graphing Fall 2008.
1 Python Chapter 2 © Samuel Marateck, After you install the compiler, an icon labeled IDLE (Python GUI) will appear on the screen. If you click.
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM.
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 2 Instructor: Tim Warburton.
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 6 Various Finite Difference Discretizations for the Advection Equations.
Multivariate Linear Systems and Row Operations.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 13.
Preview of Calculus.
Chapter 10 Review: Matrix Algebra
Scientific Computing Linear Systems – LU Factorization.
Chapter 5. Loops are common in most programming languages Plus side: Are very fast (in other languages) & easy to understand Negative side: Require a.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Matrix Algebra. Quick Review Quick Review Solutions.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
THE MATLAB ENVIRONMENT VARIABLES BASIC COMMANDS HELP HP 100 – MATLAB Wednesday, 8/27/2014
Sistem Kontrol I Kuliah II : Transformasi Laplace Imron Rosyadi, ST 1.
Erin Catto Blizzard Entertainment Numerical Integration.
ME451 Kinematics and Dynamics of Machine Systems
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM CISE301_Topic1.
Math 15 Lecture 7 University of California, Merced Scilab A “Very” Short Introduction.
ME451 Kinematics and Dynamics of Machine Systems Numerical Solution of DAE IVP Newmark Method November 1, 2013 Radu Serban University of Wisconsin-Madison.
Lecture 22 MA471 Fall Advection Equation Recall the 2D advection equation: We will use a Runge-Kutta time integrator and spectral representation.
Hydroinformatics: Session4 Dr Ivan Stoianov Room 328B Dr Andrew Ireson (Room 304) Mr Juan Rodriguez-Sanchez (411A) Mr Baback.
MA/CS 375 Fall MA/CS 375 Fall 2003 Lecture 19.
Numerical Computation Lecture 2: Introduction to Matlab Programming United International College.
MATLAB Basics. The following screen will appear when you start up Matlab. All of the commands that will be discussed should be typed at the >> prompt.
1 EEE 431 Computational Methods in Electrodynamics Lecture 4 By Dr. Rasime Uyguroglu
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 31.
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 5 Summary of convergence checks for LMM and one-step time stepping Instructor:
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 8.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 21.
Programming assignment #2 Solving a parabolic PDE using finite differences Numerical Methods for PDEs Spring 2007 Jim E. Jones.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 12.
MA/CS 375 Fall 2002 Lecture 3. Example 2 A is a matrix with 3 rows and 2 columns.
MATLAB Lecture Two Tuesday 5 July Chapter 3.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 7.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 8.
MA/CS 375 Fall 2003 Lecture 3. .* Multiplication We can use the.* operator to perform multiplication entry by entry of two matrices:
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
Copyright © Cengage Learning. All rights reserved. 2 SYSTEMS OF LINEAR EQUATIONS AND MATRICES.
MA/CS 375 Fall 2002 Lecture 2. Motivation for Suffering All This Math and Stuff Try the Actor demo from
29 January 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
MATLAB Constants, Variables & Expression Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 6.
1 Spring 2003 Prof. Tim Warburton MA557/MA578/CS557 Lecture 25.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 5.
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
NUMERICAL ANALYSIS I. Introduction Numerical analysis is concerned with the process by which mathematical problems are solved by the operations.
MTH108 Business Math I Lecture 20.
Numerical Methods for Partial Differential Equations
MA/CS 375 Spring 2002 Lecture 19 MA/CS 375 Fall 2002.
Lecture 19 MA471 Fall 2003.
MATLAB DENC 2533 ECADD LAB 9.
MATH 175: Numerical Analysis II
Chapter 2 A Survey of Simple Methods and Tools
Errors and Error Analysis Lecture 2
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM CISE301_Topic1.
Presentation transcript:

MA/CS 375 Fall 2002 Lecture Summary Week 1  Week 7

Theoretical Exercise Say we wish to design a self-playing computer game like asteroids. The player controls a rocket. There are enemy rockets who can shoot torpedoes and who can ram the player. There are moving asteroids of fairly arbitrary shape. Let’s work through the details involved……

Review We are going to do a fast review from basics to conclusion.

Week 1 Basics

Ok – Cast your minds back We are first faced with a text prompt:

Basic Math We can create our own variables and apply basic algebraic operations on these variables. Basic operations include addition (+), multiplication (*), subtraction (-), division (/ or \).

a = 1 b = a/2 c = b*3 Do the math and: b = a/2 = ½ c = b*3 = 1.5

Basic Arrays (Matrices) We can create one- or two-dimensional variables of arbitrary size. We can then apply basic linear algebra operations on these.

Example 2 A is a matrix with 3 rows and 2 columns.

Matrix Addition in Matlab

Matrix Subtraction in Matlab

Matrix Multiplication There is a specific definition of matrix multiplication. In index notation: i.e. for the (i,j) of the result matrix C we take the i’th row of A and multiply it, entry wise, with the j’th column of B

Example 4 (matrix multiplication)

Functions in Matlab Matlab has a number of built-in functions: –cos, sin, tan, acos, asin, atan –cosh, sinh, tanh, acosh, asinh, atanh –exp, log, sqrt They all take matrices as arguments and return matrices of the same dimensions. e.g. cos([1 2 3]) For other functions type: > help matlab\elfun

Example of Function of Vector

Custom-Made Matlab Functions function [ radius, theta] = myfunc( x, y) % this is a comment, just like // in C++ % now create and evaluate theta (in radians) theta = atan2(y,x); % now create and evaluate radius radius = sqrt( x.^2 + y.^2); function end Say we wish to create a function that turns Cartesian coordinates into polar coordinates. We can create a text file with the following text. It can be called like any built in function.

Custom Built Function For Matlab Make sure you use cd in Matlab to change to the directory containing myfunc.m the arguments to myfunc could also have been matrices – leading to two matrices being output.

Matlab as Programming Language We can actually treat Matlab as a coding language. It allows script and/or functions. Loops are allowed, but since Matlab is an interpreted language, their use can lead to slow code.

Loops in Matlab One variant of Matlab loop syntax is: for var=start:end commands; end

Example of a Matlab Loop Say I want to add the numbers from 1 to 10, without using the Matlab intrinsic sum.

Week 2 Plotting Finite precision effects

Plotting Recall we can create a function of a vector. Then plot the vector as one ordinate and the function of the vector as the other ordinate.

Example 5 (figure created by Matlab)

Adding Titles, Captions, Labels, Multiple Plots

subplot If you wish to create a figure with two sub-figures you can use the subplot function: subplot(1,2,1) requests 1 row of figures 2 columns of figures 1 st figure

subplot(1,2,1)subplot(1,2,2)

Starting Numerics We next considered some limitations inherent in fixed, finite-precision representation of floating point numbers.

A Convergent Binary Representation of Any Number Between 0 and 1 a similar representation in base 10: Volunteer ?

Finite Binary Approximations of a Real Number We can easily show that T N is bounded as: (think of Zeno’s paradox)

Monster #1 Consider: What should its behavior be as: Use subplots for the following 2 plots Plot this function at 1000 points in: Label everything nicely, include your name in the title. In a text box explain what is going on, print it out and hand it in

when we zoom in we see that the large+small operation is introducing order eps errors which we then divide with eps to get O(1) errors !. Each stripe is a region where 1+ x is a constant ( think about the gaps between numbers in finite precision ) Then we divide by x and the stripes look like hyperbola. The formula looks like (c-1)/x with a new c for each stripe. Monster #1

Monster #2 Consider: What should its behavior be as:

As x increases past ~=36 we see that f drops to 0 !! Monster #2 cont (finite precision effects from large*(1+small) )

Limit of

Consider: What should its behavior be as: Monster #4

Monster 4 cont Behavior as delta  0 : or if you are feeling lazy use the definition of derivative, and remember: d(sin(x))/dx = cos(x)

Monster 4 cont ( parameter differentiation, delta=1e-4) OK

Monster 4 cont ( parameter differentiation, delta=1e-7) OK

Monster 4 cont ( parameter differentiation, delta=1e-12) Worse

Monster 4 cont ( parameter differentiation, delta=1e-15) When we make the delta around about machine precision we see O(1) errors !. Bad

Approximate Explanation of Monster #4 1) Taylor’s thm: 2) Round off errors 3) Round off in computation of f and x+delta 4) Put this together:

i.e. for or equivalently approximation error decreases as delta decreases in size. BUT for round off dominates!.

Week 3 & 4 We covered taking approximate derivatives in Matlab and manipulating images as matrices.

Week 5 Approximation of the solution to ordinary differential equations. Adams-Bashforth schemes. Runge-Kutta time integrators.

Ordinary Differential Equation Example: t is a variable for time u is a function dependent on t given u at t = 0 given that for all t the slope of us is –u what is the value of u at t=T

Forward Euler Numerical Scheme Numerical scheme: Discrete scheme: where:

Summary of dt Stability 0 < dt <1 stable and convergent since as dt  0 the solution approached the actual solution. 1 <= dt < 2 bounded but not cool. 2 <= dt exponentially growing, unstable and definitely not cool.

Application: Newtonian Motion

N-Body Newtonian Gravitation Simulation Goal: to find out where all the objects are after a time T We need to specify the initial velocity and positions of the objects. Next we need a numerical scheme to advance the equations in time. Can use forward Euler…. as a first approach.

Numerical Scheme For m=1 to FinalTime/dt For n=1 to number of objects End For n=1 to number of objects End

AB Schemes Essentially we use interpolation and a Newton-Cotes quadrature formula to formulate:

Runge-Kutta Schemes See van Loan for derivation of RK2 and RK4. I prefer the following (simple) scheme due to Jameson, Schmidt and Turkel (1981):

Runge-Kutta Schemes Beware, it only works when f is a function of y and not t here s is the order of the scheme.

Week 6 Colliding disks project

Week 7 Matrix inverse and what can go wrong. Solving lower and upper triangular systems. LU factorization and partial pivoting.

Recall Given a matrix M then if it exists the inverse of a matrix M-1 is that matrix which satisfies:

Examples If what is If A is an NxN matrix how can we calculate its inverse ?

Example cont The inverse of A can be calculated as: Now let’s see how well this exact solution works in Matlab:

Example cont With this formulation of the product of A and its inverse only satisfies the definition to 6 decimal places for delta=0.001