/*************************************************************************** * Copyright (C) 2007, Paul Lutus * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ ratprint : false; solve_for_var(eq,v) := ev(rhs(solve(eq,v)[1]),fullratsimp,factor); /* print currency amounts */ pcurr(s,x) := printf(true,"~a: ~16,2f~%",s,float(x)); /* the "meta-equation" */ eq:fv=((pb*ir+1)*pmt-(ir+1)^np*((pb*ir*pmt)+pmt+ir*pv))/ir; fpv(fv,np,pmt,ir,pb) := solve_for_var(eq,pv); ffv(pv,np,pmt,ir,pb) := solve_for_var(eq,fv); fnp(fv,pv,pmt,ir,pb) := solve_for_var(eq,np); fpmt(fv,pv,np,ir,pb) := solve_for_var(eq,pmt); fir(fv,pv,np,pmt,pb) := solve_for_var(eq,ir); /* this case isn't really soluble */ pb:0; /* payment at end */ display(fpv(fv,np,pmt,ir,pb)); display(ffv(pv,np,pmt,ir,pb)); display(fnp(fv,pv,pmt,ir,pb)); display(fpmt(fv,pv,np,ir,pb)); display(fir(fv,pv,np,pmt,pb)); /* too bad this isn't real */ /* show examples of payment at beginning and end */ pcurr("FV, Payment at beginning", ffv(0,120,-100,0.01,0)); pcurr("FV, Payment at end ",ffv(0,120,-100,0.01,1));