Functions and Graphs

Section 1.1 discusses the geometry of (integer, real, complex, and quaternion) numbers. and the necessary notations from algebra. In Section 1.2 we plot graphs of some elementary, special, and piecewise functions, and investigate functions using derivativ

  • PDF / 1,187,781 Bytes
  • 80 Pages / 504 x 720 pts Page_size
  • 54 Downloads / 219 Views

DOWNLOAD

REPORT


Functions and Graphs

Section 1.1 discusses the geometry of (integer, real, complex, and quaternion) numbers. In Section 1.2 we plot graphs of some elementary, special, and piecewise functions, and investigate functions using derivatives. In Section 1.3 we study piecewise functions of one variable that are defined by several formulae for different values (intervals) of that variable. Section 1.4 is an excursion into remarkable curves (graphs) in polar coorR dinates. In Sections 1.5 and 1.6 we use several MATLAB functions that implement various interpolation and approximation algorithms. Chapter 1 can be considered as R the introduction to MATLAB symbolic/numeric calculations, programming, and basic graphing as needed in later chapters.

1.1 Numbers When MATLAB starts, its desktop opens with the Menu window, the Command window (where the special >> prompt appears), the Workspace window, the Command History window, and the Current Directory window. Throughout this book we usually type/edit the code in the Editor window, then place it (copy–paste) in the Command window, and execute. To save space, we present code and MATLAB answers in compact form (not identical to the view on the display). MATLAB can be used in two distinct modes (see Example, p. 4): – it offers immediate execution of statements in the Command window, or – it also offers programming by means of script and function M-files. A script M-file collects a sequence of commands that constitute a program. It is executed when one enters the name of the script M-file. R V. Rovenski, Modeling of Curves and Surfaces with MATLAB , Springer Undergraduate Texts in Mathematics and Technology 7, DOI 10.1007/978-0-387-71278-9 1, c Springer Science+Business Media, LLC 2010 

3

4

1 Functions and Graphs

We type % to designate a group of words (in a line) as a comment. The M-files created by ourselves we type with a bold font. The reader should place them in the MATLAB Current Directory, say D:/work; one may choose it manually or type in the Command window cd d : / work

1.1.1 Integers, rationals, and reals Let Z = {0, ±1, ±2, . . . } be integers, and N = {1, 2, 3, . . . } ⊂ Z be natural numbers. The following table contains some scalar and array arithmetic in MATLAB: N 1 2 3 4 5

Symbol Operation MATLAB + and − addition/subtraction a + b - c ∗ and .∗ multiplication a*b / and ./ right division a/b \ and .\ left division b\a ˆ and .ˆ exponentiation aˆ b

Example. Type 2+3 after the >> prompt, followed by Enter (i.e., press the Enter key). Next try the following: 2*3, 4ˆ2, 1/2, 2\1

Try the commands x = [1, 2, 3] x.ˆ2

ans = 1 4 9

% a dot in front of *, /, ˆ is used when we work with arrays. % next we present MATLAB answers in a compact form.

Compound numbers of the form n2 are called squares for obvious reasons. The triangular numbers are tn = 12 n(n + 1), etc. The MATLAB command for allows a statement or a group of statements to be repeated. One may type two lines in the Command window: for n = 1 : 10; x(n) = nˆ2; end; % squares x % Answer: x = 1 4 9 16 25 36 49