Homework 7, due October 29, 2008.

Due Wednesday, October 29, 2008.
Post Reply
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Homework 7, due October 29, 2008.

Post by goodwine »

Reading: Sections 9.1-9.4, 13.1-13.3, 13.5.

Section 9.3 should be empty. Section 9.4 contains some simple definitions that were not covered in class but are necessary for the homework.

Exercises:
  1. Problem 9.3 from the course text. The program may not be in matlab. C, FORTRAN and Java are acceptable. If you want to use another programming language, you must ask the instructor first. Using matlab to plot the results is acceptable.
    • Do this problem first using Euler's method for the numerical solution.
    • After it appears to be working and you have verified all the controls things, modify it to use the second order Runge-Kutta method. You do not need to duplicate all the parts of problem 9.3 using second order R-K, just be sure that the numerical method seems to be working properly.
  2. Problem 13.1, but for part (c) use the third order Runge-Kutta method, not fourth order as is stated in the book.
Bill Goodwine, 376 Fitzpatrick
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 7, due October 29, 2008.

Post by goodwine »

I'm having a little trouble understanding 3rd order Runge-Kutta solutions as shown in the book. Near the bottom of p433 in the text, I see v_3 defined as f(x(t) + 2v_2 - v_1, t + dt)*dt; however, in example 13.3.3.3 on page 434, you appear to plug x(t) + v_2 in for x instead of x(t) + 2v_2 - v_1. I'm probably just missing some simplification, but I'd apprecitate if you could explain this to me when you get a chance.
The equation for v_3 in Example 13.3.3 is wrong. The program for it in the appendix is correct, however.
Bill Goodwine, 376 Fitzpatrick
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 7, due October 29, 2008.

Post by goodwine »

Someone asked me:
Professor, I am having some trouble understanding the implementation of the Runge-Kutta Method. I don't know how to go about using a 2nd order Runge-Kutta approximation on the third order differential equation in problem 9.3. How does using a 3rd order differential equation change the Runge-Kutta method that the book presents for 1st order differential equations?
Just like for Euler's method, you need to convert it to three first order equations. Then you need a v1, v2 and v3 for each of the three equations. Finally, note that you have to compute the v1 for all three equations before you compute v2 for any of them.

I should have assigned section 13.5 as part of the reading assignment. If you read that section it should help clarify things.
Bill Goodwine, 376 Fitzpatrick
tgalx

Re: Homework 7, due October 29, 2008.

Post by tgalx »

in the directions for problem 9.3, it says to use the nonlinear model, but then it says to assume a small /theta. in our programs, do we have to keep the cos(/theta) term or can we equate it to 1?
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 7, due October 29, 2008.

Post by goodwine »

tgalx wrote:in the directions for problem 9.3, it says to use the nonlinear model, but then it says to assume a small /theta. in our programs, do we have to keep the cos(/theta) term or can we equate it to 1?
Use cos(\theta), not 1. The controller won't work if theta becomes large.
Bill Goodwine, 376 Fitzpatrick
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 7, due October 29, 2008.

Post by goodwine »

Someone asked me:
I had a question regarding the comparison between Euler's Method and the R-K method on problem 9.3 in our homework. My Euler's method program produces results which exhibit all of the proper behaviors (increased oscillation, reduced steady state error, etc) when the tuning constants are changed. However, it does not match up (exactly) with the graphs you have in the book - in particular, for proportional control, the amplitude of the oscillation is higher than that displayed on your graphs (the test I have been using is setting kp = 4 and checking the angle at which my graph first peaks - for your graphs this angle was about 1.5, for mine it is about 1.8 ). I am confident that this error is caused in some capacity by the fact that, in the book, you're working with a linear equation while we're working with a nonlinear one (I removed the nonlinear portion of the equation and my Euler results matched yours).

On the other hand, my R-K program for the same problem produces results that come very close to matching those displayed in your graph. But this means it doesn't match my Euler results - the trends are the same but the magnitudes of everything are totally off.

So, this leads me to my question - how close (if at all) should my Euler's method results match my R-K method results?
They should be indistinguishable with a small enough step size. The way to check is to let dt=0.001 or smaller.
Bill Goodwine, 376 Fitzpatrick
Nick S

