Showing posts with label TI-80. Show all posts
Showing posts with label TI-80. Show all posts

Sunday, April 12, 2020

TI-80 and TI-84 Plus CE: Drawing a Bag of Two Kinds of Items

TI-80 and TI-84 Plus CE:  Drawing a Bag of Two Kinds of Items

Introduction




The program BINDRAW has a participant draw from a population made of two type of objects, A and B.  Think of a bag with green marbles (A) and red marbles (B).  You are given the number of draws and you need to calculate the chance you draw a certain combination, such as 3-draws of order A, A, B or A, B, A.

POP A:  number of A balls in the bag

POP B:  number of B balls in the bag

The ^-1 is the inverse function [ x^-1 ]

TI-80 Program  BINDRAW (161 bytes)

The TI-80 Program of BINDRAW is a simple version, which calculates a single probability.

INPUT "POP A?",A
INPUT "POP B?",B
A + B → T
DISP "TOTAL:",T
INPUT "NO OF DRAWS?",D
(T nPr D)^-1 → P
FOR(I,1,D)
CLRHOME
DISP "DRAW ",I,"1. A 2. B"
INPUT J
IF J = 1
THEN
P * A → P
A - 1 → A
ELSE
P * B → B
B - 1 → B
END
END
DISP "PROB:",P

TI-84 Plus CE Program BINDRAW (374 bytes)

The TI-84 Plus CE version of BINDRAW expands on the simple version.  After calculating a single probability: you get a menu of the following options.

ADD TO MEM:  Add the probability to memory.  The memory register is the cumulative probability.  The cumulative probability is displayed.

CLEAR MEM:  Reset the cumulative probability to zero.

NEW DRAW:  Start a new draw.  The cumulative probability remains intact.

NEW PROB:   Starts a new problem.  The cumulative probability resets to zero.

QUIT:  End the program.

"2020-02-29 EWS"
Lbl 0
Input "POP A?",N
Input "POP B?",M
N + M → T
Disp "TOTAL",T
0 → S
Input "NO OF DRAWS?",D
Lbl 1
N → A 
M → B
(T nPr D)^-1 → P 
" " → Str0
For(I, 1, D)
Disp "DRAW " + toString(I), "HIST " + Str0, "1. A 2. B"
Input J
If J = 1
Then
P * A → P
A - 1 → A
Str0 + "A" → Str0
Else
P * B → P
B - 1 → B
Str0 + "B" → Str0
End
End
Disp "PROB"
Pause P
Lbl 2
Menu("MENU", "ADD TO MEM", 3, "CLEAR MEM", 4, "NEW DRAW", 1, 
"NEW PROB", 0, "QUIT", 5)
Lbl 3
P + S → S
Disp "MEM"
Pause S
Goto 2
Lbl 4
0 → S
Disp "MEM CLEARED"
Pause
Goto 2
Lbl 5

You can download the TI-84 Plus CE program here:
https://drive.google.com/open?id=1HBpv5rNN6kA-__MTKoc3RJtMAgqyF1w4

Example

The bag has 5 balls labeled "A" and 3 balls labeled "B".  What is the probability of either drawing 3 "A" balls in a row or drawing 3 "B" balls out of the bag?

Prompts:
POP A?  5
POP B?  3
(Total = 8)
DRAWS? 3

Three "A": choose option 1 three times in a row
Probability:  0.1785714286

Three "B": choose option 2 three times in a row
Probability:  0.0178571429

Cumulative Probability:  0.1964285715

Blog turns 9 on the 16th 

This is the last blog entry of the 9th year of my calculator and math blog as this blog turns 9 on April 16, 2020.  Thank you to everyone and all your support!  See year when we start Year 10 (!) on the 17th. 


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, February 3, 2019

Calculator Programming: Making FOR, WHILE, and REPEAT Loops with IS>, DS<, GOTO, IF, LBL

