Hidden WordScanner
Private scans · No account required

DuckieDai Trig 6 Graphs

Graph any of the six trig functions in the form y = A*f(Bx - C) + D from one menu: amplitude or stretch, period, phase shift, midline, key points, and asymptotes, with a drawing on the calculator.

trigonometry · MIT License

Overview

Graph any of the six trig functions in the form y = A*f(Bx - C) + D from one menu: amplitude or stretch, period, phase shift, midline, key points, and asymptotes, with a drawing on the calculator.

  • Owner-tested on a TI calculator
  • Version 1.0.0
  • 3134 bytes
  • Uses math, ti_plotlib

Before you run it

  • TI-84 Plus CE Python · No calculator OS or Python App version has been verified.
  • TI Connect CE .py transfer to the Python App; the owner's transfer details were not recorded
  • The function is y = A*f(Bx - C) + D for f = sin, cos, tan, csc, sec, or cot, with B not 0.
  • A, B, C, and D may be decimals, fractions such as 1/2, or multiples of pi such as pi/3 or -2pi.
  • Values are limited to -1,000,000 to 1,000,000; inf and nan are asked for again.

Try the DuckieDai calculator screen

Follow the program's prompts and result flow before downloading.

JavaScript is required for the optional browser simulation. Source viewing and downloading remain available without it.

Simulation boundary: This preview uses a reviewed browser adapter. It does not execute the downloaded Python and does not prove TI-Python or calculator compatibility.

Learn the math

How to graph all six trig functions with transformations

The idea

All six trig functions take the same four numbers in y = A*f(Bx - C) + D. A stretches the graph and flips it when negative, B changes the period, C/B slides it left or right, and D moves the midline. What changes from one function to the next is the period and where the key points and asymptotes fall.

Sine and cosine are waves with an amplitude. Cosecant and secant are 1 over sine and cosine, U-shaped branches with asymptotes where the wave crosses 0. Tangent and cotangent repeat every pi instead of every 2pi and climb from one asymptote to the next.

The formula

period = 2pi / |B| for sin, cos, csc, sec

period = pi / |B| for tan and cot

phase shift = C / B (right if positive, left if negative)

amplitude = |A| (sin and cos only); midline: y = D

A
the amplitude for sin and cos, or the stretch for the others; a negative A reflects the graph over the x-axis
B
sets the period; a negative B reflects it over the y-axis
C
together with B, the phase shift C/B
D
the midline

Using the program

Worked example

Graph y = 2sec(x - pi/2). Choose 5, then type 2 for A, 1 for B, pi/2 for C, and 0 for D.

stretch = 2, period = 2pi, phase shift = pi/2 right, midline y = 0

The program shows No amplitude, Stretch: 2, Period: 2pi, and Phase: pi/2 right.

The key points are a quarter period, pi/2, apart: (pi/2, 2), VA: x = pi, (3pi/2, -2), VA: x = 2pi, and (5pi/2, 2).

Tips and common mistakes

Where this comes up

Graphing all six transformed trig functions, with period, phase shift, and asymptotes, is the trigonometric graphs unit of precalculus and trigonometry.

Exact reviewed bytes

Source code

Download .py

