I wanted to challenge ChatGPT to produce a complex interactive in order to prove that it is possible for teachers without much programming background to work with it as well.
The equation was generated by ChatGPT but looked like a normal sinusoidal function to me:
var y1 = Math.sin(2 * Math.PI * x / wavelength - 2 * Math.PI * time / period);
This is what the wonky graph looks like:
My suspicion is that Chart.JS makes use of points to form the curve so animating so many points at one go put too much demand on the app.
I then asked ChatGPT to suggest a different library. It then proceeded to make a new app with Plotly.JS, which works much better with moving graphs. This impressed me. I am learning so much with this new workflow. The final interactive graph can be found here:
I shall just share the prompts that were given after I realised that plotly.js is the way to go.
Prompts for the index page:
- Create a graph using plotly.js with a vertical axis for displacement of wave particles and a horizontal axis for distance moved by a wave. .
- Draw the curve of an infinitely long transverse wave moving along the horizontal axis.
- Create another infinitely long transverse wave of the same wavelength moving in the opposite direction along the same horizontal axis. Represent them in different colours.
- Use a slider to change the period of oscillation of both waves and another slider to change the wavelength of the waves.
- Each wave should have the same wavelength.
- Revised prompt: Keep the vertical axis fixed in height, equal to the maximum possible amplitude of the third wave.
- Revised prompt: Keeep the legend of the chart to the bottom so that the horizontal axis length is fixed at 640 pixels
Prompts for the second page:
- Have separate sliders for the amplitudes, periods and wavelengths of wave 1 and wave 2.
- Display the values of the sliders next to them.