Programming Mathematics Using MATLAB 1st Edition Oberbroeckling Lisa A instant download
Programming Mathematics Using MATLAB 1st Edition Oberbroeckling Lisa A instant download
https://textbookfull.com/product/programming-mathematics-using-
matlab-1st-edition-oberbroeckling-lisa-a/
https://textbookfull.com/product/programming-mathematics-using-
matlab-1st-edition-oberbroeckling-lisa-a/
https://textbookfull.com/product/programming-mathematics-using-
matlab-1st-edition-oberbroeckling-lisa-a-2/
https://textbookfull.com/product/linear-programming-using-matlab-
springer-optimization-and-its-applications-127-ploskas/
https://textbookfull.com/product/engineering-mathematics-with-
matlab-1st-edition-won-y-yang/
Fundamentals of Graphics Using MATLAB 1st Edition
Ranjan Parekh
https://textbookfull.com/product/fundamentals-of-graphics-using-
matlab-1st-edition-ranjan-parekh/
https://textbookfull.com/product/design-optimization-using-
matlab-and-solidworks-1st-edition-suresh/
https://textbookfull.com/product/matlab-a-practical-introduction-
to-programming-and-problem-solving-stormy-attaway/
https://textbookfull.com/product/matlab-a-practical-introduction-
to-programming-and-problem-solving-stormy-attaway-2/
https://textbookfull.com/product/nonlinear-control-systems-using-
matlab-first-edition-boufadene/
PROGRAMMING
MATHEMATICS
USING MATLAB®
PROGRAMMING
MATHEMATICS USING
MATLAB®
LISA A. OBERBROECKLING
Department of Mathematics and Statistics
Loyola University Maryland
Baltimore, MD, United States
Academic Press is an imprint of Elsevier
125 London Wall, London EC2Y 5AS, United Kingdom
525 B Street, Suite 1650, San Diego, CA 92101, United States
50 Hampshire Street, 5th Floor, Cambridge, MA 02139, United States
The Boulevard, Langford Lane, Kidlington, Oxford OX5 1GB, United
Kingdom
Copyright © 2021 Elsevier Inc. All rights reserved.
MATLAB® is a trademark of The MathWorks, Inc. and is used with
permission.
The MathWorks does not warrant the accuracy of the text or
exercises in this book.
This book’s use or discussion of MATLAB® software or related
products does not constitute endorsement or sponsorship by The
MathWorks of a particular pedagogical approach or particular use of the
MATLAB® software.
No part of this publication may be reproduced or transmitted in any
form or by any means, electronic or mechanical, including photocopying,
recording, or any information storage and retrieval system, without
permission in writing from the publisher. Details on how to seek
permission, further information about the Publisher’s permissions policies
and our arrangements with organizations such as the Copyright Clearance
Center and the Copyright Licensing Agency, can be found at our website:
www.elsevier.com/permissions.
This book and the individual contributions contained in it are
protected under copyright by the Publisher (other than as may be noted
herein).
Notices
Knowledge and best practice in this field are constantly changing. As
new research and experience broaden our understanding, changes in
research methods, professional practices, or medical treatment may
become necessary.
Practitioners and researchers must always rely on their own
experience and knowledge in evaluating and using any information,
methods, compounds, or experiments described herein. In using such
information or methods they should be mindful of their own safety and
the safety of others, including parties for whom they have a professional
responsibility.
To the fullest extent of the law, neither the Publisher nor the authors,
contributors, or editors, assume any liability for any injury and/or damage
to persons or property as a matter of products liability, negligence or
otherwise, or from any use or operation of any methods, products,
instructions, or ideas contained in the material herein.
Library of Congress Cataloging-in-Publication Data
A catalog record for this book is available from the Library of
Congress
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library
ISBN: 978-0-12-817799-0
For information on all Academic Press publications
visit our website at https://www.elsevier.com/books-and-journals
Publisher: Katey Birtcher
Editorial Project Manager: Rafael G. Trombaco
Production Project Manager: Beula Christopher
Designer: Bridget Hoette
Typeset by VTeX
To Rob and James, for the support, patience (especially when
teaching MATLAB), and laughter.
To Christos Xenophontos for your encouragement and for introducing
me to MATLAB.
Contents
Preface
xiii
Introduction
xv
Part 1.
MATLAB®
1. Introduction to MATLAB®
3
1.1. Basic MATLAB® information
3
1.1.1.
Starting MATLAB
3
1.1.2.
Good commands to know
3
1.2. Basic mathematics
4
1.2.1.
Built-in mathematical functions
5
1.2.2.
Precedence rules
6
1.2.3.
Formats
8
1.3. Variables
9
1.4. Diaries and script files
10
1.5. Exercises
12
2. Vectors and Matrices (Arrays)
15
2.1. One-dimensional arrays (vectors)
15
2.1.1.
Constant spaced vectors
15
2.1.2.
Equally spaced vectors
16
2.2. Two-dimensional arrays (matrices)
17
2.3. Addressing elements of vectors/arrays
18
2.4. Component-wise calculations
22
2.5. Random numbers
25
2.6. Exercises
28
3. Plotting in MATLAB®
33
3.1. Basic 2D plots
33
3.2. Bad domain examples
34
3.3. Axis settings
35
3.4. Multiple plots
40
3.5. Color, line, and marker modifications
43
3.5.1.
Clf/close all
46
3.5.2.
Subplots
46
3.6. Other 2D plots
49
3.6.1.
Parametric curves
49
3.6.2.
Polar curves
50
3.7. Exercises
52
4. Three-Dimensional Plots
59
4.1. Vector functions or space curves
59
vii
viii
Contents
4.2. Plotting surfaces
62
4.2.1.
The meshgrid command
63
4.2.2.
Domain issues
64
4.2.3.
Level curves
65
4.2.4.
Multiple plots and modifying colors
66
4.3. View command
68
4.4. Axis settings, revisited
70
4.5. Other coordinate systems and 3D graphs
72
4.5.1.
The sphere and cylinder commands
72
4.5.2.
Cylindrical coordinates
75
4.5.3.
Spherical coordinates
77
4.6. Exercises
78
5. Functions
83
5.1. The lookfor and help commands
83
5.2. File format
84
5.3. Function examples
86
5.3.1.
Basic function examples
86
5.3.2.
More function examples – multiple inputs
86
5.3.3.
Multiple outputs
87
5.3.4.
Bad examples
89
5.4. Exercises
90
6. Control Flow
93
6.1. Relational and logical operators
93
6.2. If statements
97
6.3. Switch/case
99
6.4. Use of characteristic functions
99
6.5. For loops
100
6.6. While loops
102
6.7. Useful commands break, continue, return, and error
103
6.8. Optional inputs and outputs of functions
104
6.9. Exercises
107
7. Miscellaneous Commands and Code Improvement
115
7.1. Miscellaneous commands
115
7.1.1.
The fprintf command
115
7.1.2.
The sprintf command
117
7.1.3.
Formats revisited
118
7.1.4.
The save/load commands
118
7.1.5.
The tic/toc commands
119
7.1.6.
The fill command
119
7.1.7.
The command alpha
122
7.1.8.
The syms, diff, int, and subs commands
125
7.1.9.
Commands for polynomials
127
Contents
ix
7.2. Code improvement
129
7.2.1.
Vectorization of code
130
7.2.2.
Preallocation
131
Part 2.
Mathematics and MATLAB®
8. Transformations and Fern Fractals
135
8.1. Linear transformations
135
8.2. Affine transformations
139
8.3. Fern fractals
140
8.4. Exercises
141
9. Complex Numbers and Fractals
147
9.1. Complex numbers
147
9.1.1.
Adding complex numbers
147
9.1.2.
Multiplication by a real numbers (scalars)
147
9.1.3.
Multiplication and de Moivre’s theorem/formula
147
9.1.4.
Plotting complex numbers in MATLAB®
150
9.1.5.
Creating line segments with complex numbers
151
9.2. The Chaos Game
153
9.3. Line replacement fractals
154
9.3.1.
Snowflake fractals
154
9.3.2.
Gosper Island
155
9.4. Geometric series
156
9.5. Exercises
158
10. Series and Taylor Polynomials
167
10.1. Review of series
167
10.2. Power series
169
10.3. Taylor polynomials and Taylor series
173
10.4. Exercises
177
11. Numerical Integration
183
11.1. Approximating integrals/numerical integration
183
11.2. Riemann sums
183
11.3. Error bounds
185
11.4. Simpson’s rule
186
11.5. Exercises
189
12. The Gram–Schmidt Process
193
12.1. General vector spaces and subspaces
193
12.1.1. Vector spaces
193
12.1.2. Subspaces
194
12.2. Linear combinations of vectors
195
12.3. Linear independence and bases
196
x
Contents
12.3.1. Linear independence
196
12.3.2. Bases
197
12.4. Rank
200
12.5. Orthonormal vectors and the Gram–Schmidt process
201
12.5.1. Orthogonal and orthonormal vectors
201
12.5.2. The Gram–Schmidt process
204
12.6. Answers to example problems
210
12.7. Exercises
211
A. Publishing and Live Scripts
215
A.1. Live scripts
215
A.2. Basic scripts or M-files
215
A.3. Publishing M-files
216
A.4. Using sections
216
A.4.1. Using sections for publishing
217
A.4.2. Using sections for running/debugging files
222
A.5. Formatting text
223
A.5.1. Basic text formatting
223
A.5.2. Lists
224
A.5.3. HTML links
225
A.5.4. Inserting images
225
A.5.5. Pre-formatted text
226
A.5.6. Inserting HTML code
227
A.5.7. Inserting LATEXequations
227
B. Final Projects
229
B.1. Ciphers
229
B.1.1. Substitution cipher
229
B.1.2. Columnar transposition cipher
230
B.2. Game of Pig
231
B.3. Linearization and Newton’s method
232
B.3.1. Linearization
232
B.3.2. Newton’s method
232
B.4. Disk and Shell method
234
B.5. Power ball data
235
C. Linear Algebra Projects
237
C.1. Matrix calculations and linear systems
237
C.1.1. First handout
237
C.1.2. Exercises
239
C.2. The Hill cipher
243
C.2.1. Useful commands
245
C.2.2. Exercises
251
C.3. Least-squares solutions
252
C.3.1. Brief overview
252
Contents
xi
C.3.2. Curve fitting
253
C.3.3. Exercises
254
C.4. Markov matrices
256
C.4.1. Brief overview
256
C.4.2. Exercises
256
D. Multivariable Calculus Projects
261
D.1. Lines and planes
261
D.2. Vector functions
262
D.2.1. 2D example plots
262
D.2.2. 3D example plot
262
D.2.3. Bad domain example
263
D.2.4. Adjusting the view
263
D.2.5. Sphere command
263
D.2.6. Multiple plots on one figure
265
D.2.7. Exercises
265
D.3. Applications of double integrals
266
D.3.1. Calculating integrals and viewing regions
266
D.3.2. Exercises
268
References
271
Index
273
Preface
This book started in 2004 when I started to use MATLAB® in my
courses at Loyola University Maryland. I started including a few MATLAB
projects within the introduction to linear algebra and multivariable
calculus courses. I also taught a one-credit MATLAB course that was
required of every mathematics major. Later the course was changed to a
three-credit course. I expanded the previous assignments and added
some others. The class notes and assignments from over the years have
expanded into this book.
My philosophy has always been to use MATLAB to practice basic
programming skills with mathematics topics students had seen previously,
such as numerical integration, and topics they likely had not seen such as
fractals. Visualizing mathematics has always been important.
Supplements
Student companion site: Please visit
https://www.elsevier.com/books-and-journals/
book-companion/9780128177990
Instructor-only site: Qualified instructors can register and access
teaching materials at https://textbooks.elsevier.com/web/Manuals.aspx?
isbn=9780128177990
xiii
Introduction
The goal of the course and thus book is to introduce MATLAB® and
to practice basic programming techniques. There is a lot more to MATLAB
than what is covered in this book. Most students have already had some
programming experience in another language before taking the course
this book has stemmed from, although it is not necessary.
On completion of the course/book, one should be familiar enough
with MATLAB to explore more complicated features and commands.
Deepening your understanding of mathematics and learning new topics
are bonuses!
xv
CHAPTER 1
Introduction to MATLAB®
1.1. Basic MATLAB® information
1.1.1 Starting MATLAB
MATLAB has many different windows or panels, the first three of
which are on the main screen by default (see Table 1.1).
You can always modify the layout of the panels including “docking” or
“undocking” them, in the “Home” view, select “Layout” from the menu
and the top item is
“Default.” In order to use MATLAB successfully, you should pay
attention to the Current Folder. Otherwise, MATLAB may not be able to
save and run your programs/files successfully.
1.1.2 Good commands to know
The first four commands are useful to “start fresh” without closing
and reloading MATLAB.
•
clc Clears the command window of all previous commands and
output. These
commands are still stored in the command history and can be
accessed with the up-arrow.
•
clear Clears all defined variables in memory. BE CAREFUL WITH THIS
COM-
MAND! You can also clear certain variable names by typing clear
varname1
varname2.
•
clf and close Clears the current figure (plot). If no figure window was
open, it will open a blank figure window. Another command is close. This
will close the current figure window. The command close all will close all
figure windows.
Note that there is no clf all. Both of these commands have other
variations to Table 1.1 Main MATLAB Windows.
Command Window
Enter commands and variables, run programs
Workspace Window
Information about the current variables
Current Folder Window
Shows the files in the current folder/directory
Command History Window
History of commands entered in Command Window
Figure Window
Output from graphic commands
Editor Window
Creates and debugs script and function files
Help Window
Help information
Launch Pad Window
Access to tools, demos, and documentation
Programming Mathematics Using MATLAB®
Copyright © 2021 Elsevier Inc.
https://doi.org/10.1016/B978-0-12-817799-0.00006-5
All rights reserved.
3
4
Programming Mathematics Using MATLAB®
clear/close named figures, etc. such as clf(2) and close(2) that will
clear or close Figure 2, respectively.
•
format Sends the output display back to the default format. The
command format compact will not have as much white space (blank lines)
between subsequent
commands and output.
•
exit or quit Quit MATLAB. You can also quit/exit MATLAB by using the
MENU option under “File” or the usual close application icon within a
Mac or Windows environment.
Other good commands
•
who Lists current variables
•
help command Displays the help for command. For example, help
atan2.
•
disp('text') Displays text as output in the command window.
•
exist text or exist('text') Checks if variables or functions are defined
(see help exist for more details).
•
lookfor text Searches for “text” as a keyword in help entries of
functions.
>> exist average
ans =
0
>> lookfor average
mean
- Average or mean value.
HueSaturationValueExample
- Compute Maximum Average HSV of Images with MapReduce
ewmaplot
- Exponentially weighted moving average chart.
1.2. Basic mathematics
Mathematical operations
MATLAB uses the typical symbols for addition, subtraction,
multiplication, division, and exponentiation (+, -, ∗, /, and ^). These are
considered matrix arithmetic operations and follow the rules from
linear or matrix algebra.
>> 10/3
ans =
3.3333
MATLAB has another division operator, the “divided into” operator.
Introduction to MATLAB®
5
>> 10\3
ans =
0.3000
Thus the forward slash is our usual division, “3 divided by 2” while
the backslash is “3
divided into 2.” The need for both of these become more apparent
when working with matrices.
“Dot” operations or component-wise operations are useful and/or
necessary for use with vectors and matrices (discussed in Section 2.4).
These are considered “array arithmetic operations” and are carried out
element or component-wise.
MATLAB does NUMERICAL, rather than algebraic computations, as
seen below.
Think about what is expected versus what is given as the answer to
the subraction calculation.
>> asin(1/2)
ans =
0.5236
>> pi/6 - asin(1/2)
ans =
-1.1102e-16
1.2.1 Built-in mathematical functions
Table 1.2 has common mathematical functions in MATLAB. This is not
a complete list.
The modulo function mod calculates the modulus after division. In
other words, mod(x,y) returns the remainder when you divide x by y. In
some languages like Python or Perl this is equivalent to % is the modulus
operator. Thus mod(x,y) in MATLAB is the same as x % y in other
languages. There is also a remainder function rem that has the same
functionality as mod EXCEPT when the divisor and quotient are opposite
signs or the quotient is 0 (see Exercise 9).
>> mod(10,3)
ans =
1
6
Programming Mathematics Using MATLAB®
>> rem(10,3)
ans =
1
>> mod(10,-3)
ans =
-2
>> rem(10,-3)
ans =
1
>> mod(10,0)
ans =
10
>> rem(10,0)
ans =
NaN
NOTE: NaN stands for “not a number.”
1.2.2 Precedence rules
While some languages go strictly from left to right when there are
multiple operations within one line, most now follow the mathematical
rules for order of operations. Many of you may know the pneumonic
PEMDAS (Please excuse my dear Aunt Sally); parentheses,
exponentiation, multiplication, division, addition, subtraction. There are
some issues with that pneumonic, however. There are also some
discrepancies, to be explored in the exercises. Table 1.3 shows the
precedence rules for the arithmetic operations discussed so far, going
from highest precedence to lowest.
One thing to consider is: where do functions go on this list? For
example, how does MATLAB interpret the command cos(x)^2? Is this
equivalent to cos (x 2 ), cos2 (x), or something else entirely? This will be
explored in the exercises.
Introduction to MATLAB®
7
Table 1.2 Mathematical functions.
sqrt(x)
Square root
exp(x)
Exponential ( ex)
abs(x)
Absolute value
mod(x,y)
Modulus
rem(x,y)
Remainder
log(x)
Natural logarithm (ln (x))
log10(x)
Common logarithm
sin(x)
Sine of x (radians)
sind(x)
Sine of x (degrees)
cos(x)
Cosine of x
tan(x)
Tangent of x
cot(x)
Cotangent of x
asin(x)
Inverse sine of x (radians)
asind(x)
Inverse sine of x (degrees)
pi
π
Table 1.3 Basic math precedence.
()
parentheses
^
exponentiation
∗/\
multiplication and division
+-
addition and subtraction
If you have a long calculation/expression, you can continue on the
next line in the command window or within a MATLAB file with the
ellipses or continuation operator. Note when the ellipses work
with/without spaces:
>> 1+2*3-12^2/3 ...
*2
ans =
-89
>> 1+2*3-12^2/3 *...
2
ans =
-89
>> 1+2*3-12^2/3*...
2
8
Programming Mathematics Using MATLAB®
ans =
-89
>> 1+2*3-12^2/3...
1+2*3-12^2/3...
|
Error: Unexpected MATLAB operator.
1.2.3 Formats
As mentioned above, the format command returns the format back to
the default format, which is the same as format short. Generally speaking,
this will display a number up to four decimal places, while format long will
display 15. In scientific notation, this amounts to five and 16 significant
digits, respectively. See Table 1.4.
>> pi
ans =
3.1416
>> format long
>> pi
ans =
3.141592653589793
There are other built-in formats, including how numbers in scientific
notation are displayed. See help format for more examples.
Another useful command is format compact and format loose
(default). This
will change how the output is displayed.
>> pi
ans =
3.1416
>> format compact
>> pi
ans =
3.1416
>> format loose
Introduction to MATLAB®
9
>> pi
ans =
3.1416
>>
The subsequent commands shown in this text will use format
compact (see Table 1.4).
Table 1.4 Basic formats displaying 10∗pi.
format short (default)
31.4159
format long
31.415926535897931
format rat
3550/113
format bank
31.42
format short e
3.1416e+01
format long e
3.141592653589793e+01
format short g
31.416
format long g
31.4159265358979
format hex
403f6a7a2955385e
format compact
(no blank lines)
format loose (default)
(some blank lines)
1.3. Variables
The format for a variable assignment is as follows:
Variable name
= Numerical value or computable expression
Some conventions:
•
The = is the assignment operator which assigns a value to a
variable.
•
Left-hand side can include only one variable name.
•
Right-hand side can be a number or an expression made up of
numbers, functions, and/or variables previously assigned numerical
values.
•
Variables must begin with a letter.
•
Press the Enter/Return key to make the assignment.
•
The variable ans is the value of the last expression that is not
assigned.
•
Be careful with variable names. For example, do not name a variable
help or sin.
•
Variable names are case sensitive; thus A is not the same as a.
Remember:
•
Use semicolon (;) to suppress screen output.
•
Multiple commands can be typed on one line by typing a comma (,)
between them if they are not already ended with a semicolon (;).
10
Programming Mathematics Using MATLAB®
√
Example 1.3.1.
Assign the number 3 to variable a and 4 to variable b. Print
a2+b2
and assign the solution to the variable c.
>> a=3; b=4; c = sqrt(a^2+b^2), a+b+c
c=
5
ans =
12
Notice in the above example, you do not need spaces around the “=”
for variable assignments but you may use them for aesthetic reasons.
Example 1.3.2.
Experiment with the equation
x
cos2
= tan x + sin x
2
2 tan x
by calculating each side of the equation for x = π/ 5.
>> x = pi/5;
>> LHS = (cos(x/2))^2, RHS = (tan(x)+sin(x))/(2*tan(x))
LHS =
0.9045
RHS =
0.9045
>> format long
>> LHS, RHS
LHS =
0.904508497187474
RHS =
0.904508497187474
>> LHS-RHS
ans =
-1.110223024625157e-16
1.4. Diaries and script files
You can record your commands and output to the command window
with the diary command. The commands you enter in the command
window and any output are
stored as an ASCII (plain text) file. The command diary toggles the
recording on and off. If you do not specify a filename, it will create a file
in the current folder of the name “diary.” The command diary filename will
save the recording to a file of the name “filename.” The commands diary
off and diary on will pause and restart the recording, respectively, to the
active file. NOTE: when you use the diary filename
Introduction to MATLAB®
11
more than once (within the same current folder), it will continue to
APPEND to the file.
>> diary filename
>> 1+1
ans =
2
>> diary off
>> 2+2
ans =
4
>> diary on
>> 3^2
ans =
9
>> diary
For example, the commands above will generate the following text in
the file “filename”:
1+1
ans =
2
diary off
3^2
ans =
9
diary
Script files, or m-files, are extremely useful for running and rerunning
code. You may be required to turn in script files for your assignments.
•
Script files are ASCII files (plain text files) with extension .m; thus
they are also called m-files. These are basically batch files.
•
When you run a SCRIPT file, MATLAB executes each line as if you
typed each
line into the command window.
•
Script files are very useful; you can edit them, save them, execute
them many times and “tweak” them to experiment with commands.
•
The MATLAB editor window is the best way to create and edit script
files.
•
To avoid extraneous output to the command window, put “;” after
variable assignments or intermediate calculations.
•
Comments within MATLAB files begin with the percent symbol (%).
Running script files:
There are many ways to run an m-file of name filename.m. First, you
must MAKE
SURE CURRENT FOLDER IS CORRECT!
12
Programming Mathematics Using MATLAB®
1. >> filename
2. >> run filename
3. >> run('filename')
4. Within the Editor tab, chose run...
1.5. Exercises
1. Basic calculations Use MATLAB to do the following calculations.
Be careful! The following are displayed using regular mathematical
notation; you need to figure out what MATLAB functions are needed.
7
292
(a)
( 2 . 4 )( 64 ) +
. 753
,
(b)
+ 644 / 3 + 20 · 9−3,
16
28 − 225
5
11
(c) cos ( 360 ),
(d) cos ( 360◦ ),
(e) cos ( 2 π ),
(f) cos ( 2 π ◦ ),
(g) e + 5,
(h) | π − 5|,
(i) 3 ln 7,
(j) 3 log 7,
6
(k)
sin−1 ( 0 . 5 ) + 4,
(l) 4 cos ( 5 arctan ( 13 / 4 )).
π
2. Order of operations
(a) Calculate, without using any parentheses, −42 using THREE of
the following and write your answers on your own paper, specifying which
you did and
what answers they gave:
(i) calculator (specify type/model)
(ii) Google.com
(iii) Excel or Google Sheets
(iv) Desmos.com or Wolfram Al-
pha
Now calculate −42 using MATLAB. Are there differences in the
answers?
Based on your knowledge of Order of Operations, what should be the
an-
swers?
(b) Do the same for the calculation of − cos (π/ 4 ) 2 (you may use
parentheses around the π/ 4; i.e. you should calculate -cos(pi/4)^2).
NOTE: In Excel, to calculate with π use “PI()”, again noting the differences
(if any) in the answers.
(c) Do the same for the calculation of −212 and −81 / 3 (without
using any parentheses). Should parentheses be used to get the proper
calculations? Where?
(d) How should Table 1.3 for precedence rules within MATLAB be
changed or expanded to include functions and negation (unary minus)?
Answer this by
rewriting the table on paper.
Introduction to MATLAB®
13
3. Using variables. Define variables with the assignments x = 8, y
= 3 . 5, and X =
√
1 / 9. Calculate the following within MATLAB. For the n z calculations,
use the nthroot function.
√
4 (y − x)
3X
(a)
,
(b)
,
3 X − 20
10
√
(c) 3 cos x tan y,
(d) e(X+ y)/x + 3 3 x.
4. Suppose x = 3 and y = 5 (define the variables at the beginning of
the problem).
−1
3y
4 (y − 5 )
(a) 3 π x 2,
(b) 1 − 1
,
(c)
,
(d)
,
(e) 2 sin (x) cos (y).
x5
4x−8
3x−6
5. Define the following variables: tablePrice = 1256 . 95, chairPrice =
89 . 99, and gasPrice = 3 . 499. Using the variables and format bank for
parts a–c, write your answers to the following questions on paper,
interpreting the MATLAB output as a meaningful answer:
(a) Find the cost of one table and eight chairs.
(b) Find the same cost as above but with 6.5% sales tax.
(c) Find the cost of 14.25 gallons of gas that you would have to pay.
(d) Compute the actual cost of 14.25 gallons of gas using the
default format.
6. More calculations Define the variables x = 256 and y = 125.
Calculate the following within MATLAB. When radical notation is used in
the problem, use the sqrt and nthroot functions and use exponential
calculations when exponential notation is used in the problem.
√
√
1
1
1
(a)
x,
(b) x 2 ,
(c)
− x,
(d) (− x) 2 ,
(e) x 4 ,
√
1
1
1
√
(f)
4 x,
(g) y 3 ,
Another Random Document on
Scribd Without Any Related Topics
“‘JUST TELL THEM THAT YOU HEARD ME SAY I WAS GOING BACK
TO BOSTON.’”
[239]
CHAPTER XVI.
SEARCHING THE VIKING
“That goes with the hat,” said Henry Burns. “You can
buy peanuts with it, if you win, Joe.”
“Well, I’ve got the first fish, anyway,” cried young Joe,
who had felt a tremendous yank on his line.
Up came a big flounder, which was skittering about, the
next moment, in the bottom of the boat.
Little Tim Reardon, who had given a sly tug at Joe’s line
when the other wasn’t looking, snickered.
“I’ll beat you, if you try that trick again,” exclaimed Joe
Hinman, eying Tim sharply.
The squire and his son were, indeed, coming out to the
fishing-grounds.
The chorus that greeted Squire Brackett made him jump [242]
up in his seat.
The squire directed his son, and the latter rowed past
the other boats and tied up, at length, at a spar buoy,
with red and black horizontal stripes, which marked a
ledge in the middle of a channel.
Tom and young Joe baited up for the final effort, and
the lines went out together.
They waited expectantly. Two, three, four minutes went
by, without a bite.
“All right,” said young Joe. “I got mine first, though—No, [244]
hold on here. Hooray! I’ve won, after all.”
“That small one will cost you more than that,” chuckled
the squire to himself, as he paid the money.
“Why, you don’t mean that, do you, squire?” asked Joe [246]
Hinman, dismayed at seeing the profits of their fishing
thus suddenly threatening to vanish. “We haven’t
shipped a single short lobster all this summer. But we
don’t stop to measure them down here. We wait till we
get up to the car. We have a measuring-stick there, and
if a lobster is under the law we set him free, near the
ledges off the camp. We throw out some old fish around
those ledges, to see if we can’t keep them around
there, and be able to catch ’em later—perhaps another
year, when they’ve got their growth.”
Little Tim, the first to jump from the bow of the boat,
narrated their adventure with the squire. Captain Sam
snorted.
“Oh, yes, it’s funny, I suppose,” said Little Tim; “but you
don’t have to pay the fine.”
Little Tim’s nimble bare feet carried him out of the way [249]
of the squire’s arm. From a safe distance, he continued:
“Yes, you and Harry were breaking the law, out there in
the boat. You were tied up to one of the spar-buoys.
They belong to the gov’ment. I’ve heard a fisherman
say so; and it’s fifty dollars fine for any one to moor a
boat to one of ’em. Didn’t you know that, squire?”
As for Henry Burns, his mind had been given over for [251]
some time to the consideration of a different matter. He,
himself, couldn’t have told exactly just when and where
he had formed a certain impression; but, once the idea
had impressed him, he had turned it over and over,
looking at it from all sides, and trying to recall any
incident that would shed light on it.
“And he hadn’t lost that pin at that time, either,” said [253]
Henry Burns. “Nor had he lost the pin he told about, the
night after, when he was looking about the cabin with a
light, while we were asleep. Then, I don’t believe he
had lost any pin at all when he broke into our cabin;
and if he had, why didn’t he wait till we came up? He
knew we would be back in an hour or two. No, sir, he
was after something in that cabin.”
“Yes, that’s true,” said Henry Burns. “But persons can [254]
visit them on certain days, in certain hours. There are
ways in which Mr. Carleton could have got the
information.”
“Now you can take the ballast out on to the deck of our [255]
yacht, if you want to,” said George Warren.
“I’ll tell you what we’ll do,” suggested Henry Burns; “you [256]
and Tom start forward, and George and I will start aft,
and we’ll work toward one another, examining
everything carefully as we go. We’ll pass the stuff to
Bob and he can carry it outside.”
Setting the example, Henry Burns began with the
provision locker on the starboard side, next to the
bulkhead. He took everything out, scrutinized every
board with which the locker was sealed, and tapped on
the boards with a little hammer. But there was no
unusual fitting of the boards that suggested a hidden
chamber, nor any variance in the sound where the
hammer fell, to warrant cutting into the sides of the
locker. He examined top, sides, and bottom, with equal
care and with no favourable result.
“Only there isn’t any gold,” said Harvey; “but I’ll try the
ballast before I quit.”
“I’m afraid that’s not much use,” said Henry Burns.
“They wouldn’t go so deep as that to hide anything. I’m
afraid I’ve raised your hopes for nothing.”
“Say, Henry,” said Jack Harvey, when, after another half- [258]
hour, they had restored the yacht to its former order,
“this wasn’t one of your jokes, was it—this hidden
treasure idea?”
[259]
CHAPTER XVII.
A RAINY NIGHT
[260]
There had been only one thing lacking for the season’s
complete financial success. The mackerel had not
appeared around the coast. It was getting near the first
of September, and the local fishermen had lost hope of
their coming.
“If we could only get the first run of them,” said Little
Tim, “we’d just make a fortune. The big hotels down the
bay haven’t had any this season, except those they’ve
sent to Boston and Portland for. They’d take the whole
boat-load.”
There came a smart tug at the line, and Little Tim was
up like a rabbit out of its hole. He seized the line and
began hauling in rapidly.
Little Tim yanked the fish out of water, with a jerk that
sent fish and mackerel-jig higher than his head. But
there was no mistake about it. There was a mackerel,
flopping and jumping in the bottom of the boat,
glistening and gleaming, with its mingled shades of
green and black and white.
“Better send up and invite young Joe down,” said Henry [263]
Burns, paying little attention to the new arrivals. “Jack
and I are going into the tent, to eat supper with Tom
and Bob.”
“All right,” said young Tim. “It may be your only chance,
though, to eat one of these this summer.” Henry Burns
glanced up from his work at the string of six mackerel
which Tim proudly displayed. Then he flung down his
broom and ran to the companionway.
Tim tossed the fish into the canoe, and Bob hastened
ashore.
They were all out in the cove shortly, with lines down
close to the muddy bottom, for flounders and sculpins.
The tide, at half-flood, served them fortunately, and
soon the fish began to come aboard. Then, when they
had their catch, they rowed around to the wharf,
dropping Henry Burns ashore near the Warren cottage.
The Spray was gone from harbour; but Henry Burns left
word for the Warren boys to follow, in the morning,
impressing the importance of secrecy on Mrs. Warren,
with a solemnity as great as if they were going after
hidden gold.
They tied the flap of the tent carefully, saw that the
tent-pegs were firm, and the guy-ropes all right, and
departed. By half-past seven o’clock they were out
aboard, and the two yachts were under way.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com