Calculator Programming:  Making FOR, WHILE, and 
REPEAT Loops with IS>, DS<, GOTO, IF, LBL

Introduction

Say your programming capabilities on your calculator, BASIC portable computer, or programming app does not have the FOR, WHILE, and REPEAT loop structures.  No worries, there are some workarounds we can use.

Today the programs will be demonstrated with the language of the TI-81 and TI-84 Plus CE, but this blog isn't limited to these two calculators.


Simulating FOR Loops with IS> and DS<

The TI-81 (and every Texas Instruments graphing calculator of that family inclusive to the TI-84 Plus CE) has the commands IS> and DS<.

IS>:  Increment and Skip

Syntax:  IS>(variable, target number)

IS> increases the value stored in a variable by 1 and performs a comparison test.  The next command is excited if the increased value is less than or equal to the target number.

IS>(var, target)
[do this command if var + 1 ≤ target]
[skip to this command if var + 1 > target]

Simulating the FOR Loop:

FOR var = begin TO end*
[commands]
NEXT
[commands after loop is over]


* Syntax varies.  For the TI-84 Plus CE:  For(var,begin, end) : [commands] : End

with:

begin → var
LBL [label]
[commands]
IS>(var, end)
GOTO [label]
[commands after loop is over]

The program PRGM1 demonstrates how to accomplish a FOR loop with IS>.  PRGM1 displays the numbers 1 to 10.  The TI-81 section can be programmed by on the TI-81 and TI-84 Plus CE, which the TI-84+ section is for calculators TI-82 and later.

"TI-81"
1→K
Lbl 1
Disp K
IS>(K,10)
Goto 1
Disp "END"
Wait 2
"TI-84+"
For(K,1,10)
Disp K
End
Disp "END"

DS<   

Decrement and Skip

Syntax:  DS<(variable, target number)

DS< decreases the value stored in a variable by 1 and performs a comparison test.  The next command is excited if the increased value is greater than or equal to the target number.  DS< is the opposite of IS>.

DS<(var, target)
[do this command if var - 1 ≥ target]
[skip to this command if var - 1 < target]

Simulating the FOR Loop:

FOR var = begin TO end STEP -1*
[commands]
NEXT
[commands after loop is over]


* Syntax varies.  For the TI-82 to the TI-84 Plus CE, including TI-80 and TI-73:
For(var,begin, end, -1) [commands] End

with:

begin → var
LBL [label]
[commands]
DS<(var, end)
GOTO [label]
[commands after loop is over]

PRGM2 demonstrates the use of DS< and the associated For loop.


"TI-81"
10→K
Lbl 1
Disp K
DS<(K,1)
Goto 1
Disp "END"
Wait 2
"TI-84+"
For(K,10,1,­1)
Disp K
End
Disp "END"

Simulating WHILE and REPEAT Loops

With the proper use of the IF, LBL, and GOTO we can simulate WHILE and REPEAT loops.

Simulated WHILE Loops

WHILE [condition is true]
[commands]
END

* While is available for TI-82 to the TI-84 Plus CE, including TI-73.

can be simulated by:

LBL [label]
[commands]
IF [while condition] 
GOTO [label]

Simulated REPEAT Loops

REPEAT
[commands]
UNTIL [condition]

* The syntax for the TI-82 to the TI-84 Plus CE, including TI-73 is:
Repeat [condition] : [commands] : End

LBL [label]
[commands]
IF [inverse of the repeat condition] 
GOTO [label]

Example:  If the repeat condition is T>5, then the inverse is T≤5.

PRGM3 is a demonstration program on how all three techniques are used to accomplish this:

Start with 1000.  Take the square root.  Keep going until the calculator gets to 1 (by the precision of the calculator).

"TI-81"
1000→K
Lbl 1
√(K)→K
Disp K
If K≠1
Goto 1
Disp "END"
Wait 2
"84+ WHILE"
1000→K
While K≠1
√(K)→K
Disp K
End
Disp "END WHILE"
Wait 2
"84+ REPEAT"
1000→K
Repeat K=1
√(K)→K
Disp K
End
Disp "END REPEAT"

