• Please review our updated Terms and Rules here

TI-74 Basic programs?

Speaking of spaghetti code... "8)

Just kidding - BASIC limits choice in this regard.

Although it can be done...
 
Conversions, 1-4-19

I thought it would be nice to have a package of my own frequently used conversions. The layout 'mi>km', miles to kilometers, made sense to me. The number 1.6093 multiplied by miles should yield kilometers. Enter your own conversions and multiplier beginning at 7000 in the DATA statements. I included some conversions I frequently use. Use multipliers with more digits for more accurate results.

For conversions using a formula like 'f>c', fahrenheit to celsius, enter the conversion then a -1 for the number multiplier. This will send the program to the 7900s where you can work the equation. Follow the programming example that's there. Keep all conversions with a number multiplier between 7000 and 7399 (above the -1s).

The 'ans' variable on the display will contain the answer. You can use it to seed another input. If you type the program in, make sure it's all working properly. On line 7490 make sure you type 'end..,..' (end, two periods, comma, two periods).

Entering 'conv' for a conversion will list the conversions. Entering 'conv#' will list the conversions plus the conversion multiplier. Compare all conversions to known results before using.

(I'm no programmer but if you have the red sauce I have the code :)


Code:
7000 DATA mi>km,1.6093,km>mi,0.6214
7010 DATA yd>m,0.9144,m>yd,1.0936
7020 DATA ft>m,0.3048,m>ft,3.2808

7030 DATA in>mm,25.4,mm>in,0.03937
7040 DATA in>cm,2.54,cm>in,0.3937
7050 DATA in>m,0.0254,m>in,39.37

7060 DATA in2>mm2,645.16,mm2>in2,0.00155
7070 DATA in2>cm2,6.4516,cm2>in2,0.155
7080 DATA ft2>m2,0.0929,m2>ft2,10.764
 
7090 DATA in3>cm3,16.387,cm3>in3,0.06102   
7100 DATA gal>ltr,3.7854,ltr>gal,0.26417
7110 DATA in3>gal,0.004329,gal>in3,231

7120 DATA in3>ltr,0.01639,ltr>in3,61.023
7130 DATA gal>cm3,3785.4,cm3>gal,0.000264
7140 DATA lbs>kgs,0.4536,kgs>lbs,2.2046

7150 DATA mph>ft/s,1.46667,ft/s>mph,0.6818166322


7400 REM only -1s below
7405 DATA f>c,-1,c>f,-1

7490 DATA end..,..


7500 PRINT "Conversion":PAUSE .8:A9$="":B9=0:RESTORE 7000
7510 PRINT Z9$;" conv ";:ACCEPT NULL(Z9$),Z9$
7512 IF Z9$="conv"OR Z9$="conv#"THEN C9=0:GOTO 7800
7518 PRINT C9;"num ";:ACCEPT NULL(C9),C9
7520 READ A9$,B9
7525 IF B9=-1THEN 7900
7530 IF A9$=Z9$THEN 7570
7540 IF A9$="end.."THEN PRINT Z9$;" not found":Z9$="":PAUSE:GOTO 7500
7550 GOTO 7520

7570 ANS=C9*B9
7580 PRINT "ans";C9;A9$;" =";ANS:PAUSE:GOTO 7500

7800 RESTORE 7000
7810 READ A9$,B9$:IF Z9$="conv"THEN PRINT A9$:PAUSE
7815 IF Z9$="conv#"THEN PRINT A9$;"  ";B9$:PAUSE
7820 IF A9$="end.."THEN 7500 ELSE 7810
7830 GOTO 7500

7900 IF Z9$="c>f"THEN ANS=(C9*(9/5))+32:A9$=Z9$:GOTO 7580
7910 IF Z9$="f>c"THEN ANS=(C9-32)*(5/9):A9$=Z9$:GOTO 7580

7990 A9$="end..":GOTO 7540


Example:

conv lbs>kgs [enter]
0 num 210 [enter]
ans 210 lbs>kgs = 95.256

[enter]
lbs>kgs conv [enter]
210 num 300 [enter]
ans 300 lbs>kgs = 136.08

[enter]
lbs>kgs conv kgs>lbs [enter]
300 num 136.08 [enter]
ans 136.08 kgs>lbs = 300.001968
 
Wind Chill, 1-25-19

Sometimes the weather report doesn't give the wind chill. Sometimes my local weather conditions differ from the weather report. When it's really cold outside I like to know the wind chill. I went online and found math for wind chill and made this for the TI-74. It seems to yield similar results as weather forecasts. Check it out.


Code:
600 PRINT "Wind Chill":PAUSE .6
610 PRINT TEMP;"temp,deg f ";:ACCEPT NULL(TEMP),TEMP
620 PRINT WSPED;"wind speed,mph ";:ACCEPT NULL(WSPED),WSPED
630 WCHIL=35.74+(.6215*TEMP)-(35.75*WSPED^.16)+(.4275*TEMP*WSPED^.16)
640 ANS=WCHIL:PRINT USING"ans wind chill,deg f=###.#";WCHIL:PAUSE:GOTO 600


Example:

0 temp,deg f -5 [enter]
0 wind speed,mph 13 [enter]
ans wind chill,deg f=-24.5

-5 temp,deg f 13 [enter]
13 wind speed,mph 5 [enter]
ans wind chill,degf= 4.8
 
A few years ago, I wrote a crappy program to calculate prime numbers. Every once in a while, at social gatherings, I'd pull out the TI-74 and announce that whatever number on the screen is a prime number.
 
Simpson's Rule, 3-2-19

I found this website that calculated the volume of an American football with a definite integral.

https://www.math.ucdavis.edu/~morris/16B/sec5.7.pdf

As I've said before, I'm no programmer and I'm poor at math. But I wanted to see if I could work a definite integral on my TI-74. I found Simpson's Rule which is supposed to work a definite integral. I programmed Simpson's Rule on my 74. I put the definite integral on line 8100. It seems to work okay....at least it gave the results of their football example.


Code:
8000 PRINT "Simpson's Rule":PAUSE 1:Z=0:V=1:Y=0
8005 PRINT "Def.Integral..line 8100":PAUSE 1
8010 PRINT A;"start ";:ACCEPT NULL(A),A
8020 PRINT B;"end ";:ACCEPT NULL(B),B
8030 PRINT C;"step ";:ACCEPT NULL(C),C
8040 D=(B-A)/C:X=A-D
8045 IF (C/2)-INT(C/2)>0 THEN PRINT "..step even #s only":PAUSE :GOTO 8030
8050 X=X+D:IF X>B THEN 8130
8060 IF X=B THEN V=1
8070 IF V=1 THEN 8100
8080 IF V=2 THEN V=4:GOTO 8100
8090 IF V=4 THEN V=2

8100 Y=((-.0944*X^2)+3.4)^2*PI

8105 PRINT "x=";X;" y=";Y
8110 Y=Y*V:IF V=1 THEN V=2
8120 Z=Z+Y:GOTO 8050
8130 F=(Z*D)/3
8140 ANS=F:PRINT "ans=";F:PAUSE:GOTO 8000


Football example:

0 start -5.5 [enter]
0 end 5.5 [enter]
0 step 20 [enter]

ans= 232.1679769 in3 - football volume (cubic inches)

(delete line 8105 if you don't want to see X and Y on the display)
 
Of course that's assuming it's not the New England Patriots footballs!


Simpson's Rule, 3-2-19

I found this website that calculated the volume of an American football with a definite integral.

https://www.math.ucdavis.edu/~morris/16B/sec5.7.pdf

As I've said before, I'm no programmer and I'm poor at math. But I wanted to see if I could work a definite integral on my TI-74. I found Simpson's Rule which is supposed to work a definite integral. I programmed Simpson's Rule on my 74. I put the definite integral on line 8100. It seems to work okay....at least it gave the results of their football example.


Code:
8000 PRINT "Simpson's Rule":PAUSE 1:Z=0:V=1:Y=0
8005 PRINT "Def.Integral..line 8100":PAUSE 1
8010 PRINT A;"start ";:ACCEPT NULL(A),A
8020 PRINT B;"end ";:ACCEPT NULL(B),B
8030 PRINT C;"step ";:ACCEPT NULL(C),C
8040 D=(B-A)/C:X=A-D
8045 IF (C/2)-INT(C/2)>0 THEN PRINT "..step even #s only":PAUSE :GOTO 8030
8050 X=X+D:IF X>B THEN 8130
8060 IF X=B THEN V=1
8070 IF V=1 THEN 8100
8080 IF V=2 THEN V=4:GOTO 8100
8090 IF V=4 THEN V=2

8100 Y=((-.0944*X^2)+3.4)^2*PI

8105 PRINT "x=";X;" y=";Y
8110 Y=Y*V:IF V=1 THEN V=2
8120 Z=Z+Y:GOTO 8050
8130 F=(Z*D)/3
8140 ANS=F:PRINT "ans=";F:PAUSE:GOTO 8000


Football example:

0 start -5.5 [enter]
0 end 5.5 [enter]
0 step 20 [enter]

ans= 232.1679769 in3 - football volume (cubic inches)

(delete line 8105 if you don't want to see X and Y on the display)
 
Calories Burned Cycling, 4-3-19

Now that the weather's warmer, I'm back on my bicycle. If I didn't ride my bicycle I'd probably not excercise at all. I vary my ride frequently and often wonder how many calories a given ride burns. I found this Calories Burned Cycling calculator online:

https://captaincalculator.com/health/calorie/calories-burned-cycling-calculator/

It seems to work good. I decided to write a program for my Ti-74 using their math and info. The Ti-74 yields results pretty close to the example given. Checkout the website for more detailed information with an explanation and examples of MET. I did include some of their MET values I thought were pertinent.


Code:
1400 DATA met number is the..
1402 DATA metabolic equivalent of task
1405 DATA leisure 5.5 mph = 3.5 met
1410 DATA leisure 9.4 mph = 5.8 met
1420 DATA bicycling general = 7.5 met
1430 DATA mountain general = 8.5 met
1440 DATA fast 14-15.9 mph = 10 met
1450 DATA racing 16-19 mph = 12 met
1490 DATA end

1500 PRINT "Calories Burned Cycling":PAUSE .8:A7$="":RESTORE 1400
1510 PRINT W;"your weight ";:ACCEPT NULL(W),W
1520 PRINT CW$;" (l)bs or (k)gs ";:ACCEPT NULL(CW$),CW$
1530 IF CW$="l"THEN WT=W*0.45359237:GOTO 1560
1540 IF CW$="k"THEN 1560
1550 GOTO 1520

1560 PRINT MT$;" (m)et or (v)iew ";:ACCEPT NULL(MT$),MT$
1570 IF MT$="v"THEN 1600 ELSE 1590
1580 GOTO 1560
1590 PRINT MET;"met ";:ACCEPT NULL(MET),MET:GOTO 1630

1600 READ A7$
1610 IF A7$="end"THEN RESTORE 1400:GOTO 1560
1615 PRINT A7$:PAUSE
1620 GOTO 1600

1630 PRINT MIN;"ride mins ";:ACCEPT NULL(MIN),MIN
1640 ANS=((MET*WT*3.5)/200)*MIN
1650 PRINT USING"ans calories burned ####.#";ANS:PAUSE:GOTO 1500


Example:

0 your weight 160 [enter]
(l)bs or (k)gs l [enter] -- pounds or kilograms
(m)et or (v)iew m [enter] -- to enter or view met value
0 met 5.8 [enter] -- met number from list
0 ride mins 80 [enter] -- total minutes of bike ride

ans calories burned 589.3


160 your weight 72.72 [enter]
l (l)bs or (k)gs k [enter]
m (m)et or (v)iew [enter]
5.8 met [enter]
80 ride mins [enter]

ans calories burned 589.3
 
Calories Burned Cycling, corrections, 4-4-19

I found some errors. Change:

1540 IF CW$="k"THEN WT=W:GOTO 1560

1570 IF MT$="v"THEN 1600
1575 IF MT$="m"THEN 1590

The Kgs example result: 590.5

If I find anymore, I'll let you know. Like I've said, I'm no programmer.
 
Right Triangle, 5-17-19

I like playing with old cars. I needed something more flexible than P>R and R>P for suspension geometry and body angles. I made this program for my ti74 that works a right triangle. I tried to describe the labeling I used for the right triangle in the program with text. On input type h for help. All angles are in degrees decimal (deg dec).

I used this prompt for input, " _ _>_ _;_ _ " for "sa>sb;aa" meaning I want Side A using Side B and Angle A. The underscore characters "_ _" in the prompt are [ctl] [5] keyboard characters without any space between.

Before using Right Triangle, run through every input to be sure it's yielding accurate known results. (see IF/THENs below) I gave a right triangle sides and angles example. Expect some rounding error in example results.

After viewing answer with following input values use [space] to repeat the answer. And like usual, I'm no programmer or math expert but the program seems to work good for me.


Code:
14000 PRINT "Right Triangle":PAUSE .6:RESTORE 14400:ON ERROR 14490
14005 Z$=D$:PRINT D$;:INPUT "  _ _>_ _;_ _  ";D$:IF D$=""THEN D$=Z$
14008 IF D$="h"THEN 14300

14010 IF D$="sa>sb;aa"THEN INPUT "sb ";B,"aa ";C:F=B*TAN(C):GOTO 14210
14020 IF D$="sa>sc;aa"THEN INPUT "sc ";B,"aa ";C:F=B*SIN(C):GOTO 14210
14030 IF D$="sa>sc;ab"THEN INPUT "sc ";B,"ab ";C:F=B*COS(C):GOTO 14210
14040 IF D$="sb>sc;aa"THEN INPUT "sc ";B,"aa ";C:F=B*COS(C):GOTO 14210
14050 IF D$="sb>sa;ab"THEN INPUT "sa ";B,"ab ";C:F=B*TAN(C):GOTO 14210
14060 IF D$="sb>sa;aa"THEN INPUT "sa ";B,"aa ";C:F=B/TAN(C):GOTO 14210
14070 IF D$="sc>sa;aa"THEN INPUT "sa ";B,"aa ";C:F=B/SIN(C):GOTO 14210
14080 IF D$="sc>sb;aa"THEN INPUT "sb ";B,"aa ";C:F=B/COS(C):GOTO 14210
14090 IF D$="sc>sa;ab"THEN INPUT "sa ";B,"ab ";C:F=B/COS(C):GOTO 14210
   
14100 IF D$="aa>sa;sc"THEN INPUT "sa ";B,"sc ";C:F=ASIN(B/C):GOTO 14210
14110 IF D$="aa>sb;sc"THEN INPUT "sb ";B,"sc ";C:F=ACOS(B/C):GOTO 14210
14120 IF D$="aa>sa;sb"THEN INPUT "sa ";B,"sb ";C:F=ATN(B/C):GOTO 14210
14130 IF D$="ab>sb;sc"THEN INPUT "sb ";B,"sc ";C:F=ASIN(B/C):GOTO 14210
14140 IF D$="ab>sa;sc"THEN INPUT "sa ";B,"sc ";C:F=ACOS(B/C):GOTO 14210
14150 IF D$="ab>sa;sb"THEN INPUT "sa ";C,"sb ";B:F=ATN(B/C):GOTO 14210

14160 IF D$="sa>sb;sc"THEN INPUT "sb ";C,"sc ";B:F=SQR(B^2-C^2):GOTO 14200
14170 IF D$="sb>sa;sc"THEN INPUT "sa ";C,"sc ";B:F=SQR(B^2-C^2):GOTO 14200
14180 IF D$="sc>sa;sb"THEN INPUT "sa ";C,"sb ";B:F=SQR(C^2+B^2):GOTO 14200
14190 PRINT "not found..":PAUSE:GOTO 14005

14200 E=B:B=C:C=E
14210 ANS=F:PRINT "ans";F;SEG$(D$,1,2):PAUSE:PRINT SEG$(D$,4,6);" =";B;";";C
14220 A$=KEY$:IF A$=" "THEN 14210 ELSE 14000

14300 READ H$
14310 IF H$="end"THEN PRINT "end..":PAUSE 1:D$="":GOTO 14000
14320 PRINT H$:PAUSE
14330 GOTO 14300

14400 DATA Right Triangle Sides Angles (deg dec)
14402 DATA make an x y number line
14405 DATA where x y cross the angle is 90 deg
14410 DATA the y axis is Side A (sa)
14415 DATA the x axis is Side B (sb)
14420 DATA the hypotenuse from y to x is Side C (sc)
14425 DATA where y and hypotenuse meet is Angle B (ab)
14430 DATA where x and hypotenuse meet is Angle A (aa)
14435 DATA end

14490 PRINT "error..":PAUSE:GOTO 14000



Example: sa=25.5:sb=120:sc=122.68:aa=12:ab=78 (expect some rounding error)
 
Right Triangle edit: 5-17-19

To be sure you're in degree mode put DEG at the beginning of 14000:

14000 DEG:pRINT "Right Triangle":pAUSE .6:RESTORE 14400:ON ERROR 14490

For labeling, x y sides are positive:

14405 DATA where +x +y cross the angle is 90 deg
 
Heat Index, 7-3-19

Summer is here. Since temperature and humidity will vary from location to location, I decided to make a Heat Index program for my Ti-74 that I could use as I'm traveling and camping. I found this heat index formula,

https://www.weather.gov/media/epz/wxcalc/heatIndex.pdf

I also found a chart of temperature/humidity heat index values,

https://www.weather.gov/safety/heat-index

According to the chart, the temperature and humidity inputs need to be in a certain range to yield proper results. The temperature also needs to be in degrees fahrenheit and the relative humidity needs to be in percent. The output is a temperature in degrees fahrenheit of what the input temperature and humidity combined would seem to feel like.

Check results to the chart to be sure the program is working properly. If the answer seems unusual, check it to the chart. The only limit is on the range of the heat index output value. It seems to work okay but remember, I'm no programmer or math expert.


Code:
700 PRINT "Heat Index":PAUSE .6
710 PRINT T;"temp,deg f ";:ACCEPT NULL(T),T
720 PRINT RH;"relative humidity,% ";:ACCEPT NULL(RH),RH
730 A1=-42.379+(2.04901523*T):A2=(10.14333127*RH)
740 A3=(0.22475541*T*RH):A4=(6.83782*10^-3*T^2)
750 A5=(5.481717*10^-2*RH^2):A6=(1.2287*10^-3*T^2*RH)
760 A7=(8.5282*10^-4*T*RH^2):A8=(1.99*10^-6*T^2*RH^2)

770 ANS=A1+A2-A3-A4-A5+A6+A7-A8
780 IF ANS>137 OR ANS<80 THEN PRINT "error..inputs out of range":PAUSE:GOTO 710
790 PRINT USING"ans Heat Index,deg f=####.#";ANS:PAUSE:GOTO 700


Example:

0 temp,deg f 94
0 relative humidity,% 70
ans Heat Index,deg f= 119.0

94 temp,deg f 90
70 relative humidity,% 65
ans Heat Index,deg f= 102.6
 
Parabola, 8-20-19

I have some left-over thin aluminum roofing flashing. I want to see if I can make a parabolic solar cooker that would grill a hamburger. I need to figure and trace out 1/2 of a parabolic curve for a cardboard template I'll use to trace the curve for the vertical aluminum ribs. I went online for a parabolic calculator but found them a little confusing. So I found a formula and made a program for my ti74. Check the ti74's output to an online calculator.

After punching in some numbers, I decided to make the dish/reflector 6 feet in diameter and 18 inches high/deep. This should put the focus even with the outer edge of the reflector so I can easily mount a support across the dish at the focal point for the grill. I haven't built it but I'm hoping it will generate enough heat at the focal point to cook a hamburger using the sun. Cool if it did. (I must remember to wear good eye protection if I build and use it.)

(enter 0 at 'increment (x)' to start over)


Code:
900 PRINT "Parabola":PAUSE .6
910 INPUT "radius (x) ";R9,"height (y) ";T9:C9=T9/R9^2
920 Z9=R9^2/(4*T9):PRINT "focus=";Z9:PAUSE
925 INPUT "increment (x) ? ";K9:I9=K9^2*C9:IF K9<=0 THEN 900
930 IF K9>R9 THEN PRINT "max incremented (x)=";R9:PAUSE:GOTO 925
940 PRINT USING"INCREMENT (y)=###.###";I9;:PRINT " @";K9;"(x)":PAUSE:GOTO 925


My planned dish example:

radius (x) 36"
height (y) 18"
focus= 18"

increment (x) then INCREMENT (y)

1" = .014"
2" = .056"
3" = .125"
4" = .222"
5" = .347"
6" = .500"
7" = .680"
8" = .889"
9" = 1.125"
10" = 1.389"
11" = 1.681"
12" = 2.000"
13" = 2.347"
14" = 2.722"
15" = 3.125"
16" = 3.556"
17" = 4.014"
18" = 4.500"
19" = 5.014"
20" = 5.556"
21" = 6.125"
22" = 6.722"
23" = 7.347"
24" = 8.000"
25" = 8.681"
26" = 9.389"
27" = 10.125"
28" = 10.889"
29" = 11.681"
30" = 12.500"
31" = 13.347"
32" = 14.222"
33" = 15.125"
34" = 16.056"
35" = 17.014"
36" = 18.000"
 
Last edited:
Combined Gas Law, 11-4-19

On one of my old cars I want to increase the pressure in my copper radiator and raise the boiling point of the coolant. Using water as the coolant, what temperature would my coolant boil with a 16 psi radiator cap instead of my current 15 psi cap? I wanted the answer in customary English units of which I'm most familiar. I found this Combined Gas Law calculator online....

https://www.calcprofi.com/combined-gas-law-formula-calculator.html

I made a program for my Ti74. (I don't always have access to wifi and my phone is 'dumb') The program yields similar results to the online calculator. If I'm understanding and calculating correctly, going from a 15 psi cap at a 212 deg f boiling point to a 16 psi cap should yield a boiling temp of 257 deg f. I'm no math expert or programmer so check the results for yourself. But I think I'll give a 16 psi cap a try.


Code:
1100 PRINT "Combined Gas Law":PAUSE .8
1105 PRINT "Enter 0 For":PAUSE .8
1107 PRINT "Desired Quanity":PAUSE .8
1110 PRINT A;"> V1,in3 ";:ACCEPT NULL(A),A:V1=A
1120 PRINT B;"> P1,psi ";:ACCEPT NULL(B),B:P1=B
1130 PRINT C;"> T1,deg f ";:ACCEPT NULL(C),C:T1=C+459.67
1140 PRINT D;"> V2,in3 ";:ACCEPT NULL(D),D:V2=D
1150 PRINT E;"> P2,psi ";:ACCEPT NULL(E),E:P2=E
1160 PRINT F;"> T2,deg f ";:ACCEPT NULL(F),F:T2=F+459.67

1170 IF A=0 THEN X=(V2*P2*T1)/(P1*T2):X$="V1,in3=":A=X:GOTO 1240
1180 IF B=0 THEN X=(V2*P2*T1)/(V1*T2):X$="P1,psi=":B=X:GOTO 1240
1190 IF C=0 THEN X=(V1*P1*T2)/(V2*P2):X=X-459.67:X$="T1,deg f=":C=X:GOTO 1240
1200 IF D=0 THEN X=(V1*P1*T2)/(P2*T1):X$="V2,in3=":D=X:GOTO 1240
1210 IF E=0 THEN X=(V1*P1*T2)/(V2*T1):X$="P2,psi=":E=X:GOTO 1240
1220 IF F=0 THEN X=(V2*P2*T1)/(V1*P1):X=X-459.67:X$="T2,deg f=":F=X:GOTO 1240
1230 PRINT "error..":PAUSE:GOTO 1100

1240 ANS=X:PRINT "ans ";X$;X:PAUSE:GOTO 1100



For my radiator:

V1=1 in3 [enter]
P1=15 psi [enter]
T1=212 deg f [enter]

V2=1 in3 [enter]
P2=16 psi [enter]
T2=0 [enter]

T2=256.778 deg f
 
Stat, 12-15-19

My granddaughter was showing me how to use/do paired statistics. She had her TI-84 and I had my TI-74 in Calc Mode trying to keep up with her. In Calc Mode I haven't found a way to view entered data. But unlike variables in Basic Mode, Calc Mode stores the stat data with the TI-74 off. In Basic Mode the Basic programm is saved with the TI-74 off.

In the TI-74 User's Guide, TI gives the stat formulas and a spring example using paired data. I thought if I were to store paired data in Basic DATA statements in a program my paired data would be stored and more easily edited. Using TI's stat formulas I wrote a Basic program to do stats. The program yields the same results for TI's spring example as calculated in the Calc Mode using the [stat] keys. How many lines of DATA statements before you're out of memory or it errors itself out, I don't know. I allowed almost 500 program lines for the paired data.

Like I say, I'm no math expect or programmer so check it out for yourself. The program is intended for use with paired data. I'm going to get my granddaughter to show me a few more things now that I can view, edit and enter data more easily.


Code:
1 DATA 27,99
2 DATA 32,152
3 DATA 23,81
4 DATA 25,98
5 DATA 31,151
6 DATA 28,112

499 DATA 1.E+126,1.E+126

500 ON ERROR 810:RESTORE:X=0:Y=0:N=0:SUMX=0:SUMY=0
503 MEANX=0:MEANY=0:SUMX2=0:SUMY2=0:SUMXY=0
505 N=N+1:READ X,Y:PRINT "Stat";X;Y
510 IF X=1.E+126 AND Y=1.E+126 THEN 580
520 SUMX=X+SUMX:SUMY=Y+SUMY
530 MEANX=SUMX/N:MEANY=SUMY/N
540 SUMX2=SUMX2+X^2:SUMY2=SUMY2+Y^2
550 SUMXY=SUMXY+(X*Y)
570 GOTO 505

580 PRINT :PRINT "sumx =";SUMX:PAUSE
590 PRINT "sumy =";SUMY:PAUSE
600 PRINT "meanx =";MEANX:PAUSE
610 PRINT "meany =";MEANY:PAUSE
620 PRINT "sumx2 =";SUMX2:PAUSE
630 PRINT "sumy2 =";SUMY2:PAUSE
640 PRINT "sumxy =";SUMXY:PAUSE  

650 A=(SUMX*(((SUMX*SUMY)/(N-1))-SUMXY))/(((N-1)*SUMX2)-SUMX^2)+(SUMY/(N-1))
660 PRINT "A intercept =";A:PAUSE
670 B=(((N-1)*SUMXY)-(SUMX*SUMY))/(((N-1)*SUMX2)-SUMX^2)
680 PRINT "B slope =";B:PAUSE
690 SX=((((N-1)*SUMX2)-SUMX^2)/((N-1)*((N-1)-1))):SX=SQR(ABS(SX))
700 SY=((((N-1)*SUMY2)-SUMY^2)/((N-1)*((N-1)-1))):SY=SQR(ABS(SY)):R=(B*SX)/SY

710 PRINT "R cor coef =";R:PAUSE
720 PRINT "SX =";SX:PAUSE
730 PRINT "SY =";SY:PAUSE
740 PRINT "N =";N-1:N=N-1:PAUSE

770 INPUT "est x or y  ";Z$:IF Z$="x"THEN 790
780 IF Z$="y"THEN 800 ELSE 500
790 INPUT "est,x enter y  ";Y:X=(Y-A)/B:PRINT "est x =";X:PAUSE:GOTO 770
800 INPUT "est,y enter x  ";X:Y=A+(B*X):PRINT "est y =";Y:PAUSE:GOTO 770

810 PRINT "Error..redo":PAUSE:END


Example: enter paired data into program DATA statements starting with line number 1

1 DATA 27,99
2 DATA 32,152
3 DATA 23,81
4 DATA 25,98
5 DATA 31,151
6 DATA 28,112

now RUN, use [enter] to toggle through the results

sumx = 166
sumy = 693
meanx = 27.66666667
meany = 115.5
sumx2 = 4652
sumy2 = 84415
sumxy = 19667
A intercept = -114.8483146
B slope = 8.325842697
R cor coef = .9697571933
SX = 3.444802849
SY = 29.57532756
N = 6

estimate x, (enter y) 84.97191011
est x= 24

estimate y, (enter x) 24
est y= 84.97191011
 
Last edited:
Stat, 12-15-19 Edit:

I can only edit a short time after I post. I was looking over the Stat program and I see I was a little redundant. You can reduce the repetitive math by replacing these lines if you want. Stat should operate the same and yield the same results.


580 N=N-1:pRINT :pRINT "sumx =";SUMX:pAUSE

650 A=(SUMX*(((SUMX*SUMY)/N)-SUMXY))/((N*SUMX2)-SUMX^2)+(SUMY/N)

670 B=((N*SUMXY)-(SUMX*SUMY))/((N*SUMX2)-SUMX^2)

690 SX=(((N*SUMX2)-SUMX^2)/(N*(N-1))):SX=SQR(ABS(SX))

700 SY=(((N*SUMY2)-SUMY^2)/(N*(N-1))):SY=SQR(ABS(SY)):R=(B*SX)/SY

740 PRINT "N =";N:pAUSE
 
Last edited:
Ohm DC, 1-22-2020

I wanted to be able to work a list of formulas directly. I put the formulas in DATA statements. With the [+] [-] keys I can scroll up and down the formula list. When I find a formula I want, I break the program and do [SHIFT] [PB]. I store the formula holding [FN] and [SHIFT] then [1]. I seed the variables, recall the formula with [FN] [1] then [ENTER] the formula and look at the variable result.

Sometimes I seed the variables in the DATA statement followed by the formula and a PRINT statement. I break the program, recall with [SHIFT] [PB] then [ENTER] the formula for the result. In the program below I include some Ohms Law DC formulas I use. Here's a webite that has more formulas.

http://www.electrical101.com/ohms-law.html

I find this quicker and easier than writing seperate small programs or typing everything in repeatedly. I'm no programmer or math expert, so check everything out before using.


E=voltage,volts
I=currect,amps
R=resistance,ohms
P=power,watts


Code:
1 DATA Ohm DC..use + - keys
2 DATA E=12:R=2:I=E/R:PRINT I
3 DATA I=SQR(P/R)
4 DATA I=P/E
5 DATA R=E/I
6 DATA R=P/I^2
7 DATA R=E^2/P
8 DATA E=I*R
9 DATA E=P/I

99 DATA end..


100 C9=0:DIM A9$(105)
110 C9=C9+1:READ A9$(C9)
120 IF A9$(C9)="end.."THEN 200
130 GOTO 110

200 C9=0
210 C9=C9+1:PRINT A9$(C9):IF A9$(C9)="end.."THEN 230
220 IF KEY$="+"THEN C9=C9+1:PRINT A9$(C9)
225 IF C9>98 THEN C9=99
230 IF KEY$="-"THEN C9=C9-1:PRINT A9$(C9):IF C9<2 THEN C9=0 ELSE 230
240 IF A9$(C9)="end.."THEN C9=C9-1:GOTO 230
250 GOTO 210


Examples: E=12 R=2 I=6

[RUN] [ENTER] [+]

E=I*R [BREAK] [CLR] [SHIFT] [PB]

E=I*R [FN]and[SHIFT] [1]

I=6 [ENTER]
R=2 [ENTER]
[FN] [1] E=I*R [ENTER]

E [ENTER] 12

..................................

[RUN] [ENTER] [+]

E=12:R=2:I=E/R:pRINT I [BREAK] [CLR]

[SHIFT] [PB] E=12:R=2:I=E/R:pRINT I

[ENTER] 6
 
Last edited:
Vectors, 2-20-20

I could find a single magnitude and angle using [P>R] in calc mode. I wrote this program to find the resultant of a number of vectors. All angles are in degrees decimal (dd). On a quadrant, angles are positive rotating counter-clock-wise (CCW) 0 to 359 degrees. 'resang-360' shows the resultant angle negative from 0 rotating in the clock-wise (CW) direction.

I went online to find examples of vector addition and the resultant. There are many websites explaining the process. Here are two with worked examples and a third with example and calculator. The Vectors program seems to give similar results. [spc] bar at the end repeats the answer and [enter] returns to the beginning. Re-RUN to clear.

https://www.ae.msstate.edu/vlsm/forcesys/concurrent_force_systems/examples/example1.htm

https://www.allaboutcircuits.com/textbook/alternating-current/chpt-5/series-r-l-and-c/

http://hyperphysics.phy-astr.gsu.edu/hbase/vect.html

I'm no math expert or programmer so check the program out completely for yourself. I might have missed something or there could be thing's of which I'm unaware.


Code:
6000 PRINT "Vectors":PAUSE .6:DEG
6002 PRINT "..all angles deg dec":PAUSE 1.2
6005 VA=0:VB=0:PRINT X;"# of vectors ";:ACCEPT NULL(V),V
6006 IF V=0 THEN V=X ELSE X=V
6008 IF V>9 OR V<2 THEN PRINT "error..2 to 9":PAUSE:GOTO 6005
6010 PRINT M9(V);"#";V;"mag ";:ACCEPT NULL(M9(V)),M9(V)
6012 PRINT N9(V);"#";V;"dd ";:ACCEPT NULL(N9(V)),N9(V)
6015 IF N9(V)<0 THEN N9(V)=N9(V)+360
6020 IF V=1 THEN 6100 ELSE V=V-1:GOTO 6010

6100 V=X:PRINT"..."
6110 A=SIN(N9(V)):SA(V)=M9(V)*A:A=COS(N9(V)):SB(V)=M9(V)*A
6120 VA=VA+SA(V):VB=VB+SB(V):V=V-1:IF V=0 THEN 6200
6130 GOTO 6110

6200 F=ATN(VA/VB):E=VB/COS(F):E=ABS(E)
6210 IF VA>0 AND VB<0 THEN F=180+F
6220 IF VA<0 AND VB<0 THEN F=180+F
6230 IF VA<0 AND VB>0 THEN F=360+F
6235 RESMAG=E:RESANG=F
6240 PRINT "resmag= ";E;"mag":PAUSE:PRINT "resang= ";F;"dd":PAUSE
6250 PRINT "resang-360= ";RESANG-360;:PRINT "dd":PAUSE
6260 PRINT "[spc] or [enter]":IF KEY$=" "THEN 6240 ELSE 6005


Example 1, with the boat example:

0 # of vectors, 2
0 # 2 mag, 15000 N
0 # 2 dd, 30 dd
0 # 1 mag, 20000 N
0 # 1 dd, -50 dd

resmag= 27003.49804 N
resang= 343.1644917 dd
resang-360= -16.8355083 dd

(from 0 dd, 343.1644917 CCW same as -16.8355083 CW)

...........................

Example 2, with the series RLC circuit:

0 # of vectors, 3
0 # 3 mag, 245.04 ohm
0 # 3 dd, 90 dd
0 # 2 mag, 250 ohm
0 # 2 dd, 0 dd
0 # 1 mag, 1.7684E3 ohm
0 # 1 dd, -90 dd

resmag= 1543.737571 ohm
resang= 279.3197872 dd
resang-360= -80.68021281 dd

..........................

Example 3, 4 vectors with the online calculator:

0 # of vectors, 4
0 # 4 mag, 120
0 # 4 dd, 160
0 # 3 mag, 110
0 # 3 dd, 225
0 # 2 mag, 140
0 # 2 dd, 260
0 # 1 mag, 120
0 # 1 dd, 340

resmag= 238.5998386 mag
resang= 244.6668012 dd
resang-360= -115.3331988 dd
 
PR-RP, 11-5-20

As far as I know, you can't pass variables between the Calculator and Basic modes. So I stripped out the rectangular to polar/polar to rectangular section from the RPN program to make converting easier in Basic mode. It's the same basic routine but I find it easier to use rather than going back and forth between modes. Angles are in degrees decimal (dd). Like I say, I'm no programmer or math expert so thoroughly check it out before using it.


Code:
6500 PRINT "PR-RP":PAUSE .6:DEG
6510 C=0:D=0:Z$="?"
6520 PRINT "1)";C;": ";:ACCEPT NULL(C),C
6530 PRINT "2)";D;": ";:ACCEPT NULL(D),D
6540 PRINT Z$;" : pr rp  ";:ACCEPT NULL(Z$),Z$
6550 IF Z$="0"THEN END

6560 IF Z$="pr"THEN Y=C*SIN(D):X=C*COS(D):GOTO 6600
6570 IF Z$="rp"THEN R=SQR(C^2+D^2):A=ASIN(D/R):GOTO 6610
6580 PRINT "error..":PAUSE:GOTO 6540

6600 PRINT "x=";X;"y=";Y:PAUSE:GOTO 6520

6610 IF C<0 AND D>0 THEN A=ABS(180-A)
6620 IF C<0 AND D<0 THEN A=ABS(180-A)-360
6630 PRINT "r=";R;" ";CHR$(242);"a=";A:PAUSE:GOTO 6520


Examples:

1) 100, 2) 40, pr =, x=76.60444431, y=64.27876097
1) 145, 2) 23, rp =, r=146.812806, a=9.013204356
 
