ebook img

MATLAB Differential and Integral Calculus PDF

220 Pages·2014·5.033 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview MATLAB Differential and Integral Calculus

L ó p e z MATLAB Differential and Integral Calculus M A T MATLAB is a high-level language and environment for numerical computation, visualization, and pro- L gramming. Using MATLAB, you can analyze data, develop algorithms, and create models and appli- A cations. The language, tools, and built-in math functions enable you to explore multiple approaches B and reach a solution faster than with spreadsheets or traditional programming languages, such as C/C++ or Java. D MATLAB Differential and Integral Calculus introduces you to the MATLAB language with practical i f hands-on instructions and results, allowing you to quickly achieve your goals. In addition to giving a f short introduction to the MATLAB environment and MATLAB programming, this book provides all the e material needed to work with ease in differential and integral calculus in one and several variables. r Among other core topics of calculus, you will use MATLAB to investigate convergence, find limits of e sequences and series and, for the purpose of exploring continuity, limits of functions. Various kinds of n local approximations of functions are introduced, including Taylor and Laurent series. Symbolic and t i numerical techniques of differentiation and integration are covered with numerous examples, including a applications to finding maxima and minima, areas, arc lengths, surface areas and volumes. You will l also see how MATLAB can be used to solve problems in vector calculus and how to solve differential a and difference equations. n d • How to use the MATLAB environment I • How to explore convergence and find limits of sequences, series and functions with MATLAB n • How to investigate the continuity of functions, and produce high quality graphical representations of curves and surfaces t • How to use MATLAB to differentiate functions, with applications to maxima and minima e • How to use MATLAB to integrate functions, with applications to finding arc lengths, areas, surface areas and volumes g • How MATLAB can be used to solve problems in vector calculus • How to use MATLAB to solve differential and difference equations r a l C a l c u l u s ISBN 978-1-4842-0305-7 54999 Shelve in Applications/Mathematical & 9781484203057 Statistical Software For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. Contents at a Glance About the Author �����������������������������������������������������������������������������������������������������������������ix ■ Chapter 1: Introduction and the MATLAB Environment �����������������������������������������������������1 ■ Chapter 2: Limits and Continuity� One and Several Variables ������������������������������������������17 ■ Chapter 3: Numerical Series and Power Series ���������������������������������������������������������������45 ■ Chapter 4: Derivatives and Applications� One and Several Variables ������������������������������69 ■ Chapter 5: Vector Differential Calculus and Theorems in Several Variables �����������������109 ■ Chapter 6: Integration and Applications ������������������������������������������������������������������������129 ■ Chapter 7: Integration in Several Variables and Applications ���������������������������������������163 ■ Chapter 8: Differential Equations �����������������������������������������������������������������������������������181 iii Chapter 1 Introduction and the MATLAB Environment 1.1 Numerical Computation with MATLAB You can use MATLAB as a powerful numerical computer. While most calculators handle numbers only to a preset degree of precision, MATLAB performs exact calculations to any desired degree of precision. In addition, unlike calculators, we can perform operations not only with individual numbers, but also with objects such as arrays. Most of the topics of classical numerical analysis are treated by this software. It supports matrix calculus, statistics, interpolation, least squares fitting, numerical integration, minimization of functions, linear programming, numerical and algebraic solutions of differential equations and a long list of further methods that we’ll meet as this book progresses. Here are some examples of numerical calculations with MATLAB. (To obtain the results simply press Enter once the desired command has been entered after the prompt “>>”.) 1. We calculate 4 + 3 to obtain the result 7. To do this, just type 4 + 3, and then Enter. >> 4 + 3 ans = 7 2. We find the value of 3 to the power of 100, without having previously set the precision. To do this we simply enter 3 ^ 100. >> 3 ^ 100 ans = 5. 1538e + 047 3. We can use the command “format long e” to obtain results to 15 digits (floating-point). >> format long e >> 3^100 ans = 5.153775207320115e + 047 1 Chapter 1 ■ IntroduCtIon and the MatLaB envIronMent 4. We can also work with complex numbers. We find the result of the operation raising (2 + 3i) to the power 10 by typing the expression (2 + 3i) ^ 10. >> (2 + 3i) ^ 10 ans = -1 415249999999998e + 005 - 1. 456680000000000e + 005i 5. The previous result is also available in short format, using the “format short” command. >> format short >> (2 + 3i)^10 ans = -1.4152e + 005- 1.4567e + 005i 6. We can calculate the value of the Bessel function J at 11.5. To do this we type 0 besselj(0,11.5). >> besselj(0,11.5) ans = -0.0677 7. We can also perform numerical integration. To calculate the integral of sin(sin(x)) between 0 and p we type int(‘sin((sin(x)),’ 0, pi). >> int ('sin(sin(x))', 0, pi) ans = 1235191162052677/2251799813685248 * pi These ideas will be treated more thoroughly later in the book. 1.2 Symbolic Computation with MATLAB MATLAB perfectly handles symbolic mathematical computations, manipulating and performing operations on formulae and algebraic expressions with ease. You can expand, factor and simplify polynomials and rational and trigonometric expressions, find algebraic solutions of polynomial equations and systems of equations, evaluate derivatives and integrals symbolically, find solutions of differential equations, manipulate powers, and investigate limits and many other features of algebraic series. To perform these tasks, MATLAB first requires all the variables (or algebraic expressions) to be written between single quotes. When MATLAB receives a variable or expression in quotes, it is interpreted as symbolic. Here are some examples of symbolic computations with MATLAB. 2 Chapter 1 ■ IntroduCtIon and the MatLaB envIronMent 1. We can expand the following algebraic expression: ((x + 1)(x + 2) - (x + 2) ^ 2)^3. This is done by typing: expand(‘((x + 1)(x + 2) - (x + 2) ^ 2) ^ 3’). The result will be another algebraic expression: >> syms x; expand(((x + 1) *(x + 2)-(x + 2) ^ 2) ^ 3) ans = -x ^ 3-6 * x ^ 2-12 * x-8 2. We can factor the result of the calculation in the above example by typing: factor(‘((x + 1) *(x + 2) - (x + 2) ^ 2) ^ 3’) >> syms x; factor(((x + 1)*(x + 2)-(x + 2)^2)^3) ans = -(x+2)^3 3. We can find the indefinite integral of the function (x ^ 2) sin(x) ^ 2 by typing: int(‘x ^ 2 * sin(x) ^ 2,’ ‘x’) >> int('x^2*sin(x)^2', 'x') ans = x ^ 2 *(-1/2 * cos(x) * sin(x) + 1/2 * x)-1/2 * x * cos(x) ^ 2 + 1/4 * cos(x) * sin(x) + 1/4 * 1/x-3 * x ^ 3 4. We can simplify the previous result: >> syms x; simplify(int(x^2*sin(x)^2, x)) ans = sin(2*x)/8 -(x*cos(2*x))/4 -(x^2*sin(2*x))/4 + x^3/6 5. We can present the previous result using a more elegant mathematical notation: >> syms x; pretty(simplify(int(x^2*sin(x)^2, x))) ans = 2 3 sin(2 x) x cos(2 x) x sin(2 x) x -------- - ---------- - ----------- + -- 8 4 4 6 3 Chapter 1 ■ IntroduCtIon and the MatLaB envIronMent 6. We can find the series expansion up to order 12 of the function x ^ 2 * sin (x) ^ 2, presenting the result in elegant form: >> pretty(taylor('x^2*sin(x)^2',12)) 4 6 8 10 12 x - 1/3 x + 2/45 x - 1/315 x + o (x) 7. We can solve the equation 3ax - 7 x ^ 2 + x ^ 3 = 0 (where a is a parameter): >> solve('3*a*x-7*x^2 + x^3 = 0', 'x') ans = [ 0] [7/2 + 1/2 *(49-12*a) ^(1/2)] [7/2-1/2 *(49-12*a) ^(1/2)] 8. We can find the five solutions of the equation x ^ 5 + 2 x + 1 = 0: >> solve('x^5+2*x+1','x') ans = RootOf(_Z^5+2*_Z+1) As the result does not explicitly give five solutions, we apply the “allvalues” command: >> allvalues(solve('x^5+2*x+1','x')) ans = [-.7018735688558619-. 8796971979298240 * i] [-. 7018735688558619 +. 8796971979298240 * i] [-. 4863890359345430] [.9450680868231334-. 8545175144390459 * i] [. 9450680868231334 +. 8545175144390459 * i] On the other hand, MATLAB can use the Maple program libraries to work with symbolic math, and can thus extend its field of action. In this way, MATLAB can be used to work on such topics as differential forms, Euclidean geometry, projective geometry, statistics, etc. At the same time, Maple can also benefit from MATLAB’s powers of numerical calculation, which might be used, for example, in combination with the Maple libraries (combinatorics, optimization, number theory, etc.) 1.3 MATLAB and Maple Provided the “Extended Symbolic Math Toolbox” is installed then MATLAB can extend its symbolic calculation abilities by making use of the Maple libraries. To use a Maple command from MATLAB, use the command ‘maple’ followed by the corresponding Maple syntax. 4 Chapter 1 ■ IntroduCtIon and the MatLaB envIronMent To use a Maple command from Matlab, the syntax is as follows: maple ('Maple_command_syntax') or alternatively: maple 'Maple_command_syntax' To use a Maple command with N arguments from Matlab, the syntax is as follows: maple('Maple_command_syntax', argument1, argument2,..., argumentN) Here are some examples. 1. We can calculate the limit of the function (x ^ 3-1) / (x-1) as x tends to 1: >> maple('limit((x^3-1)/(x-1),x=1)') ans = 3 We could also have used the following syntax: >> maple limit('(x^3-1)/(x-1),x=1)'; ans = 3 2. We can calculate the greatest common divisor of 10,000 and 5,000: >> maple('gcd', 10000, 5000) ans = 5000 1.4 Graphics with MATLAB MATLAB can generate two- and three-dimensional graphs, as well as contour and density plots. You can graphically represent data lists, controlling colors, shading and other graphics features. Animated graphics are also supported. Graphics produced by MATLAB are portable to other programs. Some examples of MATLAB graphics are given below. 1. We can represent the function xsin(1/x) for x ranging between -p/4 and p/4, taking 300 equidistant points in the interval. See Figure 1-1. >> x = linspace(-pi/4,pi/4,300); >> y=x.*sin(1./x); >> plot(x,y) 5 Chapter 1 ■ IntroduCtIon and the MatLaB envIronMent Figure 1-1. 2. We can give the above graph a title and label the axes, and we can add a grid. See Figure 1-2. >> x = linspace(-pi/4,pi/4,300); >> y=x.*sin(1./x); >> plot(x,y); >> grid; >> xlabel('Independent variable X'); >> ylabel('Dependent variable Y'); >> title('The function y=xsin(1/x)') 6 Chapter 1 ■ IntroduCtIon and the MatLaB envIronMent Figure 1-2. 3. We can generate a graph of the surface defined by the function z = sin(sqrt(x^2+y^2)) / sqrt(x^2+y^2), where x and y vary over the interval (–7.5, 7.5), taking equally spaced points 0.5 apart. See Figure 1-3. >> x =-7.5:. 5:7.5; >> y = x; >> [X, Y] = meshgrid(x,y); >> Z=sin(sqrt(X.^2+Y.^2))./sqrt(X.^2+Y.^2); >> surf(X, Y, Z) 7

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.