Advanced Mathematics and Mechanics Applications Using ... .fr

The physical applications vary widely from solution of linear and nonlinear ... 1.2 MATLAB Commands and Related Reference Materials. MATLAB ... The manual for The Student Edition of MATLAB should be read thoroughly and kept handy for ...
252KB taille 2 téléchargements 348 vues
Chapter 1 Introduction

1.1 MATLAB: A Tool for Engineering Analysis This book presents various MATLAB applications in mechanics and applied mathematics. Our objective is to employ numerical methods in examples emphasizing the appeal of MATLAB as a programming tool. The programs are intended for study as a primary component of the text. The numerical methods used include interpolation, numerical integration, Þnite differences, linear algebra, Fourier analysis, roots of nonlinear equations, linear differential equations, nonlinear differential equations, linear partial differential equations, analytic functions, and optimization methods. Many intrinsic MATLAB functions are used along with some utility functions developed by the authors. The physical applications vary widely from solution of linear and nonlinear differential equations in mechanical system dynamics to geometrical property calculations for areas and volumes. For many years FORTRAN has been the favorite programming language for solving mathematical and engineering problems on digital computers. An attractive alternative is MATLAB which facilitates program development with excellent error diagnostics and code tracing capabilities. Matrices are handled efÞciently with many intrinsic functions performing familiar linear algebra tasks. Advanced software features such as dynamic memory allocation and interactive error tracing reduce the time to get solutions. The versatile but simple graphics commands in MATLAB also allow easy preparation of publication quality graphs and surface plots for technical papers and books. The authors have found that MATLAB programs are often signifantly shorter than corresponding FORTRAN versions. Consequently, more time is available for the primary purpose of computing, namely, to better understand physical system behavior. The mathematical foundation needed to grasp most topics presented here is covered in an undergraduate engineering curriculum. This should include a grounding in calculus, differential equations, and knowledge of a procedure oriented programming language like FORTRAN. An additional course on advanced engineering mathematics covering linear algebra, matrix differential equations, and eigenfunction solutions of partial differential equations will also be valuable. The MATLAB programs were written primarily to serve as instructional examples in classes traditionally referred to as advanced engineering mathematics and applied numerical methods. The greatest beneÞt to the reader will probably be derived through study of the programs relat© 2003 by CRC Press LLC

ing mainly to physics and engineering applications. Furthermore, we believe that several of the MATLAB functions are useful as general utilities. Typical examples include routines for spline interpolation, differentiation, and integration; area and inertial moments for general plane shapes; and volume and inertial properties of arbitrary polyhedra. We have also included examples demonstrating natural frequency analysis and wave propagation in strings and membranes. MATLAB is now employed in more than two thousand universities and the user community throughout the world numbers in the thousands. Continued growth will be fueled by decreasing hardware costs and more people familiar with advanced analytical methods. The authors hope that our problem solutions will motivate analysts already comfortable with languages like FORTRAN to learn MATLAB. The rewards of such efforts can be considerable.

1.2 MATLAB Commands and Related Reference Materials MATLAB has a rich command vocabulary covering most mathematical topics encountered in applications. The current section presents instructions on: a) how to learn MATLAB commands, b) how to examine and understand MATLAB’s lucidly written and easily accessible “demo” programs, and c) how to expand the command language by writing new functions and programs. A comprehensive online help system is included and provides lengthy documentation of all the operators and commands. Additional capabilities are provided by auxiliary toolboxes. The reader is encouraged to study the command summary to get a feeling for the language structure and to have an awareness of powerful operations such as null,orth,eig, and fft. The manual for The Student Edition of MATLAB should be read thoroughly and kept handy for reference. Other references [47, 97, 103] also provide valuable supplementary information. This book extends the standard MATLAB documentation to include additional examples which we believe are complementary to more basic instructional materials. Learning to use help, type, dbtype, demo, and diary is important to understanding MATLAB. help function name (such as help plot) lists available documentation on a command or function generically called “function name.” MATLAB responds by printing introductory comments in the relevant function (comments are printed until the Þrst blank line or Þrst MATLAB command after the function heading is encountered). This feature allows users to create online help for their own functions by simply inserting appropriate comments at the top of the function. The instruction type function name lists the entire source code for any function where source code is available (the code for intrinsic functions stored in compiled binary for computational efÞciency cannot be listed). Consider the following list of typical examples

© 2003 by CRC Press LLC

Command help help help demos type linspace type plot intro type intro graf2d graf3d help diary diary Þl name

demo

Resulting Action discusses use of the help command lists names of various demo programs lists the source code for the function which generates a vector of equidistant data values outputs a message indicating that plot is a built-in function executes the source code in a function named intro which illustrates various MATLAB functions. lists the source code for the intro demo program. By studying this example, readers can quickly learn many MATLAB commands demonstrates X-Y graphing demonstrates X-Y-Z graphing provides instructions on how results appearing on the command screen can be saved into a Þle for later printing, editing, or merging with other text instructs MATLAB to record, into a Þle called Þl name, all text appearing on the command screen until the user types diary off. The diary command is especially useful for making copies of library programs such as zerodemo initiates access to a lengthy set of programs demonstrating the functionality of MATLAB. It is also helpful to source list some of these programs such as: zerodemo, Þtdemo, quaddemo, odedemo, ode45, fftdemo, and truss

