5 Replies Latest reply on Aug 27, 2006 10:02 AM by Newsgroup_User

Hi All -
Anybody REALLLY good with CF Calculations?
I am trying to follow this formula for APR
http://www.efunda.com/formulae/finance/apr_calculator.cfm

I have it working... almost... but something is off with my exponentials,
causing infinite numbers.

<cfset p1 = ((#cc#+#ee#)*#rr#*((1+#rr#)^#nn#))>
<cfset p2 = (((1+#rr#)^#nn#)-1)>
<cfset pp = #p1#/#p2#>

<cfoutput>
P1 = #p1#
p2 = #p2#
pp=#pp#
</cfoutput>

This yields the following

P1 = 1.#INF
p2 = 1.00589517508E+307
pp = 1.#INF

Where are those INF valued coming from?
And why is my p2 showing up as something+something else, instead of it doing the math??

--
Michael Evangelista
Evangelista Design / Evangelista Consulting, inc.
www.evangelista-web.com

Maybe you are entering the rate #rr# as a percentage amount instead of dividing it by 100 before using it in the equations. The value in p2 is in scientific or exponential notation. You need to move the decimal place by the 307 positions indicated.
Here's the formula for doing the monthly payment. The APR is going to be considerably harder, as it requires iterative approximations.

<cfset loanAmount = 200000 />
<cfset extraCost = 5000 />
<cfset interestRate = 7.5/1200 />
<cfset numberOfMonths = 360 />

<cfset monthlyPayment = ((loanAmount + extraCost) * interestRate * ((1 + interestRate)^numberOfMonths)) / (((1 + interestRate)^numberOfMonths) - 1) />

<cfoutput>
#monthlyPayment#
</cfoutput>
YES good point - my mistake, thanks!

--
Michael Evangelista
Evangelista Design / Evangelista Consulting, inc.
www.evangelista-web.com

"draves" <webforumsuser@macromedia.com> wrote in message news:ecr4fc\$53h\$1@forums.macromedia.com...
> Maybe you are entering the rate #rr# as a percentage amount instead of dividing
> it by 100 before using it in the equations. The value in p2 is in scientific
> or exponential notation. You need to move the decimal place by the 307
> positions indicated.
>

Yes that works!
Thank you!

--
Michael Evangelista
Evangelista Design / Evangelista Consulting, inc.
www.evangelista-web.com

"Hal B. Helms" <webforumsuser@macromedia.com> wrote in message news:ecr6or\$72k\$1@forums.macromedia.com...
> Here's the formula for doing the monthly payment. The APR is going to be
> considerably harder, as it requires iterative approximations.
>
> <cfset loanAmount = 200000 />
> <cfset extraCost = 5000 />
> <cfset interestRate = 7.5/1200 />
> <cfset numberOfMonths = 360 />
>
> <cfset monthlyPayment = ((loanAmount + extraCost) * interestRate * ((1 +
> interestRate)^numberOfMonths)) / (((1 + interestRate)^numberOfMonths) - 1) />
>
> <cfoutput>
> #monthlyPayment#
> </cfoutput>
>

Ok... back again... you are not kidding about the APR formula, yikes.

I merged your code with another attempt, in the form of a cfscript, and it is working
great to show the monthly payment

<cfscript>
loanAmount = #form.LoanAmount#;
extraCost = #totalClosingCosts#;
interestRateAnnual = #loanRate#;
origIntRate = interestRateAnnual/1200;
loanMonths = #loanTerm#*12;
monthlyPaymentsNum = (loanAmount+extraCost)* origIntRate * ((1+origIntRate)^loanMonths);
monthlyPaymentsDen = ((1+origIntRate)^loanMonths)-1;
monthlyPayments = monthlyPaymentsNum / monthlyPaymentsDen;
</cfscript>

But now, I need to find the APR.
Here is one formula that shows it 'in reverse'.. in other words, the equation must be solved to find the missing variable.. and
I have no idea how to do that in CF.
http://www.efunda.com/formulae/finance/loan_calculator.cfm
What I need to do is use 'scenario #2'

Any ideas how to approach that?

--
Michael Evangelista
Evangelista Design / Evangelista Consulting, inc.
www.evangelista-web.com

"Hal B. Helms" <webforumsuser@macromedia.com> wrote in message news:ecr6or\$72k\$1@forums.macromedia.com...
> Here's the formula for doing the monthly payment. The APR is going to be
> considerably harder, as it requires iterative approximations.
>
> <cfset loanAmount = 200000 />
> <cfset extraCost = 5000 />
> <cfset interestRate = 7.5/1200 />
> <cfset numberOfMonths = 360 />
>
> <cfset monthlyPayment = ((loanAmount + extraCost) * interestRate * ((1 +
> interestRate)^numberOfMonths)) / (((1 + interestRate)^numberOfMonths) - 1) />
>
> <cfoutput>
> #monthlyPayment#
> </cfoutput>
>