Memory, 11-11-20

As you get older they say you should 'exercise' your memory. This program allows you to enter items you wish to try to remember on program lines 1 to 97. Enter the line number, 'space DATA space' followed by the item you wish to remember (see program lines 1,2,3). 'end..' will be the last item you'll have to remember before the program restarts and repeats itself. Enter a '?' to see the current item to be remembered.

If you remember the item correctly you'll get a 'point'. If the item remembered is wrong, 1 'point' will be subtrated from your score. If you use the '?' to see the item, 1 'point' will also be subtracted. The items I put on lines 1,2,3 in the program are there just as examples. Enter your own items to remember.



Code:
1 DATA one
2 DATA two
3 DATA 3

98 DATA end..

100 PRINT "MEMORY":PAUSE 1
110 P=0
120 READ M$

130 INPUT "Remember ? ";T$
140 IF T$="?"THEN PRINT "Ok. ";M$:PAUSE:P=P-1:GOTO 130
150 IF T$=M$THEN PRINT "Got it.";M$:PAUSE:P=P+1:GOTO 170
160 IF T$<>M$THEN PRINT "Nope.":PAUSE:P=P-1:GOTO 130

170 PRINT M$;" : Points ";P:PAUSE
180 IF M$="end.."THEN PRINT "Restarting..":PAUSE 1:RESTORE:GOTO 110
190 GOTO 120


Example: RUN [enter]

Remember ? one [enter]
Got it. one [enter]
one : Points 1 [enter]

Remember ? 2 [enter]
Nope. [enter]

Remember ? two [enter]
Got it. two [enter]
two : Points 1 [enter]

Remember ? three [enter]
Nope. [enter]

Remember ? ? [enter]
Ok. 3 [enter]

Remember ? 3 [enter]
Got it. 3 [enter]
3 : Points 0

Remember ? end.. [enter]
Got it. end.. [enter]
end.. : Points 1 [enter]

Restarting..
 
Last edited:
Back
Top