﻿ An Engineer's Guide to Mathematica - Edward B. Magrab - E-Book - Legimi online

# An Engineer's Guide to Mathematica E-Book

## Edward B. Magrab

0,0
72,99 €

Beschreibung

Free Mathematica 10 Update Included! Now available from www.wiley.com/go/magrab Updated material includes: - Creating regions and volumes of arbitrary shape and determining their properties: arc length, area, centroid, and area moment of inertia - Performing integrations, solving equations, and determining the maximum and minimum values over regions of arbitrary shape - Solving numerically a class of linear second order partial differential equations in regions of arbitrary shape using finite elements An Engineer's Guide to Mathematica enables the reader to attain the skills to create Mathematica 9 programs that solve a wide range of engineering problems and that display the results with annotated graphics. This book can be used to learn Mathematica, as a companion to engineering texts, and also as a reference for obtaining numerical and symbolic solutions to a wide range of engineering topics. The material is presented in an engineering context and the creation of interactive graphics is emphasized. The first part of the book introduces Mathematica's syntax and commands useful in solving engineering problems. Tables are used extensively to illustrate families of commands and the effects that different options have on their output. From these tables, one can easily determine which options will satisfy one's current needs. The order of the material is introduced so that the engineering applicability of the examples increases as one progresses through the chapters. The second part of the book obtains solutions to representative classes of problems in a wide range of engineering specialties. Here, the majority of the solutions are presented as interactive graphics so that the results can be explored parametrically. Key features: * Material is based on Mathematica 9 * Presents over 85 examples on a wide range of engineering topics, including vibrations, controls, fluids, heat transfer, structures, statistics, engineering mathematics, and optimization * Each chapter contains a summary table of the Mathematica commands used for ease of reference * Includes a table of applications summarizing all of the engineering examples presented. * Accompanied by a website containing Mathematica notebooks of all the numbered examples An Engineer's Guide to Mathematica is a must-have reference for practitioners, and graduate and undergraduate students who want to learn how to solve engineering problems with Mathematica.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi

Seitenzahl: 434

Bewertungen
0,0
0
0
0
0
0

#### AN ENGINEER’S GUIDE TO MATHEMATICA®

Edward B. Magrab

University of Maryland, USA

This edition first published 2014 © 2014 John Wiley & Sons, Ltd

Registered office John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, United Kingdom

For details of our global editorial offices, for customer services and for information about how to apply for permission to reuse the copyright material in this book please see our website at www.wiley.com.

The right of the author to be identified as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988.

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 or otherwise, except as permitted by the UK Copyright, Designs and Patents Act 1988, without the prior permission of the publisher.

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

Designations used by companies to distinguish their products are often claimed as trademarks. All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners. The publisher is not associated with any product or vendor mentioned in this book.

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. It is sold on the understanding that the publisher is not engaged in rendering professional services and neither the publisher nor the author shall be liable for damages arising herefrom. If professional advice or other expert assistance is required, the services of a competent professional should be sought.

Mathematica® is a registered trademark of Wolfram Research, Inc. and is used with permission. Wolfram Research, Inc. does not warrant the accuracy of the text or exercises in this book. The books use or discussion of Mathematica® or related products does not constitute endorsement or sponsorship by Wolfram Research, Inc. nor is Wolfram Research, Inc. directly involved in this book’s development or creation.

Library of Congress Cataloging-in-Publication Data applied for.

ISBN: 9781118821268

For

June Coleman Magrab

#### Contents

Preface

Table of Engineering Applications

Part 1 Introduction

1 Mathematica

®

Environment and Basic Syntax

1.1 Introduction

1.2 Selecting Notebook Characteristics

1.3 Notebook Cells

1.4 Delimiters

1.5 Basic Syntax

1.6 Mathematical Constants

1.7 Complex Numbers

1.8 Elementary, Trigonometric, Hyperbolic, and a Few Special Functions

1.9 Strings

1.10 Conversions, Relational Operators, and Transformation Rule

1.11 Engineering Units and Unit Conversions:

Quantity[]

and

UnitConvert[]

