Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

It has been years since I took calculus and I am trying to figure out if it is possible to calculate the derivative of a mutli variable equation and what the result would be. This equation is from the video game Diablo 3 that represents your damage based on your critical chance and critical damage. I am trying to determine where are the optimal points (or best bang for buck stat) by using derivatives.

x = critical chance, y = critical damage, z = damage output

Equation: $z = 1 + xy$

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

There are two variables in $z$, $x$ and $y$. Taking the partial derivative in respect to $x$ (treating $y$ like a constant), we get:

$$\frac{\partial z}{\partial x}=y$$

similarly, the partial derivative in terms of $y$ is

$$\frac{\partial z}{\partial y}=x$$

share|improve this answer
3  
+1 for the partial derivatives, And the extrema will be when these guys vanish, which is boring :'( –  Alex Nelson Jul 6 '12 at 16:03
1  
Thank you Argon. I read the wiki article and this makes more sense to me. –  icu222much Jul 6 '12 at 16:10
    
@icu222much No problem, glad to help! –  Argon Jul 6 '12 at 21:53
add comment

As the other answer says, your partial derivatives are $$\frac{\partial z}{\partial x} = y, \quad \frac{\partial z}{\partial y} = x \, . $$

What does this mean in terms of actual gameplay? It means that, if you currently have stats $x=x_0$, $y=y_0$, you should (approximately) value small changes in $x$ by multiplying them by $y_0$, and value small changes in $y$ by multiplying them by $x_0$.

For example, say that at some point in the game your stats are $x=0.5, y=0.25$ (you have a $50$% chance of scoring a critical, and it does one-quarter again as much damage as an ordinary hit). Then, if you're given the option of increasing $x$ by $0.04$ at the cost of decreasing $y$ by $0.01$, you should value this at $0.04(0.25)-0.01(0.5)=0.01-0.005=0.005$. Since this is positive, that option is beneficial.

Since your initial formula for $z$ was fairly simple, this is a little bit superfluous. You could just plug everything into the original $z$-formula. Your initial damage output would be $$z_0=1+(0.5)(0.25)=1.125 \, .$$ Your new damage output would be $$z_1=1+(0.5+0.04)(0.25-0.01)=1.1296 \, .$$ Again, since $z_1>z_0$, we can see that taking this new option is beneficial.

Note that $z_1-z_0=0.0046$: very close to, but not actually equal to, the $0.005$ we computed by using partial derivatives.

Why would you ever use partial derivatives at all, if you could just use the original function to get an exact answer? In this case, I would say you probably shouldn't unless you're in a big hurry. If $z$ were more complicated, though, it might save you a bunch of time, especially if you've got a bunch of different possible changes to try from the same starting point. Since all you care about is which change leads to the biggest (positive) shift in $z$, you won't need to worry that the your partial-derivative computations are approximations unless you have two different potential options that are really close in value.

One thing to be careful about: since $x$ is a probability, presumably it's capped at $1$ (or maybe at some lower value if D3 doesn't like the idea that all your hits could be criticals). So your formula for $z$ probably isn't universal. But it's pretty obvious what you should do when it breaks down (maximize $y$ at all costs, stop worrying about $x$).

share|improve this answer
    
Thank you Micah for your detailed explanation :) –  icu222much Jul 6 '12 at 16:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.