|
|
|
| Title : |
A suite of financial management functions including present and future value of an annuity and a loan payment calculation function.
|
| Categories : |
Algorithms, PHP |
 William Lucking |
| Date : |
Jan 17th 1999 |
| Grade : |
3 of 5 (graded 10 times) |
| Viewed : |
18887 |
| File : |
No file for this code example. |
| Images : |
No Images for this code example. |
|
| Search : |
More code by William Lucking |
|
| Action : |
Grade This Code Example
|
|
| Tools : |
My Examples List |
|
|
|
|
|
|
<?php
/*
by William Lucking (will@ahnet.net) of Affinity Hosting, LLC, offering
low cost hosting providing UNIX accounts supporting PHP3, PHP2, and
mySQL
(no telnet access).
We are always hiring PHP programmers in the Los Angeles area, full
and
part-time.
This suite offers many financial management functions that can be
used (but not limited) for a web based mortgage or loan calculator.
Need some Financial Management training:
http://www.duke.edu/~charvey/Classes/ba350_1997/preassignment/preassign.htm
VARIABLES:
$m = number of periods per year. For instance, if you are For
instance, if you are making payments monthly then this number is 12.
$n = total number of periods. For instance, if you are
compounding monthly for 5 years, this number would be 60 (12 months
x 5 years).
$R = annual interest rate (represented as a decimal, 8% = .08)
$pmt = first or re-occuring payment or receipt (this number cannot
vary for differing cash flows)
$principal = present value of an annuity, or current principal of a
loan used in the PaymentCalc function
*/
// present value of an Annuity
// uses include defining Remaining Principal of a loan/mortgage
function PVannuity ($m,$n,$R,$pmt) {
$Z = 1 / (1 + ($R/$m));
return ($pmt * $Z * (1 - pow($Z,$n)))/(1 - $Z);
}
// Given the compounding, principal, interest rate, you can calculate
the monthly payment
function PaymentCalc ($m,$n,$R,$principal) {
$Z = 1 / (1 + ($R/$m));
return ((1 - $Z) * $principal) / ($Z * (1 - pow($Z,$n)));
}
// future value of an Annuity
function FVannuity ($m,$n,$R,$pmt) {
return $pmt * ((pow((1 + $R/$n),$m) - 1)/($R/$n));
}
// present value of a single payment
function PVsingle ($m,$n,$R,$pmt) {
return $pmt * pow((1 + $R/$m),-$n);
}
// future value of a single payment
function FVsingle ($m,$n,$R,$pmt) {
return $pmt * pow((1 + $R/$m),$n);
}
// future value of a single payment with continuous compounding
function FVperp ($m,$n,$R,$pmt) {
return $pmt * exp($R * ($n/$m));
}
?> |
|
| Function to convert Arabic numbers into Roman Numerals Categories : Algorithms, PHP, Date Time | | | How to Generate a random 8 character string in php3? Categories : PHP, Algorithms | | | Library of math functions to expand the functionality of PHP3. Version 1.2.1 fixes a major problem with the gcd function.
Categories : Algorithms, PHP, Math. | | | Credit Card Identification and Validation Class - The credit_card class provides methods for cleaning, validating and identifying the type of credit card numbers. Categories : PHP, PHP Classes, Credit Cards, Ecommerce, Algorithms | | | Boolean Keyword Interpreter Categories : PHP, Algorithms, Search Engines | | | Dollar Serial Number Validator Categories : PHP, Security, Algorithms | | | what salt do I have to feed the crypt function with to make it work like the htpasswd command of apache? Categories : Algorithms, PHP, Authentication | | | Mail-lib provides a simple interface to the sendmail program. Note: you must actually have sendmail on your machine (sorry windows NT users). Categories : Algorithms, Email, PHP | | | Prime number finder (Sieve of Erastothenes) Categories : PHP, Algorithms, Math. | | | The Porter Word Stemming Algorithm in PHP
Reduces words to their base stem for search engines and indexing Categories : Algorithms, PHP, Strings | | | A recursive function to traverse a multi-dimensional array where the
dimensions are not known Categories : Arrays, PHP, Algorithms | | | Kasskooye($path) tell you the complete size of a folder
Categories : PHP, Algorithms, Utilities, Filesystem | | | A simple bubblesort that takes 2 arrays as argument.The first one is the actual data used for sorting, the second is data that will "tag along" with the first array, for instance a descriptive text about the data in the first array. Categories : Algorithms, Arrays, PHP, Complete Programs | | | How to validate an Israeli ID number. Categories : Ecommerce, PHP, Algorithms | | | Object() = Custom __autoload + Singleton. "automagically" instantiates a class and always retuns the same instance of the same class. It's pretty useful when you want to have persistence in objects. Categories : PHP, PHP Classes, Algorithms | |
| |
| |
|