Acessibilidade / Reportar erro

Using neural networks to predict the range of projectile motions in viscous medium

Abstract

The motion of any material body after be launched from some point in Earth surface start to follow a trajectory determined by two different interactions, the gravitational attraction and the resistance to his movement caused by the contact with the molecules of the medium in which it travels. Considering that a huge amount of physics problems remains not even mentioned on physics courses due to the requirements of strong mathematical background or computational effort. The authors propose a new and easier approach to introduce the study of complex problems in introductory physics courses, based on neural networks and machine learning. Through one simple example of classical mechanics with artificial intelligence the authors are supposed to contribute with the introduction of new technologies to physics learning.

Keywords
Projectile motion; horizontal range; neural networks; viscous medium


1. Introduction

The use of artificial intelligence has taken on considerable proportions in our daily lives in recent years and caused transformations with relevant social and economic impact [1[1] P. Aghion, C. Antonin and S. Bunel, Economie et Statistique/Economics and Statistics 510-511-512, 150 (2019).]. The increasing speed of information processing combined with the development of efficient data transmission and storage systems has leveraged major advances in areas such as imaging diagnostics, arts, economics, automation, pattern recognition, social network analysis and data security, among others [2[2] S. Das, A. Dey, A. Pal and N. Roy, International Journal of Computer Applications 115, 31 (2015).]. Adaptation to this powerful technological resource has occurred quickly, which causes a need to introduce artificial intelligence in the area of physics teaching [3[3] O. Zawacki-Richter, V.I. Marín, M. Bond and F. Gouverneur, International Journal of Educational Technology in Higher Education 16, 1 (2019).,4[4] G.R. Schleder and A. Fazzio, Revista Brasileira de Ensino de Física 43, e20200407 (2021).,5[5] H. Ferreira, E.F. Almeida Junior, W. Espinosa-García, E. Novais, J.N.B. Rodrigues and G.M. Dalpian, Revista Brasileira de Ensino de Física 44, e20220214 (2022).]. This demand has presented challenges to teachers and educational institutions, which naturally occurs when emerging technologies are aimed at innovation in teaching [6[6] Z.A. Krusberg, Journal of Science Education and Technology 16, 401 (2007).].

The development of appropriate approach methods and the availability of a specialized bibliography are spaces to be filled in the current stage of this knowledge area. This work seeks to present a contribution in this sense by describing a method for studying the oblique launch of an object in a viscous medium. The problem was chosen with the didactic objective of using the students’ familiarity with oblique launch without air resistance, so that understanding the role of the viscous friction force proportional to the speed of the object becomes more direct and intuitive.

A database was initially generated from mathematical modeling of the addressed problem using conventional numerical computing. This data was then used to train a neural network built for the considered system. Our objective is to present a proposal for innovation in the computational approach to solving physics problems for teaching purposes. By presenting this contribution, we intend to contribute to disseminating artificial intelligence as a teaching tool in the area of physics.

2. Oblique Launch

The oblique launch problem has numerous applications from Olympic sports activities to the launch of georeferencing satellites and aerospace probes [7[7] W. Freire, M. Medeiros, D. Leite and R. Silva, Revista Brasileira De Ensino De Física 38, 1306 (2016).].

The dependence of the air damping force with velocity is quadratic for objects moving with high velocities. However, relatively small objects with velocities lower than approximately 24m/s(86km/h) faces air damping depending on −bv [17[17] S.T. Thornton and J.B. Marion, Classical dynamics of particles and systems (Boston, Cengage, 2020).]:

(1) F y = m a y
(2) F y = m g b v y = m a y
(3) x ( t ) = m b v 0 x ( 1 e b m t ) b x m v 0 x = 1 e b m t e b m t = 1 b x m v 0 x b m t = ln 1 b x m v 0 x m b ln 1 b x m v 0 x

Substituting t found in the equation y(t), we have:

(4) y t = m 2 b 2 g + m b v 0 y 1 e b m t m b g t y x = m 2 b 2 g + m b v 0 y = 1 e b m t m b ln 1 b x m v 0 x + m b g m b ln 1 b x m v 0 x
(5) y x = m 2 b 2 g + m b v 0 y 1 e ln 1 b x m v 0 x + + m 2 b 2 g ln 1 b x m v 0 x
(6) m 2 b 2 g m b v 0 y 1 1 + b x m v 0 x + + m 2 b 2 g ln 1 b x m v 0 x

But v0x = v0 cos θ0; v0y = v0 sin θ0

(7) y x = m g b v 0 cos θ 0 + tan θ 0 x + m 2 b 2 g ln 1 b x m v 0 cos θ 0

Expanding function (3), the term which appears as the logarithm, we will have:

(8) ln 1 b x m v 0 cos θ 0

With ω=bxmv0x, we have:

(9) ln ( 1 ω ) 0 + ( 1 ) 1 ! ω 1 + ( 1 ) 2 ! ω 2 + ( 2 ) 3 ! ω 3 ...
(10) ln ( 1 ω ) ω 1 1 ω 2 2 2 ω 3 3 2 ...
(11) ln ( 1 ω ) ω ω 2 2 ω 3 3 ...

Then ω=bxmv0x, the expansion becomes:

(12) ln 1 b x m v 0 x b x m v 0 x + b 2 x 2 2 m 2 v 0 x 2 b 3 x 3 3 m 3 v 0 x 3 ...

Substituting the expansion into the trajectory equation, we have:

(13) y ( x ) = m g b v 0 cos θ 0 + tan θ 0 x + m 2 b 2 g b x m v 0 x b 2 x 2 2 m 2 v 0 x 2 b 3 x 3 3 m 3 v 0 x 3 = tan θ 0 x g 2 v 2 0 cos 2 θ x 2 b g 3 m v 0 3 x 3 = 0

3. Neural Networks

Modern computers have the ability to simulate circuits similar to networks. The basic principle of a neural network is schematically depicted in Figure 1, given by one or more input variables, hidden layers of different sizes and quantities, which can change according to the objective, and also the layer of one or more outputs. The signals emitted by neurons are represented by the formula:

(14) S k = f 1 n x i w i k + b k

Sk: signal emitted by neuron k

f: activation function

n: number of entries from the previous layer

xi: i-th entry

wik: weight between presynaptic neuron i and postsynaptic neuron k

bk: bias associated with neuron k

Figure 1
Basic structure of a neural network with k inputs, l neurons, and m outputs.

Random weights associated with all variables are initially used to conduct the first iterations (epochs). An epoch carried out with a batch of input values interacts to the network and return a set of predicted ranges. Such random weights lead to outputs far from the expected values. The mean squared error is applied to evaluate batch performance as follow:

(15) M S E = 1 n 1 n y i p i 2

n: number of samples in the batch

yi: actual sample value

pi: predicted value

Based on the mean squared error found, the RMSProp optimization algorithm [9[9] V. Bushaev, Undestanding RMSprop - faster neural networking learning, available in: https://towardsdatascience.com/understanding-rmsprop-faster-neural-network-learning-62e116fcf29a
https://towardsdatascience.com/understan...
, 10[10] T. Tieleman and G. Hinton, COURSERA: Neural Networks for Machine Learning 4, 26 (2012)] is used to calculate the new weights that will replace the current ones, as indicated in Figure 2, so that the MSE value can be reduced in the next epochs. The formula for this algorithm is given by:

(16) E [ g 2 ] t = β E [ g 2 ] t 1 + ( 1 β ) δ C δ w 2 w t + 1 = w t η E [ g 2 ] t + 1 δ C δ w

wt+1: updated weight

wt: current weight

η: learning rate, example = 0.001

E[g2]: moving average of the quadratic gradient

β: moving average parameter

δCδw: gradient of the cost function with weight

Figure 2
Update of all weights.
Figure 3
Range depending on the parameters in Table 1.

4. Method

