[Math] partial derivative with Maxima

maxima-softwarepartial derivative

I have the following equation:

(v * w) / ( v * ((v * w) + (1 - v) * x) )

I want to find the partial derivative with respect to v. Using the quotient rule I get:

(-w * (w - x)) / ((v * w + x - v * x)^2) 

If I set the values of the variables:

v = 0.50
w = 0.25
x = 0.40

the above partial derivative is 0.3550296. I tried to check this answer using the following:

delta   = 0.00001
v.delta = v + delta

(v.delta*w / (v.delta^2*w + v.delta*x - v.delta^2*x) - v*w / (v^2*w + v*x - v^2*x)) / delta

which returns 0.3550312.

However, I also tried checking my answer using the following line in the software Maxima:

diff( (w / (v * w + x - v * x)) , v, 1);

The software returns:

(w * (w - x)) / ((-v * x + x + v * w)^2)

which gives:

-0.3550296

which is the same number I obtained with the quotient rule, except with the opposite sign.

If I plot the original function with v varying from 0 to 1 I get an increasing line from approximately 0.65 to 0.95.

All of the above suggests to me an error in my Maxima code. However, perhaps my partial derivative via the quotient rule is wrong. If my partial derivative via the quotient rule is correct I will post a follow up question in the Maxima section of StackOverflow. Thank you for any advice. Sorry that I do not know how to format my equations.

EDIT:

Thank you for the answers below. They were very helpful. I returned to Maxima and this time I noticed that there was a negative sign in front of the equation Maxima returned. The negative sign was positioned immediately in front of the division line separated with such a small gap that I did not realize the negative sign was there earlier despite looking at the Maxima equation repeatedly. I thought there was just one continuous line. Having realized my mistake, I would like to leave this question here because the answers were so helpful.

Best Answer

Well, we get the partial derivative as:

$$\frac{\partial}{\partial v} \frac{v w}{v (v w+(1-v) x)} = -\frac{w (w-x)}{(v (w-x)+x)^2}$$

If we substitute the values:

  • $v = 0.50$
  • $w = 0.25$
  • $x = 0.40$

Look at the magnitude of $w-x$ and it is negative which affects the numerator, but not the denominator, hence the result is positive, that is $= 0.35503$.

Related Question