Reputation: 17160
I wanted to write a simple formula in TI-Basic to calculate compound interest for my TI-84 calculator. The formula for compound interest is A = P(1+(r/n))^(n)(t)
where p
is the principal amount, r
is the interest rate (expressed as a decimal), n
is the number of times the principal is compounded, t
is the amount of time, and a
is your final amount with interest added.
When I set variables (see below) and and type the formula in exactly how it is above on my calculators home screen, I get $7332.86, which is the correct answer.
However, when I set the variables and type the formula in as a program (see below), I get $42684.69, which is not correct.
I have tried this program on 2 different TI-84 calculators and I have gotten the same results, so it is not something with my calculator.
I am honestly stumped. I have no idea why this is happening, so if you are good at math, know how to program a ti series calculator, or just see a mistake that I am missing, please tell me because this thing has been driving me crazy!
Program with same inputs and formula but gives different answer than when used on the home screen:
: 2000 -> P
: 0.065 -> R
: 54 -> N
: 20 -> T
: P(1+(R/N))^(N)(T) -> A
: Disp A
Upvotes: 0
Views: 2595
Reputation: 231
A shorter version of the code (if you want to conserve memory space):
:promptP,R,N,T
:Disp P(1+(R/N))^(NT)
Happy coding!
Upvotes: 0
Reputation: 10939
You're formula is equivalent to T*P*((1+(R/N))^(N))
, which is obviously wrong. The reason it's doing this is because of the order of operations. Try P*(1+(R/N))^(T*N)
Upvotes: 1
Reputation: 20314
I don't exactly know what the problem you are facing is, but I think your program should look like this:
Prompt P
Prompt R
Prompt N
Prompt T
Disp P(1+(R/N))^(NT)
EDIT
I think you need an extra set of parentheses. ^(N)(T)
only raises to the power of N
, and then multiplies by T
. Try ^((N)(T))
or simply ^(NT)
.
Upvotes: 2