Showing posts with label PITI. Show all posts
Showing posts with label PITI. Show all posts

Saturday, November 23, 2024

Fun with the HP 30b

Fun with the HP 30b



Introduction





The following programs are for the HP 30b Business Professional. Did you know that the 30b has a programming mode? The program mode has room for 10 programs with a total of 290 steps, where each key press is counted. Thankfully, shifts and hold-shifts are merged steps.


I couldn’t get the MSG or R/S commands to work properly. Therefore I use an approach that I often use for the Voyager calculators (HP 11C, 12C, 15C): store everything first and then run the program.


Disp5 is like the PSE (pause) command, it stops the execution for a second. Disp can be set to 1-9. Disp1 lasts for 1/5 second.


All programs are done in the Algebraic instead of the RPN I usually do on HP calculators.


All the results in the examples, except the last one, are rounded to four decimal places.



Program 0: f(x,y) = (x * y) / (x + y)


f(x, y) = (x * y) / (x + y)


Store x in memory 1 and y in memory 2.


Prog 0 =

RCL 1

×

RCL 2

÷

( ↓

RCL 1

+

RCL 2

) Swap

=

Stop


Examples:

x = 1.5, y = 16; Result: 1.3714

x = 3.6, y = 32; Result: 3.2360

x = 8.7, y = 10; Result: 4.6524



Program 1: PITI – Principal, Interest, Taxes, and Insurance


This program calculates the monthly payment of PI (principal and interest) and PITI (principal, interest, taxes, and insurance). The program assumes that payments per year setting (P/YR) is set to 12.


Store to Memory:

M1: Annual insurance rate.

M2: Annual property tax rate.

N: number of payments

I/YR: interest rate of the loan

PV: amount of the loan


It assumed that there is no balloon payment (FV = 0), although this program can be modified to include balloon payments by removing the first two steps (0 FV).


Prog 1 =

0

FV

PMT

Disp5

Disp5

-

( R↓

RCL 1

+

RCL 2

) Swap

/

1

2

0

0

*

RCL PV

=

Stop


Examples:


N = 360

I/YR = 8.9%

PV = 289000

Insurance Rate = 1% (1 STO 1)

Property Tax Rate = 1.3% (1.3 STO 2)


Result:

PMT: -2304.60

PITI: -2858.51



N = 360

I/YR = 8.9%

PV = 289000

Insurance Rate = 1% (1 STO 1)

Property Tax Rate = 1.3% (1.3 STO 2)


Result:

PMT: -2304.60

PITI: -2858.51



Program 2: Quadratic Equation – Po-Shen Lo Method

This program solves the monic quadratic polynomial:


x^2 + B * x + C = 0


where the solutions:

U^2 = B^2 / 4 – C

x1, x2 = - B / 2 ± √(U^2)


Store to Memory:

M1: B

M2: C


Prog 2 =

RCL 1

X^2

/

4

-

RCL 2

=

STO 0

-

RCL 1

/

2

=

STO 3

Disp5

Disp5

-

2

*

RCL 0

=

STO 4

Stop


M3: root 1 ( -B / 2 + √(U^2) )

M4: root 1 ( -B / 2 + √(U^2) )


This program finds real roots only. If there are no real roots, then the program displays an error.


Examples:


x^2 – 2 * x – 24 = 0

B = -2 STO 1

C = -24 STO 2

Roots: 6, -4


x^2 – 10 * x + 21 = 0

B = -10 STO 1

C = 21 STO 2

Roots: 3, 7



Program 3: Lease with Advanced Payments (HP 12C – see source)


This program calculates the regular monthly payment of a lease when the borrower pays a set number of payments in advance. Payments per year (P/YR) is assumed to be set at 12 while the calculator is set to End of Period payments.


Store in Memory:

number of payments [ N ]

annual lease rate [ I/YR ]

residual value [ FV ]

number of payments to be made in advance [ STO ] 0

loan amount [ STO ] 1 (not PV)


Prog 3 =

0

PMT

0

PV

PV

+

RCL 1

=

STO 2

0

FV

RCL N

-

RCL 0

=

N

1

+/-

PMT

( R↓

PV

+

RCL 0

) Swap

1/X

*

RCL 2

=

Stop


Examples:


Total Payments: 48 [ N ]

Rate: 13 [ I/YR ]

Residual Value: 7,000 [ FV ]

Payments in Advance: 1 [ STO ] 0

Loan Amount: 25,000 [ STO ] 1


Result: -536.06



