An Introduction to Programming

and Numerical Methods in MATLAB

~~~~~~~~~~~~~~~~~~~~ www.MathWorks.ir ~~~~~~~~~~~~~~~~~~~~

S.R. Otto and J.P. Denier

An Introduction to

Programming and

Numerical Methods

in MATLAB

With 111 Figures

~~~~~~~~~~~~~~~~~~~~ www.MathWorks.ir ~~~~~~~~~~~~~~~~~~~~

S.R. Otto, BSc, PhD

The R & A

St Andrews

Fife

KY16 9JD

Scotland

J.P. Denier, BSc (Hons), PhD

School of Mathematical Sciences

The University of Adelaide

South Australia 5005

Australia

British Library Cataloguing in Publication Data

Otto, S. R. (Stephen Robert)

An introduction to programming and numerical methods in

MATLAB

1. MATLAB (Computer file) 2. Numerical analysis — Data

processing

I. Title II. Denier, J. P.

518′.02855

ISBN 1852339195

Library of Congress Control Number: 2005923332

Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced, stored or transmitted, in any form or by any means, with the prior permission in writing of the publishers, or in the case of reprographic reproduction in accordance with the terms of licences issued by the Copyright Licensing Agency. Enquiries concerning reproduction outside those terms should be sent to the publishers.

ISBN-10: 1-85233-919-5

ISBN-13: 978-185233-919-7

Springer Science+Business Media

springeronline.com

© Springer-Verlag London Limited 2005

The use of registered names, trademarks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant laws and regulations and therefore free for general use. The publisher makes no representation, express or implied, with regard to the accuracy of the information contained in this book and cannot accept any legal responsibility or liability for any errors or omissions that may be made.

Typesetting: Camera-ready by authors

Printed in the United States of America

12/3830-543210 Printed on acid-free paper SPIN 11317333

~~~~~~~~~~~~~~~~~~~~ www.MathWorks.ir ~~~~~~~~~~~~~~~~~~~~

For

Julie

and

Jill and Megan.

~~~~~~~~~~~~~~~~~~~~ www.MathWorks.ir ~~~~~~~~~~~~~~~~~~~~

Preface

This text provides an introduction to the numerical methods that are typically encountered (and used) in science and engineering undergraduate courses. The material is developed in tandem with MATLAB which allows rapid prototyping and testing of the methods. The package MATLAB (matrix laboratory) provides an environment in which students can learn to programme and explore the structure of the numerical methods. The methods included here are of a basic nature and only rely on material which should have been explored prior to the ﬁrst year undergraduate stage.

The methods presented are supplemented with a set of tasks at the end of each chapter (full solutions of these are given in Appendix C). The tasks are introduced in such a way as to allow students to explore the topics as they evolve. Some are of a mathematical nature, but in the main they involve manipulating codes which are given in the text of the chapter (or section). Those tasks which we regard as being harder are marked with an asterisk. Throughout the text MATLAB commands appear using this font in the text. In the main the names of MATLAB commands reﬂect the commands rˆle. We o

have taken particular care to highlight many of the problems that occur with interpreting the syntax of MATLAB commands. In Appendix B we provide a glossary of all MATLAB commands within the text and short examples of how these commands can be used. Reference is made to the comprehensive help facility within MATLAB: however examples are given which are similar to those given in other places within the text.

Throughout the text we derive the numerical techniques we use, but also emphasise that MATLAB’s rich...