MATHEMATICAL MODELING AND PROGRAMMING IN SCIENCE EDUCATION

Using mathematical models to represent aspects of physical reality is an essential activity in science and science education. This contribution discusses four approaches of using computer programming and mathematical models in classroom activities: 1. Mathematical models, found in the textbook, are used as a basis for computer programs. Students, when creating useful interactive python programs calculating concentrations or pH-values, experience similar intellectual challenges as in solving traditional text book problems. 2. Scratch-animations simulating physical or chemical systems simulation can be specifically designed to check the validity of given mathematical models. 3. A computer-related challenge is to design a simulation (like gas diffusion in a closed system with two phases) that might be a basis for discovering a mathematical model (like Henry’s law) or just an element of a mathematical model. 4. Using sensor technology and a Raspberry Pi, students create a computer program that automatically visualizes the observed system behaviour (like changes in gas concentrations) in order to find a mathematical model.


INTRODUCTION
Models of the physical reality that are taught in high school science lessons are represented by mathematical equations. Well known examples from physics are Einstein's equation E = m · c 2 representing the idea that energy can be transformed to matter and vice versaand E = h · f representing the dual model of light (discrete photons with energy E versus electromagnetic waves with a frequency f ).
There exist special digital tools for performing simulations and discovering and exploring models. They can be grouped in two types: • Open modelling tools like Insightmaker (https://insightmaker.com/) allow students to create dynamic models of physical systems and study their behaviour. • In virtual laboratories, students can simulate experiments that are too expensive, too time-consuming or too dangerous in reality [3].
Specialized digital tools have great potential for learning. However, they have certain limitations: • Students use highly specialized software-tools only seldom. Still they have to acquire technical knowledge to be able to handle the tool. And part of this knowledge is not transferable and not related to any educational goal. • A virtual laboratory is a surrogate for reality and hides the underlying mathematical models. Programming projects -using a general purpose programming language like Python or Scratch -are different from classroom activities with specialized digital tools: • They imply creating useful digital artifacts and have a stronger focus on engineering and designing than on researching. "Learning by creating" is the educational paradigm of "Constructionism" ( [1,2]). • The students need to develop general informatics competences before and during the project. This takes time and may require some "professional support" by a computer science teacher. However, the acquired computer-related knowledge is deeper and more general. "Computational thinking" is more and more considered as a competence that everybody should develop -not just professional programmers [6]. • Programming challenges can be designed in a way that mathematical modelling is specifically involved. This contribution discusses four approaches of integrating computer programming and mathematical modeling in science education: 1) Using mathematical models as a basis for simple interactive Python programs. 2) Developing animations simulating physical or chemical systems in order to check the validity of given mathematical models. 3) Designing computer simulations in order to discover mathematical models. 4) Creating computer programs that automatically visualize sensor data and support checking mathematical models.

