Need help figuring out how to keep a ratio constant between two functions I'm coding up some custom code for an RPG character sheet, and need some help finding a mathematical formula to use.
Alright, so  I have two sets of two variables.
State 1:  damageTaken1 and maxHP1
State 2: damageTaken 2 and maxHP2
I know for a fact that maxHP1 and maxHP2 will never be equal. (maxHP2 > maxHP1 in all cases).
I am supposed to keep the ratio (damageTaken1/maxHP1) and (damageTaken2/maxHP2) equal.
However, at the same time, both the damageTaken variables are also functions themselves; they will change depending on how much damage the character takes.
What I am trying to find, is how to make the damageTaken functions in order to keep the ratios constant.
To give an example;
In State 1, the character has taken 13 damage, and has a max HP of 26. Thus, the current ratio is 50%.
In State 2, the character has 38 HP. Thus, I want the damage taken to be 19, to keep the ratio 50%.
However, this has to go both ways; if the character is in State 2 and takes 19 damage, I want the damageTaken1 formula to make sure that the character has taken 13 damage in State1.
I hope this makes sense to you! I am supposed to code it on a google docs / excel sheet. I should be able to code it up once I know what I'm actually trying to do, but right now I'm kind of lost.
(I also hope this is the right forum for this)
 A: I'm going to call the damages $D_1$ and $D_2$, the maximum health points $H_1$ and $H_2$. If I'm understanding the question, then one of your difficulties might be using variable names that are too long to do efficient pencil-and-paper algebra! For programming it makes sense, but mathematically, long names can be rough.
From what you've said, we have $$\frac{D_1}{H_1} = \frac{D_2}{H_2}.$$
We can rearrange this in a number of ways. To get a value for $D_2$, we can multiply both sides by $H_2$, so that
$$D_2 = H_2 \frac{D_1}{H_1} = D_1 \frac{H_2}{H_1},$$
where this last formula highlights that $D_1$ and $D_2$ are always proportional: To go from $D_1$ to $D_2$, just take $D_1$ and multiply by that max health ratio, $\frac{H_2}{H_1}$. The damage taken scales just like maximum health does: To go from $H_1$ to $H_2$, we multiply by $\frac{H_2}{H_1}$, which is the same way to go from $D_1$ to $D_2$.
To go backwards, from $D_2$ to $D_1$, you'll multiply by the reciprocal of the above ratio; you have $$D_1 = D_2 \frac{H_1}{H_2}.$$
If I've misunderstood the question or it's the algebra itself giving you trouble, let me know.
