1 Chapter 8 Calculus Operations with MATLAB We are now ready to see how calculus operations can be performed with MATLAB. It should be noted that a digital.

Slides:



Advertisements
Similar presentations
Discrete Controller Design
Advertisements

Beginning Programming for Engineers
ECE 8443 – Pattern Recognition EE 3512 – Signals: Continuous and Discrete Objectives: Response to a Sinusoidal Input Frequency Analysis of an RC Circuit.
1 Chapter 13 Curve Fitting and Correlation This chapter will be concerned primarily with two separate but closely interrelated processes: (1) the fitting.
1 Chapter 4 Curve Plotting with MATLAB MATLAB provides some very powerful features for plotting and labeling curves. These operations can be performed.
Chapter 11: Symbolic Computing for Calculus
Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Differentiation.
Section 7.2: Direction Fields and Euler’s Methods Practice HW from Stewart Textbook (not to hand in) p. 511 # 1-13, odd.
CSE 123 Symbolic Processing. Declaring Symbolic Variables and Constants To enable symbolic processing, the variables and constants involved must first.
Lecture 16 Symbolic Mathematics Symbolic mathematics: algebraezplotcalculus © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
Today’s class Romberg integration Gauss quadrature Numerical Methods
Ch 2.1: Linear Equations; Method of Integrating Factors
1 Chapter 9 Differential Equations: Classical Methods A differential equation (DE) may be defined as an equation involving one or more derivatives of an.
Boyce/DiPrima 9 th ed, Ch 2.1: Linear Equations; Method of Integrating Factors Elementary Differential Equations and Boundary Value Problems, 9 th edition,
Section 2.2 – Basic Differentiation Rules and Rates of Change.
Chapter 6 Differential Calculus
259 Lecture 16 Numerical Differentiation and Integration in MATLAB; Function M-files.
AP Calculus AB – Made Simple
ACSL, POSTECH1 MATLAB 입문 CHAPTER 8 Numerical calculus and differential equations.
259 Lecture 18 The Symbolic Toolbox. 2  MATLAB has a set of built-in commands that allow us to work with functions in a fashion similar to Mathematica.
9/14/ Trapezoidal Rule of Integration Major: All Engineering Majors Authors: Autar Kaw, Charlie Barker
1 Trapezoidal Rule of Integration. What is Integration Integration: The process of measuring the area under a function.
Formal Definition of Antiderivative and Indefinite Integral Lesson 5-3.
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.
1 Chapter 7 Integral Calculus The basic concepts of differential calculus were covered in the preceding chapter. This chapter will be devoted to integral.
Chapter 2: First Steps in MuPAD MATLAB for Scientist and Engineers Using Symbolic Toolbox.
Introduction To this point MATLAB has been used to answer questions with a numeric value ▫Variables are assigned specific values ▫Answers are numbers MATLAB.
Copyright © 2015 Chris J Jewell 1 Mechanics M1 (Slide Set 11) Core Mathematics for Mechanics M1 Mechanics M1.
Trapezoidal Rule of Integration
11/30/ Romberg Rule of Integration Mechanical Engineering Majors Authors: Autar Kaw, Charlie Barker
12/1/ Trapezoidal Rule of Integration Civil Engineering Majors Authors: Autar Kaw, Charlie Barker
CSE 330 : Numerical Methods Lecture 15: Numerical Integration - Trapezoidal Rule Dr. S. M. Lutful Kabir Visiting Professor, BRAC University & Professor.
Math – Antiderivatives 1. Sometimes we know the derivative of a function, and want to find the original function. (ex: finding displacement from.
ACSL, POSTECH1 MATLAB 입문 CHAPTER 8 Numerical calculus and differential equations.
Distance Traveled Area Under a curve Antiderivatives
Integral calculation. Indefinite integral. Differentiation Rules If f(x) = x 6 +4x 2 – 18x + 90 f’(x) = 6x 5 + 8x – 18 *multiply by the power, than subtract.
Chapter 11 Calculus. Symbolic Expressions Required: > Symbolic Math Toolbox > Use Symbolic Variables.
PS 5-3 Integration –Discrete data –Polynomial functions Differentiation –Discrete data –Polynomial functions Roots (i.e., zeros) of functions –Polynomial.
Antiderivatives and Indefinite Integration
Ch 2.1: Linear Equations; Method of Integrating Factors A linear first order ODE has the general form where f is linear in y. Examples include equations.
Linear Constant-Coefficient Difference Equations
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
3/12/ Trapezoidal Rule of Integration Computer Engineering Majors Authors: Autar Kaw, Charlie Barker
3/20/ Trapezoidal Rule of Integration Chemical Engineering Majors Authors: Autar Kaw, Charlie Barker
EEE 242 Computer Tools for Electrical Engineering Lecture IV Mustafa KARABULUT.
Mathematical Applications By Matlab 3 rd Day Dr. Wael Khedr CSI Dept.
Numerical Differentiation and Integration in MATLAB; Function M-files
Trapezoidal Rule of Integration
Air Force Admin College, Coimbatore
Chapter 1 MATLAB Primer This introductory chapter is relatively short and has as its main objective the introduction of MATLAB® to the reader. This early.
Chapter 7 Numerical Differentiation and Integration
1. 2 What is Integration? Integration The process of measuring the area under a curve. Where: f(x) is the integrand a= lower limit of integration b=
Gauss Quadrature Rule of Integration
Symbolic mathematics: algebra ezplot calculus
Various Symbols for the Derivative
Trapezoidal Rule of Integration
Trapezoidal Rule of Integration
Divisibility Rules.
Chapter 7 Integral Calculus
Elements of Numerical Integration
Divisibility Rules.
Romberg Rule of Integration
Simpson’s 1/3rd Rule of Integration
Romberg Rule of Integration
Numerical Computation and Optimization
Romberg Rule of Integration
Numerical Computation and Optimization
Romberg Rule of Integration
Air Force Admin College, Coimbatore
Presentation transcript:

1 Chapter 8 Calculus Operations with MATLAB We are now ready to see how calculus operations can be performed with MATLAB. It should be noted that a digital computer operates on a numerical basis with addition, subtraction, multiplication, and division, along with memory storage and logic. True differentiation and integration can never be achieved exactly with numerical processes. However, there are two ways that differentiation and integration can be achieved on a practical level with MATLAB.

2 Two Types of Operations First, MATLAB can be viewed as a very comprehensive "look-up" table in that numerous derivatives and integrals as character strings can be manipulated with software. The Symbolic Math Toolbox permits the exact formulas for derivatives and integrals to be extracted, manipulated, and plotted.

3 Two Types of Operations (Continued) Second, MATLAB can be used for calculus with numerical approximations to differentiation and integration. While such approximations are not exact, they can be used to provide extremely close approximations to the derivatives and integrals of experimental data, even when closed form solutions are impossible.

4 Symbolic Variables A symbolic variable is one that can be manipulated in the same manner as in an equation, and it may or may not ever take on any numerical values. To make x and a symbolic, the command is >> syms x a Alternately, the symbolic portion of a command may be enclosed with apostrophes ' '.

5 Symbolic Differentiation The command is diff( ) with the function to be differentiated in parentheses. All variables should have been established as symbolic variables or the function should be enclosed by apostrophes.

6 Example 8-1. Use MATLAB to determine derivative of function below. >> syms x >> y = 4*x^5 y = 4*x^5 >> yprime = diff(y) yprime = 20*x^4

7 Example 8-1. Continuation. Second Approach: >> yprime = diff(4*x^5) yprime = 20*x^4

8 Example 8-1. Continuation. Third Approach: >> y = '4*x^5' y = 4*x^5 >> yprime = diff(y) yprime = 20*x^4

9 Example 8-1. Continuation. The third approach could also be performed in one step. >> yprime = diff('4*x^5') yprime = 20*x^4

10 Example 8-2. Use ezplot to plot y and yprime of Example 8-1. The simplest form is ezplot(y), but the domain will be from -2 to 2. The domain can be changed by >> ezplot(y, [x1 x2]) In this example, ezplot(y, [-1 1]) ezplot(yprime,[-1 1]) The plots after labeling are shown on the next two slides.

11

12

13 Symbolic Integration The command is int( ) with the function to be integrated in parentheses. All variables should have been established as symbolic variables or the function should be enclosed by apostrophes. Indefinite Integral: >> yint = int(y) Definite Integral: >> yint = int(y, a, b)

14 Example 8-3. Use MATLAB to determine integral of function below. >> syms x >> y = x^2*exp(x) y = x^2*exp(x) >> z = int(y) z = x^2*exp(x)-2*x*exp(x)+2*exp(x)

15 Example 8-3. Continuation. We require that z(0) = 0, but the function obtained has a value of 2 at x = 0. Thus, >> z = z - 2 z = x^2*exp(x)-2*x*exp(x)+2*exp(x)-2 Plots of y and z are shown on the next two slides.

16

17

18 Numerical Differentiation Generally, numerical differentiation is more prone to error than numerical integration due to the nature of “sudden changes” in differentiation.

19 Diff Command for Numerical Data Assume that x and y have been defined at N+1 points. A vector u with N points is defined as

20 Diff Command for Numerical Data. Continuation. The following command forms u: >> u = diff(y) To approximate derivative, >> yprime = diff(y)/delx Because x and y have one more point than yprime, they can be adjusted. >> x = x(1:N) >> y = y(1:N) >> plot(x, y, x, yprime)

21 Example 8-5(a) For y = sin x, determine numerical derivative based on 11 points in one cycle. >> x = linspace(0, 2*pi, 11); >> y = sin(x); >> delx = 2*pi/10; >> yprime = diff(y)/delx; >> x = x(1:10); >> plot(x, yprime, x, cos(x),’o’) The plots are shown on the next slide.The approximation is “crude” as expected.

22

23 Example 8-5(b) For y = sin x, determine numerical derivative based on 101 points in one cycle. >> x = linspace(0, 2*pi, 101); >> y = sin(x); >> delx = 2*pi/100; >> yprime = diff(y)/delx; >> x = x(1:100); >> plot(x, yprime, x, cos(x),’o’) The plots are shown on the next slide.The approximation is much better.

24

25 Numerical Integration Two types will be studied: 1. Zero-order integration 2. First-order integration, which is also known as the trapezoidal rule. Assume vectors x and y that have each been defined at N points.

26 Zero-Order Integration

27 Two Zero-Order MATLAB Commands The two MATLAB commands for zero- order integration are sum() and cumsum(). >> area = delx*sum(y) >> z = delx*cumsum(y)

28 First-Order Integration

29 Two First-Order MATLAB Commands The two MATLAB commands for first- order integration are trapz() and cumtrapz(). >> area = delx*trapz(y) >> z = delx*cumtrapz(y)

30 Example 8-6(a). Determine exact area A for following integral:

31 Example 8-6(b). Determine approximate area A1 with zero-order integration algorithm and step-size of >> delx = 0.05; >> x = 0:delx:2; >> y = 4*x.^3; >> A1 = delx*sum(y) A1 =

32 Example 8-6(c). Determine approximate area A2 with first-order integration algorithm and step-size of >> delx = 0.05; >> x = 0:delx:2; >> y = 4*x.^3; >> A2 = delx*trapz(y) A2 =

33 Example 8-7(a). Determine the exact running integral for the following function:

34 Example 8-7(b) and (c). Determine first- order approximation with 100 points per cycle and plot the two functions. >> delx = 2*pi/100; >> x = 0:delx:2*pi; >> y = sin(x); >> z1 = delx*cumtrapz(y); >> plot(x, z1, x, 1 - cos(x), ‘o’) The plots are shown on the next slide.

35

36 Example 8-8 A test is performed on a mechanical part and the acceleration versus time is measured and shown on the next slide. Use MATLAB to determine and plot the velocity and displacement as a function of time.

37 Acceleration versus Time Data

38 MATLAB Analysis >> delt = 0.1; >> t = 0:delt:2; >> a = [ the 21 values of a]; >> v = delt*cumtrapz(a); >> y = delt*cumtrapz(v); >> plot(t,a,t,v,t,y) Additional labeling was provided and the curves are shown on the next slide.

39