I hope you find these tips useful and helpful.

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.

Friday, January 12, 2018

TI-80 and TI-84 Plus CE – Two Opposing Ocean Waves

TI-80 and TI-84 Plus CE – Two Opposing Ocean Waves

Introduction

The program OPPTIDE draws an ocean wave consisting of a composite of two opposite waves at time t seconds. 

Inputs:

L = wavelength of the wave in feet (λ)
A = amplitude of the wave in feet
H = depth of the ocean in feet
T = time that the wave is drawn, in seconds

Constants:

G ≈ 32.174049 ft/s^2  (approximate Earth’s gravitation constant)

Output: 

Drawing of the wave described by the equation:

y = A cos (K*X – W*T) + A cos (K*X + W*T)  (X varies, T is a constant and given), where:
K = 2*π/L
W = (g*K*tanh(K*H))

Note:

The tanh, hyperbolic tangent function, is not on the TI-80.  Therefore the following definition is used:

tanh x = (e^(2*x) – 1)/(e^(2*x) + 1)

The tanh function is found only in the catalog of the TI-84 Plus CE ([Shift], [ 0 ]).

TI-80 Program OPPTIDE

DISP “2018-01-10 EWS”
RADIAN
0→XMIN
50→XMAN
5→XSCL
32.17049→G
DISP “FEET”
INPUT “WAVELENGTH:”,L
INPUT “DEPTH:”,H
INPUT “AMPLITUDE:”,A
-A-1→YMIN
A+1→YMAX
1→YSCL
INPUT “TIME:”,T
(2π)/L→K
(e^(2KH)-1)/(e^(2KH)+1)→Q
√(QKG)→W
“A*COS(KX-WT)+A*COS(KX+WT)”→Y1
DISPGRAPH

TI-84 Plus CE Program OPPTIDE

“EWS 2018-01-10”
Func: Radian
0→Xmin: 50→Xmax: 5→Xscl
32.174049→G
Disp “DISTANCE IN FEET”
Input “WAVELENGTH:”, L
Input “AMPLITUDE:”, A
-A-1→Ymin: A+1→Ymax: 1→Yscl
Input “OCEAN DEPTH:”, H
Input “TIME (S):”, T
2π/L→ K
√(G K * tanh(KH))→W
“A cos(KX – WT) + A cos(KX + WT)” → Y1
GraphColor(1,BLUE)
DispGraph

Example

At T = 1 second with parameters:
W = 75.5 feet
A = 4.76 feet
H = 25 feet

See the results below.



Source:

Salmon, Rick.  “Intro to Ocean Waves”  Scripps Institution of Oceanography.  UC San Diego  December 7, 2015.  http://pordlabs.ucsd.edu/rsalmon/111.textbook.pdf  Retrieved December 26, 2017

Eddie


This blog is property of Edward Shore, 2018.  

Wednesday, September 6, 2017

Fun with the TI-80

Fun with the TI-80


TI-80 Program D2DMS - Decimal to Degrees-Minutes-Seconds

Variables:

Decimal Format:
D = decimal

DMS Format:
H = degrees/hours, M = minute, S = seconds

INPUT “DEC:”,D
IPART D→H
IPART (60*FPART D)→M
60 * FPART (60 * FPART D)→S
DISP “H,M,S:”,H,M,S

TI-80 Program DMS2D - Degrees-Minutes-Seconds to Decimal

Variables:

Decimal Format:
D = decimal

DMS Format:
H = degrees/hours, M = minute, S = seconds

INPUT “H:”,H
INPUT “M:”,M
INPUT “S:”,S
H + M/60 + S/3600 → D
DISP “DEC:”,D

TI-80 Program QUADRAT - Quadratic Equation

Variables:

