# MiningMath's internal math for NPV Calculation

The following video explains more about the NPV calculation made by MiningMath's algorithm. The understand of these steps might be useful for users working on projects with variable mining costs, which are not yet smoothly implemented on the UI.

1. ## Understand how the discount rate per period is calculated and how to find undiscounted cash-flows

The discount rate (%/year) is provided by the user in MiningMath’s interface, as depicted in the figure below. Figure 1: Interface example to define discount rate (%/year)

## 1.1 Undiscounted cash flow for annual time frames

In an usual scenario period ranges are defined by annual time frames, as depicted in Fig-2. Figure 2: Interface example with annual time frame

In this case, the annual discount rate multiplier (annual_multiplier) to return the discounted cash flow is performed as follows: The table below exemplifies:

1) the NPV (discounted) resulting from a 10 yearly period;

2) the annual discount rate (annual_multiplier) for each period; and

3) the undiscounted NPV as the result of the discounted NPV divided by the annual_multiplier. Table 1: Example of annual multiplying factors and undiscounted cash-flows

1.2 Undiscounted cash flow for custom time frames

MiningMath allows the creation of scenarios in which period ranges are defined with custom time frames (months, trienniums, decades, etc.), as depicted in Figure 3. Figure 3: Interface example with custom time frames

In this case, the discount rate is still provided in years on the interface. However, the discount rate per period follows a different set of calculations.

## 1.2.1 Timeframes shorter than a year

In the example on Figure 3, the first range is composed of 12 periods of one month each. To calculate their discount rate, a timeframe factor for each period t is defined first. This is basically the value associated with each timeframe, as depicted in Figure 3, or a custom value given by the user. Another required information is the year in which t occurs. For instance, the 2ndmonth occurs in year 1, while the 13th month occurs in year 2. The discount rate of periods in which timeframes correspond to less than one year (low_multiplier) is, then, given by the formula: Table 2 shows an example of 12 periods of one month each, with:

1) timeframe factor;

2) cumulative timeframe factors;

3) corresponding annual_multiplierfor each period;

4) the low_multiplierof each period; and finally,

5) the undiscounted cash flow (discounted cashflow divided by the low_multiplier) Table 2: Example of discount rates calculated per month and undiscounted cashflows

## 1.2.2 Timeframes greater than a year

In the example on Figure 3, the last period ranges are composed of 3 trienniums. To calculate the discount rate of a triennium, the annual_multiplier of each year contained in it is computed and then averaged. Hence, the discount rate of periods in which timeframes are greater than one year (great_mutiplier) is given by the formula: Table 3 shows the example of 3 trienniums occuring after 14 periods (12 months and 2 years). The annual_multiplierof each year contained in each triennium is listed. The average of these factors return the great_multiplier of each triennium, which, in turn, divides the discounted cash flow to calculate the undiscounted one. Table 3: Example of discount rates calculated per triennium and undiscounted cash flows

Related Topics