Saturday, December 31, 2022

HP Prime: Free Fall with Air Friction

HP Prime:   Free Fall with Air Friction 



Introduction


The program FALLS will calculate the position and velocity of an object falling with friction proportional to square of the object's speed.   The program is aimed towards large objects in free fall.  The half-increment method is used.


With the initial conditions:


y = 0  (initial position, assumed to be at zero)

g = gravitational constant

α = f/m  (force-mass ratio)

dy/dt = 0 (velocity, assume to be at rest from the beginning)


With Δt with the change of time:


dy/dt_1/2 = dy/dt_0 + C * Δt/2  where C = g - α * (dy/dt_0)^2


dy/dt_(i+1/2) = dy/dt_(i-1/2) + C * Δt where C =   g - α * (dy/dt_(i-1/2))^2


y_i+1 = y_i + dy/dt_(i+1/2) * Δt



HP Prime Program: FALLS


EXPORT FALLS()

BEGIN

// EWS 2022-11-03


HFormat:=1;

HDigits:=4; 


LOCAL t,g,a,n;

LOCAL i,d,c,y,m;

LOCAL l0,l1,l2;

LOCAL l3,l4,m0;

 

INPUT({t,g,a,n},"Fall-Air Resistance",

{"Δt =","g =","α =","n ="},

{"charge in time","gravity",

"force/mass","number of steps"});


l0:={m};

l1:={d};

l2:={y};


// for section here

FOR i FROM 1 TO n DO

c:=g-a*d^2;

IF t==0 THEN

c:=c/2;

END;

d:=d+c*t;

m:=m+t;

y:=y+d*t;

l0:=CONCAT(l0,{m});

l1:=CONCAT(l1,{d});

l2:=CONCAT(l2,{y});  

END;


l3:=CONCAT(l0,l1);

l4:=CONCAT(l3,l2);

m0:=list2mat(l4,SIZE(l0));

m0:=TRN(m0);

RETURN m0;

 

END;


The result is a matrix wit the columns:


Column 1:  time  (t = m)

Column 2:  velocity  (dy/dt = d)

Column 3:  position (y)


The program assumes that the object or person being dropped is well above the ground or floor.  




Example


Go 10 steps with Δ = 0.25 sec, g = 9.80665 m/s^2, and α = 0.028




Velocity ≈ 18.6716 m/s

Position ≈ 76.1314 m


The program assumes that the object or person being dropped is well above the ground or floor.  



Source


Eisberg, Robert M.  Applied Mathematical Physics with Programmable Pocket Calculators  McGraw-Hill Book Company:  New York  1976.   ISBN 0-07-019109-3




I want to wish you a Happy New Year. May you have a healthy, prosperous, and happy 2023!


Note:  For January and February 2023, my posting schedule will be on Saturdays only, starting January 7.  This doesn't include any firmware updates or reviews, they will be on Mondays should they occur.    One of my resolutions for 2023 is to catch up on my reading of math books and articles.


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. 


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. 


Saturday, December 24, 2022

Retro Review: HP 75C

Retro Review:  HP 75C



It's Christmas Eve!





Quick Facts


Model:  HP 75C 

Company:  Hewlett Packard

Years:  1982-1984

Type:  Scientific, BASIC Programmable

Batteries: Rechargeable Ni-CAD, with AC-Adapter**

Display:  1 line, 32 characters

Original Price:  $995

Memory:  16,000 bytes RAM with a slot for an 8K RAM Card

Other Ports:  3 ROM slots for applications 

Hard Case which stores the HP 75 and the cards, but not the AC adapter


The HP 75C (and later HP 75D) has an 8-bit CPU microprocessor named the Capricorn.   The Capricorn microprocessors where featured in the HP 85 computer.


For fans of tropical astrology, this article is posted on December 24, under the sign of Capricorn.   ♑  The Capricorn processor was designed by a Steve Wozniak, a Leo.  But I digress.