1.12 Creation of CDF Documents and Documents in Other Formats

1.13 Functions Introduced in Chapter 1

Exercises

Notes

2 List Creation and Manipulation: Vectors and Matrices

2.1 Introduction

2.2 Creating Lists and Vectors

2.3 Creating Matrices

2.4 Matrix Operations on Vectors and Arrays

2.5 Solution of a Linear System of Equations:

LinearSolve[]

2.6 Eigenvalues and Eigenvectors:

EigenSystem[]

2.7 Functions Introduced in Chapter 2

References

Exercises

3 User-Created Functions, Repetitive Operations, and Conditionals

3.1 Introduction

3.2 Expressions and Procedures as Functions

3.3 Find Elements of a List that Meet a Criterion:

Select[]

3.4 Conditionals

3.5 Repetitive Operations

3.6 Examples of Repetitive Operations and Conditionals

3.7 Functions Introduced in Chapter 3

Exercises

Notes

4 Symbolic Operations

4.1 Introduction

4.2

Assumption

Options

4.3 Solutions of Equations:

Solve[]

4.4 Limits:

Limit[]

4.5 Power Series:

Series[]

,

Coefficient[]

, and

CoefficientList[]

4.6 Optimization:

Maximize[]/Minimize[]

4.7 Differentiation:

D[]

4.8 Integration:

Integrate[]

4.9 Solutions of Ordinary Differential Equations:

DSolve[]

4.10 Solutions of Partial Differential Equations:

DSolve[]

4.11 Laplace Transform:

LaplaceTransform[]

and

InverseLaplaceTransform[]

4.12 Functions Introduced in Chapter 4

References

Exercises

5 Numerical Evaluations of Equations

5.1 Introduction

5.2 Numerical Integration:

NIntegrate[]

5.3 Numerical Solutions of Differential Equations:

NDSolveValue[]

and

ParametricNDSolveValue[]

5.4 Numerical Solutions of Equations:

NSolve[]

5.5 Roots of Transcendental Equations:

FindRoot[]

5.6 Minimum and Maximum:

FindMinimum[]

and

FindMaximum[]

5.7 Fitting of Data:

Interpolation[]

and

FindFit[]

5.8 Discrete Fourier Transforms and Correlation:

Fourier[]

,

InverseFourier[]

, and

ListCorrelate[]

5.9 Functions Introduced in Chapter 5

References

Exercises

Notes

6 Graphics

6.1 Introduction

6.2 2D Graphics

6.3 3D Graphics

6.4 Summary of Functions Introduced in Chapter 6

References

Exercises

7 Interactive Graphics

7.1 Interactive Graphics:

Manipulate[]

References

Exercises

Part 2 Engineering Applications

8 Vibrations of Spring–Mass Systems and Thin Beams

8.1 Introduction

8.2 Single Degree-of-Freedom Systems

8.3 Two Degrees-of-Freedom Systems

8.4 Thin Beams

References

9 Statistics

9.1 Descriptive Statistics

9.2 Probability of Continuous Random Variables

9.3 Regression Analysis:

LinearModelFit[]

9.4 Nonlinear Regression Analysis:

NonLinearModelFit[]

9.5 Analysis of Variance (ANOVA) and Factorial Designs:

ANOVA[]

9.6 Functions Introduced in Chapter 9

Notes

10 Control Systems and Signal Processing

10.1 Introduction

10.2 Model Generation: State-Space and Transfer Function Representation

10.3 Model Connections – Closed-Loop Systems and System Response:

SystemsModelFeedbackConnect[]

and

SystemsModelSeriesConnect[]

10.4 Design Methods

10.5 Signal Processing

10.6 Aliasing

10.7 Functions Introduced in Chapter 10

Reference

Notes

11 Heat Transfer and Fluid Mechanics

11.1 Introduction

11.2 Conduction Heat Transfer

11.3 Natural Convection Along Heated Plates

11.4 View Factor Between Two Parallel Rectangular Surfaces

11.5 Internal Viscous Flow

11.6 External Flow

References

Index

Chapter 1

Table 1.1

Table 1.2

Table 1.3

