Showing posts with label algebraic. Show all posts
Showing posts with label algebraic. 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.

Monday, October 11, 2021

Comparison Between HP 17B and 17BII+

 Comparison Between HP 17B and 17BII+


This is a quick comparison between the original HP 17B and the current (since 2007) silver HP 17BII+ calculators. I hope the 17BII+ is still being produced and sold, it has been quite a while since an update to the 17BII+.  


The main features of the 17B family have remained constant since the original 17B came to the markets in early 1988:


*  Time Value of Money with Amortization

*  Business Calculations including Percent Change, Cost/Sell/Margin/Markup

*  Four Regression Models:  Linear, Logarithm, Power, Exponential

*  Bond Calculations

*  Depreciation including Straight Line, Sum of the Year's Digits, and Accelerated Cost Recovery

*  Days Between Dates, 10 Alarms, Clock

*  10 Memory Registers with Storage Arithmetic

*  Can use the HP 82240 Infrared Printer (82240A/82240B); even though they are well out of production by now


HP 17B

HP 17BII+

HP 17B Mode Menu

HP 17BII+ Mode Menu

Now for the differences:


HP 17B:  (1988)

*   Available Memory:  6,752 bytes

*   Batteries:  3 x LR 44

*   Case Colors:   Brown, Peach-Orange shift key and text

*   Shift functions are printed above the keys


HP 17BII+:  (2007 - present)

*   Available Memory:  about 31,000 bytes

*   Batteries:  2 x CR2032

*   Case Colors:  Silver, Electric Blue shift key and text

*   Shift functions are printed below the function

*   Double line print option  

*   Currency conversion mode

*   RPN mode (this was added to the HP 17BII in 1990)


I did a quick speed test on the equation:


Σ(I:1:525:1:I)  (Result:  138,075)


The original HP 17B won the speed test.


HP 17B Solver

HP 17BII+ Solver


That is about it.   I love the 17B series, which has a rich set of financial functions and a robust solver that includes ore functions that most calculators have.  (including integer part, fractional part, signum, solve if, Σ, date functions, and yes, the Let and Get functions!)

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, January 26, 2020

HP 42S & Casio fx-260 Solar: Continued Fractions

HP 42S & Casio fx-260 Solar: Continued Fractions

Introduction

Let x be a real number.  Then x can be represented by the fraction:

x = n_1 + 1/(n_2 + 1/(n_3 + 1/(n_4 + 1/(n_5 + ...))))

The above form is known as a continuous fraction, which can either have a finite set of terms or infinite set of terms.   In short form, continuous fractions can be written in a vector form:

x = [ n_1, n_2, n_3, n_4, n_5, ... ]

If you are given a continuous fraction (n_1, n_2, etc.), you can calculate x with the following keystrokes, starting with the last term n_k and working left to n_1:

RPN Calculators

1.  Start by entering n_k, then press [ 1/x ]
2.  Loop:  For each n_m for 1 < m < k:  enter n_m, [ + ], [ 1/x ]
3.  For n_1:  Enter n_1, [ + ]

Remember, we are working leftwards. 

Example:

Calculate 2 + 1/( 3 + 1/(5 + 1/2)).   In other words x = [2, 3, 5, 2]

2 [ 1/x ]
5 [ + ] [ 1/x ]
3 [ + ] [ 1/x ]
2 [ + ]

Result:  81/35 ≈ 2.31429

The program CF for the HP 42S (and Swiss Micros DM42 and Free42 emulator) calculates the value of a continued fraction.  Instructions:

1.  Run CF ( [ XEQ ] (CF) )
2.  Enter n_k, press (LAST)
3.  For each n_m for 1 < m < k, enter n_m, press (MID)
4.  For n_1, enter n_1, press (1ST).  You get the result.

HP 42S/DM42/Free 42 Program CF

00 {56-Byte Prgm}
01 LBL "CF"
02 LBL 04
03 CLMENU
04 "LAST"
05 KEY 1 GTO 01
06 "MID"
07 KEY 2 GTO 02
08 "1ST"
09 KEY 3 GTO 03
10 MENU
11 LBL 00
12 STOP
13 GTO 00
14 LBL 01
15 1/X
16 GTO 04
17 LBL 02
18 +
19 1/X
20 GTO 04
21 LBL 03
22 + 
23 CLMENU
24 EXITALL
25 RTN
26 END

Classic Algebraic (AOS) Calculators

We can use the same strategy for classic algebraic calculators such as the Casio fx-260 Solar II and TI-30Xa Solar:

1.  Start by entering n_k, then press [ 1/x ]
2.  Loop:  For each n_m for 1 < m < k: press [ + ], enter n_m, press [ = ], [ 1/x ]
3.  For n_1:  Enter n_1, [ + ]

Remember, we are working leftwards. 

Calculate 2 + 1/( 3 + 1/(5 + 1/2)).   In other words x = [2, 3, 5, 2]

2 [ 1/x ]
[ + ] 5 [ = ] [ 1/x ]
[ + ] 3 [ = ] [ 1/x ]
[ + ] 2 [ = ]

Result:  81/35 ≈ 2.31429


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.

Tuesday, October 11, 2011

RPL Programming Tutorial - Part 5 - HP 49g+/50g: Prompt and Introduction to Algebraic Objects

Excuse me, but I must prompt you for something.

Welcome to the second week of my RPL tutorials, using the Hewlett Packard HP 49g+ and 50g calculators. Today's session will cover the PROMPT command.

The PROMPT command sets the program to ask the user for input. That input can be whatever you practically want: text, numbers, matrices, and equations. The user enters the requested information and presses the key sequence [LS] [ON] (CONT) . The [LS] [ON] sequence tells the calculator that the user is ready to move on.

The PROMPT structure is this:

"String that asks the user for input" PROMPT

Today we will do two programs using PROMPT: a simple program that picks an integer from 1 to N, and a more complex one that takes an equation and graphs it.

In this bag we have lotto balls from 1 to 49, and the first number is...

This program will ask you for a number (N), the number of draws (X), and the calculator will return X integers randomly selected from 1 to N. One caveat in this program is that the numbers selected can repeat.

The Program ONETO

Comments will be italicized, starting with an asterisk. You will not need to pre-load the stack with ONETO - all the inputs will be prompted for.

As a reminder:

[LS] means the left shift key (white on the 50g, green on the 49g+)
[RS] means the right shift key (orange on the 50g, red on the 49g+)
Pressing [ALPHA] twice will put the calculator in ALPHA-LOCK mode. If you want lower case letters, press [LS] then the letter. For greek and other characters, select [RS] then the letter.

Hint:

During program entry, you can press [RS] [ . ] for a carriage return. This can make program entry easier to see and read. Best of all, this does not affect program entry or execution.

Note:

The key [big X] is located on the 5th rows of keys up from the bottom. I will use this to distinguish the X character from the times key [ x ].

Program Input:

[RS] [ + ] ( << >> )
* Start the program entry
[RS] [ x ] ( "" )
[ALPHA] [ALPHA] [MODE] (H) [TOOL] (I) [APPS] (G) [MODE] (H) [SPC] [EVAL] (N) [TAN] (U) [HIST] (M) [F2] (B) [F5] (E) [ √ ] (R) [RS] [+/-] (=) [ALPHA]
[ &rarr ] [LS] [EVAL] (PRG) [NXT] [F5] (IN) [NXT] [F1] (PROMPT)

* Enters the first prompt request, "HIGH NUMBER="
[RS] [ x ] ( "" )
[ALPHA] [ALPHA] [LS] 3 (#) [SPC] [ ' ] (O) [F6] (F) [SPC] [F4] (D) [ √ ] (R) [F1] (A) [+/-] (W) [SIN] (S) [RS] [+/-] (=) [ALPHA]
[ &rarr ] [F1] (PROMPT)

* Enters the second prompt request, "# OF TIMES="
[RS] 0 ( &rarr ) [ALPHA] [EVAL] (N) [SPC] [big X]
* Enters N and X and declares them as local variables
[RS] [ + ] (<< >>) 1 [SPC] [big X]
[F6] (PRG) [F3] (BRCH) [LS] [F4] (FOR)

* Use the current menu to go back to the Program level, enters FOR-NEXT structure
[ALPHA] [STO>] (K) [SPC] [ALPHA] [EVAL] (N)
[LS] [SYMB] (MTH) [NXT] [F1] (PROB) [F4] (RAND)
[ x ] 1 [ + ] [NXT] [F6] (MTH) [F5] (REAL) [NXT] [IP] (F5)

* Enters the commands for the For loop
[ENTER]
* Terminate program entry

[ ' ] [ALPHA] [ALPHA] [ ' ] (O) [EVAL] (N) [F5] (E) [COS] (T) [ ' ] (O) [ALPHA] [ENTER] [STO>]

The completed program:

<< "HIGH NUMBER=" PROMPT
"# OF DRAWS=" PROMPT
&rarr N X
<< 1 X
FOR K N RAND * 1 + IP
NEXT >> >>


Instructions:

1. Run ONETO
2. The calculator will prompt "HIGH NUMBER=" at the top of the screen. Enter the high number and then press [LS] [ON] (CONT).
3. The calculator will prompt "# OF DRAWS=" at the top of the screen. Enter the number of draws and then press [LS] [ON] (CONT).
4. The calculator fills the stack with randomly selected numbers. Use [HIST] and [ &uarr ] to view the numbers. Press [ON] when done viewing the stack.
5. You may want to clear the stack before continuing.

Example:

A possible set of 12 random integers from 1-12 is: 9, 4, 7, 2, 11, 1, 10, 4, 1, 4, 1, 7.

Graphing an equation from the Stack Program

This program graphs a given an function y(x) using specified window settings. This is just one way of graphing an equation, which is an alternate way to graphing functions without using the graphing set up screens (Y=, WIN, GRAPH, and 2D/3D). The function can be traced and analyzed just like any other functions that are plotted.

The Catalog

You can access all the commands that the 49g+ and 50g has in the catalog. To access the catalog, press [RS] [SYMB] (CAT). If you press [ALPHA] and a letter, you can quickly scroll to that part of the catalog. You may be able to get a few letters if you are fast enough.

The other thing that is nice about the 49g+ and 50g is that the commands can be typed. This may be a helpful and faster alternate than trying to hunt commands in the menu or catalog. However, in this tutorial, the keystrokes I show will make use of the catalog.

Commands that are Used

* XRNG: Sets the left and right boundaries of the plot screen. The left boundary is taken from Level 2; the right boundary is taken from Level 1.
* YRNG: Sets the bottom and top boundaries of the plot screen. The bottom boundary is taken from Level 2; the top boundary is taken from Level 1.
* FUNCTION: Sets the calculator to Function mode.
* STEQ (Store Equation): Stores an equation in the EQ variable. The EQ variable is a system variable which the calculator uses to plot and solve equations with. EQ can have a list of more than one equation or expression.
* INDEP: Sets a variable as independent. Useful when setting up a plot. It makes sense to make the independent variable 'X' or even 'T' or ' θ', but you can make the independent variable anything you want.
* ERASE: Erases the plot screen and gets the calculator ready to draw a fresh, new plot.
* DRAW: Has the calculator draws whatever is stored in EQ.
* DRAX (Draw the Axes): Has the calculator draw the axes.
* PICTURE: Switches the calculator to the plot (picture) environment.

With all these commands to play with, let's program GRPFX.

The Program GRPFX

[RS] [ + ] (<< >>)
[RS] [ x ] ( "" )
[ALPHA] [ALPHA] [1/x] (Y) [LS] [ - ] (parenthesis) [big X] [RS] [+/-] (=)

* Input the string "Y="
[LS] [EVAL] (PRG) [NXT] [F5] (IN) [NXT] [F1] (PROMPT)
* Inserts the Prompt command. Leave this menu open.
[RS] [SYMB] (CAT) [ALPHA] [SIN] (S) scroll until you find STEQ
[F6] (OK)

* Use the catalog to find the STEQ command. You can hold [ &darr ] and [ &uarr ] to quickly scroll the catalog.
[RS] [SYMB] (CAT) [ALPHA] [F6] (F) find FUNCTION [F6] (OK)
* Set the calculator to FUNCTION mode
[ ' ] [ (big) X ] [ &rarr ] [RS] [SYMB] [ALPHA] [TOOL] (I) find INDEP [F6] (OK)
* Set X to be the independent variable.
[RS] [ x ] ( "") [ALPHA] [ALPHA] [big X] [HIST] (M) [TOOL] (I) [EVAL] (N) [RS] [+/-] (=) [F1] (PROMPT)
[RS] [ x ] ( "" ) [ALPHA] [ALPHA] [big X] [HIST] (M) [F1] (A) [big X] [RS] [+/-] (=) [F1] (PROMPT)
[RS] [SYMB] (CAT) [big X] find XRNG [F6] (OK)

* Prompt for the left and right boundaries, then use the XRNG command.
[RS] [ x ] ( "" ) [ALPHA] [ALPHA] [1/X] (Y) [HIST] (M) [TOOL] (I) [EVAL] (N) [RS] [+/-] (=) [F1] (PROMPT)
[RS] [ x ] ( "" ) [ALPHA] [ALPHA] [1/X] (Y) [HIST] (M) [F1] (A) [big X] [RS] [+/-] (=) [F1] (PROMPT)
[RS] [SYMB] (CAT) [ALPHA] [1/X] (Y) find YRNG [F6] (OK)

* Prompt for the bottom and top boundaries, then use the YRNG command.
[RS] [SYMB] (CAT) [ALPHA] [F5] (E) find ERASE [F6] (OK)
[RS] [SYMB] (CAT) [ALPHA] [F4] (D) find DRAX [F6] (OK)
[RS] [SYMB] (CAT) [ALPHA] [F4] (D) find DRAW [F6] (OK)

* Input the ERASE, DRAX, and DRAW commands.
[RS] [SYMB] (CAT) [ALPHA] [SYMB] (P) find PICTURE [F6] (OK) [ENTER]
* Input the PICTURE command and terminate program entry.

The completed program:

<< "Y(X)=" PROMPT
STEQ
FUNCTION
'X' INDEP
"XMIN=" PROMPT "XMAX=" PROMPT XRNG
"YMIN=" PROMPT "YMAX=" PROMPT YRNG
ERASE DRAX DRAW
PICTURE >>



Algebraic Objects

Simply put, algebraic objects are equations or formulas that are enclosed in single quotes. Examples include:

'1'
'X+2/5'
'SIN(Ï€-1/2)'
'e^5.2-SQ(3)'

Algebraic objects gives the user an alternative (and maybe easier) way for the user to enter equations. In Part 6, we will explore several common functions that can be used with algebraic objects.

We can also enter equations using the RPN method. Let's try an example:

To enter 'X^2 + 3X - 1', we can enter this two ways. Assume X does not have anything stored in it. Purge X if need be.

RPN Way: [big X] [ENTER]
* duplicates X.
[LS] [ √ ] (x^2) [LS] [ &rarr ] (SWAP) 3 [ x ] [ + ] 1 [ - ] [EVAL]

Use [EVAL] to simplify the expression.

Algebraic Object: [ ' ] [big X] [y^x] 2 [ + ] 3 [ x ] [big X] [ - ] 1 [ENTER]

Instructions for GRPFX:

1. Run GRPFX. All the input will be asked for you, so you don't need anything in the stack to start with.
2. At the "Y(X)=" prompt, enter a function in X. You can use RPN, an algebraic object, or use the equation writer. Please be aware that the prompt may disappear when you are entering the function, just continue. Press [LS] [ON] (CONT) to continue.
3. At the "XMIN=" prompt, enter the left boundary, then press [LS] [ON] (CONT).
4. At the "XMAX=" prompt, enter the right boundary, then press [LS] [ON] (CONT).
5. At the "YMIN=" prompt, enter the bottom boundary, then press [LS] [ON] (CONT).
6. At the "YMAX=" prompt, enter the top boundary, then press [LS] [ON] (CONT).
7. You will see the function plotted. Use [F3] [F2] to trace the function. [F4] will give you access to function analysis such as ROOT, SLOPE, and AREA. Press [ON] to get back to the home screen.

The following pictures show GRPHX in action while plotting y(x) = x^2 + 3x - 1. Using the window, X = [-10, 10] and Y = [-10, 10]. (I am took pictures at a coffee shop using the iPad)

Hope you enjoyed Part 5. Come back for Part 6 where we explore cool functions with algebraic objects.

This tutorial is property of Edward Shore. Mass reproduction or distribution requires express permission of the author.

Casio fx-50F/Radio Shack EC-4024 Program Collection: October 2026

Casio fx-50F/Radio Shack EC-4024 Program Collection: October 2026 Notes: * The fx-50F/EC-4024 has a 29 step program space betwe...