Introduction


The HP 75C computer is a portable computer with an almost full sized QWERTY keyboard.  The 75C is a scrolling one-line display that can have up to 32 characters.  The keyboard works like a computer keyboard: the [SHIFT] key must be pressed and held to type capital letters.


The keyboard is nice to type and with the correct size of hands, touch typing can be accomplished.  It also has a numeric keypad that can be activated by holding down [CTL] while pressing [LOCK].   Pressing [LOCK] ends the numeric keypad mode.


[ 7 ]  returns 7

[ 8 ]  returns 8

[ 9 ]  returns 9

[ U ] returns 4

[ I ] returns 5

[ O ] returns 6

[ J ] returns 1

[ K ] returns 2

[ L ] returns 3

[ M ] returns 0


Other characters can be accessed by holding down the [CTL] key and pressing another key.   Example characters that can be typed this way are:


CTL + Space:  Δ

CTL + A:  °

CTL + D:  α

CTL + I:  σ

CTL + P:  θ

CTL + T:  π

CTL + plus key:  Σ


The keyboard also has an HP-IL port and a card reader.  The card reader is manual, requiring the user to pull the card at just the right speed to record programs.  Transferring programs to cards, which are long and skinny, takes a lot of patience.  Each card be pulled in two ways and each way can store a program up to only 650 bytes.   Every time a new program is stored in a track, that new program replaces the previous contents.     


The battery is a rechargeable Ni-CAD battery.  If you purchase a HP 75C, I advise you to get one with a working AC plug.  According to the HP 75 Owner's Manual, it takes about 8 hours for the batteries to fully recharge.  


See the Sources section for a download link to the Owner's Manual.  


How to turn the HP 75C on?   There is no ON key.   The [ATTN] (attention) key takes care of this.  To turn the 75C off, hold [SHIFT] and press [ATTN] or type bye then [RTN]. 



Modes


The HP 75C has three operating modes:


TIME: setting the computer's clock and time.  Thankfully the HP 75C is Y2K friendly and allows dates after 2000.


APPT:  set and check personal appointments.


EDIT:  the main mode of the HP 75C computer.  This is where all the basic programs are edited, stored, and ran.   The Edit mode can handle one line algebraic calculations, with the order of operations followed.  



Programming


The HP 75C has BASIC programming language, although not as extensive as the HP 71B.  It's probably the one slight problem I have with the 75C, but missing functions can be programmed.   In tomorrow's post, I have a simple linear regression which the 75C's list of commands lack commands for.


What is included?  A short list includes:


*  square roots, modulus, sign, maximum, minimum, random numbers, remainder, integer part, fractional part 

*  the constants PI, INF (9.99999999999E499), EPS (1E-499)

*  degree/radian angle conversions, trigonometric functions, angle (atan2), sec, sec, cot, logarithms (log10 and log (for ln, this is a computer language))

*  relational tests (evaluated to 0 for false or 1 for true), logic (and, or, exor (either or but not both), not)

*  strings, alarm settings, beep, read and data, goto and label, for-to-step structure, if-then-else structure, character, date and time strings, arrays

*  printing and user function commands


Remember, in programming the 75C, line numbers are required.   


Like the HP 71B, I find it a joy to program the 75C.  



The Updated HP 75D


The HP 75D was an updated HP 75C computer and produced in rare supply from 1984 to 1986.  The retail price of an HP 75D was $1,095 and included a port for a  bar code wand. Yes, the same type of bar codes that you see on grocery products and you scan at the self checkout lines.   



Final Thoughts 


The HP 75C is not an inexpensive purchase.  If you buy one, please be sure you see pictures from the seller with the unit turned on.  In addition, at the very least, make sure it has working batteries and the AC adapter.   The going price for the HP 75C these days from at least $250 US.   


It is a worthwhile machine especially for fans of BASIC and a good companion to the HP 71B.   I am happy to have the 75C in my collection, which is years I missed out on winning one as a door prize.  



