Re: Some questions about vector

*To*: mathgroup at smc.vnet.net*Subject*: [mg74554] Re: Some questions about vector*From*: Bill Rowe <readnewsciv at sbcglobal.net>*Date*: Mon, 26 Mar 2007 02:03:10 -0500 (EST)

On 3/25/07 at 1:26 AM, qzhang81 at gmail.com (Qi Zhang) wrote: >input: >Clear[f]; >f[v] = Sum[(i*v[i]), {i, 1, N}] I am suprised the code above does anything meaningful The summand in the code is the product of an index variable i, and a function v of that variable that is no where defined. And you have defined i to range from 1 to N which apparently Sum recognizes as a variable despite the fact Mathematica has a system object N which converts numeric quantities to machine precision. You should notice that Sum[(i*v[i]), {i, 1, N}] is returned unevaluated. And finally you define another function f with argument v (which you are using to be a function on the rhs) to be the computed sum >D[f[v], v[i]] This code will evaluate f[v] to be the evaluated sum above. Since each term of that sum is i*v[i] the derivative of each term is i. Hence the result is simply the sum of integers from 1 to N which is what you obtained. >the output is >\!\(1\/2\ N\ \((1 + N)\)\) >However what I expect is i Why? What were you trying to do? >What should I do in order to get the the answer I expected? Most likely the answer is to use appropriate Mathematica syntax -- To reply via email subtract one hundred and four