Table 1.4

Table 1.5

Table 1.6

Table 1.7

Table 1.8

Table 1.9

Table 1.10

Table 1.11

Chapter 2

Table 2.1

Table 2.2

Table 2.3

Table 2.4

Table 2.5

Table 2.6

Table 2.7

Chapter 3

Table 3.1

Table 3.2

Table 3.3

Chapter 4

Table 4.1

Table 4.2

Table 4.3

Table 4.4

Table 4.5

Chapter 5

Table 5.1

Table 5.2

Chapter 6

Table 6.1

Table 6.2

Table 6.3

Table 6.4

Table 6.5

Table 6.6

Table 6.7

Table 6.8

Table 6.9

Table 6.10

Table 6.11

Table 6.12

Table 6.13

Table 6.14

Table 6.15

Table 6.16

Table 6.17

Table 6.18

Table 6.19

Table 6.20

Table 6.21

Table 6.22

Chapter 7

Table 7.1

Chapter 9

Table 9.1

Table 9.2

Table 9.3

Table 9.4

Table 9.5

Table 9.6

Table 9.7

Table 9.8

Table 9.9

Table 9.10

Table 9.11

Chapter 10

Table 10.1

Table 10.2

Chapter 11

Table 11.1

Cover

Preface

Part

Chapter

xiii

xvii

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

#### Preface

The primary goal of this book is to help the reader attain the skills to create Mathematica programs that obtain symbolic and numerical solutions to a wide range of engineering topics, and to display the numerical results with annotated graphics.

Some of the features that make the most recent versions of Mathematica a powerful tool for solving a wide range of engineering applications are their recent introduction of new or expanded capabilities in differential equations, controls, signal processing, optimization, and statistics. These capabilities, coupled with its seamless integration of symbolic manipulations, engineering units, numerical calculations, and its diverse interactive graphics, provide engineers with another effective means of obtaining solutions to engineering problems.

The level of the book assumes that the reader has some fluency in engineering mathematics, can employ the engineering approach to problem solving, and has some experience in using mathematical models to predict the response of elements, devices, and systems. It should be suitable for undergraduate and graduate engineering students and for practicing engineers.

The book can be used in several ways: (1) to learn Mathematica; (2) as a companion to engineering texts; and (3) as a reference for obtaining numerical and symbolic solutions to a wide range of engineering topics involving ordinary and partial differential equations, optimization, eigenvalue determination, statistics, and so on.

The following aids have been used to make it easier to navigate the book’s material. Different fonts are used to make the Mathematica commands and the computer code distinguishable from text. In addition, since Greek letters and subscripts can be used in variable names, almost all programs have been coded to match the equations being programmed, thereby making portions of the code more readable. In the first chapter, the use of templates is illustrated so that one can easily create variables with Greek letters and with subscripts. Lastly, since Mathematica is fundamentally different from computer languages usually employed by engineers, the introductory material attempts to make this transition as smooth as possible.

In many of the chapters, tables are used extensively to illustrate families of commands and the effects that different options have on their output. From these tables, the reader can determine at a glance which command and which options can be used to satisfy the current objective. The order of the material is introduced is such a way that the complexity of the examples can be increased as one progresses through the chapters. Thus, the examples range from the ordinary to the challenging. Many of the examples are taken from a wide range of engineering topics. To supplement the material presented in this book, many specific references are made throughout the text to Mathematica’s Documentation Center, which provide numerous guides and tutorials on topical collections of commands.

The book has two interrelated parts. The first part consists of seven chapters, which introduce the fundamentals of Mathematica’s syntax and a subset of commands useful in solving engineering problems. The second part makes extensive use of the material in these seven chapters to show how, in a straightforward manner, one can obtain numerical solutions in a wide range of engineering specialties: vibrations, fluid mechanics and aerodynamics, heat transfer, controls and signal processing, optimization, structures, and engineering statistics. In this part of the book, the vast majority of the solutions are presented as interactive graphics from which one can explore the results parametrically.

