Graph plotting of 1-D motion in introductory physics education using scripts generated by ChatGPT 3.5

Introductory physics courses often necessitate students to graphically represent one-dimensional (1-D) motion and derive various physical parameters. Physical quantities are often solved by calculating either slope or the area under the graph. Instructors and students who do not have access to paid software must plot graphs by hand. This paper explores three introductory physics examples related to 1-D motion, and employs ChatGPT 3.5 to generate scripts that will produce graphs from raw data. It can generate scripts, based on accurate user inputs, in free programming languages like Python and/or GNU Octave to enable efficient graph plotting. Examples will be provided on calculating the slope of a distance–time graph and determining the area under a velocity–time graph. Given raw data, ChatGPT 3.5 may exhibit occasional inaccuracies when solving for physical parameters. However, user can communicate in English to modify the output. The author does not endorse the use of ChatGPT for academic misconducts such as assisting students to cheat in problem solving. Instead, ChatGPT is presented as a tool to enhance data visualisation for both instructors and students, which can potentially improve learning environments in introductory physics. This paper lays the groundwork for future initiatives, beyond the plotting of 1-D motion graphs, aiming to integrate artificial intelligence to assist more complex motion studies in physics learning environments.


Introduction
In physics, one-dimensional (1-D) motion refers to the movement of an object along one spatial dimension, typically represented by a single coordinate axis.In this context, the position of the object can be described by a single variable, usually denoted as x, which represents its location along the chosen axis.Time is usually represented by t.Therefore, (x, t) represents the position of an object at a particular time.1-D motion simplifies the analysis of certain physical phenomena, allowing for a straightforward examination of physical quantities such as distance, displacement, speed, velocity, and acceleration along a single direction.While real-world motion often involves multiple dimensions, the study of 1-D motion serves as a foundational concept in physics education and provides a basis for understanding more complex motion in two or three dimensions.
Students often study 1-D motion during the first few weeks of introductory undergraduate physics courses.They are usually tasked with data collection and graph plotting.They often have to analyze linear and second order polynomial plots.There exist software that can offer comprehensive graph plotting.Sometimes, these software offers curve fitting equations, and magnified view of lines of intersection that can help students and instructors to accurately analyze data.However, there are educational environments around the world, whereby the cost for purchase and license renewal of these software can potentially be restrictive.Therefore, while attempting to solve 1-D motion, students and instructors may need to resort to manual plotting of graphs.Errors in data analysis due to inaccurate plots can reduce the effectiveness of learning in introductory physics.Examples in literature show that errors in manual plotting can arise from inconsistent scaling on axes, and reduced precision on lines of best fits due to limiting space [1].A study whereby a phone application was developed to plot introductory physics graphs showed the gap between 'below average' and 'above average' students decreased and overall students' performance increased [2].Therefore, plotting graphs electronically has potential to improve introductory physics learning.Free scientific programming languages, like Python [3] and GNU Octave [4], provide accessible options for graph plotting and data analysis.However, the drawback lies in the prerequisite knowledge of specific programming languages, a skill not universally possessed by all introductory physics students.
ChatGPT 3.5 is an artificial intelligence chatbot that can be freely accessed via the internet [5].It lacks the ability to independently perform physical experiments or directly analyze data.Research has revealed its limited effectiveness in solving physics problems [6].Nevertheless, ChatGPT can generate scripts in various programming languages that can assist in data visualization and analysis.This paper demonstrates how ChatGPT 3.5 can create scripts in Python or GNU Octave to support instructors and students to plot graphs, in order to solve problems related to 1-D motion in introductory physics.The author assumes that data has already been gathered that needs plotting.The emphasis lies in using ChatGPT to generate plots which will then facilitate calculation of physical values.

Data plotting and analysis
In this section, we will explore different cases of motion along a single dimension (1-D).ChatGPT 3.5 will be tasked with generating scripts capable of creating graphs.Following the plotting, students or instructors can then request additional code from ChatGPT to aid in data analysis.For instance, users can ask ChatGPT to generate scripts for plotting best-fit lines to calculate slopes or drawing polygonal regions for area calculations.This is a commonly studied topic in introductory physics, where speed can Upon requesting ChatGPT 3.5 to generate a Python script for graphing using the provided data, it not only produced the script for drawing the graph but also recommended installing essential libraries, such as matplotlib [7] and numpy [8], to facilitate graph creation and data calculation for line fitting.The conversation between the author and ChatGPT 3.5 for these plots are demonstrated in appendix A. Figures 1(a) and (b) depict the plot with a tangential line and a secondorder equation, respectively.Students can now determine the speed by either computing the slope of the tangential line or finding the derivative of the second-order best fit.

