Sunday, May 7, 2023

TI-84 Plus CE: Drawing a Balance Scale and an Updated High Low Game

TI-84 Plus CE:   Drawing a Balance Scale and an Updated High Low Game



Drawing a Scale



The program DSCALE draws a balance scale given two weights:  one placed on the left side (A) and one on the right side.  The length of the bar, which is measured from the center to one of the weights can be set by the user.   Assume that the length is equal on both sides.





The scale in this program is not meant to bend more than 45°.   The program will not draw the scale if the bend is greater than 45°.  


DSCALE was programmed with a TI-84 Plus CE, but can be programmed on a monochrome calculator with the color commands taken out.


The program repeats for different weights at the user's choice.  



TI-84 Plus CE Program:   DSCALE



Degree:Func:FnOff 

Disp "BALANCE SCALE"

Disp "LENGTH-CENTER?"

Prompt L

4→W

Lbl 1

ClrHome

Disp "LENGTH-CENTER:",L,""

Input "LEFT WEIGHT? ",A

Input "RIGHT WEIGHT? ",B

(B-A)/2→D

abs(tan^-1((B-A)/L))→θ

W*(B-A)/L→S

If θ>45:Then:Disp "CANNOT DRAW":Goto 2:End

­-W-1→Xmin:W+1→Xmax:1→Xscl

­-W-1→Ymin:W+1→Ymax:1→Yscl

AxesOff:LabelOff

ClrDraw

Line(0,W,0,-­W,ORANGE)

Line(-­.5,W,.5,W,BROWN)

Line(­-1,­-W,1,­-W,BROWN)

Line(­-.5,W,-­W,S,LTGRAY)

Line(.5,W,W,­-S,LTGRAY)

Line(­-W,S,W,­-S,BLACK)

Lbl 2

Pause 

Menu("AGAIN?","YES",1,"NO",0)

Lbl 0

Disp "THANK YOU"







Updating a Game



The program HILODS is the classic high-low guessing game, but instead of text, it draws a balance scale to indicate whether you are higher and lower from the target number.  You work with the left weight (A), with the goal of balancing with the right weight (B).  The right weight is set with a random integer from 10 to 99.  


The game has three difficulty levels:  easy (25 guesses), medium (15 guesses), and hard (10 guesses).



TI-84 Plus CE Program:   HILODS


Degree:Func:FnOff 

Disp "HIGH-LOW GAME"

AxesOff:LabelOff

100→L

randInt(10,99)→B

4→W

­-W-1→Xmin:W+1→Xmax:1→Xscl

­-W-1→Ymin:W+1→Ymax:1→Yscl

Menu("DIFFICULTY LEVEL","EASY",10,"MEDIUM",11,"HARD",12)

Lbl 10:25→C:Goto 20

Lbl 11:15→C:Goto 20

Lbl 12:10→C:Goto 20

Lbl 20

Disp toString(C)+" GUESSES"

Disp "BETWEEN 10 AND 99"

C→N


Lbl 1

ClrHome

Disp "GUESSES LEFT: "+toString(C)

Disp "{10,99}"

Input "GUESS? ",A

(B-A)/2→D

W*(B-A)/L→S

ClrDraw

Line(0,W,0,-­W,ORANGE)

Line(-­.5,W,.5,W,BROWN)

Line(­-1,­-W,1,­-W,BROWN)

Line(­-.5,W,-­W,S,LTGRAY)

Line(.5,W,W,­-S,LTGRAY)

Line(­-W,S,W,­-S,BLACK)

Pause 

C-1→C

If A=B:Goto 9

If C=0:Goto 8

Goto 1


Lbl 8

ClrHome

Disp "THE NUMBER IS "+toString(B)

Disp toString(abs(A-B))+" AWAY"

Disp "BETTER LUCK NEXT TIME"

Stop



Lbl 9

ClrHome

Disp "THE NUMBER IS "+toString(A)

Disp "YOU WIN!"

Disp "NUMBER OF GUESSES: "+toString(N-C)

Stop







Download both programs here (as a zip file):  https://drive.google.com/file/d/1hJwyqSZJ-aCQ36Wh2cCfMVy6BpAzmmPZ/view?usp=share_link



Enjoy,


Eddie 


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

Wheel Calculator: Merchant's Graphic Profit Finder

Wheel Calculator:  Merchant's Graphic Profit Finder