In Chapter 1, the basic syntax of Mathematica is introduced and it is shown how to intermingle symbolic and numerical calculations, how to use elementary mathematical functions and constants, and how to create and manipulate complex numbers. Several notational programming constructs are both illustrated and tabulated and examples are given on how to attach physical units to numerical and symbolic quantities. The basic structure of the notebook interface and its customization are presented. In addition, the various templates that can be used to simplify the integration of Greek letters, superscripts and subscripts, and other mathematical symbols into the programming process, and the commands that represent many basic mathematical functions and mathematical constants are illustrated.

In Chapter 2, the commands that can be used to create lists are discussed in detail and their special construction to form vectors and matrices composed of numerical and/or symbolic elements that are commonly employed to obtain solutions engineering applications are introduced. The use of vectors and matrices is discussed in two distinctly different types of applications: to perform operations on an element-by-element basis or to use them as entities in linear algebra operations.

In Chapter 3, ways to create functions, exercise program control, and perform repetitive operations are discussed. The concept of local and global variables is introduced and its implications with respect to programming are illustrated.

In Chapter 4, two types of symbolic manipulations are illustrated. The first is the simplification and manipulation of symbolic expressions to attain a compact form of the result. The second is to perform a mathematical operation on a symbolic expression. The mathematical operations considered are: differentiation, integration, limit, solutions to ordinary and partial differential equations, power series expansion, and the Laplace transform.

In Chapter 5, several Mathematica functions that have a wide range of uses in obtaining numerical solutions to engineering applications are presented: integration, solution to linear and nonlinear ordinary and partial differential equations, solution of equations, determination of the roots of transcendental equations, determining the minimum or maximum of a function, fitting curves and functions to data, and obtaining the discrete Fourier transform.

In Chapter 6, a broad range of 2D and 3D plotting functions are introduced and illustrated using numerous tables and examples from engineering topics. It is shown how to display discrete data values and values obtained from analytical expressions in different ways; that is, by displaying them using logarithmic compression, in polar coordinates, as contours, or as surfaces. The emphasis is on the ways that the basic figure can be modified, enhanced, and individualized to improve its visual impact by using color, inset figures and text, figure titles, axes labels, curve labels, legends, combining figures, filled plot regions, and tooltips.

In Chapter 7, the creation and implementation of interactive graphics and animations are introduced and discussed in detail and illustrated with many examples. The control devices that are considered are the slider/animator, slider, 2D sliders, radio buttons, setter buttons, popup menus, locators, angular gauges, and horizontal gauges.

In Chapter 8, the response of single and two degree-of-freedom systems and thin elastic beams are determined when they are subject to various loadings, damping, initial conditions, boundary conditions, and nonlinearities.

In Chapter 9, the commands used to determine the mean, median, root mean square, variance, and quartile of discrete data are presented and the display of these data using histograms and whisker plots are illustrated. It is shown how to display the results from a regression analysis using a probability plot, a plot of the residuals, and confidence bands. The ways to perform an analysis of variance (ANOVA) and to setup and analyze factorial designs are introduced with examples.

In Chapter 10, the modeling and analysis of control systems using transfer function models and state-space models are presented. It is shown how to connect system components to form closed-loop systems and to determine their time-domain response. Examples are given to show how to optimize a system’s response with a PID controller and any of its special cases using different criteria. The creation and use of different models of high-pass, low-pass, band-pass, and band-stop filters are presented and the effects of different types of windows on the short-time Fourier transform are illustrated. The spectral analyses of sinusoidal signals in the presence of noise are presented using root mean square averaging and using vector averaging.

In Chapter 11, several topics in heat transfer and fluid mechanics are examined numerically and interactive environments are developed to explore the characteristics of the different systems. The general topic areas include: conduction, convection, and radiation heat transfer, and internal and external flows.

Edward B. Magrab

Bethesda, MD USA October, 2013

#### Table of Engineering Applications

Topic

Example or Section

Controls

State-Space Models

Section 10.2.2

Transfer Function Models

Section 10.2.3

Model Connections – Closed-Loop Systems and System Response

Section 10.3

PID Control System

Example 10.1

Root Locus

Section 10.4.1

Bode Plot

