What's the difference between using rows or columns?
(%i5) x: [u,v,w];
(%o5) [u, v, w]
(%i6) transpose(x);
[ u ]
[ ]
(%o6) [ v ]
[ ]
[ w ]
-sen
---------------------------------------------------------------------------
| Sheldon E. Newhouse | e-mail: sen1 at math.msu.edu |
| Mathematics Department | |
| Michigan State University | telephone: 517-355-9684 |
| E. Lansing, MI 48824-1027 USA | FAX: 517-432-1562 |
---------------------------------------------------------------------------
On Thu, 25 Jan 2007, Dan Solomon wrote:
> that would make row vectors, instead of column vectors, right? Which
> should be OK for using rk, but perhaps not for other purposes, is why
> I was doing matrix([x1], [x2], [x3]) - i understood the documentation
> to mean matrix () needs its rows inside separate [ ]. I was trying
> to make a 3 row by 1 column matrix, i.e., a column 3 vector.
>
> But anyway, don't you have to say x:matrix([x1,x2,x3]); rather than
> just x:[x1,x2,x3]; ?
>
>
> On Jan 25, 2007, at 3:35 PM, sen1 at math.msu.edu wrote:
>
>>
>> On Thu, 25 Jan 2007, Dan Solomon wrote:
>>
>>> I really appreciate everyone's help, but I have two questions.
>>> 1. How can I learn the differences/relationships between lists,
>>> arrays, and matrices? I've read the documentation (a few times), and
>>> I never picked up the idea that if I define init[1], init[2], and
>>> init
>>> [3], maxima wouldn't realize that "init" meant the 3 vector.
>>>
>>> 2. is there a way to define my vectors, dxdt, x, and init, so that
>>> it will work to issue the command
>>> rk(dxdt, x, init, [t,0,1,.1])
>>
>>
>> How about e.g.,
>>
>> x: [x1,x2,x3];
>>
>> dxdt: [x1*exp(-x2) - x2^(-3), x1 + x2, x1 + x3];
>>
>> init: [2.0, -1.1, 3.2];
>>
>> sol: rk(dxdt, x, init, [t,0,1,.1]);
>>
>>
>>> Thanks again!
>>> Dan
>>> On Jan 25, 2007, at 10:46 AM, sen1 at math.msu.edu wrote:
>>>
>>>> My guess is that Dan wanted to write his system of DE's using matrix
>>>> methods to simply express them. So, his original right hand side
>>>> is a
>>>> vector function whose components are 1x1
>>>> matrices of functions instead of functions. So, all that was
>>>> necessary to get it to work is to replace
>>>>
>>>> [dxdtau[1],dxdtau[2],dxdtau[3]]
>>>>
>>>> by
>>>>
>>>> [dxdtau[1][1],dxdtau[2][1],dxdtau[3][1]]
>>>>
>>>> Thus, instead of his right side of the DE looking like (using x,y,z
>>>> instead of x[1],x[2],x[3] for easier writing)
>>>>
>>>> [[x^2 + y^2], [x - y], [z*y*z]], it should have looked like
>>>>
>>>> [x^2 + y^2, x - y, z*y*z]
>>>>
>>>> Hence, the simple fix above. I think Jaime's manual and the
>>>> examples
>>>> are fine as written. If one wants to use matrices of functions to
>>>> define systems of equations, one just has to convert back to the
>>>> standard thing maxima expects. I don't know if it is worth
>>>> rewriting
>>>> the code to take care of this. But, it might be worthwhile to
>>>> put an
>>>> example or two in the manual to show how to deal with this.
>>>>
>>>> -sen
>>>>
>>>>
>>>> --------------------------------------------------------------------
>>>> --
>>>> -----
>>>> | Sheldon E. Newhouse | e-mail:
>>>> sen1 at math.msu.edu |
>>>> | Mathematics Department | |
>>>> | Michigan State University | telephone:
>>>> 517-355-9684 |
>>>> | E. Lansing, MI 48824-1027 USA | FAX:
>>>> 517-432-1562 |
>>>>
>>>> --------------------------------------------------------------------
>>>> --
>>>> -----
>>>>
>>>> On Thu, 25 Jan 2007, Robert Dodier wrote:
>>>>
>>>>> Dan, it looks like the basic problem is that Maxima treats lists
>>>>> and
>>>>> matrices in ways that are somewhat less than obvious.
>>>>> I'll try to clarify some points.
>>>>>
>>>>> On 1/25/07, Jaime E. Villate <villate at fe.up.pt> wrote:
>>>>>> On Thu, 2007-01-25 at 06:12 -0500, Dan Solomon wrote:
>>>>>>> I don't understand your comment. Don't I have x as a 3-vector?
>>>>>>
>>>>>> No, you don't. x[1], x[2], x[3] have no relation to the
>>>>>> variable x.
>>>>>> x and x[1] are considered different variables in Maxima.
>>>>>
>>>>> Well, if the user writes x:[a, b, c] (i.e. assign a list to x) then
>>>>> x[1], x[2], and x[3] are indeed related to x; those are the three
>>>>> elements of x.
>>>>>
>>>>> Dan, I think you want x:[a, b, c], not x[1]:a, etc -- in the latter
>>>>> form, x doesn't refer collectively to a, b, and c.
>>>>> Whether that's a design flaw is a topic for a rainy day ....
>>>>>
>>>>>> The first argument given to rk must be a list of expressions. You
>>>>>> first
>>>>>> tried with a 3x1 matrix dxdtau. It won't work. You then tried
>>>>>> [dxdtau[1],dxdtau[2],dxdtau[3]]
>>>>>>
>>>>>> this is not a list of expressions either. Please notice that since
>>>>>> dxdtau is a matrix, dxdtau[1] is the first row of that matrix;
>>>>>> namely,
>>>>>> it is a list itself.
>>>>>
>>>>> Lists are not row or column matrices, and the elements of a
>>>>> row or column matrix must be indexed by 2 indices (one of which
>>>>> is always 1). Dan, probably what you want is to make dxdtau a list.
>>>>>
>>>>> Hope this helps -- I'm sorry if the treatment of lists and matrices
>>>>> is confusing. I would be interested to hear your comments on this
>>>>> point.
>>>>>
>>>>> Robert Dodier
>>>>> _______________________________________________
>>>>> Maxima mailing list
>>>>> Maxima at math.utexas.edu
>>>>> http://www.math.utexas.edu/mailman/listinfo/maxima
>>>>>
>>>> _______________________________________________
>>>> Maxima mailing list
>>>> Maxima at math.utexas.edu
>>>> http://www.math.utexas.edu/mailman/listinfo/maxima
>>> _______________________________________________
>>> Maxima mailing list
>>> Maxima at math.utexas.edu
>>> http://www.math.utexas.edu/mailman/listinfo/maxima
>>>
>> _______________________________________________
>> Maxima mailing list
>> Maxima at math.utexas.edu
>> http://www.math.utexas.edu/mailman/listinfo/maxima
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>