Table 1 shows data from several tests carried out computationally using the Python programming language [11[11] G. Van Rossum and F. Drake Jr, Python reference manual (Centrum voor Wiskunde en Informatica, Amsterdam, 1995).] and the Sympy library [12[12] A. Meurer, C. Smith, M. Paprocki, O. Čertík, S. Kirpichev, M. Rocklin, A. Kumar, S. Ivanov, J. Moore, S. Singh et al. PeerJ Computer Science 3, e103 (2017).], aimed at solving equations, and all results were stored in a spreadsheet. With the input variables (mass, initial velocity, gravity, angle and damping constant), Figure 3 stands for the better range calculated and the result (x) which is the correct range calculated, we have a large table of information formed by 4 columns of inputs and 1 for output.

Table 1
Empirical data for neural network training.

From the launch equation:

(17) t a n θ 0 x g 2 v 0 2 cos 2 θ x 2 b g 3 m v 0 3 x 3 = 0

m: mass

v0: initial velocity

θ: launch angle

b: damping constant

Equations were calculated with all possible combinations between values:

1 < = b < = 4.8 | Step = 0.2 10 < = θ < = 89 | Step = 1 0.02 < = m < = 0.09 | Step = 0.01 15 < = v 0 < = 25 | Step = 1

The TensorFlow library [13[13] M. Abadi, P. Barham, J. Chen, Z. Chen and A. Davis, in: 12th USENIX Symposium On Operating Systems Design And Implementation (OSDI 16) (Savannah, 2016).], an open-source software library was applied to build the network. Such application offers high performance topological resources to implement machine learning models and neural networks. In addition, it is designed to training complex neural networks for tasks like image recognition, language processing, numerical predictions and time series analysis. It menages to handle with large data sets and intense mathematical operations. One of the main advantages of TensorFlow is its ability to handle large volumes of data and intense mathematical operations. It enables defining high-level models using abstractions such as layers and computational graphs, and provides a rich Application Programming Interface (API) for customization and extensibility.

The first step in executing training is to pre-process the data, initially separating it into training data and testing data in an 80/20 ratio. After this, we must also separate the target values (range) from the other variables to be the supervised learning labels [14[14] T. Ludermir, Estudos Avançados 35, 85 (2021).].

From this point on we can perform data normalization, which consists of transforming the values into a specific scale in a standardized way which facilitates comparison with other batches of data in order to avoid the existence of learning biases and improve model convergence. The normalization formula is given by:

(18) Z = x μ σ

Z: normalized value

x: value

μ: mean of the values

σ: standard deviation of the values

After normalizing the input data, we use the Keras API which runs on top of Tensorflow [15[15] F. Chollet, Q.S. Zhu, F. Rahman, T. Lee, C. Qhian, G. Marmiesse, H. Jin, O. Zabluda, S. Marks and M. Watson et al. Keras, GitHub, (2015), available in: https://github.com/fchollet/keras
https://github.com/fchollet/keras...
]. It was possible to create a network using the keras function. Sequential() is responsible for grouping the layers of the network of Figure 4, defining only one internal layer with 100 neurons, all connected to an output, which represents the predicted range. The activation function applied was that which returns the maximum value between 0 and the signal received by the neuron.

Figure 4
Structure of the neural network adapted to the problem.

With the network parameters defined, we then use the fit method added with normalized training data and labels with the results of their combinations to perform training for 1000 epochs, recalculating the weights through backpropagation in each one.

5. Results

We created a neural network which learned from the data that was delivered, as shown in Figure 5, and was then able to predict the results of new launches with values very close to those obtained when solving equations, which can be observed in Table 2.

Figure 5
Comparison between the values found by the network with the correct values that were labeled.
Figure 6
Evolution of MSE during epochs.
Table 2
Random empirical examples with their predictions.

We can evaluate the performance of a neural network with the root mean squared error evaluation metric (RMSE) [16[16] D. Santos and E. Oliveira, Sociedade Brasileira De Automática 1, SBSE2020 (2020).], which is very useful to check its prediction quality. The lower the result, the better the network’s ability to estimate values. It is widely used in machine learning implementations, and its formula is:

The square root of the last MSE value obtained equals the RMSE

0.00048722 0.02207316

Such a small magnitude of the RMSE represents how appropriate neural networks can be to make the study of mathematically sophisticated physics problems much more easier to understand in learningprocesses.

6. Final Considerations

Considering the revolutionary paradigm shift now in course, carried out by different ways of perform machine learning and apply it to different branches of human activity, allied to author’s intent of popularize artificial intelligence in science education, the authors performed the machine learning approach in a very simple classical mechanics problem, and of course the results obtained might be considered very good.

References

  • [1]
    P. Aghion, C. Antonin and S. Bunel, Economie et Statistique/Economics and Statistics 510-511-512, 150 (2019).
  • [2]
    S. Das, A. Dey, A. Pal and N. Roy, International Journal of Computer Applications 115, 31 (2015).
  • [3]
    O. Zawacki-Richter, V.I. Marín, M. Bond and F. Gouverneur, International Journal of Educational Technology in Higher Education 16, 1 (2019).
  • [4]
    G.R. Schleder and A. Fazzio, Revista Brasileira de Ensino de Física 43, e20200407 (2021).
  • [5]
    H. Ferreira, E.F. Almeida Junior, W. Espinosa-García, E. Novais, J.N.B. Rodrigues and G.M. Dalpian, Revista Brasileira de Ensino de Física 44, e20220214 (2022).
  • [6]
    Z.A. Krusberg, Journal of Science Education and Technology 16, 401 (2007).
  • [7]
    W. Freire, M. Medeiros, D. Leite and R. Silva, Revista Brasileira De Ensino De Física 38, 1306 (2016).
  • [8]
    M. Sousa, Como funcionam os neurônios?, available in: https://www.colegioweb.com.br/biologia/como-funcionam-os-neuronios.html
    » https://www.colegioweb.com.br/biologia/como-funcionam-os-neuronios.html
  • [9]
    V. Bushaev, Undestanding RMSprop - faster neural networking learning, available in: https://towardsdatascience.com/understanding-rmsprop-faster-neural-network-learning-62e116fcf29a
    » https://towardsdatascience.com/understanding-rmsprop-faster-neural-network-learning-62e116fcf29a
  • [10]
    T. Tieleman and G. Hinton, COURSERA: Neural Networks for Machine Learning 4, 26 (2012)
  • [11]
    G. Van Rossum and F. Drake Jr, Python reference manual (Centrum voor Wiskunde en Informatica, Amsterdam, 1995).
  • [12]
    A. Meurer, C. Smith, M. Paprocki, O. Čertík, S. Kirpichev, M. Rocklin, A. Kumar, S. Ivanov, J. Moore, S. Singh et al. PeerJ Computer Science 3, e103 (2017).
  • [13]
    M. Abadi, P. Barham, J. Chen, Z. Chen and A. Davis, in: 12th USENIX Symposium On Operating Systems Design And Implementation (OSDI 16) (Savannah, 2016).
  • [14]
    T. Ludermir, Estudos Avançados 35, 85 (2021).
  • [15]
    F. Chollet, Q.S. Zhu, F. Rahman, T. Lee, C. Qhian, G. Marmiesse, H. Jin, O. Zabluda, S. Marks and M. Watson et al. Keras, GitHub, (2015), available in: https://github.com/fchollet/keras
    » https://github.com/fchollet/keras
  • [16]
    D. Santos and E. Oliveira, Sociedade Brasileira De Automática 1, SBSE2020 (2020).
  • [17]
    S.T. Thornton and J.B. Marion, Classical dynamics of particles and systems (Boston, Cengage, 2020).

Publication Dates

  • Publication in this collection
    05 Jan 2024
  • Date of issue
    2023

History

  • Received
    12 Nov 2023
  • Accepted
    20 Nov 2023
Sociedade Brasileira de Física Caixa Postal 66328, 05389-970 São Paulo SP - Brazil - São Paulo - SP - Brazil
E-mail: marcio@sbfisica.org.br