Section 10.4.2

Nichols Plot

Section 10.4.3

Engineering Mathematics

Evaluating a Fourier Series

Example 2.1

Convergence of a Series

Example 2.2

Summing a Double Series

Example 2.3

Solution of a System of Equations

Example 2.4

Secant Method

Example 3.14

Solution of a System of Equations

Example 4.2

Example 4.10

Euler–Lagrange Equation

Example 4.11

Fourier Coefficients

Example 4.13

Cauchy Integral Formula

Example 4.18

System of First-Order Equations and the Matrix Exponential

Example 4.23

Laplace Transform Solution of an Inhomogeneous Differential Equation #1

Example 4.29

Laplace Transform Solution of an Inhomogeneous Differential Equation #2

Example 4.31

Limit Using

Assumptions

Example 4.4

Perturbation Solution #1

Example 4.7

Perturbation Solution #2

Example 4.8

Poincare Plot

Example 5.11

Nonlinear Ordinary Differential Equation

Example 5.12

Second-Order Differential Equation: Periodic Inhomogeneous Term

Example 5.15

Interpolation Function from Some Data

Example 5.24

Function’s Parameters for a Fit to Some Data

Example 5.25

Parametric Solution to a Nonlinear Differential Equation

Example 5.26

Fluid Mechanics

Flow Around a Cylinder

Example 6.6

Air Entrainment by Liquid Jets

Example 5.14

Flow Around an Ellipse

Example 7.6

Laminar Flow in Horizontal Cylindrical Pipes

Section 11.5.1

Flow in Three Reservoirs

Section 11.5.2

Pressure Coefficient of a Joukowski Airfoil

Section 11.6.1

Surface Profile in Nonuniform Flow in Open Channels

Section 11.6.2

Heat Transfer

Heat Conduction in a Slab

Example 5.13

One-Dimensional Transient Heat Diffusion in Solids

Section 11.2.1

Heat Transfer in Concentric Spheres: Ablation of a Tumor

Section 11.2.2

Heat Flow Through Fins

Section 11.2.3

Natural Convection Along Heated Plates

Section 11.3

View Factor Between Two Parallel Rectangular Surfaces

Section 11.4

Kinematics

Example 7.7

Signal Processing

Spectral Analysis of a Sine Wave

Example 5.27

Spectral Analysis of a Sine Wave of Finite Duration

Example 5.28

Cross-Correlation of a Signal with Noise

Example 5.29

Sum of Two Sinusoidal Signals

Example 7.2

Example 7.3

Effects of Filters on Sinusoidal Signals

Example 10.2

Effects of Windows on Spectral Analysis

Example 10.3

Spectrum Averaging

Example 10.4

Aliasing

Example 10.5

Statistics

Histograms

Example 9.1

Whisker Plot

Section 9.1.5

Confidence Intervals

Section 9.2.4

Hypothesis Testing

Section 9.2.5

Simple Linear Regression

Section 9.3.1

Multiple Linear Regression

Section 9.3.2

Nonlinear Regression Analysis

Section 9.4

Two-Factor ANOVA

Example 9.2

Four-Factor Factorial Analysis

Example 9.3

Structures

Analysis of Beams

Example 4.20

Deformation of a Timoshenko Beam

Example 4.21

Example 5.4

Beam with an Overhang

Example 5.5

Beam with Abrupt Change in Properties

Example 5.6

Deflection of a Uniformly Loaded Solid Circular Plate

Example 5.16

von Mises Stress in a Stretched Plate with a Hole

Example 7.4

Analysis of Beams

Example 7.5

Vibrations

Natural Frequencies of a Three Degrees-of-Freedom System

Example 2.5

Natural Frequency Coefficient of a Two Degrees-of-Freedom System

Example 3.5

Natural Frequencies of Beams

Example 4.5

Peak Amplitude Response of a Single Degree-of-Freedom System

Example 4.9

Response of a Two Degrees-of-Freedom System

Example 4.30

Two Degrees-of-Freedom System Revisited

Example 5.7

Particle Impact Damper

Example 5.8

Change in Period of a Nonlinear System

