How do I solve for time?

Started by
25 comments, last by Aj37 22 years, 6 months ago
I always *hated* the fact that you had to mystically divine the correct form of the answer to an ODE before you solved it - which is why I use Laplace transforms to solve them all (the only tricky part is factoring the transformation, and if you take some liberties with an arbitrary constant it gets really easy). i.e. You can use Laplace transforms to solve general ODE''s, not just ones with boundary conditions.

(And it has nothing to do with the fact that my TI-92 can be programming to do L{} & L-1{})




Magmai Kai Holmlor
- Not For Rent
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
quote:Original post by Omaha
Come on, stop doing the kid''s homework for him. This is basic physics!


The discussions have evolved beyond the homework question now, although I agree with the thought (obviously, ).

Offline, the other moderators and I have been discussing the issue of homework questions posted here, and how to deal with them. There''s no real way we can totally prevent people from cheating, but we can discourage it. And we can encourage other forum members to NOT help a person cheat.

I''ve created a Math & Physics forum FAQ with some guidance on the issue of homework, and you may want to read it. I have a feeling some of this guidance will be posted in a way that all forum members can easily see it in the near future.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
quote:Original post by Magmai Kai Holmlor
I always *hated* the fact that you had to mystically divine the correct form of the answer to an ODE before you solved it - which is why I use Laplace transforms to solve them all (the only tricky part is factoring the transformation, and if you take some liberties with an arbitrary constant it gets really easy).


For the problem we''re discussing, the assumed exponential form is directly related to the Laplace transform solution. Our assumed form produces the same algebraic characteristic equation as the Laplace transform.

Of course the Laplace transform is only useful for ODE''s that are LINEAR. And so you wouldn''t really use it to solve "general" ODE''s, . The problem actually might be MORE difficult! The full Newton-Euler equations of motion, for example, are NOT linear for general problems. Even a simple pendulum is not a linear problem (although the standard introductory physics textbook solution for pendulum motion is for a linearized version of the equation of motion....). Try to solve this using the Laplace transform:

J*d2theta/dt2 = -m*L*sin(theta)

This is basically the nonlinear equation of motion for an undamped simple pendulum with theta being the angle measured counterclockwise from straight down, bob mass of m, length L, and initial position at time 0 of theta(t=0) = 0.

You can do the Laplace transform of d2theta/dt2, but to transform sin(theta) you have to assume a form for theta! (There''s that "mystical divine" stuff again!) Otherwise, how can you do the Fourier integral:

L(sin(theta)) = integral_0_infinity(sin(theta)*exp(-st)*dt)

Even when you do assume a form----which will intuitively include a harmonic function----you''ll end up integrating something like sin(sin(omega*t)). Have you ever integrated the sine of a sine? If you manage to do this, chances are you''re not going to end up with an algebraic equation in the end, which is really the reason you wanted to use Laplace transform in the first place, . Food for thought.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Ok so it was a rash statement to say I can solve _all ODE's with laplace transforms - but I think I can solve that one.
I'm a little rusty on Laplacain/Holmlorain arbitration, but I'll try to remember:

J*d2theta/dt2 = -m*L*sin(theta)

