Basic physics course with MATLAB’s symbolic toolbox and live editor

The course offers a compact presentation of the basic content of classical mechanics, quantum mechanics, interaction and chaos theory. In 26 MATLAB Live scripts, the basic physical laws are presented, and examples are solved. Since it is assumed that the reader already has basic knowledge of physics and mathematics, a more modern view of physics, mathematics and calculation can be chosen. The dynamic laws, uniform throughout the course, stem from the concepts of invariance and continuity. Throughout the course, ground vectors and metric are used instead of basis vectors. The use of symbolic computer software enables more complicated problems, vivid graphics, and lots of animation. Students like it because they are play-like. Even students who major in mathematics, computer science and similar subjects have gained a good understanding of the basic physical principles.


Introduction
Basic courses usually start by looking at phenomena such as free fall of a body, the interaction between charges or the scattering of electrons by atoms. Based on this, the corresponding basic laws are developed for each area and applied in a variety of ways. Classic mechanics [1], electrodynamics [2] or quantum mechanics [3] are developed independently of each other. However, all areas have two basic principles in common: The basic laws must be invariant, they must not depend on the specific spatial-temporal references. And content such as mass, charge or the measurement probability of quantum mechanics must be preserved and subject to a continuity equation. It turns out that the fundamental basic laws of physics can be justified from this. Through the invariance requirement we arrive at the concept of action as a representation of the four-momentum independent of the reference system. With the concept of action, similarities and differences between classic mechanics and quantum mechanics can be clearly formulated. We also see that potential equations in electrodynamics can be understood as the continuity of the momentum gradients. It is worthwhile to use this to develop new ways of teaching the physical basics, while also incorporating modern methods of mathematics and scientific computing. This paper describes the course in more detail, while the course itself is available on a homepage of the University of Tübingen and on the 'MathWorks file Exchange'.

Motivation
In conventional standard courses, the students get all the basic knowledge and skills they need for physics. They learn so much that sometimes they get lost in detail and fail to see the essentials, missing out on context in the lectures. The purpose of the course described in this paper is to help with these problems. We work out the essentials, try to clarify the structure behind the laws of physics, and how the details are connected. Since it is assumed that the reader already possesses fundamental knowledge of physics and mathematics, a more modern view of physics, mathematics and computation can be taken.

Observer
In modern physics, the measurement plays a dominant part. In quantum mechanics, an electron or atom appears as a particle or wave, depending on how it is measured [3]. In special relativity, the length of a space or time interval depends on its motion relative to the observer [4]. Even Newton's laws can be understood as conditions for observability. A mass cannot change its motion without reason. If there were any arbitrariness involved, it would make no sense to measure this motion and there would be no way to predict anything. Newton introduced the concept of force as objective reason for the change of motion. It is worth mentioning that what we observe directly is the change of motion, not forces. There are conditions for observability, reproducibility, or any kind of knowledge of physical phenomena. The laws behind them should not depend on the specific observation, which means that they must be applicable at any place and time. They must be invariant of the context and nothing may just appear or disappear without objective reason. For matter, charge, probability, or even the change of motion, the continuity equation must hold.

Invariant Formulation
An invariant formulation of the physical laws is based on the length of vectors or their scalar products, since vectors themselves contain the arbitrariness of basis-directions and coordinates. Basic laws emerge directly from this requirement. So, the invariant speed of light implies four-vectors, and the invariance of their length implies the Lorentz-transformation. The invariant length of four-momentum introduces the concept of energy.

Action field
A third invariant expression arises as scalar product of four-space and four-momentum. This leads to the concept of action. This way, the action function becomes a transparent definition. It is the invariant field for considerations of phenomena in space and time. The momentum in a specific space direction is the change of action in this direction, the energy relates to change of time of action. The law of energy conservation can be expressed by the action function. This is a very short and clear way to the Hamilton-Jacobi equation. The concept of action can be viewed as the center of all physical laws. We get to classical mechanics by action on point particles, and to quantum mechanics by action on detectors. There we consider action quanta instead of objects. The action described by Plank's constant h is as fundamental in physics as the speed of light c. The laws of interaction evolve from the continuity equation for the gradients of the momentum components, where the latter is the gradient of the action function.

Mathematical description
Appropriate representations of vectors and their products are needed for the mathematical description of physics. We use ground vectors from the very beginning [5]. They are basis vectors, just not normalized. The normalization is in the metric, which is part of the vector products. Involving the metric is not the usual way, but it is not more difficult. It allows for systems with non-orthogonal coordinates and one gets used to covariant and contravariant vectors and their metrics. When it comes to general relativity the are already familiar.