APPLYING MATHEMATICAL MODELS TO CREATE COMPUTER PROGRAMS
High school science textbooks contain exercises that require algebraic transformations and calculation. The educational idea is to comprehend the mathematical models by applying them.
Example from a German Chemistry textbook [4]: Calculate the pH of these solutions: • Sodium hydroxide solution, c 0 (N aOH ) = 1 mol/L • Ammonia solution, c 0 (N H 3 ) = 0.2 mol/L The solution of this task requires these activities: • Find relevant mathematical models: p H = −l og 10 (c(H 3 O + )) and p H + pOH = 14.
• Do algebraic transformations and solve equations.
• Look up chemical constants (like pK B (N H 3 ))in a table.
• Use correct wording, in particular write correct units like mol/L for concentrations. In contrast to conventional pencil and paper textbook exercises, a programming task requires to develop a digital artifact, that is useful for other people. Example: Write a Python program that asks for the concentration of sodium hydroxide (N aOH ) in water and then calculates the pH of the solution. That implies basically the same activities as in finding the solution of a textbook problem, but they are now part of a design process. The programmer must create verbal system responses that are precise and well understandable and uses scientific vocabulary and units because they are essential, when asking for input data. Example "Input the concentration of NaOH in mol/L." For programming beginners, the first approach would be an interactive program, following an input-processing-output pattern. from math import log10 p r i n t ( " Enter the concentration of the NaOH s o l u t i o n . " ) x = input ( " c (NaOH) in mol / L : " ) p r i n t ( "pH" , round (pH, 1 ) ) Example dialog: Enter the concentration of the NaOH s o l u t i o n . c (NaOH) in mol / L : 0.2 pH 13.3 The program is so short that beginners can develop it from scratch. Line #2 matches the equation that a student needs to develop when solving the first word problem. The word problem implies calculations for one given concentration, whereas the program should be able to process all concentrations and calculate reasonable results. This makes the program more complex than the single case of a word problem and it requires a deeper elaboration of the chemistry model The statement in line #2 is reasonable under the assumption that N aOH dissociates completely to sodium ions N a + and hydroxide Ions OH − . Since in neutral water the concentration of hydroxide ions is only 10 −7 mol/L, in all solutions of practical relevance c(OH-) is approximately equal to c(N aOH ). However, the computer program must handle the case that the user inputs a lower concentration, may be even 0 mol/L. The statement in line #1 takes care of this. Here the programmer has used the knowledge that in neutral water pH equals pOH . The equation p H +pOH = 14 then implies that pOH = 7. Thus c(OH − ) = 10 −7 mol/L. In any solution of N aOH in water, the concentration of hydroxide ions may never be below this value. More experienced students may want to develop a version with a graphical user interface (GUI). The advantage is that is easier to use and that it looks more like a regular app in everyday life. Obviously, the following Python listing is more advanced. Note that the complete chemistryrelated calculation is within a single function definition starting at line #1. So, beginners could take a prototype program text that already implements the GUI and just code this function.

CHECKING MATHEMATICAL MODELS USING COMPUTER SIMULATIONS
In high school education, mathematical models are often just used for calculations, but not deduced from assumptions. A classic example from kinetics is the equation It specifies the location s of a uniformly accelerated object. This equation can be derived from the definition of acceleration a = d v d t by algebraic rearrangement and integration. Alternatively, it is possible to create a computer simulation, modelling a rocket or a free-falling stone. If position, speed, acceleration and elapsed time are documented one can compare the behaviour of the simulation with the mathematical model. Figure 1 depicts a Scratch project simulating a uniformly accelerated object. To avoid negative numbers, it is not a free-falling object driven by gravity but a rocket car moving from left to right.
The script reveals the modelling: The change of position during a time step d t is determined by speed (d s = v ·d t ) and the change of speed is determined by acceleration (d v = a ·d t ).
Command block 1 calculates the position that is expected according to the mathematical model (equation 1). During run time one can watch the readouts on top of the screen and compare the values. Obviously, the values are similar but not equal. The smaller the value of the time step d t the better the numerical approximation. In a real physical experiment [5], the mathematical model can be verified just by observing a real falling object measuring distances and time intervals. Note the difference: In this approach the model is considered as a black box model. It describes the behaviour but does not explain it. Real experiments for checking mathematical models can be dull and time consuming. For example, the Beer-Lambert law is the According to the Beer-Lambert Law, the absorbance of a dye solution is proportional to the concentration (mols per litre) and path length. The constant is the molar extinction coefficient, which is a physical property of the analyte and depends on the wavelength of the monochromatic light travelling through the solution The derivation of the Beer-Lambert Law requires knowledge of the calculus that high school students (in Germany) usually do not have. Fig. 3 shows a screen shot from a simple Scratch simulation, illustrating that the absorbance is proportional to pathlength. The green spots on the background represent dye molecules in the solution. Red photons travel from left to right starting at random y-positions and leaving a red track. When a photon hits a molecule, it vanishes. The absorption events are counted. The two readouts on top show the number of photons, which have been absorbed in the first half and the number of photons, which have been absorbed, in the second half. From these numbers the light intensities I0 (initial intensity), I1 (intensity in the middle) and I2 (intensity after the solution) are calculated. It may seem plausible that the absorbency of light is proportional to the pathlength. But it might be disturbing that the logarithm is used to calculate the absorbance. The simulation is not an analytical proof that the Beer-Lambert Law is correct. But it demonstrates that it is a logical consequence of the assumptions we have made in the design of the model.