Quick Facts


Model:  Merchant's Graphic Profit Finder

Company:  G.C. Company

Years:  1954

Type:  Business and Merchandise






I purchased this wheel calculator at a swap meet in Long Beach, California in February 2023.



What is the Selling Price?



The Graphic Profit Finder is a paper slide rule calculator.   A stationary wheel sits on top of a sliding wheel.   


Red Side:  Calculating selling price based on cost and mark-up


Black Side:  Calculate selling price based on cost and margin


The stationary wheel has markup percentages and margin percentages.  


Mark-Up:  Use the red arrow to set the cost.  Set the arrow to the profit mark-up, which will point to the selling price.   


Margin:  Use the black arrow to set the cost.  Set the arrow to the margin, which will point to the selling price.


Each side has two additional arrows attached to the stationary wheel:  Cost Per Dozen and Cost Per Gross.



Formulas Used



Let x = Cost


Cost Per Dozen = 1.2 * x


Cost Per Gross = 1.44 * x


Selling Price on Mark-Up = x * (1 + mark-up% ÷ 100)


Selling Price on Margin = x ÷ (1 - margin% ÷ 100)




More sliding and wheel calculators to possibly come,


Eddie 


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


Wednesday, May 3, 2023

Announcement: HP 15C Collector's Edition

 Announcement:  HP 15C Collector's Edition



The HP 15C Returns



Hewlett Packard and Moravia is bringing back the HP 15C Calculator with the HP 15C Collector's Edition, which is set to be delivered starting the summer of 2023.  


The HP 15C is a RPN (Reverse Polish Notation) programming scientific calculator, first released in in 1982 and has the following features:  


*  Matrices:  Store up to 5 matrices.  Operations include determinant, inverse, norm, and transpose.  

*  Complex Numbers:  The set of complex numbers includes powers, logarithms, and trigonometry.

*  Numerical integration

*  Solve:  Finding the roots of functions

*  Standard Scientific functions:  polar/rectangular conversions, trigonometry, powers, roots, logarithms, linear regression, fraction and integer parts, hyperbolic functions

*  Programming:  Keystroke with labels, comparison tests


The HP 15C Collector's Edition has the following improvements from the original and Limited Edition of the HP 15C:


*  There are now 99 memory registers, up from 67

*  There is now a memory capacity of 672 steps, up from 448

*  The new processor promises a faster speed 

*  The Collector's Edition comes with a printed manual, which can be downloaded from Calculator Store's website here:  https://www.thecalculatorstore.com/epages/eb9376.sf/en_US/?ObjectPath=/Shops/eb9376/Products/%22HP-15c%20%23INT%22


From browsing the PDF file of the manual, the manual looks nice and it's detailed. 


For details, credit, and discussion, click on Klass' original post is on the Museum of HP Calculators (MoHPC) here:  https://www.hpmuseum.org/forum/thread-19886.html



Pre-Orders


The HP 15C Collector's Edition is set to be delivered starting at the end of June 2023.   At this moment, Moravia Consulting, a licensee for HP Calculators, has two stores offering pre-sales:


Eduwinkel:  (Netherlands) (Price:  129,95 Euros as of 5/3/2023*)


https://www.eduwinkel.nl/hp-15c-collectors-edition-calculator.html


The Calculator Store:  (Spain) (Price: 129,99 Euros as of 5/3/2023*)


English:  

https://www.thecalculatorstore.com/epages/eb9376.sf/en_US/?ObjectPath=Categories


Spanish:  

https://www.thecalculatorstore.com/epages/eb9376.sf/es_ES/?ObjectPath=Categories


* Prices do not include delivery charges but does include value added tax (VAT).  Depending where the customer is from VAT may be subtracted from the price.  


Source:


Kuperus, Klaas.   "NEW: HP 15C Collectors Edition"  MoHPC (Museum of HP Calculators)   May 2, 2023.  https://www.hpmuseum.org/forum/thread-19886.html



I have pre-ordered a HP 15C Collector's Edition and can't wait to work with it.  



Disclaimer:  No compensation has been received for this post.  



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

Review: Casio DE-12E-WE Ergonomic Calculator

Review: Casio DE-12E-WE Ergonomic Calculator



3° Tilt


Quick Facts


Model:  DE-12E-WE

Company:  Casio

Years:  Internationally: 2022 - present, United States: March 2023 - present

