{"id":332,"date":"2022-07-30T13:49:42","date_gmt":"2022-07-30T12:49:42","guid":{"rendered":"https:\/\/wp.coventry.domains\/e2edu\/?page_id=332"},"modified":"2022-08-23T10:43:23","modified_gmt":"2022-08-23T09:43:23","slug":"numerical-integration","status":"publish","type":"page","link":"https:\/\/wp.coventry.domains\/e2edu\/numerical-integration\/","title":{"rendered":"Temporal Derivatives and Numerical Integration"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This article plays is a preamble to the other articles since it addresses not a specific simulation technique but rather general methods that are required for implementing simulations on a computer. The simulation that are described in the following articles employ mathematical equations to calculate physical forces. In order for these forces to exert any effects on the simulated objects, the objects&#8217; acceleration, velocities and positions need to be derived from the forces. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Newton&#8217;s Second Law of Motion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Accelerations can be derived from forces according to <a rel=\"noreferrer noopener\" href=\"https:\/\/www.physicsclassroom.com\/class\/newtlaws\/Lesson-3\/Newton-s-Second-Law#:~:text=Newton's%20second%20law%20of%20motion%20can%20be%20formally%20stated%20as,the%20mass%20of%20the%20object.\" target=\"_blank\">Newton&#8217;s second law of motion. <\/a> This law simply states that the force acting on an object is proportional to the object&#8217;s acceleration with the proportionality factor being the mass of the object.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/ForceAccelerationEquation.jpg\" alt=\"\" class=\"wp-image-326\" width=\"323\" height=\"109\" srcset=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/ForceAccelerationEquation.jpg 870w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/ForceAccelerationEquation-300x102.jpg 300w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/ForceAccelerationEquation-768x260.jpg 768w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/ForceAccelerationEquation-788x267.jpg 788w\" sizes=\"auto, (max-width: 323px) 100vw, 323px\" \/><figcaption>Equation for Newton&#8217;s second law of motion.  F stands for force, t for time, x for position, and m for mass.<\/figcaption><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">Temporal Derivatives<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once the acceleration of an object is known, the object&#8217;s velocity and position can be obtained through integration with regards to time.  These two equations are very similar. To obtain an object&#8217;s velocity, its acceleration is integrated with regards to time, and to obtain an object&#8217;s position, it&#8217;s velocity is integrated with regards to time.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/AccelerationVelocityEquation-1024x306.jpg\" alt=\"\" class=\"wp-image-325\" width=\"383\" height=\"114\" srcset=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/AccelerationVelocityEquation-1024x306.jpg 1024w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/AccelerationVelocityEquation-300x90.jpg 300w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/AccelerationVelocityEquation-768x230.jpg 768w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/AccelerationVelocityEquation-788x236.jpg 788w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/AccelerationVelocityEquation.jpg 1106w\" sizes=\"auto, (max-width: 383px) 100vw, 383px\" \/><figcaption>Equation to obtain velocity from acceleration. x stands for position, t stands for time.<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/VelocityPositionEquation.jpg\" alt=\"\" class=\"wp-image-328\" width=\"363\" height=\"113\" srcset=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/VelocityPositionEquation.jpg 938w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/VelocityPositionEquation-300x94.jpg 300w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/VelocityPositionEquation-768x241.jpg 768w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/VelocityPositionEquation-788x247.jpg 788w\" sizes=\"auto, (max-width: 363px) 100vw, 363px\" \/><figcaption>Equation to obtain position from velocity. x stands for position, t stands for time.<\/figcaption><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">Numerical Integration<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These integral equations treat the physical properties of objects such as position and velocity as symbols and time as continuous parameter. In order to use these equations in a computer simulation, symbols have to be replaced by actual numerical values and time proceeds in discrete steps. This is where numerical integration methods come in. They operate on numerical values and they calculate these values at discrete time intervals. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The simplest but also the least stable numerical integration method is the <a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/Euler_method\" target=\"_blank\">Euler Method<\/a>. This method employs a piecewise linear approximation by calculating the change of a variable with regards to time at a specific point point in time and then assuming that this change is constant for a certain interval of time. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/Euler_method.png\" alt=\"\" class=\"wp-image-345\" width=\"417\" height=\"325\" srcset=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/Euler_method.png 1024w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/Euler_method-300x234.png 300w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/Euler_method-768x600.png 768w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/Euler_method-788x616.png 788w\" sizes=\"auto, (max-width: 417px) 100vw, 417px\" \/><figcaption>Polygonal approximation (in red) of an original equation (blue). Here, the horizontal axis represents time, the vertical axis the value of the dependent variable. \u00a9 en.wikipedia.org<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Following this principle, the value of a physical variable such as velocity is obtained from its derivative by taking the value of velocity at some previous point in time and adding to it the value of its derivative at the current point in time multiplied by the interval between the previous and current point in time. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"459\" height=\"66\" src=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/EulerAccelerationVelocityEquation.jpg\" alt=\"\" class=\"wp-image-352\" srcset=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/EulerAccelerationVelocityEquation.jpg 459w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/EulerAccelerationVelocityEquation-300x43.jpg 300w\" sizes=\"auto, (max-width: 459px) 100vw, 459px\" \/><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"458\" height=\"53\" src=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/EulerVelocityPositionEquation.jpg\" alt=\"\" class=\"wp-image-353\" srcset=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/EulerVelocityPositionEquation.jpg 458w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/EulerVelocityPositionEquation-300x35.jpg 300w\" sizes=\"auto, (max-width: 458px) 100vw, 458px\" \/><figcaption>Euler Numerical Integration Method. The first equation calculates velocity from acceleration, the second equation calculates position from velocity. The symbols are: x for position, v for velocity, a for acceleration, t for time, Delta t for time interval.<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">The advantage of the Euler method is that it is very simple to implement and fast to compute. Its disadvantage is its inaccuracy. As can be seen in the figure depicting an approximation, calculations conducted with the Euler method can lead to values that become increasingly more incorrect over time. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/Leapfrog_integration\" target=\"_blank\">Leapfrog Method<\/a> is an alternative integration scheme that is still easy to implement and fast to compute but exhibits much higher numerical stability than the Euler method. The reason for this is twofold: the it employs second order integration instead of only first order as the Euler method, it calculates updated velocities and positions at interleaved times instead of the same times as in the Euler method.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"723\" height=\"94\" src=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/LeapFrogAccelerationVelocityEquation.jpg\" alt=\"\" class=\"wp-image-357\" srcset=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/LeapFrogAccelerationVelocityEquation.jpg 723w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/LeapFrogAccelerationVelocityEquation-300x39.jpg 300w\" sizes=\"auto, (max-width: 723px) 100vw, 723px\" \/><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"665\" height=\"92\" src=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/LeapFrogVelocityPositionEquation.jpg\" alt=\"\" class=\"wp-image-358\" srcset=\"https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/LeapFrogVelocityPositionEquation.jpg 665w, https:\/\/wp.coventry.domains\/e2edu\/wp-content\/uploads\/sites\/3486\/2022\/07\/LeapFrogVelocityPositionEquation-300x42.jpg 300w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><figcaption>Leapfrog Numerical Integration Method. The first equation calculates velocity from acceleration, the second equation calculates position from velocity and acceleration. The symbols are: x for position, v  for velocity, a for acceleration, t for time, Delta t for time interval.<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">There exist much more sophisticated numerical integration methods than those two that have been described here. An example are the popular <a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/Runge%E2%80%93Kutta_methods#:~:text=In%20numerical%20analysis%2C%20the%20Runge,solutions%20of%20simultaneous%20nonlinear%20equations.\" target=\"_blank\">Runge\u2013Kutta methods<\/a>. These methods are used in applications in which numerical stability and accuracy are important. While numerical stability might be of a concern when using simulations for artistic purposes, accuracy is much less so. For these applications, the Leapfrog method is very well suited. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article plays is a preamble to the other articles since it addresses not a specific simulation technique but rather general methods that are required for implementing simulations on a computer. The simulation that are described in the following articles employ mathematical equations to calculate physical forces. In order for these forces to exert any [&hellip;]<\/p>\n","protected":false},"author":2154,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"class_list":["post-332","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/wp.coventry.domains\/e2edu\/wp-json\/wp\/v2\/pages\/332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.coventry.domains\/e2edu\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/wp.coventry.domains\/e2edu\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/wp.coventry.domains\/e2edu\/wp-json\/wp\/v2\/users\/2154"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.coventry.domains\/e2edu\/wp-json\/wp\/v2\/comments?post=332"}],"version-history":[{"count":28,"href":"https:\/\/wp.coventry.domains\/e2edu\/wp-json\/wp\/v2\/pages\/332\/revisions"}],"predecessor-version":[{"id":2609,"href":"https:\/\/wp.coventry.domains\/e2edu\/wp-json\/wp\/v2\/pages\/332\/revisions\/2609"}],"wp:attachment":[{"href":"https:\/\/wp.coventry.domains\/e2edu\/wp-json\/wp\/v2\/media?parent=332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}