Example 5.9

Single Degree-of-Freedom System

Example 5.10

Natural Frequencies of a Beam Clamped at Both Ends

Example 5.20

Mode Shape of a Circular Membrane

Example 6.10

Periodic Force on a Single Degree-of-Freedom System

Section 8.2.1

Squeeze Film Damping and Viscous Fluid Damping

Section 8.2.2

Electrostatic Attraction

Section 8.2.3

Single Degree-of-Freedom System Energy Harvester

Section 8.2.4

Response to Harmonic Excitation: Amplitude Response Functions

Section 8.3.2

Enhanced Energy Harvester

Section 8.3.3

Natural Frequencies and Mode Shapes of a Cantilever Beam with In-Span Attachments

Section 8.4.1

Effects of Electrostatic Force on Natural Frequency and Stability of a Beam

Section 8.4.2

Response of a Cantilever Beam with an In-span Attachment to an Impulse Force

Section 8.4.3

#### 1.1 Introduction

Mathematica is a programming language that integrates, through its notebook interface, symbolic and numerical computations, visualization, documentation, and dynamic interactivity. It provides access to a large collection of such diverse and continually updated and expanded data sets as geometric shapes, a searchable dictionary, and individual country attributes. It also permits one to simultaneously program with different programming paradigms, such as procedural, functional, rule-based, and pattern-based. Its interface has a real-time input semantics evaluator that uses styling and coloring to provide immediate visual feedback on such coding aspects as function names, variable selection, and argument structures. Many of the Mathematica functions used for computation and visualization contain a fair amount of high-level automation so that the user has to interact minimally with their inner workings. If desired, many aspects of the automation procedures can be bypassed and specific choices can be selected.

In this book, we shall employ a subset of Mathematica’s library of functions and use them to obtain solutions to a variety of engineering applications. It will be found as one becomes more confident with Mathematica that it is most effectively used interactively. In later chapters, emphasis will be placed on displaying the results as dynamically interactive graphical displays so that real-time parametric investigations can be performed.

In this chapter, we shall introduce the fundamental syntax of Mathematica. In Chapters 2to 7, we shall introduce additional syntax and illustrate its usage. We start by stating that all variables by default are symbols and global in nature, and unless specifically restricted or cleared, are always available in all open notebooks until Mathematica is closed. Also, because Mathematica treats all variables initially as symbolic entities, any undefined symbol appearing in an expression (that is, any variable appearing on the right-hand side of an equal sign) is perfectly acceptable and will not produce an error message. However, depending on how the expression is used, subsequent operations may not perform as expected depending on the intent for this variable.

In addition to the functions that are an integral part of Mathematica, each version of Mathematica comes with what are called standard extra packages that provide specific additional functionality. Frequently, the capabilities of these packages become an integral part of Mathematica. What the names of these packages are and a brief description of what they do can be obtained by entering Standard Extra Packages into the search area of the Documentation Center Window, which is found in the Help menu. Each package is loaded by using the Needs function. One such case is illustrated in Example 4.11.

#### 1.2 Selecting Notebook Characteristics

Interaction with Mathematica occurs through its notebook interface. As we shall be concerned primarily with presenting graphically solutions to engineering analyses, our discussion will be directed to one type of use of the notebook: entering, manipulating, and numerically evaluating equations typically encountered in engineering.

Upon opening Mathematica, the window shown in Figure 1.1 appears on the computer screen. Since virtually all types of mathematical symbols can appear in Mathematica expressions, it is beneficial to also have its Special Characters palette open. As indicated in Figure 1.2, the letters and symbols are accessed by selecting Palettes from the Mathematica menu strip and then choosing Special Characters. These operations produce the windows shown in Figure 1.2.

Figure 1.1 Window appearing upon opening Mathematica

Figure 1.2 (a) Opening the Special Characters window to select various alphabet symbols; (b) Accessing various types of symbols; shown here are shapes that can be used as plot markers

