forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to work out the Annual Percentage Rate (APR)?
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Thu Jan 16, 2003 4:03 pm    Post subject: Reply with quote

I think you'll have to use an incremental rate (starting at .001 or so,
and incremented by .001), and test it each increment to see if it's
correct to make all months come out as they should - if so, there's
gonna be a whole lotta loopin' going on. Wink

BTW, I'd still like to know how ya worked out 10 to the power of 1/12... Wink

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
arcray
Valued Contributor
Valued Contributor


Joined: 13 Jul 2001
Posts: 242
Location: Aude, France

PostPosted: Thu Jan 16, 2003 5:40 pm    Post subject: Reply with quote

Sorry for the non responsiveness. I have been very busy.

I did use the '^' as an indicator of raising to the power of.

%Y can be equal to 12 as the payment is always monthly in this case. In cases it could be daily 1/365th!, but not here.

So:-

Quote:

%A=(1+(%X/100))^1/%Y




%A=(1+(%X/100))^1/12

But I am getting confused as well!

10 to the power of 1/12? Can it be done with Logs?




Andy

_________________
Andrew GRAY
If you don't know I am looking for work, I won't get the job.

andrewrcgray.com
Back to top
View user's profile Send private message Send e-mail
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Thu Jan 16, 2003 7:06 pm    Post subject: Figuring APR Reply with quote

I dealt with the APR problem several years ago in a Clipper application. I can tell you that the only way I found to figure it out is a loop that increments a "test" apr by small amounts until it works out. The math guys I talked to called it a "non-linear" equation.

If anyone is interested, I can post the Clipper code. It is not very complicated, and should be able to be duplicated in VDS, if you are familiar with basic Clipper/dBase programming terminology.

Smile
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu Jan 16, 2003 7:11 pm    Post subject: Reply with quote

Hi jwfv,
Yes please post your clipper code:)

Andy,
That is the direction I was going in myself. You should be able to use Logs to figure this out... I am looking for a calculation that uses Logs...

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Thu Jan 16, 2003 7:22 pm    Post subject: Clipper code - Figuring APR Reply with quote

This is what I have used for many years in issuing loans.

This function accepts 3 variables:

nAmtFin - the amount to be loaned out

nPayment - the amount of each payment (simply the TOTAL that will be paid including interest/fees, divided by the numer of payments)

nNumPmts - the number of payments

With these 3 values, it begins testing APRs and increments or decrements it until it gets to the answer.


Hope this helps. Here is the code:


FUNCTION joeAPR(nAmtFin, nPayment, nNumPmts)
LOCAL nTestAPR := 1.00, nMonthRate, nTestAmtFin, nAdder :=50.00, nCtr := 0, diff := 0
LOCAL JOEVAR:=.F.
DO WHILE JoeVar=.F.
nTestAPR := nTestAPR+nAdder
IF ++nCtr>500
RETURN 999.99
ENDIF
nMonthRate := nTestAPR/100.0000/12
nTestAmtFin := nPayment*((1-(1+nMonthRate)^(-nNumPmts))/nMonthRate)
IF nTestAmtFin = nAmtFin
EXIT
ENDIF
IF nTestAmtFin<nAmtFin
IF nAdder=50
nAdder := 25
nTestAPR := nTestAPR-50
LOOP
ENDIF
IF nAdder=25
nAdder := 10
nTestAPR := nTestAPR-25
LOOP
ENDIF
IF nAdder=10
nAdder := 5
nTestAPR := nTestAPR-10
LOOP
ENDIF
IF nAdder=5
nAdder := 2.5
nTestAPR := nTestAPR-5
LOOP
ENDIF
IF nAdder=2.5
nAdder := .5
nTestAPR := nTestAPR-2.5
LOOP
ENDIF
IF nAdder=.5
nAdder := .01
nTestAPR := nTestAPR-.5
LOOP
ENDIF
EXIT
ENDIF
LOOP
STORE .T. TO JoeVar
END DO
IF nTestAPR-nAdder>999.99
RETURN 999.99
Else
RETURN nTestAPR-nAdder
Endif
Back to top
View user's profile Send private message
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Fri Jan 17, 2003 10:11 am    Post subject: Reply with quote

i have done some investigating, ray, and i can do the apr thing for you using logs in vds BUT i need to know exactly what formulae to use

the web site you suggested is contradictory and makes no sense to me eg. at one stage, he says that P is the annual interest rate and then he says that P is the APR!?!!?!

i looked at the example you posted and some things were not clear:

- how do you work out what you need to pay each month?

- i noticed that the interest rate decreases each month, how do you work out the interest rate for each month?

- and so on...

i need to know exaclty what formulae you used to work out each value in the table you put together for us even if you give me the formulae used by excel at each stage

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
arcray
Valued Contributor
Valued Contributor


Joined: 13 Jul 2001
Posts: 242
Location: Aude, France

PostPosted: Fri Jan 17, 2003 1:14 pm    Post subject: Reply with quote

Serge

I don't have all the info with me at the moment, but will put it all together over the next couple of days for posting here.


Cheers

_________________
Andrew GRAY
If you don't know I am looking for work, I won't get the job.

andrewrcgray.com
Back to top
View user's profile Send private message Send e-mail
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Fri Jan 17, 2003 2:09 pm    Post subject: APR Reply with quote

