# Partial differentiation using Mathematica

I am trying to solve and verify the below equation using Mathematica.

$$\frac{\partial}{\partial b} \sum_{i=1}^n y_i \log\left[ \frac{\sum_{i=1}^n y_i}{1-\prod_{i=1}^n (1-b)^{Exp[x_i\beta]}} \right]$$

I tried to solve this on paper and I was able to obtain the following solution:

$$\sum_{i=1}^n \left( \frac{(1-b)^{Exp[x_i \beta]-1} Exp[x_i \beta] y_i \prod_{i=1}^n (1-b)^{Exp[x_i \beta]} \sum_{i=1}^n\frac{Exp[x_i\beta]}{1-b}}{1-\prod_{i=1}^n(1-b)^Exp[x_i\beta]} \right)$$

I usually verify my equations using Mathematica by plugging in numbers. However, in this case, Mathematica is unable to solve the first equation. So, I appreciate if any of you can share any information on this.

• Can you show us your attempt to calculate the derivative? One thing is that your notation is wierd... you seem to be using the i variable in two places at once (outside the log, and inside the log). One of these should probably be a sum over j. – bill s Dec 13 '18 at 1:53
• People here generally like users to post code as Mathematica code instead of just images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find this this meta Q&A helpful – Michael E2 Dec 13 '18 at 2:27
• It is unclear what is being asked. I do not see any equations in the post, only a derivative of a sum. Can you clarify? You tagged this as "differential-equations", but I see no differential equation in the question. Please remove unrelated tags. Are you just trying to compute a derivate (and not solve a differential equation)? – Szabolcs Jan 21 at 15:59

Give n a numerical value, then Mathematica will evaluate the derivative and you can check it against your result. Try several values of n to convince yourself the your result is correct. I coded your initial equation (but not your derived result) and calculated the derivative for n=2:

f = Sum[y[i] Log[Sum[y[i], {i, 1, n}]/(
1 - Product[(1 - b)^Exp[x[i] β], {i, 1, n}])], {i, 1, n}];
D[f /. n -> 2, b]


the result is

-(((1 - b)^(-1 + E^(β x[1]) +
E^(β x[2])) (E^(β x[1]) + E^(β x[2])) y[1])/(
1 - (1 - b)^(E^(β x[1]) + E^(β x[2])))) - ((1 - b)^(-1 +
E^(β x[1]) + E^(β x[2])) (E^(β x[1])
+ E^(β x[2])) y[2])/(1 - (1 - b)^(E^(β x[1]) + E^(β x[2])))

• Thank you. I generalized it and verified it based on your suggestion. – Lucky Dec 13 '18 at 17:25