1
$\begingroup$

In one of my computer science classes we were given a homework problem that deals with partial differentiation. I never learned this in my math classes and have been trying to teach myself this but really could use some help with where to start.

So given this equation: (the numbers are supposed to be subsets, dont know how to format)

$F = (X1 - (W1A1 + W2B1))^2 + (X2 - (W1A2 + W2B2))^2 + (X3 - (W1A3 + W2B3))^2 $

So the problem suggests that we have to solve for w1 and w2 and minimize the error. I know this means that I have to take the derivative and set it equal to 0. From what I've read and videos I've watched, I think I'm understanding that when solving for w1 or w2 in a equation like this you need to treat the other variables as constants.. So my work so far is (just subbing into the top equation):

$$dF/dW1 = (0 - (A1 + 0))^2 + (0 - (A2 + 0))^2 + (0 - (A3 + 0))^2 = (-A1)^2 + (-A2)^2 + (-A3)^2 = -2A1 + -2A2 + -2A3$$

and..

$$dF/dW2 = (0 - (0 + B1))^2 + (0 - (0 + B2))^2 + (0 - (0 + B3))^2 = (-B1)^2 + (-B2)^2 + (-B3)^2 = -2B1 + -2B2 + -2B3$$

This is where I am stuck pretty much. I guess my main question is how did doing that step in each help us get close to finding w1 and w2? We are trying to find the vector w-> (arrow above w) such that in the equation w-> * x-> the error is minimized. X-> = [Ai, Bi] and w-> = [W1, W2]

Thanks

$\endgroup$

1 Answer 1

1
$\begingroup$

You should review the rules for taking derivatives, specifically the chain rule. (Either that, or expand all squares in $F$, but this is more algebraically painful.)

The basic idea is that the derivative of the square of some function $g$ should be computed as $(g^2)'=2 g g'$. For example, the derivative of $(3x-7y+5)^2$ with respect to $y$ is $2(3x-7y+5)(-7)$.

Using the chain rule on $$F = (X_1 - (W_1A_1 + W_2B_1))^2 + (X_2 - (W_1A_2 + W_2B_2))^2 + (X_3 - (W_1A_3 + W_2B_3))^2 $$ I get $$\frac{\partial F}{\partial W_1} = -2 A_1 (X_1 - (W_1A_1 + W_2B_1)) -2A_2 (X_2 - (W_1A_2 + W_2B_2)) -2A_3 (X_3 - (W_1A_3 + W_2B_3)) $$ and similarly $$\frac{\partial F}{\partial W_2} = -2 B_1 (X_1 - (W_1A_1 + W_2B_1)) -2B_2 (X_2 - (W_1A_2 + W_2B_2)) -2B_3 (X_3 - (W_1A_3 + W_2B_3)) $$

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .