How do I solve for time?

Started by
25 comments, last by Aj37 22 years, 6 months ago
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*(d2s/dt2)  


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*(d2s/dt2)  

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)andd2s/dt2 = A*i2*omega2*exp(i*omega*t)or, since i2 = -1,d2s/dt2 = -A*omega2*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*omega2*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*omega2oromega = 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
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Advertisement
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...
Hey Guys!!!! Thanks for all the discussion. I have another post I was hoping you could help me with titled "Need help with this vector problem".
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.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
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!
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.


/Mankind gave birth to God.

Edited by - silvren on October 9, 2001 11:53:54 AM
/Mankind gave birth to God.
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.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
well-spoken!

I can only agree.

/Mankind gave birth to God.
/Mankind gave birth to God.
Well Beer Hunter, the general solution of the differential equation (DE)
d2 x / dt2 = c2 * 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
Come on, stop doing the kid''s homework for him. This is basic physics!

This topic is closed to new replies.

Advertisement