Page 1 of 1
Re: Homework 10, due December 8, 2004.
Posted: Sat Dec 04, 2004 5:22 pm
by mjesick
"On the same plot, plot x1 versus x2 for 0 < t < 30."
...what are x1 and x2?
Re: Homework 10, due December 8, 2004.
Posted: Sat Dec 04, 2004 8:23 pm
by goodwine
mjesick wrote:"On the same plot, plot x1 versus x2 for 0 < t < 30."
...what are x1 and x2?
x1 and x2 are the two componetnts of x, i.e., x=(x1,x2).
If it's still not clear, skim the first section of chapter 9 -- that's what this is leading up to.
Plots
Posted: Sun Dec 05, 2004 9:53 pm
by The Kid
Did you want the plots done with C code?
Re: Plots
Posted: Mon Dec 06, 2004 8:10 am
by goodwine
The Kid wrote:Did you want the plots done with C code?
You may use whatever you want to plot.
Mathematica
Posted: Mon Dec 06, 2004 9:10 pm
by Grendel
I was checking my work on mathematica for problem #1. I got
but the computer gave
which is correct. and also when you do Exp[T^-1 *A*T] since T^-1 *A*T has some 0's in it, should Exp^0 be = 1, but in the notes you said you wanted it to be a diagonal matrix. Should Exp[T^-1 *A*T] contain 1's or 0's ??
Re: Mathematica
Posted: Mon Dec 06, 2004 10:34 pm
by goodwine
Grendel wrote:I was checking my work on mathematica for problem #1. I got
but the computer gave
which is correct. and also when you do Exp[T^-1 *A*T] since T^-1 *A*T has some 0's in it, should Exp^0 be = 1, but in the notes you said you wanted it to be a diagonal matrix. Should Exp[T^-1 *A*T] contain 1's or 0's ??
exp(T^{-1} A T} has 0's in it.
You don't want to think of it as exponentiating each term, but rather, because it's diagonal, when you compute all the powers in the series expansion for the matrix exponential, all the higher powers are diagonal as well.
With regard to T, I usually use Eigensystem in mathematica. That way I can pair the eigenvalues with the eigenvectors (they are printed in order).
problem 1
Posted: Tue Dec 07, 2004 4:30 pm
by acrutchf
I tried problem 1, got a different answer than a friend for T because he swapped the order of his eigenvalues (z1 was his z2) and it changed T from my (1 1),(0 1) to (1 1),(1 0) and mathematica gave us (1 0),(1 1)... what is the problem? this is the mathematica code i used:
In[4]:=
Eigenvectors[m1={{2 ,-1},{0,1}}]
Out[4]=
{{1,0},{1,1}}
Re: problem 1
Posted: Tue Dec 07, 2004 5:00 pm
by goodwine
acrutchf wrote:I tried problem 1, got a different answer than a friend for T because he swapped the order of his eigenvalues (z1 was his z2) and it changed T from my (1 1),(0 1) to (1 1),(1 0) and mathematica gave us (1 0),(1 1)... what is the problem? this is the mathematica code i used:
In[4]:=
Eigenvectors[m1={{2 ,-1},{0,1}}]
Out[4]=
{{1,0},{1,1}}
T may differ for different people if you choose the eigenvectors and eigenvalues in a different order (remember they come in pairs, though). Your final x(t) answer should be identical, though.
You may want to use Eigensystem[] in mathematica -- that gives both the eigenvalues and eigenvectors, and they are ordered so that the first eigenvalue goes with the first eigenvector, etc.
Numbers 3, 4
Posted: Tue Dec 07, 2004 8:41 pm
by PhillyPhan17
I just wanted to clarify whats going on in problems 3 and 4. Does x(0) correspond to an initial point on the graph where the top number in the vector is x1 and the bottom number is x2? Also, is it acceptable to plot x1 vs. x2 by hand?....i'm not really sure how to do it using C or Mathematica....
Posted: Tue Dec 07, 2004 9:45 pm
by kdormuth
Is there a way, in MatLab, to input data directly into a function? For example, if I create a function, f(x,y) and I have a data set, data=(x,y) is there any way to input data directly into f when I call that function? ie f(data) = f(x,y)
Thanks!
-Kristin
mathematica
Posted: Tue Dec 07, 2004 10:03 pm
by student
In Mathematica, I used
A = {{100, -90, -9}, {0, 10, -9}, {0, 0, 1}}
Eigenvalues[A]
{100,10,1}
T = Eigenvectors[A]
{{1,0,0},{1,1,0},{1,1,1}}
which is what I got by hand, but when I try to compute AT I get
A T
{{100,-90,-9},{0,10,0},{0,0,0}}, which is not what I get; Matlab gives me
{{1,1,1},{10,10,0},{100,0,0}}, which IS what I get.
I got the inverse of T, X to be the same as both programs
X = Inverse[T]
{{0,0,1},{0,1,-1},{1,-1,0}}
but again, Matlab says the same as I do for X*A*T, but Mathematica says
X A T
{{0,0,-9},{0,10,0},{0,0,0}}
Why does Mathematica give differnet answers?[/code]
3 and 4
Posted: Tue Dec 07, 2004 10:33 pm
by student
Is there a better way to plot 3 and 4, such as using some Matlab/Mathematica/C code, or do I just calculate X(t) for all 16 points?
Posted: Tue Dec 07, 2004 11:47 pm
by 7
Just for more clarification for #1 part e. Is the answer a matrix? Or is it just expressed as exp[matrix*t]?
The answer is a matrix. I want you to actually compute the matrix exponential.
Posted: Tue Dec 07, 2004 11:51 pm
by grc585
hello fellow student,
yeah, Mathematica's kind of tricky sometimes.
You'd think putting two matrices together then shift-entering would multiply them.
BUT NO! You have to use the "." notation.
You can download Mathematica 5 from OIT for windoze.
Start a matrix by hitting CTRL-SHIFT-C, use the palette, or find it in the menu.
Some nice shortcuts are shift-, and shift-enter for making new rows.
When I use the dot my AT multiplication comes out correctly. Make one matrix, type in a period, then another matrix.
Interesting.
Use the somewhat helpful help in the help menu, or pick up an old copy of "The Mathematica Book." (Stephen Wolfram- any version 2.0 and up ought to do.)
Hope that helps.
Posted: Wed Dec 08, 2004 12:10 am
by grc585
7,
My notes say e^(T^-1*A*T)t = a matrix with e^(lamba_n*t) as the diagonal entries.
If you're really smart (I'm not), then you followed exactly all the theory behind all this stuff and understand how we got that from the definition we had on an earlier day.
But that's why I show up for class and take notes
Look at your notes from Monday and Friday, I believe. It builds up the theory for raising a # to the power of a matrix.
Let me know if I'm right/wrong here on anything.
mathematica
Posted: Wed Dec 08, 2004 12:34 am
by student
Thank you, it did help
Re: Numbers 3, 4
Posted: Wed Dec 08, 2004 11:03 am
by goodwine
PhillyPhan17 wrote:I just wanted to clarify whats going on in problems 3 and 4. Does x(0) correspond to an initial point on the graph where the top number in the vector is x1 and the bottom number is x2? Also, is it acceptable to plot x1 vs. x2 by hand?....i'm not really sure how to do it using C or Mathematica....
Your interpretation is correct. You may plot it by hand as long as it's an accurate representation of the solution(s).
Posted: Wed Dec 08, 2004 11:04 am
by goodwine
kdormuth wrote:Is there a way, in MatLab, to input data directly into a function? For example, if I create a function, f(x,y) and I have a data set, data=(x,y) is there any way to input data directly into f when I call that function? ie f(data) = f(x,y)
Thanks!
-Kristin
I'm sure there is an easy way to do this, but I don't know it. Sorry!
Re: mathematica
Posted: Wed Dec 08, 2004 11:06 am
by goodwine
student wrote:In Mathematica, I used
A = {{100, -90, -9}, {0, 10, -9}, {0, 0, 1}}
Eigenvalues[A]
{100,10,1}
T = Eigenvectors[A]
{{1,0,0},{1,1,0},{1,1,1}}
which is what I got by hand, but when I try to compute AT I get
A T
{{100,-90,-9},{0,10,0},{0,0,0}}, which is not what I get; Matlab gives me
{{1,1,1},{10,10,0},{100,0,0}}, which IS what I get.
I got the inverse of T, X to be the same as both programs
X = Inverse[T]
{{0,0,1},{0,1,-1},{1,-1,0}}
but again, Matlab says the same as I do for X*A*T, but Mathematica says
X A T
{{0,0,-9},{0,10,0},{0,0,0}}
Why does Mathematica give differnet answers?[/code]
If you set T = Eigenvalues[A], then the
rows of T are the eigenvectors, not the columns. Do a
to set things straight.
Re: 3 and 4
Posted: Wed Dec 08, 2004 11:07 am
by goodwine
student wrote:Is there a better way to plot 3 and 4, such as using some Matlab/Mathematica/C code, or do I just calculate X(t) for all 16 points?
In either matlab or mathematica, one way would be, once you have the answer, just to do a Do or for loop for t = 0 to 30 and put the x1, x2 values into an array. Then just plot the array.
solutions?
Posted: Mon Dec 13, 2004 4:56 pm
by Grendel
is there going to be solutions posted soon?
Re: solutions?
Posted: Mon Dec 13, 2004 8:51 pm
by 7
Grendel wrote:is there going to be solutions posted soon?
I second that.