Numerical Methods in Engineering with MATLAB Edition 1 Jaan Kiusalaas instant download
Numerical Methods in Engineering with MATLAB Edition 1 Jaan Kiusalaas instant download
or textbooks at https://ebookultra.com
https://ebookultra.com/download/numerical-methods-in-
engineering-with-matlab-edition-1-jaan-kiusalaas/
https://ebookultra.com/download/numerical-methods-in-engineering-with-
python-j-kiusalaas-cambridge-1st-edition-jaan-kiusalaas/
https://ebookultra.com/download/numerical-methods-in-engineering-with-
python-3-3rd-edition-jaan-kiusalaas/
https://ebookultra.com/download/numerical-and-statistical-methods-for-
bioengineering-applications-in-matlab-1st-edition-michael-r-king/
https://ebookultra.com/download/numerical-computing-with-matlab-
revised-reprint-2nd-edition-cleve-b-moler/
MATLAB Numerical Calculations López
https://ebookultra.com/download/matlab-numerical-calculations-lopez/
https://ebookultra.com/download/engineering-computation-with-
matlab-2nd-ed-edition-david-m-smith/
https://ebookultra.com/download/numerical-analysis-using-matlab-and-
excel-3rd-edition-steven-t-karris/
https://ebookultra.com/download/numerical-methods-in-contact-
mechanics-1st-edition-vladislav-a-yastrebov/
Numerical Methods in Engineering with MATLAB
Edition 1 Jaan Kiusalaas Digital Instant Download
Author(s): Jaan Kiusalaas
ISBN(s): 9780521852883, 0521852889
File Details: PDF, 7.75 MB
Year: 2005
Language: english
Numerical Methods in Engineering with MATLAB®
Cambridge University Press has no responsibility for the persistence or accuracy of urls
for external or third-party internet websites referred to in this publication, and does not
guarantee that any content on such websites is, or will remain, accurate or appropriate.
Contents
Preface . . . . . . . . . vii
1. Introduction to MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Appendices . . . . 411
Index . . . . . . . . . . . 421
v
Preface
This book is targeted primarily toward engineers and engineering students of ad-
vanced standing (sophomores, seniors and graduate students). Familiarity with a
computer language is required; knowledge of basic engineering subjects is useful, but
not essential.
The text attempts to place emphasis on numerical methods, not programming.
Most engineers are not programmers, but problem solvers. They want to know what
methods can be applied to a given problem, what are their strengths and pitfalls and
how to implement them. Engineers are not expected to write computer code for basic
tasks from scratch; they are more likely to utilize functions and subroutines that have
been already written and tested. Thus programming by engineers is largely confined
to assembling existing pieces of code into a coherent package that solves the problem
at hand.
The “piece” of code is usually a function that implements a specific task. For the
user the details of the code are unimportant. What matters is the interface (what goes
in and what comes out) and an understanding of the method on which the algorithm
is based. Since no numerical algorithm is infallible, the importance of understanding
the underlying method cannot be overemphasized; it is, in fact, the rationale behind
learning numerical methods.
This book attempts to conform to the views outlined above. Each numerical
method is explained in detail and its shortcomings are pointed out. The examples
that follow individual topics fall into two categories: hand computations that illustrate
the inner workings of the method, and small programs that show how the computer
code is utilized in solving a problem. Problems that require programming are marked
with .
The material consists of the usual topics covered in an engineering course on
numerical methods: solution of equations, interpolation and data fitting, numerical
differentiation and integration, solution of ordinary differential equations and eigen-
value problems. The choice of methods within each topic is tilted toward relevance
vii
viii Preface
www.cambridge.org/0521852889
The author wishes to express his gratitude to the anonymous reviewers and
Professor Andrew Pytel for their suggestions for improving the manuscript. Credit
is also due to the authors of Numerical Recipes (Cambridge University Press) whose
presentation of numerical methods was inspirational in writing this book.
1 Introduction to MATLAB
r MATLAB contains a large number of functions that access proven numerical li-
braries, such as LINPACK and EISPACK. This means that many common tasks (e.g.,
solution of simultaneous equations) can be accomplished with a single function
call.
r There is extensive graphics support that allows the results of computations to be
plotted with a few statements.
r All numerical objects are treated as double-precision arrays. Thus there is no need
to declare data types and carry out type conversions.
1
2 Introduction to MATLAB
The syntax of MATLAB resembles that of FORTRAN. To get an idea of the similari-
ties, let us compare the codes written in the two languages for solution of simultaneous
equations Ax = b by Gauss elimination. Here is the subroutine in FORTRAN 90:
subroutine gauss(A,b,n)
use prec_ mod
implicit none
real(DP), dimension(:,:), intent(in out) :: A
real(DP), dimension(:), intent(in out) :: b
integer, intent(in) :: n
real(DP) :: lambda
integer :: i,k
! --------------Elimination phase--------------
do k = 1,n-1
do i = k+1,n
if(A(i,k) /= 0) then
lambda = A(i,k)/A(k,k)
A(i,k+1:n) = A(i,k+1:n) - lambda*A(k,k+1:n)
b(i) = b(i) - lambda*b(k)
end if
end do
end do
! ------------Back substitution phase----------
do k = n,1,-1
b(k) = (b(k) - sum(A(k,k+1:n)*b(k+1:n)))/A(k,k)
end do
return
end subroutine gauss
The statement use prec mod tells the compiler to load the module prec mod
(not shown here), which defines the word length DP for floating-point numbers. Also
note the use of array sections, such as a(k,k+1:n), a feature that was not available
in previous versions of FORTRAN.
The equivalent MATLAB function is (MATLAB does not have subroutines):
function b = gauss(A,b)
n = length(b);
%-----------------Elimination phase-------------
for k = 1:n-1
for i = k+1:n
3 1.1 General Information
if A(i,k) ˜= 0
lambda = A(i,k)/A(k,k);
A(i,k+1:n) = A(i,k+1:n) - lambda*A(k,k+1:n);
b(i)= b(i) - lambda*b(k);
end
end
end
%--------------Back substitution phase-----------
for k = n:-1:1
b(k) = (b(k) - A(k,k+1:n)*b(k+1:n))/A(k,k);
end
Simultaneous equations can also be solved in MATLAB with the simple command
A\b (see below).
MATLAB can be operated in the interactive mode through its command window,
where each command is executed immediately upon its entry. In this mode MATLAB
acts like an electronic calculator. Here is an example of an interactive session for the
solution of simultaneous equations:
The symbol >> is MATLAB’s prompt for input. The percent sign (%) marks the
beginning of a comment. A semicolon (;) has two functions: it suppresses printout
of intermediate results and separates the rows of a matrix. Without a terminating
semicolon, the result of a command would be displayed. For example, omission of
the last semicolon in the line defining the matrix A would result in
>> A = [2 1 0; -1 2 2; 0 1 4]
A =
2 1 0
-1 2 2
0 1 4
4 Introduction to MATLAB
Functions and programs can be created with the MATLAB editor/debugger and
saved with the .m extension (MATLAB calls them M-files). The file name of a saved
function should be identical to the name of the function. For example, if the function
for Gauss elimination listed above is saved as gauss.m, it can be called just like any
MATLAB function:
>> A = [2 1 0; -1 2 2; 0 1 4];
>> b = [1; 2; 3];
>> soln = gauss(A,b)
soln =
0.2500
0.5000
0.6250
Variables
Variable names, which must start with a letter, are case sensitive. Hence xstart and
xStart represent two different variables. The length of the name is unlimited, but
only the first N characters are significant. To find N for your installation of MATLAB,
use the command namelengthmax:
>> namelengthmax
ans =
63
Variables that are defined within a MATLAB function are local in their scope.
They are not available to other parts of the program and do not remain in memory
after exiting the function (this applies to most programming languages). However,
variables can be shared between a function and the calling program if they are declared
global. For example, by placing the statement global X Y in a function as well as
the calling program, the variables X and Y are shared between the two program units.
The recommended practice is to use capital letters for global variables.
MATLAB contains several built-in constants and special variables, most important
of which are
inf Infinity
NaN Not a number
√
i or j −1
pi π
realmin Smallest usable positive number
realmax Largest usable positive number
>> 0/0
6 Introduction to MATLAB
ans =
NaN
>> eps
ans =
2.2204e-016
Arrays
Arrays can be created in several ways. One of them is to type the elements of the array
between brackets. The elements in each row must be separated by blanks or commas.
Here is an example of generating a 3 × 3 matrix:
>> A = [ 2 -1 0
-1 2 -1
0 -1 1]
A =
2 -1 0
-1 2 -1
0 -1 1
The elements can also be typed on a single line, separating the rows with semi-
colons:
>> A = [2 -1 0; -1 2 -1; 0 -1 1]
A =
2 -1 0
-1 2 -1
0 -1 1
Unlike most computer languages, MATLAB differentiates between row and col-
umn vectors (this peculiarity is a frequent source of programming and input errors).
For example,
Exploring the Variety of Random
Documents with Different Content
Across the German Ocean,
In a country far from our own,
Once, a poor little boy, named Gottlieb,
Lived with his mother alone.
By Charles Dickens.
TINY TIM'S CHRISTMAS DINNER.
Then up rose Mrs. Cratchit, Cratchit's wife, dressed out but poorly in
a twice turned gown, but brave in ribbons, which are cheap and
make a goodly show for sixpence; and she laid the cloth, assisted by
Belinda Cratchit, second of her daughters, also brave in ribbons;
while Master Peter Cratchit plunged a fork into the saucepan of
potatoes, and getting the corners of his monstrous shirt-collar (Bob's
private property, conferred upon his son and heir in honor of the
day) into his mouth, rejoiced to find himself so gallantly attired, and
yearned to show his linen in the fashionable Parks. And now two
smaller Cratchits, boy and girl, came tearing in, screaming that
outside the baker's they had smelt the goose, and known it for their
own; and basking in luxurious thoughts of sage and onion, these
young Cratchits danced about the table, and exalted Master Peter
Cratchit to the skies, while he (not proud, although his collars nearly
choked him) blew the fire, until the slow potatoes, bubbling up,
knocked loudly at the saucepan lid to be let out and peeled.
"What has ever got your precious father then?" said Mrs. Cratchit.
"And your brother Tiny Tim! And Martha warn't as late last
Christmas Day by half an hour!"
"Here's Martha, mother!" said a girl, appearing as she spoke.
"Here's Martha, mother!" cried the two young Cratchits. "Hurrah!
There's such a goose, Martha!"
"Why, bless your heart alive, my dear, how late you are!" said Mrs.
Cratchit, kissing her a dozen times, and taking off her shawl and
bonnet for her with officious zeal.
"We'd a deal of work to finish up last night," replied the girl, "and
had to clear away this morning, mother!"
"Well! never mind so long as you are come," said Mrs. Cratchit. "Sit
ye down before the fire, my dear, and have a warm, Lord bless ye!"
"No, no! there's father coming," cried the two young Cratchits, who
were everywhere at once. "Hide, Martha, hide!"
So Martha hid herself; and in came little Bob, the father, with at least
three feet of comforter exclusive of the fringe hanging down before
him, and his threadbare clothes darned up and brushed to look
seasonable, and Tiny Tim upon his shoulder. Alas for Tiny Tim, he
bore a little crutch, and had his limbs supported by an iron frame!
"Why, where's our Martha?" cried Bob Cratchit, looking round.
"Not coming," said Mrs. Cratchit.
"Not coming!" said Bob, with a sudden declension in his high spirits;
for he had been Tim's blood horse all the way from church, and had
come home rampant. "Not coming upon Christmas Day!"
Martha didn't like to see him disappointed, if it were only a joke; so
she came out prematurely from behind the closet door, and ran into
his arms, while the two young Cratchits hustled Tiny Tim, and bore
him off into the wash-house, that he might hear the pudding singing
in the copper.
"And how did little Tim behave?" asked Mrs. Cratchit, when she had
rallied Bob on his credulity, and Bob had hugged his daughter to his
heart's content.
"As good as gold," said Bob, "and better. Somehow he gets
thoughtful, sitting by himself so much, and thinks the strangest
things you ever heard. He told me, coming home, that he hoped the
people saw him in the church, because he was a cripple, and it
might be pleasant to them to remember upon Christmas Day who
made lame beggars walk and blind men see."
Bob's voice was tremulous when he told them this, and trembled
more when he said that Tiny Tim was growing strong and hearty.
His active little crutch was heard upon the floor, and back came Tiny
Tim before another word was spoken, escorted by his brother and
sister to his stool beside the fire; and while Bob, turning up his cuffs,
—as if, poor fellow, they were capable of being made more shabby,
—compounded some hot mixture in a jug with gin and lemons, and
stirred it round and round and put it on the hob to simmer, Master
Peter and the two ubiquitous young Cratchits went to fetch the
goose, with which they soon returned in high procession.
Such a bustle ensued that you might have thought a goose the
rarest of all birds,—a feathered phenomenon, to which a black swan
was a matter of course; and in truth it was something very like it in
that house. Mrs. Cratchit made the gravy (ready beforehand in a
little saucepan) hissing hot; Master Peter mashed the potatoes with
incredible vigor; Miss Belinda sweetened up the apple-sauce; Martha
dusted the hot plates; Bob took Tiny Tim beside him in a tiny corner
at the table; the two young Cratchits set chairs for everybody, not
forgetting themselves, and mounting guard upon their posts,
crammed spoons into their mouths, lest they should shriek for goose
before their turn came to be helped. At last the dishes were set on,
and grace was said. It was succeeded by a breathless pause, as Mrs.
Cratchit, looking slowly all along the carving-knife, prepared to
plunge it in the breast; but when she did, and when the long-
expected gush of stuffing issued forth, one murmur of delight arose
all round the board, and even Tiny Tim, excited by the two young
Cratchits, beat on the table with the handle of his knife, and feebly
cried Hurrah!
There never was such a goose. Bob said he didn't believe there ever
was such a goose cooked. Its tenderness and flavor, size and
cheapness, were the themes of universal admiration. Eked out by
apple-sauce and mashed potatoes, it was a sufficient dinner for the
whole family; indeed, as Mrs. Cratchit said with great delight
(surveying one small atom of a bone upon the dish), they hadn't ate
it all at last! Yet every one had had enough, and the youngest
Cratchits in particular were steeped in sage and onion to the
eyebrows! But now the plates being changed by Miss Belinda, Mrs.
Cratchit left the room alone—too nervous to bear witnesses—to take
the pudding up, and bring it in.
Suppose it should not be done enough! Suppose it should break in
turning out! Suppose somebody should have got over the wall of the
back yard, and stolen it, while they were merry with the goose,—a
supposition at which the two young Cratchits became livid! All sorts
of horrors were supposed.
Hallo! A great deal of steam! The pudding was out of the copper. A
smell like a washing-day! That was the cloth. A smell like an eating-
house and a pastry-cook's next door to each other, with a
laundress's next door to that! That was the pudding! In half a
minute Mrs. Cratchit entered—flushed, but smiling proudly—with the
pudding, like a speckled cannon-ball, so hard and firm, blazing in
half of half-a-quartern of ignited brandy, and bedight with Christmas
holly stuck into the top.
Oh, a wonderful pudding! Bob Cratchit said, and calmly too, that he
regarded it as the greatest success achieved by Mrs. Cratchit since
their marriage. Mrs. Cratchit said that now the weight was off her
mind, she would confess she had her doubts about the quantity of
flour. Everybody had something to say about it, but nobody said or
thought it was at all a small pudding for a large family. It would have
been flat heresy to do so. Any Cratchit would have blushed to hint at
such a thing.
At last the dinner was all done, the cloth was cleared, the hearth
swept, and the fire made up. The compound in the jug being tasted,
and considered perfect, apples and oranges were put upon the
table, and a shovelful of chestnuts on the fire. Then all the Cratchit
family drew round the hearth, in what Bob Cratchit called a circle,
meaning half a one; and at Bob Cratchit's elbow stood the family
display of glass,—two tumblers and a custard-cup without a handle.
These held the hot stuff from the jug, however, as well as golden
goblets would have done; and Bob served it out with beaming looks,
while the chestnuts on the fire sputtered and cracked noisily. Then
Bob proposed:—
"A merry Christmas to us all, my dears. God bless us."
Which all the family re-echoed.
"God bless us every one!" said Tiny Tim, the last of all.
He sat very close to his father's side, upon his little stool. Bob held
his withered little hand in his, as if he loved the child, and wished to
keep him by his side, and dreaded that he might be taken from him.
"Mr. Scrooge!" said Bob; "I'll give you, Mr. Scrooge, the Founder of
the Feast!"
"The Founder of the Feast indeed!" cried Mrs. Cratchit, reddening. "I
wished I had him here. I'd give him a piece of my mind to feast
upon, and I hope he'd have a good appetite for it."
"My dear," said Bob, "the children! Christmas Day!"
"It should be Christmas Day, I am sure," said she, "on which one
drinks the health of such an odious, stingy, hard, unfeeling man as
Mr. Scrooge. You know he is, Robert! Nobody knows it better than
you do, poor fellow!"
"My dear," was Bob's mild answer, "Christmas Day!"
"I'll drink his health for your sake and the Day's," said Mrs. Cratchit,
"not for his. Long life to him! A merry Christmas and a happy new
year! He'll be very merry and very happy, I have no doubt!"
The children drank the toast after her. It was the first of their
proceedings which had no heartiness in it! Tiny Tim drank it last of
all, but he didn't care twopence for it. Scrooge was the Ogre of the
family. The mention of his name cast a dark shadow on the party,
which was not dispelled for full five minutes.
After it had passed away, they were ten times merrier than before,
from the mere relief of Scrooge the Baleful being done with. Bob
Cratchit told them how he had a situation in his eye for Master Peter,
which would bring in, if obtained, full five-and-sixpence weekly. The
two young Cratchits laughed tremendously at the idea of Peter's
being a man of business; and Peter himself looked thoughtfully at
the fire from between his collars, as if he were deliberating what
particular investments he should favor when he came into the
receipt of that bewildering income. Martha, who was a poor
apprentice at a milliner's, then told them what kind of work she had
to do, and how many hours she worked at a stretch, and how she
meant to lie abed to-morrow morning for a good long rest; to-
morrow being a holiday she passed at home. Also how she had seen
a countess and a lord some days before, and how the lord "was
much about as tall as Peter," at which Peter pulled up his collars so
high that you couldn't have seen his head if you had been there. All
this time the chestnuts and the jug went round and round; and by
and by they had a song, about a lost child travelling in the snow,
from Tiny Tim, who had a plaintive little voice, and sang it very well
indeed.
By Hans Christian Andersen.
CHRISTMAS CAROL.
Anonymous.
LAST NIGHT, AS I LAY SLEEPING.
Last night, as I lay sleeping,
When all my prayers were said,
With my guardian angel keeping
His watch above my head,
I heard his sweet voice carolling,
Full softly on my ear,
A song for Christian boys to sing,
For Christian men to hear:
By Charles Dickens.
CHRISTMAS DAY IN LONDON.
The poulterers' shops were still half open, and the fruiterers' shops
were radiant in their glory. There were great round, pot-bellied
baskets of chestnuts, shaped like the waistcoats of jolly old
gentlemen, lolling at the doors, and tumbling out into the street in
their apoplectic opulence. There were ruddy, brown-faced, broad-
girthed Spanish onions, shining in the fatness of their growth like
Spanish Friars, and winking from their shelves in wanton slyness at
the girls as they went by and glanced demurely at the hung up
mistletoe. There were pears and apples, clustered high in blooming
pyramids; there were bunches of grapes, made, in the shop-keepers'
benevolence, to dangle from conspicuous hooks that people's
mouths might water gratis as they passed; there were piles of
filberts, mossy and brown, recalling, in their fragrance, ancient walks
among the woods, and pleasant shufflings ankle-deep through
withered leaves; there were Norfolk Biffins, squab and swarthy,
setting off the yellow of the oranges and lemons, and, in the great
compactness of their juicy persons, urgently entreating and
beseeching to be carried home in paper bags and eaten after dinner.
The very gold and silver fish, set forth among these choice fruits in a
bowl, though members of a dull and stagnant-blooded race,
appeared to know that there was something going on; and, to a fish,
went gasping round and round their little world in slow and
passionless excitement.
The Grocers'! oh, the Grocers'! nearly closed, with perhaps two
shutters down, or one; but through those gaps such glimpses! It
was not alone that the scales descending on the counter made a
merry sound, or that the twine and roller parted company so briskly,
or that the canisters were rattled up and down like juggling tricks, or
even that the blended scents of tea and coffee were so grateful to
the nose, or even that the raisins were so plentiful and rare, the
almonds so extremely white, the sticks of cinnamon so long and
straight, the other spices so delicious, the candied fruits so caked
and spotted with molten sugar as to make the coldest lookers-on
feel faint and subsequently bilious. Nor was it that the figs were
moist and pulpy, or that the French plums blushed in modest
tartness from their highly decorated boxes, or that everything was
good to eat and in its Christmas dress; but the customers were all so
hurried and so eager in the hopeful promise of the day, that they
tumbled up against each other at the door, crashing their wicker
baskets wildly, and left their purchases upon the counter, and came
running back to fetch them, and committed hundreds of the like
mistakes, in the best humor possible; while the Grocer and his
people were so frank and fresh that the polished hearts with which
they fastened their aprons behind might have been their own, worn
outside for general inspection, and for Christmas daws to peck at if
they chose.
IN THE CHURCH.
But soon the steeples called good people all to church and chapel;
and away they came, flocking through the streets in their best
clothes and with their gayest faces. And at the same time there
emerged from scores of by-streets, lanes, and nameless turnings,
innumerable people, carrying their dinners to the bakers' shops. The
sight of these poor revellers appeared to interest the Spirit very
much; for he stood with Scrooge beside him in a baker's doorway,
and taking off the covers as their bearers passed, sprinkled incense
on their dinners from his torch. And it was a very uncommon kind of
torch; for once or twice when there were angry words between
some dinner-carriers who had jostled each other, he shed a few
drops of water on them from it, and their good humor was restored
directly. For they said, it was a shame to quarrel upon Christmas
Day. And so it was! God love it, so it was!
By Charles Mackay.
UNDER THE HOLLY-BOUGH.
Ye who have scorned each other,
Or injured friend or brother,
In this fast-fading year;
Ye who, by word or deed,
Have made a kind heart bleed,—
Come gather here.
Let sinned against and sinning
Forget their strife's beginning,
And join in friendship now;
Be links no longer broken,
Be sweet forgiveness spoken
Under the holly-bough.
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.
ebookultra.com