Manual 1 - Basic Engine Operationcseweb.ucsd.edu/~sergiom/icarus/downloads/Icarus Physics... ·...
Transcript of Manual 1 - Basic Engine Operationcseweb.ucsd.edu/~sergiom/icarus/downloads/Icarus Physics... ·...
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 1 de 24
Icarus Physics Engine Manual 1 - Basic Engine Operation
Version 1.0
Revision History Date Version Description Author
03/06/2010 1.0 Initial Version Sergio Miguel Martin
Table of Contents
1. Introduction 2
1.1 Purpose 2 1.2 Scope 2 1.3 Definitions, Acronyms and Abbreviations 2 1.4 References 2
2. Introduction to the finite differential method of solving complex problems 3
2.1 Introduction to complex problems 3 2.2 Integral methods limitations 6 2.3 Finite differential Method 10
3. How does the Icarus Physics Engine work? 14
3.1 Basic IPE operation 14 3.2 Impact of accumulated error on the simulation 15
4. Gravitation, Electric and Magnetic forces. 18
4.1 Gravitation Forces 18 4.2 Electric Forces 19 4.3 Magnetic Forces 20 4.4 Time differential commit operation 20
5. Optimization methods 21
5.1 Non Optimized Mode 21 5.2 n-Step Euler Method 21 5.3 Runge-Kutta Method 23
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 2 de 24
Manual 1 - Basic Engine Operation
1. Introduction
1.1 Purpose
The purpose of this document is to introduce the reader to the complexity of the continuous problem
resolution, the differential approach solution, define the basic differential algorithms and procedures used
in the Icarus Physics Engine, and the numeric optimization methods implemented.
1.2 Scope
This document describes first the mathematical approach to the field simulations problems and then show
the overall operation and algorithms to be used by Icarus Physics Engine in order to simulate a object /
fields oriented schema under Gaussian fields (limited to: gravitation and electromagnetic fields)
1.3 Definitions, Acronyms and Abbreviations
IPE – Icarus Physics Engine
1.4 References
N/A
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 3 de 24
2. Introduction to the finite differential method of solving complex problems
2.1 Introduction to complex problems
The Icarus Physics Engine will simulate gravitation scenarios where n-quantity of objects will interact in
real time. As their position varies so will their gravitation field and its influence in other objects. So, is
there a ‘magic formula’ to determine the whole system state in a certain moment of the future? Well,
modern physics and math count with a wide practical knowledge on solving any kind systems. But they
will only solve simplified versions of those systems as they provide a tool for an specific area of science.
Complex systems (such as the ones to simulate in Icarus) will require that it can be divided into a discrete
quantity of simpler systems able to be solved with these tools.
As example, when a student is taught about gravitational forces, it’s exemplified by simple exercises that
discard factors other than a constant gravity acceleration itself by considering them despicable (and they
are: air resistance, gravity variation thorough altitude). This way the real complex system becomes a
singular simple system able to be calculated using simple formulas.
This methodology is very useful to teach and learn this phenomenon, but often fall short in front of more
complex systems that (unfortunately) can not be solved with the application of a handful of formulas.
Figure 1: Simple free fall example.
In the Diagram 1 a standard free fall exercise example is shown. While a gravitation force (shown in black)
‘pulls down’ the object to the earth’s surface, other factors such as Air Resistance and the much less
obvious gravitation field variation effects (shown in red) on the studied case are considered despicable.
Now, while the fact that its influence in the final development of the exercise is practically despicable is the
only reason to discard Air Resistance, it is the partial truth when gravitation field variation comes to play
its cards. The second factor for gravitation field variation to not being taken account is that its continuous
solution has a very complex solution in some cases and, in some other, no mathematical solution at all.
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 4 de 24
The gravitation acceleration over any existing thing over the universe varies in the inverse of the square of
the distance with the attracting mass. So, reviewing Diagram 1, we can point that at Altitude 1, earth’s
gravitation acceleration is greater from Altitude 2 as much as the inverse of the square of the increment
(distance) allows. This distance difference (at the scale of meters) has such small effect in acceleration
that it would affect very little in the final duration of the fall. So little that it can be ignored.
2/8.9 smg
Formula 1: Gravity remains constant thorough the whole exercise
But is it so for larger scales of distance? The answer is definitely no.
The linear gravity scalar accelerations for different distances (in crescent order) from the earth are shown in
the following table:
Where Distance from Earth’s core Gravity Acceleration
At the surface of the earth (poles): 6356 km 9,8322 m/s2
At the surface of the earth (equator): 6378 km 9,78 m/s2
MIR Space station 6656 km 8.18 m/s2
Termosphere 7356 km 7.32 m/s2
Geostationary orbit 35786 km 0,3113 m/s2
Moon’s average orbit 384400 km 0,0027 m/s2
Table 1: Gravitation acceleration in different distances from earth
As shown Table 1. The earth’s gravitation influence in nearby bodies greatly varies at kilometrical
magnitudes. Moreover, at the distance of ten thousand kilometers you experience half of the gravity
acceleration that you would if you were at the very surface.
So, now imagine a free fall example from the Moon’s average orbit distance. You would take a lot longer
to finally touch earth’s surface (we strongly recommend using a parachute, though) than what you could
calculate using the simplified theoretical exercises where the gravity is a constant equal to 9.8m/s.
You would start feeling a slow acceleration (0,0027 m/s2) which will fast increase as you pass close to the
MIR Space station (8.18 m/s2) and then get close to the surface (9,8 m/s
2).
At the end of this experience, the elapsed time would be much more than ‘expected’ as acceleration started
much slower than the one at surface.
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 5 de 24
Figure 2: Formula complexity for gravitation exercises using variable gravity force.
Now, there is nothing to criticize to our physics professors. Formulas for free fall (see Figure 2)
calculations keeping in mind the gravity acceleration variation are extremely complex.
If now we add other factors of complexity such as another dimension (moving sideways while falling as on
Case 2) or add multiple sources of gravity (imagine an object at the middle of moon and earth being
attracted by both as in Case 3), there is no single step solution that could possibly calculate this situation.
Fortunately, there is a way to get to a case 3-like (or even more complex) solution, but first we will analyze
why the current approach is unable to do this.
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 6 de 24
2.2 Integral methods limitations
When we first try to solve a free-fall problem such as the one in figure 1 to calculate how long would take
for an object falling from, as example, 50 meters high to reach the earth’s ground, we use the following
well-known formulas:
Formula 2: Standard free-fall calculation formulas
Where:
is the initial velocity (m/s).
is the vertical velocity with respect to time (m/s).
is the initial altitude (m).
is the altitude with respect to time (m).
is time elapsed (s).
is the constant acceleration due to gravity (set to 9.81 m/s2).
Given that the acceleration is taken as constant thorough the whole exercise duration, time difference has
no effect on this value, therefore making it an independent variable respecting to time.
Figure 3: Object’s acceleration thorough the exercise
From the first formula, we can see that final velocity given a certain variation of time, depends linearly
on the gravity’s acceleration. In other words, we can define the velocity as a variable that is defined
integration of the gravity’s acceleration thorough the variation of time.
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 7 de 24
In the figure 3 we can define the unsigned amount of the velocity variation as the area enclosed by the
gravity constant and the start/end times.
Geometrically we can define this as the rectangle’s area where the height is the gravity constant and the
length is the time elapsed. This we can verify that the variation of the velocity obeys the formula 2:
Formula 3: Absolute variation of velocity depends linearly on gravity
This shows that, as time flows from start to end, velocity will have to vary linearly, slowing its way up,
completely stopping at the highest point, and accelerating to its way to the floor. We can see this
graphically in the Figure 4:
Figure 4: Object’s Velocity thorough the exercise
In the figure 4 we can define the unsigned amount of the altitude variation as the area enclosed by the linear
velocity variation and the start/end times. This means that the variation of altitude can be defined as the
integral of the velocity respecting to time
Formula 3: Absolute variation of altitude depends linearly on velocity
But since velocity is not constant, but linearly dependent of the gravity’s acceleration, we can compose the
amount of the velocity’s variation from the (2) equation into the v value of (3) as the double integral of
the gravity respecting to time twice:
tgv
vtgtgv
*)2(
*)1( 0
0*)3( htvtvh
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 8 de 24
Formula 4: Absolute variation of position depends on the square of the gravity
Now we can see the evolution of the position in the following graph in figure 5:
Figure 5: Altitude finally depends on the square of the time
At this point, having gravitation as constant, we have been able to solve a simple free fall exercise using
integral methods.
The unknown variable must be put alone at once side of the (5) equation and the calculation of the other
side will reveal its exact value.
But this method has its limitations. As the problems become more and more complex (Cases 1 to 3),
mathematical tools become less capable of determining a discrete quantity of formulas that could solve
the system.
In case 1, the gravitation’s acceleration of the object, is not constant, but depends on the inverse of the
square of the distance as in the following formula (6):
Where g is the gravity’s acceleration, G is the universal gravitation constant, Me is the earth’s mass and d is
the distance between the object and the earth.
00
2
0
2)5(
)4(
htvtg
h
tvtgttgh
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 9 de 24
Assuming that the object’s mass is so little that it won’t affect earth, the x position of the earth can be taken
as a constant, this way, distance (d) will depend on the x position of the object:
)()10(
)()9(
)()8(
object
object
xfg
dfg
xfd
Now, the gravity is not constant anymore, but depends on the position of the object (formula 10)! Since the
position of the object will be affected, at its time, on the gravity in each point, the solution is not easy to
obtain anymore. The gravitation force suffered by the object at each moment can be calculated with the
distance from the attracting objects, but there is no way to know this value a priori using integral
methods.
This way, the only alternative for those and more complex cases is simplifying them using a discrete
approach: the finite differential method.
objectearth
e
xxd
d
MGg
)7(
)6(2
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 10 de 24
2.3 Finite differential Method
In the context of a case 1 One-Dimensional example, let’s examine what happens to gravity’s acceleration
as the object approaches the earth:
Figure 6: One-Dimensional example
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 11 de 24
Now that the gravity varies and depends on the distance, we can determine the strength of the gravitation
field in any point of the space based on the distance from the attracting mass.
Figure 7: Earth gravitational field’s equipotential lines
In the Figure 7, we can see that, at a certain radius, the value of the earth gravitational field remains equal.
In this example, all the objects in the R1 radius will suffer the same gravitational attraction. At the same
time, any object in the R1 radius will suffer more gravitational attraction than any object in the R2 radius.
At its time, any object located in the R2 radius will suffer more gravitational attraction than any object in
the R3 radius.
From that, we are able affirm that:
- In any position of space, there is one and only one value for the gravitational field and, (1)
- This value can be obtained using a finite number of calculations (2)
Remembering the first example where the gravitation acceleration was taken as constant (figure 1). The
reasoning was that the variation of distance (in the order of mere meters) was not enough to significantly
modify the results. So, if we can use the same formula 1 to calculate the position change of an object many
times with a very little time differential recalculating the gravity value at each new position and taking it as
constant, we can be able to reduce case 1, 2, 3 and even more complex problems into a finite number of
simpler problems with a little cost which is information loss.
To comprehend what we mean with information loss and how it is influenced by the time differential, we
will give a graphical approach of the integration basics.
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 12 de 24
Let’s define an arbitrary unknown function f(x) that depends on some x variable that encloses a given area
(At) between its y value, the y = 0 axis, and side limits between x = 0 and x = x’. (Remember figures 3 and
4 to see why determining the area below the function is important for our simulation).
Figure 8: Arbitrary function f(x).
A first approach to estimate the area enclosed by the function, we can draw series of rectangles based in the y value
(based on the (2) affirmation) of the function at the x point where we are placed as height, and using a constant x
differential (Δx) as length, as shown in the following Figure:
Figure 9: Rectangular approximation to the total area using finite x differentials
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 13 de 24
As you can observe in the figure 9 we can approximate to the total area below the function by using a finite number
of rectangles. The n times sum of the area of the rectangles will give an estimate of the area that will differ in an
indeterminate error that we call information loss (E(i)).
)(*)()11(0
iEttifAtn
i
In the next figure we can observe that, if we reduce the time differential (Δx), the number of steps (n) will increase,
and the information loss will decrease.
Figure 10: Information loss decreases as time differentials become smaller
As logic consequence, as the time differential (Δx) approaches zero, steps number become infinite, and information
loss approaches zero as well. As we can see in the following formula, this results in the definition of defined integral
of the function:
n
i
nn
xx
x
xxfdxxfAt1
'
0
)(lim)()12(
Where an hypothetical E information loss would tend to zero.
But using an infinite number of steps brings us to a new dead-end: n-quantity of steps would require an infinite
computational power to calculate. We are back where we started and we don’t have an exact function to define g.
However, in the very first free fall example, we assumed that, for a few meters, the gravitational acceleration
difference was so low that the information loss would not affect the result of the exercise in a significant way.
Keeping that in mind, we can solve a complex problem where we lack a defining function for g (but can easily
obtain its value in any moment of time), by dividing the whole experience time in very little time differentials taking
a constant g to cover ‘a few meters’ where it’s time differential causes information loss so small to not affect the
results significantly and updating the gravitation value in each step. And that’s exactly how the Icarus Physics
Engine works. Check the next chapter for more information on this.
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 14 de 24
3. How does the Icarus Physics Engine work?
3.1 Basic IPE operation
The Icarus Physics Engine (IPE), just as any other computational physics engine, uses the finite differential
method to simulate the whole system in discrete time increments. IPE lets the user set the time differential in order
to take it to a balance between acceptable error margins and computer performance. The following figure defines
how the user can use the time differential as a balance between error (information loss) and performance (faster
simulation):
Figure 11: User can define a Time Differential that best fit his necessities
IPE re-evaluates all force interactions to an object at the beginning of every step and obtains a resulting force which
is the vector sum of all the other forces. Then uses this force to calculate vector acceleration and takes it as a
constant. Once it has finished calculating this constant for all the objects in the system, applies the simple (5)
formula using the obtained constant instead of ‘g’. Figure 12 illustrates the resulting forces on a given state:
Figure 12: All the resulting forces are calculated before committing the step
As result of the committing the formula (5) in each object of the system using the obtained acceleration as constant,
the system passes to the following state (with a time equal to the previous state plus one time differential) where the
object’s positions and velocities are very close to the real case. (remember how close we can get to the real function
by using the differential approach by reviewing the Figure 10).
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 15 de 24
In the following figure, we can see how we can approach a real orbit using finite series of linear steps (time
differentials have been exaggerated to allow viewer note the linear form of the steps advances; all the embedded IPE
scenarios have time differentials that are not even perceptible):
Figure 13: Movement comparison between real and simulated orbits
3.2 Impact of accumulated error on the simulation
While error (or information loss) in one step only may be despicable, its effect remains in for the next step. Even if
we can consider that, in one step, the effects of gravity variation are despicable, as the steps run its effects
accumulate and, in some future moment will end up in an error that could significantly affect the simulation’s result.
Reviewing Case 1 from Figure 2, we have a simple example of an object being attracted by another mass (which is
not affected by the first object’s mass, in order to simplify the example).
See Figure 14:
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 16 de 24
Figure 14: Error accumulates as steps are simulated for a case 1 example
Figure 14 shows how error due to setting gravity as constant accumulates step by step. Imagine that the error
tolerated for this exercise was that the distance between the simulation and a ‘real’ measure were not to exceed the
500 kilometers limit. After the first step, the error was only 50 kms, and was still tolerable for this simulation. After
the second step, the combination between the previous error accumulation and the actual step’s error made it
increment to 200kms, a still tolerable value. But in the third step, the error accumulation produced a position error of
1000kms and the simulation could not be considered accurate anymore.
Obviously, in this visual example, error was exaggerated. Modern computational capacity allows relatively fast
simulations at an extremely low error rate. In some cases it could take very large amount of steps until the error
accumulation could be considered significant.
However, it’s important to notice that, given that this is still a finite differential method, all simulations end up in
significant error in some n-quantity of steps, independent of the time differential selected.
There are, nonetheless, several ways to strongly reduce error accumulation using mathematical methods such as
euler and runge-kutta methods which are implemented in IPE and can be selected by the user. These methods will be
explained later in this manual.
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 17 de 24
IPE provides a way to estimate the absolute value of the error, and therefore evaluating if the simulation has suffered
significant accumulation. Since we are simulating a closed system, energy must be conserved thorough the whole
simulation.
You can obtain the total system’s energy as the sum of all the individual potential and kinetic energies at the
beginning of simulation (when we know that error E is equal to zero). Then at each step you can recalculate the sum
of those energies.
Figure 15: Shadowed area shows possible deviations of the energy due to error accumulation
As you can see on Figure 15, a real measurement is expected to show a constant energy thorough the whole
experience time, but since the error in the simulation tends to accumulate, the total energy measurement tends to
diverge as well. Energy divergence is then, a good indicative of error accumulation:
tTTtE 0)(
Where E(t) is the error accumulation at a t moment, To is the total energy at the beginning of simulation and Tt is
the total energy at the t moment.
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 18 de 24
4. Gravitation, Electric and Magnetic forces.
The Icarus Physics Engine (IPE) is able to simulate gravitation, electric and magnetic interactions between the
simulated bodies. It can even simulate a system where the three kind of forces (in this software, we deliberately
separate electromagnetic force into two, for technical reasons), at the same time if these bodies have mass and
charge and the user wants both of them to affect the simulation.
The interactions between objects, uniform electric/magnetic, and electrically induced magnetic fields can be set as a
list of rules, as example:
Object Is affected by Through the following force
Object 1 Object 2 Gravity
Object 2 Object 1 Gravity
Object 1 Magnetic Field 1 Magnetism
This way, the user has the total control of the interactions included in the simulation.
The way IPE simulates each force is explained in the following paragraphs:
4.1 Gravitation Forces
The Icarus Physics Engine calculates the forced produced by the attraction between to bodies with mass in the space
(x,y,z) using the Newton's law of universal gravitation.
where:
F is the magnitude of the gravitational force between the two point masses,
G is the gravitacional constant*
m1 is the mass of the first point mass,
m2 is the mass of the second point mass, and
r is the distance between the two point masses.
*The default value for G is:
And can be edited by the user.
As IPE uses vector values for position, velocity and acceleration, the attraction force produced for its calculations
must be obtained as a vector force as well, using the following formula:
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 19 de 24
4.2 Electric Forces
The Icarus Physics Engine calculates the force produced by the attraction/repulsion between to charged bodies in the
space (x,y,z) using the Coulomb's law.
where:
F is the magnitude of the electric force of attraction/repulsión between the two point charges,
Ke is the Coulomb constant
q1 is the charge of the first particle,
q2 is the charge of the second particle,
r is the distance between the two point masses and,
is the unit vector pointing from the particle with charge q to the E-field evaluation point,
*The default value for Ke is:
And can be edited by the user.
As IPE uses vector values for position, velocity and acceleration, the attraction/repulsion force produced for its
calculations must be obtained as a vector force as well, using the following formula:
Where
Eo is the electric constant*
*The default value for Eo is: 8.854187817...×10−12
A·s/(V·m) = 8.854187817...×10−12
F/m
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 20 de 24
4.3 Magnetic Forces
The Icarus Physics Engine calculates the force produced by the action of a magnetic field (B) on a charged body (q)
in the space (x,y,z) using the Lorentz force equation.
where:
B is the vector intensity of the magnetic field
v is the vector velocity of the affected particle
q is the charge of the affected particle,
As IPE uses vector values for position, velocity and acceleration, the attraction/repulsion force produced for its
calculations must be obtained as a vector force as well, and the Lorentz force equation provides it
Note that, in difference with the other interactions where the force had the direction of the unit vector uniting both
objects position, the magnetic field produces a force that is perpendicular both to the velocity and direction of the
field. Icarus is an excellent way to learn about this phenomenon as you can clearly see the perpendicularity of the
resulting force.
4.4 Time differential commit operation
Once all the rules from the IPE list of rules were calculated, the resulting force (Fr) over any ‘k’ object is the vector
sum of all the individual gravitational/electric/magnetic forces from the other objects/fields working over this k
object:
n
i
ikk FF0
Having the resulting force on the object, the only thing we need to do to obtain the vector acceleration is by dividing
it by the object’s mass:
i
ii
m
Fa
Once we have all the acceleration vectors for all the objects in the simulation, IPE applies the formula 5 (using ‘a’ as
g) for each of them and commits the time differential.
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 21 de 24
5. Optimization methods
The Icarus Physics Engine allows the user to choose between three modes of solving finite differential simulations.
5.1 Non Optimized Mode
This is the faster mode and takes only one calculation unit from each step.
If the user chooses the non-optimized mode, the simulation will use the rectangular approach as seen on figure 9.
The area under the field’s function will be estimated by using a sum of the area of a finite number of rectangles
whose lengths will be the time differential and their heights are the value of the function at the initial point.
This mode produces much more information loss than the optimized modes and is recommended for simulations
where the performance is much more important than the error accumulation.
Figure 16: Non Optimized Mode
5.2 n-Step Euler Method
This is the most explicit and simple method for numeric integration for differential equations. The idea behind it is
that we can use 2 or more calculation units per step to increase its precision with less information loss than with
increasing the steps per unit of time (in other words, decreasing the time differential).
We can generalize the Figure 16 case as a 1-step euler’s method approximation. Now, instead of going ahead with
the next time differential, we can apply another calculation unit using a 2-step euler’s method. This is done by re
evaluating the constant variable (acceleration) at the middle of the estimation and re calculating it. The result would
be the following figure:
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 22 de 24
Figure 17: n-step Euler approximation method
The idea behind the 2-step euler method is that, the acceleration is re-evaluated in function of the position that the
object would have at the half of the time differential. Then a correction in the slope of the velocity will occur at Δt/2.
In the 3-step euler method, the re-evaluation occurs two times, one at the third and the other at the second third of
the time differential.
A good balance between euler steps per time differential and time differential duration could greatly improve
precision at very low performance cost.
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 23 de 24
5.3 Runge-Kutta Method
This is the most efficient performance/accuracy method for numeric integration for differential equations. It is based
on four steps, each one using the results obtained from the previous.
Defining an initial problem as:
The approximated solution is defined as:
Where:
This way, the following value (yn+1) is determined by the current value (yn) plus the product of an interval (h) and
an estimated slope. This slope is obtained as the average of the following weighted slopes:
k1 is the slope at the beginning of the interval.
k2 is the slope at the middle of the interval, using k1 to determine the value of y in the Tn + h/2 point using euler’s
method
k3 is again the slope evaluated at the middle of the interval but using k2 to determine the value of y
k4 is the slope at the end of the interval using k3.
Making an average of the four and assigning more importance to the two in the middle (k2 and k3), we obtain the
runge-kutta estimated slope:
The following figure shows graphically how the runge-kutta approximates to a very accurate slope in four steps.
Icarus Version: 1.0
Manual 1 - Basic Engine Operation Date: 03/06/2010
Universidad Nacional de La Matanza - 2010 Page 24 de 24
Figure 18: Runge-Kutta Method