# Thread: Derivative of a function wrt to another function

1. ## Derivative of a function wrt to another function

I have 3 sets called A,B and C. Each set is a union of 2 non intersecting subsets, i.e. :
$A = \{A1 \cup A2\}, A1 \cap A2 = \emptyset$
$B = \{B1 \cup B2\}, B1 \cap B2 = \emptyset$
$C = \{C1 \cup C2\}, C1 \cap C2 = \emptyset$

I'm interested in knowing what happens to the quantity
|A| / (|A| + |B| + |C|)

when I change :
|A2| / (|A2| + |B2| + |C2|)

One way might be to take the derivative of the first quantity with respect to the second quantity, although it doesn't seem to be an easy computation ? Is there another way ?

2. ## Re: Derivative of a function wrt to another function

You can only take a derivative of a continuous quantity. Since the sizes of the sets are either infinite or discrete, you run into trouble, that is, a derivative is out of the question. However, we'll cheat and assume that the sizes of the sets could be real numbers (non-negative). Maybe you can start with $A$ and $B$ and no $C$. That is, you are looking for the change of $|A|/(|A|+|B|)$ with respect to $|A_2|/(|A_2|+|B_2|)$. If you call the first one $f$ and the second one $g$ you are looking for something like

$\frac{df}{dg} = \frac{df/d|A_2|}{dg/d|A_2|} = \frac{df/d|B_2|}{dg/d|B_2|}$

I wonder if you have any other constraints on the sets. If the sets are arbitrary finite sets you can think of the following. Let $|A_1| = u, |A_2| = x, |B_1| = v, |B_2| = y$. Then you have

$f = \frac{u+x}{u+x+v+y},\quad g = \frac{x}{x+y}$

Now we have

$\frac{df}{dg} = \frac{df/dx}{dg/dx} = \frac{df/dy}{dg/dy}$

We have

$\frac{df}{dx} = \frac{v+y}{(u+v+x+y)^2}$
$\frac{df}{dy} = -\frac{u+x}{(u+v+x+y)^2}$
$\frac{dg}{dx} = \frac{y}{(x+y)^2}$
$\frac{dg}{dy} = - \frac{x}{(x+y)^2}$

So now we have

$\frac{df}{dg} = \frac{(v+y) (x+y)^2}{y (u+v+x+y)^2}$
$\frac{df}{dg} = \frac{(u+x) (x+y)^2}{x (u+v+x+y)^2}$

Or you can even use the more symmetric

$\frac{df}{dg} =\frac{1}{2}\left(\frac{(v+y) (x+y)^2}{y (u+v+x+y)^2}+\frac{(u+x) (x+y)^2}{x (u+v+x+y)^2}\right)$

$=\frac{(x+y)^2}{2(u+v+x+y)^2}\left(\frac{v+y}{y }+\frac{u+x}{x}\right)$

Writing this last one in your notation we have

$\frac{df}{dg} = \frac{(|A_2|+|B_2|)^2}{2(|A|+|B|)^2}\left(\frac{|A |}{|A_2|}+\frac{|B|}{|B_2|}\right)$

This whole derivation assumes that the values are continuous but it should not be a problem to evaluate it at discrete values. Also, I actually think that there is no factor of 2 in the denominator.

3. ## Re: Derivative of a function wrt to another function

Thanks for helping. The sets are indeed discrete but it's probably fine to assume continuity for my application. I also don't have any other additional constraints on the sets.