Showing posts with label economics. Show all posts
Showing posts with label economics. Show all posts

Saturday, May 13, 2023

HP 12C Using TVM variables as Registers

 HP 12C Using TVM variables as Registers



Special Thanks

Regarding the HP 12C Tips talk I gave on HHC 2017, I received this tip from an email from   SergioSamy.   Appreciation and gratitude.  


To watch my HP 12C tip presentation, click here:

https://www.youtube.com/watch?v=Q54UbDzpAIw




Why Use TVM Variables?


Normally, we use the variables n, i, PV, PMT, and FV for time value of money, cash flow, and depreciation calculations.  They can be used for variables for non-finance or other business calculations as well.


When we program on the Classic HP 12C, we have 99 steps.  If the program memory is clear, we have 20 registers from R.9  (register dot-nine) to R0 (register zero).   For every eight steps, a memory register is lost.   


At full capacity of the Classic HP 12C, we only have seven registers left (R0 through R6).  


The moment that we use press the [ Σ+ ] button and use statistics, the registers R1 and R6 get occupied, possibly leaving R0 to use for other purposes:


R1 = n

R2 = Σx

R3 = Σx^2

R4 = Σy

R5 = Σy^2

R6 = Σxy


However, the TVM registers: n, i, PV, PMT, and FV, are permanent memory registers for use.   Today's programs will illustrate this use.   


Note:  Pressing the TVM keys once after a number (key word: after) stores the number in a variable.   If you don't key a number first, then the program solves for the a variable.  Let's look at a couple of examples.



Economic Ordering Quantity


Formula:


EOQ = √(2 * CPO * SLS ÷ (CPU * HOLD%))


CPO = fixed order cost

SLS = number of project sales units

CPU = variable cost per unit

HOLD% = projected cost of holding inventory

EOQ = economic ordering quantity, in units


TVM variables used:


[ n ]:  EOQ, computed

[ i ]: HOLD%,  entered

[ PV ]:  CPU, entered

[ PMT ]:  CPO, entered

[ FV ]:  SLS, entered



Program Code:


Line Number:  Key Code;  Key


01:  45, 14;  RCL PMT

02:  45, 15;  RCL FV

03:  20;  ×

04:  2;  2

05:  20;  ×

06:  45, 13;  RCL PV

07:  45, 12;  RCL i

08:  25;  %

09:  34;  x<>y

10:  33;  R↓

11:  10;  ÷

12:  43, 21;  √

13:  44, 11;  STO n

14:  43,33,00;  GTO 00



Example


CPO = 40.95

SLS = 8,000

CPU = 5.50

HOLD% = 10%


10 [ i ]

5.50 [ PV ]

40.95  [ PMT ]

8000 [ FV ]

[ R/S ].  Result:  1091.45


Source


HP-17B, HP-19B, HP-27S  Step-by-Step Solutions For Your HP Calculator.  Marketing and Sales.   Hewlett Packard.  Edition 1.  January 1988



Quadratic Equation


Instructions:


Find the roots of a*x^2 + b*x + c = 0


The program ends with the discriminant stored in R0. 


D = b^2 - 4*a*c


If D<0, the roots are complex in the form of s ± ti:

s:  real part, stored in PMT

t:  imaginary part, stored in FV


If D≥0, the roots are real and:

Root 1 is stored in PMT

Root 2 is stored in FV


Store a in [ n ], b in [ i ], and c [ PV ].  Then run the program. 


Note:  to get the absolute value, square then take the square root of the number.  This is why I have two square root commands in a row: one is to make the absolute value; the second to take the square root of D. 


Program Code:


Line Number:  Key Code;  Key


01:  45,12;  RCL I

02:  2;  2

03:  21;  y^x

04:  45, 13;  RCL PV

05:  45, 11;  RCL n

06:  20;  ×

07:  4;  4

08:  20;  ×

09:  30;  -

10:  44, 0;  STO 0

11:  45, 12;  RCL i

12:  16;  CHS

13:  2;  2

14:  10;  ÷

15:  45, 11;  RCL n

16:  10;  ÷

17:  44, 14;  STO PMT

18:  45, 0;  RCL 0

19:  2;  2

20:  21;  y^x

21:  43, 21;  √

22:  43, 21;  √

