RE: Q: Matrix Construction

• To: mathgroup at smc.vnet.net
• Subject: [mg26318] RE: [mg26299] Q: Matrix Construction
• From: "David Park" <djmp at earthlink.net>
• Date: Sun, 10 Dec 2000 21:38:03 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Christoph,

Mathematica will always balk if you ask it to take a part of an expression
which has no such part. That is what you are asking it to do.

What is your objective here? Are you trying to deal with the parts of
vectors symbolically and then later fill in the values of the parts? This is
a common problem so I will show one way to do it.

This defines the symbolic components of two vectors:

{v1, v2} = Array[x, {2, 2}]
{{x[1, 1], x[1, 2]}, {x[2, 1], x[2, 2]}}

This is a set of substitution rules for a specific pair of vectors:

subrules = Thread[Flatten /@ ({v1, v2} ->
{{1, 2}, {2, -3}})]
{x[1, 1] -> 1, x[1, 2] -> 2, x[2, 1] -> 2,
x[2, 2] -> -3}

Now we can do calculations using the symbolic components and then substitute
the actual values. This calculates the projection of vector v1 in the
direction of vector v2.

v1.v2/v2.v2
% /. subrules

(x[1, 1]*x[2, 1] + x[1, 2]*x[2, 2])/
(x[2, 1]^2 + x[2, 2]^2)
-(4/13)

David Park

> From: Christoph [mailto:scone at kepler.mechanik.tu-darmstadt.de]
To: mathgroup at smc.vnet.net
>    hi,
>
> i would like to create a matrix like this
>
> {{x[1][[1]],x[1][[2]]},{x[2][[1]],x[2][[2]]}}
>
> i tried to do it like this
>
> Table[x[i][[j]],{i,2},{j,2}] and got some errormessages (partlength).
> How can i just create this table without evaluating it now. Later i
> will define some vectors x to be filled in.
>
> Greetngs
> 	Christoph

```

• Prev by Date: Re: Re: Big trouble with Mathematica Code parsing -- Rant.
• Next by Date: rules for Sign[_]^n
• Previous by thread: Re: Q: Matrix Construction
• Next by thread: Re: Q: Matrix Construction