Re: Homework 7, due October 29, 2008.

Post by Nick S »

In problem 13.1, part 3 asks for information regarding "Global Error" and "Global Truncation Error," but the section on these concepts is blank in the book. What is the difference between these errors and the Local Truncation Error described in the book?
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 7, due October 29, 2008.

Post by goodwine »

Nick S wrote:In problem 13.1, part 3 asks for information regarding "Global Error" and "Global Truncation Error," but the section on these concepts is blank in the book. What is the difference between these errors and the Local Truncation Error described in the book?
That's worded poorly. I want you to reduce the time step and see if the error does what you expect. That is the "global error." The "local truncation error" is how the error at each time step would change when you change dt, which is different from the global error since the number of steps changes if dt is changed.
Bill Goodwine, 376 Fitzpatrick
xdong

Re: Homework 7, due October 29, 2008.

Post by xdong »

I have a question regarding solving the 2nd order equations. Once I have the equation, I have a term (Kp*theta) - mgl*(cos theta). How can I get theta out, so I can get a C term for the quadratic formula to get a solution ?
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 7, due October 29, 2008.

Post by goodwine »

xdong wrote:I have a question regarding solving the 2nd order equations. Once I have the equation, I have a term (Kp*theta) - mgl*(cos theta). How can I get theta out, so I can get a C term for the quadratic formula to get a solution ?
You can't solve that equation analytically because it is nonlinear (which is exactly the problem you are having). That is why the problem asks you to solve it numerically.
Bill Goodwine, 376 Fitzpatrick
Anon

Re: Homework 7, due October 29, 2008.

Post by Anon »

Professor for problem 9.3 it says to assume zero initial conditions, does that mean you the conditions outlined in every example?

mgl=1
J=1
theta(0)=0
theta_dot(0) = 0
theta_double_dot(0)= kp
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 7, due October 29, 2008.

Post by goodwine »

Anon wrote:Professor for problem 9.3 it says to assume zero initial conditions, does that mean you the conditions outlined in every example?

mgl=1
J=1
theta(0)=0
theta_dot(0) = 0
theta_double_dot(0)= kp
I think it should be
theta(0)=0
theta_dot(0) = 0
theta_double_dot(0)= 0
or am I misunderstanding the question?
Bill Goodwine, 376 Fitzpatrick
Anon

Re: Homework 7, due October 29, 2008.

Post by Anon »

From examples 9.2.2 through 9.2.6 you made the assumption that,

theta (0) = 0
theta_dot (0) = 0
mgl = 1
theta_d = 1
J = 1

then on example 9.2.6 you determined that

theta_double_dot (0) = kp

I was just wondering whether we should apply (or rather assume) the same conditions (obviously not the linearization, but I digress) as the ones listed for examples 9.2.2 through 9.2.6.
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 7, due October 29, 2008.

Post by goodwine »

Anon wrote:From examples 9.2.2 through 9.2.6 you made the assumption that,

theta (0) = 0
theta_dot (0) = 0
mgl = 1
theta_d = 1
J = 1

then on example 9.2.6 you determined that

theta_double_dot (0) = kp

I was just wondering whether we should apply (or rather assume) the same conditions (obviously not the linearization, but I digress) as the ones listed for examples 9.2.2 through 9.2.6.
I understand your question now. Since the motion of the system is governed by Newton's law, which is a second order equation, you need to specify theta(0) and theta_dot(0). If you write it as a third order equation, then the initial condition for theta_ddot is determined by the total moment on the arm at time zero, which you must compute in a manner similar to that in the book.

If you do your problem like alternative 2 in that example, then all three initial conditions are zero. I'd recommend this approach.
Bill Goodwine, 376 Fitzpatrick
cpascual

Re: Homework 7, due October 29, 2008.

Post by cpascual »

Are we supposed to upload our programs for Problem 9.3 or only just for Problem 13.1?
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 7, due October 29, 2008.

Post by goodwine »

cpascual wrote:Are we supposed to upload our programs for Problem 9.3 or only just for Problem 13.1?
Upload them all.
Bill Goodwine, 376 Fitzpatrick
Post Reply

Return to “AME 30314, Homework 7”