Sources


"HP-75"  Wikipedia.  September 7, 2021.   Retrieved December 4, 2022.  https://en.wikipedia.org/wiki/HP-75


"HP-75C/D"  Museum of HP Calculators.   Retrieved December 4, 2022.

https://www.hpmuseum.org/hp75.htm


Hewlett Packard.  HP-75 Owner's Manual.  Rev. B   November 1982.  

Download from the hpcalc.org's literature page here:  https://literature.hpcalc.org/items/1072



Until next time, keep happy and sane,


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. 


Monday, December 19, 2022

Review: Casio FC-200V 2nd Edition

Review:  Casio FC-200V 2nd Edition









Quick Facts


Model:  FC-200V 2nd Edition

Company:  Casio

Years:  October 2022 - present

Type:  Finance 

Batteries:  Solar and Battery (1 LR44)

Memory: 7 memory registers

System:  Algebraic with Order of Operations

Contrast Setting



The Financial 2nd Edition 



Ten years ago I reviewed the FC-200V "1st edition", which had the gold keyboard.  To be honest, I the cash flow problem I had was probably due to operator error (me).  


The gold 1st edition was released in 2004 and 18 years later, we have the black 2nd edition.  The 2nd edition follows Casio updating the scientific calculators such as fx-115 ES, fx-300 ES, and fx-300 MS.  According to Casio, the redesign are more environmental friendly and more durable than their previous editions.   


Like the fx-115 ES 2nd Edition, the keyboard FC-200V 2nd Edition feels responsive and looks clean.  


The two rows of light gray keys features the worksheets and modes of the FC-200V:


SMPL:  Simple Interest

CPMD:  Compound Interest (Time Value of Money)

CASH:  Cash Flows

AMRT:  Amortization (of compound interest)

COMP:  Compute mode, main mode

STAT:  Statistics

CNVR:  APR/EFF Conversions

COST:  Cost/Sell/Profit Margin Solver

DAYS:  Days Between Dates and Date Calculation

DEPR:  Depreciation

BOND:  Bond Calculations

BEVN:  Breakeven Calculations


The sticker on the case lists all of variables used in the calculator, as well as how to set the contrast on the screen.   


The available regressions are:


A+Bx:  Linear

+Cx^2:  Quadratic

ln X:  Logarithmic

e^X:  Exponential

A∙B^X:  Exponential (any base)

A∙X^B: Power

1/X:  Inverse


We can store up to 80 single data points, or 40 pairs of data points.  Turning STAT mode on in SETUP will give us access to the frequency column.  However this reduces the maximum number of data points to 40 and 26, respectively. 


The types of depreciation models available are:


SL:  Straight Line

FP:  Fixed Percentage

SYD: Sum of the Year's Digits

DB:  Declining Balance


Some of the variables are shared with the time value of money variables:


n = life of the asset

I% = percentage or declining balance factor

PV = cost

FV = residual value or salvage value


The Cash Flow worksheet features the following calculations:


NPV:  net present value

IRR:  internal rate of return

PBP:  payback period

NFV:  net future value 


Be aware that the data entry is shared with the statistics mode.   The first data point is still marked data point 1.  Data point 1 is the initial cash flow, typically labeled CF0 in most calculators.  I wish that the FC-200V had two separate lists in memory for cash flows and statistics to reduce confusion.  Turning STAT mode on in SETUP will allow for each point to have a frequency.   


Switch between statistics and cash flow modes will clear the list of data points.   This is one of the few areas where data does not transfer between applications.  


There is a FC-100V which is battery powered but does not have depreciation, bonds, and breakeven calculations.   The FC-100V 2nd Edition is currently available outside of the United States.  


I think the FC-200V could have used a QR code command on the calculator like the fx-991 EX.  However, we get a QR code on the calculator's case which gives access to the user manual.  


