Predicting Movement Time

• May 3rd 2013, 08:38 AM
CakeSpear
Predicting Movement Time
Hi
I have a moving Ball
- The Ball moves at speed V
- The Ball has an InitialSpeed V_i
- The Ball has a TargetSpeed V_t

Every second:
- Ball is displaced V number of pixels
- V is multiplied by deacceleration D ( D is a number between 0 - 1 )

...
I need an expression, returning how many seconds it takes before V reaches TargetSpeed V_t ( V_t is allways lower or equal to V_i )
( Time is integer only )

...
Im quite rusty when it comes to math, but i think i know where to start with this:

V_i * ( D )^x <= V_t

Now i need to isolate the X?
However im not sure how to do that, or if this is what i need to do at all.
Pleace correct me if im wrong.
• May 3rd 2013, 10:32 AM
emakarov
Re: Predicting Movement Time
Quote:

Originally Posted by CakeSpear
i think i know where to start with this:

V_i * ( D )^x <= V_t

This is correct. If $\displaystyle V_i$ and $\displaystyle V_t$ are positive, then this inequality is equivalent to $\displaystyle D^x\le\frac{V_t}{V_i}$, and the first integer x for which this holds is $\displaystyle \left\lceil\log_D\left( \frac{V_t}{V_i}\right) \right\rceil$ where $\displaystyle \lceil\cdot\rceil$ is the ceiling function. Note that $\displaystyle \log_D\left(\frac{V_t}{V_i}\right)=\log_D V_t-\log_D V_i$ and $\displaystyle \log_D z=\frac{\log_bz}{\log_bD}$ for any positive z and base b. For b = e you get natural logarithm ln(), and for b = 10 you get common logarithm often denoted by lg().
• May 3rd 2013, 11:17 AM
ebaines
Re: Predicting Movement Time
cakespear - you asked this exact same question 2 days ago and it was answered then - see:

http://mathhelpforum.com/math/218442...get-speed.html.

If you need any clarification regarding the answer provided then please ask about it with follow-up on the original thread.
• May 3rd 2013, 01:56 PM
CakeSpear
Re: Predicting Movement Time
Ebaines
First of all, thank you for helping me with the other problem i had "Predicting Target Speed", much appreciated.

However this is clearly not the same question although the formulation of the problem is similar.
The Topics are not the same, the question i ask in the posts are not the same.
Time is not the same as Speed.
Theese are two different questions.

Im not sure about the posting culture around here, but since i had a different question, i created a new Thread.

...
Emakarov
I cant believe i got that correct, i hope im slowly getting the right mindset for this stuff! :)
Ah i see, so by multiplying with Log on both sides, the exponential x is removed.

Im not sure how or why the Tall Pins come into play however...?
As a programmer i do know what a Ceiling function is ( rounds a decimal number up ), but i dont know if this is the same as the Tall Pins.

"This is correct. If V_i and V_t are positiv"
The equation needs to work for two different situations

1
V_i and V_t are both positive

2
V_i and V_t are both negative

...
Anyways, ill play around whith this and post back how it turns out
• May 4th 2013, 02:57 AM
emakarov
Re: Predicting Movement Time
Quote:

Originally Posted by CakeSpear
Ah i see, so by multiplying with Log on both sides, the exponential x is removed.

To put it correctly, we apply (not multiply by) logarithm on both sides.

Quote:

Originally Posted by CakeSpear
Im not sure how or why the Tall Pins come into play however...?
As a programmer i do know what a Ceiling function is ( rounds a decimal number up ), but i dont know if this is the same as the Tall Pins.

The equality $\displaystyle D^x=V_t/V_i$ is equivalent to $\displaystyle x = \log_D(V_t/V_i)$ without rounding. But you said that in your situation x is an integer, and the right-hand side does not have to be an integer. For example, if $\displaystyle \log_D(V_t/V_i)=3.2$, then $\displaystyle D^3$ is still greater than $\displaystyle V_t/V_i$, but $\displaystyle D^4$ is already smaller than $\displaystyle V_t/V_i$ (since 0 < D < 1). That's why I said that the first x such that $\displaystyle D^x\le V_t/V_i$ is obtained by rounding up the logarithm.

Quote:

Originally Posted by CakeSpear
The equation needs to work for two different situations

1
V_i and V_t are both positive

2
V_i and V_t are both negative

This way of finding x works if both $\displaystyle V_i$ and $\displaystyle V_t$ are negative. In this case, multiplying $\displaystyle V_i$ by D makes it larger, though it makes its absolute value smaller. Therefore, you are looking for the first x such that $\displaystyle V_iD^x\ge V_t$. After dividing by a negative $\displaystyle V_i$, which changes the direction of the inequality, we get the same $\displaystyle D^x\le V_t/V_i$.
• May 6th 2013, 05:05 AM
ebaines
Re: Predicting Movement Time
OK, I missed the nuance that you are asking for the time to reach target speed, as opposed to distance covered. But actually in the other post I provided that calculation, as I used it to derive the distance. If you check the other post you'll see that the formula is:

$\displaystyle T = \frac {\ln (V_T/V_i)} {ln D}$
• May 7th 2013, 01:03 AM
CakeSpear
Re: Predicting Movement Time
I did end up with alsmost the same solution as you:

V_i * ( D )^x <= V_t
( divide by V_i )
( D )^x <= V_t / V_i
( apply Log )
Log( D )*x <= Log( V_t / V_i )
( divide by Log )
x <= Log( V_t / V_i ) / Log

Log( V_t / V_i ) / Log is the answer and gives the correct output, both for possitive and negative V_i V_t, in my test application!