Type:  Desktop

Power:  Solar with CR 2025 backup battery

Display:  12 digits

Original Price:  $30.99 US Dollars

Memory Registers:  1

Operating System: Chain


Casio's promotional video (United States):  

https://www.youtube.com/watch?v=-6NlPVBSK7U


Casio released a series of ergonomic desktop calculators:


DE-12E-WE:  $30.99 retail, 12 digits, width of 140 mm (about 5.512 inches)


JE-12E-WE:  $27.99 retail, 12 digits, width of 111 mm (about 4.331 inches)


The features between both calculators are virtually the same, except (1) the arrangement of the keys are different, and (2)  the DE-12E-WE has two extra settings, which we will discuss next.


Features


Decimal Setting Switch:  Add Mode, 0, 1, 2, 3, 4, 5 (DE-12E-WE only)


Rounding Setting Switch:  F (Float), CUT (truncate), 5/4 (regular rounding), UP (round everything up, DE-12E-WE only)


[M/EX] Key:  Memory and Exchange mode toggle.  The mode affects four keys, which text of these keys are in blue


Memory Mode (no indicator):


[ M+ ]:   add the number in the display to memory M

[ M- ]:  subtract the number in the display from M

[ MR ]:  recall the value stored in M

[ MC ]:  clear the value stored in M (set M to zero) 


Exchange Mode (EXCH indicator):


[ M+ ] (C1):   currency 1 - base currency;  always set to 1

[ M- ] (C2):  currency 2

[ MR ] (C3):  currency 3

[ MC ] (C4):  currency 4


In exchange mode, currency 1 is the base currency is always set to 1, which the other three currencies are set to the exchange rate relative to C1.  Each of the other three currencies can be set one at time.  Start by with holding the [ AC ] and the [ % ] keys simultaneously.  Keep holding the keys until the display refreshes and a SET indicator appears.   Choose a currency (C2, C3, or C4), enter a rate, then press the [ % ] key to set the currency rate.


We also have the tax functions, which text are in green.


[ TAX- ]:  subtract the tax rate from the number in the display

[ TAX+ ]:  add the tax rate to the number in the display.  Use this key to add sales tax to a purchase.


The tax keys are available in either Memory or Exchange mode.   To set the tax rate:  hold the [ AC ] and [ % ] keys until the display refreshes and a SET indicator appears.   Then press the [ TAX+ ] key, enter the rate, then press the [ % ] key.  


The DE-12E has the square root function, and I am big on the square root function on the desktop calculators.   


The 3° Tilt


Casio markets the 3° tilt to promote ergonomic typing on the desktop calculator.   The tilt on both the DE-12E-WE and JE-12E-WE tilt downwards from the left, which is designed for right-handed users.   The keys themselves are curved to facilitate easier finger movement.  


The titled keyboard is comfortable to use, and I did notice a slight increase in typing speed.   The keys are big, which allows me to type without the worry of pressing a neighboring key or two keys simultaneously by accident.  


I also tried the DE-12E-WE with my left hand, at first the keyboard was intense, but I did feel comfortable.  Being right-hand dominant, I am faster with the right-hand.  I am thinking if this series is a success, perhaps there will be a left-handed version of the calculator.  


Final Thoughts


I like the 3° tilt and the clean, professional look of the 12E-WE.  I like how the keys are designed for fast typing.  


I can see the currency exchange mode used for conversions of a common measure, such as feet-meters-miles-kilometers or liters-quarts-cups-gallons.  


Because I tend to use the memory keys in practice, I wish the those keys on the DE-12E-WE were the same size as the number keys, but it does not take away from the comfort and use of this calculator.  


With ergonomics being promoted in the office and financial settings, I expect this series to sell well, which will lead to more ergonomic-friendly calculators in the future.  The 12E-WE is worth checking out if you want a desktop calculator with a lot of features, ergonomics is important, or you are type fast on a desktop calculator.



Eddie 


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

TI-74 and Python (Casio fx-9750GIII): A Treasure of Programs

TI-74 and Python (Casio fx-9750GIII):  A Treasure of Programs



Today's programs illustrates an approach from both the BASIC and Python programming languages. 



Skiing Stars



This program paves a ski path by randomly plotting a path.  A slight difference:  the TI-74 version goes indefinitely until the user presses a key and uses one line.  The Python version goes 50 steps and the result must be scrolled up after the program completes.  I optimized the program to fit each screen.


