## Off topic, anyone here a math dude?

### Off topic, anyone here a math dude?

I am writing a small finacial calculator. I know how to calculate a
payment:

payment = (amount * pow(1 + interval_rate, interval * periods)) /
((1+interval_rate) * ((pow(1+intrval_rate, intervals * periods)
-1)/interval_rate)

or at least something like that. Anyway, I have checked it against Excel
and Applix and there payment functions seem to agree.

What I need to calculate interest vs principal for specific payments. I
know it is easy, I just can't remember it, and can't find any books
right Now, if anyone knows off the top of their head, drop me a an
e-mail.

--
Mohawk Software
Windows 95, Windows NT, UNIX, Linux. Applications, drivers, support.
Take the Mohawk Software Computer Survey at: www.mohawksoft.com

### Off topic, anyone here a math dude?

>I am writing a small finacial calculator. I know how to calculate a
>payment:

>payment = (amount * pow(1 + interval_rate, interval * periods)) /
>((1+interval_rate) * ((pow(1+intrval_rate, intervals * periods)
>-1)/interval_rate)

>or at least something like that. Anyway, I have checked it against Excel
>and Applix and there payment functions seem to agree.

>What I need to calculate interest vs principal for specific payments. I
>know it is easy, I just can't remember it, and can't find any books
>right Now, if anyone knows off the top of their head, drop me a an
>e-mail.

>--
>Mohawk Software
>Windows 95, Windows NT, UNIX, Linux. Applications, drivers, support.
>Take the Mohawk Software Computer Survey at: www.mohawksoft.com

Well, I have a BA in Math, does that count? :-)

Admittedly, computing the interest given a payment P, number of payments n,
and principal A(0) might be a bit tricky.

If I define A(n) as the principal left after n payments,
then A(0) is the original amount of the loan, A(1) = A(0)*(1+r) - P,
A(2) = A(1)*(1+r) - P, and so on, where P is of course the payment
and r is the rate, expressed as a fraction (.05 = 5%, for example).
At this point, r is unknown.

Now, A(n)=A(0)*(1+r)**n - P*(1+r)**(n-1) - P*(1+r)**(n-2) ... - P*(1+r) - P
= A(0)*(1+r)**n - P*(((1+r)**n-1) / r).

Now we get to solve for r.  Good luck, although it's helped a bit
by noting that A(n) = 0 (we assume the loan is paid off), so

0 = A(0)*(1+r)**n - P*((1+r)**n-1) / r.

But it's a mess no matter how one relates to it.

----

### Off topic, anyone here a math dude?

[crunch]

Quote:>> Now we get to solve for r.  Good luck, although it's helped a bit
>> by noting that A(n) = 0 (we assume the loan is paid off), so

>> 0 = A(0)*(1+r)**n - P*((1+r)**n-1) / r.

>> But it's a mess no matter how one relates to it.

>I hear you. I worked at a banking software company a few years back and
>had this stuff down cold. I now find all I can remember is basic
>amortization. I like counting bits, not someone else's dollars.

>Anyway, I was helping a friend figure out the best way to buy a car and
>wanted to do the whole analysis, interest rate risk, etc. I ended up
>using applix, but am now I want to rewrite this code for myself and make
>it a web calculator.

Yeah, well, best I can suggest is to do successive linear interpolation
or something.  Basically, it's an (n+1)-degree polynomial in r,
which has no nice solution for large n.

One could try this, though:

r = x-1
x = 1+r
0 = A(0)*x**n - P*(x**n-1) / r.
0 = A(0)*x**n*r - P*(x**n-1)
0 = A(0)*x**n*x - A(0)*x**n - P*(x**n-1)
0 = A(0)*x**(n+1) - A(0)*x**n - P*x**n - P
0 = A(0)*x**(n+1) - (A(0) - P)*x**n - P
P = A(0)*x**(n+1) - (A(0) - P)*x**n
P / (x**n) = A(0)*x - (A(0) - P)

Hmm...I was hoping to get something nice, but oh well.

Quote:>--
>Mohawk Software
>Windows 95, Windows NT, UNIX, Linux. Applications, drivers, support.
>Take the Mohawk Software Computer Survey at: www.mohawksoft.com

----

mortgages, though! :-)

Hello !!!!

I am a student of computer sciencie in Spain... I am triying to make a
minishell like bash but smaller...with only a few commands... I have to
implment command time but i am having problems. I am trying to execute a
command in a process child and count the time that it is executing. I have
used the structure tms...but i am not sure which camp of the structure to
use...... Any one can help me..?

Can tell me what i am making wrong? I dont't know how to convert...ticks in
seconds and mseconds... Thank you very much

--
--
Ignacio Robledo Rosell

http://zipi.fi.upm.es/~g990406
****************************************
"When code matters more than comercials"
****************************************