Im guessing i could just do the exact same thing with Ln as i did with Log, not sure what the difference is.
Im guessing inverse of ^ is both Log and Ln...?

Anyways, Emakarov and Ebainese, thank you for getting me this far!
• May 7th 2013, 11:08 AM
emakarov
Re: Predicting Movement Time
Quote:

Originally Posted by CakeSpear
V_i * ( D )^x <= V_t
( divide by V_i )
( D )^x <= V_t / V_i
( apply Log )
Log( D )*x <= Log( V_t / V_i )
( divide by Log )
x <= Log( V_t / V_i ) / Log

Two remarks about this solution. First, Log is a function while, e.g., Log( V_t / V_i ) is a number (the result of applying Log to V_t / V_i). As a programmer, you should appreciate the difference between values of different types. The type of Log is something like (float -> float), while the type of Log(D) is float. In particular, you can't divide by Log, but you can divide by Log(D).

Second, since D < 1, Log(D) is negative. I am guessing that this is logarithm to base 10. See its graph here. Logarithms to other bases are obtained by multiplying this function by a constant. So, since Log(D) < 0, when you divide Log( D )*x <= Log( V_t / V_i ) by Log(D), the direction of the inequality reverses to give x >= Log( V_t / V_i ) / Log(D). That's why the first integer solution x is Ceiling(Log( V_t / V_i ) / Log(D)).

Quote:

Originally Posted by CakeSpear
Im guessing i could just do the exact same thing with Ln as i did with Log, not sure what the difference is.
Im guessing inverse of ^ is both Log and Ln...?

Yes, $\displaystyle \log_b(x^p) = p \log_b (x)$, which is the identoty you used in your solution, holds for all bases b (of course, logarithm is only defined when the base is positive and different from 1). If Log is logarithm to base 10, then Log(y) is the inverse of y = 10^x, and Ln(y) is the inverse of y = e^x where e ≈ 2.718 is Euler's number.
• May 7th 2013, 12:50 PM
CakeSpear
Re: Predicting Movement Time
Emakarov, most of your sentances are like bullets burning holes straight through my brain.
Im not saying i dont appreciate the bullets.

Two remarks about this solution. First, Log is a function while, e.g., Log( V_t / V_i ) is a number (the result of applying Log to V_t / V_i). As a programmer, you should appreciate the difference between values of different types. The type of Log is something like (float -> float), while the type of Log(D) is float. In particular, you can't divide by Log, but you can divide by Log(D).

Out of curiosity, are you saying Log is an undefined float( 10^x ? ) existing somewere within a specific range?
I know i can easily google Log and find out what it is, but i ask anyway ( i see you have explained it below already ).

And sorry about the typo, i meant to say i divided by Log( D ) and not Log alone.

V_i * ( D )^x <= V_t
( divide by V_i )
( D )^x <= V_t / V_i
( apply Log )
Log( D )*x <= Log( V_t / V_i )
( divide by Log( D ) )
x <= Log( V_t / V_i ) / Log( D )

Second, since D < 1, Log(D) is negative.
So, since Log(D) < 0, when you divide Log( D )*x <= Log( V_t / V_i ) by Log(D), the direction of the inequality reverses to give x >= Log( V_t / V_i ) / Log(D).

However, and to my surprise, the solution to my problem was solely the right side of the inequality.
What i mean is it didnt matter at all if it was x <=, x= or x>=, the right side of the equation/ inequation was what mattered and gave the correct return.
In a pure mathematical context i do understand that this matters much, and i vaugely remember now how an inequation sometimes(?) switches sides when multiplying or dividing ( from early school ).

Yes, \log_b(x^p) = p \log_b (x), which is the identoty you used in your solution, holds for all bases b (of course, logarithm is only defined when the base is positive and different from 1). If Log is logarithm to base 10, then Log(y) is the inverse of y = 10^x, and Ln(y) is the inverse of y = e^x where e ≈ 2.718 is Euler's number.

Ah, im starting to remember this, Log is 10 based, Ln is e based, thanks for explaining :D
And ill have to read about this Euler and his number ( e ), gave it a quick look and sounds crazy
• May 7th 2013, 01:28 PM
emakarov
Re: Predicting Movement Time
Quote:

Originally Posted by CakeSpear
Out of curiosity, are you saying Log is an undefined float( 10^x ? ) existing somewere within a specific range?

No, Log is not of type float. The type of functions from float to float is distinct from the type of float, and values of different types are not directly comparable (without coercing one value to a different type); they are different entities, just like apples and oranges.

Quote:

Originally Posted by CakeSpear
However, and to my surprise, the solution to my problem was solely the right side of the inequality.
What i mean is it didnt matter at all if it was x <=, x= or x>=, the right side of the equation/ inequation was what mattered and gave the correct return.

If you are solving the equation V_i * ( D )^x = V_t, then the answer is x = Log( V_t / V_i ) / Log( D ). If you are solving the inequality V_i * ( D )^x <= V_t, then the answer is x >= Log( V_t / V_i ) / Log( D ). This matters if you need to find an integer x. The equation may not have an integer solution. If you round the right-hand side to an integer, you need to understand how this rounded value relates to the original problem. In the case of inequality you know that any x >= Log( V_t / V_i ) / Log( D ) satisfies the original inequality, so you can round Log( V_t / V_i ) / Log( D ) up. If you round it to the nearest integer (which may round it down sometimes), it will still be an approximate solution, but it won't answer the original question: "How many seconds it takes before V reaches TargetSpeed V_t?" (the speed at moment x may still be greater that V_t).