To increase or decrease the font size of the characters displayed in the notebook, Window from the Mathematica menu strip is selected, then Magnification is chosen, and the amount of magnification (or reduction) is clicked. These operations are illustrated in Figure 1.3. As shall be discussed in what follows, various types of expression delimiters are used in constructing expressions: parentheses, brackets, and braces. When nested expressions are employed and various combinations of these delimiters are used, one frequently needs to verify that these delimiters are grouped as intended. A tool that performs this check by highlighting the region that appears between the delimiter selected and its closing delimiter is accessed from the Edit menu and then by clicking on Check Balance, as shown in Figure 1.4. In Mathematica 9, the placement of the cursor adjacent to either an opening or closing delimiter will highlight them in green. This is a very valuable editing tool; however, it can be disabled by going to Preferences in the Mathematica menu strip, selecting Interface, and then deselecting Enable dynamic highlighting. Just below Check Balance is another useful tool: Un/Comment Selection. This feature comments out text highlighted or removes the comment symbols if the selected text had been commented out. The commenting is produced by the system by placing the highlighted text between the asterisks of the set (*…*). (See also Table 1.2.)

Table 1.1 Selected topical search entries for the Documentation Center

Topic

Search Entry

Trigonometric and inverse trigonometric functions

guide/TrigonometricFunctions

Hyperbolic and inverse hyperbolic functions

guide/HyperbolicFunctions

Special functions

guide/SpecialFunctions

Statistics

guide/DescriptiveStatistics guide/FunctionsUsedInStatistics

Minimum, maximum, optimization, curve fitting, least squares

guide/Optimization

Differentiation and integration

guide/Calculus tutorial/Differentiation tutorial/Integration

Differential equations, roots of polynomials, and roots of transcendental functions

guide/DifferentialEquations guide/EquationSolving tutorial/SolvingEquations tutorial/DSolveOverview

Matrices, vectors, and linear algebra

guide/MatricesAndLinearAlgebra

Fourier and Laplace transforms

guide/IntegralTransforms

Interactive graphical output

Manipulate guide/DynamicVisualization tutorial/IntroductionToManipulate

Lists

guide/ListManipulation

Plotting: 2D and 3D

guide/VisualizationAndGraphicsOverview guide/FunctionVisualization guide/DataVisualization guide/DynamicVisualization guide/PlottingOptions guide/Legends guide/Gauges

Listing of all Mathematica functions

guide/AlphabeticalListing (or click on the

Index of Functions

label at the bottom left of the

Documentation Center

window)

Mathematica’s syntax

guide/Syntax

Function creation

tutorial/DefiningFunctions

Program debugging and speed

guide/TuningAndDebugging

Manipulation of symbolic expressions

tutorial/PuttingExpressionsIntoDifferentForms

Controls

guide/ControlSystems

Signal processing

guide/SignalProcessing

Units and units conversion

tutorial/UnitsOverview

Export graphics

tutorial/ExportingGraphicsAndSounds

Table 1.2 Special characters and their usage

Figure 1.3 Setting the notebook font size

Figure 1.4 Selecting Check Balance for implementation of delimiter region identification for (…), […], and {…}

Since Mathematica has such a large selection of functions to choose from and since the arguments and their individual form and purpose vary, one should keep the Documentation Center window and/or the Function Navigator window open for easy access to descriptions of these functions. The Documentation Center window is accessed by selecting Help from the Mathematica menu strip and then selecting Documentation Center. The Function Navigator is accessed either by selecting Function Navigator from this same menu or by selecting the fourth icon from the left at the top of the Documentation Center’s menu strip, which is labeled F[…]. Performing these operations, the windows shown in Figure 1.5 are obtained. Entering either the function name or several descriptive words in the Documentation Center search entry area will bring up the appropriate information. In the Function Navigator, one will see the candidate functions by selecting the appropriate topic. Using the search function in the Function Navigator is the same as using the search function in the Documentation Center window; that is, the results appear in the Documentation Center window.

Figure 1.5 (a) Documentation Center window and (b) Function Navigator window

