## Sunday, July 31, 2016

### Casio fx-3650p and fx-50FH: Integer Parts and Fractional Parts

Casio fx-3650p and fx-50FH: Integer Parts and Fractional Parts

Programming can be a pain if the popular functions INT (integer part) and FRAC (fractional part) are not present.  Here is a sample routine to extract the parts for the Casio fx-3650p and fx-50FH.  The key is to take advantage of:

* Switching to and from Fix 0 mode and
* Using the RND (round the number in the display) to the number of decimal places specified in the Fix mode

You can modify or incorporate the sample code to fit your needs.  This basic scheme should work on any programming calculator with at least 2 variable registers and the RND function.   Due to the syntax of RND, the programs for the fx-3650p and fx-50FH are slightly different.

The following results will be stored in the following variables:
A = ABS(A)
B = INTG(A)
C = FRAC(A)
M = SGN(A)

Casio fx-3650P:  Integer and Fractional Parts  (53 steps)

?→A:  \\ ask for a number
A ÷ √( A ²) → M:  \\ sign of A
√( A ²) → A:  \\ absolute value
Fix 0:  \\ go into Fix 0 mode
RND:  \\ round answer in the display
Ans → B:
Norm 1:  \\ back into floating mode
B > A ⇒ B - 1 → B:  \\ adjust B if necessary
BM → B ◢  \\ integer portion
AM - B → C  \\ fractional portion

Casio fx-50FH: Integer and Fractional Parts  (51 steps)

?→A:  \\ ask for a number
A ÷ Abs(A) → M:  \\ sign of A
Abs(A) → A:  \\ absolute value
Fix 0:  \\ go into Fix 0 mode
Rnd(A) →  B :  \\ round A and store in B
Norm 1:  \\ back into floating mode
B > A ⇒ B - 1 → B:  \\ adjust B if necessary
BM → B ◢  \\ integer portion
AM - B → C  \\ fractional portion

Test 1:   13.913
Results:
B = 13 (integer portion)
C = 0.913 (fractional portion)

Test 2: -741.185
Results:
B = -741 (integer portion)
C = -0.185 (fractional portion)

If you find this helpful and can incorporate this routine into future programs.  To those calculators with fractional  and integer part commands: you're awesome.

Eddie

This blog is property of Edward Shore, 2016

### Casio fx-50FH Programs: Ellipses

Casio fx-50FH Programs: Ellipses

Hello everyone!  It is good to be back.  What a crazy year this has been so far.

Introduction

The programs assume that the center of the ellipse is (0,0).  They can be adopted on the current Casio graphing calculators and fx-5800p as well (some adjustments may be necessary).

Casio fx-50FH Ellipse Program 1: Area, Eccentricity, Focal Points
(61 steps)

Text after double slash marks (\\) are comments.

X≥Y ⇒ Goto 0:
X→B: Y→A: Goto 1:  \\ X ≥ Y
Lbl 0: X→A: Y→B:   \\ X < Y
Lbl 1: πAB ◢  \\ calculate area
√(1 - B ² ÷ A ²) ◢   \\ calculate eccentricity
√(A ² - B ²)  \\ focal distance

Test 1: X = 6.63, Y = 1.86
Area:  38.74149229
Eccentricity: 0.959841462
Focal Distance: 6.36748895
Hence the focal points are (-6.36748895, 0) and (6.36748895, 0)

Test 2: X = 2.99, Y = 5.06
Area: 47.53041189
Eccentricity: 0.806738152
Focal Distance: 4.08209505
Hence the focal points are (0, -4.08209505) and (0, 4.08209505)

Casio fx-50FH Ellipse Program 2: Points on the Ellipse, and distance to center (0,0)
(54 steps)

You specify A, B, and D.  D represents the number of steps.  Degree mode is set.

?→A: ?→B: ?→D:
Deg: For 0→M To 360 Step 360 ÷ D:  \\ set up loop
M ◢  \\ display angle
A cos(M) → X ◢   \\ display X coordinate
B sin(M) → Y ◢  \\ display Y coordinate
√( X ² + Y ² ) ◢  \\ distance to center
Next  \\ end loop