23:  2;  2

24:  10;  ÷

25:  45, 11;  RCL n

26:  10;  ÷

27:  44, 15;  STO FV

28:  0;  0

29:  45, 0;  RCL 0

30:  43, 34;  x≤y

31:  43,33,00;  GTO 00

32:  45,14;  RCL PMT

33:  36;  ENTER

34:  36;  ENTER

35:  45, 15;  RCL FV

36:  30;  -

37:  44, 15; RCL FV

38:  33; R↓

39:  43, 36;  LSTx

40:  40;  +

41:  44,14; STO PMT

42:  45, 0;  RCL 0

43:  43,33,00;  GTO 00


Examples


2*x^2 - 3*x + 6 = 0


2 [ n ]

-3 [ i ] 

6 [ PV ]

[ R/S ]


Results:

D = -39.00   (complex roots)

[ RCL ] [ PMT ]:  Real part:  0.75

[ RCL ] [ FV ]:  Imaginary part:  1.56

0.75 ± 1.56i


x^2 + 8*x - 4 = 0


1 [ n ]

8 [ i ] 

-4 [ PV ]

[ R/S ]


Results:

D = 80

[ RCL ] [ PMT ]:  Root 1:  0.47

[ RCL ] [ FV ]:  Root 2:  -8.47

0.47, -8.47



Hope you find this tip helpful,


Eddie 



All original content copyright, © 2011-2023.  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, October 4, 2020

TI-84 Plus CE: Lorenz Curves and the Gini Coefficient

TI-84 Plus CE:  Lorenz Curves and the Gini Coefficient

Introduction - Graphing Income Inequality

Developed by Max O. Lornez, the Lorenz curve displays the graphs of income distribution and income inequality.  Each point of represents a cumulative percentage of an income level.   An example of a Lorenz curve:

(25%, 9%):   The first 25% of a population earns 9% of the population's total income

(50%, 21%):  Half of the population earns only 21% of the total income.

(75%, 44%):  The bottom 75% of the population earns 44% of the total income.

(100%, 100%):  This represents the total population.  

The Lornez curve is compared against a straight line which connects points (0%, 0%) to (100%, 100%).    The ratio between the top area and the whole curve is called a Gini coefficient.  If the Gini coefficient is 0, then there is no income inequality.  On the other hand, the closer that the Gini coefficient is to 1, there is more income inequality.  The diagram below is a Lorenz curve.



Calculating the Gini Coefficient


Let:

A = the area above the Lorenz  curve and below the straight line

B = the area above the x axis and below the Lorenz curve

W = the total area = A + B = 1/2 * max(x value) * max(y value)  

Note: that the total area is the area of a right triangle


The Gini coefficient is defined as:

G = A / (A + B) = (W - B) / B


TI-84 Plus CE Program: LORENZ

430 bytes


"2020-09-13 EWS"

Menu("LORENZ CURVE", "EQUAL PERCENTILE", 1, "DATA", 2)

Lbl 1

Input "DATA?", L4

dim(L4) → N

cumSum(L4) → L6

seq(100J/N, J, 1, N) → L3

L3 → L5

Goto 3

Lbl 2

Disp "ASCENDING ORDER: Y"

Input "X DATA?", L3

Input "Y DATA?", L4

cumSum(L3) / sum(L3) * 100 → L5

sumSum(L3 * L4) / sum(L3 * L4) * 100 → L6

Goto 3

Lbl 3

"BELOW"

augment( {0}, L5 ) → L5

augment( {0}, L6 ) → L6

sum( seq(.5 * (L5(J) - L5(J-1)) * (L6(J) + L6(J-1)) /2 , J, 2, dim(L6) ) ) → B

"WHOLE"

.5 * max(L5) * max(L6) → W

(W - B) / W → G

Disp "GINI INDEX:", G

Pause

Func

PlotsOff

FnOff

FnOn 1

PlotsOn 1

10 → Xscl : 10 → Yscl

Plot1( xyLine, L5, L6, □, RED)

"max(L6)*X/100" → Y1

ZoomStat


There are two options:

1. Equal Percentile:  Enter the percentage of each bin.  The percentile of each class is divided equally. Example:  for ten data points, the percentiles are split in 10% increments.