TI-74 BASICALC Program


100 REM "Skiing Stars"

102 RANDOMIZE RND

104 P=14

106 PRINT "Press any key to stop.": PAUSE .25

120 CALL KEY(K,S)

122 IF S<>0 THEN 140

124 R=RND

126 IF R<.4 AND P>0 THEN LET P=P-1

128 IF R>.4 AND P<26 THEN LET P=P+1

130 DISPLAY ERASE ALL AT(P),"*****": PAUSE .15

132 GOTO 120

140 PRINT RPT$("*",31): PAUSE .25

142 STOP


Python (Casio fx-9750GIII):  skistar.py


# skiing stars

from random import *

rnd=int(10000000*random())

seed(rnd)

p=8

for i in range(50):

  r=random()

  if r<.4 and p>0:

    p-=1

  if r>.6 and p<14:

    p+=1

  print(" "*p+"*****")

print("scroll up")

    


Phase Speed of a Wave


Equation:

c = √( g  * λ / (2 * π) * tanh(2 * π * d / λ))


c = phase speed

λ = wavelength 

d = water depth

g = Earth's gravity = 9.80665 m/s = 32.174049 ft/s


Source:


"Wind Wave"  Wikipedia.  Last Edited January 28, 2023.  Accessed February 14, 2023.  https://en.wikipedia.org/wiki/Wind_wave#:~:text=In%20fluid%20dynamics%2C%20a%20wind,is%20known%20as%20the%20fetch.


TI-74 BASICALC Program:  


400 REM Phase Speed

402 PRINT "U.S. units used": PAUSE .25

404 T=2*PI: G=32.174049

406 INPUT "Depth (ft)? "; D

408 INPUT "Wavelength (ft)? "; L

410 C=SQR(G*L/T*TANH(T*D/L))

412 PRINT "Phase Speed (ft/s)=": PAUSE .25

414 PRINT C: PAUSE

416 STOP


Python (Casio fx-9750GIII): phspeed.py  


# phase speed

from math import *

print("U.S  units used")

t=2*pi

g=32.174049

print("Depth (ft)?")

d=float(input())

print("Wavelength?")

l=float(input())

c=sqrt(g*l/t*tanh(t*d/l))

print("Phase speed (ft/s)=")

print(c)


Example:


Depth:  2.26 ft

Wavelength:  18.9 ft


Result:  

Phase Speed:  7.845145563 ft/s



Horsepower Generated by a Wave


p = 0.0329 * h^2 * √( l * (1 - 4.935 * (h^2/l^2))


h = wave height (ft)

l = length of a wave (ft)

p = horsepower


Source: 


Rosenstein, Morton.  Strategies for Scientific Calculating Casio.  January 1982.


TI-74 BASICALC Program:


500 REM horsepower of a wave

502 PRINT "U.S. units used": PAUSE .25

504 INPUT "Wave height (ft)? ";H

506 INPUT "Length of wave (ft)? "; L

508 P=.0329*H^2*SQR(L*(1-4.935*(H^2/L^2)))

510 PRINT "Horsepower = ": PAUSE .25

512 PRINT P: PAUSE

514 STOP


Python (Casio fx-9750GIII):  hpwave.py


# horsepower of a wave

from math import *

print("U.S. units used")

print("Wave height (ft)?")

h=float(input())

print("Length of a wave?")

l=float(input())

p=.0329*h**2*sqrt(l*(1-4.935*(h**2/l**2)))

print("horsepower = ")

print(p)


Example:


Wave height:  1.26 ft

Length of wave: 24.04 ft


Result:

Horsepower = .2543549811 hp



Until next time,


Eddie



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

TI-74 and Python (Casio fx-9750GIII): Probability

TI-74 and Python (Casio fx-9750GIII):  Probability



Today's program illustrates an approach from both the BASIC and Python programming languages. 


The program offers the user to calculate common probability problems:



1)  n!:  factorial of an integer

2)  nCr:  combinations without replacement

3)  nPr:  permutations

4)  nHr:  combinations with replacement

