# Differentiation & Integration

## Recommended Posts

marcus12    329
Hi, I am going through physics & maths modules, where I am seeing lot of mathematics. I have some doubts about differentiation and integration like: Differentiation - (I understand)It gives rate of change, eg: ball is moving then to get new position at time 't' ( ds/dt = dv) we do like .. present_position = old_position + dv * dt; Where all it can be used? Also what is the difference and when it is useful to use: -> Ordinary differential equation -> Partial differential equation Integration - (I understand)It is used to add up all the parts. But dont know exactly when and where is it applicable in game application? What is the difference between Explicit integration and Implicit integration, and where it is more useful? All suggestions are welcome...

##### Share on other sites
DanielH    138
Your question is phrased a bit strange. You are asking about when differentiation and integration can be used?

Differentiation and integration are the fundamentals of analysis. It's used in uncountable number of theorems and applications.

* Differentiation
You just gave an example where differentiation can be used: To find the velocity of an object!

Differentiation is used to find the rate of change in a function. Normally it is a continuous function are differentiation, but when you are doing calculations in games such as finding out velocities you are often doing discreet differentiations.

* Integration
You actually gave and example of integration as well:

present_position = old_position + dv * dt

This is a simple sort of numeric integration called Euler integration. You integrate the position over time.

Integration can be thought of a continuous version of the discreet summation. You can integrate different kind of areas and volumes, but there are many other uses for it.

##### Share on other sites
fng    154
Don't mix up differentiation and differential equations!

* Differentiation is the process of calculating the rate of change.

* Differential equations are formulas that describe something with regard to the change of some variables (e.g. p = v_0 + v * t expresses the position with regard to the velocity).

* ordinary differential equations (ODE):
Most problems in mechanical physics (e.g. rigid body dynamics) can be expressed as these. As games try to use "real" mechanics a lot, these kinds of equations quite often pop up when dealing with the physics simulation.

Solver: Euler integration (very simple and intuitive), Runge-Kutta-Methods (better precision, a bit more complicated). Implicit solver are harder to implement as you need to solve a (sometimes non-) linear system of equations. You need them for so called "stiff ODEs". For games a simple explicit solvers are usually sufficient as they are usually faster.

* partial differential equations (PDE):
Are often used to describe fluid dynamics (e.g. water going through soil, heat distribution). They are harder to understand compared to ordinary differential equations. There are also different kinds of very PDEs which have different algorithms for solving them.

Solver: Finite Element Methods that divide the area in smaller chunks and solve the equations on the resulting smaller grids.

* Integration is also sometimes referred to solving a differential equation. Other than that it can also be interpreted as computing the area between the function an the time-axis.

##### Share on other sites
DanielH    138
Haha I know realize I should never write anything in the math forum.

##### Share on other sites
daviangel    604
What level of math have you completed?
-> Ordinary differential equation
-> Partial differential equation
Will both be Greek to you if even if you have studied Calculus as I have since they are advanced topics and I doubt they can be adequately explained in a forum post.
You can try watching some iTunes university video's on the subject if you are serious.
Anyways, basically from what I remember of Calc a derivative in simplest terms is the slope of the tangent line and an Integral is the area under a curve.
If you take a Calculus Physics course you'll learn of countless examples where you need to use all this higher level math is all I can say.

##### Share on other sites
Eric_Brown    127
marcus,

I think I felt a similar confusion when I first started delving into the world of computational physics simulation.

My confusion came from the fact that the process was called "integration", but the method of integration seemed more like taking a derivative.

For instance, you give an example of a differentiation:

Quote:
 Differentiation - (I understand)It gives rate of change, eg: ball is moving then to get new position at time 't' ( ds/dt = dv) we do like .. present_position = old_position + dv * dt;

but the expression "present_position = old_position + dv * dt" would actually be termed integration.

When you approximate calculus with finite differences, the operations of differentiantion and integration are encoded in the standard algebraic operations of addition, subtraction, multiplication and division. With this encoding, you can kind of think of a derivative as being associated with division, and an integral as being associated with multiplication.

For example, the approximation of a derivative can be expressed like this

$v=\frac{ds}{dt}\approx\frac{s(t+\Delta t)-s(t)}{\Delta t}$

Which incorporates a division. Integrating the previous equation amounts to multiplying both sides by Δt

$\int_t^{t+\Delta t}v\,dt \approx v\Delta t = s(t+\Delta t) - s(t)$

You can rearrange this expression to get the equation that you were referencing.

So, in the end, even though they are basically the same relationship, if the equation is in this form

$v=\frac{s(t+\Delta t)-s(t)}{\Delta t}$

it is a derivative. If the equation is in this form

$v\Delta t = s(t+\Delta t) - s(t)$

it is an integral.

Once I came to grips with this, I overcame my confusion about terminology.

##### Share on other sites
Lascha    122
In game programming integration commonly with updating positions every timestep. Using some calculus you can derive derive formulas so that you'll be able to calculate the position at any given time.
- An example that my lecturer told me is passing a football to a player that is running. In order to make it look realistic, you'll have to know at what angle the ball has to be shot in order to reach the running players' future position.
- Another example, based on the same principle, is an AI enemy that wants to cleverly chase you. A stupid AI enemy would simply move towards your current position, whereas a smarter AI enemy would know your position in future and cleverly move towards the closest point of intersection.