Re: help
- To: mathgroup@smc.vnet.net
- Subject: [mg11709] Re: [mg11653] help
- From: Bob Hanlon <BobHanlon@aol.com>
- Date: Thu, 26 Mar 1998 03:08:39 -0500
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].