5) bday:  probability that n people do not share a category in common from a size of categories (i.e. birthday problem:  How many people in a room don't share a birthday?)



TI-74 BASICALC Program


200 REM probability

202 INPUT "1)n! 2)nCr 3)nPr 4)nHr 5)bday "; I

204 IF I<5 THEN INPUT "n? "; N

206 IF I>1 AND I<5 THEN INPUT "r? "; R

208 ON I GOTO 220,240,260,280,300


220 X=N

222 GOSUB 320

224 PRINT "n! = "; F: PAUSE

226 GOTO 340


240 Z=1: FOR K=(N-R+1) TO N: Z=Z*K: NEXT K

242 X=R: GOSUB 320

244 Z=Z/F

246 PRINT "nCr = "; Z: PAUSE

248 GOTO 340


260 Z=1: FOR K=(N-R+1) TO N: Z=Z*K: NEXT K

262 PRINT "nPr = "; Z: PAUSE

264 GOTO 340


280 Z=1: FOR K=N TO (N+R-1): Z=Z*K: NEXT K

282 X=R: GOSUB 320: Z=Z/F

284 PRINT "nHr = "; Z: PAUSE

286 GOTO 340


300 INPUT "# categories? "; R

302 INPUT "Sample size? "; N

304 Z=1: FOR K=1 TO (N-1): Z=Z*(1-K/R): NEXT K

306 PRINT "P(all unique) = "; Z: PAUSE

308 GOTO 340


320 F=1

322 FOR K=1 TO X: F=F*K: NEXT K

324 RETURN


340 INPUT "Again? 0:No, 1:Yes "; A

342 IF A=1 THEN 202

344 IF A=0 THEN STOP

346 GOTO 340



Python Program:  prob.py 


Program completed with the Casio fx-9750GIII.


# probability

from math import *


def fact(x):

  f=1

  for k in range(1,x+1):

    f*=k    

  return f



fc=1


while fc!=0:

  print("1)n! 2)nCr")

  print("3)nPr 4)nHr")

  print("5)bday")

  ch=int(input())

  if ch<5:

    n=int(input("n? "))

  if ch>1 and ch<5:

    r=int(input("r? "))

  if ch==1:

    f=fact(n)

    print("n! = "+str(f))

  if ch==2:

    f=fact(n)/(fact(n-r)*fact(r))

    print("nCr = "+str(f))

  if ch==3:

    f=fact(n)/fact(n-r)

    print("nPr = "+str(f))

  if ch==4:

    f=fact(n+r-1)/(fact(r)*fact(n-1))

    print("nHr = "+str(f))

  if ch==5:

    r=int(input("# categories? "))

    n=int(input("Sample size? "))

    f=1

    for k in range(n):

      f*=1-k/r

    print("p(all unique)=")

    print(str(f))

  print("Again? 0)no 1)yes")

  fc=int(input())    


Examples


1) n!  

13! = 6227020800


2) nCr

n = 13, r = 6; result:  1716


3) nPr

n = 13, r = 6; result:  1235520


4) nHr

n = 13, r = 6; result:  18564


5) bday

# categories: 13

Sample size: 6

Result:  P(all unique) = .2559703523



Wishing you an excellent day.   More BASIC and Python programming coming your way tomorrow!


Eddie


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

HP Prime: Firmware 14730

HP Prime:   Firmware 14730



Windows Update - Firmware 14730





There is a new update for the HP Prime, the Connectivity Kit, and the HP Virtual Calculator:  Firmware 14730.


Highlights of the firmware 14730:


*  Polynomial inequalities can be reliably solved in CAS mode.

*  The Chi-Square Goodness of Test automatically updates the degrees of freedom.

*  Intersection of functions in the Function App has an improved algorithm.

*  The equals character (=) is added to the soft keys in CAS mode.

*  Memory leaks and crashes are fixed.


For a detailed list, check the detailed list provided by Klaas Kuperus, Product Manager for HP for MORAVIA Consulting on the MoHPC (Museum of HP Calculators) page:


https://www.hpmuseum.org/forum/thread-19845.html


Download the new package here:


https://hpcalcs.com/download/


The file is the HP Connectivity Kit (32 or 64 bit) 2.1.14730 (2023 04 13) for Windows.  Update for Macintosh to come soon.  The file contains:


*  The updated Connectivity Kit.

*  The updated firmware, which will be downloaded through the kit once the calculator is plugged into the PC.

*  The updated virtual calculator, which will be upgraded once the file is run for the first time.


Credit to HP and MORAVIA Consulting.  