(10%, y1%)
(20%, y2%)
(30%, y3%)
(40%, y4%)
(50%, y5%)
(60%, y6%)
(70%, y7%)
(80%, y8%)
(90%, y9%)
(100%, y10%)

2.  Data:  Enter x and y data.   For y data, make sure that list has all of its elements in ascending order.

The graph displays in values of percents.  X Axis: 0 to 100 (representing 0% to 100%).  Y Axis: 0 to 100 (representing 0% to 100%).

Examples

Example 1:  Equal Percentile  

The total health spending for high average per capita in 10% percentiles in 2002.  (see source for background information)

Percentile Percent of Health Spending
10% 0%
20% 0.1%
30% 0.6%
40% 1.2%
50% 2%
60% 3.4%
70% 5.4%
80% 9.1%
90% 16.5%
100% 61.7%


Enter Option 1: Data.   

Gini Index: 0.8633

List = { 0, .1, .6, 1.2, 2, 3.4, 5.4, 9.1, 16.5, 61.7 }




Example 2:  Data

Hourly employees of a company and their wages:

Number of Employees Hourly Wage
156 $15.00
195 $30.00
53 $50.00
49 $70.00

X Data:  {156, 195, 53, 49}
Y Data:  {15, 30, 50, 70}

Gini Index:  0.6379627898



Source:

Reindhardt, Uwe E.   "The Construct of Lorenz Curves and of The Gini-Coeficient to Decpict Degrees in Inequality in Health Care"  Princeton University, WWS 597  (Political Economy of Health Systems) 
Retrieved August 26, 2020 


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, November 10, 2019

HP 12C: Economic Ordering Quantity

HP 12C: Economic Ordering Quantity

Introduction

In inventory control, a business may try to determine the optimum level of inventory, which is known as the economic ordering quantity.  There are several ways to calculate the economic ordering quantity, each with various approaches of what variables and factors to use.  This blog entry will explore two approaches, as described by the HP Step by Step Solutions For Your HP Calculator book for marketing and sales.  (see source)

Economic Ordering Quantity Knowing Costs and Sales

A simple approach to determining economic ordering quantity is by use of the following formula:

EOQ = √(2 * CPO * SALES / ( UNIT_COST * HOLD%) )

where:
EOQ = economic ordering quantity
CPO = the cost of place an order
SALES = the company's annual sales
UNIT_COST = cost per unit of inventory
HOLD% = holding cost as a rate of inventory costs

HP 12C Program:

Step;  Key Code;  Key
01;   2 ;  2
02;  45, 1; RCL 1
03;  20;  *
04;  45, 2;  RCL 2
05;  20;  *
06;  45, 3;  RCL 3
07;  45, 4;  RCL 4
08;  25;  %
09;  34;  x<>y
10;  35;  R↓
11;  10; ÷
12;  43, 21;  √
13;  44, 0;  STO 0
14;  43,33,00;  GTO 00

Instructions:

Store the following values:
R1 = CPO 
R2 = SALES
R3 = HOLD%
R4 = UNIT_COST

Press R/S to calculate EOQ, which is stored in R0.

Example:

R1 = CPO = $35.00
R2 = SALES = 10,000 units
R3 = HOLD% = 20% of inventory value
R4 = UNIT_COST = $4.73 cost per inventory unit

Result:
CPO = 860.21

Economic Ordering Quantity Factoring Discounts and Taxes

This next calculation adds discounts rates, units used, and income taxes. 

EOQ = √(( 2 * (1 - TAX%) * CPO * UNITS_USED)
/ ( (1 - TAX%) * HOLD% * UNIT_COST + DISCOUNT% * UNIT_COST))

where:
EOQ = economic ordering quantity
TAX% = income tax rate
CPO = the cost of place an order
UNITS_USED = inventory units used in a year
UNIT_COST = cost per unit of inventory
HOLD% = holding cost as a rate of inventory costs
DISCOUNT% = discount rate

HP 12C Program:

