Smath for Physics
Total Page:16
File Type:pdf, Size:1020Kb
SMath for Physics A primer Bernard V Liengme St Francis Xavier University, Nova Scotia, Canada Morgan & Claypool Publishers Copyright © 2015 Morgan & Claypool Publishers 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, without the prior permission of the publisher, or as expressly permitted by law or under terms agreed with the appropriate rights organization. Multiple copying is permitted in accordance with the terms of licences issued by the Copyright Licensing Agency, the Copyright Clearance Centre and other reproduction rights organisations. Rights & Permissions To obtain permission to re-use copyrighted material from Morgan & Claypool Publishers, please contact [email protected]. ISBN 978-1-6270-5925-1 (ebook) ISBN 978-1-6270-5924-4 (print) ISBN 978-1-6270-5927-5 (mobi) DOI 10.1088/978-1-6270-5925-1 Version: 20150301 IOP Concise Physics ISSN 2053-2571 (online) ISSN 2054-7307 (print) A Morgan & Claypool publication as part of IOP Concise Physics Published by Morgan & Claypool Publishers, 40 Oak Drive, San Rafael, CA, 94903, USA IOP Publishing, Temple Circus, Temple Way, Bristol BS1 6HG, UK Contents Preface Acknowledgements Author biography 1 An overview of SMath Suite 1.1 What is SMath Suite? 1.2 How do I get SMath Suite? 1.3 How can I get help with SMath? 1.4 The SMath interface 1.5 Constructing regions 1.6 Greek characters 1.7 Option settings 1.8 Scratchpad calculations 1.9 Simple algebraic calculations 1.10 Subscripted variables 1.11 Working with units 1.12 Physical and mathematical constants 1.13 SMath functions 1.14 Matrices and vectors 1.15 Drawing graphs 1.16 Solving equations and finding roots 1.17 Symbolic differentiation 1.18 Programming 1.18.1 The If…Else structure 1.18.2 The For structure 1.18.3 The While structure 1.19 Snippets Appendix A. SMath functions 2 Introductory physics: some simple problems 2.1 Mass on a string 2.2 Kinetic energy of a merry-go-round 2.3 Telescope resolution 2.4 Dimensional analysis 2.5 Solving a cubic equation with polyroots 2.6 Conservation of energy 2.7 Stone dropped down a well (solve function) 2.8 Roller-coaster problem (function solve) 2.9 Bullet velocity 2.10 Water depth 2.11 Balmer series 2.12 Uncertainty calculation 2.13 Calculate the age of a rock 2.14 The ladder problem: search method 2.15 The ladder problem: solved with differentiation 2.16 Circuit analysis: matrix math 2.17 Thermistor quality control 2.18 Fourier series 2.19 Self-test projects 2.19.1 Centroid 2.19.2 Sound beats 2.19.3 Rigid structure analysis 2.19.4 Inflection points 2.19.5 Chart task References 3 Trajectory of a projectile 3.1 A simple calculation 3.2 An improved plot 3.3 Trajectory when drag is considered 3.4 Did we use a small enough Δt increment? 3.5 What is the purpose of the Eval function? References 4 Linear regression 4.1 Simple linear regression 4.2 Zero intercept 4.3 Multiple linear regression 4.4 Multiple linear regression using a vector function 4.5 Multiple regression: some exercises Reference 5 Root finding 5.1 Fixed point iteration 5.2 Bisection method 5.3 The secant method 5.4 Newton–Raphson method 5.5 Self-test 5.5.1 Find a root 5.5.2 False position method Reference 6 Numerical integration 6.1 Simpson’s ⅓ rule 6.2 Simpson’s ⅓ rule with tabular data 6.3 Numerical integration using a Monte Carlo method Reference 7 Solving differential equations 7.1 The Euler approximation 7.2 Runge–Kutta method 7.3 Cooling by radiation 7.4 Runge–Kutta for systems of equations 7.4.1 Using vector functions 7.5 Second-order differential equations References 8 The SMath Viewer 8.1 The basic steps 8.2 A better GUI 8.3 Working with units 8.4 Adding tabs Reference 9 Data exchange with external files 9.1 Wfile and rfile functions 9.1.1 Write and read a single variable 9.1.2 Write and read a vector 9.2 The importData(9) function 10 SMath with Maxima 10.1 Saving options 10.2 The XY plot feature 10.3 Maxima’s equation solving functions 10.3.1 Solve function 10.3.2 Bisection function 10.3.3 FindRoot function 10.4 Golden section search 10.5 Linear regression 10.6 Symbolic integration 10.7 Data exchange (wfile and rfile) 10.8 Data exchange with Microsoft Excel® 10.9 Differential equations 10.9.1 The rkfixed function; example 1 10.9.2 The rkfixed function; example 2 10.9.3 The Rkadapt function 10.9.4 The Rkadapt function with a system of equations 10.9.5 The ODE.2 function 10.10 Statistics Reference To our 10 wonderful grandchildren; may your futures be bright. Preface The target audience for this book is mainly physics students and their instructors. While not quite as powerful as Mathcad, upon which it is modeled, SMath can be of great use to the physics student at any level. And the price is right—it is free. Furthermore, there is a mobile version than can be run from a thumb drive. This is a boon to students wishing to use school computers on which they lack the permission needed to install software. More information is given in the Overview chapter. The professional physicist can often justify the expense of the excellent symbolic mathematics applications like Mathematica, Maple, MathLab and Mathcad. But funds may not be available to let every technician have a copy. Again SMath can fill the gap. The author has kept the physics in the book at a fairly low level so that readers can concentrate on understanding the SMath features. The reader is encouraged to work through the Overview and Simple Physics chapters to master the fundamentals. As with all software, you learn by doing. So please experiment. After that, one can jump about as interest dictates. The SMath website can be a source of great help and questions can be posted on its forum—registration is required but you will not be inundated with spam. The author is happy to answer by email questions than may arise as you work through the book. Bernard Liengme St Francis Xavier University, Nova Scotia, Canada [email protected] http://people.stfx.ca/bliengme Note on typography: to avoid the confusion that often arises with the use of quotation marks, these have been kept to a minimum. The names of functions and variables (and occasionally, new terminology) are shown in italic. To indicate what a user should type, or to draw attention to statements in figures showing SMath pages, you will see, for example: The statement converts the data in the Temp vector from °C to Kelvin. Acknowledgements The author thanks Andrey Ivashov (Андрей Ивашов) for his brilliant work in creating SMath Studio, and for the help he has given the author. Thanks also to Professors Martin Kraska (Brandenburg University of Applied Science) and Gilberto E Urroz (Utah State University) for their help with SMath. And great thanks to Pauline, my wife, for her encouragement and word skills. Author biography Bernard V Liengme Bernard V Liengme attended Imperial College London for his undergraduate and postgraduate degrees; he held post-doctoral fellowships at Carnegie-Mellon University and the University of British Columbia. He has conducted research in surface chemistry and the Mossbauer effect. He has been at St Francis Xavier University in Canada since 1968 as a Professor, Associate Dean and Registrar, as well as teaching chemistry and computer science. He currently lectures part-time on business information systems. Bernard is also the author of other successful books: COBOL by Command (1996), A Guide to Microsoft Excel for Scientists and Engineers (now in its 4th edition), A Guide to Microsoft Excel for Business and Management (now in its 2nd edition) and Modelling Physics with Microsoft Excel®. IOP Concise Physics SMath for Physics A primer Bernard V Liengme Chapter 1 An overview of SMath Suite Throughout the book reference is made to SMath files in the form [LinearRegress1.sm], generally at the start of a paragraph. All these files are available here. Files with names ending with M, M1, etc. are functional only when opened with SMath with Maxima. 1.1 What is SMath Suite? [Overview1.sm.] The developers of SMath Suite call it a mathematical program with paper-like interface and numerous computing features. SMath has many of the features found in the expensive application Mathcad but differs in that SMath is free. Some of its features are shown in figure 1.1. The SMath user interface resembles that of Mathcad. Figure 1.1. The SMath interface. Although the application is correctly called SMath Suite, it is normal to use just the word SMath. However, when doing an internet search always use the full name to avoid hitting sites dealing with an unrelated item. 1.2 How do I get SMath Suite? The website http://en.smath.info/ has downloadable files for a Windows and a Linus (Mono) installation. They are quite small: about 2 and 1 MB, respectively. The author has used SMath under Windows XP, 7 and 8.1. At the site http://smath.info/wiki/SMath%20with%20Plugins.ashx one can obtain a Windows portable version. Just download the 78 MB Zip file and expand it to a USB thumb drive. Now you can run SMath on any computer without having to do an installation.