Constant Amount Applied to Principal - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: Constant Amount Applied to Principal (/thread-19086.html) Constant Amount Applied to Principal - Eddie W. Shore - 11-06-2022 05:36 PM Constant Amount Applied to Principal In most loans and mortgages, the amount of payment applying to interest and principal depends on the running balance. This program assumes the customer wants an equal portion to apply to principal each payment. As a result, the payment itself, principal and interest, will vary. The simple algorithm to amortize this loan is this: For K=1 to N: Int = Bal * I%รท100 Tpmt = Int + CPMT Bal_k = Bal_(k-1) - CMPT where: Bal = balance of a loan PV = loan amount CPMT = amount to be applied to principal each payment I% = interest rate Int = interest calculated for payment K Tpmt = total payment for payment K HP Prime Program CPYMT The result of CPYMT is a four column matrix with rows: k, interest in payment k, total payment k, resulting balance. Keep in mind that program asks for periodic interest rate. Code: Code: ``` EXPORT CPYMT() BEGIN // 2022-10-24 EWS // fix 2 HFormat:=1; HDigits:=2; // local LOCAL n,i,p,b,it,tp,k,x; LOCAL ll,l0,l1,l2,l3,m; // main INPUT({n,i,p,b},"Constant Principal", {"N = ","I%=","PMT=","LOAN="}, {"# of payments", "periodic interest rate", "constant payment", "loan amount"}); l0:={0}; l1:={0}; l2:={b}; FOR k FROM 1 TO n DO it:=b*i/100; tp:=p+it; b:=b-p; ll:=MAKELIST(x,x,1,n+1,1); l0:=CONCAT(l0,{it}); l1:=CONCAT(l1,{tp}); l2:=CONCAT(l2,{b}); END; l3:=CONCAT(ll,l0); l3:=CONCAT(l3,l1); l3:=CONCAT(l3,l2); m:=list2mat(l3,SIZE(l0)); m:=TRN(m); RETURN m;  END;``` Example Five year loan of \$10,000 where the lendee requests an equal amount of principal to be applied each annual payment (\$2,000 a year). The loan rate is 6.99%. Inputs: N = 5 I% = 6.99 PMT = 2,000.00 LOAN = 10,000.00 Result: Year 1: Interest: \$699.00; Total Payment: \$2,699.00; Balance: \$8,000.00 Year 2: Interest: \$599.20; Total Payment: \$2,559.20; Balance: \$6,000.00 Year 3: Interest: \$419.40; Total Payment: \$2,419.40; Balance: \$4,000.00 Year 4: Interest: \$279.60; Total Payment: \$2,279.60; Balance: \$2,000.00 Year 5: Interest: \$139.80; Total Payment: \$2,139.80; Balance: \$0.00 Source "Constant Payment to Principal Loan" HP-41 User's Library Solutions: Lend/Lease/Savings Hewlett Packard. November 1980