Total Payments: 60 [ N ]

Rate: 8.8 [ I/YR ]

Residual Value: 12,000 [ FV ]

Payments in Advance: 3 [ STO ] 0

Loan Amount: 118,000 [ STO ] 1


Result: -2,229.71



For those of you in the United States, Happy Thanksgiving!


Source


Hewlett Packard. HP 12C Financial Calculator: User’s Guide. Edition 5. 2008. San Diego, CA. pp. 124-126


Eddie


All original content copyright, © 2011-2024. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Sunday, May 15, 2022

Python: Financial Functions (2nd Edition)

Python:  Financial Functions (2nd Edition)


This is an update to the python file, which I first released on May 17, 2020:


https://edspi31415.blogspot.com/2020/05/numworkscasio-micropythonpython.html


I am able to transfer and test the python file to a Numworks calculator through the online editor, and TI-84 Plus CE Python through the TI Connect CE.  Because only the math module is used, the python file can be run in most, if not all calculators with Python, as well as Python 3.  


What is included?


*  time value of money calculations

*  net present value and internal rate of return

*  net present value (xnpv) and internal rate of return (xirr) when periods between flows are not consistent, a 365 day-year is assumed

*  simple interest:  calculating interest, total, and solving for principal

*  profit calculations: cost-sell-markup

*  adding sales tax

*  percent change

*  present and future value uniform stream factors

*  compound interest calculations of a single stream:  solve for present value, future value, number of periods, and periodic interest

*  days between dates

*  specific applications:  monthly payment, PITI, qualifying loan amount, sinking fund, expressing a list of amounts as a percent of the sum, prorating an amount among a list of flows


Download the Python file and the instructions (pdf file) here:

https://drive.google.com/file/d/1l7Xg9dM-RHfekKkU7A1Wjay76-yVc56S/view?usp=sharing


Size: about 3,800 bytes.  


Eddie


All original content copyright, © 2011-2020.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Saturday, April 24, 2021

TI-Nspire CX and CX II: Finance Widgets

TI-Nspire CX and CX II:  Finance Widgets


Financial Widgets


The zip file has five widgets:


simple interest widget:  Calculates the total interest paid in a simple interest loan


pi payment widget:  Calculates the payment of a monthly mortgage without a balloon payment.  


piti widget:  Calculates the PITI (payment-interest-tax-insurance) of a mortgage.  Down payment, annual property tax, and annual property insurance are included.


qualified loan amount widget:  Determines the amount of purchase price a buyer can afford.  The standard 28/36 ratio test is used, compares the two methods, and uses the minimum payment to estimate the qualified amount.  


qualified income test widget:  Test whether the proposed PITI and debt payments against a buyer's income  


Instructions


1.  Download the zip file here:  https://drive.google.com/file/d/1cl-yMpcwRHypGa1kdi66ThZs2xf5pPaQ/view?usp=sharing

2.  Save the widget (tns) files to the MyWidgets folder.

3.  Any tns file in the MyWidgets can be opened as a regular document or be added to a document by Insert-Widget.  

4.  When operated as a widget, highlight the entire page by Ctrl+A, pressing [ menu ], selecting 1. Actions, 1.  Evaluate (Enter).  


Eddie


All original content copyright, © 2011-2021.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Sunday, May 17, 2020

Numworks/Casio MicroPython/Python: Financial Functions

Numworks/Casio MicroPython/Python:  Financial Functions 

My first python script for the Numworks calculator:  finance.py

Great calculator and glad I finally have one. 

Introduction

The following scripts creates the user functions for the following financial functions:

pchg(old, new):  Returns the percent change between two numbers
Example:  pchg(1400,2600) returns 85.71

taxlplus(amt, tax): Adds the tax rate to an amount. amt + tax%.  Results are rounded up to 2 decimal places.
Example:  taxplus(59,9.5) returns 64.6

uspv(n,i):  Takes n (number of payments) and i (periodic interest rate) and calculates the uniform present value factor.  PV = PMT * USPV.  Future value is assumed to be 0.
Example:  n = 36 payments, i = 0.25%.  uspv(36,0.25) returns 34.39

usfv(n,i):  Takes n (number of payments) and i (periodic interest rate) and calculates the uniform future value factor.  FV = PMT * USFV.  Present value is assumed to be 0.
Example:  n = 36 payments, i = 0.25%.  usfv(36,0.25) returns 37.62