One of my favorite features is the ability to store two expressions through SHORT CUT 1 and SHORT CUT 2, and two functions with the FMEM1 and FMEM2.  FMEM1 and FMEM2 are the only way to assign access some of the functions such as rectangular/polar conversions, arcsine, arccosine, arctangent, factorial, and absolute value to the keyboard.



Variables


The FC-200V has seven variables independent of the financial variables: A, B, C, D, X, Y, and M.  M has the memory add (M+) and memory subtract (M-) that Casio has on scientific calculators.  We can enter variables with the ALPHA key.  However, the store key brings up a menu and this is the only way to store variables.  



The Percent Key and the Percent Change Key


The percent key works like the percent function on scientific algebraic calculators, just dividing its argument by 100.  The percent key (Δ%) also had idiosyncrasies to it.  Just typing Δ% execute the function immediately. 


To add y percent to x:  x + x * y% or x * (1 + y%)

To subtract y percent from x:  x - x * y% or x * (1 - y%)

To calculate percent change from x to y:  x - y Δ%

To calculate (y + x)/x * 100%:  x + y Δ%

To calculate sale price:   cost * profit margin Δ%



The manual makes a great reference, not only detailing the operations of the calculator, but also lists reference formulas.  You will have to find it online, as the calculator only gets quick start guides in English, Spanish, and French.



Final Thoughts


The FC-200V 2nd Edition is a feature rich financial calculator and its pretty easy to use, if you are willing to work with the idiosyncrasies.  

 

  


Source


Casio.  "FC-200V-2 Financial"  Retrieved December 3, 2022.  https://www.casio.com/us/scientific-calculators/product.FC-200V-2/



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. 


Sunday, December 18, 2022

HP Prime: Constant Payment Applied to Principal

HP Prime:  Constant Payment Applied to Principal 



Constant Amount Applied to Principal 


In most loans and mortgages,  the amount of payment applying to interest and principal depends on the running balance.  


This program assumes the customer wants an equal portion to apply to principal each payment.   As a result, the payment itself, principal and interest, will vary.  The simple algorithm to amortize this loan is this:


For K=1 to N:


Int =  Bal * I%÷100


Tpmt = Int + CPMT


Bal_k = Bal_(k-1) - CMPT


where:


Bal = balance of a loan

PV = loan amount

CPMT = amount to be applied to principal each payment

I% = interest rate

Int = interest calculated for payment K

Tpmt = total payment for payment K



HP Prime Program CPYMT


The result of CPYMT is a four column matrix with rows:  k, interest in payment k, total payment k, resulting balance.  Keep in mind that program asks for periodic interest rate.  


EXPORT CPYMT()

BEGIN

// 2022-10-24 EWS

// fix 2

HFormat:=1;

HDigits:=2;

// local

LOCAL n,i,p,b,it,tp,k,x;

LOCAL ll,l0,l1,l2,l3,m;

// main

INPUT({n,i,p,b},"Constant Principal",

{"N = ","I%=","PMT=","LOAN="},

{"# of payments",

"periodic interest rate",

"constant payment",

"loan amount"});

l0:={0};

l1:={0};

l2:={b};

FOR k FROM 1 TO n DO

it:=b*i/100;

tp:=p+it;

b:=b-p;

ll:=MAKELIST(x,x,1,n+1,1);

l0:=CONCAT(l0,{it});

l1:=CONCAT(l1,{tp});

l2:=CONCAT(l2,{b});

END;

l3:=CONCAT(ll,l0);

l3:=CONCAT(l3,l1);

l3:=CONCAT(l3,l2);

m:=list2mat(l3,SIZE(l0));

m:=TRN(m);

RETURN m; 

END;



Example


Five year loan of $10,000 where the customer requests an equal amount of principal to be applied each annual payment ($2,000 a year).  The loan rate is 6.99%.


Inputs:

N = 5

I% = 6.99

PMT = 2,000.00

LOAN = 10,000.00


