Simulations

Dice Simulation to Teach Probability

A dice simulation is an excellent tool for teaching probability because it provides a hands-on, visual way for students to understand the concepts of probability through experimentation and observation.

In the simplest demonstration, students should be able to predict and observe that a fair six-sided dice gives equal probability of outcome and hence, almost equal total occurrences given a large-enough sample size.

Students can then be asked to predict the probability distribution if given two dice.

The good thing is that with simulations, students get to compare the experimental probabilities they calculated with the theoretical probabilities and discuss any discrepancies and reasons for them. This allows students to understand the concept of randomness and how experimental results may vary from theoretical expectations due to chance.

Click here to access the simulator and here to download it for SLS.

The prompts used for ChatGPT are as follow:

Provide the code for the following in a single html file:

  1. Create a 6-sided dice simulator where the user can click on the image of a dice, the dice image will change randomly and the final result will be shown on the image.
  2. The dice image will be represented by the file “dice1.png” for the number 1, “dice2.png” for number 2, “dice3.png” for number 3 and so on. The image size is 80 pixels by 80 pixels.
  3. The default setting shows one dice. The initial image shown is “dice1.png”.
  4. Create a button to cast the dice.
  5. Create a bar chart with 6 vertical columns at the bottom that shows the frequency of the numbers obtained by the dice. Adjust the bar chart to show all 6 possible outcomes.
  6. Each time the dice is cast and the result is shown, it is added to a list shown below the chart.
  7. Create a button for an option to toggle between the use of one dice or two die. When this button is clicked, the list of results and the bar chart is cleared. The initial images shown are both “dice1.png”. If two die are used, both die will be shown side by side.
  8. Both die will be cast when clicking on either dice. The bar chart now shows the frequency of the total of the numbers obtained by the die. Adjust the bar chart such that it now has 12 vertical columns show all 12 possible outcomes.
  9. The total number for each toss will be shown in the list.

Creating Learning Apps Using ChatGPT

Simulating an Oscillation

Despite learning some time ago that ChatGPT can help with coding, I had not had the chance to test it out. Since I had a pocket of time available to explore last week, I keyed in the following prompt:

“Create a simulation of an oscillating particle moving from left to right with simple harmonic motion with a slider to control the period of oscillation using javascript, html and css.”

I then cut and pasted the code in its entirety into a html file and this is the output:

https://physicslens.github.io/shm/

This is what it looks like, in case you do not want to click into the link above.

Of course, more work needs to be done to improve the usability but I believe some of that can be done using ChatGPT as well. A basic knowledge of the programming language will certainly help to refine the user interface or add new functions.

Extending the oscillation to include 100 particles each with a constant phase difference, we can simulate a wave :

https://physicslens.github.io/shm/oscillator3.html

Simluation of oscillation with variable period

For the second simulation, I used the following prompt:

“Create a simulation of particles moving horizontally with simple harmonic motion. The simulation should display 100 particles arranged vertically, each oscillating horizontally at a different phase. The horizontal motion of the particles should simulate simple harmonic motion, with their positions following a sine wave pattern. The amplitude of oscillation should be set to 100 pixels, and the period of oscillation should be controlled by a slider input with a range from 0.1 to 2 seconds. The particles should be confined within a container with a fixed width of 600 pixels and a height of 400 pixels. The slider input should be positioned at the bottom of the container. The simulation should update the positions of the particles at regular intervals to create the illusion of continuous motion.”

Flashcards

Next, I tried creating an webpage that allows students to practise recalling definitions of specific terms that are obtained from a csv file. This is the prompt I gave:

“Create a revision webpage using html, javascript and css that references a csv file in the same folder with three columns: “topic”, “term” and “definition”. There should be a filter for the “topic” field. Each term in the “term” field will be displayed in turn using a left and right button. Another button labelled “Definition” will be used to show or hide the corresponding “definition” field at the bottom. Put all the script and style codes in the html file.”

At first, the button to display the definitions did not appear as ChatGPT misunderstood my instructions.

After making some adjustments, this is the link to the functioning site:

https://physicslens.github.io/definitions/

and this is the refined html file:

All you have to do is to update the csv file with the topics, terms and definitions and ensure the index file is in the same folder as the data.csv file.

The best part for Singaporean teachers is, the zip file can be uploaded as a file into SLS and students can use it to test their recall of key terms.

Conclusion

The rise of generative AI is indeed creating new opportunities for learning, even for teachers. What used to require long hours of learning can now be condensed into a session with ChatGPT. We will still need to give very specific instructions which require some basic understanding of the product. At the same time, we need to be able to make tweaks here and there, but that should be easier since we have the basic structure of the product already.

Bouncing Ball Animation using Python

For a fullscreen view, visit https://www.glowscript.org/#/user/wboson2007/folder/MyPrograms/program/Bouncing

Modified this python simulation from Dr Darren Tan’s work at https://sciencesamurai.trinket.io/a-level-physics-programming#/collisions/bouncing-ball

Wanted to try out a different way of creating simulations. Added the acceleration-time graph in place of his energy-time graph, in preparation for the teaching of kinematics. Also assuming no energy loss during collisions for simplicity.

For Singapore teachers, I have submitted a request to SLS for this URL to be whitelisted for embedding. Once approved, glowscript simulations can be embedded as part of the lesson. For the time being, a URL link out to the simulation will have to do.

3D Virtual Experiment – Simple Pendulum

This is a simple virtual experiment with a 3D view, allow teachers to explain the simple concepts of an oscillation experiment, such as which view is best to measure timing of the oscillation from.

To access this simulation directly via GeoGebra, go to : https://www.geogebra.org/m/d3yxgjfp

To embed it in SLS or other platforms, use the following code:

<iframe scrolling="no" title="Pendulum" src="https://www.geogebra.org/material/iframe/id/d3yxgjfp/width/640/height/480/border/888888/sfsb/true/smb/false/stb/false/stbh/false/ai/false/asb/false/sri/false/rc/false/ld/false/sdz/true/ctl/false" width="640px" height="480px" style="border:0px;"> </iframe>

3D Virtual Experiment on Torsional Pendulum

In preparation for HBL in 2022, I designed a simple virtual experiment that will allow for students to collect data on oscillations using their own stopwatches and investigate the relationship between the period of oscillation and two separate variables. To access the simulation on GeoGebra, visit https://www.geogebra.org/m/jhc4xvpe.

Based on the given relationship $$T = cm^aL^b$$ where a, b and c are constants, students will be tasked to find the constants a, b and c. Students will then attempt to “linearise” the equation such that the independent variables m and L can be tested one by one.

Examples of data collected can be plotted using Excel to give the following graphs from which the gradients and vertical intercepts can be obtained instantly.

Hidden Circuits Interactive

I made this interactive tool using javascript for the teaching of DC circuits for integration with SLS as part of the IP4 Physics blended learning experience in the upcoming weeks.

The intention of this interactive is for students to do a preliminary inquiry activity to exercise what they learnt about series and parallel circuits. They can be tasked to draw out what they think the circuit diagram will be like, either on Nearpod or SLS.

Students can even notice the differences in brightness under different conditions. Questions can be designed around this as well.

Previously we used to construct little boxes with wires hidden underneath. However, due to wear and tear and with Covid-19’s safe management measures, a digital version that can be accessed via the students’ mobile devices is more suitable.

Light bulb image is adapted from Good Ware from www.flaticon.com
Switch image is adapted from Those Icons from www.flaticon.com

For a direct link to this interactive, please go to: https://www.physicslens.com/wp-content/uploads/2022/04/index.html (updated link)

To obtain the zip file for upload into SLS as an interactive media object, click here.