Post Reply 
(71B) Sign "Graph" of Trig Functions
12-06-2020, 03:52 PM
Post: #1
(71B) Sign "Graph" of Trig Functions
http://edspi31415.blogspot.com/2020/12/h...tions.html





Introduction

The program SGNTRIG builds a 22 character binary string that depends on the function:

g(x) =
1 if sgn(t(x/c)) > 1
0 if sgn(t(x/c)) ≤ 0

where:

c is a scaling factor,

sgn(x) is the sign function, and

t(x) represents one of three trigonometric functions, sin(x), cos(x), or tan(x). Angles are assumed to be radians.

If we set to scale to c = 1, then g(x) takes the integer values from 1 to 22.

The HP 71B builds the result to the string S$. This is an aid to visualize at least some of the graph. When the bit is 1, the graph is above the x-axis, otherwise, the graph is either on or below the x-axis. The program presented can be expanded or modified to explore other functions.

The resulting string is a "psuedo-graph".

Below is a graphical representation of g(x) (an HP Prime is used to graph g(x)).

[HP Prime of g(x)]

HP 71B Program SGNTRIG
Size: 270 bytes
Code:

100 DESTROY S,I,N,E,C
105 S$=""
110 RADIANS
115 INPUT 'SCALE? ';C
120 DISP "S:SIN C:COS T:TAN"
125 E$=KEY$
130 IF E$="S" OR E$="C" OR E$="T" THEN 200 ELSE 120

200 FOR I=1 TO 22
205 IF E$="S" THEN N=SGN(SIN(I/C))
210 IF E$="C" THEN N=SGN(COS(I/C))
215 IF E$="T" THEN N=SGN(TAN(I/C))
220 IF N=1 THEN N=1 ELSE N=0
225 S$=S$&STR$(N)
230 DISP S$ @ BEEP 589,0.1 @ WAIT 0.2
235 NEXT I
240 DISP S$ @ BEEP 661,2

Notes:

Line 105: creates a blank string, which is allowed on the HP 71B

Line 125: The KEY$ function calls for a key input. S for sine, C for cosine, and T for tangent.

Lines 205 to 215: determine which trigonometric function to use

Line 220: Sets the character to 0 if the sign function returns 0 or -1

Line 225: &, the ampersand symbol concatenates two strings

Lines 230 and 240, respectively: 589 Hz is middle D, 661 Hz is middle E
Visit this user's website Find all posts by this user
Quote this message in a reply
01-11-2021, 02:29 PM (This post was last modified: 01-12-2021 06:56 AM by C.Ret.)
Post: #2
RE: (71B) Sign "Graph" of Trig Functions
Hello !

It really surprise me, why using binary text representation, whereas the HP-71B is a really perfect Graphic Calculator ?!


I liberally simplify your code using built-in instructions only. The result is a much better field of curve explorations and freedom. No more limited to sin cos tan or sgn function’s now.

Code:

10 DIM G$[133] @ RADIANS
12 INPUT “Absc. Rng “,’-PI,+PI’;X1,X2 @ S1=(X2-X1)/132
14 INPUT “Ordn. Hght “,’ -1,+1 ‘;Y1,Y2 @ S2=7/(Y2-Y1)
16 INPUT “Fnct. F(X)=”, ’SIN(X)’;F$
20 FOR I=0 TO 132 @ X=X1+I*S1 @ J=(Y2-VAL(F$))*S2 @ B=2^FLOOR(J+.4995)
22 G$[I]=CHR$(B) @ GDISP G$ @ NEXT I @ PAUSE @ GOTO 12

Fill free to continue testing any SGN(SIN(X)) as well !

Enjoy it !

Images Sharing:
https://drive.google.com/file/d/1pDTHSA6...sp=sharing
https://drive.google.com/file/d/1pGSwbJm...sp=sharing
Find all posts by this user
Quote this message in a reply
01-12-2021, 03:57 AM
Post: #3
RE: (71B) Sign "Graph" of Trig Functions
Incredible! Thank you for sharing!
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)