Question: How to diff() on summations and double summations?

I am trying to compute partial derivatives of some complicated expression which include summations. First, I noticed that sum behaves differently if I use 1D vs. 2D math. Why?

Questions:
  1. Partial derivative of a summation: why is it not just 2*X[i]?
  2. Partial derivative of a double summation: how to define the nested structure of a double summation with j<>i?
  3. System of n+1 equations: how to define and solve for it?

For 3., each i equation is the partial derivative of my complicated expression with summations with respect to X[i], where i ranges from 1 to n. The last equation is the partial derivative with respect to X_r (a fixed variable).

Thanks.

restart

A := sum(X[i]^2, i = 1 .. n); eq[1] := diff(A, X[i]) = 0

sum(X[i]^2, i = 1 .. n)

 

sum(2*X[i], i = 1 .. n) = 0

(1)

B__wrong := sum(sum((X__r*w+X[i])*(X__r*w+X[j]), j = 1 .. n), i = 1 .. n); B__correct := 'sum(sum((X__r*w+X[i])*(X__r*w+X[j]), j = 1 .. n), i = 1 .. n)'

n^2*X__r^2*w^2+sum(sum(X__r*w*X[j]+X[i]*X[j], j = 1 .. n)+n*X__r*w*X[i], i = 1 .. n)

 

sum(sum((X__r*w+X[i])*(X__r*w+X[j]), j = 1 .. n), i = 1 .. n)

(2)

eqs := seq(eq[i], i = 1 .. n); vars := seq(X[i], i = 1 .. n)

Error, range bounds in seq must be numeric or character

 

Error, range bounds in seq must be numeric or character

 
 

NULL

Download equations_with_summations.mw

Please Wait...