View source below, copy it when JavaScript is available, or download the exact .py bytes.

  1. from math import sin,cos,pi
  2. N=('sin','cos','tan','csc','sec','cot')
  3. def pg():input('[enter]');print('\n'*11)
  4. def val(t):
  5. t=t.lower().replace(' ','').replace('*','')
  6. if 'pi' in t:
  7. a,b=(t+'/1').split('/')[:2]
  8. if not a.endswith('pi'):raise ValueError
  9. a=a[:-2];a={'':'1','+':'1','-':'-1'}.get(a,a)
  10. return float(a)*pi/float(b)
  11. if '/' in t:a,b=t.split('/');return float(a)/float(b)
  12. return float(t)
  13. def ask(q,d):
  14. while 1:
  15. t=input(q+' ['+d+']: ').strip() or d
  16. try:
  17. v=val(t)
  18. if abs(v)<=1e6:return v
  19. except (ValueError,ZeroDivisionError):pass
  20. print('Like 2 or pi/3')
  21. def num(x):
  22. if abs(x-round(x))<1e-8:return str(int(round(x)))
  23. for d in range(2,33):
  24. k=round(x*d)
  25. if abs(x*d-k)<1e-8:return str(int(k))+'/'+str(d)
  26. return str(round(x,4))
  27. def rad(x):
  28. if abs(x)<1e-8:return '0'
  29. z=x/pi
  30. for d in range(1,65):
  31. k=int(round(z*d))
  32. if abs(z*d-k)<1e-8:return {1:'',-1:'-'}.get(k,str(k))+'pi'+('/'+str(d) if d>1 else '')
  33. return num(x)
  34. def den(m,t):return cos(t) if m in(3,5) else sin(t) if m in(4,6) else 1
  35. def trig(m,t):
  36. if abs(den(m,t))<1e-8:return None
  37. s=sin(t);c=cos(t)
  38. if m==1:return s
  39. if m==2:return c
  40. if m==3:return s/c
  41. if m==4:return 1/s
  42. if m==5:return 1/c
  43. return c/s
  44. def draw(m,A,B,C,D,P,H,Q):
  45. try:
  46. import ti_plotlib as p
  47. lo=H-(3 if m==3 else 1)*P/4;hi=H+(3 if m==3 else 5)*P/4
  48. h=max(3,abs(D)+(1 if m<3 else 2.6)*max(1,abs(A))+1)
  49. p.cls();p.window(lo,hi,-h,h);p.axes('on')
  50. for k in(1,0):
  51. if k:p.color(140,140,140)
  52. else:p.color(0,0,255)
  53. o=None
  54. for i in range(91):
  55. x=lo+(hi-lo)*i/90;t=x if k else B*x-C;v=trig(m,t)
  56. y=v if k or v is None else D+A*v
  57. if y is not None and abs(y)<=h:
  58. if o and den(m,o[2])*den(m,t)>0:p.line(o[0],o[1],x,y,'')
  59. o=(x,y,t)
  60. else:o=None
  61. p.color(255,0,0)
  62. for x,y in Q:
  63. if y is not None and -h<=y<=h:p.plot(x,y,'o')
  64. p.show_plot()
  65. except Exception as e:print('No plot:',e);pg()
  66. def main():
  67. print("TRIG 6 GRAPHS\n __\n ___(o )> quack!\n \\ <_. )\n `---'\nDuckieDai (TM)\nhiddenwordscanner.com");pg()
  68. while 1:
  69. m=input('1 sin 2 cos 3 tan\n4 csc 5 sec 6 cot\n1-6, 7 Exit: ').strip()
  70. if m=='7':break
  71. if m not in('1','2','3','4','5','6'):continue
  72. m=int(m);print('y=A*'+N[m-1]+'(Bx-C)+D\n[enter] keeps default')
  73. A=ask('A','1');B=ask('B','1');C=ask('C','0');D=ask('D','0')
  74. if abs(B)<1e-12:print('B cannot be zero');pg();continue
  75. P=(pi if m in(3,6) else 2*pi)/abs(B);H=C/B;g=1 if B>0 else -1
  76. v=([0,g,0,-g,0],[1,0,-1,0,1],[None,-g,0,g,None],[None,g,None,-g,None],[1,None,-1,None,1],[None,g,0,-g,None])[m-1]
  77. Q=[(H+(i-2 if m==3 else i)*P/4,None if v[i] is None else D+A*v[i]) for i in range(5)]
  78. print('\n'*11)
  79. if m<3:print('Amplitude:',num(abs(A)))
  80. else:print('No amplitude\nStretch:',num(abs(A)))
  81. print('Period:',rad(P))
  82. print('Phase:',rad(abs(H)),'right' if H>1e-9 else 'left' if H<-1e-9 else 'none')
  83. print('Midline: y =',num(D))
  84. if A<0:print('Reflect x-axis')
  85. if B<0:print('Reflect y-axis')
  86. pg()
  87. for x,y in Q:print('VA: x = '+rad(x) if y is None else '('+rad(x)+', '+num(y)+')')
  88. pg()
  89. if input('Draw? 1 Yes 2 No: ').strip()=='1':draw(m,A,B,C,D,P,H,Q)
  90. print('\n'*11)
  91. main()
Filename
TRIG6.py
Size
3134 bytes
SHA-256
2a214510ee4bd40a868136c7fd5a3e604a6b4be7ef1e7062c73eea406d9adc98

Usage

Inputs

  • A choice: 1 sin, 2 cos, 3 tan, 4 csc, 5 sec, 6 cot, 7 exit
  • A, B, C, and D for y = A*f(Bx - C) + D; Enter keeps the default shown

Outputs

  • The amplitude for sin and cos or the stretch for the other four, and the period, phase shift, midline, and any reflection
  • Five key x values: points, and vertical asymptotes for tan, csc, sec, and cot
  • Optionally, a graph on the calculator with the parent graph in gray and the key points marked

Units: Radians; angles may be typed as multiples of pi.

Assumptions and limitations

Assumptions

  • The function is y = A*f(Bx - C) + D for f = sin, cos, tan, csc, sec, or cot, with B not 0.
  • A, B, C, and D may be decimals, fractions such as 1/2, or multiples of pi such as pi/3 or -2pi.

Constraints

  • Values are limited to -1,000,000 to 1,000,000; inf and nan are asked for again.
  • B must not be 0. A B smaller than 0.000000000001 is treated as 0.

Known failures

  • Answers that are not a whole number, a fraction with a denominator up to 32, or a multiple of pi up to pi/64 show 4 decimal places.
  • The graph needs the calculator's ti_plotlib module; on a computer the program shows No plot instead.

Compatibility and review

Review status
Owner-tested on a TI calculator
Tested on
Owner reports personally running this program on a TI-84 Plus CE Python calculator; the test date, OS version, and Python App version were not recorded
What happened
Owner reported pass on the calculator for the owner's original. For publication, inf, nan, and values beyond 1,000,000 are asked for again instead of stopping the program. This exact file has not yet been rerun on a calculator.
Dependencies
math, ti_plotlib
Suggested calculator name
TRIG6 — you can give it another valid, unique name when you transfer it
Desktop test cases
Not available for this interactive-only source

This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.

Transfer and launch

Download the .py file, send it to your calculator with TI Connect CE as TRIG6 or another name, then open the Python App and try the worked example on this page first. This release has no verified calculator OS or Python App version; treat transfer and execution as unverified until independently tested.

Full installation and troubleshooting guide. Check your teacher's or exam's rules before using any program.

Version history

Did a DuckieDai program help with your homework? Every program here is free. If you would like to say thanks, you can leave a tip on Cash App ($duckiedai214) or read what tips pay for.

Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.

Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters, and so does a Yes or No answer about whether the program worked. Your browser notes that you answered; that note is never sent to the site. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.