MathGroup Archive 1998

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

Search the Archive

Re: help



I do not understand what you are asking in your first question.

As to the second:

seq[a_, b_, n_Integer] /; a != b && n > 1 := 
	Table[x, {x, a, b, (b - a)/(n - 1)}]

However, with this definition the function is unevaluated for symbolic
values of a or b. This occurs because Mathematica cannot decide whether
a != b (test required to avoid attempted division by zero when
Mathematica tries to determine the number of steps).  This can be
overcome by using the definition:

seq[a_, b_, n_Integer] /; n > 1 := 
	Table[a + m*(b - a)/(n - 1), {m, 0, n - 1}]

However, when a = b using this second definition, the result will be a
list of n identical elements.

For the second definition and when working with symbolic values, you may
want to apply Simplify to the results to provide cleaner forms for the
elements in the list.

Bob Hanlon

In a message dated 3/19/98 10:14:19 PM, tie@cscn.com wrote:

>how can i do the following  with mathematica:
>
>1. let X be a vector of N nonnegative numbers.
>    let Y be any og length N.
>    form the vector comprised of Y replicated according to the corresponding 
>    value of the element of X.
>
>2. write a function seq[a,b,n] which returns n equally-spaced numbers on the 
>    interval [a,b].



  • Prev by Date: Integer designation
  • Next by Date: Vectors and Mathematica
  • Prev by thread: Re: help
  • Next by thread: Re: Re: help