Sunday, December 25, 2022

HP 75C Program Collection

HP 75C Program Collection


Merry Christmas everyone!   I hope everyone is safe, happy, and blessed.



LAWCOS:  Law of Cosines

335 bytes


100 DISP "Law of Cosines" @ WAIT .25

105 OPTION ANGLE DEGREES

180 DISP "Θ is opp. side a" @ WAIT .25

110 INPUT "1) Side, 2) Angle? "; H

115 ON H GOTO 1000, 2000


1000 INPUT "b?, c?, Θ? "; B,C,T

1010 A=SQR(B^2+C^2-2*B*C*COS(T))

1020 DISP "a: "; STR$(A) @ END


2000 INPUT "a?, b?, c? "; A,B,C

2010 T=ACOS((B^2+C^2-A^2)/(2*B*C))

2020 DISP "Θ:"; STR$(T); "°" @ END


Example:

1) Side:  1

B = 11.78, C = 32.12, T = 60

Result:  a = 28.1440793063


2)  Angle: 2

A = 14.55, B = 12.65, C = 17.00

Result:  Θ = 56.5108780171°



SPECPOLY:  Special Polynomials

526 bytes  (10/27/2022)


1.Cheb:  Chebyshev Polynomial of the 1st order

2.Herm:  Hermite Polynomial 

3.Lagur:  Laguerre Polynomial (with α=0)

4.Legen:  Legendre Polynomial of the 1st Order


100 DISP "Polynomials:  Type?" @ WAIT .5

105 INPUT "1.Cheb 2.Herm 3.Lagur 4.Legen:"; H

110 INPUT "x? "; X

115 INPUT "order? ";N

120 A=1 @ B=X*(H=1 OR H=4)+2*X*(H=2)+(1-X)*(H=3)


300 IF N=0 THEN DISP A @ END

302 IF N=1 THEN DISP B @ END

305 FOR I=2 TO N

310 ON H GOSUB 500,505,510,515

315 A=B

320 B=C

325 NEXT I

330 DISP C

335 END


500 C=2*X*B-A @ RETURN

505 C=2*X*B-2*(I-1)*A @ RETURN

510 C=((2*(I-1)+1-X)*B-(I-1)*A)/I @ RETURN

515 C=((2*I-1)*X*B-(I-1)*A)/I @ RETURN


Source:


Davidson, James J.  "Chebyshev Polynomials, First & Second Kind, Tn(x) & Un(x)", "Hermite Polynomials, H(n); n≥n", "Laguerre Polynomials, Generalized, Ln^(α)(x)", "Legendre Functions, First & Second Kinds, Pn(x) & Qn(x)"  ENTER 65 NOTES  Vol. 3 No. 8 September 1976  pp. 11-12



Examples:

x = 11, order = 6

1.  Cheb:  55989361

2.  Herm: 106439224

3.  Lagur: -35.5902777778

4.  Legen: 25289461


ENGINE:  Automotive Engine Mathematics

630 bytes (10/27/2022)


100 DISP "Engine Math" @ WAIT .5

110 INPUT "# cylinders? "; N

120 DISP "Solve for?" @ WAIT .25

125 INPUT "1)DSP, 2)STROKE, 3)BORE "; H

130 IF H#1 THEN INPUT "DSP? "; D

135 IF H#2 THEN INPUT "STROKE? "; S

140 IF H#3 THEN INPUT "BORE? "; B

145 IF H=1 THEN LET D=PI/4*B^2*S*N

150 IF H=2 THEN LET S=D/(PI/4*B^2*N)

155 IF H=3 THEN LET B=SQR(D/(PI/4*S*N))

160 DISP "DPS= "; D @ STOP

165 DISP "STORKE= "; S @ STOP

170 DISP "BORE= "; B @ STOP


205 INPUT "RPM? (y/n) "; I$

210 IF UPRC(I$)="N" THEN 400


300 INPUT "RPM? "; R

310 P=S*R/6

320 E=R*D*.85/3456

350 DISP "Piston Speed="; P @ STOP

360 DISP "St. Carb CFM= "; E @ STOP

370 INPUT "Again? (y/n) "; I$ 

375 IF UPRC(I$)="Y" THEN 300


400 DISP "Done."


Source:


Lawlor, John.  Auto Math Handbook.  Calculations, Formulas, Equations, and Theory for Automotive Enthusiasts.  HP Books:  Berkeley Publishing Group:  New York, NY.  1991.  ISBN 1-55788-020-4


LINREG:  Linear Regression

568 bytes (10/31/2022)


100 DISP "y=mx+b" @ WAIT .5

110 S0=0 @ S1=0 @ S2=0 @ S3=0 @ S4=0 @ S5=0

120 DISP 'Σ+ Σ- Calc'

130 K$=KEY$ @ IF K$='' THEN 130

140 IF K$="+" THEN H=1 @ GOTO 200

150 IF K$="-" THEN H=-1 @ GOTO 200

160 IF UPRC$(K$)='C' THEN 400

170 GOTO 130


200 INPUT 'x,y? '; X,Y

210 S0=S0+H @ S1=S1+H*X @ S2=S2+H*Y

220 S3=S3+H*X^2 @ S4=S4+H*Y^2 @ S5=S5+H*X*Y

230 DISP S0 @ WAIT .5 @ GOTO 120


400 B=(S5-S1*S2/S0)/(S3-S1^2/S0)

440 A=(S2-B*S1)/S0

450 R=B*SQR((S0*S3-S1^2)/(S0*S4-S2^2))

470 DISP 'type cont...' @ WAIT .5


500 DISP 'SLP=';B @ STOP

510 DISP 'ITC=';A @ STOP

520 DISP 'CORR=';R


Instructions:

Press + to add data.  Separate  x and y with a comma.

Press - to delete data.  Separate x and y with a comma.

Press C to determine the slope, intercept, and correlation.


Example:

Data:

5, 4.066

8, 4.125

11, 4.202

18, 4.293

21, 4.349


ITC ≈ 3.99046

SLP ≈ 0.01719

CORR ≈ 0.99376


Source:


Hewlett Packard.  HP 12C User Guide  Edition 4.  San Diego, CA  2004.


SIMPSON:  Integral Using Simpson’s Rule Approximation

size varies - around 300 bytes


∫ FNF(X) dX from X = a to X = b


Line 100 is where you have to define your function (of X). 


100 DEF FNF(X) = [define f(x) here]


115 OPTION ANGLE RADIANS

120 INPUT "a? ";A

125 INPUT "b? ";B

130 INPUT "# parts (even)? ";N

135 T=FNF(A)+FNF(B)

140 H=(B-A)/N

145 FOR I TO N-1

150 IF FP(I/2)=0 THEN 155 ELSE 160

155 T=T+2*FNF(A+I*H) @ GOTO 165

160 T=T+4*FNF(A+I*H)

165 NEXT I

170 T=T*H/3

175 DISP "Integral = ";T


Examples:

For both examples, n = 24


FNF(X)= 2*X^2+3,  a = 1, b = 6, result:  158.333333333


FNF(X)=2*COS(X), a = 0, b = .785398163398, result:  1.41421357139  (exact √2)




Happy Holidays everyone!


Next post will be on New Years' Eve:  December 31, 2022.


Eddie 


All original content copyright, © 2011-2022.  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.