0

The Formula call for variables. I've look all over and can't find what these variables are and what values they're supposed to represent.

RATE($nper, $pmt, $pv, $fv = 0.0, $type = 0, $guess = 0.1)

Is anyone familiar with this function? Do you know what values the variables are meant to represent?

Plummer
  • 6,522
  • 13
  • 47
  • 75
  • I'm not familiar with `phpexcel`, but surely there are docs – Madbreaks Jan 18 '13 at 18:19
  • @MarcB : Please see the question title. Visit this website if you're unfamiliar with the code. http://phpexcel.codeplex.com/ Or, if you're unfamiliar with the difference between server scripting and magic, this link: http://en.wikipedia.org/wiki/Magic_(paranormal) – Plummer Jan 18 '13 at 18:20
  • tplummer: phpexcel is simply a php library to manipulate excel files. if you're embedding a spreadsheet function, it doesn't matter WHAT library you're doing it with - the library cannot embed a function that excel itself doesn't support. – Marc B Jan 18 '13 at 18:30
  • @MarcB: Excel supports RATE(). I'm using it. Just so we're on the same page... http://stackoverflow.com/questions/3198939/recreate-excel-rate-function-using-newtons-method – Plummer Jan 18 '13 at 18:34
  • and that's what I'm saying as well... you should have gone straight to the Excel documentation instead of asking about phpexcel here. – Marc B Jan 18 '13 at 19:13
  • I don't think you're really saying much of anything, to be honest with you. – Plummer Jan 18 '13 at 20:17

2 Answers2

3

From the Excel help file:

RATE(nper,pmt,pv,fv,type,guess)

For a complete description of the arguments nper, pmt, pv, fv, and type, see PV.

  • Nper - is the total number of payment periods in an annuity.
  • Pmt - is the payment made each period and cannot change over the life of the annuity. Typically, pmt includes principal and interest but no other fees or taxes. If pmt is omitted, you must include the fv argument.
  • Pv - is the present value — the total amount that a series of future payments is worth now.
  • Fv - is the future value, or a cash balance you want to attain after the last payment is made. If fv is omitted, it is assumed to be 0 (the future value of a loan, for example, is 0).
  • Type - is the number 0 or 1 and indicates when payments are due.

    Set type equal to the following if payments are due:

    • 0 or omitted - At the end of the period
    • 1 - At the beginning of the period
  • Guess - is your guess for what the rate will be.

    If you omit guess, it is assumed to be 10 percent.
    If RATE does not converge, try different values for guess. RATE usually converges if guess is between 0 and 1.

Remark

Make sure that you are consistent about the units you use for specifying guess and nper. If you make monthly payments on a four-year loan at 12 percent annual interest, use 12%/12 for guess and 4*12 for nper. If you make annual payments on the same loan, use 12% for guess and 4 for nper

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
dnagirl
  • 20,196
  • 13
  • 80
  • 123
  • Should've figured it used the same variables as the Excel function since it's meant to be a clone. Thanks! – Plummer Jan 18 '13 at 18:21
  • Please don't just blindly copy/paste from a manual, make sure your data is presentable. I've put exactly 2 minutes in editing this post, you should do it yourself next time. – Madara's Ghost Jan 18 '13 at 18:24
  • 2
    @MadaraUchiha: while yours certainly looks nicer, I felt that the text was readable enough, especially since most people wanting to use Excel functions have the Excel manual available to them. If you have a look at my posting history you'll see that I spend quite a bit of time editing for presentation. I very rarely "blindly" paste in anything. Thanks for prettifying my post, but please don't assume I posted without thought. – dnagirl Jan 18 '13 at 18:30
1

I dont know if you need to implement this function, but in any case, I looked at how this algorithm was built and even though I was not able to access the excel source code (or the google worksheet) I found that this is not a simple calculation. About this math, more can be read here:

https://brownmath.com/bsci/loan.htm#Eq8

The function, in PHP, may be something like this:

function rate($nprest, $vlrparc, $vp, $guess = 0.25) {
    $maxit = 100;
    $precision = 14;
    $guess = round($guess,$precision);
    for ($i=0 ; $i<$maxit ; $i++) {
        $divdnd = $vlrparc - ( $vlrparc * (pow(1 + $guess , -$nprest)) ) - ($vp * $guess);
        $divisor = $nprest * $vlrparc * pow(1 + $guess , (-$nprest - 1)) - $vp;
        $newguess = $guess - ( $divdnd / $divisor );
        $newguess = round($newguess, $precision);
        if ($newguess == $guess) {
            return $newguess;
        } else {
            $guess = $newguess;
        }
    }
    return null;
}
chuckedw
  • 648
  • 2
  • 9
  • 13