• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CF Calculation - so close.. please help?!?

LEGEND ,
Aug 26, 2006 Aug 26, 2006

Copy link to clipboard

Copied

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??

I know I am close... please help!


--
Michael Evangelista
Evangelista Design / Evangelista Consulting, inc.
www.evangelista-web.com
Custom Small Business Website Solutions


TOPICS
Advanced techniques

Views

476

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 26, 2006 Aug 26, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 26, 2006 Aug 26, 2006

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 27, 2006 Aug 27, 2006

Copy link to clipboard

Copied

YES good point - my mistake, thanks!

--
Michael Evangelista
Evangelista Design / Evangelista Consulting, inc.
www.evangelista-web.com
Custom Small Business Website Solutions



"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.
>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 27, 2006 Aug 27, 2006

Copy link to clipboard

Copied

Yes that works!
Thank you!

--
Michael Evangelista
Evangelista Design / Evangelista Consulting, inc.
www.evangelista-web.com
Custom Small Business Website Solutions



"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>
>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 27, 2006 Aug 27, 2006

Copy link to clipboard

Copied

LATEST
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
Custom Small Business Website Solutions



"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>
>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation