# How do I solve for time?

Started by Aj37, Oct 02 2001 01:30 AM

26 replies to this topic

Sponsor:

###
#2
Members - Reputation: **122**

Posted 02 October 2001 - 02:41 AM

Hi,

here''s my solution:

y = -1/2gt^2 + vt +yi // - y

0 = -1/2gt^2 + vt + yi -y

//abc formula??? (I don''t know the English name)

t1= -v/(2*(-1/2g)) + sqrt( (v/(2*(-1/2g)))^2 -((yi-y)/(-1/2g)) )

t1= v/g + sqrt( v^2/g^2 + (yi-y)/(1/2g) )

t2= -v/(2*(-1/2g)) - sqrt( (v/(2*(-1/2g)))^2 -((yi-y)/(-1/2g)) )

t2= v/g - sqrt( v^2/g^2 + (yi-y)/(1/2g) )

cLE

here''s my solution:

y = -1/2gt^2 + vt +yi // - y

0 = -1/2gt^2 + vt + yi -y

//abc formula??? (I don''t know the English name)

t1= -v/(2*(-1/2g)) + sqrt( (v/(2*(-1/2g)))^2 -((yi-y)/(-1/2g)) )

t1= v/g + sqrt( v^2/g^2 + (yi-y)/(1/2g) )

t2= -v/(2*(-1/2g)) - sqrt( (v/(2*(-1/2g)))^2 -((yi-y)/(-1/2g)) )

t2= v/g - sqrt( v^2/g^2 + (yi-y)/(1/2g) )

cLE

###
#3
Moderators - Reputation: **1361**

Posted 02 October 2001 - 06:44 AM

Yes, we call it the "quadratic" formula:

if At

then

See, there are

You would choose the t that is physically consistent. For example, it might not make sense to choose a value of t that is negative.

So in this case just set:

A = -1/2g

B = v

C = yi - y

Something for you to think about...what if B^2 - 4AC is negative?

Graham Rhodes

Senior Scientist

Applied Research Associates, Inc.

if At

^{2}+ Bt + C = 0then

t = (-B + sqrt(B^{2}- 4AC)) / (2A)or

t = (-B - sqrt(B^{2}- 4AC)) / (2A)

See, there are

**two**possible values of t.You would choose the t that is physically consistent. For example, it might not make sense to choose a value of t that is negative.

So in this case just set:

A = -1/2g

B = v

C = yi - y

Something for you to think about...what if B^2 - 4AC is negative?

Graham Rhodes

Senior Scientist

Applied Research Associates, Inc.

###
#5
Members - Reputation: **374**

Posted 02 October 2001 - 10:01 AM

Or you can use Polysolve on a TI-85/86

Free Speech, Free Sklyarov

Fight the unconstitutional DMCA.

Commander M

Free Speech, Free Sklyarov

Fight the unconstitutional DMCA.

Commander M

###
#7
Moderators - Reputation: **1361**

Posted 03 October 2001 - 07:39 AM

quote:Original post by Beer Hunter

grhodes_at_work: If b^2 - 4ac is negative, there are no real solutions. Or was that question intended from a programming perspective?

Your answer is basically what I was hoping to hear, although I was also wanting to point out that this situation is something to check for, at least during development and debugging.

There is another part to the question, something to think about not necessarily to answer. For the

**equation, is there a physical interpretation of a non-real ("imaginary" or "complex") solution? I mean, you could plug in seemingly "legal" values for g, v, yi, and y that would result in an imaginary value for t:**

*given*v = 0 (object not currently moving)

g = 9.8 (yes, its gravity)

yi = 0 (object started at yi = 0)

y = 1 (object is currently at y = 1)

yields:

A = -9.8/2 = -4.9

B = 0

C = 0 - 1 = -1

So, b

^{2}-4AC = 0*0 - 4*(-4.9)(-1) = -19.6

which requires we deal with sqrt(-19.6)

Is it *possible*, for the given equation, to have a situation that results in an imaginary time value? Are the example values above "legal"?

Please excuse me if that sounds like a math teacher equation. It really *is* one of those.

Graham Rhodes

Senior Scientist

Applied Research Associates, Inc.

Edited by - grhodes_at_work on October 3, 2001 2:49:34 PM

###
#9
Moderators - Reputation: **1361**

Posted 04 October 2001 - 04:27 AM

quote:Original post by Beer Hunter

An object starts from rest at position = 0, and accelerates forwards at 2m/s. At what time will it be at position = -1?

Yes, exactly! The values I gave are not "legal" for the equation. They are not compatible with the assumptions used to derive the equation.

But if you''re simulating systems with oscillatory modes, such as systems with springs that have vibration modes, *then* complex/imaginary numbers do appear. They can be used to represent periodic solutions.

Graham Rhodes

Senior Scientist

Applied Research Associates, Inc.

###
#11
Moderators - Reputation: **1361**

Posted 05 October 2001 - 09:43 AM

quote:Original post by Beer Hunter

Which sort of systems? I've only looked at SHM and UCM in my physics class, and I don't think you can get complex results with those, except for invalid cases. Or am I looking in the wrong place?