Eddie 


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

HP Prime: Edge Diffraction Parametric Plot

HP Prime:  Edge Diffraction Parametric Plot



Introduction


The program EDGEDIFFRAC plots the complex amplitude of edge diffraction.  The equation is:


φp = φ0 / √2 * ( CS(t) + 1/2 * (1 + i) )


where:

φp = complex amplitude 

φ0 = unobstructed amplitude, can be a complex number

CS(t) = Cornu Spiral, defined as CS(t) = C(t) + i * S(t)


Cosine Fresnel Integral

C(t) = ∫( cos (π * s^2 / 2) ds for s = 0 to t)


Sine Fresnel Integral

S(t) = ∫( sin (π * s^2 / 2) ds for s = 0 to t)


i = √-1




HP Prime Program:   EDGEDIFFRAC


Notes:


1.  This program runs in the Parametric app.


2.  To allow for the program to be run from any app, the STARTAPP command is placed in the beginning of the program.


3.  To allow editing in any app, the Parametric. prefix is added to the variables Tmin, Tmax, and Tstep.   


4.  The QUOTE command is used to store functions to the graphing variables X1 and Y1.  


5.  The program runs faster in the emulator than the hardware calculator.  


6.  x1(t) is the real part of φp, and y1(t) is the imaginary part of φp. 


Code:


EXPORT EDGEDIFFRAC()

BEGIN

// Edge Diffraction 

// 2023-02-19 EWS

STARTAPP("Parametric");


// set radians mode

HAngle:=0;

// local variables

LOCAL ch,l,lc,pc;

LOCAL y,λ,z,w,φp;

 

// plot application

INPUT(Z0,"Unobstructed Amplitude",

"φ0:");


CHOOSE(l,"Change Color","Red","Indigo",

"Blue","Orange","Green");

