2
$\begingroup$

I'm new to Mathematica, and I'm still learning. I'm trying to code this partial differentiation. Can someone please help me find out where I coded wrong? I've attached a hand-written solution below.

enter image description here

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ Please post your code, not images. Thanks. $\endgroup$ Commented Apr 19, 2020 at 0:30

1 Answer 1

5
$\begingroup$

D[x1Com,x[1,i]] will give zero, since there is no x[1,i] any more in x1Com. There is only x[1,1] and x[1,2] and so on.

One way could be

ClearAll[x1Com, x, m];
x1Com = HoldForm@(Sum[(m[1, i]*x[1, i]), {i, 1, 6}]/Sum[m[1, i], {i, 1, 6}])

Mathematica graphics

Now make a function to differentiate w.r.t. to specific x[1,i]

diff[x1Com_, x_] := D[ReleaseHold@x1Com, x];

Now use it

diff[x1Com, x[1, 1]]

Mathematica graphics

diff[x1Com, x[1, 2]]

Mathematica graphics

And so on.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.