mopmt(yrs,rate,loan):  Calculates the monthly payment of a loan with monthly payments.  Payments are assumed to be due at the end of each month.   Results are rounded to up to 2 decimal places. 
Example:  Loan of $238,000 for 30 years at 4.28% annual rate.  mompt(30,4.28,238000) returns 1175.0

annrate(ppy,cpy,rate):  Calculates the equivalent annual rate given ppy (payments per year), cpy (compounding payments per year), rate (estimated periodic rate).
Example:  ppy = 12, cpy = 2, periodic rate = 0.74%.   annrate(12,2,0.74) returns 9.0459

Source for annrate:
Roger F. Farish and The Staff of the Texas Instruments Learning Center.  Calculator Analysis for Business and Finance.  Texas Instruments, Inc.  1977.  ISBN 0-89512-015-1

sinkfund(yrs,rate,pymt):  Calculates the balance of a sink fund (savings account)  of monthly deposits.   Number of years and the annual interest rate are needed.  Deposits are assumed to be due at the end of each month.   Results are rounded to up to 2 decimal places. 
Example:  Monthly deposits of $400.00 for 5 years, at a rate of 2.9%.  sinkfund(5,2.9,400) returns 25793.77

piti(yrs,rate,loan,tax,insur):   Calculates the monthly payment of a mortgage given:  the term of the loan in years (yrs), the annual interest rate (rate), the mortgage (loan), the annual property tax (tax), and the annual property insurance (insur).  Payments are assumed to be due at the end of each month.  Results are rounded to up to 2 decimal places.
Example:  piti(30,3.3,160000,1349,240) returns 833.15

qualinc(inc,debt,taxins,rate,yrs):  Calculates the qualifying amount given the following parameters:  monthly income (inc), monthly debt payments (debt), monthly proper taxes and insurance (taxins), interest rate (rate), and term of the mortgage in years (yrs).   Mortgage payments are assumed to be due at the end of each month.   The standard debt:income ratio of 28:36 is used.  Results are rounded to up to 2 decimal places.
Example:  qualinc(4485,375,126.83,5.30) returns 207288.6


Python Script: finance.py

# 2020-04-12 EWS

from math import *

# percent change
def pchg(old,new):
  pch=(new-old)/old*100
  return pch

# add sales tax  
def taxplus(amt,tax):
  total=amt*(1+0.01*tax)
  return round(total,2)

# uniform pv factor pv=pmt*uspv
def uspv(n,i):
  factor=(1-(1+0.01*i)**(-n))/(0.01*i)
  return factor

# uniform fv factor fv=pmt*usfv
def usfv(n,i):
  factor=((1+0.01*i)**n-1)/(0.01*i)
  return factor
  
# monthly payment
def mopmt(yrs,rate,loan):
  pymt=loan/uspv(yrs*12,rate/12)
  return round(pymt,2)
  
# equivalent annual rate
def annrate(ppy,cpy,rate):
  irate=cpy*100*((1+0.01*rate)**(ppy/cpy)-1)
  return irate
  
# sinking fund
def sinkfund(yrs,rate,pymt):
  sink=pymt*usfv(yrs*12,rate/12)
  return round(sink,2)

# piti
def piti(yrs,rate,loan,tax,insur):
  pymt=loan/uspv(yrs*12,rate/12)+(tax+insur)/12
  return round(pymt,2)

# qualifying income 28:36 ratio
def qualinc(inc,debt,taxins,rate,yrs):
  a=min(inc*0.36-debt,inc*0.28)-taxins
  qual=a*uspv(yrs*12,rate/12)
  return round(qual,2)

Eddie

All original content copyright, © 2011-2020.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Sunday, March 24, 2019

HP 17BII and HP 17BII+: Finance Solver Equations

HP 17BII and HP 17BII+:  Sales Tax, Substantial Presence Test, Automobile Purchase, Principal Interest Property Tax & Insurance (PITI), Retirement Accounts

Note:  Some equations have the L (Let) and G (Get) functions, which are not available on the brown keyboard of the 17BII+ (around 2003). 

Sales Tax:  Determine the total amount of taxable items and non-taxable items.

AMT=NTAX+TXBL*(1+R%÷100)

AMT:  Total Amount
NTAX:  Items not subject to sales tax
TXBL:  Items subject to sales tax
R%:  sales tax rate

Example 1:  A company purchases equipment which costs $99.99, which was subject to 9.5% sales tax, which includes $139.99 of services.  The services are not subject to sales tax.  What is the total invoice? 

Input:
NTAX:  139.99
TXBL: 99.99
R%:  9.5(%)