Let y' '(t) = d2theta/dt2
L{y(t)} = Y(s)
L{y' '(t)} = s2*Y(s) - s*y'(0) - y(0)
(since y'(0) and y(0) are unknown, we will give them the distinct arbitrary constant values c1 and c2)

L{sin(t)} = k2 / (s2 + k2)
However, as you pointed out, the sin is problematic. Not entirely unlike taking a square root, taking the laplacain of a sin requires special attention - in particular, whenever you take the laplacain of a sin (or cos) you add the laplacain of cos (or sin) and multiple it by (yet another) arbitrary constant.
This may be mystical, but at least it's not divine. You do the same thing the same way every time, just like +/- the square root.

So, for our purposes:
L{sin(t)} -> k2 / (s2 + k2) + c3*s2 / (s2 + k2)

J*y' '(t) + m*L*sin(t) = 0
Take the Laplacain
J*Y*s2 + c1s + c2 + m*L/ (s2 + 1) + c3*s/ (s2 + 1) = 0

Now we need to get rid of that ugly s2, so multiple by 1/s2

J*Y + c1/s + c2/s2 + m*L/ (s2 * (s2 + 1)) + c3* / (s * (s2 + 1)) = 0

Expand
J*Y + c1/s + c2/s2 - m*L/(s2 + 1) + m*L/s2 - c3*s/(s2 + 1) + c3/s = 0

Now, we can elminate the c3/s and m*L/s2 terms because they are subsumed into c1/s and c2/s2 arbitrary terms

J*Y + c1/s + c2/s2 - m*L/(s2 + 1) - c3*s/(s2 + 1) = 0

Inverse Laplacain

J*y(t) + c1*t + c2*t2 - m*L*sin(t) + c3*cos(t) = 0

Given initial conditions you can solve for c1, c2, & c3 using some LA.

Now, I know your thinking that that looks like a pile more work than other methods - but you can teach a computer this method (like a TI-92 for instance).


Magmai Kai Holmlor
- Not For Rent

[edit]
not much of a chance getting that right the first time

Edited by - Magmai Kai Holmlor on October 12, 2001 2:52:32 AM
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
I should say first that there was an error in my equation. I neglected to include the gravitational acceleration, g in the right-hand-side. The equation should be:

J*d2theta/dt2 = -m*g*L*sin(theta)

If the mass is approximated as a point mass, then J = m*L*L, and the equation can be rewritten:

d2theta/dt2 = -(g/L)*sin(theta)

Otherwise, you have to keep J in there explicitly.

quote:Original post by Magmai Kai Holmlor
L{sin(t)} = k2 / (s2 + k2)


Nice try, but there is fundamental flaw in your analysis, not to mention at least two errors. You're taking the Laplacian of sin(t), where t is time. Actually, looks like you meant to take the Laplacian of sin(k*t), not just sin(t). The k in the numerator should not be squared, thus the correct Laplacian of sin(k*t) is:

L{sin(k*t)} = k / (s2 + k2)

Likewise, the s in the numerator of L{cos(t)} should not be squared. The correct transform is:

L{cos(k*t)} = s / (s2 + k2)

[reference: "Introduction to Control System Analysis and Design" by Francis J. Hale, Prentice Hall, 1973, Chapter 2].

Probably a careless error, due to "rustiness," . But the erroneous square in the numerators is not the fundamental flaw of your analysis. The fundamental flaw is that you've transformed the wrong equation! You took my equation, shown below with your variable y(t) replacing my theta...

J*d2y(t)/dt2 = -m*g*L*sin(y(t))

...and transformed it into the following:

J*d2y(t)/dt2 = -m*g*L*sin(t)

Its not the same thing. Your replacement equation can be solved with Laplace transforms (as you well proved---apart from the minor error I pointed out). But you have not solved the actual equation of motion for a nonlinear simple pendulum. Or even a linear pendulum. The harmonic functions for y(t) for a linear pendulum should show a frequency that is a function of g and L, but your solution shows a frequence of exactly 1.0.

Tell me, what is the Laplace transform of sin(y(t))? Well, if you say that y(t) = t then the equation is your equation and it can be solved. But if y(t) = A*sin(constant*t+phi), which is required for the nonlinear pendulum in a simple constant gravity field, the Laplace transform is at least much more difficult, and there may be no closed form equation at all for the transform... There may be a way, but I don't think you'll find the answer in a simple table of Laplace transforms.

Anyway, this is all a bit overkill. For nonlinear problems that are interesting enough to put into games, we'd use numerical methods rather than sweat over trying to find a closed form solution. Still, its good to hone up on those old heavy math skills sometimes, .

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

______________________________
These superscripts are driving me crazy!

Edited by - grhodes_at_work on October 12, 2001 2:13:58 PM

Edited by - grhodes_at_work on October 12, 2001 2:14:55 PM
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
And I guess I really meant:
Let y' ' = d2theta/dt2
L{sin(k*theta)} = k / (s2 + k2)
L{sin(k*theta)} -> k / (s2 + k2) + c3*s / (s2 + k2)

Are these valid assumptions to make? or does the laplace transform only work on functions of time?

And the final result would be:
J*y(theta) + c1*theta + c2*theta2 - m*g*L*sin(theta) + c3*cos(theta) = 0

I uh, used two different variables named t... all a mote point if I missed something in the original equation.

....
So, are you saying that theta is actually a function, dependant on t?

J*d2theta(t)/dt2 = -m*g*L*sin(theta(t)) ?

quote:
Still, its good to hone up on those old heavy math skills sometimes, .

Absolutely, I feel like I'm leaking.

Magmai Kai Holmlor
- Not For Rent

Edited by - Magmai Kai Holmlor on October 12, 2001 9:17:15 PM

Edited by - Magmai Kai Holmlor on October 12, 2001 9:21:53 PM
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
quote:Original post by Magmai Kai Holmlor
And I guess I really meant:
Let y'' '' = d2theta/dt2
L{sin(k*theta)} = k / (s2 + k2)
L{sin(k*theta)} -> k / (s2 + k2) + c3*s / (s2 + k2)

Are these valid assumptions to make? or does the laplace transform only work on functions of time?


Your first equation, defining y'''', is correct. Its basically the same thing as saying y = theta, or y'''' == theta''''. Its just a change of the variable name from theta to y. Both are functions of time, t.

The Laplace transform transforms a function in the time domain into a function in the frequency domain. Your transforms of L(sin(k*theta)) are incorrect unless you say that theta = t = time. That''s a linear function that says theta grows to infinity with time. And again, for the nonlinear pendulum this assumption is wrong since theta does not grow to infinity, it just oscillates between a maximum and minimum value. (Well, if its a frictionless pendulum and the bob can move 360 degrees around and you apply a large enough initial force or velocity then theta could go to infinity. But it still won''t grow linearly with time since gravity will cause it to accelerate and decelerate as it moves around. (And a pure linearized ODE solution won''t capture this case.)

quote:
And the final result would be:
J*y(theta) + c1*theta + c2*theta2 - m*g*L*sin(theta) + c3*cos(theta) = 0


I didn''t look to closely at this, but the "J*y(theta)" part is wrong. Remember, y and theta are the exact same so you would never have a y(theta). You would have a y(t) in the time domain or y(s) in the frequency domain. The transform of J*y''''(t) is J*s2y(s) plus the two initial condition terms.

quote:
So, are you saying that theta is actually a function, dependant on t?


Yes! That''s exactly it! theta(t) = y(t). Theta is the solution we''re looking for, and it specifies the motion of the pendulum or object over time. Theta is exactly the same as your variable y.

quote:
Absolutely, I feel like I''m leaking.

Ha!

I say we quit while we''re ahead, .

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

This topic is closed to new replies.

Advertisement