A possible math error in linear algebra

I am trying to work with ChatGPT to find derivative of J with respect to w_i:

J = c^T ( I + D W D.T ) ^ {-2} c

where c is a vector of n, D is square matrix of n x n and W is a diagonal square matrix of n x n, with diagonal elements being w_1, w_2, …, w_n.

I want to find derivative of J with respect to w_i. Attached please find the ChatGPT’s answer. I am not sure the chain rule was applied correctly between the two red boxes. It seems that the exponent should be -3.

Please verify if this is indeed a bug. Thanks.

Not a surprise. Even the most popular math GPT has made really elementary mistakes with me…for example, when converting inches to centimeters, it divides the inches by 2.54 (or whatever the ratio is) instead of multiplying. The standard GPT has also done fairly basic multiplication and been off by two zeroes (decimal points)…definitely not foolproof, even with formulas that most of us laypeople would be able to recognize.