Symbolic Mathematics for Chemists
Total Page:16
File Type:pdf, Size:1020Kb
Symbolic Mathematics for Chemists Symbolic Mathematics for Chemists A Guide for Maxima Users Fred Senese Frostburg State University MD, USA This edition first published 2019 © 2019 John Wiley & Sons Ltd 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 law. Advice on how to obtain permission to reuse material from this title is available at http://www.wiley.com/go/permissions. The right of Fred Senese to be identified as the author of this work has been asserted in accordance with law. Registered Offices John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, USA John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, UK Editorial Office The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, UK For details of our global editorial offices, customer services, and more information about Wiley products visit us at www.wiley.com. Wiley also publishes its books in a variety of electronic formats and by print-on-demand. Some content that appears in standard print versions of this book may not be available in other formats. Limit of Liability/Disclaimer of Warranty In view of ongoing research, equipment modifications, changes in governmental regulations, and the constant flow of information relating to the use of experimental reagents, equipment, and devices, the reader is urged to review and evaluate the information provided in the package insert or instructions for each chemical, piece of equipment, reagent, or device for, among other things, any changes in the instructions or indication of usage and for added warnings and precautions. While the publisher and authors have used their best efforts in preparing this work, they make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives, written sales materials or promotional statements for this work. The fact that an organization, website, or product is referred to in this work as a citation and/or potential source of further information does not mean that the publisher and authors endorse the information or services the organization, website, or product may provide or recommendations it may make. This work is sold with the understanding that the publisher is not engaged in rendering professional services. The advice and strategies contained herein may not be suitable for your situation. You should consult with a specialist where appropriate. Further, readers should be aware that websites listed in this work may have changed or disappeared between when this work was written and when it is read. Neither the publisher nor authors shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages. Library of Congress Cataloging-in-Publication Data Names: Senese, Fred, author. Title: Symbolic mathematics for chemists : a guide for Maxima users / Fred Senese. Description: Hoboken, NJ : John Wiley & Sons, 2019. | Includes bibliographical references and index. | Identifiers: LCCN 2018024356 (print) | LCCN 2018033308 (ebook) | ISBN 9781119273233 (Adobe PDF) | ISBN 9781119273264 (ePub) | ISBN 9781118798690 (pbk.) Subjects: LCSH: Chemistry–Mathematics. | Logic, Symbolic and mathematical–Data processing. Classification: LCC QD39.3.M3 (ebook) | LCC QD39.3.M3 S46 2018 (print) | DDC 542/.8553–dc23 LC record available at https://lccn.loc.gov/2018024356 Cover design by Wiley Cover image: © Billion Photos/Shutterstock; @ leminuit/Getty Images Set in 10/12pt Warnock by SPi Global, Pondicherry, India 10987654321 To my dearest wife, Hazel, without whose tolerance, patience, support and love this book would not have been possible. vii Contents Preface xiii 1 Fundamentals 1 1.1 Getting Started With wxMaxima 1 1.1.1 Input Cells 2 1.1.2 The Toolbar 3 1.1.3 The Menus 3 1.1.4 Command History 4 1.1.5 Basic Arithmetic 5 1.1.6 Mathematical Functions 7 1.1.7 Assigning Variables 8 1.1.8 Defining Functions 10 1.1.9 Comments, Images, and Sectioning 12 1.2 A Tour of the General Math Pane 12 1.2.1 Basic Plotting 13 1.2.1.1 Plotting Multiple Curves 14 1.2.1.2 Parametric Plots 15 1.2.1.3 Discrete Plots 15 1.2.1.4 Three-Dimensional Plots 17 1.2.2 Basic Algebra 18 1.2.2.1 Equations 18 1.2.2.2 Substitutions 18 1.2.2.3 Simplification 20 1.2.2.4 Solving Equations 21 1.2.2.5 Simplifying Trigonometric and Exponential Functions 21 1.2.3 Basic Calculus 22 1.2.3.1 Limits 22 1.2.3.2 Differentiation 23 1.2.3.3 Series 24 1.2.3.4 Integration 25 1.2.4 Differential Equations 28 1.3 Controlling Execution 28 1.4 Using Packages 30 2 Storing and Transforming Data 33 2.1 Numbers 33 2.1.1 Floating Point Numbers 33 viii Contents 2.1.2 Integers and Rational Numbers 37 2.1.3 Complex Numbers 38 2.1.4 Constants 42 2.1.5 Units and Physical Constants 43 2.2 Boolean Expressions and Predicates 47 2.2.1 Relational Operators 47 2.2.2 Logical Operators 48 2.2.3 Predicates 49 2.3 Lists 51 2.3.1 List Assignments 51 2.3.2 Indexing List Items 52 2.3.3 Arithmetic with Lists 52 2.3.4 Building and Editing Lists 54 2.3.4.1 Adding Items 54 2.3.4.2 Deleting Items 55 2.3.5 Nested Lists 55 2.3.6 Sublists 56 2.4 Matrices 57 2.4.1 Row and Column Vectors 57 2.4.2 Indexing Matrices 58 2.4.3 Entering Matrices 59 2.4.4 Assigning Matrices 60 2.4.5 Editing Matrices 61 2.4.6 Reading and Writing Matrices From Files 63 2.4.7 Transforming Data in a Matrix 65 2.5 Strings 66 2.5.1 Using String Functions to Work with Files 67 3 Plotting Data and Functions 71 3.1 Plotting in Two Dimensions 71 3.1.1 Changing Plot Size and Resolution 71 3.1.2 Plotting Multiple Curves 73 3.1.3 Changing Axis Ranges 74 3.1.4 Plotting Complex Functions 74 3.1.5 Plotting Data 74 3.1.5.1 Plotting Data in Separate X, Y Lists 75 3.1.5.2 Plotting Data as Lists of X, Y Points 75 3.1.5.3 Plotting Data in Matrices 76 3.1.5.4 Plotting Data with Units 76 3.1.5.5 Plotting Functions and Data Together 77 3.1.6 Adding Text Labels to Graphs 77 3.1.7 Plotting Rapidly Rising Functions 78 3.1.7.1 Solving Axis Scaling Problems 81 3.1.7.2 Positioning the Legend 83 3.1.8 Parametric Plots 84 3.1.9 Implicit Plots 87 3.1.10 Histograms 89 3.2 Plotting in Three Dimensions 91 3.2.1 Plotting Functions of x, y,andz91 Contents ix 3.2.2 Plotting Multiple Surfaces 93 3.2.3 Plotting in Spherical Coordinates 94 3.2.4 Plotting in Cylindrical Coordinates 95 3.2.5 Parametric Surface Plots 96 3.2.6 Plotting Discrete Three-Dimensional Data 98 3.2.7 Contour Plotting 99 4 Programming Maxima 103 4.1 Nouns and Verbs 103 4.2 Writing Multiline Functions 106 4.3 Decision Making 108 4.4 Recursive Functions 109 4.5 Contexts 110 4.6 Iteration 114 4.6.1 Indexed Loops 114 4.6.2 Conditional Loops 116 4.6.3 Looping Over Lists 117 4.6.4 Nested Loops 118 5 Algebra 119 5.1 Series 119 5.1.1 Simplifying Sums 120 5.1.2 Reindexing and Combining Sums 122 5.1.3 Applying Functions to Sums and Products 123 5.2 Products 124 5.3 Equations 126 5.3.1 Simplifying Equations 126 5.3.2 Simplifying Trigonometric and Exponential Functions 127 5.3.3 Extracting Expressions From an Equation 128 5.3.4 Expanding Expressions 131 5.3.5 Factoring Expressions 134 5.3.6 Substitution 135 5.3.7 Solving an Equation Symbolically 138 5.3.7.1 Handling Multiple Solutions 139 5.3.8 Solving an Equation Numerically 140 5.4 Systems of Equations 141 5.4.1 Eliminating Variables 141 5.4.2 Solving Systems of Equations Without Elimination 143 5.5 Interpolation 144 5.5.1 Piecewise Linear Interpolation 146 5.5.2 Spline Interpolation 147 6 Differentiation, Integration, and Minimization 149 6.1 Limits 149 6.1.1 Limits for Discontinuous Functions 151 6.1.2 Limits for Indefinite Functions 152 6.2 Differentials 153 6.3 Derivatives 154 6.3.1 Explicit Partial and Total Derivatives 156 x Contents 6.3.2 Derivatives Evaluated at a Specific Point 157 6.3.3 Higher-Order Derivatives 158 6.3.4 Mixed Derivatives 159 6.3.5 Assigning Partial Derivatives 160 6.3.5.1 Partial Derivatives from Total Differential Expansions 161 6.3.5.2 Writing Total Differential Expansions in Terms of New Variables 161 6.3.6 Implicit Differentiation 162 6.4 Maxima, Minima, and Inflection Points 164 6.4.1 Critical Points of Surfaces 167 6.4.2 Numerical Minimization 169 6.5 Integration 173 6.5.1 Integration Constants 174 6.5.2 Definite Integration 174 6.5.3 When Symbolic Integration Fails 175 6.5.4 Numerical Integration 178 6.5.4.1 Numerical Integration over Infinite Intervals 179 6.5.4.2 Numerical Integration with Strongly Oscillating Integrands 180 6.5.4.3 Numerical Integration with Discontinuous Integrands 181 6.5.5 Multiple Integration 182 6.5.6 Discrete Integration 183 6.6 Power Series 186 6.6.1 Testing Power Series for Convergence 186 6.7 Taylor Series 187 6.7.1 Exploring Function Properties with Taylor Series 188 6.7.2 The Remainder Term 190 6.7.3 Taylor Series for Multivariate Functions 191 6.7.4 Approximating Taylor Series 191 7MatricesandVectors193 7.1 Vectors 193 7.1.1 Vector Arithmetic 194 7.1.2 The Dot Product 195 7.1.3 Vector Lengths and Angles 196 7.1.4 The Cross Product 197 7.1.5 Angular Momentum 198 7.1.6 Vector Algebra 199 7.2 Matrices 200 7.2.1 Matrix Arithmetic 201 7.2.2 The Transpose 201 7.2.3 The Matrix Product 202 7.2.4 Determinants 203 7.2.5 The Inverse of a Matrix 206 7.2.6 Matrix