CREATING A COMPUTER SIMULATION IN ORDER TO FIND A MATHEMATICAL MODEL
It is very hard and time consuming to discover quantitative scientific laws and create a mathematical model. People can only be creative in a domain they know well. If students are experienced in Scratch programming, they can use this knowledge to design a simulation that might be a basis for a mathematical model. Task: Consider a closed system with two phases -fluid and gas -like a bottle of mineral water. The water (phase 1) contains solved carbon dioxide as well as the air (phase 2) on top. The carbon dioxide molecules move, when they hit the interface between the two phases, they just change to the other phase, from water to air and vice versa. Assumptions: 1) The CO 2 molecules move with a constant speed on straight trajectories. 2) CO 2 molecules move slower in the water than in the air, since they hit water molecules all the time (the water molecules are invisible).
Challenge: 1) Create the Scratch model. 2) Observe the Scratch model with different numbers of molecules and write a hypothesis (equation). 3) Try to verify the hypothesis using the Scratch model. Fig. 4 shows a possible implementation with Scratch using clones and message passing. The first script generates several clones. The second scripts defines the motion of each clone (molecule). When a molecule is in the water phase (dark blue area at the bottom), it moves slower than in the gas phase (light blue area on top).
(4) If the volume is constant, the concentration is proportional to the number of molecules. In the background, a script (connected to the stage) is running sending a message to all molecule-clones every four seconds. When a molecule-clone receives the message, it checks its position and increments a global variable. Thus, we have the numbers of molecules in both phases (variables displayed in the upper left corner of the screen). On the screen shot in fig. 4 the third readout on screen displays the quotient of the numbers of "CO 2 -molecules" in both "phases" this way checking Henry's Law. Note that this Scratch program is not just a simulation. Additional to representing objects of the physical world it includes specifically designed features for "measuring" and checking mathematical models.

VISUALIZING SENSOR DATA
In the previous section we discussed the evaluation of computer simulations, which were based on simple assumptions like the the behaviour of gas molecules. mathematical models (like Henry's Law) that are found by checking simulations are basically not more than logical deductions from the model the simulation is based upon. This section discusses the automatized evaluation of empirical data, gained by observing real experiments. The Raspberry Pi supports experimenting with all kinds of sensors (luminosity, temperature,ethanol, methane, carbon dioxide etc.). Fig. 5 shows an NDIR (non-dispersive infrared) carbon dioxide sensor, connected via SPI (serial peripheral interface) to a Raspberry Pi. It is not very difficult to create a Python program that reads the sensor data and collects them in a list. The list of numbers can easily be plotted using the Python module MathPlotLib. A simple experiment with this sensor is the observation of gas diffusion. The NDIR-sensor is a tube with holes allowing gas molecules to enter and to leave.
Inside the tube the CO 2 -concentration is measured by detecting the absorbance of infrared radiation. When a person breathes against the sensor, the CO 2 -concentration increases, because more CO 2 gets into the tube through the holes. After a few seconds it decreases again, because the gas molecules move (diffusion) and leave the tube through the holes.  Fig. 6 shows the output of a Python program that semi-automatically conducts the diffusion experiment, collects the sensor data and creates a plot (using MatPLotLib). A further challenge is to formulate a mathematical model for the change of the concentration of CO 2 in the tube, write Python code to calculate a list of numbers, create a plot visualizing this list (using MatPlotLib) and compare it with the plot based on empirical data.

CONCLUSION
Programming projects can be an enrichment of science classes. They offer many different ways to elaborate, check or even develop mathematical models of the physical world. This diversity makes it possible that even those students that are not primarily interested in math can find motivation to learn theoretical content. Since a programming project can be open and lead to different products, learning is more individual. An open question is, to what extend students can develop programming competence on their own (without teacher's help) during projects in regular sciences classes. Physics, chemistry and biology teacher are not necessarily programming experts. One type of support are media (movies, tutorials, skill cards), specifically designed for science-related projects.