# Calculate Simple Interest and Compound Interest – easy exercises with Matlab

We’ll see how to calculate the simple interest and the compound one in this article. We have to start with some definitions, though.

 Interest is money paid by an individual or organization for the use of a sum of money called the principal. The interest is usually paid at the end of specified equal periods of time (such as monthly, quarterly, or annually). The sum of the principal and the interest is called the amount.

### 1.- Simple Interest

To help us work and calculate the simple interest, we have these two easy formulas:

I = P r t
A = P + P r t

where
I = simple interest
P = principal
r = interest rate per year
t = time in years
A = amount

We can also conclude that
A = P(1 + r t) and
I = A - P

Examples

If an individual borrows \$1000 at 5% per year for 1.5 years, how much interest must be paid on the loan?

I = P r t
I = 1000 (0.05) (1.5)
I = \$75

If an organization invests \$13000 at 4% per year for 3 years, how much will the investment be worth at the end of the 3 years?

A = P + Prt
A = \$13000 + \$13000 (0.04) (3)
A = \$14560

### 2.- Compound Interest

Compound interest means that the interest is paid periodically over the term of the loan which results in a new principal at the end of each interval of time.

The ending balance is given by:

where
A = amount, or ending balance
P = principal
r = annual interest rate
n = compounded times per year
t = number of years

The following video shows an example and a solution using a calculator specially prepared for such purpose. After the video, we show how to solve the problem by creating in Matlab our own function for the task...

Let's create our code! - Example

Find the amount of an investment if \$10,000 is invested at 5% compounded monthly for three years.

Fortunately, we can create a function in Matlab for the compound interest formula, like this:

function A = comp_int(P, r, n, t)
A = P*(1 + r/n)^(n*t);

and we can call it from another m-file, script, or from the command window, in this way:

P = 10000;
r = 0.05;
n = 12;
t = 3;

format bank
A = comp_int(P, r, n, t)

A = 11614.72

### 3.- Continuously Compounded Interest

When the interest is compounded more frequently, we get to a situation of continuously compounded interest. This formula works it out:

A = Pert

where
A = amount, or ending balance
P = principal
e = 2.718281...
t = number of years
r = annual interest rate

Example

Find the amount of an investment if \$10000 is invested at 5% compounded continuously for three years.

Fortunately again, we can create another function to calculate the formula above, like this:

function A = comp_int_2(P, r, t)
A = P * exp(r*t);

and we can call it from another script or from the command window, in this way:

P = 10000
r = 0.05
t = 3
A = comp_int_2(P, r, t)

A = 11618.34

From 'Calculate Simple Interest ' to home

From 'Calculate Simple Interest ' to Finance Formulas

 Top Online calculator Future value Salvage value Initial investments Effective interest rate Calculate loan payment

## Related pages

piecewise defined functionswhat is the salvage value of a carcalculate sq feet from inchesrecursive functions matlabmultiplication algorithm steps3d plotting in matlabbinary to decimal algorithmhow to graph a piecewise functionbmi exampleswrite table matlabcharacteristic equation calculatoroctal to binary examples5 band resistance calculatoralternating harmonic seriesbell graph generatorbasic programs in matlabmatlab probability plottutorial gui matlabtau rcequation of lines calculatorcalculate salvage valuewhat are octal numberscode to convert decimal to binarymatlab callback functionhow to solve system of equations matlabisnan matlabpolynomial root findernodal analysis calculatorhow to sketch a piecewise functionthe prime factorization of 49solve definite integral calculatortrendline matlabquadratic roots equation3d surface plot matlabparallel rc circuit differential equationmatlab inverse function5 band resistance color code calculatorpermutations and combinations calculatorbilinear interpolation formulamatlab fminsearch examplesketch piecewise functiongauss jordan elimination calculator onlinecurvefithow to calculate fibonacci seriesfzero function matlabplot 3d matrix matlaboctal to binary converterexamples of fibonacci seriesmatlab programsfibonacci series generatorconversion to binary numbersmatlab windowalgorithm to find gcdmatlab bisection method codetextscan matlab examplecircle matlabsolve simultaneous equations calculator onlinegui examples matlabmaclaurin series exampleswrite a program for fibonacci seriessolids of revolutionfminsearchconversion hexadecimal to binaryfactorial in matlabcramer rule examplesawtooth waveconversion binary to hexadecimalbinary to decimal converterunit circle tutorialexponential matlabascii table alphabetconversion octal to binarymatlab 2d plotsine seriesrate of depreciation calculatorsolving simultaneous nonlinear equationsexpansion of cosxmatlab rotate figurescilab tutorialbisection example