Velocity-time
Consider the provided in table 2, where velocity (⃗ v) is measured in miles per hour (mph), and time (t) is given in hours (h).If the objective is to determine the total distance or displacement travelled, there is a requirement to calculate the area under the graph.

Sum of forces
Imagine an object with a mass of 300 g undergoing acceleration.It experiences a 5 N force in one direction and a 2 N force in the opposite direction.ChatGPT 3.5 was tasked with creating a visual representation of the object in GNU Octave, depicting an arrow of length 5 pointing in one direction and an arrow of length 2 pointing in the opposite direction.The plot is shown in figure 3(a).Morever, ChatGPT was asked to generate scripts to plot a graph of constant acceleration, 10 m s −2 vs time for time ranging from 0 s to 10 s.In this case, ChatGPT 3.5 also went beyond and plotted the displacement vs time graph by assuming an initial velocity of 0 m s −1 .The author then requested all three plots of displacement, velocity and acceleration vs time.This is shown in figure 3(b).The conversation between the author and ChatGPT 3.5 for these plots are demonstrated in appendix C.

Discussion
ChatGPT 3.5 generated scripts for plotting the graphs.However, it relied on accurate input and clear instructions from the author to produce the graphs.The author communicated in plain English to obtain the desired output.For example, when dealing with the graphs discussed in the previous section, the author provided ChatGPT 3.5 with values and requested a plot in the specified programming language.While the generated codes proved effective, the process occasionally involved multiple interactions to refine them.Remarkably, these interactions demanded concise instructions from the author.For instance, in the   The author fixed the code by simply adding the prompt 'legend not needed' after requesting for a new line to be drawn.In the acceleration-time graph, ChatGPT 3.5 presumed 'an initial velocity of 0 m s −1 for simplicity,' a assumption the author adopted without modification.
It is worth noting that although ChatGPT 3.5 can sometimes solve algebraic problems, it is not consistently able to directly assist students in solving physics problems.For instance, in section 2.3, ChatGPT 3.5] successfully determined the acceleration to be 10 m s −2 .However, it faced limitations in solving for the area under the graph in section 2.2.A comparison of manually calculated data and data computed by ChatGPT 3.5 is presented in table 3, revealing discrepancies between the two.Notably, ChatGPT 3.5 did not incorporate units in its calculations.ChatGPT 3.5 has been found to have various limitations, including a lack of reasoning capability and a tendency to generate biased output [9,10].Both are evident in the provided example.Firstly, the model struggled to reason and distinguish data between the 2 and 3 s intervals, particularly when certain values in that range extended below the negative velocity axis.Secondly, a consistent bias was observed as ChatGPT 3.5 consistently employed the area of a trapezoid for each segment of the graphs.Hence, while ChatGPT proves useful in section 2.2 to generate lines for polygons to calculate areas, it falls short in completely solving the problem.It is imperative for students to actively learn physics and employ their cognitive skills for problem-solving rather than relying solely on ChatGPT.Nonetheless, students can employ ChatGPT as a tool to enhance the visualization of graphs.
Another illustration demonstrating that ChatGPT 3.5 cannot consistently solve physics problem involves section 2.1.In this context, consider figure 1(a), where the slope at t = 3 s is  computed according to equation (1).Similarly, in figure 1(b), the slope at t = 3 s is determined through the derivative of the second-order equation, as expressed in equation ( 2).They both produced answer of 6 m s −1 .However, when ChatGPT 3.5 was tasked with calculating the slope at t = 3 s, it yielded a result of 5 m s −1 , as shown in figure 5.
d dt These analyses demonstrate that ChatGPT 3.5 is effective in aiding students to generate 1-D motion graphs using various free programming languages.The utilization of such graphs has the potential to enhance physics education, especially in scenarios that limits options to manual graph plotting.However, ChatGPT 3.5 is not always able to solve physics problems accurately.In a study where ChatGPT 3.5 was assumed to be an introductory physics student, the user gave it several physics problem to solve and ChatGPT had many numerical errors similar to a beginner students [11].Nonetheless, it has been shown that due to ChatGPT's operations being probabilistic, it can still be a useful tool to aid in physics education [12].Sometimes the user must ask ChatGPT to regenerate its response, which allows it to restart its calculations all over.This is ideal for physics education because it allows the students or teachers to perform the cognitive analysis of a physics problem, and to simply use ChatGPT as a tool to assist in visualising the problem solving.

