Preface
This tutorial contains software programs that are free: you can redistribute codes and/or modify scripts under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This tutorial is distributed in the hope that its material and codes will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. For full version of GNU General Public License, see https://www.gnu.org/licenses/gpl-3.0.en.html.
Universities usually offer two courses on differential equations: one is just an introductory course (which requires basic knowledge of calculus), and another one presents further exposition of differential equations, including an introduction to partial differential equations. These courses form a main mathematical background for all students majoring in engineering, physics, geology, economics, biology, and other areas. In our days, information technologies play a more and more significant role in modeling, therefore, we observe a trend in an intensive use of available software packages. This tutorial is a part of introductory websites that inform students who are taking differential equations courses of some applications of software packages that can be used. The tutorial accompanies the textbook Applied Differential Equations. The Primary Course by Vladimir Dobrushkin, CRC Press, 2022; https://www.routledge.com/Applied-Differential-Equations-The-Primary-Course/Dobrushkin/p/book/9781138606586
This tutorial is not a traditional course on differential equations that deals almost entirely with the derivation of formulas for solutions of various kinds of differential equations. In addition to understanding the topic, the tutorial tries to help the reader with recognizing a problem that involves differential equations and drawing conclusions from their solutions. Since in our days, the majority of traditional techniques used in a differential equation course can be dedicated to a computer, this tutorial combines these two features by retaining the intellectual values of classical methods with computational skills and focusing on conceptual understanding and interpretation of their results.
Therefore, the primary goal of this document is not only to explain the material in the text; rather, it is to give you the tools to solve problems and to present the capabilities of available software packages as they are needed by someone studying the text. This tutorial is designed for students who have absolutely no prior experience with computer algebra systems and programming, which reflects the pace, tone, and content of the material presented. Because there are many ways to solve physics problems, we present a variety of styles to illustrate different ways of solving similar problems using Mathematica. We emphasize that the solutions presented here are not necessarily the most efficient for dealing with all possible instances. While we do discuss writing efficient Mathematica code, we sometimes sacrifice the most elegant or efficient solution in favor of one that is most easily understood pedagogically. As a result, this tutorial will sometimes introduce several different ways to do the same thing. It is always good to be aware of these alternate pathways, but you are welcome to pick whatever notation you like the best.
A solution of a realistic problem is often hampered because the algebra is too complex for anyone but the dedicated researcher. Just as the calculator eliminated laborious numerical computations, symbolic software programs eliminate arduous algebraic computations. While computer power is no substitute for thinking, it spares the scientist from performing mundane mathematical steps, and thereby frees time for creative thinking. This tutorial can be used to introduce students who are taking the first course in differential equations (at Brown University, it is APMA 0330, Methods of Applied Mathematics - I) to a symbolic mathematical computation program, Mathematica, that was conceived by a theoretical physicist Stephen Wolfram (born in 1959 in London, England) in late 1980's.
Mathematica is a great computer algebra system to use, especially if you are in applied areas where it is necessary to solve differential equations and other complicated problems. It was created by a brilliant entrepreneur, who was inspired by Maxima, the first computer algebra system in the world, and produced an elegant, coherent, and extremely general approach to computing. Mathematica provides friendly tools to solve and plot solutions to differential equations, but it is certainly not a panacea of all problems. This computer algebra system has tremendous plotting capabilities. There is a free version of Mathematica featuring its syntax and functions---Mathics that was developed by a team led by Jan Pöschko. It is backed by the highly extensible Python code, relying on SymPy for most mathematical tasks. Mathics is released under the GNU General Public License (GPL). This tutorial contains many Mathematica scripts. You, as the user, are free to use all codes for your needs, and have the right to distribute this tutorial and refer to this tutorial as long as it is accredited appropriately. Any comments and/or contributions for this tutorial are welcome; you can send your remarks to <Vladimir_Dobrushkin@brown.edu>
Return to computing page for the second course APMA0340
Return to computing page for the fourth course APMA0360
Return to Mathematica tutorial for the second course APMA0340
Return to Mathematica tutorial for the fourth course APMA0360
Return to the main page for the course APMA0330
Return to the main page for the course APMA0340
Return to the main page for the course APMA0360
Glossary
Stephen Wolfram | Jan Pöschko |
Introduction to ODEs
The attempt to solve physical problems led gradually to mathematical models involving an equation in which a function and its derivatives play important roles. However, the theoretical development of this new branch of mathematics---Ordinary Differential Equations---has its origins rooted in a small number of mathematical problems. These problems and their solutions led to an independent discipline with the solution of such equations an end in itself.
According to some historians of mathematics, the study of differential equations began in 1675, when Gottfried Wilhelm von Leibniz (1646--1716) wrote the equation:
Only in special cases can a particular differential equation be integrable in a finite form, i.e., be finitely expressed in terms of known functions. In the general case one must depend upon solutions expressed in infinite series in which the coefficients are determined by recurrence-formulae.
Introduction to Mathematica
Mathematica is based on its own programming language, called Wolfram language. Unlike other programming languages, the philosophy of the Wolfram Language is to build as much knowledge about algorithms and about the world into the language as possible. There is nothing that can be done in Mathematica and absolutely can not be done in other programming environments. For many problems however, especially those involving symbolic programming, solving a problem in a language such as C or C++ will be eventually equivalent to re-implementing a subset of Mathematica (or other system for symbolic manipulations) needed to solve the problem. The point is that many things are done in Mathematica with less or a lot less effort and time, because a lot of both generic and specific functionality is already built in Mathematica. And because it is so general, this statement is expected to be true for almost any field where some computations, prototype or program design and development, simulations etc are used.
Here are 10 good reasons (according to Leonid Shifrin ) to use Mathematica:
- Multiparadigm language: the richness of the language allows to pick for any problem a programming paradigm or style which corresponds to it most directly. You spend most of the time thinking about the problem rather than implementation. The very high level of the language means that a lot of work is done for you by the system.
- Interactivity. Mathematica is an interpreted language, which allows interactive and incremental program development. The Mathematica front-end adds another layer of interactivity, being able to display various forms of input and output (and this can be controlled programmatically).
- Programming in the large. The typically small size and high level of abstraction of the code allows a single person to manage substantial projects. There is also a built-in support for large projects through the system of packages.
- Built-ins. Availability of thousands of built-in functions makes it possible to do sophisticated analysis very quickly. Extended error message system (each built-in function can issue a lot of error messages on improper inputs) greatly simplifies debugging.
- Generality, higher-order functions and tight system integration. The very general principles of Mathematica, its uniform expression structure, generic nature of many built-in functions, and tight integration of all components allows to use all other built-in functions much easier than one would use libraries in other languages. The Help system is also uniform and it is immediate to learn the functionality of any built-in function that you have never used before.
- Visualizations. Great dynamic and visualization capabilities.
- Cross-platform. The Mathematica code developed in one environment or OS will work in exactly the same way in all others where Mathematica is available.
- Connectivity: the developers keep increasing the number of file formats which Mathematica can understand and process. Also, tools like MathLink, J/Link, database connectivity etc. allow one to connect Mathematica to external programs.
- Backward compatibility: since the version 1 and the most recent developers are careful to maintain very high level of backwards compatibility. This means that one should not worry too much that solutions developed in the current version will need a rewrite to work on the future versions (apart from possible improvements related to availability of new built - in functions, if one is so inclined).
- Support for parallel and distributed computing.
Mathematica is split into two parts, the kernel and the front end. The kernel interprets expressions (Wolfram Language code) and actually does the computation and returns result expressions. The front end is the window where you type in your commands, which in turn is a part of notebooks. The front end, designed by Theodore Gray, provides a GUI, which allows the creation and editing of Notebook documents containing program code with pretty printing, formatted text together with results including typeset mathematics, graphics, GUI components, tables, and sounds. All contents and formatting can be generated algorithmically or interactively edited. Most standard word processing capabilities are supported. It includes a spell-checker but does not spell check automatically as you type.
Mathematica is launched by double-clicking on its icon or any other shortcut your computer system recognizes. Documents can be structured using a hierarchy of cells, which allow for outlining and sectioning of a document and support automatic numbering index creation. Documents can be presented in a slideshow environment for presentations. Notebooks and their contents are represented as Mathematica expressions that can be created, modified, or analyzed by Mathematica programs. This allows conversion to other formats.
Help on Mathematica commands is always available through the help browser. The browser provides
several ways to access the information. I usually select Documentation Center from the
help menu to find the topic I need (there is a search option in the Documentation Center). The help menu
has the following options:
Documentation Center
(gives access to the documentation in outline form),
Function Navigator
(allows you to type in the name of a function and get its documentation), and many others.
Mathematica notebooks can be converted to many other formats, such as HTML and PDF. To do this, open the notebook in Mathematica, choose File > Save As, and use the drop-down menu to view the various formats available. Conversions to other formats are also scriptable using the built-in Mathematica function Export.
Mathematica notebooks are structured interactive documents that can contain text, graphics, sound, calculations, typeset expressions, and user interface elements. Notebooks have the file extension .nb. Files of this type are automatically associated with Mathematica on systems in which Mathematica is installed. Mathematica notebooks contain only printable, 7-bit ASCII characters and are viewable and largely human-readable in any text editor. The notebook file format is a cross-platform format, meaning that a Mathematica installation on any supported platform can read and display a notebook that has been created by Mathematica on any other platform.
Eventually, you may wish to produce your own notebooks, perhaps when writing up solutions to homework. You can create a document like this one, with headings, subheadings, and text cells (in addition to input/output cells), using the Style option from the Format menu at the top. It may be preferable, in some cases, to initialize the entire notebook at the beginning. You can do this by going to the Evaluation menu and selecting Evaluate notebook. If this is how you want to initialize the kernel, then you should do it at the beginning of your session. The first time you save the document, go the File menu, select the Save As option, and then enter a file name ending in ".nb". For example, to create a text cell (like this one), click between cells (or after the last cell in your document), so that Mathematica is prepared to receive input. Then (using the mouse) go to the Format menu, click on Style, and then select Text from the list of options. Whatever you then type in the cell will be in text format.
0.1: Getting Started
0.2: Case Sensitivity
0.3: The Equals Signs
0.4: Complex Numbers
0.5: Simplify and Expand
0.6: Collect
0.7: Logical operators
0.8: Functions
0.9: Mathematica Commands
0.10: Solving Equations
0.11: Derivative
0.12: Existence
0.13: Uniqueness
0.14: Picard Iterations
0.15: Adomian Iterations
- Coddington, E.~A., and Levinson, N., Theory of Ordinary Differential Equation, McGraw--Hill Book Company, New York, 1955.
- Computational Class Notes.
- Enns Richard H. and McGuire, George C., Nonlinear Physics with Mathematica for Scientists and Engineers, Birhauser, Boston, 2001.
- Gockenbach, Mark S., Mathematica Tutorial to accompany the book, SIAM, 2010.
- Gray, A., Mezzino, M., and Pinsky, M., Introduction to Ordinary Differential Equations with Mathematica: An Integrated Multimedia Approach, Springer. ISBN-10: 0387944818 | ISBN-13: 978-0387944814
- Hastings, C., Mischo, K., Morrison, M., Hands-On Start to Wolfram Mathematica: And Programming with the Wolfram Language, 2016, Wolfram Media; 2nd. edition.
- Hunt, B.R., Lipsman, R.L., Osborn, J.E., Outing, D.A., Rosenberg, J., Differential Equations with Mathematica, 2009, Wiley; 3rd Edition. ISBN: 978-0-471-77316-0
- Ince, E.~L., Ordinary Differential Equations, Dover Publications, Inc., New York, 1964.
- Keskin, A.U., Ordinary Differential Equations for Engineers: with MATLAB Solutions, Springer; 1st ed. 2019.
- Leon, J.G.S., Mathematica Beyond Mathematics: The Wolfram Language in the Real World, 2017, Chapman and Hall/CRC.
- Lynch, S., Dynamical Systems with Applications Using Mathematica, 2017, Birkhäuser; 2nd ed.
- Nagy, G., Ordinary Differential Equations, Michigan State University, East Lansing, MI, 2019.
- Napolitano, J., A Mathematica Primer for Physicists, 2018, CRC Press.
- Romano, A. and Marasco, A., Classical Mechanics with Mathematica, 2018, Birkhäuser; 2nd ed.
- Shifrin, Leonid, Mathematica Programming: An Advanced Introduction, 2009
- Tam, P.T., A Physicist’s Guide to Mathematica, second edition, Elsevier, Boston, 2008.
- Wagon, Stan, Mathematica in Action, Springer, 2010.
- Wellin, P., Essentials of Programming in Mathematica, 2016, Cambridge University Press.
- Wolfram, S., An Elementary Introduction to the Wolfram Language, 2017, Wolfram Media; 2nd. edition.
- Zwillinger, D. and Dobrushkin, V., Handbook of Differential Equations, 4th edition, CRC Press, 2021.
Return to Mathematica page
Return to the main page (APMA0330)
Return to the Part 1 (Plotting)
Return to the Part 2 (First order ODEs)
Return to the Part 3 (Numerical Methods)
Return to the Part 4 (Second and Higher Order ODEs)
Return to the Part 5 (Series and Recurrences)
Return to the Part 6 (Laplace Transform)
Return to the Part 7 (Boundary Value Problems)