We use cookies to distinguish you from other users and to provide you with a better experience on our websites. Close this message to accept cookies or find out how to manage your cookie settings.
To save content items to your account,
please confirm that you agree to abide by our usage policies.
If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account.
Find out more about saving content to .
To save content items to your Kindle, first ensure [email protected]
is added to your Approved Personal Document E-mail List under your Personal Document Settings
on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part
of your Kindle email address below.
Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations.
‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi.
‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
In two-point boundary value problems the auxiliary conditions associated with the differential equation, called the boundary conditions, are specified at two different values of x. This seemingly small departure from initial value problems has a major repercussion—it makes boundary value problems considerably more difficult to solve. In an initial value problem we were able to start at the point where the initial values were given and march the solution forward as far as needed. This technique does not work for boundary value problems, because there are not enough starting conditions available at either end point to produce a unique solution.
One way to overcome the lack of starting conditions is to guess the missing values. The resulting solution is very unlikely to satisfy boundary conditions at the other end, but by inspecting the discrepancy we can estimate what changes to make to the initial conditions before integrating again. This iterative procedure is known as the shooting method. The name is derived from analogy with target shooting—take a shot and observe where it hits the target, then correct the aim and shoot again.
Another means of solving two-point boundary value problems is the finite difference method, where the differential equations are approximated by finite differences at evenly spaced mesh points. As a consequence, a differential equation is transformed into set of simultaneous algebraic equations.
Find x that minimizes F(x) subject to g(x) = 0, h(x) ≥ 0
Introduction
Optimization is the term often used for minimizing or maximizing a function. It is sufficient to consider the problem of minimization only; maximization of F(x) is achieved by simply minimizing – F(x). In engineering, optimization is closely related to design. The function F(x), called the merit function or objective function, is the quantity that we wish to keep as small as possible, such as cost or weight. The components of x, known as the design variables, are the quantities that we are free to adjust. Physical dimensions (lengths, areas, angles, etc.) are common examples of design variables.
Optimization is a large topic with many books dedicated to it. The best we can do in limited space is to introduce a few basic methods that are good enough for problems that are reasonably well behaved and don't involve too many design variables. By omitting the more sophisticated methods, we may actually not miss all that much. All optimization algorithms are unreliable to a degree—any one of them may work on one problem and fail on another. As a rule of thumb, by going up in sophistication we gain computational efficiency, but not necessarily reliability.
The algorithms for minimization are iterative procedures that require starting values of the design variables x. If F(x) has several local minima, the initial choice of x determines which of these will be computed.
This book is targeted primarily toward engineers and engineering students of advanced standing (sophomores, seniors and graduate students). Familiarity with a computer language is required; knowledge of basic engineering mechanics 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.
Packages are text files that contain Mathematica commands. They are designed to make it easy to distribute your programs to others, but they also provide a mechanism for you to write programs that integrate with Mathematica in a seamless manner. In this chapter we will discuss the organization and creation of packages including a discussion of contexts, which are a mechanism for organizing new names and symbols in your Mathematica sessions.
Introduction
When you begin a Mathematica session, the built-in functions are immediately available for you to use. There are, however, many more functions that you can access that reside in files supplied with Mathematica. In principle, the only difference between those files and the ones you create is that those were written by professional programmers. There is another difference: the definitions in those files are placed in special structures called packages. Indeed, these files themselves are often called “packages” instead of “files.”
Packages are a name localizing construct, analogous to Module, but for entire files of definitions. Their purpose is to allow the programmer to define a collection of functions for export. These exported functions are for the users of the package to work with and are often referred to as public functions. Other functions, those that are not for export, are auxiliary, or private functions, and are not intended to be accessible to users.
In this chapter, you will learn how to write your own packages.
The development of larger-scale Mathematica programming projects is discussed and illustrated in this chapter. Each of the examples in this chapter contain numerous tasks that need to work together and also integrate well with Mathematica. When you develop such applications, it is important to think about how your functions work with each other as well as how well they integrate with the rest of Mathematica. The user's interface to your programs should be as close as possible to the built-in functions of Mathematica so that users can more easily learn the syntax and usage. Features such as options, argument checking, messaging, and documentation are all discussed in the context of larger applications that are developed using all of the tools that were developed in earlier chapters.
Manipulating data files
Introduction
One of the most common tasks for scientists and engineers is working with data sets that have been generated by some external process or collector. If they are lucky, the data are stored in a file that has a standard format and can then be read into other programs such as Mathematica with ease using that program's importing functionality. Oftentimes, however, data are stored in files with nonstandard formats and reading that file into a program such as Mathematica requires some manual processing of that file to extract the required parts.
In this section we will walk through the steps of reading, manipulating, and visualizing a dataset that consists of solar radiation data collected by the Renewable Resource Data Center, an organization that is managed by the US Department of Energy (interested readers should visit rredc.nrel.gov).