Sunday, October 20, 2019

HP 12C: Finding Two Factors of an Integer

HP 12C:  Finding Two Factors of an Integer

Introduction

This program finds two factors of the integer N, where one of the factors is close to, but not equal to √N as possible.

Let X and Y be positive integers where:

(I)
N = B^2 - A^2

By the difference of squares:

(II)
N = (B - A) * (B + A)

The program tests every integer higher than √N.  Let B = int(√N) + 1.   If A = N - B^2 is an integer, the search stops.  The program uses the equation (II) above and places the results on the stack as such:

Y Stack:  B + A   // the program pauses to show this result
X Stack:  B - A

Program:
(Step ##: key code: key)
01:  44, 0:  STO 0
02:  43, 21: √
03:  43, 25:  INTG
04:  1:  1
05:  40:  +
06:  44, 1: STO 1
07:  2:   2
08:  21:  y^x
09:  45, 0:  RCL 0
10:  30:  -
11:  43, 21:  √
12:  44, 2:   STO 2
13:  43, 24:  FRAC
14:  43, 35:  X=0
15:  43, 33, 20:  GTO 20
16:  1:   1
17:  44, 40, 1:  STO+1
18:  45, 1:  RCL 1
19:  43, 33, 07:  GTO 07
20:  45, 1:  RCL 1
21:  45, 2:  RCL 2
22:  40:   +
23:  43, 31:  PSE
24:  45, 1:  RCL 1
25:  45, 2:  RCL 2
26:  30:  -
27:  43, 33, 00:  GTO 00

Examples:
n = 22356 = 162 * 138

n = 667 = 29 * 23

n = 4120 = 206 * 20

n = 144 = 18 * 8
(remember, factors close to √n as possible, but not the square root)

n = 97 = 97 * 1
(prime number)

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.

Saturday, October 19, 2019

HP 12C: Total Sales Tax with Rounded Amounts

HP 12C:  Total Sales Tax with Rounded Amounts

Introduction

The following program calculates the total invoice with the total sales tax.   Each time sales tax is calculated, the amount is rounded to two decimal places.

For example:

What is the total invoice for the purchase of three taxable items, if the sales tax is 9.5%.

\$19.95
\$32.85
\$47.50

The calculation:

19.95 + round(19.95 * .095,2)
+ 32.85 + round(32.85 * .095,2)
+ 47.50 + round(47.50 * .095,2)

= 19.95 + 1.90
+ 32.85 + 3.12
+ 47.50 + 4.51

= 109.83

Rounding to 2 Decimal Places

The FIX 2 mode rounds results to 2 decimal places, but for the purposes the display only.  The number retains it's full decimal expansion.

When you want to use the rounded amount, we can use the following routine:

In fixed 2 mode:  [ f ] 2

...
1
EEX
2
*
ENTER   // makes a duplicate of the number
FRAC   // takes the fraction
.
5
x<>y
x≤y   // is the fraction part less than 0.5
GTO  (A)   // go to line where (A) is

R↓  // fraction part is more than 0.5
+
GTO (B)

R↓   // (A)
R↓

ITNG  // (B), finalize the rounded number
1
EE
2
÷    // rounded number in the stack
...

Example:  425/118 = 3.60 in the display, shows 3601694915 when pressing [ f ] (PREFIX)

After this routine, we have 3.60, shows 3600000000 when pressing [ f ] (PREFIX)

Instructions:
1.  Enter the tax rate.
2.  Press [ f ] (PRGM), [R/S]
3.  Enter the item's cost, press [R/S]
4.  For subsequent items, enter the cost, then [R/S]
5.  When finished, press [RCL], 1 to recall total rounded sales tax.  Press [RCL], 2 to recall the total invoice.

I have program set to pause to show the rounded sales tax when each cost is entered.

Program:
(Step ##: key code, key)
01:  44,0  STO 0
02:  42, 2  FIX 2
03:  35,  CLx
04:  44, 1 STO 1
05:  44, 2 STO 2
06:  31  R/S
07:  45, 0  RCL 0
08:  25   %
09:  1     1
10:  26   EE
11:  2     2
12:  20   *
13:  36   ENTER
14:  43, 24  FRAC
15:  48    .  (decimal point)
16:  5      5
17:  34   x<>y
18:  43, 34  x≤y
19:  43, 33, 23  GTO 23
20:  33   R↓
21:  40   +
22:  43, 33, 25   GTO 25
23:  33  R↓
24:  33  R↓
25:  43, 25  ITNG
26:  1    1
27:  26  EEX
28:  2     2
29:  10   ÷
30:  43, 31   PSE
31:  44, 40, 1   STO+ 1
32:  40   +
33:  44, 40, 2   STO+ 2
34:  31   R/S
35:  43, 33, 07  GTO 07

Example:
Sales Tax Rate:  9.5%
Item Costs:  \$14.35, \$18.99, \$39.99, \$23.64

Keystrokes:
9.5  [ f ] (PRGM) [R/S]
14.35 [R/S]
18.99 [R/S]
39.99 [R/S]
23.64 [R/S]

R1:  Total rounded sales tax:  9.21
R2:  Total invoice:  106.18

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.

Sunday, October 13, 2019

Casio fx-991EX Classwiz: Simple Programming With Mutli-Statements

Casio fx-991EX Classwiz:  Simple Programming With Mutli-Statements

Formula Programming

With the use of the [CALC] key and multi-statment feature on the Casio fx-991EX, we can make simple temporary formula programs for repeated calculations.   Emphasis is on the word temporary:  once we go on to another mode, or press [ ON ],  the formula disappears.

There are also no comparison operators or loops to work with.

Given these limitations, we can still program simple formulas with the fx-991EX.

You are going to want to be in Norm mode for this.

Note:  This feature is present on other advanced solar calculators, however we will focus on the fx-991 EX Classwiz.

Let's illustrate formula programming with some examples.

Formula 1

B(A) = 2A² + 1
C(B) = B/(B - 1)

To assign variables in multi-step calculations, use the syntax:

var = value.

The equals symbol can be found by pressing pressing [ALPHA] [CALC] ( = ).  This is NOT the same as the equals key on the bottom right hand corner of the keyboard.

Each calculation is separated by a colon (:).  Type a colon by pressing [ALPHA] [ ∫ ] ( : ).

Set up:

B=2A²+1:C=B÷(B-1)

Each variable that is not assigned will be prompted for in the order that they are typed.  In the expression above, B and C are assigned while A is not.   Pressing [CALC] will prompt the user to enter a value for A.

Keystrokes:

[ALPHA] ( B ) [ALPHA] ( = ) 2 [ALPHA] ( A ) [ x² ] [ + ] 1 [ALPHA] ( : ) [ALPHA] ( C )  [ALPHA]  ( = )  [ALPHA] ( B ) [ ÷ [ [ ( ] [ [ALPHA] ( B ) [  -  ] 1 [ ) ] [ CALC ]

Note:  For this to work, press [ CALC ], not the EXE key.

You will be prompted for A.  The results for B and C will be displayed.

Examples

Example 1:  A = 3
[CALC],  enter 3, press [ = ]
B:  19,  press [ = ]
C:  19/18  [ S ←→ D ] 1.0555555556

Example 2:  A = -6
Results:  B = 73,  C = 73/12 ≈ 1.013888889

R-C Circuit:  Voltage Charge and Discharge

The charge and discharge of an R-C time circuit are described by the following equations:

Charge = Y / ( 1 - B)
Discharge = Y / B

where B = e^(-A / (C*X))

Inputs:
A = time (s)
X = resistance (kΩ)
C = capacitance (μF)
Y = voltage across the capacitor (V)

In this example, B is going to be used as the temporary variable.

Set up:

B=e^(-A÷(Cx)):Y÷(1-B):Y÷B

[CALC]

Example

Inputs:
A = 5 s
C = 2.6 μF
x = 10 kΩ
y = 30 V

Results:
B = 0.825052967 (sub-formula, press [ = ] )
171.4804732 V  (voltage charge, press [ = ] )
36.36130188 V (voltage discharge)

Solar Energy:  % of Solar Light Reflected

The proportion of solar light reflected off the surface is calculated by:

T = 1/2 ( sin(E - F)^2 / sin(E + F)^2 + tan(E - F)^2 / tan(E + F)^2 )

where

E = the angle of incidence (θi)
F = the angle of refraction (θt)

We can use Snell's law in connection with the equation above.

Since both  E-F and E+F repeat, we can assign temporary variables, such as:
A = E - F
B = E + F

Therefore:
T = 1/2 ( sin(A)^2 / sin(B)^2 + tan(A)^2 / tan(B)^2 )

And the set up for the fx-991EX Classwiz is:

A=E-F:B=E+F:1÷2*(sin(A)²÷sin(B)²+tan(A)²÷tan(B)²)   [CALC]

Example:

For this example, the calculator is Degrees mode.
Inputs:
E = 35° (θi)
F = 22° (θt)

Results:
A = E-F = 13
B = E+F = 57
0.04721102683  (% of reflected light)

Source (for R-C Circuit and Solar Energy)

Rosenstein, Morton  Computing with the Scientific Calculator  Casio.  1986. ISBN: 978-1124164130

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.

Saturday, October 12, 2019

HP Prime: Law of Refraction

HP Prime: Law of Refraction

Introduction

The program DRAWREFRACT, visually demonstrates the Law of Refraction, or Snell's Law:

n1 sin θi = n2 sin θt

The program asks for n1, θi, and n2; and calculates θt.  The program draws the incident ray (in red) and the refracted ray (in blue).  The calculator is set to Degrees mode and the Function app.

Note: you can find the angle character ∡, by pressing [SHIFT] [ × ].

HP Prime: Law of Refraction: DRAWREFRACT

Program:
EXPORT DRAWREFRACT(n1,θ1,n2)
BEGIN
// EWS 2018-08-20
// drawing Descates law
HAngle:=1; // Degrees
LOCAL θ2,x1,y1,x2,y2;
LOCAL str1,str2;
// window setup
STARTAPP("Function");
STARTVIEW(11,0);  // Decimal zoom
// calculation
θ2:=ASIN(n1*SIN(θ1)/n2);
x1:=RE(16∡(θ1+90));
y1:=IM(16∡(θ1+90));
x2:=RE(16∡(270+θ2));
y2:=IM(16∡(270+θ2));
// plot
RECT();
// draw axis
LINE(0,−16,0,16,0);
LINE(16,0,−16,0,0);
// draw analysis
LINE(0,0,x1,y1,#FF0000h);
LINE(0,0,x2,y2,#0000FFh);
str1:="n = "+STRING(n1)+
", θi = "+STRING(θ1);
str2:="-> n = "+STRING(n2)+
", θt = "+STRING(θ2);
TEXTOUT(str1,−15,−5,4,#FF0000h);
TEXTOUT(str2,−15,−8,4,#0000FFh);
WAIT(0);
// display home
STARTVIEW(−1);
END;

Example

n1 = 1.001
θ = 34.5°
n2= 1.205

DRAWREFRACT(1.001, 34.5, 1.205)

Result:
θt = 28.0678429359°

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

HP 41C/DM 41: Halloween and Thanksgiving - Calendar Calculations

HP 41C/DM 41:  Halloween and Thanksgiving - Calendar Calculations

Introduction

We are about to enter the annual holiday season, and it's can be hard to remember when all the holidays.  Here is a way to determine what date Thanksgiving will be on this year, and all you have to know is what day of the week Halloween falls on.

Halloween is celebrated on October 31.  Halloween is celebrated on a fixed date, while Thanksgiving is celebrated on a fixed day of the week.

In the United States, Thanksgiving is on the fourth Thursday in November.  Therefore the only dates Thanksgiving in the United States is between November 22 and November 28.

In Canada, Thanksgiving is on the second Monday in October, which lands the possible dates between October 8 and October 14.

Determine The Date of Thanksgiving Knowing What Day of the Week Halloween Is On

The first step is to give each day a numeric value:

Sunday: 0
Monday:  1
Tuesday:  2
Wednesday:  3
Thursday:  4
Friday:  5
Saturday:  6

To determine what date Thanksgiving falls on in the United States:

1.  Let H be the numeric value for the day Halloween falls on (see the above chart).
2.  Subtract 4 from H.
3.  If the result is zero or negative, add 28; otherwise, add 21.

Note:  The following programs could address alternative approaches given what the command set of the HP 41C/DM 41 allows us to do.

HP 41C/DM 41 Program:  H>T

01 LBL^T  H>T
02 4
03 X<>Y
04 -
05 X>0?
06 GTO 01
07 7
08 +
09 LBL 01
10 21
11 +
12 RTN

To determine what date Thanksgiving falls on in Canada:

1.  Let H be the numeric value for the day Halloween falls on (see the above chart).
2.  Subtract H from 7.
3.  Subtract 3 from the last result.
4.  If the result from Step 3 is zero or negative, add 14; otherwise, add 7.

HP 41C/DM 41 Program: H>CT

01 LBL^T H>CT
02 7
03 X<>Y
04 -
05 3
06 -
07 X>0?
08 GTO 01
09 7
10 +
11 LBL 01
12 7
13 +
14 RTN

Now, let's go the other way.

Determine The Day of the Week Halloween Knowing the Date of Thanksgiving

The first step is to give each day a numeric value:

Sunday: 0
Monday:  1
Tuesday:  2
Wednesday:  3
Thursday:  4
Friday:  5
Saturday:  6

To determine the day of the week Halloween falls on given the date of Thanksgiving (United States):

1.  Let T be the date of Thanksgiving.
2.  Subtract 21 from T.
3.  Subtract the result from Step 2 from 4.  If the number is negative, add 7.  See the above chart to determine the Day of the Week.

HP 41C/DM41 Program:  T>H

01  LBL^T T>H
02 21
03 -
04 4
05 X<>Y
06 -
07 X<0 font="">
08 GTO 01
09 RTN
10 LBL 01
11 7
12 +
13 RTN

To determine the day of the week Halloween falls on given the date of Thanksgiving (Canada):

1.  Let T be the date of Thanksgiving.
2.  Subtract T from 11.  If the result is negative, add 7.  See the above chart to determine the Day of the Week.

HP 41C/DM41 Program:  CT>H

01 LBL^T CT>H
02 11
03 X<>Y
04 -
05 X<0 font="">
06 GTO 01
07 RTN
08 LBL 01
09 7
10 +
11 RTN

Are you ready for the holiday season?  I'm not sure I am.  Let's have fun,

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.

Sunday, October 6, 2019

Fun with the TI-81: Part II

Fun with the TI-81:  Part II

Please check out yesterday's blog entry for Part I.  Now let's continue.

TI-81 Decimal to Fraction:  DECTOFRAC
(148 bytes)

This program converts a number X to fraction as an approximation.  Each successful approximation is displayed until the absolute value of the error falls below 10^-12.  This program is based on a program written for the Radio Shack TRS-80 (see source).

Variables:
X = Number
H = numerator
I = denominator
Y = error
Used: A, B, C, D, E, F, G, J

Program:
Disp "X="
Input X
IPart X → A
1 → B
X - A → C
0 → D
1 → E
1 → F
0 → G
Lbl 2
A * F + D → H
A * G + E → I
H / I - X → Y
ClrHome
Disp H
Disp "/"
Disp I
Disp "ERR="
Disp Y
Pause
If abs Y<1e-12 font="">
Stop
C → J
B - A * C → C
J → B
F → D
H → F
G → E
I → G
Goto 2

Example:
X = 4.7995
4 / 1,  ERR = -.7995
5 / 1,  ERR = .2005
13 / 4, ERR = -.0495
24 / 5,  ERR = 5E-4
1915 / 399, ERR = -1.253133E-6
9599 / 2000, ERR = 0

4.7995 = 9599/2000

Source:

Craig, John Clark  119 Practical Programs for the TRS-80 Pocket Computer  Tabs Books Inc.:  Blue Ridge, PA.  1982 ISBN 0-8306-0061-1 (Paperback)

TI-81 Simple Logistic Regression:  LOGISFIT
(71 bytes)

The program LOGISFIT fits the statistical data to the equation:

y = 1 / (a + b*e^x)

This program uses the linear regression fit with the following translations:

x' = e^(-x), y' = 1/y

This fit will is good for all data except when y = 0.

Instructions:
1.  Enter the data through the Stat Edit menu.
2.  Run LOGISFIT.  The data will be altered.

Program:
1 → I
Lbl 1
e^( -{x}(I) ) → {x}(I)
{y}(I)⁻¹ → {y}(I)
IS>( I, Dim{x} )
Goto 1
LinReg
Disp "Y=1/(a+be^(X))"
Disp "a"
Disp a
Disp "b"
Disp b

Example:
x1 = 0.5
y1 = 0.384
x2 = 1
y2 = 0.422
x3 = 1.5
y3 = 0.45
x4 = 2
y4 = .468
x5 = 2.5
y5 = .48

Results:
a = 2.001859259
b = .9942654005

Equation:
y = 1 / (2.001859259 + .9942654005*e^x)

Source:

Shore, Edward.  "HP Prime and TI-84 Plus CE: Simple Logistic Regression"  Eddie's Math and Calculator Blog. 2017.  http://edspi31415.blogspot.com/2017/04/hp-prime-and-ti-84-plus-ce-simple.html
Retrieved August 17, 2019

TI -81 Confidence Intervals: INTERVAL
(184 bytes)

The program INTERVAL calculates a confidence interval given the sample's mean (M), variance (V), and number of data points (N).  A Z scored is selected when the user selects one of three confidence levels:

99%  (0.5% on each side of the curve, Z = 2.575829586)
95%  (2.5% on each side of the curve, Z = 1.959963986)
90%.  (5% on each side of the curve, Z = 1.644853627)

The interval lies between ( M - Z * V/√N,  M + Z * V/√N )

Notes:
1.  Z is used as an control variable and the Z score.
2.  The percent symbol is built of three characters, the degree symbol (°), the forward slash by pressing the [ ÷ ] key (/), the decimal point (.).

Program:
0 → Z
Disp "MEAN="
Input M
Disp "VAR="
Input V
Disp "N="
Input N
Lbl 0
ClrHome
Disp "1. 99°/."
Disp "2. 95°/."
Disp "3. 90°/."
Input P
If P=1
2.575829586 → Z
If P=2
1.959963986 → Z
If P=3
1.644853627 → Z
If Z=0
Goto 0
M + Z * V / √N → U
M - Z * V / √N → V
Disp "INTERVAL"
Disp U
Disp V

Example:
Input:  n = 100, M = 156.39, V = 10.94, 99% confidence interval
Results:
162.2079576
156.5720424

Source:
Kelly, Kathy A., Robert E. Whitsitt II, M. Deal LaMont, Dr. Ralph A. Olivia, et all.  Scientific Calculator Sourcebook   Texas Instruments Inc.  1981.  (no ISBN number is given)

TI-81 Fresnel Polarization:  MICROPOL
(120 bytes)

Given a microwave transferring from one medium to another with the initial angle with respect to the plane surface that separates the mediums, the following are calculated:

1.  Angle of refraction, θt
2.  Fresnel Horizontal Polarization, R_H
3.  Fresnel Vertical Polarization, R_V

The Law of Refraction:
n1 sin θi = n2 sin θt

Fresnel Horizontal Polarization:
R_H = sin(θ_i - θ_t) / sin(θ_i + θ_t)

Fresnel Vertical Polarization:
R_V = tan(θ_i - θ_t) / tan(θ_i + θ_t)

Variables:
N = n_1  (index of refraction of medium 1)
M = n_2  (index of refraction of medium 2)
θ = θ_i  (angle of incidence)
Z = θ_t (angle of refraction)
H = R_H (Fresnel horizontal polarization)
V = R_V (Fresnel vertical polarization)

Note:  Angles are in degrees

Program:
Deg
Disp "N1="
Input N
Disp "θ="
Input θ
Disp "N2="
Input M
sin⁻¹ (Nsin θ / M) → Z
sin(θ-Z) / sin(θ+Z) → H
tan (θ-Z) / tan (θ+Z) → V
Disp "REFRACT θ="
Disp Z
Disp "H-POLAR="
Disp H
Disp "V-POLAR="
Disp V

Example:
Inputs:  N1 = 1.001, θ = 40°, N2 = 1.333
Results:
REFRACT θ = 28.86146514°
H-POLAR = .2071186671
V-POLAR = .0761259908

Source:
Barue, Geraud  Microwave Engineering:  Land & Space Communications  John Wiley & Sons: Hoboken, NJ 2008.  ISBN 978-0-470-08996-5

TI-81 Hyperbolic Circles: Circumference and Area:  HYPCIRCL
(61 bytes)

The program HYPCIRCL calculates the circumference and area of a circle in hyperbolic space.  Note that this not the same as (normal, regular, everyday) circles in Euclidean space.

Circumference of a hyperbolic circle: C = 2 π sinh(R)

Area of a hyperbolic circle:  A = 4 π sinh(R/2)^2

Program:
Disp "HYP CIRCLE"
Disp "R="
Input R
2π sinh R → C
4 π (sinh(R/2))² → A
Disp "C="
Disp C
Disp "A="
Disp A

Example:
Input: R = 3
Results:
C = 62.94416455
A = 56.97380062

Source:
Series, Caroline  "Hyperbolic Geometry MA 448"  2010. Edited Jan. 4, 2013

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.

Saturday, October 5, 2019

Fun with the TI-81: Part I

Fun with the TI-81:  Part I

Before there there was the TI-82, TI-83 and its family, and the TI-84 Plus and its family, there was the Texas Instrument's original calculator from the 1990, the TI-81!

Translating TI-81 to TI-84 Plus (and Back)

Most of the commands can be copied directly.  Some caveats to keep in mind:

Disp

The TI-81's Disp (Display command) can only display either a variable's value or a string.  The command can only display one item per line.

The TI-84 Plus' Disp command can list any combination of strings and variable values, separated by a comma.  Each argument will be placed on one line.

Input

The TI-81's Input command can ask for one variable.  There is no prompt string option.  A prompt string will require an extra Disp command.  Also, there is no colon character.

Disp "VAR="
Input A

The TI-84 Plus' Input command can have an optional prompt string.

Input "VAR=", A

Lists

The TI-81 has two lists that are used for statistical calculations, {x} and {y}.  To recall an element of either {x} or {y}, press [ 2nd ] [ 0 ] or [ 2nd ] [ 1 ], respectively.  The dimensions of the stat lists can be found by pressing [VARS], and selecting Dim{x} under the DIM menu.  Stat lists can't be resized by storing a value to it.

All of the lists for the TI-84 Plus start with a lower case bold "L".  Lists 1-6 can be pressed by [ 2nd ] [ 1 ] through [ 6 ].  There are many lists commands and functions for the TI-84 Plus.

Linear Regression Options

Running linear regression is the LinReg command on the TI-81.  The equation will always be a + bx.

Running linear regression for the TI-84 Plus will need you to designate the x-list and y-list.  There are also various options: a + bx, ax + b, or Med-Med

The If Command and Loops

The TI-81 only has a singular If command, no Then or Else.  The syntax is:

If condition
do if condition is true
skip to here if condition is false

Loops will require the extensive use of Lbl (label), Goto, DS<(, and IS>(.   Lbl and Goto are self-explanatory.

DS<(var, target).   The value of var is decreased by 1.  The next command is skipped when value < target.

IS>(var, target).  The value of var is increased by 1.  The next command is skipped when value > target.

In addition to If (which can still do the two-line structure), Lbl, Goto, DS<(, and IS>(, the TI-84 Plus has Then, Else, For, While, and Repeat.

The STO> Button

The TI-81 turns on the ALPHA keyboard when pressing [STO>].

The TI-84 Plus doesn't.

On to the programming...

TI-81 Decimal to Binary Conversion:  BINTODEC
(75 bytes)

Input the binary integer at the prompt.  Use only 1s and 0s.

Variables:
B = binary representation
D = decimal representation
N, M:  used

Program:
Disp "BIN>DEC"
Input B
0 → D
0 → N
B → M
Lbl 0
2^N * 10 * FPart(M/10) + D → D
IPart(M/10) → M
IS>(N, IPart(log B) + 1)
Goto 0
Disp D

Example:
Input:  B:  1001010
Result:  D:  74

TI-81 Binary to Decimal Conversion:  DECTOBIN
(99 bytes)

Input the decimal integer at the prompt.  The integer needs to be in between 1 and 1024.  Only positive integers are allowed.

Variables:
B = binary representation
D = decimal representation
N, M:  used

Program:
Disp "DEC>BIN"
Disp "1≤D≤1024"
Input D
0 → B
D → M
IPart( log D / log 2 ) → N
Lbl 2
If 2^N ≤ M
B + 1 → B
If 2^N ≤ M
M - 2^N → M
If N ≠ 0
10 * B → B
DS<(N, 0)
Goto 2
Disp B

Example:
Input:  D:  516
Result:  B:  1000000100

TI-81 Roots of a Quadratic Equation:  QUADEQN
(121 bytes)

This program solves the equation A*X^2 + B*X + C = 0, which allows for real or complex roots.

Variables:
A, B, C:  coefficients
X, Y:  roots

If the discriminant is zero or positive, the roots are real, and are stored in X and Y.

If the discriminant is negative, we have complex roots in the form of X ± Yi, X is the real part, Y is the imaginary part.

Program:
Disp "AX²+BX+C=0"
Input A
Input B
Input C
-B / (2A) → X
(B² - 4AC) / (4A²) → Y
If Y<0 font="">
Goto 0
√Y → Y
X + Y → Y
2X - Y → X
Disp "ROOTS"
Goto 2
Lbl 0
√(abs Y) → Y
Disp "X+YI, X-YI"
Lbl 2
Disp X
Disp Y

Examples:

x^2 + 4x + 5 = 0,  Roots:  2 ± i
Input:  A: 1, B: 4, C: 5
Results:  "X+YI, X-YI", X: -2, Y: 1

x^2 + 5x + 4 = 0,  Roots:  -4, -1
Input:  A: 1, B: 5, C: 1
Results: "ROOTS", X: -4, Y: -1

Tomorrow will be Part 2. Until then,

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.

HP 12C: Finding Two Factors of an Integer

HP 12C:  Finding Two Factors of an Integer  Introduction This program finds two factors of the integer N, where one of the factors ...