3191
|
1 ## Copyright (C) 1995, 1996, 1997 Kurt Hornik |
3426
|
2 ## |
3922
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
3191
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
3426
|
9 ## |
3922
|
10 ## Octave is distributed in the hope that it will be useful, but |
3191
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3426
|
13 ## General Public License for more details. |
|
14 ## |
3191
|
15 ## You should have received a copy of the GNU General Public License |
3922
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
3191
|
19 |
3439
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} pvl (@var{r}, @var{n}, @var{p}) |
|
22 ## Return the present value of an investment that will pay off @var{p} |
|
23 ## in one lump sum at the end of @var{n} periods, given the interest |
|
24 ## rate @var{r}. |
3191
|
25 ## |
3439
|
26 ## Note that the rate @var{r} is specified as a fraction (i.e., 0.05, |
|
27 ## not 5 percent). |
|
28 ## @end deftypefn |
3191
|
29 |
3458
|
30 ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> |
|
31 ## Description: Present value of an investment that pays off at the end |
3191
|
32 |
|
33 function v = pvl (r, n, p) |
3426
|
34 |
3191
|
35 if (nargin != 3) |
|
36 usage ("pvl (r, n, p)"); |
|
37 endif |
3426
|
38 |
4030
|
39 if (! (isscalar (r) && (r > -1))) |
3458
|
40 error ("pvl: r has to be a scalar > -1"); |
4030
|
41 elseif (! (isscalar (n) && (n > 0))) |
3458
|
42 error ("pvl: n has to be a positive scalar"); |
4030
|
43 elseif (! isscalar (p)) |
3458
|
44 error ("pvl: p has to be a scalar"); |
3191
|
45 endif |
3426
|
46 |
3191
|
47 v = p / (1 + r)^n; |
3426
|
48 |
3191
|
49 endfunction |