PACIFIC COMP 155 - Calculus Based Techniques

Unformatted text preview:

COMP155Computer SimulationNovember 3, 2008Basic Concepts of Calculus Derivative – rate of change of a function Integral – area under the curve of a functionDerivative is the slopeImage from http://en.wikipedia.org/wiki/DerivativeExample: velocity and acceleration This curve represents velocity over time.What does acceleration look like?Acceleration is slope of velocity Velocity is blue, acceleration is redExample 2: Velocity Velocity(t) = -t2/2 + 10t + 70Example 2 Velocity is blue, acceleration is red70102)(2++−= tttv2tta−=10)(Example 3 Green curve is distance, what is velocity?Example 3 Green is position, blue is velocityExample 3 What is happening to green curve when blue curve crosses zero?The derivative is zero when function is at a local minimum or maximumExample 3 Position (green), velocity (blue), acceleration (red)Integral is the areaImage from http://en.wikipedia.org/wiki/IntegralExample: Integration Velocity is blue, acceleration is red+ area- areaExample: Integration Red line is acceleration, what is velocity?- area+ areaIntegration Requires Init Values Accumulated area gives shape, initial conditions locate shapeThese are both correct velocity curves, for given acceleration curveExample 2: Integration position at t=0 is 100,position at t=25 is 150What is position at t=50?Example 2: Integration position at t=0 is 100,position at t=25 is 150What is position at t=50?answer: 200This area must be 50.This area is also 50.Fundamental Theorem of Calculus f is a continuous real-valued function defined on a closed interval [a, b],  F is an anti-derivative of f:  F’ = f,the definite integral offover that interval is the definite integral offover that interval is given by differentiation is the reverse of integration∫−=baaFbFdxxf )()()(Fundamental Theorem of CalculusWhatever the shape of the velocity curve, we can determine its area in some interval from the position values at the ends of that interval.green = position∫−−−=5.25.2)5.2()5.2()( ppdxxvgreen = positionblue = velocityCalculus in Simulation We’ll commonly have a derivative of some function(or instantaneous values of the derivate)and need to construct values for the functionand need to construct values for the function Example: We know velocity, need to compute position Example: We know acceleration, need to compute velocity and positionTime Slicing Simulation is updated at regular interval in time dt = time step/sliceTo approximate integration:To approximate integration: compute derivative at time steps make assumption about derivative value at other times accumulate area to approximate integrationTime slice approximation dt = 1, assume current value held for previous time sliceblue: correct derivative functionover-estimate of positive functionred: approximated derivative functionunder-estimate of positive areaover-estimate of negative areaof positive areaunder-estimate of negative areaTime slice approximationdt = 1green: correct positionred: approximated positionTime slice approximationdt = 1green: correct positionred: approximated positionSmaller dt  better approximationdt= 1dt= 0.5dt= 1dt= 0.5dt = 0.1dt = 0.01Smaller dt  better approximationdt= 1This is similar to the limit in the definition of a derivative:hafhafafh)()(lim)('0−+=→dt= 1dt = 0.1The time slice is h.As it gets smaller, we get closer to the true value of the derivative.hh0→Time slice approximationdt= 1We’ve rewrittento getdttfdttftfdt)()(lim)('0−+=→dt= 1dt = 0.1to get(actually, we’re using))(')()( tfdttfdttf⋅+=+)(')()( dttfdttfdttf+⋅+=+Euler’s Method Taylor Series:as dt0, the higher order terms quickly ...)(''')('')(')()(32+⋅+⋅+⋅+=+ tfdttfdttfdttfdttfas dt0, the higher order terms quickly approach 0, giving our approximation The higher order terms are the error in the approximation)(')()( tfdttfdttf⋅+=+Instantaneous Derivative Values In interactive simulations, we often do not have a function for the derivative, rather we have instantaneous values for the derivativeExample: driving simulationExample: driving simulationacceleration value is set by driver’s joystick Euler’s method can still be applied (twice)to compute velocity and position assume that current value of acceleration was constant through previous time stepExample: Vehicle Dynamics Acceleration is set by user Function updates velocity, then positionvoid Vehicle::update(double elapsed_time){{double dt = elapsed_time/1000.0;velocity += acceleration*dt;double vx = velocity*sin(heading);double vy = velocity*cos(heading);double x = position.getX() + vx*dt;double y = position.getY() +


View Full Document

PACIFIC COMP 155 - Calculus Based Techniques

Download Calculus Based Techniques
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Calculus Based Techniques and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Calculus Based Techniques 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?