Saturday, December 30, 2023

HP 15C (CE) and TI-84 Plus CE Triangle, Square, and Sawtooth Waves

HP 15C (CE) and TI-84 Plus CE Triangle, Square, and Sawtooth Waves


Almost New Years...  thank you for all your support in 2023!


The Periodic Waves Featured


Let:


A = amplitude of the wave

P = period of the wave


Triangle:





TW(A,P,x) = (2 × a ÷ π) × arcsin(sin (2 × π × x ÷ p))

Domain:  [ -A, A ]


Square:





SW(A,P,x) = a × sgn(sin(2 × π × x ÷ p)) = a × (-1)^floor(2 × x ÷ P)

Domain:  [ -A, A ]


Sawtooth:





SAW(A,P,x) = A × frac(x ÷ P) 

Domain:  [ -A, A ]



The programs presented only allow for non-negative arguments (x>0).  The TI-84 Plus CE program PRDWAVES offer calculations and graphs.



HP 15C Program Code


LBL A:  Triangle Wave

LBL B:  Square Wave

LBL C:  Sawtooth Wave



Registers Used:

R1 = amplitude (A)

R2 = period (P)


Load A and P in R1 and R2 and then load x  in the x stack.   X must be non-negative or an error occurs (Error 0).


Step |  Key Code |  Key


Triangle Wave


001 | 42, 21, 11 |  LBL A

002 | 43, _5, _8 |  CF 8

003 | 43, 30, _2 |  TEST 2 (x<0?)

004 | __, __, 11 |  √x

005 | __, __, _2 |  2

006 | __, __, 20 |  ×

007 | __, 43, 26 |  π

008 | __, __, 20 |  ×

009 | 45, 10, _2 |  RCL÷ 2

010 | __, __, 23 |  SIN

011 | __, 43, 23 |  SIN^-1

012 | __, __, _2 |  2

013 | __, __, 20 |  ×

014 | 45, 10, _1 | RCL÷ 1

015 | __, 43, 26 |  π

016 | __, __, 10 |  ÷

017 | __, 43, 32 | RTN


Square Wave


018 | 42, 21, 12 |  LBL B

019 | 43, _5, _8 |  CF 8

020 | 43, 30, _2 |  TEST 2 (x<0?)

021 | __, __, 11 |  √x

022 | __, __, _2 |  2

023 | __, __, 20 |  ×

024 | 45, 10, _2 |  RCL÷ 2

025 | __, 43, 44 |  INT

026 | __, __, _1 |  1

027 | __, __, 16 |  CHS

028 | __, __, 34 |  x<>y

029 | __, __, 14 | y^x

030 | 45, 20, _1 | RCL× 1

031 | __, 43, 32 | RTN


Sawtooth Wave


032 | 42, 21, 13 | LBL C

033 | 43, _5, _8 |  CF 8

034 | 43, 30, _2 |  TEST 2 (x<0?)

035 | __, __, 11 |  √x

036 | 45, 10, _2 |  RCL÷ 2

037 | __, 42, 44 |  FRAC

038 | 45, 20, _1 | RCL× 1  

039 | __, 43, 32 | RTN 



Technique:  If you require entries to be nonegative, you can use the sequence:


... commands. ..

CF 8  (turns complex mode off)

TEST 2  (x<0?)

√x   (causes an error, specifically Error 0; skipped if x is non-negative)

... commands ... 



TI-84 Plus CE Program PRDWAVES


(spaces added for clarity)


Func

Radian

FnOff

"2023-11-28 EWS"

1→A

1→P

ClrHome


Lbl 0

"AMP = "+toString(A)+","+"PRD = "+toString(P)→Str1

Menu(Str1,"ENTER PARAMETERS",1,"TRIANGLE WAVE",2,"SQUARE WAVE",3,

"SAWTOOTH WAVE",4,"EXIT",E)


Lbl 1

Input "AMPLITUDE? ",A

Input "PERIOD? ",P

Goto 0


Lbl 2

"2*A/π*sin^-1(sin(2*π*X/P))"→Y1

Goto C


Lbl 3

"A*(-1)^iPart(2*X/P)"→Y1

Goto C


Lbl 4

"A*fPart(X/P)"→Y1

Goto C


Lbl C

ClrHome

Menu("CALCULATE","F(X)",F,"GRAPH",G,"NEW PROBLEM",0,"EXIT",E)


Lbl F

Equ>String(Y1,Str2)

Disp Str2

Input "X≥0,X? ",X

If X<0

Then

Disp "X CAN NOT BE NEGATIVE"

Pause

ClrHome

Goto F

end

Y1(X)→Y

Disp "Y = ", Y

Pause 

Goto C


Lbl G

0→Xmin

10→Xmax

ZoomFit

DispGraph

Stop


Lbl E

Disp "BYE."

Stop


Notes:


Y1:  [vars], Y-VARS, 1: Function..., 1: Y1  (captial Y with subscript 1)


Download PRDWAVES.8xp here


Examples


Let P = 2, A = 1


X = 1

Triangle:  0.0000

Square:  -1.0000

Sawtooth:  0.5000


X = 2.5

Triangle: 1.0000

Square:  1.0000

Sawtooth:  0.2500


X = 4.8 

Triangle:  0.4000

Square:  1.0000

Sawtooth:  0.4000




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. 


Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation

  Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation The HP 16C’s #B Function The #B function is the HP 16C’s number of...