A, B, C are coefficients of the equation Ax^2 + Bx + C, where the discriminant D:

D = B^2 – 4*A*C
If D≥0, then the roots are real and stored in X and Y.

If D<0, then the roots are complex and are in the form of conjugates X ± Yi.  X is the real part, Y is the imaginary part.



DISP “AX^2+BX+C=0”
INPUT “A:”,A
INPUT “B:”,B
INPUT “C:”,C
B^2 – 4AC → D
DISP D 
-B / (2A) → E
IF D≥0
THEN
E + √D/(2A) → X
E - √D/(2A) → Y
DISP “R1:”,X
DIPS “R2:”,Y
ELSE
E → X
√-D / (2A) → Y
DISP “RE:”,X
DISP “IM :”,Y
END

Annuity Factors

Variables:
I = periodic interest rate
N = number of payments/periods/deposits

TI-80 Program USFV – Annuity Future Value Factor

INPUT “I:”,I
INPUT “N:”,N
( (1+.01)^N – 1)/(.01I) → F
DISP F

TI-80 Program USPV – Annuity Present Value Factor

INPUT “I:”,I
INPUT “N:”,N
(1 – (1 + .01I)^-N)/(.01I) → P
DISP P

Two Dimensional Vector Operations

Let two vectors be defined as V1 = [A, B] an V2 = [C, D].  The program calculates the dot product, stored in E, norm of V1, stored in F, norm of V2, stored in G, and the angle between V1 and V2 in degrees, stored in H.

TI-80 Program VECTOR2

DEGREE
DISP “V1:”
INPUT A
INPUT B
DISP “V2:”
INPUT C
INPUT D
AC + BD → E
√(A^2 + B^2) → F
√(C^2 + D^2) → G
COS^-1 (E /(F*G)) → H
DISP “NORM V1:”, F
DISP “NORM V2:”, G
PAUSE
DISP “DOT:”, E
DISP “ANGLE:”, H

Simplistic Logistic Regression

Fit data (x,y) to the equation:

Y = 1 / (A + B*e^(-X))


TI-80 Program SIMPLOG

INPUT “L1:”, L1
INPUT “L2:”, L2
e^-L1 → L1
1/L2 → L2
LINREG(aX+b) L1, L2
a→A: b→B
DISP “1/(B+Ae^X)”,A,B
PAUSE
DISP “CORR^2”,r^2





Eddie


This blog is property of Edward Shore, 2017

Monday, September 4, 2017

Retro Review: Texas Instruments TI-80

TI-80


TI-80 (left), TI-84 Plus CE (right)
Look how thin the TI-80 is
Retro Review: Texas Instruments TI-80

First, thank you Nano for the TI-80 (along with giving me a pair of slide rules and an astronomy poster)!  Much appreciated!
  
Essentials

Company:  Texas Instruments
Years:  1995
Type:  Graphing, Programming
Memory:  7,034 bytes
Operating System: Algebraic
Memory Registers: 27 (A-Z, θ)
Screen:  Monochrome

Batteries:  2 CR2032 batteries

Graphing Modes:  Function (4), Parametric (3).  Table included. 

Regressions:  6: Linear (ax + b), Quadratic, Linear (a + bx), Logarithmic, Exponential, Power

Lists: Up to 99 entries per lists, 6 lists available (L1 through L6)

Matrices: none

Complex Numbers:  none

Keyboard

The keyboard is what one would expect on a Texas Instruments graphing calculator: nice and responsive. 

Screen

The screen is small.  Not kidding.  The screen is only 48 x 64 pixels big, accompanying 8 lines of 16 characters.  That means that the font is small.  What is wild is that the pi symbol (π) does not conform to the rest of the font, and is twice as long as the rest of the characters.

The screen is still bigger than the mini-graphing calculators such as the Casio fx-6300g or the Hewlett Packard HP-9g.

Is the TI-80 a simplified TI-81?