lc:={#FF0000h,#400080h,#FFh,

#FFA500h,#C000h};

X1(COLOR):=lc[l];

Parametric.Tmin:=-5;

Parametric.Tmax:=5;

Parametric.Tstep:=0.25;


A:=RE(Z0);

B:=IM(Z0);

X1:=QUOTE(A/√2*(∫(COS(π*S^2/2),S,0,T)+1/2)

-B/√2*(∫(SIN(π*S^2/2),S,0,T)+1/2));

Y1:=QUOTE(A/√2*(∫(SIN(π*S^2/2),S,0,T)+1/2)

+B/√2*(∫(COS(π*S^2/2),S,0,T)+1/2));

CHECK(1);

STARTVIEW(10);


END;



Examples



Example 1:   φ0 =  2 + 6i






Example 2:  φ0 = 2.29






Source


Woan, Graham.  The Cambridge Handbook of Physics Formulas.  Cambridge University Press:  Cambridge, New York.   2003



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

Python: Drawing Regular Polygons (TI-84 CE Python, Numworks)

Python:  Drawing Regular Polygons (TI-84 CE Python, Numworks)



Introduction



The following scripts uses the Turtle module to draw regular polygons.   It turns out that every set of commands is slightly different in every calculator.  


For instance, there are no color names in the TI-84 Plus CE Python but they are present in Numworks.  


Also, the turtle module needs a t. (t-point) suffix of all turtle commands for the TI-84 Plus CE Python.  The Numworks turtle module does not need a suffix. 



TI-84 Plus CE Python:  dpolygon.py


from turtle import *

t=Turtle()


# initialization

s=60

n=int(input("# of sides? "))


# angle

a=180*(n-2)/n


# set turtle for TI-84

# color

k=-1

while k<0  or  k>4:

  print("Choose Color")

  print("0. blue")

  print("1. red")

  print("2. green")

  print("3. orange")

  print("4. indigo")

  k=int(input())

if k==0:

  t.pencolor(0,0,255)

if k==1:

  t.pencolor(255,0,0)

if k==2:

  t.pencolor(0,192,0)

if k==3:

  t.pencolor(255,165,0)

if k==4:

  t.pencolor(75,0,130)


t.clear()


# setup

t.penup()

t.left(180)

t.forward(60)

t.left(90)

t.forward(60)

t.left(90)


# draw the polygon

t.pendown()

for i in range(n):

  if n>6:

    t.forward(s/2)

  else:

    t.forward(s)

  t.left(180-a)

t.done()




Numworks Python:  dpythonnw.py


from math import *

from turtle import *


# initialization

s=60

n=int(input("# of sides? "))


# angle

a=180*(n-2)/n


# set color numworks

k=-1

l=['blue','red','green','orange','purple']

while k<0 or k>4:

  print("Choose Color")

  print("0. blue")

  print("1. red")

  print("2. green")

  print("3. orange")

  print("4. purple")

  k=int(input())

col=l[k]


# setup

penup()

left(180)

forward(60)

left(90)

forward(60)

left(90)


# draw the polygon

pendown()

color(col)

for i in range(n):

  if n>6:

    forward(s/2)

  else:

    forward(s)

  left(180-a)




Until next time,


Eddie 


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

Python and Casio fx-4000P: Transmission and Deviation Angles - Prism

Python and Casio fx-4000P:   Transmission and Deviation Angles - Prism




Celebrating 12 Years in the Blogopshere!   Thank you to my readers, subscribers, and everyone who has stopped by during the years!  




Introduction


Today's program calculates the transmission and deviation angles passing through a prism.   The refractive index of the prism is determined by the material it is made of.   





Formulas Used for the transmission and deviation angles, respectively:


θt = arcsin( α * √(n^2 - sin^2 θi) - sin θi * cos α)


δ = θi + θt - α


The Python program calculates for prisms made of acrylic, glass, fluorite, and plastic.  



Python Script:  prism.py


Program Notes:


1.  The angle mode in Python is always radian angle mode. Conversions between degrees and radians are necessary on this code.


2.  This code was programmed with a Casio fx-9750GIII in the Python app.   I could have used the degrees and radians functions, however, they were not present in the calculator's catalog.  


3.  I used a While loop and initialized the choice variable k as -1 to prevent the user from choosing anything from picking outside the range 0-3.  This simulates the Menu command in Casio graphing calculator programming.


4. The refractive indices are average and approximate.  


5. To make everything fit on the screen, the new line escape character, \n, is used.  


Code:


from math import *

# radians mode

print("Enter in Degrees")

i=float(input("Incidence Angle? \n"))

a=float(input("Top Angle? \n"))


# convert to radians

ir=i*pi/180

ar=a*pi/180


# choice of material

# refractive index

ls=[1.4905,1.52,1.433,1.58]

k=-1

while k<0 or k>3:

  print("Select Material")

  print("0. Acrylic")

  print("1. Glass")

  print("2. Fluorite")

  print("3. Plastic")

  k=int(input())

n=ls[k]


# calculation

t=asin(sin(ar)*sqrt(n**2-sin(ir)**2)-sin(ir)*cos(ar))

d=ir+t-ar


# convert to degrees

td=t*180/pi

dd=d*180/pi


# results

print("Results are in Degrees")

print("Transmission Angle: \n"+str(td))

print("Deviation: \n"+str(dd))



Casio fx-4000P Program:  Prism


Notes:


1.  Variables used:

I = incidence angle

A = top angle of the prism

N = refractive index, must be entered manually


2.  Outputs:

Transmission Angle (T)

Deviation Angle (D)


Code:

(59 steps)


Deg :

"I": ?→ I:

"A": ?→A:

"N": ?→N:

sin⁻¹ ( sin A × √( N² - (sin I)²) - sin I × cos A) → T ◢

I + T - A → D



Examples


I = incidence angle

A = top angle of the prism

T = Transmission Angle

D = Deviation Angle



1.  I = 50°, A = 60°,  Glass (1.52)


T ≈  48.932708276°

D ≈ 38.932708276°


2.  I = 10°, A = 45°, Plastic (1.58)


T ≈ 80.99437617°

D ≈ 45.99437617°


3.  I = 33°, A = 25°,  Acrylic (1.4905)


T ≈ 5.32137979°

I ≈ 13.32137979°


4.  I = 17°, A = 40°, Fluorite (1.433)


T ≈ 42.66957975°

I ≈ 19.66957975°



Source


Woan, Graham.  The Cambridge Handbook of Physics Formulas  Cambridge University Press.  Cambridge, New York.  2003 edition



Here is to many more years, 


Eddie 


All original content copyright, © 2011-2023.  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 32SII: Volume of a Square Frustum (Three Approaches in RPN)

HP 32SII: Volume of a Square Frustum (Three Approaches in RPN ) The volume of a square frustum is: v = height ÷ ...