MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Help needed: defining a function of a vector variable

  • To: mathgroup at
  • Subject: [mg18056] Re: Help needed: defining a function of a vector variable
  • From: Brian Higgins <bghiggins at>
  • Date: Tue, 15 Jun 1999 01:43:18 -0400
  • Delivery-date: Tue Jun 15 10:26:55 1999
  • Organization: - Share what you know. Learn what you don't.
  • References: <7jub1a$>
  • Sender: owner-wri-mathgroup at

In article <7jub1a$56u at>,
  iaz at (Ilya Zavorine) wrote:
> Suppose I have an object (e.g. a matrix) which I want to consider as a
> of several variables. For instance, suppose the matrix is diagonal of
size N and the
> variables are its diagonal elements. Logically I can also consider the
same matrix
> as a function of a single N-vector variable which would contain the
diagonal elements.
> How should I define my matrix? Whatever the definition is, it has to
satisfy 2
> requirements:
> (1) I need to be able to assign values both to specific variables and
to the
> whole vector.
> (2) The definition should be the same for any N, i.e. if I want to go
from N = 2 to N = 3
> or even to N = 10, I do not want to rewrite the whole thing from
> One way of defining a matrix would be something like this:
> M[d1_,d2_,d3_] = DiagonalMatrix[{d1,d2,d3}];
> Clearly, this type of definition does not really satisfy either
requirement since it is
> difficult to assign a value to the vector {d1,d2,d3} as a whole. Also,
this definition
> has to be rewritten every time I change N.
> I've also tried doing something like this:
> Size = 3;
> M[d_] = Array[d,Size];
> This satisfies (2) but not (1). In fact Mathematica does not seem to
relate the variable d
> in the left-hand side of the definition to the variable d inside
> Is there a better way of doind this?
> Thanks for any help,
> Ilya


Try this:


Here is the result for  alist of 2  elements



and her for  3 elements




Sent via
Share what you know. Learn what you don't.

  • Prev by Date: Re: A little problem with positive numbers
  • Next by Date: Re: Tips for 4.0 !!
  • Previous by thread: Re: Help needed: defining a function of a vector variable
  • Next by thread: Re: Formatting of Equations