I will be interested to see if someone comes up with a formula for figuring this out. I was always told that there is no formula for it. The answer I got is that if you have a term loan with equal payment amounts and you are charging a pre-figured amount of interest (not pre-figured interest RATE, but a pre-figured dollar amount of interest), that you could not figure the A.P.R. linearly, but had to estimate, calculate, adjust, recalculate, etc. ... until you reached the answer.


By the way, as you can see in my Clipper solution above, the actual code is very simple. Most of it is simply changing the "adjustment amount" to try to arrive at the answer more quickly. When this code was written, the fastest processor out was the new 286! It was like a supercomputer.
Back to top
View user's profile Send private message
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Thu Sep 29, 2005 7:24 pm    Post subject: Reply with quote

Reviving an old post, because I have a need to implement this function in VDS.

Is there a way to do exponents in VDS? 2^3 or 2^(-1), etc.?

_________________
Joe Floyd
Back to top
View user's profile Send private message
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Fri Sep 30, 2005 2:14 am    Post subject: Reply with quote

Quote:
Is there a way to do exponents in VDS? 2^3 or 2^(-1), etc.?


not directly, as often with vds, you have to find a work around Very Happy Very Happy

to do 2^3, do: ln2 x ln3 and then exp the result

serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Mar 24, 2006 8:16 pm    Post subject: Reply with quote

Hi All,
I was thinking the other day how to do these things with just plain VDS instead of using a DLL. I have finally found a solution that works for most cases. See the code below.

Code:
 Title Simple Pow for VDS
OPTION DECIMALSEP,.
#DEFINE FUNCTION,FPOW
# First a simple use of our new @fpow function
# Just to check that it works you should get 16 = 4^2
%A = @fpow(4,2)
Info %A = 4^2

# Second up a solution for 10^1/12 power
%%numerator = 1
%%denominator = 12
%%Ten = 10
%%TwelthAsDecimal = @fdiv(%%numerator,%%denominator)
%%TenToTwelthPower = @fpow(%%Ten,%%TwelthAsDecimal)
Info 10^1/12 = %%TenToTwelthPower

# Third up a solution for
# nPayment*((1-(1+nMonthRate)^(-nNumPmts))/nMonthRate)

%%nPayment = 400.00
%%nMonthsInYear = 12
%%nTestAPR = 2.5
%%nPercentToDecimal = @fdiv(%%nTestAPR,100)
%%nMonthRate = @fdiv(%%nPercentToDecimal,%%nMonthsInYear)
%%nNumPmts = 10
# The line below does the magic nPayment*((1-(1+nMonthRate)^(-nNumPmts))/nMonthRate)

%%nTestAmtFin = @fmul(%%nPayment,@fdiv(@fsub(1,@fpow(@fadd(1,%%nMonthRate),-%%nNumPmts)),%%nMonthRate))
# Round your answer to 4 digits after the decimal for currency
Info @format(%%nTestAmtFin,13.4)@CR()

Exit
:FPOW
  # A simple function to raise a number
  # to the power of some number using the VDS
  # builtin floating point arithmitic functions
  #x = a^b
  %a = %1
  %b = %2
  %%aisneg = @pos(-,%a)
  %%bisneg = @pos(-,%b)
  If @equal(%%aisneg,1)
    %a = @strdel(%a,1) 
  End
  %x = @fmul(%b,@fln(%a))
  if @equal(%%aisneg,1)
    # really needs a floating mod here but that will
    # happen with GadgetX and you want need this at all.
    %%iseven = @mod(@fint(%b),2)
    if @Zero(%%iseven)
      %x = @fexp(%x)
    else
      %x = -@fexp(%x)
    end
  else
   %x = @fexp(%x)
  end
Exit %x


Have @FPOWerful day VDS users Wink

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Fri Mar 24, 2006 8:21 pm    Post subject: Reply with quote

Looks pretty cool! I'll try to digest it over the weekend.
_________________
Joe Floyd
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Mar 24, 2006 11:45 pm    Post subject: Reply with quote

BTW the fraction 1/12 can also be converted to a floating point using the @fpow() like below.

Code:

Title Simple Pow for VDS
  OPTION DECIMALSEP,.
  #DEFINE FUNCTION,FPOW
 
# Second up a solution for 10^1/12 power
  %%numerator = 1
  %%denominator = 12
  %%Ten = 10
  %%TwelthAsDecimal = @fpow(%%denominator,-%%numerator)
  %%TenToTwelthPower = @fpow(%%Ten,%%TwelthAsDecimal)
  Info 10^1/12 = %%TenToTwelthPower
Exit
FPOW
  # A simple function to raise a number
  # to the power of some number using the VDS
  # builtin floating point arithmitic functions
  #x = a^b
  %a = %1
  %b = %2
  %%aisneg = @pos(-,%a)
  %%bisneg = @pos(-,%b)
  If @equal(%%aisneg,1)
    %a = @strdel(%a,1)
  End
  %x = @fmul(%b,@fln(%a))
  if @equal(%%aisneg,1)
    # really needs a floating mod here but that will
    # happen with GadgetX and you want need this at all.
    %%iseven = @mod(@fint(%b),2)
    if @Zero(%%iseven)
      %x = @fexp(%x)
    else
      %x = -@fexp(%x)
    end
  else
    %x = @fexp(%x)
  end
  Exit %x

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group