APPLIED NUMERICAL METHODS USING MATLAB - UMRI

APPLIED NUMERICAL METHODS USING MATLAB

Won Young Yang

Chung-Ang University, Korea

Wenwu Cao

Pennsylvania State University

Tae-Sang Chung

Chung-Ang University, Korea

John Morris

The University of Auckland, New Zealand

A JOHN WILEY & SONS, INC., PUBLICATION

Questions about the contents of this book can be mailed to wyyang@cau.ac.kr.

MATLAB and Simulink are trademarks of the The MathWorks, Inc. and are 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 and Simulink software or related products does not

constitute endorsement or sponsorship by The MathWorks of a particular pedagogical approach or particular use of the MATLAB and Simulink software.

Copyright 2005 by John Wiley & Sons, Inc. All rights reserved.

Published by John Wiley & Sons, Inc., Hoboken, New Jersey. Published simultaneously in Canada.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400, fax 978-646-8600, or on the web at . Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008.

Limit of Liability/Disclaimer of Warranty: While the publisher and authors have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.

For general information on our other products and services please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993 or fax 317-572-4002.

Wiley also publishes its books in a variety of electronic formats. Some content that appears in print, however, may not be available in electronic format.

Library of Congress Cataloging-in-Publication Data

Yang, Won-young, 1953? Applied numerical methods using MATLAB / Won Y. Yang, Wenwu Cao, Tae S.

Chung, John Morris. p. cm.

Includes bibliographical references and index. ISBN 0-471-69833-4 (cloth) 1. Numerical analysis?Data processing. 2. MATLAB. I. Cao, Wenwu. II. Chung, Tae-sang, 1952? III. Title.

QA297.Y36 2005 518 ? dc22

2004013108

Printed in the United States of America. 10 9 8 7 6 5 4 3 2 1

To our parents and families who love and support us

and to our teachers and students who enriched our knowledge

CONTENTS

Preface

xiii

1 MATLAB Usage and Computational Errors

1

1.1 Basic Operations of MATLAB / 1 1.1.1 Input/Output of Data from MATLAB Command Window / 2 1.1.2 Input/Output of Data Through Files / 2 1.1.3 Input/Output of Data Using Keyboard / 4 1.1.4 2-D Graphic Input/Output / 5 1.1.5 3-D Graphic Output / 10 1.1.6 Mathematical Functions / 10 1.1.7 Operations on Vectors and Matrices / 15 1.1.8 Random Number Generators / 22 1.1.9 Flow Control / 24

1.2 Computer Errors Versus Human Mistakes / 27 1.2.1 IEEE 64-bit Floating-Point Number Representation / 28 1.2.2 Various Kinds of Computing Errors / 31 1.2.3 Absolute/Relative Computing Errors / 33 1.2.4 Error Propagation / 33 1.2.5 Tips for Avoiding Large Errors / 34

1.3 Toward Good Program / 37 1.3.1 Nested Computing for Computational Efficiency / 37 1.3.2 Vector Operation Versus Loop Iteration / 39 1.3.3 Iterative Routine Versus Nested Routine / 40 1.3.4 To Avoid Runtime Error / 40 1.3.5 Parameter Sharing via Global Variables / 44 1.3.6 Parameter Passing Through Varargin / 45 1.3.7 Adaptive Input Argument List / 46

Problems / 46

vii

viii CONTENTS

2 System of Linear Equations

71

2.1 Solution for a System of Linear Equations / 72 2.1.1 The Nonsingular Case (M = N ) / 72 2.1.2 The Underdetermined Case (M < N ): Minimum-Norm Solution / 72 2.1.3 The Overdetermined Case (M > N ): Least-Squares Error Solution / 75 2.1.4 RLSE (Recursive Least-Squares Estimation) / 76

2.2 Solving a System of Linear Equations / 79 2.2.1 Gauss Elimination / 79 2.2.2 Partial Pivoting / 81 2.2.3 Gauss?Jordan Elimination / 89

2.3 Inverse Matrix / 92 2.4 Decomposition (Factorization) / 92

2.4.1 LU Decomposition (Factorization): Triangularization / 92

2.4.2 Other Decomposition (Factorization): Cholesky, QR, and SVD / 97

2.5 Iterative Methods to Solve Equations / 98 2.5.1 Jacobi Iteration / 98 2.5.2 Gauss?Seidel Iteration / 100 2.5.3 The Convergence of Jacobi and Gauss?Seidel Iterations / 103

Problems / 104

3 Interpolation and Curve Fitting

117

3.1 Interpolation by Lagrange Polynomial / 117 3.2 Interpolation by Newton Polynomial / 119 3.3 Approximation by Chebyshev Polynomial / 124 3.4 Pade Approximation by Rational Function / 129 3.5 Interpolation by Cubic Spline / 133 3.6 Hermite Interpolating Polynomial / 139 3.7 Two-dimensional Interpolation / 141 3.8 Curve Fitting / 143

3.8.1 Straight Line Fit: A Polynomial Function of First Degree / 144

3.8.2 Polynomial Curve Fit: A Polynomial Function of Higher Degree / 145

3.8.3 Exponential Curve Fit and Other Functions / 149 3.9 Fourier Transform / 150

3.9.1 FFT Versus DFT / 151 3.9.2 Physical Meaning of DFT / 152 3.9.3 Interpolation by Using DFS / 155 Problems / 157

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download