Result:


Year 1:  Interest:  $699.00;  Total Payment:  $2,699.00;  Balance:  $8,000.00

Year 2:  Interest:  $599.20;  Total Payment:  $2,559.20;  Balance:  $6,000.00

Year 3:  Interest:  $419.40;  Total Payment:  $2,419.40;  Balance:  $4,000.00

Year 4:  Interest:  $279.60;  Total Payment:  $2,279.60;  Balance:  $2,000.00

Year 5:  Interest:  $139.80;  Total Payment:  $2,139.80;  Balance:  $0.00



Source


"Constant Payment to Principal Loan"  HP-41 User's Library Solutions: Lend/Lease/Savings  Hewlett Packard.  November 1980



Next week I am going to cover the legendary HP 75C.  



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. 


Saturday, December 17, 2022

HP 20S: Triac Waveforms

HP 20S:   Triac Waveforms


Introduction


The following calculations involve triode AC switches, better known as triacs.  A triac is generally used as a bidirectional power switch device.  James J. Davidson, the original author of the HP 25 programs states "these programs are for use with mean-absolute (also called average) responding voltmeters which are calibrated to read the rms value of a sine wave"  (Davidson, 38).


The variables used in Davidson's programs are: 


Vs = root mean square from source

VLMS = root mean square voltage

VLMA = average load voltage

θ = firing angle of triac in degrees (Davidson, 38)


These programs have been translated to for the use of the HP 20S calculator.  


HP 20S Program:  Triac Waveforms

(59 steps)



Given:  Vs and θ°, calculate VLMA and VLMS


Store Vs in R0

Store θ° in R1 (degrees)

Press [ XEQ ] [ A ]

VLMA is displayed

Press [ R/S ], VLMA is displayed



Given:  Vs and VLMA, calculate θ° and VLMS


Store Vs in R0

Store VLMA in R4

Press [ XEQ ] [ B ]

θ° is displayed

Press [ R/S ], VLMA is displayed


Variables:


R0 = Vs

R1 = θ in degrees

R2 = θ in radians

R3 = VLMA 

R4 = VLMS



Program Code


Key Code:  { Key }


61, 41, A:  { LBL A }

61, 24:  { RAD }

22, 1:  { RCL 1 }

61, 55:  { →RAD }

21, 2:  { STO 2 }

24:  { COS }

75:  { + }

1:  { 1 }

74:  { = }

55: { × }

22, 0:  { RCL 0 }

45:  { ÷ }

2:  { 2 }

74:  { = }

21, 3:  { RCL 3 }

26:  { R/S }

51, 41, 1:  { GTO 1 }

61, 26:  { RTN }


61, 41, b:  { LBL B }

61, 24:  { RAD }

33:  { ( }

2:  { 2 }

55:  { × }

22, 3:  { RCL 3 }

45:  { ÷ }

22, 0:  { RCL 0 }

65:  { - }

1:  { 1 }

34:  { ) }

51, 24:  { ACOS }

21, 2:  { STO 2 }

51, 55:  { →DEG }

21, 1:  { STO 1 }

26:  { R/S }

51, 41, 1:  { GTO 1 }

61, 26:  { RTN }


61, 41, 1:  { LBL 1 }

61, 22:  { π }

65:  { - }

22, 2:  { RCL 2 }

75:  { + }

33:  { ( }

2:  { 2 }

55:  { ÷ }

22, 2:  { RCL 2 }

34:  { ) }

23:  { SIN }

45:  { ÷ }

2:  { 2 }

74:  { = }

11:  { √ }

55:  { × }

22, 0:  { RCL 0 }

45:  { ÷ }

61, 22:  { π }

11:  { √ }

74:  { = }

21, 4:  { STO 4 }

61, 26:  { RTN }



Example


Example 1:

Inputs:  θ  = 75° (stored in R1), Vs = 160 (stored in R0)

Results:

VLMA ≈ 100.70552

