]> Creatis software - CreaPhase.git/blob - octave_packages/financial-0.4.0/fvl.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / financial-0.4.0 / fvl.m
1 ## Copyright (C) 1995-1998, 2000, 2002, 2005-2007 Kurt Hornik <Kurt.Hornik@wu-wien.ac.at>
2 ##
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
6 ## version.
7 ##
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11 ## details.
12 ##
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
15
16 ## -*- texinfo -*-
17 ## @deftypefn {Function File} {} fvl (@var{r}, @var{n}, @var{l})
18 ## Return the future value at the end of @var{n} periods of an initial
19 ## lump sum investment @var{l}, given a per-period interest rate
20 ## @var{r}.
21 ##
22 ## Note that the rate @var{r} is specified as a fraction (i.e., 0.05,
23 ## not 5 percent).
24 ## @end deftypefn
25
26 function v = fvl (r, n, l)
27
28   if (nargin != 3)
29     print_usage ();
30   endif
31
32   if (! (isscalar (r) && r > -1))
33     error ("fvl: r has to be a scalar > -1");
34   elseif (! (isscalar (n) && n > 0))
35     error ("fvl: n has to be a positive scalar");
36   elseif (! isscalar (l))
37     error ("fvl: l has to be a scalar");
38   endif
39
40   v = l * (1 + r)^n;
41
42 endfunction