# Math:Resource Preservation

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Let's say you have 120 bars, 80% resource preservation, and 0% doubling chance.

If a dagger takes one bar to create, how many daggers would you create on average out of 120 bars?

The answer is $\frac{120}{1 - 80/100}= \frac{120}{0.2} = 600.$

The main idea behind the preservation is that you can reuse what you preserved to make more stuff.

Using the same example with 120 bars, you take 120 actions producing 120 daggers, but with 80% preservation you are left with $120 \times 0.8 = 96$ bars.

Now you can use those 96 bars to do the same thing, and you will be left with $96 \times 0.8 = 76.8$ bars on average.

Repeat that to infinity, and you will get the average number of daggers that you will produce from 120 bars.

But how do we calculate this number?

So the number of daggers produced is $120 + (120 \times 0.8) + (120 \times 0.8 \times 0.8) + ... + (120 \times 0.8^n)$ where $n$ is a number as huge as you can imagine.

If we replace the number $120$ with any other number $a$ and the probability $0.8$ with any other probability $r$, the number of produced daggers would look like this:

$a + (a \times r) + (a \times r \times r) + ... + (a \times r^n)$

or in short

$\sum\limits_{n=0} ar^n$.

This thing is called a geometric progression, and it turns out that its value is equal to $\frac{a(1 - r^n)}{1 - r}$.

And because $r \lt 1$ and $n$ is very big, it can be simplified to $\frac{a(1 - 0)}{1 - r} = \frac{a}{1 - r}$.

So, coming back to our example where $a = 120$ and $r = 0.8$, we get

$\frac{120}{1 - 0.8} = 600$.