A community for students.
Here's the question you clicked on:
 0 viewing
gerryliyana
 2 years ago
Use of numerical integral method to calculate the length of the path has traversed the car during the time recording below
gerryliyana
 2 years ago
Use of numerical integral method to calculate the length of the path has traversed the car during the time recording below

This Question is Closed

Patapom
 2 years ago
Best ResponseYou've already chosen the best response.2Don't you have more informations concerning the method of interpolation of the velocities ? Is this linear interpolation ?

Patapom
 2 years ago
Best ResponseYou've already chosen the best response.2Well, assuming linear interpolation of velocities, you can write: \[V(t) = V0 + (V1V0) t\]\[D(t) = \int\limits\limits_{0}^{t}v(x).x.dx\] Here, V0 and V1 are 2 consecutive values in your array. Like 124 and 134 for the first 2 values. D(t) is the distance you went through during time t. For this particular example of yours, we're going to always use t=6 because your time steps are constant and always equal 6 seconds. I used http://integrals.wolfram.com/index.jsp?expr=a+x+%2B+b+x%5E2&random=false to perform the integral (although it's very easy to write it yourself) so we find that: \[D(t) = \int\limits\limits_{0}^{t}v(x).x.dx\ = \left[ \frac{ V0 }{ 2 } t^2 + \frac{ V1V0 }{ 18 } t ^{3} \right]\] When solving for D(6) (t varying in [0,6]) we get: \[D(6) = 18 V0 + 12(V1V0) = 12 V1 + 6 V0\] All you need to do next is to write a loop that sums \[12 V1 + 6 V0\] for all you time intervals. It goes like: float SumDistance = 0; for ( int TimeStepIndex=0; TimeStepIndex < TimeValuesCount1; TimeStepIndex++ ) { float TimeStepDistance = 6 * Velocities[TimeStepIndex] + 12 * Velocities[TimeStepIndex+1]; SumDistance += TimeStepDistance; }

Patapom
 2 years ago
Best ResponseYou've already chosen the best response.2Sorry, my first equation should read: \[V(t) = V0 + \frac{ V1  V0 }{ 6 } t\] because starting from V0 at t=0 second, we only reach V1 after 6 seconds...

Patapom
 2 years ago
Best ResponseYou've already chosen the best response.2If the actual assignment was to perform numerical integration using many small time steps then I suppose my solution is wrong, instead you should go all code and write something like: int IntegrationStepsCount = 1000; // The more you use, the more precise it will get, but never as precise as an analytical integration obviously... float SumDistance = 0; for ( int TimeStepIndex=0; TimeStepIndex < TimeValuesCount1; TimeStepIndex++ ) { float TimeStepDistance = 0; float StartVelocity = Velocities[TimeStepIndex]; float EndVelocity = Velocities[TimeStepIndex+1]; float IntegrationStepSize = 6.0 / IntegrationStepsCount; for ( int i=0; i < IntegrationStepsCount ; i++ ) { float CurrentVelocity = StartVelocity + (EndVelocity  StartVelocity) * i / IntegrationStepsCount; TimeStepDistance += CurrentVelocity * IntegrationStepSize; // Distance += Velocity * DeltaTime } SumDistance += TimeStepDistance; } This is a purely numerical integration...
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.