Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 45826 invoked from network); 17 Aug 2008 23:25:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Aug 2008 23:25:01 -0000 Received: (qmail 33545 invoked by uid 500); 17 Aug 2008 23:24:56 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 33496 invoked by uid 500); 17 Aug 2008 23:24:55 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Delivered-To: moderator for user@commons.apache.org Received: (qmail 47134 invoked by uid 99); 16 Aug 2008 23:17:10 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rory.winston@gmail.com designates 66.249.90.178 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:user-agent :mime-version:to:subject:references:in-reply-to:content-type :content-transfer-encoding:from; bh=kaF6gIlJC3whowEj7iMxjnxGTUkquYKBVKf5s9NDcbc=; b=fEjYnDUWIwJzmn7GLYirZdWwglud/d8/49/s37kXnBIH73Ebfdbw4TFdfaVu97ETZ+ sci3/JKNYlLb/UfSmAHc2imS6iTDnFO9Gr0uAZPAarreEEK4ZyY22jNxVtRmMzHZbPOT dApzkM5UQxcXNbxqDadDkm0dQzqeesxVJt8N0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding:from; b=H0shidWRQNZ39bWoRE1fvar1kjcPjcs4t2s3/nayPSYg2pUmYFG5Dp01EFp9Jh7vmo NTuMCCnlpxIqdc0gR5Z3qnVYg2mUOMByccq2DvlxymCVaoDmJQlUZivLjh0AQ71Ie5FA oodWicIu6ye4I94tRQPJ7dVLcjQbr8KwkjnGM= Message-ID: <48A76013.1000002@eircom.net> Date: Sun, 17 Aug 2008 00:17:39 +0100 User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: Commons Users List , david.hoffer@issinc.com Subject: Re: commons-math usage to calculate APR? References: <000201c8ffdc$2f0abce0$4100a8c0@issinc.com> <48A73C68.4030906@free.fr> <000301c8ffe3$e4a53330$4100a8c0@issinc.com> <48A74A63.1010304@free.fr> <000501c8ffea$c9daf7e0$4100a8c0@issinc.com> In-Reply-To: <000501c8ffea$c9daf7e0$4100a8c0@issinc.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit From: Rory Winston X-Virus-Checked: Checked by ClamAV on apache.org If your loan fees are expressed as a fixed amount you may be able to represent the total PV of the loan as loan amount + fees, and then solve for the monthly payment amount using the annuity formula: PV = C(1/r - 1/(r(1+r)^t)) => C = PV/(1/r - 1/(r(1+r)^t)) Then you can build a payment schedule and calculate the APR of the entire loan plus fees by calculating the IRR of the cash flows. Do you actually need commons-math to do this? Could you do it in Excel instead, using the IRR() or PMT() functions? That would probably be easier. Rory David Hoffer wrote: > Luc, > > It's not clear to me that I could. See another email I just sent for the > approximate formula. > > I think Newton-Raphson or Bisection can be used to solve the non-linear part > but I don't know how. > > -Dave > > -----Original Message----- > From: Luc Maisonobe [mailto:Luc.Maisonobe@free.fr] > Sent: Saturday, August 16, 2008 3:45 PM > To: Commons Users List > Subject: Re: commons-math usage to calculate APR? > > David Hoffer a �crit : > >> My usage is for USA only at this point. >> >> I have inputs of loanAmount, monthlyInterestRate, numberMonths, loanFees; >> > so > >> this would be for fixed monthly payments. >> > > You can try this (considering monthlyInterestRate is a number between > 0.0 and 1.0, i.e. percent values have already been divided by 100.0, and > considering the loanFees are fixed monthly fees): > > public double getMonthlyPayment(final double loanAmount, > final double monthlyInterestRate, > final int numberMonths, > final double loanFees) { > final double f = Math.pow(1 + monthlyInterestRate, numberMonths); > return loanFees + monthlyInterestRate * f * loanAmount / (f - 1); > } > > Could you compute the APR from this monthly payment ? > > Luc > > >> I understand that commons-math doesn't have specific finance methods >> > however > >> I think the APR formula is a non-linear equation that I was hoping >> commons-math could help solve. >> >> -Dave >> >> -----Original Message----- >> From: Luc Maisonobe [mailto:Luc.Maisonobe@free.fr] >> Sent: Saturday, August 16, 2008 2:45 PM >> To: Commons Users List >> Subject: Re: commons-math usage to calculate APR? >> >> David Hoffer a �crit : >> >>> Can anyone point me to an example of how to use commons-math to calculate >>> APR (Annual Percentage Rate)? >>> >> There are no specific finance related algorithm in commons-math. >> >> >>> I think this is solvable using either the NewtonSolver or BisectionSolver >>> but I am not sure how to accomplish this. Perhaps a different way is >>> better. >>> >> I think so, but it depends on what you really need. APR computation >> seems to be slightly different depending on local regulations (for >> example USA or EU). It also depends on the assumptions you do and the >> input data. For example you can compute it one way for fixed monthly >> payments and another way for varying monthly payments. >> >> >>> Any help would be greatly appreciated. >>> >> Could you explain your needs more precisely ? >> >> Luc >> >> >>> Thanks. >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org >>> For additional commands, e-mail: user-help@commons.apache.org >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org >> For additional commands, e-mail: user-help@commons.apache.org >> >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org >> For additional commands, e-mail: user-help@commons.apache.org >> >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org