Symbolic computer software
For the derivation of physical laws, we sometimes use symbolic computer software. This helps avoid long calculations, which distract from the actual physics. For exercises, we use symbolic and numeric computer software. This allows for more complicated problems, vivid graphics and a lot of animations. Students like it, as they are play-like and computers are their way to deal with all kinds of affairs. We apply MATLAB's Symbolic Math Toolbox in the Live Editor [6,7] as computer language. MATLAB itself offers powerful methods for diverse numerical problems and graphic representations. The laws of interaction evolve from the observation that movement is subject to change. The continuity of momentum gradients turns out to be a Laplace equation for the momentum. Through something like minimal coupling, we find the potential formulation of Maxwell's equations. We consider a Helmholtz coil, the field of an electric charge above a conducting sphere and the radiation of a Hertz dipole. With the equivalence principle of general relativity, we symbolically derive the Schwarzschild metric and consider black holes. Chaos theory deals with limits of calculations [9]. We introduce dissipative systems and Hamilton systems. Fractals, strange attractors and the question of integrability are discussed. Computational examples are the Lindenmayer systems for fractals, the Duffing oscillator and a Billiard.

Remarks to the course at the University of Tübingen
This course was developed and carried out over several years in the Department of Physics of the University of Tübingen. Participants are physics students after completion of the basic courses, i.e. after at least one and a half years of studying physics. They are in the Bachelor of Science or Bachelor of Education programs. The credits for the course can be used for an additional module in the bachelor's degree programs or for the specialization 'Scientific Computing'. Other participants study mathematics, computer science or similar subjects. They can use the credit points to obtain a minor in physics. During the course, we have a weekly session of 3 hours and the students get physical problems to solve with MATLAB at home. During the week, they can email me for help. Before our weekly meeting, they send me their solutions so that I can see them in advance. During the meeting, we discuss issues and creative ideas that students came up with while completing the assignment. Then, I explain the theory for the next chapter, and we prepare the new assignment together. For example, if there is a differential equation to be solved for the Kepler problem or the roll pendulum, then we solve the equations of motion for the anharmonic oscillator together. This approach has proven to be very powerful. After a short time, I get to know the participants quite well and I can choose the topics carefully according to their strengths and weaknesses.

Experiences with the participants
As a rule, there are 15-20 participants at the beginning. After the first two to three weeks, a few give up. The rest works very enthusiastically throughout the course. At the end of the course, we have a written exam in which participants must solve minor physical problems with MATLAB. For example, the oscillation of two coupled pendulums or the quantum mechanical bonding problem in a finite rectangular potential. By then, they can do that very well. In the specialization "Scientific Computing" and to obtain the minor in physics, oral examinations are carried out. It is good to see that even students who major in mathematics, computer science and other similar subjects also achieve a pretty good understanding of the basic physical principles.

Some notes on the course methods
Developing the basic physical laws around the conditions for observation is very convenient. All basic topics are treated in about 20 pages of theory In other courses I taught, it was always hard to explain the concept of action, especially when retired engineers or students from other departments participated. The participants were very interested to understand this concept, since it is, among other things, the basis for action quanta, the Plank constant and the Heisenberg uncertainty principle. They could not accept the usual definition of action as time integral over the Lagrange function or as generator of a particular transformation. The introduction of action as a fundamental invariant of physics, which makes it possible to treat dynamic problems without specifying a particular coordinate system, has satisfied them. To treat generalized coordinates, form the very beginning with the metric instead of normalized basis vectors turned out to be also very fruitful. The formalism is not more complicated than the usual procedure, but it has its advantages. It is much more general! And for example, the problems of classical mechanics become very systematic, especially when using symbolic computer software. After defining the coordinates, one can determine the Jacobian matrix and square it to get the metric. A simple symbolic inversion provides the contravariant metric. For me as teacher it is very satisfying to have a relatively small group of students, and to be able to see what they do and where they have problems. This differs greatly from the usual physics basic courses, in which the connection between lecturers and students is made very indirectly through assistants and tutors.

Some technical remarks
In this article, only a general description of the course can be given. To illustrate the nature of the material, a typical Live Editor script is shown in the appendix. The complete course is available on a server of the University of Tübingen. The hyperlinks can be found in the appendix. There are also other sources listed.
The calculational examples generate a variety of graphic animations. They can also be viewed via the hyperlinks in the appendix. The MATLAB scripts can be downloaded as PDF files or as MATLAB Live Editor scripts in mlx format. The mlx files can be run in MATLAB's Live Editor. The complete course is also available on 'MathWorks File Exchange'. Search for 'Kurt Braeuer' to download a zip-File with all Live Editor scripts (mlx).

Appendix
To get an impression of the course material, in Figure 1 is a Live Editor script with a sample calculation. It deals with quantization and questions of the relationship between quantum mechanics and classical g 