Excel for Scientists and Engineers Numerical Methods 1st Edition E. Joseph Billo all chapter instant download
Excel for Scientists and Engineers Numerical Methods 1st Edition E. Joseph Billo all chapter instant download
com
https://ebookname.com/product/excel-for-scientists-and-
engineers-numerical-methods-1st-edition-e-joseph-billo/
OR CLICK BUTTON
DOWNLOAD EBOOK
https://ebookname.com/product/excel-2007-for-scientists-and-
engineers-2nd-edition-dr-gerard-verschuuren/
ebookname.com
https://ebookname.com/product/statistical-methods-for-engineers-and-
scientists-third-edition-bethea/
ebookname.com
https://ebookname.com/product/numerical-analysis-for-scientists-and-
engineers-theory-and-c-programs-1st-edition-madhumangal-pal/
ebookname.com
https://ebookname.com/product/helping-grieving-people-when-tears-are-
not-enough-a-handbook-for-care-providers-1st-edition-j-shep-jeffreys/
ebookname.com
Phantom Nation Inventing the Palestinians as the Obstacle
to Peace Volume One and Two Box Set Sha'I Ben-Tekoa
https://ebookname.com/product/phantom-nation-inventing-the-
palestinians-as-the-obstacle-to-peace-volume-one-and-two-box-set-shai-
ben-tekoa/
ebookname.com
https://ebookname.com/product/poems-of-the-elder-edda-charles-w-dunn/
ebookname.com
https://ebookname.com/product/carla-bley-1st-edition-edition-amy-c-
beal/
ebookname.com
https://ebookname.com/product/ocr-a-level-biology-
studentbook-1-adrian-schmit/
ebookname.com
https://ebookname.com/product/digital-video-moving-images-and-
computers-the-digital-world-1st-edition-ananda-mitra/
ebookname.com
Operation Dragoon 1944 France s Other D Day Steven J.
Zaloga
https://ebookname.com/product/operation-dragoon-1944-france-s-other-d-
day-steven-j-zaloga/
ebookname.com
Excel@
for Scientists
and Engineers
Numerical Methods
E. Joseph Bill0
BICENTENNIAL
BICENTENNIAL
WILEY-INTERSCIENCE
A John Wiley & Sons, Inc., Publication
This Page Intentionally Left Blank
Excel@
for Scientists
and Engineers
Numerical Methods
THE W I L E Y BICENTENNIAL-KNOWLEDGE FOR GENERATIONS
G a c h generation has its unique needs and aspirations. When Charles Wiley first
opened his small printing shop in lower Manhattan in 1807, it was a generation
of boundless potential searching for an identity. And we were there, helping to
define a new American literary tradition. Over half a century later, in the midst
of the Second Industrial Revolution, it was a generation focused on building the
future. Once again, we were there, supplying the critical scientific, technical, and
engineering knowledge that helped frame the world. Throughout the 20th
Century, and into the new millennium, nations began to reach out beyond their
own borders and a new international community was born. Wiley was there,
expanding its operations around the world to enable a global exchange of ideas,
opinions, and know-how.
For 200 years, Wiley has been an integral part of each generation’s journey,
enabling the flow of information and understanding necessary to meet their needs
and filfill their aspirations. Today, bold new technologies are changing the way
we live and learn. Wiley will be there, providing you the must-have knowledge
you need to imagine new worlds, new possibilities, and new opportunities.
Generations come and go, but you can always count on Wiley to provide you the
Ek-&Ti%
knowledge you need, when and where you need it!
L44!!-.f. @
-
WILLIAM J. P E S C E PETER B O O T H W l L E V
PRESIDENT AND CHIEF EXECUTIVE P m C E R CHAIRMAN OF THE BOARD
Excel@
for Scientists
and Engineers
Numerical Methods
E. Joseph Bill0
BICENTENNIAL
BICENTENNIAL
WILEY-INTERSCIENCE
A John Wiley & Sons, Inc., Publication
Copyright 02007 by John Wiley & Sons, Inc. All rights reserved.
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) 750-4470, or on the web at www.copyright.com. 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-601 1, fax (201) 748-6008, or online at http://www.wiley.comgo/permission.
Limit of Liability/Disclaimer of Warranty: While the publisher and author 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 or for technical support, please contact our Customer Care
Department within the United States at (800) 762-2974, outside the United States 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 may not be available in
electronic format. For information about Wiley products, visit our web site at www.wiley.com.
ISBN: 978-0-471-38734-3
109 8 7 6 5 4 3 2 1
Summary of Contents
..
Detailed Table of Contents .................................................................................. v11
Preface ................................................................................................................ xv
Acknowledgments ............................................................................................... xix
About the Author ................................................................................................. xix
Chapter 1 Introducing Visual Basic for Applications .................................... 1
Chapter 2 Fundamentals of Programming with VBA .................................. 15
Chapter 3 Worksheet Functions for Working with Matrices ....................... 57
Chapter 4 Number Series ............................................................................. 69
Chapter 5 Interpolation ................................................................................ 77
Chapter 6 Differentiation ............................................................................. 99
Chapter 7 Integration ................................................................................. 127
Chapter 8 Roots of Equations .................................................................... 147
Chapter 9 Systems of Simultaneous Equations .......................................... 189
Chapter 10 Numerical Integration of Ordinary Differential Equations
Part I: Initial Conditions ............................................................ 217
Chapter 11 Numerical Integration of Ordinary Differential Equations
Part 11: Boundary Conditions ..................................................... 245
Chapter 12 Partial Differential Equations .................................................... 263
Chapter 13 Linear Regression and Curve Fitting ......................................... 287
Chapter 14 Nonlinear Regression Using the Solver ..................................... 313
Chapter 15 Random Numbers and the Monte Carlo Method ....................... 341
APPENDICES
Appendix 1 Selected VBA Keywords ........................................................... 365
Appendix 2 Shortcut Keys for VBA ............................................................. 387
Appendix 3 Custom Functions Help File ...................................................... 389
Appendix 4 Some Equations for Curve Fitting ............................................. 409
Appendix 5 Engineering and Other Functions .............................................. 423
Appendix 6 ASCII Codes .............................................................................. 427
Appendix 7 Bibliography .............................................................................. 429
Appendix 8 Answers and Comments for End-of-Chapter Problems ............431
INDEX ............................................................................................................. 443
V
This Page Intentionally Left Blank
Contents
Preface ...........:.................................................................................................... xv
Acknowledgments ............................................................................................... xix
About the Author ................................................................................................. xix
Chapter 1 Introducing Visual Basic for Applications 1
The Visual Basic Editor ......................................................................................... 1
Visual Basic Procedures ......................................................................................... 4
There Are Two Kinds of Macros ..................................................................... 4
The Structure of a Sub Procedure .................................................................... 4
The Structure of a Function Procedure ............................................................ 5
Using the Recorder to Create a Sub Procedure ............................................ 5
The Personal Macro Workbook ....................................................................... 7
Running a Sub Procedure ................................................................................ 8
Assigning a Shortcut Key to a Sub Procedure ................................................. 8
Entering VBA Code ............................................................................................... 9
Creating a Simple Custom Function .............................................................. 10
Using a Function Macro ................................................................................ 10
A Shortcut to Enter a Function ...................................................................... 12
Some FAQs .......................................................................................................... 13
Chapter 2 Fundamentals of Programming with VBA 15
Components of Visual Basic Statements.............................................................. 15
Operators........................................................................................................ 16
Variables ........................................................................................................ 16
Objects, Properties, and Methods .................................................................. 17
Objects ........................................................................................................... 17
Properties ....................................................................................................... 17
Using Properties............................................................................................. 19
Functions........................................................................................................ 20
Using Worksheet Functions with VBA ......................................................... 22
Some Useful Methods .................................................................................... 22
Other Keywords ............................................................................................. 23
Program Control ................................................................................................... 23
Branching ....................................................................................................... 23
Logical Operators .......................................................................................... 24
Select Case ..................................................................................................... 24
Looping .......................................................................................................... 24
For... Next Loop .............................................................................................. 25
Do While... Loop ........................................................................................... 25
vii
...
Vlll EXCEL: NUMERICAL METHODS
Chapter 5 Interpolation 77
Obtaining Values from a Table ............................................................................ 77
Using Excel's Lookup Functions to Obtain Values from a Table ..................77
Using VLOOKUP to Obtain Values from a Table .......................................... 78
Using the LOOKUP Function to Obtain Values from a Table ....................... 79
Creating a Custom Lookup Formula to Obtain Values from a Table ............80
Using Excel's Lookup Functions
to Obtain Values from a Two-way Table .................................................. 81
Interpolation ......................................................................................................... 83
Linear Interpolation in a Table by Means of Worksheet Formulas ............... 83
Linear Interpolation in a Table by Using the TREND Worksheet Function ..85
Linear Interpolation in a Table by Means of a Custom Function ..................86
Cubic Interpolation ........................................................................................ 87
Cubic Interpolation in a Table by Using the TREND Worksheet Function ...89
Linear Interpolation in a Two-way Table
by Means of Worksheet Formulas .............................................................. 90
Cubic Interpolation in a Two-way Table
by Means of Worksheet Formulas .............................................................. 91
Cubic Interpolation in a Two-way Table
by Means of a Custom Function ................................................................. 93
Problems ............................................................................................................... 96
Chapter 6 Differentiation 99
First and Second Derivatives of Data in a Table .................................................. 99
Calculating First and Second Derivatives .......................................................... 100
Using LINEST as a Fitting Function ............................................................ 105
Derivatives of a Worksheet Formula .................................................................. 109
Derivatives of a Worksheet Formula Calculated by Using
a VBA Function Procedure ...................................................................... 109
First Derivative of a Worksheet Formula Calculated by Using
the Finite-Difference Method ................................................................... 110
The Newton Quotient................................................................................... 110
Derivative of a Worksheet Formula Calculated by Using
the Finite-Difference Method ................................................................... 111
First Derivative of a Worksheet Formula Calculated by Using
a VBA Sub Procedure Using the Finite-Difference Method .................... 112
First Derivative of a Worksheet Formula Calculated by Using
a VBA Function Procedure Using the Finite-Difference Method ............115
Improving the VBA Function Procedure ..................................................... 118
Second Derivative of a Worksheet Formula ................................................ 120
Concerning the Choice of Ax for the Finite-Difference Method ................. 123
Problems ............................................................................................................. 124
CONTENTS xi
Importing the Trendline Equation from a Chart into a Worksheet .............. 305
Problems ............................................................................................................. 309
Chapter 14 Nonlinear Regression Using the Solver 313
Nonlinear Least-Squares Curve Fitting .............................................................. 314
Introducing the Solver ................................................................................. 316
How the Solver Works................................................................................. 316
Loading the Solver Add-In .......................................................................... 317
Why Use the Solver for Nonlinear Regression? .......................................... 317
Nonlinear Regression Using the Solver: An Example................................. 318
Some Notes on Using the Solver ................................................................. 323
Some Notes on the Solver Parameters Dialog Box ..................................... 323
Some Notes on the Solver Options Dialog Box........................................... 324
When to Use Manual Scaling ...................................................................... 326
Statistics of Nonlinear Regression ..................................................................... 327
The Solver Statistics Macro ......................................................................... 328
Be Cautious When Using Linearized Forms of Nonlinear Equations .........329
Problems ............................................................................................................. 332
Chapter 15 Random Numbers and the Monte Cario Method 341
Random Numbers in Excel ................................................................................. 341
How Excel Generates Random Numbers .................................................... 341
Using Random Numbers in Excel ............................................................... 342
Adding "Noise" to a Signal Generated by a Formula .................................. 344
Selecting Items Randomly from a List ........................................................ 345
Random Sampling by Using Analysis Tools ............................................... 347
Simulating a Normal Random Distribution of a Variable ........................... 349
Monte Carlo Simulation ..................................................................................... 350
Monte Carlo Integration ..................................................................................... 354
The Area of an Irregular Polygon ................................................................ 354
Problems ............................................................................................................. 362
APPENDICES 363
Appendix 1 Selected VBA Keywords ........................................................... 365
Appendix 2 Shortcut Keys for VBA ............................................................. 387
Appendix 3 Custom Functions Help File ...................................................... 389
Appendix 4 Some Equations for Curve Fitting ............................................. 409
Appendix 5 Engineering and Other Functions .............................................. 423
Appendix 6 ASCII Codes .............................................................................. 427
Appendix 7 Bibliography .............................................................................. 429
Appendix 8 Answers and Comments for End-of-Chapter Problems ............431
INDEX .............................................................................................................. 443
Preface
xv
xvi EXCEL: NUMERICAL METHODS
topics, such as Bairstow's method for obtaining the roots of a regular polynomial,
are discussed in detail.
In this book I have provided a wide range of Excel solutions to problems. In
many cases I provide a series of examples that progress from a very simple
implementation of the problem (useful for understanding the logic and
construction of the spreadsheet or VBA code) to a more sophisticated one that is
more general. Some of the VBA macros are simple "starting points" and I
encourage the reader to modify them; others are (or at least I intended them to
be) "finished products" that I hope users can employ on a regular basis.
Nearly 100% of the material in this book applies equally to the PC or
Macintosh versions of Excel. In a few cases I have pointed out the different
keystrokes requires for the Macintosh version.
a "Problems" folder. The Problems folder contains a folder for each chapter,
e.g., 'Ch. 06 (Differentiation) problems.' The problems folder for each
chapter contains solutions to (almost) all of the end-of-chapter problems in
that chapter. VBA code required for the solution of any of the problems is
provided in each workbook that requires it; the VBA code will be identical to
the code found in the 'Examples' folder.
an Excel workbook, "Numerical Methods Toolbox," that contains all of the
important custom functions in this book.
a copy of "Numerical Methods Toolbox'' saved as an Add-In workbook (an
.xla file). If you open this Add-In, the custom functions will be available for
use in any Excel workbook.
Two Excel workbooks containing the utilities Solver Statistics and Trendline
to Cell.
E. Joseph Billo
PREFACE xix
Acknowledgments
Dr. Richard N. Fell, Department of Physics, Brandeis University, Waltham,
MA; Prof. Michele Mandrioli, Department of Chemistry and Biochemistry,
University of Massachusetts-Dartmouth, North Dartmouth, MA; and Prof.
Christopher King, Department of Chemistry, Troy University, Troy, AL, who
read the complete manuscript and provided valuable comments and corrections.
Prof. Lev Zompa, University of Massachusetts-Boston, and Dr. Peter Gans,
Protonic Software, for UV-vis spectral data.
Edwin Straver and Nicole Steidel, Frontline Systems Inc., for information
about the inner workings of the Solver.
The Dow Chemical Company for permission to use tables of physical
properties of heat transfer fluids.
1
2 EXCEL: NUMERICAL METHODS
contain any module sheets, the Code window will be empty. To insert a module
sheet, choose Module from the Insert menu. A folder icon labeled Modules
will be inserted; if you click on this icon, the module sheet Module1 will
bedisplayed. Excel gives these module sheets the default names Modulel,
Module2 and so on.
Use the Project window to select a particular code module from all the
available modules in open workbooks. These are displayed in the Project
window (Figure 1-2), which is usually located on the left side of the screen. If
the Project window is not visible, choose Project Explorer from the View
menu, or click on the Project Explorer toolbutton $& to display it. The Project
Explorer toolbutton is the fifth button from the right in the VBA toolbar.
In the Project Explorer window you will see a hierarchy tree with a node for
each open workbook. In the example illustrated in Figure 1-2, a new workbook,
Bookl, has been opened. The node for Bookl has a node (a folder icon) labeled
Microsoft Excel Objects; click on the folder icon to display the nodes it contains-
an icon for each sheet in the workbook and an additional one labeled
Thisworkbook. If you double-click on any one of these nodes you will display the
code sheet for it. These code sheets are for special types of procedures called
automatic procedures or event-handler procedures, which are not covered in this
Random documents with unrelated
content Scribd suggests to you:
— En ensinkään ihmettele, että teette elämänne niin mieluisaksi
kuin suinkin. Teillähän on sangen hyvä paikka.
Viime sanat lausui hän niin lujalla totisuudella, että kaikki hymy,
joka kertomuksen kestäessä oli noussut kuulijoiden kasvoille, paikalla
katosi.
— Todellako?
Kiireesti oli hän sanansa lausunut. Hänet oli vallannut halu vielä
nähdä tuo tyttö, usein jutella hänen kanssaan yhtä lapsellisen
hauskasti kuin tänään.
Konrad oli niin kummissaan, ettei hän voinut muuta kuin ääneti
nyökäyttää päätään; hän pysyi harvapuheisena, yksin
vieruskumppanittarelleenkin. Vihdoin katosi häneltä ruokahalu.
Olisiko hän niin kokonaan erehtynyt? Äkkiä muistui Klaudina hänen
mieleensä. Kunhan ei hän vain olisi vaikuttanut asiain kulkuun?
Konrad ei häneen luottanut, vaikka veli olisi kehunut häntä tuhat
kertaa enemmän kuin tänään aamupäivällä.
Kymmenes luku.
Tohtori Baldus läksi eteläistä etukaupunkia kohti. Taivaalle
kerääntyi synkkiä pilviä; se pani ihmiset kiiruhtamaan. Mutta hän ei
ajatellut uhkaavaa ilmaa, vaan astui erityistä kiirettä pitämättä
katujen halki; hän oli ajatusten vallassa, jotka suuresti häneen
koskivat. Eilispäivästä oli hän kokenut paljon ja oppinut tuntemaan
ihmeellisiä ihmisiä!
— Entä te kolme?
— Eikö sitä ole siinä? hämmästeli tyttö. — Minä jaoin sen kolmeksi
kerraksi. Ja jälellä on vielä aika joukko. Herätän heidät pian,
nimittäin Emilin ja Marian — ennenkuin toiset tulevat kotiin ja isä
herää. Sitte saatte nähdä kuinka sitä syödään.
— Olen pappi.
— Mutta istukaa toki, herra pastori. Pyydän, olkaa niin hyvä. Tämä
tuoli on tosin vähän… Mutta minä heti… Fransiskan piti jo eilen viedä
se nikkarille, mutta kun ei itse toimita kaikkia…!
— Tässä se on. Mitähän meistäkään olisi tullut, jollei sitä olisi ollut!
Rakas vanha raamattu, joka vielä on isoisä-vainajan peruja, virkkoi
hän, laskettuaan jättiläiskokoisen perintönsä pöydälle. Luiseva käsi
kosketti hyväellen kulunutta kantta.