Conclusion
The author encourages the use of ChatGPT as a valuable tool to aid both students and instructors in creatively generating graphical plots for enhanced data visualization and subsequent analysis.Based on the finding of this paper, there are several benefits of using ChatGPT 3.5 to assist in introductory physics education learning.ChatGPT 3.5 is capable of generating scripts based on accurate user input.These scripts can create 1-D motion graphs using free programming languages like Python and GNU Octave.This was used to plot distance-time graphs, velocity-time graphs, and acceleration-time graphs in Python or GNU Octave.ChatGPT 3.5 guides users to download and install any additional libraries that may be required.Users can provide instructions in English to customize graphs, including tasks like altering fonts, adding lines of best fit, introducing legends, and/or changing line colors.For example, lines of best fit, to facilitate calculation of slope, were added to the distance-time graph.The author also requested drawing of lines to delineate polygons that can be used to calculate area under the velocity-time graph.However, there are some limitations of using ChatGPT 3.5 to assist in physics education learning.ChatGPT 3.5 may make assumptions during graph plotting that can result in inaccuracies during data calculations.For instance, in the distance-time graph, ChatGPT 3.5 erroneously presumed that a tangent at t = 3 s should also intersect the point at t = 2 s.This also led ChatGPT 3.5 to inaccurately determine the velocity to be 5 m s −1 at t = 3 s.However, users can provide English instructions to rectify errors or incorrect assumptions made by ChatGPT 3.5.This improved the tangential line on the distance-time graph to only intersect the plot at t = 3 s.When presented with raw data, ChatGPT 3.5 does not promptly recognize instances where lines intersect the time axis.For instance, in the distancetime graph, ChatGPT 3.5 overlooked the crossing of the velocity graph with the time axis at t = 2.6 h in the velocity-time graph, resulting in an erroneous calculation of the area under the graph for displacement.However, these limitation of ChatGPT 3.5 can prove to be a blessing, since it allows the user to apply their cognitive skills to assess and modify of the presented data.
The author does not endorse the use of ChatGPT to facilitate cheating in solving physics problems.Instead, the author encourages users to use their cognitive skills to solve physics problems and to use ChatGPT as a tool to assist in data visualization.The observations and constraints discussed are specific to ChatGPT 3.5.The response of future versions of ChatGPT to physics problems may differ.Therefore, it is important not to extend the conclusions of this paper to all versions of ChatGPT.However, it would be interesting for future research to compare newer versions of ChatGPT to the current one.

Future directions
There exist numerous inventive possibilities for leveraging ChatGPT to support physics education, and further exploration of these applications is anticipated in upcoming research.ChatGPT 3.5 has the potential to generate code for intricate data visualization and computations.This capability could assist in visualizing concepts in introductory physics education, promoting interactive problem-solving and facilitating the learning process.In the future, the scope of the present study may extend to include 2D motion and the creation of animations, offering opportunities to enhance physics education environments.For example, ChatGPT could be utilized to generate scripts that create animations of motion in a 2D plane for students to examine.It may also incorporate randomness, ensuring unique motion scenarios.In this context, students may collaborate and work together on problem-solving activities.Another example could be exercises in which students identify and explain errors in the problemsolving performed by ChatGPT.Furthermore, since ChatGPT can be freely accessed via the internet, it is possible to integrate it in future remote learning environments.For example, it might be challenging for physics students to perform experiments remotely, however, they might be able to analyze data using ChatGPT as a tool.
Incorporating artificial intelligence, such as ChatGPT, into physics education is inevitable.Although there is concern about the potential misuse of rapidly advancing technology, it has been proposed that the best approach is to incorporate the new technology while establishing safeguards to prevent misuse [13].Consequently, educators should guide students on the responsible use of this tool.The rapid evolution of this technology requires an ongoing research and adjustment on how we integrate artificial intelligence into the classroom.There is a possibility that, in the future, teachers and students will receive regular training on the ethical integration of artificial intelligence technology in the classroom.
In this modified code, I have adjusted the calculation of the tangent slope using the points at t = 2 and t = 4 to ensure that the tangent line touches the original graph only at t = 3.The tangent line is now plotted accordingly.Author: ignoring the tangentian line, that is, going back to the original graph, generate a second order and a third order polynomial that best fits the data and draw them in the python code.Do them in separate colors and show the equations.ChatGPT 3.5: To generate second-order and third-order polynomials that best fit the data and draw them on the graph, you can use the numpy.polyfitfunction.Here's the modified code: In this code, numpy.polyfit is used to fit second-order and third-order polynomials to the data.The np.polyval function is then used to generate points for these polynomials, and they are plotted on the graph with different colors.The equations of the fitted polynomials are also displayed in the legend.
Author: remove the tangent line, make the second order black and the third order green ChatGPT 3.5: Certainly!Here's the modified code with the tangent line removed and the secondorder polynomial in black and the third-order polynomial in green: Now, the second-order polynomial is represented by a black dashed line, and the third-order polynomial is represented by a green dashed line on the graph.
Author: remove the third order data and only show the second order data ChatGPT 3.5: Certainly!Here's the modified code to display only the second-order polynomial data: Now, the graph only displays the original data and the second-order polynomial, with the secondorder polynomial shown in black.