Step;  Key Code;  Key
01;  1 ; 1
02;  45, 1; RCL 1
03;  25 ;  %
04;  30 ;  -
05; 44,1;  STO 1
06;  2  ;  2
07;  20 ;  *
08;  45, 2 ;  RCL 2
09;  20 ;  *
10;  45, 3 ;  RCL 3
11;  20 ;  *
12;  44, 0 ; STO 0
13;  45, 5 ; RCL 5
14;  45, 4 ; RCL 4
15;  25 ;  %
16;  45, 1 ; RCL 1
17;  20 ;  *
18;  45, 5 ; RCL 5
19;  45, 6 ; RCL 6
20;  25 ;  %
21;  34 ;  X<>Y
22;  33;  R↓
23;  40;  +
24; 45, 0 ; RCL 0
25; 34 ;  X<>Y
26;  10 ;  ÷
27;  43, 21 ;  √
28;  44, 0 ; STO 0
29;  43, 33, 00 ;  GTO 00

Instructions:

Store the following values:
R1 = TAX% = income tax* 
R2 = CPO
R3 = UNITS_USED
R4 = HOLD%
R5 = UNIT_COST
R6 = DISCOUNT%

R1 gets recalculated as  (1 - TAX%)

Press R/S to calculate EOQ, which is stored in R0.

Example:

R1 = TAX% = 22%
R2 = $150.00
R3 = 24,000 units
R4 = 5.1% holding cost
R5 = $8.00 per unit
R6 = 2% discount

Results:
CPO = 3,426.81

Source:
"HP Step By Step Solutions For Your HP Calculator:  Marketing and Sales:  HP-17B, HP-19B, HP-27S"  Hewlett Packard.  January 1988.  Edition 1

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, August 8, 2019

A Choice of Discounts

A Choice of Discounts



Situation

We are ready to purchase two items.  Let A be the cost of the more expensive item, while B is the cost of the less expensive item (A > B).  We have two coupons:

Coupon 1:  Take 10% off of all purchases  (10% off the cost of both A and B)

Coupon 2:  Take 20% off of the most expensive item  (20% off of A, B remains at full price)

The store allows for only one coupon to be used per transaction.  Which coupon gives us the best benefit?  Let's assume that we are only buying two items.

We will not worry about sales tax in this situation.

Calculating the Costs After Discounts

Using Coupon 1:  Let T1 be the total cost using coupon 1.

T1 = (100% -10%) * (A + B)
T1 = 90% * (A + B)
T1 = 0.9 * (A + B)

Using Coupon 2:  Let T2 be the total cost using coupon 2.

Here, A is more expensive, so:

T2 = (100% -20%) * A + B
T2 = 80% * A + B
T2 = 0.8 * A + B

In summary, the total costs are:

T1 = 0.9 * (A + B)
T2 = 0.8 *A + B

Comparing the Two Coupons

Is there a price point of both A and B where the total costs of the two items is the same?  This occurs when T1 = T2.

T1 = T2

0.9 * (A + B) = 0.8 * A + B
0.9 * A + 0.9 * B = 0.8 * A + B
0.1 * A + 0.9 * B = B
0.1 * A = 0.1 * B
A = B

The costs are the same when the cost of both items are the same.

But we assume that A > B.    So, either T1 will be more or T2 will be more.  To determine this, we will need to perform a subtraction.  Let's pick T1 - T2.

If T1 -T2 > 0, then T1 costs more and using the second coupon, 20% of the more expensive item,  is preferable.

If T1 - T2 < 0, then T2 costs more and using the first coupon, 10% of both items, is preferrable.

T1 - T2
= 0.9 * A + 0.9 * B - (0.8 * A +  B)
= 0.1 * A - 0.1 * B
= 0.1 * (A - B)

Since A represents the cost of the more expensive item, A > B, and A - B > 0.  Therefore 0.1 * (A - B) > 0 and T1 > 0.   The second coupon is preferable.

Case Studies

A = $29.99,  B = $24.99:  T1 = $49.48,  T2 = $48.98  (not much difference)

A = $29.99,  B = $13.99:  T1 = $39.58,  T2 = $37.98

A = $29.99, B = $5.99;  T1 = $32.38,  T2 = $29.98  (difference between T1 and T2 increase as discrepancy of costs increase)

Hopefully this helps on all of our future shopping trips,

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.

Classic RPN Stack Operations

  Classic RPN Stack Operations Starting Stack: T:  d Z:  c Y:  b X:  a OVER :   Copies b to the Z and X stacks, while leaving ...