Calculated Fields Form Blog

Tips and cases of use for a successful WordPress website with calculated forms.

Blog / Compound Interest Calculator

Compound Interest Calculator

Compound Interest refers to earning or paying interest on interest. This post teaches you to calculate the Compound Interest with the Calculated Fields Form.


Compound Interest refers to earning or paying interest on interest. Although it can apply to both savings and loans, it is easiest to understand when thinking about savings. After each compound period, the interest earned over that period is added to the principal so that the next calculation of interest includes the original principal plus the previously earned interest.

The Calculated Fields Form plugin includes many operations modules for different working areas, like the "Financial Operations" module. The "Financial Operations" module is distributed with the Developer and Platinum versions of the plugin. However, I will implement the form using only basic mathematical operations, making it compatible even with lower versions of the plugin.

The Compound Interest uses the following formulas and definitions:

Future_Value = Principal_or_Start_Amount * (1+rate)^nper + Payment*( ((1+rate)^nper - 1)/rate )
rate = ((1+Annual_Interest_Rate/Compound_Frequency)^(Compound_Frequency/Payment_Frequency))-1
nper = Payment_Frequency * Years_of_Growth
Total_Payments = Payment*nper
Total_Interest = Future_Value - Principal_or_Start_Amount - Total_Payments



Annual_Interest_Rate = nominal annual interest rate (decimal), fieldname2
Compound_Frequency = number of compounding periods per year, fieldname3
Payment_Frequency = number of payment periods per year, fieldname6
rate = rate per payment period
nper = total number of payment periods
Payment = an amount added to the principal at the end of each payment period, fieldname5

Compound Interest Calculator

The equations code for the result fields are:

Future Value

(function(){
    var due = 0,
        A = fieldname5,   /* Payment */
        P = fieldname1,   /* Start Amount */
        r = fieldname2,   /* Annual Interest Rate 5% */
        n = fieldname3,   /* Compound Frequency */
        t = fieldname4,   /* Years of Growth */
        p = fieldname6,   /* Payment Frequency */

        rate = Math.pow(1+r/n,n/p)-1,
        nper = p * t,
        F = (P+(due ? A : 0))*Math.pow(1+rate, nper) + A*( (Math.pow(1+rate,nper) - 1)/rate ) - (due ? A : 0);
    return PREC(F,2);
})()

Total Payments

(function(){
    var A = fieldname5,
        t = fieldname4,
        p = fieldname6,
        nper = p * t,
        TotalPayments = A*nper;
    return PREC(TotalPayments, 2);
})()

Total Interest

(function(){
    var P = fieldname1,
        Total_Interest = fieldname7 - P - fieldname8;
    return PREC(Total_Interest,2);
})()

The form includes a bonus. It generates a chart representing the earning evolution with the principal amount and payments and the balance curve.

Progress Chart

The plugin generates the chart using the CFFCHART operation, distributed with the Developer and Platinum versions of the plugin. For lower versions of the plugin, the calculations will still work except for the chart.