At 17:49 5-3-03, you wrote:
I'd like to add a mortgage calculator to a client's site. I've been unable
to find the formula.

Well the calculation depends on the companies policy of course. 1. Normal rent calculation would go like this:

where
i = interest or rent over a certain the period of time (
usually between 0 and 1 (1=100%). With 3.5% interest, i is 3.5/100=0.035
n = the amount of timeperiods that passed
$ = pack of money , and $(0) is heap at start, $(n) is at end of n timeperiods


$(n)= $(0) * (1+i)^n

(x raised-to-the-power-of y is sometimes written as x^y, sometimes as x**y (Perl))

in PHP
        $startsum=$_POST['startsum'];
        $interest=$_POST['interest'];
        $timeperiods=$_POST['timeperiods'];
  $endsum = $startsum * pow(1+$interest/100,$timeperiods);

With a 3% year-rent  in 5 years $10 grows to
  $(n) = 10 * 1.03^5

2. Mortgage calculation
Well how do they pay back?
You can have them pay a fixed part of the loan plus the interest of the month, here called an annuiteiten-hypotheek
Then every month you pay
($in_this_month *interest) + (1/$totalmonths * $startsum )


$in_this_month is probably
$n=thismonths number

so the monthly payment would look something like

((1 - $n/$totalmonths) * $startsum ) + (1/$totalmonths * $startsum )

I suppose you can simplify this if you are a mathematician.
If you are a bloody consultant you should have learned these formulas once up on a time.


You can loop through $n of course to make a nice list.






 In searching php.net, I found a discussion from back in
2000 related to some buggy code. My web search hasn't produced anything
other than realtor and mortgage companies and a perl script site. I'm not
familiar with perl and would prefer avoiding it until my knowledge improves.
There were corrections for a java script somewhere, but I'm beginning to
think it is down. Some things seem so obvious that you just don't think you
need to bookmark! So why can't I remember...
Perl is not that hard to translate to PHP if it is clear what every variable means.


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to