Appendix B. Velocity-time graph
A link to the full conversation between author and ChatGPT 3.5 for the velocity time graph is: https://chat.openai.com/share/c6ae2b5d-8b2d-4c4b-a04a-a76df9e3e331.The full conversation is also provided below.
Author: plot a graph of velocity versus time in python.Label the velocity axis as ⃗ v (mph) and the time axis as t (h) .the data for velocity are: 0, 40, 40, -25, -25 and the data for time are 0, 1, 2, 3, 4 make the font big.put minor ticks and keep the grid on ChatGPT 3.5: To plot a graph of velocity versus time in Python, you can use the matplotlib library.Here's an example code snippet that fulfills your requirements: This code uses matplotlib to create a plot with labeled axes, a title, a grid with minor ticks, and specified font sizes.The velocity is plotted against time, and the data points are connected with lines.The r ′ ⃗ v' is used to render the "v" with an arrow on top.
You can run this code in a Python environment with matplotlib installed to generate the desired plot.
Author: Draw a dashed black line between T = 0, V = 0 and T = 1 and V = 0. Legend not needed.This script creates a figure, plots the object as a black circle, and then uses the quiver function to draw arrows away from the object in two different directions.The lengths of the arrows are specified by the variables arrow1_length and arrow2_length.The arrows are plotted in red and blue for better visibility, and the legend indicates the object and the two arrows.The grid is displayed for reference, and the axis is set to equal for better visualization.
Author: remove the legend.Make the font Arial and bigger ChatGPT 3.5: Certainly!Here's the modified script with the legend removed and the font set to Arial with a larger size: In this script, I added the 'FontName' and 'FontSize' parameters to the xlabel, ylabel, and title functions to set the font to Arial and adjust the font size.The legend has been removed as per your request.Feel free to adjust the font size further if needed.
Author: in octave, generate scripts to plot a graph of constant acceleration, 10 m s −2 vs time for time ranging from 0 s to 10 s ChatGPT 3.5: Certainly!To plot a graph of constant acceleration against time in Octave, you can use the following script.I will assume an initial velocity of 0 m s −1 for simplicity: This script generates a plot of displacement versus time for an object undergoing constant acceleration.The time vector is created with a range from 0 to 10 s in increments of 0.1 seconds.The displacement is calculated using the kinematic equation s = ut + 1 2 at 2 , where u is the initial velocity, a is the acceleration, and t is time.
Feel free to adjust the initial conditions or the time range based on your specific requirements.Author: plot displacement vs time, velocity vs time, and acceleration vs time in 3 subgraphs ChatGPT 3.5: Certainly!You can create subplots for displacement, velocity, and acceleration versus time using the following Octave script:

Figure 1 .
Figure 1.Plots made in python using scripts generated by ChatGPT 3.5.(a) A tangent line is added at t = 3 s.(b) A second order polynomial is added to fit the data.
distance-time graph, the initial script created by ChatGPT 3.5 resulted in the tangential line intersecting at t = 2 and t = 3 s, as depicted in figure 4.However, the author fixed the code by simply instructing ChatGPT 3.5 to 'make the tangential line only touch the original graph at t = 3,' leading to the finalized code for figure1(a).In the velocity-time graph, ChatGPT 3.5 sometimes labelled the dashed line for the polygons drawn for calculating area under the graph in the legend.

Figure 2 .
Figure 2. (a) Velocity vs time contains minor tick marks that can help identify values of velocity.(b) Polygons drawn to help calculate area under the graph.

Figure 3 .
Figure 3. (a) Arrows showing forces acting on object (black dot) and (b) displacement, velocity and acceleration vs time, when ChatGPT assumed an initial velocity of 0 m s −1 .

ChatGPT 3 . 5 :ChatGPT 3 . 5 :
Certainly!You can modify the code to include a dashed black line between T = 0 and T = 1 with V = 0. Here's the updated code: This code adds a dashed orange line between V = 0 and T = 2.6 to V = 0 and T = 4.The line is specified using the plot function with linestyle = '-' and color = 'orange'.If you have any further questions or requests, feel free to let me know!Author: nice! now add a dashed orange line between T = 4 V = 0 to T = 4 and V = −25 no legend needed Certainly!You can add a dashed orange line between T = 4 and V = 0 to T = 4 and V = −25.Here's the modified code:

Table 1 .
Distance versus time data.

Table 2 .
Velocity versus time data.