Output:
AMT = 249.48

The total of the invoice is $249.48.

Example 2:  During an audit, a company finds an invoice with the total of $236.40 (amount), and the invoice listed non-taxable services of $146.50.  The company lives in a county where the sales tax is 8.75%.  What is the amount of taxable items? 

Input:
NTAX:  146.50
R%:  8.75(%)
AMT:  236.40

Output:
TXBL = 82.67

The amount of taxable items on the invoice is $82.67.

Substantial Presence Test

For more information about the substantial presence test, please click here:  http://edspi31415.blogspot.com/search?q=substantial+presence+

This equation uses Let and Get. 

SPT=IF(L(X:DDAYS(D:12.31+FP(100*D)÷100:1)>183:DATE(D:183):DATE(1.01+(FP(100*D)+.0001)÷100:IP(183-G(X)÷3)))

STP:  Number of days calculated for the Substantial Presence Test
D:  Date (in the format DD.MMYYYY)

Example 1:

D:  1.052019 (1/5/2019),  SPT = 7.072019 (7/7/2019)

Example 2:

D:  6.182008 (6/18/2008), SPT = 12.182008 (12/18/2008)

Example 3:

D:  9.262018 (9/26/2018), SPT = 6.012019 (6/1/2019)

Example 4:

D:  7.102017 (7/10/2017), SPT = 5.062018 (5/6/2018)

Financing the Purchase of an Automobile

This equation deals with the purchase of an automobile. 

AUTO:PRICE*(1-DISC%*.01)*(1+STAX%*.01)-DOWN=PMT*USPV(I%÷12:YRS*12)

PRICE: Sticker price of the automobile
DISC%:  Discount percent
STAX%: Sales tax rate
DOWN:  Down payment (amount)
PMT:  Payment of the loan
I%:  Interest rate of the loan
YRS: Number of years of the loan

Example 1:  The sticker price of a car is $28,000.00.  A discount of 15% is offered.  The car is subject to 10% sales tax.  The dealer offers a 6-year loan at 4.5%.  With $2,000, what is the monthly payment?

Input: 
PRICE: 28000.00
DISC%: 15
STAX%:  10
DOWN: 2000
I%:  4.5
YRS: 6

Output:
PMT = 383.83

The monthly payment is $383.83. 

Example 2:  Assuming the same facts from Example 1, expect the buyer wants to pay no more than $350.00 a month.  What is the required down payment?

Input: 
PRICE: 28000.00
DISC%: 15
STAX%:  10
I%:  4.5
YRS: 6
PMT: 350.00

Output:
DOWN = 4131.42

The down payment needs to be $4,131.42.

Real Estate:  Principal Interest Property Tax & Insurance (PITI)

Determine the total payment of mortgage when considering property tax and property insurance. 

PITI=MORT÷USPV(I%÷12:YRS*12)+(PROP$+INS$)÷12

PITI:  Payment including principal, interest, property tax, and insurance
MORT:  Mortgage amount, price of the property
I%:  Annual interest rate
YRS: Number of the years of the mortgage
PROP$:  Annual property tax
INS$:  Annual property insurance

Example:  A buyer purchases a home with a price of $200,000.00.  The amount is to be financed.  The loan lasts for 30 years and 5% interest rate.  There is annual property tax of $1,200.00 with insurance of $395.95.  What is the buyer's PITI?

Input:
MORT: 200000.00
I%:  5
YRS: 30
PROP$:  1200.00
INS$:  395.95

Output:
PITI = 1206.64

The buyer's PITI is $1,206.64. 

Retirement Accounts:  Future Value and Earned Untaxed Dividends

Determine the future value and untaxed dividends of tax-free retirement accounts (IRS/Keogh).

There are two versions, the second uses Let (L) and Get (G) functions.

Version 1:
IRA: VAL*0+DIV*0+IF(S(VAL):USFV(I%:YRS)*PMT*(1+I%÷100)-VAL:0)+IF(S(DIV):(USFV(I%:YRS)*(1+I%÷100)-YRS)*PMT-DIV:0)

Version 2:
IRA:(VAL+DIV+L(X:USFV(i%:YRS)*(1+I%÷100)))*0+IF(S(VAL):G(X)*PMT-VAL:(G(X)-YRS)*PMT-DIV)

Input Variables:
I%:  Annual Interest Rate
YRS:  Number of Years
PMT:  Annual Payment

Output Variables:
VAL:  Tax Free Value of the Retirement Account
DIV:  Total Untaxed Dividends Earned

Remember, these are untaxed amounts.

Example:
I%:  6.88
PMT:  1000.00
YRS: 40

Output (Results):
VAL = 206811.01
DIV = 166881.01

Source:
Tony Hutchins, Luiz Vieria, and Gene Wright "HP 12C Platinum Solutions Handbook"  Hewlett Packard.  Revised 03.04  2004

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Thursday, July 14, 2016

HP 12C Programming Part I: Modulus, GCD, PITI

HP 12C Programming Part I:  Modulus, GCD, PITI 

The last stop (for now) on my 1980s tour is the Hewlett Packard HP 12C calculator, one of the most popular financial calculators of all time.  The HP 12C was first manufactured in 1982 and has been seen ever since.

Today, there are two versions of the HP 12C:  the original and the Platinum.  The original is RPN only and has 99 programming steps of memory.  The Platinum edition, first released in 2003, has room for 400 steps and includes Algebraic mode.

In this series, I'll concentrate on the 1982 classic.  Albeit, using one manufactured this decade, the processing speed in today's HP 12C's compared to those produced in the 1980s is tremendous.


HP 12C Modulus

This program takes the modulus of two numbers:
Y MOD X = X * FRAC(Y/X)
In this program, X > 0 and Y > 0.

STEP
CODE
KEY
01
10
÷
02
43, 36
LST x
03
34
X<>Y
04
43, 24
FRAC
05
20
*
06
43, 33, 00
GTO 00

Input:  Y [ENTER] X [R/S],  
Result:  Y MOD X

Test 1:  124 MOD 77  = 47
Test 2: 3862 MOD 108 = 82

HP 12C Greatest Common Divisor (GCD)

This program calculates the greatest common divisor of two integers.  You can enter the two integers in either order.

Program:
STEP
CODE
KEY
COMMENT
01
43, 34
X≤Y
Determine which integer is greater
02
34
X<>Y

03
44, 1
STO 1
R1 = max(X,Y)
04
34
X<>Y

05
44, 0
STO 0
R0 = min(X,Y)
06
45, 1
RCL 1
Begin Euclidian division routine
07
45, 1
RCL 1
Recall R1 twice
08
45, 0
RCL 0

09
10
÷

10
43, 25
INTG

11
45, 0
RCL 0

12
20
*

13
30
-

14
43, 35
X=0

15
43, 33, 21
GTO 21

16
34
X<>Y

17
44, 1
STO 1

18
34
X<>Y

19
44, 0
STO 0

20
43, 33, 06
GTO 06

21
45, 0
RCL 0

22
43, 33, 00
GTO 00



Input:  integer [ENTER] integer [R/S]
Result: GCD

Test 1:   GCD(142,25)
Input:  142 [ENTER] 25 [R/S]
Result: 1

Test 2:  GCD(2555, 1365).   Result: 35

HP 12 PITI (Principal, Interest, Taxes, Insurance)

Here is a simple program that calculates the payment (principal and interest) while taking property taxes and insurance in consideration.  Property taxes and insurance are assumed to be combined as an annual amount.  Payments are assumed to be on a monthly basis.

Program:
STEP
CODE
KEY
COMMENT
01
1
1

02
2
2

03
10
÷
(tax + ins)/12
04
44, 0
STO 0

05
14
PMT

06
14
PMT
Need to press PMT twice.  Second press calculates payment.
07
45, 0
RCL 0

08
16
CHS

09
40
+
PITI is assumed to be an outflow
10
43, 33, 00
GTO 00
Ends the program

Input:
Number of Years [ g ] [ n ] (12*)
Annual Interest Rate [ g ] [ i ] (12÷)
Loan Amount [PV]
Annual Property Insurance and Taxes [R/S]
Result:  PITI

Test:  Calculate PITI for a 30-year loan of $205,000.  The rate on the loan is 4.1%.  Annual insurance and property taxes are estimated to be $1,102.50.
Input:  30 [ g ] [ n ] (12*), 4.1 [ g ] [ i ] (12÷), 205000 [PV], 1102.50 [R/S]
Result:  -1,082.43  (PITI = $1,082.43)

This is blog is proerpty of Edward Shore, 2016.




RPN HP 12C: Fibonacci and Lucas Sequences

  RPN HP 12C: Fibonacci and Lucas Sequences Golden Ratio, Formulas, and Sequences Let φ be the Golden Ratio: φ = (1 + √5) ÷ 2...