ACSL, POSTECH1 MATLAB 입문 CHAPTER 8 Numerical calculus and differential equations.

Slides:



Advertisements
Similar presentations
Numerical Integration
Advertisements

Numerical Differentiation and Quadrature (Integration) 1Daniel Baur / Numerical Methods for Chemical Engineers / Numerical Quadrature Daniel Baur ETH Zurich,
Ordinary Differential Equations
MATHEMATICAL METHODS.
Numerical Integration of Functions
Lecture 18 - Numerical Differentiation
Chapter 19 Numerical Differentiation §Estimate the derivatives (slope, curvature, etc.) of a function by using the function values at only a set of discrete.
Chapter 1 Introduction The solutions of engineering problems can be obtained using analytical methods or numerical methods. Analytical differentiation.
Ordinary Differential Equations Final Review Shurong Sun University of Jinan Semester 1,
1 Chapter 9 Differential Equations: Classical Methods A differential equation (DE) may be defined as an equation involving one or more derivatives of an.
Differential Equations and Boundary Value Problems
6&7-2 Dynamics, two examples of the use of ode45. Numeric Integration using trapz and quad/quadl functions. Readings: Matlab by Pratap Chapter 5.4,5.5.
7.1 – Completing the Square
Numerical Solution of Ordinary Differential Equation
CISE301_Topic7KFUPM1 SE301: Numerical Methods Topic 7 Numerical Integration Lecture KFUPM Read Chapter 21, Section 1 Read Chapter 22, Sections 2-3.
Lecture 2 Differential equations
CISE301_Topic71 SE301: Numerical Methods Topic 7 Numerical Integration Lecture KFUPM (Term 101) Section 04 Read Chapter 21, Section 1 Read Chapter.
Chapter 4 Additional Derivative Topics Section 5 Implicit Differentiation.
Professor Walter W. Olson Department of Mechanical, Industrial and Manufacturing Engineering University of Toledo Solving ODE.
Graph quadratic equations. Complete the square to graph quadratic equations. Use the Vertex Formula to graph quadratic equations. Solve a Quadratic Equation.
CpE- 310B Engineering Computation and Simulation Dr. Manal Al-Bzoor
Ch 8.1 Numerical Methods: The Euler or Tangent Line Method
Simpson’s 1/3 rd Rule of Integration. What is Integration? Integration The process of measuring the area under a.
MECN 3500 Inter - Bayamon Lecture Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010.
ACSL, POSTECH1 MATLAB 입문 CHAPTER 8 Numerical calculus and differential equations.
Chapter 9 Introduction to MATLAB for Engineers, Third Edition
CMPS1371 Introduction to Computing for Engineers NUMERICAL METHODS.
1 Simpson’s 1/3 rd Rule of Integration. 2 What is Integration? Integration The process of measuring the area under a curve. Where: f(x) is the integrand.
Chapters 5 and 6: Numerical Integration
ORDINARY DIFFERENTIAL EQUATION (ODE) LAPLACE TRANSFORM.
Autumn 2008 EEE8013 Revision lecture 1 Ordinary Differential Equations.
More U-Substitution February 17, Substitution Rule for Indefinite Integrals If u = g(x) is a differentiable function whose range is an interval.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
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
Scientific Computing Linear Least Squares. Interpolation vs Approximation Recall: Given a set of (x,y) data points, Interpolation is the process of finding.
Rules of differentiation REVIEW:. The Chain Rule.
Ordinary Differential Equations
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
Numerical Methods for Solving ODEs Euler Method. Ordinary Differential Equations  A differential equation is an equation in which includes derivatives.
Calculus and Analytic Geometry I Cloud County Community College Fall, 2012 Instructor: Timothy L. Warkentin.
Numerical Methods for Engineering MECN 3500
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 12.
Quadrature rules 1Michael Sokolov / Numerical Methods for Chemical Engineers / Numerical Quadrature Michael Sokolov ETH Zurich, Institut für Chemie- und.
Week 6 Second Order Transient Response. Topics Second Order Definition Dampening Parallel LC Forced and homogeneous solutions.
Numerical Differentiation and Quadrature (Integration)
CHAPTER 3 NUMERICAL METHODS
Barnett/Ziegler/Byleen Business Calculus 11e1 Chapter 13 Review Important Terms, Symbols, Concepts 13.1 Antiderivatives and Indefinite Integrals A function.
3 DERIVATIVES.  Remember, they are valid only when x is measured in radians.  For more details see Chapter 3, Section 4 or the PowerPoint file Chapter3_Sec4.ppt.
Newton’s Method, Root Finding with MATLAB and Excel
ACSL, POSTECH1 MATLAB 입문 CHAPTER 8 Numerical Calculus and Differential Equations.
Suppose we are given a differential equation and initial condition: Then we can approximate the solution to the differential equation by its linearization.
Chapter 4 Additional Derivative Topics Section 5 Implicit Differentiation.
Antiderivatives and Indefinite Integration
Techniques for Numerical Integration
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 5 Integration and Differentiation.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
ACSL, POSTECH1 MATLAB 입문 CHAPTER 8 Numerical Calculus and Differential Equations.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 6 - Chapters 22 and 23.
Chapters 5 and 6: Numerical Integration Code development trapezoid rule Simpson’s rule Gauss quadrature Laguerre quadrature Analysis changing the variable.
SE301_Topic 6Al-Amer20051 SE301:Numerical Methods Topic 6 Numerical Integration Dr. Samir Al-Amer Term 053.
Computational Physics (Lecture 3) PHY4370. Interpolation Computer is a system with finite number of discrete states. – In numerical analysis, the results.
Differential Equations
CPE 332 Computer Engineering Mathematics II Part III, Chapter 11 Numerical Differentiation and Integration Numerical Differentiation and Integration.
CHAPTER 3 NUMERICAL METHODS.
FE Exam Tutorial
DIFFERENTIATION & INTEGRATION
Introduction to Programming for Mechanical Engineers (ME 319)
MATH 2140 Numerical Methods
Presentation transcript:

ACSL, POSTECH1 MATLAB 입문 CHAPTER 8 Numerical calculus and differential equations

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 2 Review of integration and differentiation Engineering applications  Acceleration and velocity:  Velocity and distance:  Capacitor voltage and current:  Work expended: A ab x f(x)

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 3 Integrals Properties of integrals Definite integrals Indefinite integrals This week's content handles definite integrals only the answers are always numeric see chapter 9

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 4 Derivatives Integration differentiation example : product rule : quotient rule : chain rule 1) 2) 3)

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 5 Numerical integration Rectangular integration trapezoidal integration Numerical integration functions CommandDescription quad (‘function’,a,b,tol) Uses an adaptive Simpson’s rule to compute the integral of the function ‘function’ with a as the lower integration limit and b as the upper limit. The parameter tol is optional. Tol indicates the specified error tolerance. quadl (‘function’, a,b,tol) Uses Lobatto quadrature to compute the integral of the function ‘function’. The rest of the syntax is identical to quad. trapz (x,y) Uses trapezoidal integration to compute the integral of y with respect to x, where the array y contains the function values at the points contained in the array x. y x a b y=f(x) y x a b ··· (exact solution) (use of the trapz function)

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 6 Rectangular, Trapezoidal, Simpson Rules Rectangular rule  Simplest, intuitive  wi = 1  Error=O(h) Mostly not good enough! Trapezoidal rule  Two point formula, h=b-a  Linear interpolating polynomial Simpson’s Rule  Three point formula, h=(b-a)/2  Quadratic interpolating polynomial  Lucky cancellation due to right-left symmetry  Significantly superior to Trapezoidal rule  Problem for large intervals -> Use the extended formula x 0 =a x N =b f(x) x1x1 x2x2 f(x 1 ) f(x 2 ) x 0 =a x 1 =b f(x) f0f0 f1f1

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations Matlab's Numerical Integration Functions trapz(x,y) When you have a vector of data  trapezoidal integration method  not as accurate as Simpson's method  very simple to use quad('fun',a,b,tol)When you have a function file  adaptive Simpson’s rule  integral of ’fun’ from a to b  tol is the desired error tolerance and is optional quad1('fun',a,b,tol) Alternative to quad  adaptive Lobatto integration  integral of ’fun’ from a to b  tol is the desired error tolerance and is optional 7

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 8 Comparing the 3 integration methods The answer is A1=A2=0.6667, A3= test case: Trapezoid Method: x=linspace(0,pi, 10); y=sin(x); trapz(x,y); (exact solution) ( Simpson's Method: quad('sin',0,pi); Lobatto's Method quadl('sin',0,pi);

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations To obtain a vector of integration results: For example,  sin(x) is the integral of the cosine(z) from z=0 to z=x In matlab we can prove this by calculating the quad integral in a loop: for k=1:101 x(k)= (k-1)* pi/100; % x vector will go from 0 to pi sine(k)=quad('cos',0,x(k)); % this calculates the integral from 0 to x end plot(x, sine) % this shows the first half of a sine wave % calculated by integrating the cosine 9

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations Using quad( ) on homemade functions 10 1) Create a function file: function c2 = cossq(x) % cosine squared function. c2 = cos(x.^2); Note that we must use array exponentiation. 2) The quad function is called as follows: quad('cossq',0,sqrt(2*pi)) 3) The result is

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 11

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 12 Numerical differentiation x1x1 x2x2 x3x3 y1y1 y2y2 y3y3 ΔxΔx ΔxΔx y=f(x) True slope A B C Δx 0 : backward difference : central difference : forward difference

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 13 The diff function The diff Function d= diff (x) Backward difference & central difference method example example x=[5, 7, 12, -20]; d= diff(x) d =

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations Try that: Compare Backward vs Central Construct function with noise x=[0:pi/50:pi]; n=length(x); % y=sin(x) +/-.025 random error y=sin(x) +.05*(rand(1,51)-0.5); td=cos(x); % true derivative Backward difference using diff: d1= diff(y)./diff(x); subplot(2,1,1) plot(x(2:n),td(2:n),x(2:n),d1,'o'); xlabel('x'); ylabel('Derivative'); axis([0 pi -2 2]) title('Backward Difference Estimate') Central Difference d2=(y(3:n)-y(1:n-2))./(x(3:n)-x(1:n-2)); subplot(2,1,2) plot(x(2:n-1),td(2:n-1),x(2:n-1),d2,'o'); xlabel('x'); ylabel('Derivative'); axis([0 pi -2 2]) title('Central Difference Estimate'); 14

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 15 Analytical solutions to differential equations(1/6) Solution by Direct Integration  Ordinary differential equation (ODE) example  Partial differential equation (PDE) -- not covered

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 16 Analytical solutions to differential equations(2/6) Oscillatory forcing function A second-order equation Forcing function example

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 17 Analytical solutions to differential equations(3/6) Substitution method for first-order equations Characteristic equation Characteristic root ( ), to find A Solution, Free response ∵ The solution y(t) decays with time if τ>0 τ is called the time constant. suppose for M at t=0 Such a function is the step function ( ), Forced response Natural (by Internal Energy) v.s. Forced Response (by External Energy) Transient (Dynamics-dependent) v.s. Steady-state Response (External Energy-dependent)

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations solve on paper then plot (next week we solve with Matlab) Use the method in previous slide 18

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations solve on paper then plot (next week we solve with Matlab) Re-arrange terms: mv' + cv = f, OR (m/c) v' + v = f/c now it's in the same form as 2 slides back 19

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 20 Analytical solutions to differential equations(4/6) Nonlinear equations Substitution method for second order equations(1/3) example () general solution suppose that solution 1)

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 21 Analytical solutions to differential equations(5/6) Substitution method for second order equations(2/3) ( ) general solution Euler’s identities period frequency 2) 3) () 1. Real and distinct: s 1 and s Real and equal: s Complex conjugates:

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations 22 Analytical solutions to differential equations(6/6) Substitution method for second order equations(3/3) 1.real, distinct roots: m=1,c=8, k=15. characteristic roots s=-3, complex roots: m=1,c=10,k=601 characteristic roots 3. unstable case, complex roots: m=1,c=-4,k=20 characteristic roots 4. unstable case, real roots: m=1,c=3,k=-10 characteristic roots s=2,-5.

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations Problem 22 Just find the roots to the characteristic equation and determine which form the free response will take (either 1, 2, 3 or 4 in previous slide) This alone can be a helpful check on matlab's solutions—if you don't get the right form, you can suspect there is an error somewhere in your solution 23

Acsl, Postech MATLAB 입문 : Chapter 8. Numerical calculus and differential equations Next Week: we learn how to solve ODE's with Matlab 24