After some proficiency has been attained with Mathematica, one can also access the types of functions available for certain tasks and what their arguments are from the Basic Math Assistant. The Basic Math Assistant is accessed from the Palettes menu as shown in Figure 1.6. Visiting the region labeled Basic Commands, one can find what arguments are required for many commonly used Mathematica functions. The functions are grouped into seven areas as indicated by the seven tabs. The two rightmost tabs refer to plotting commands. There are two other programming aids that have been added in Mathematica 9. They are the Next Computation Suggestions Bar and the Context-Sensitive Input Assistant; these are discussed in Section 1.3.

Figure 1.6 Opening the Basic Math Assistant window to access the 2D palette of plotting commands

The Documentation Center window also provides access to tutorials on various topics concerning the usage of classes of functions and also has a page that summarizes a collection of functions that can be applied to solve specific topics. Listed in Table 1.1 are selected search entries that can be used as a starting point in determining what is available in Mathematica for obtaining solutions to a particular topic or class of problems. In addition, entering tutorial/ VirtualBookOverview in the Documentation Center search box provides a table of contents to a “how to” introduction to the Mathematica language and contains a very large number of examples illustrating the options available for a specific function.

Lastly, the appearance of the code and the numerical results displayed in the notebook can be altered by selecting Preferences in the Edit menu. In the Preferences window, the Appearance tab is chosen and the appropriate tab is selected. For example, the default value of the number of decimal digits to be displayed is 6. To change this value, one goes to the Numbers tab and then to the Formatting tab. In the box associated with Displayed precision, the desired integer value it entered.

#### Creating New Notebooks or Opening Existing Notebooks

To create a new notebook, one clicks on File on the Mathematica menu strip and selects New and then Notebook. A new notebook window will appear. To open an existing notebook, one clicks on File on the Mathematica menu strip and selects Open or Open Recent. Selecting Open will bring up a file directory window, whereas Open Recent will bring up a short list of the most recently used notebooks.

#### Saving Notebooks

To save a notebook that was created during a Mathematica session, one clicks on File on the Mathematica menu strip and selects Save As…. This brings up a file directory from which an appropriate directory is selected and a notebook name is entered. This procedure is also used for renaming an existing notebook. For an existing notebook that has been modified and the existing notebook name is to remain the same, one clicks on File on the Mathematica menu strip and selects Save.

#### 1.3 Notebook Cells

To execute an expression or a series of expressions, one has two ways to do it. To execute each expression separately, one types the expression and then simultaneously depresses Shiftand Enter. The system response appears directly below. When one wants to execute a series of expressions after all the expressions have been entered, each expression is typed on a separate line and after each expression has been typed it is followed by Enter. When the collection of expressions is to be executed, the last expression entered is followed by simultaneously depressing Shift and Enter. Each expression in this group of expressions is executed in the order that they appear and the results from each expression (if not followed by a semicolon) appear directly after the last expression entered.

In the first case, the single expression constitutes an individual cell and is so indicated by a closing bracket that appears at the rightmost edge of the notebook window. The system response also appears in its own cell. However, these two individual cells are part of another cell that is composed of these two individual cells. This is illustrated in Figure 1.7a. In the process of obtaining these cells, Mathematica provided two programming aids automatically. The first is the Context-Sensitive Input Assistant, which appeared after the first two letters of Sin were typed. As shown in Figure 1.7b, a short list of common Mathematica commands appears that can be expanded to all appropriate Mathematica commands that begin with Si by clicking on the double downward facing arrows. Additional information regarding the Context-Sensitive Input Assistant can be found in the Documentation Center using the entry tutorial/UsingTheInputAssistant.

Figure 1.7 (a) Cell delimiters, which appear on the right-hand edge of the window and the Next Computation Suggestions Bar; (b) the Context-Sensitive Input Assistant, which appeared after the two letters Si were typed

Note: The Context-Sensitive Input Assistant can be disabled by selecting Preferences in the Mathematica menu. In the Preferences window, the Interface tab is chosen and then the check mark adjacent to Enable autocompletion with a popup … is removed.

After the execution of a line of code and the display of the result, there appears on a separate line a system-provided set of choices. This line is called the Next Computation Suggestions Bar. It can be suppressed for this calculation by clicking on the encircled × that appears at its right edge. The