comes back with "pow is not defined"

``````
var p = @principal
var r = @rate period
var n = @total number of payments
var r1 = 1+r
var r2 = r*r1
var n1 = n-1
var c1 = Math.pow(r2, n)
var c2 = Math.pow(r1, n1)
var result = p*(c1/c2)
result.toFixed(2)

``````

"the script resulted in infinity" error

This worked. Thank you.

HELP* -- I need calculations for mortgage loans --

If I know the following:
1) Loan Amount = \$100,000
2) Interest Rate = 1%
3) Loan Amortization Period = 30 years
4) Loan Term = 5 years

I need calculations to produce the following results:
1) Monthly Payment
2) Total Interest Paid during "Loan Term"
3) Amortized Loan Balance at the end of "Loan Term"

Hey gang,

just an update. I rewrote the equation and got it to work. I seemed to have a problem with the script and had to delete the calculation field and start over, but all in all below is my info for group benefit.

p = principle

r = rate

n = years

The Formula that I used was:

p * ( (r/12) / (1-(1+(r/12) )^(n*12) ) )

The code was:

var p = @Offer
var r = .06
var n = 20
var r1 = (r/12)
var n1 = -(n*12)
var r2 = 1+r1
var c1 = Math.pow(r2, n1)
var result = (p*(r1/(1-c1)))
result

thanks guys

Sorry the formula was entered wrong. It is P((r(1+r)^n)/((1+r)^n-1)). P = principal, r = rate period, n = total number of payments or periods.

Hi Faisal,
Try with this :

``````
var p = @principal
var r = @rate period
var n = @total number of payments
var r1 = 1+r
var r2 = r*r1
var n1 = n-1
var c1 = pow(r2, n)
var c2 = pow(r1, n1)
var result = p*(c1/c2)
result
``````

also, I have no idea how to do java scripting. Will need some hand holding on this.

Sorry,
Try to replace 'pow' by 'Math.pow' like this :

var c1 = Math.pow(r2, n)
var c2 = Math.pow(r1, n1)

for c1= Math.pow (r2, n)

(2) is the number of digits after comma

Hey Gang, I have tried to use this and for some reason everything comes up 0.00

var p = @Offer
var r = .06/12
var n = 20*12
var r1 = 1+r
var r2 = r*r1
var n1 = n-1
var c1 = Math.pow(r2, n)
var c2 = Math.pow(r1, n1)
var result = p*(c1/c2)
result.toFixed(2)

I have also tried

var p = @Offer
var r = .06
var n = 20
var r1 = 1+r
var r2 = r*r1
var n1 = n-1
var c1 = Math.pow(r2, n)
var c2 = Math.pow(r1, n1)
var result = p*(c1/c2)
result.toFixed(2)

this is a bit out of my wheel house. any help is much appreciated

The problem seems to be var c1

The result .06 to be the power of 20 has to many .0000 . It seems Javascript can't handle that.

C2 works.

Rainer

This post really helped me.  Thanks!