For the most part, no.  Sure, the TI-80 does not have matrices and hyperbolic functions (sinh, cosh, etc) like the TI-81.  However, the TI-80 has fractions (see the next section), integer division and remainder function, random integer, a complementary table mode, and lists.  The number of stat plots increased to 3, which they don’t have to depend on the statistics mode.

As far as programming memory, the TI-80 beats the TI-81: 7,034 bytes to 2,400 bytes.  Also, you can go beyond 37 programs for the TI-80, as the names are not restricted to one character.

Fractions

The TI-80 has a dedicated fraction menu, which allow users to convert between improper and proper form, as well as conversion between fraction and decimal approximation.  The Manual Simplification mode allows fractions to not be automatically simplified on calculation. 

To enter fractions, the format is:  A _ B / C
Note that the slash is bold.  Merely pressing the division key will not register the fraction.

To separate the whole part from the fraction, press [ 2nd ] [ + ] (UNIT_).

To separate the numerator from the denominator, press [ 2nd ] [ ÷ ] (b/c).

Example:  Enter 2 3/4
Keystrokes:  2 [ 2nd ] [ + ] 3 [ 2nd ] [ ÷ ] 4

According to Datamath (http://www.datamath.org/Graphing/TI-80.htm ), the TI-80 would get replaced with the TI-73 in 1998.  This may mean that the TI-80 became the base for the TI-73 series (TI-73, TI-73 explorer).

Lists

The TI-80 allows for 6 lists, each with a 99 element capacity.  Arithmetic can be operated on two same-sized lists, on an element-by-element functions.  Lists functions include sorting, dimension, minimum, maximum, sum of the elements, product of the elements, and sequence generation.

Programming

Programming is fairly basic for the TI-81.  Commands:
If-Then-Else-End Structure (IF, THEN, ELSE, END)
Quick if structure
For-End structure (no IS>, DS< this time) (FOR, END)
Labels:  one character and local labels (LBL, GOTO)
Subroutines (PRGM_, RETURN)
Drawing commands include points, shading (three types, general, Y<, Y>)

Since the only built-in calculus function of the TI-80 is numerical derivation (NDERIV), two programs for Newton’s Method and Simpson’s Rule are presented below.

TI-80 Program:  SOLVEY1  (Newton’s Method)

80 bytes
The equation is stored in Y1.  The program solves for X in Y1(X) = 0

INPUT “GUESS:”, X
LBL 0
X-Y1/NDERIV(Y1,X,X)→N
IF ABS (X-N)>1E-10
THEN
N→X
GOTO 0
END
N→X
DISP “X = “, X

Example: X^2-3X+1, guess X = 3
Result:  X = 2.618033989

TI-80 Program: SIMPY1 (Integral, Simpson’s Rule)

140 bytes
The equation is stored in Y1.  The program calculates ∫(Y1,X,A,B)

RADIAN
INPUT “A:”,A
INPUT “B:”,B
INPUT “N (EVEN):”,N
(B-A)/N→H
0→T
FOR(I,1,N-1)
A+IH→X
T+2*Y1→T
IF FPART(I/2)≠0
2*Y1+T→T
END
(T+Y1(A)+Y1(B))H/3→T
DISP “INTEGRAL:”,T

Example: X^2-3X+1, with A = 0 to B = 5 and N = 10
Result:  X = 9.166666667

Final Verdict

The TI-80 is a nice introductory calculator, and thanks to programming a lot can be done with it.  I wish the screen was bigger and degree/degrees-minutes-seconds conversions were available, but other than that, it was a great calculator which provides a lot of features (maybe not as intimidating as more advanced calculators). 

It is a nice calculator to add to the collection, and I thank you Nano immensely. 

Eddie


This blog is property of Edward Shore, 2017.

Numworks (Python): Parallelograms Described by Vectors

Numworks (Python): Parallelograms Described by Vectors Introduction The script drawpgram.py draws a parallelogram constructed by ...