1.3 Example Problem on Financial Analysis Let us next analyze a problem showing several language constructs of MATLAB programming. Most of this book is devoted to solving initial value and boundary value problems for physical systems. For sake of variety we study brießy an elementary example useful in business, namely, asset growth resulting from compounded investment return. The differential equation Q (t) = R Q(t) + S exp(At) describes growth of investment capital earning a rate of investment return R and augmented by a saving rate S exp(At). The general solution of this Þrst order linear equation is   t Q(t) = exp(Rt) Q(0) + S exp((A − R)t)dt . 0

© 2003 by CRC Press LLC

A realistic formulation should employ inßation adjusted capital deÞned by q(t) = Q(t) exp(−It) where I denotes the annual inßation rate. Then a suitable model describing capital accumulation over a saving interval of t 1 years, followed by a payout period of t 2 years, is characterized as q  (t) = r q(t) + [s(t ≤ t1 ) − p exp(−at1 )(t > t1 )] exp(at), q(0) = q0 . The quantity (t ≤ t 1 ) equals one for t ≤ t 1 and is zero otherwise. This equation also uses inßation adjusted parameters r = R − I and a = A − I. The parameter s quantiÞes the initial saving rate and p is the payout rate starting at t = t 1 . It is plausible to question whether continuous compounding is a reasonable alternative to a discrete model employing assumptions such as quarterly or yearly compounding. It turns out that results obtained, for example, using discrete monthly compounding over several years differ little from those produced with the continuous model. Since long term rates of investment return and inßation are usually estimated rather than known exactly, the simpliÞed formulas for continuous compounding illustrate reasonably well the beneÞts of long term investment growth. Integrating the differential equation for the continuous compounding model gives q(t) = q0 exp(rt) + s[h(t) − (t > t1 ) exp(at1 )h(t − t1 )] − p (t > t1 ) h(t − t1 ) where h(t) = [exp(rt) − exp(at)]/(r − a). The limiting case for r = a is also dealt with appropriately in the program below. At time T 2 = t1 + t2 the Þnal capital q2 = q(T2 ) is q2 = q0 exp(rT2 ) + −

s [exp(rt1 ) − exp(at1 )] exp(rt2 ) r−a

p [exp(rt2 ) − exp(at2 )]. r−a

Therefore, for known r, a, t 1 , t2 , the four quantities q 2 , q0 , s, p are linearly related and any particular one of these values can be found in terms of the other three. For instance, when q0 = q2 = 0, the saving factor s needed to provide a desired payout factor p can be computed from the useful equation s = p[1 − exp((a − r)t2 )]/[exp(rt1 ) − exp(at1 )] A MATLAB program using the above equations was written to compute and plot q(t) for general combinations of the nine parameters R, A, I, t 1 , t2 , q0 , s, p, q2 . The program allows data to be passed through the call list of function Þnance, or the interactive input is activated when no call list data is passed. Finance calls function inputv to read data and the function savespnd to evaluate q(t). First we will show some numerical results and then discuss selected parts of the code. Consider a case where someone initially starting with $10,000 of capital expects to save for 40 years © 2003 by CRC Press LLC

and subsequently draw $50,000 annually from savings for 20 years, at which time the remaining capital is to be $100,000. Assume that the investment rate before inßation is R = 8 while the inßation rate is I = 4 . During the 60 year period, annual savings, as well as the pension payout amount, are to be increased to match inßation, so that A = 4. The necessary value of s and a plot of the inßation adjusted assets as a function of time are to be determined. The program output shows that when the unknown value of s was input as nan (meaning Not-a-Number in IEEE arithmetic), a corrected value of $6417 was computed. This says that, with the assumed rate of investment return, saving at an initial rate of $6417 per year and continually increasing that amount to match inßation will sufÞce to provide the desired inßation adjusted payout. Furthermore, the inßation adjusted Þnancial capital accumulated at the end of 40 years is $733,272. The related graph of q(t) duplicates the data listed on the text screen. The reader may Þnd it interesting to repeat the illustrative calculation assuming R = 11, in which case the saving coefÞcient is greatly reduced to only $1060.

1.4 Computer Code and Results A computer code which analyzes the above equations and presents both numerical and graphical results appears next. First we show the program output, and then discuss particular aspects of the program.

1.4.1 Computer Output >> finance; ANALYSIS OF THE SAVE-SPEND PROBLEM BY SOLVING q’(t)=r*q(t)+[s*(tt1)*exp(-a*t1)]*exp(a*t) where r=R-I, a=A-I, and q(0)=q0 To list parameter definitions enter y otherwise enter n ? y INPUT QUANTITIES: R - annual percent earnings on assets I - annual percent inflation rate A - annual percent increase in savings to offset inflation r,a - inflation adjusted values of R and I t1 - saving period (years), 0