Test: A = 3.25, B = 2.75, D = 6
Results: (angle, X, Y, distance)
0.000, 3.250, 0.000, 3.250
60.000, 1.625, 2.382, 2.883
120.000, -1.625, 2.382, 2.883
180.000, -3.250, 0.000, 3.250
240.000, -1.625, -2.382, 2.883
300.000, 1.625, -2.382, 2.883
360.000, 3.250, 0.000, 3.250

Until next time,

Eddie

This blog is property of Edward Shore, 2016

## Thursday, July 14, 2016

### HP 12C Programming Part II: Weekday Number, Gross Up Calculation

HP 12C Programming Part II:  Weekday Number, Gross Up Calculation

Here is Part II of the HP 12C programming series.

HP 12C Weekday Number

This program determines (“extracts” in a sense) the workday number of a given date.  I have this program set to work properly after January 6, 1800, which was a Monday.  The results translate as follows:

1 = MON
2 = TUE
3 = WED
4 = THU
5 = FRI
6 = SAT
7 = SUN

The HP 12C is assumed to be use the United States date format (M.DY – [ g ] [ 5 ]).

Program:
 STEP CODE KEY COMMENT 01 1 1 02 48 . Decimal point 03 0 0 04 6 6 05 1 1 06 8 8 07 34 X<>Y 08 43, 26 ΔDYS Days between dates function 09 7 7 10 10 ÷ 11 43, 24 FRAC 12 7 7 13 20 * 14 1 1 15 40 + 16 43, 33, 00 GTO 00

Input:  Date in MM.DDYYYY format, [R/S]
Result: Date indicator

Test 1: May 22, 1999.
Input:  5.221999 [R/S]
Result:  6 (Saturday)

Test 2:  July 11, 2016

Result:  1 (Monday)

HP 12C Gross Up Calculation

We have to pay a person, and the person lives outside of your tax jurisdiction (outside of your state or the United States).  Tax withholding may be required.  However, you or someone else that is requesting the payment wants the face amount.  In order to give the face amount and fulfill the tax requirement at the same time, the payment is must be grossed up.

Link to the Investopedia article:  http://www.investopedia.com/terms/g/gross-up.asp

Formulas:
Gross up Amount = Face Amount/(1 – Tax Rate%)
Amount of Tax = Gross up Amount – Face Amount

Program:
 STEP CODE KEY COMMENT 01 44, 0 STO 0 Store Tax Rate 02 34 X<>Y 03 44, 1 STO 1 Store Face Value 04 45, 0 RCL 0 05 1 1 06 25 % 07 1 1 08 30 - 09 16 CHS 10 45, 1 RCL 1 11 34 X<>Y 12 10 ÷ 13 31 R/S Display Gross up Amount 14 45, 1 RCL 1 15 30 - 16 43, 33, 00 GTO 00 Display Tax

Input:  face value, [R/S], tax rate, [R/S]
Result: gross amount, [R/S], tax

Part 1:  Face Value:  \$1,000, Tax Rate:  30%.
Input:  1000 [R/S], 30 [R/S]
Result:  1428.57 [R/S], 428.57 [R/S]
The gross up amount is \$1,428.57 (total amount to be paid), and corresponding tax is \$428.57.

Part 2:  Face Value:  \$2,500, Tax Rate:  7%.
Input:  2500 [R/S], 7 [R/S]
Result:  2688.17 [R/S], 188.17 [R/S]
The gross up amount is \$2,688.17 (total amount to be paid), and corresponding tax is \$188.17.

Another note, I will be taking some time off and plan to be back within two weeks.  I want to thank all of you readers and those who commentators, this blog would not be the success that it is without you.  Enjoy summer (or winter if you are in the Southern Hemisphere) and we'll talk again.

Eddie

This blog is property of Edward Shore, 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.

### HP 15C: Error Function and Lower Tail Normal Cumulative Function

HP 15C:   Error Function and Lower Tail Normal Cumulative Function Formulas Used  Error Function  erf(x) = 2 ÷ √π * ∫( e^(-t^2) dt, t = 0 t...