# How to get the effective yield?

I have a system that calculates the effective yield. The problem is what formula does the system used to calculate the effective yield. I am trying to convert the system into a mobile application. I am trying to get the formula used. The formula used they said is from the excel function's Rate

Image of the system

Details:

1. Start Date: 10/15/2019
2. End Date: 10/15/2019
3. Interest Rate: 12%
4. Term: 12 Months
5. Loan Amount: 900,000
6. Repayment Amount: 84,000
7. Effective Yield: 21.457184

The rate is the rate such that the present value of outflows (payments) is equal to the present value of the amount(s) borrowed.

The present value of a cashflow is:

c / (1+r/c)^(t*c)

Where c is the amount of the cashflow, r is the rate, c is the number of compounding periods per year, and t is the number of years.

Once your calculation is set up to calculate the present value of the cashflows as a function of r, you can use a binary search or other algorithm to guess and check r values until you find the one that results in 0 net present value.

With the following variables

``````s = loan amount
r = monthly loan rate
n = number of months
d = monthly payment
``````

the standard loan equation is

``````s = 900000
n = 12
d = 84000

(d - d (r + 1)^-n)/r - s = 0
``````

Note, this cannot be manipulated to an expression for `r`.

You can use a solver in your program. E.g. Math.NET Root finding

``````RealRoots.OfFunction(r => (d - d * Pow(r + 1, -n)) / r - s, 0, 0.5)
``````

Solving for `r`

``````∴ r = 0.0178809869

12 r = 21.457184 %
``````

Or in Excel

``````=RATE(12,-84000,900000)*12
``````

21.457184 %