VLMS ≈ 130.27094


Example 2:

Inputs:  VLMA = 130 (stored in R3), Vs = 160 (stored in R0)

Results:

θ ≈ 51.31781°

VLMS ≈ 149.25534



Source


Davidson, James J.  "Triac Waveforms #1" and "Traic Waveforms #2" 65 Notes V3N10 December 1976.  pg. 38.  


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 and any authors of original programs and scripts.  


Sunday, December 11, 2022

HP 32SII: Random Number Utilities

HP 32SII:  Random Number Utilities



Note:  The following programs should work with the original HP 32S.   The checksums listed are for the HP 32SII only.  



HP 32SII Program:  Fill a Set of Registers with Increasing Integers


This program fills up the alpha registers with consecutive increasing integers.  Up to 25 slots are available, A- Y, with the lowest being stored in A.   Register Z is used to store the difference.  


The difference from both numbers should not be more than 24.  


F01  LBL F

F02  x<>y

F03  1

F04  -

F05 STO Z

F06 -

F07 STO i

I01  LBL I

I02  RCL i

I03  IP

I04  RCL+ Z

I05  STO(i)

I06  DSE i

I07  GTO I

I08  RTN


F:  10.5 bytes, 32SII checksum 9FB9

I:  12.0 bytes, 32SII checksum E189

Total:  22.5 bytes


Examples


18 to 27:   18 ENTER 27 XEQ F

Results:

A = 18, B = 19, C = 20, D = 21, E = 22, 

F = 23, G = 24, H = 25, I = 26, J = 27



HP 32SII Program:  Pick from Registers A through Y


Enter the number of registers to pick from into register Z.  For example, if you have registers A through J loaded, store 10 into register Z.


Note:  When used for indirect addressing, the absolute value of integer of register i is used.   This will allows us to save a few steps.


G01  RANDOM

G02  RCL× Z

G03  1

G04  +

G05  STO i

G06  RCL(i)

G07  RTN


G:  12.0 bytes, 32SII checksum FE18


Example:


Use the data from the last problem.  


10 STO Z, 

XEQ G:   22

XEQ G:   21

(results will vary)




Source for the next two programs:


Chamberlain, Gary.  "HP-29C Random Number Generators"  PPC Journal V6 N7 October 1979


HP 32SII Program:  Uniform Distribution 


This program picks random numbers between two parameters.


U01  LBL U

U02  STO C

U03  -

U04  STO D

W01  LBL W

W02  RANDOM

W03  RCL× D

W04  RCL+ C

W05  STOP

W06  GTO W


U:  6.0  bytes, 32SII checksum 8022

W: 9.0  bytes, 32SII checksum 88EE

Total:  15.0 bytes


Example:


Random numbers between -1 and 1:


XEQ U:  -0.74076 (press R/S for more random numbers)

0.28000

-0.80090

0.20653

0.50614



HP 32SII Program:  Gaussian Distribution of Random Numbers


Generate random numbers that fit on a normal distribution with mean M and deviation D.  Two random numbers are generated, press x<>y to see both results.


X01  LBL X

X02  INPUT M

X03  INPUT D

X04  RAD   (radians mode)

Y01  LBL Y

Y02  RANDOM 

Y03  2 

Y04  ×

Y05  π

Y06  ×

Y07  RANDOM

Y08  LN

Y09  -2

Y10  ×

Y11 SQRT

Y12  θ,r→y,x

Y13  RCL× D

Y14  RCL+ M

Y15  x<>y

Y16  RCL× D

Y17  RCL+ M

Y18  STOP

Y19  GTO Y


Example:


Mean = 3 

Deviation: 1.5


XEQ X

M?  3 R/S

D?  1.5 R/S


1.70434 x<>y 2.89313 R/S

2.22287 x<>y 2.50113 R/S

1.67644 x<>y 2.87034 ...

(results will vary)




Happy programming,


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.