Actually, SHM (for example) *is* part of a complex result! Or at least complex variables can be used to achieve the equations for SHM. Its just rarely presented that way until you get into the theory of vibrations or control systems. But here is how it works.

The fundamental equation of motion is Newton's second law,

F = m*a = m*(d^{2}s/dt^{2})

Here, s is the displacement, and so acceleration a is the second derivative of displacement in time.

lets suppose that the force F is actually a spring force, which for a linear spring is defined as:

F = -k*s

where k is the stiffness of the spring. And the spring force acts to restore displacement to zero. (I'm considering here a mass that oscillates about an initial position of s = 0, but the equation is similar for other systems.)

Then from Newton's law and the spring equation we can write the equation of motion for our mass and spring:

-k*s = m*(d^{2}s/dt^{2})

We'd like to solve for s. How do we do it, given that we have a derivative of s on one side and just s on the other side? When F was a constant m*g/2 we could just integrate twice to get an equation for s, and that's exactly how we get the quadratic equation form for s.

In this case, we can't simply integrate. We have to solve this ordinary differential equation some other way. And the way to do it is to assume a form for s. We're going to assume s is:

s = A*exp(i*omega*t)

where A is an unknown constant, i is sqrt(-1), omega is an unknown constant, and t is time.

Now, there's magic in that exp(i*omega*t). From complex number theory, it is true that:

ds/dt = A*i*omega*exp(i*omega*t)

and

d^{2}s/dt^{2}= A*i^{2}*omega^{2}*exp(i*omega*t)

or, since i^{2}= -1,

d^{2}s/dt^{2}= -A*omega^{2}*exp(i*omega*t)

And we can simply plug those into our equation of motion to get:

-k*A*exp(i*omega*t) = -m*A*omega^{2}*exp(i*omega*t)

Now if you look at this you'll see that A*exp(i*omega*t) can be divided out to get:

-k = -m*omega^{2}

or

omega = sqrt(k/m)

Then we know part of our solution s:

s = A*exp(i*sqrt(k/m)*t)

Now, there's still more magic in that exp() term. In complex number theory, it is true that:

exp(iX) = cos(X) + i*sin(X)

So the exponential of a complex number is equal to a complex harmonic function! And,

s = A*cos(omega*t) + i*A*sin(omega*t)

So omega turns out to be the frequency of oscillation, in radians/unit time.

*That* is the complex equation of harmonic motion for a mass connected to a spring. Note that A is determined by plugging in initial conditions (e.g., s = 0 when t = 0) and solving for A.

For determining the *real* position of the object s, you don't need the imaginary component. Just drop the imaginary component to get the SHM solution.

When combined with A, which can be complex, the imaginary component really models a time lag, for example, if you had two masses oscillating out-of-phase.

Note that if A = i, then the real part of s will have the sin() function instead of the cos() function.

So, that's way off topic but it actually is the starting point for understanding how to simulate more interesting systems. If you were to add in a damping force you could follow this same procedure, with just a slightly different assumed form for s. This kind of analysis becomes important when you are concerned about the stability of a simulation of, say, soft bodies.

Graham Rhodes

Senior Scientist

Applied Research Associates, Inc.

Edited by - grhodes_at_work on October 5, 2001 4:51:04 PM

Edited by - grhodes_at_work on October 5, 2001 4:51:52 PM

###
#14
Moderators - Reputation: **1361**

Posted 08 October 2001 - 09:30 AM

quote:Original post by Beer Hunter

That... almost makes sense. The one thing that I don''t quite get is, why do we assume that:

s = A*exp(i*omega*t)

That sort of looks like we''re assuming that the answer will be in terms of sines or cosines...

There''s a reason why I assumed the complex form exp(i*omega*t) instead of just assuming it was a real-valued harmonic function directly. Read on.

That assumption is made by observation. Since the time derivatives of this form include the original function, just multiplied by coefficients, then we can divide out the original function and convert the ordinary differential equation into an algebraic equation, making it easy to solve for omega and A---really, making it easy to solve the ODE. Yes, exp(i*omega*t)

**is**made of sines and cosines, and ultimately for displaying the simulation we''re only interested in the real part.

But it actually wouldn''t work in general to go ahead and assume the real-valued harmonic function instead of the exp form...

We could have achieved the same result for

**this**problem just by assuming s = A*cos(omega*t + phi) instead. This works for our case since the equation of motion includes only s and the second time derivative of s. Since the second derivative of this new form includes cos(omega*t + phi), we can divide out the cos() to get an algebraic equation. But would that work if we also had a first derivative of s, ds/dt? (This would occur if we had damping.) No, since ds/dt would have sin(omega*t+phi) and so we can''t divide out the cosine or sine terms. But the exp() form would still work.

The moral of the prior paragraph is that the exp() form works for ODE''s that have any combination of odd and even time derivatives of the unknown variable, while making a direct assumption that s is written in terms of real-valued sine or cosine will only work if the ODE has all odd or all even time derivatives, but not both odd and even.

Does that help? Or maybe more confusing?

Graham Rhodes

Senior Scientist

Applied Research Associates, Inc.

###
#15
Members - Reputation: **712**

Posted 08 October 2001 - 01:19 PM

I know that exp(i*theta) = cos(theta) + i sin(theta), that can be seen simply from the equations for exp, sin and cos. What I meant was, aren''t we assuming that one of the final equations for SHM will be in terms of sin or cos?

Still, you answered that, too. We need a second derivative equal to a multiple of the function, and exp makes sense there.

Thanks!

Still, you answered that, too. We need a second derivative equal to a multiple of the function, and exp makes sense there.

Thanks!

###
#16
Members - Reputation: **122**

Posted 09 October 2001 - 04:53 AM

Ok, this post is for graham rhodes (moderator):

I see that you have decided to close some threads that concerned homework problems. In my opinion, isn't it better to let him/she and everyone else that has problems with this stuff to post their questions and IF someone wants to answer they could do so?

I mean, if you and everyone else thinks it's a simple problem, then you don't have to reply, and thus leave the thread unanswered. If someone has the time and wants to answer they could do so and everyone is happy, especially the poster (aj37 in this case).

I don't know, but there might be a risk that the forum gets filled with such questions, but I don't think so.

Anyway, that's my humble opinion.

Edited by - silvren on October 9, 2001 11:53:54 AM

I see that you have decided to close some threads that concerned homework problems. In my opinion, isn't it better to let him/she and everyone else that has problems with this stuff to post their questions and IF someone wants to answer they could do so?

I mean, if you and everyone else thinks it's a simple problem, then you don't have to reply, and thus leave the thread unanswered. If someone has the time and wants to answer they could do so and everyone is happy, especially the poster (aj37 in this case).

I don't know, but there might be a risk that the forum gets filled with such questions, but I don't think so.

Anyway, that's my humble opinion.

*/Mankind gave birth to God.*Edited by - silvren on October 9, 2001 11:53:54 AM

###
#17
Moderators - Reputation: **1361**

Posted 09 October 2001 - 06:38 AM

quote:Original post by silvren

Ok, this post is for graham rhodes (moderator):

I see that you have decided to close some threads that concerned homework problems. In my opinion, isn''t it better to let him/she and everyone else that has problems with this stuff to post their questions and IF someone wants to answer they could do so?

I mean, if you and everyone else thinks it''s a simple problem, then you don''t have to reply, and thus leave the thread unanswered. If someone has the time and wants to answer they could do so and everyone is happy, especially the poster (aj37 in this case).

I don''t know, but there might be a risk that the forum gets filled with such questions, but I don''t think so.

Anyway, that''s my humble opinion.

I did consider that approach, and discussed different options with the other moderators on this board before deciding on the thread-closing approach. One certainly could argue that your approach is more appropriate than mine. The problem I personally have with just allowing people to choose to respond or not is that there will

**always**be someone who will respond to simple questions, and that''s exactly what the poster is counting on. It is my opinion that in these cases the poster is cheating on an assignment, which leads a teacher to erroneously judge the

**forum''s**comprehension of a technical subject, and not the student''s comprehension and problem-solving skills. Of course, there''s almost no chance in hell that the teacher will ever know that the student cheated in this way. Given that there are some lazy folks who will always try to cheat, I''ve closed some threads hoping to reduce the cheating that goes on here.

I personally believe it does the poster a

**disservice**to give answers to questions that are clearly homework problems, as you''ve no doubt understood from my post to the closed threads.

Now, given all of

**that**...if the question were posted in the right way, and the poster was asking for hints, or just a different description of the problem, I could see that as a legitimate request. And I will consider this before closing future homeworky threads. And if I see that a person has asked for help on homework in the right way, I''ll post a reply to praise the person for that.

If a person is having trouble understanding a concept, its time for them to visit their teacher/professor or meet with other students in the same class. To merely ask for a solution here does not usually help the person to actually learn and understand the math. I would not feel the same way if the poster would

**show**the work of their prior efforts in detail, then ask for

**hints**of how to proceed. It is the asking for solutions that I feel is just wrong.

I do believe in helping people to solve problems that arise in (especially) game development. I participate in these forums, and moderate this forum, in an attempt to help people educate themselves and solve problems. The vast majority of the initial posts are either clearly related to game development or show that the poster has done significant work before making the post.

You may notice that I did not close

**this**thread, since the simple problem in question does arise in implementing simple game physics.

Graham Rhodes

Senior Scientist

Applied Research Associates, Inc.

###
#19
Members - Reputation: **151**

Posted 09 October 2001 - 07:40 AM

Well Beer Hunter, the general solution of the differential equation (DE)

is

It can be shown that the general solution of a homogeneous DE with constant coefficients is a linear combination of exponential functions. So the exponential function is a property of the equation.

The coefficients A and B follow from the boundary contitions.

Edited by - VolkerG on October 9, 2001 2:41:09 PM

d^{2}x / dt^{2}= c^{2}* x

is

x = A * exp (c*t) + B * exp (-c*t)

It can be shown that the general solution of a homogeneous DE with constant coefficients is a linear combination of exponential functions. So the exponential function is a property of the equation.

The coefficients A and B follow from the boundary contitions.

Edited by - VolkerG on October 9, 2001 2:41:09 PM