trigonometry · MIT License
Overview
Graph y = A*sin(Bx - C) + D or y = A*csc(Bx - C) + D: the amplitude, period, phase shift, midline, key points, and asymptotes, with the parent graph to compare and a drawing on the calculator.
- Owner-tested on a TI calculator
- Version 1.0.0
- 2879 bytes
- Uses math, ti_plotlib
Tried it? Did this program work on your calculator?
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*sin(Bx - C) + D or y = A*csc(Bx - C) + D, 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.
TI-84 Plus CE Python · screen preview
Learn the math
How to graph sine and cosecant with transformations
The idea
Sine waves up and down like cosine, but starts on its midline instead of at its top, so its five key points go midline, top, midline, bottom, midline. Cosecant is 1 divided by sine: U-shaped branches that touch the sine wave at its top and bottom, with asymptotes wherever sine is 0.
In y = A*sin(Bx - C) + D, A sets the amplitude, B squeezes the period, C/B slides the graph left or right, and D moves the midline up or down. A negative B also turns the wave upside down, because sine of a negative angle is the negative of sine.
The formula
amplitude = |A| (sin only)
period = 2pi / |B|
phase shift = C / B (right if positive, left if negative)
midline: y = D; csc has asymptotes where sin(Bx - C) = 0
A- the amplitude for sin, or the stretch for csc; a negative A flips the graph
B- changes the period to 2pi/|B|
C- together with B, the phase shift C/B
D- the midline
Using the program
- Choose 1 for sin or 2 for csc.
- Type A, B, C, and D. Press Enter to keep the default in brackets. Fractions such as 1/2 and pi values such as pi/2 or -2pi work.
- Read the amplitude or stretch, period, phase shift, and midline, then five key points across one period. For csc, three of them are asymptotes.
- The program then shows the same facts for the parent graph y = sin(x) or y = csc(x) so you can compare.
- Choose 1 at Draw? to see both graphs on the calculator, yours in blue and the parent in gray, with the key points in red. Press clear to go back to the menu.
Worked example
Graph y = 2sin(3x - pi) + 1. Choose 1, then type 2 for A, 3 for B, pi for C, and 1 for D.
amplitude = 2, period = 2pi/3, phase shift = pi/3 right, midline y = 1
The program shows Amplitude: 2, Period: 2pi/3, Phase: pi/3 right, and Midline: y = 1.
The key points are a quarter period, pi/6, apart, starting on the midline: (pi/3, 1), (pi/2, 3), (2pi/3, 1), (5pi/6, -1), and (pi, 1).
Tips and common mistakes
- Sine starts on its midline and goes up first; cosine starts at its top. Mixing them up shifts every point by a quarter period.
- Divide C by B for the shift. In sin(3x - pi) the shift is pi/3, not pi.
- Cosecant's asymptotes are at the start, middle, and end of each sine period, where the sine wave crosses its midline.
- Measure the amplitude from the midline: with D = 1 and A = 2, the top is 3 and the bottom is -1.
Where this comes up
Graphing transformed sine and cosecant waves is the first graph in the trigonometric graphs unit of precalculus and trigonometry, and it returns in physics with waves and sound.
Exact reviewed bytes
Source code
from math import sin,cos,pidef pg():input('[enter]');print('\n'*11)def val(t):t=t.lower().replace(' ','').replace('*','')if 'pi' in t:a,b=(t+'/1').split('/')[:2]a=a[:-2];a={'':'1','+':'1','-':'-1'}.get(a,a)return float(a)*pi/float(b)if '/' in t:a,b=t.split('/');return float(a)/float(b)return float(t)def ask(q,d):while 1:t=input(q+' ['+d+']: ').strip() or dtry:v=val(t)if abs(v)<=1e6:return vexcept Exception:passprint('Like 2 or pi/3')def num(x):if abs(x-round(x))<1e-8:return str(int(round(x)))for d in range(2,33):k=round(x*d)if abs(x*d-k)<1e-8:return str(int(k))+'/'+str(d)return str(round(x,4))def rad(x):if abs(x)<1e-8:return '0'z=x/pifor d in range(1,65):k=int(round(z*d))if abs(z*d-k)<1e-8:return {1:'',-1:'-'}.get(k,str(k))+'pi'+('/'+str(d) if d>1 else '')return num(x)N=('sin','csc')def f(m,t):s=sin(t)if m==0:return sreturn None if abs(s)<1e-8 else 1/sdef dn(m,t):return sin(t) if m else 1def draw(m,A,B,C,D,P,H,Q):try:import ti_plotlib as plo=H-1*P/4;hi=H+5*P/4h=max(3,abs(D)+(1 if m==0 else 2.6)*max(1,abs(A))+1)p.cls();p.window(lo,hi,-h,h);p.axes('on')try:p.text_at(1,'gray=parent blue=yours','left');p.text_at(12,' '.join(rad(x) for x,y in Q),'left')except Exception:passfor k in(1,0):if k:p.color(140,140,140)else:p.color(0,0,255)o=Nonefor i in range(91):x=lo+(hi-lo)*i/90;t=x if k else B*x-C;v=f(m,t)y=v if k or v is None else D+A*vif y is not None and abs(y)<=h:if o and dn(m,o[2])*dn(m,t)>0:p.line(o[0],o[1],x,y,'')o=(x,y,t)else:o=Nonep.color(255,0,0)for x,y in Q:if y is not None and -h<=y<=h:p.plot(x,y,'o')p.show_plot()except Exception as e:print('No plot:',e);pg()def facts(m,A,B,C,D,T):P=2*pi/abs(B);H=C/B;g=1 if B>0 else -1v=([0,g,0,-g,0],[None,g,None,-g,None])[m]Q=[(H+(i-0)*P/4,None if v[i] is None else D+A*v[i]) for i in range(5)]print('\n'*11);print(T)if m==0:print('Amplitude:',num(abs(A)))else:print('No amplitude\nStretch:',num(abs(A)))print('Period:',rad(P))print('Phase:',rad(abs(H)),'right' if H>0 else 'left' if H<0 else '')print('Midline: y =',num(D))if A<0:print('Flipped (A<0)')pg();print(T)for x,y in Q:print('VA: x = '+rad(x) if y is None else '('+rad(x)+', '+num(y)+')')pg();return P,H,Qprint("SIN + CSC GRAPHS\n __\n ___(o )> quack!\n \\ <_. )\n `---'\nDuckieDai (TM)\nhiddenwordscanner.com");pg()while 1:m=input('1 sin 2 csc 3 Exit: ').strip()if m=='3':breakif m not in('1','2'):continuem=int(m)-1;print('y=A*'+N[m]+'(Bx-C)+D\n[enter] keeps default')A=ask('A','1');B=ask('B','1');C=ask('C','0');D=ask('D','0')if abs(B)<1e-6:print('B=0?');continueP,H,Q=facts(m,A,B,C,D,'YOUR GRAPH (BLUE)')facts(m,1,1,0,0,'GRAY: y='+N[m]+'(x)')if input('Draw? 1 Yes 2 No: ').strip()=='1':draw(m,A,B,C,D,P,H,Q)print('\n'*11)
- Filename
TRIGSC.py- Size
- 2879 bytes
- SHA-256
8596e4dc24926dcf6d931471a5308a5db4390583c892dc8ea934188689b54ac4
Usage
Inputs
- A choice: 1 sin, 2 csc, 3 exit
- A, B, C, and D for y = A*sin(Bx - C) + D; Enter keeps the default shown
Outputs
- The amplitude for sin or the stretch for csc, and the period, phase shift, and midline, and whether the graph is flipped
- Five key x values over one period: points, and for csc its three vertical asymptotes
- The same facts for the parent graph y = sin(x) or y = csc(x)
- Optionally, a graph of both on the calculator, with the key points marked
Units: Radians; angles may be typed as multiples of pi.
Assumptions and limitations
Assumptions
- The function is y = A*sin(Bx - C) + D or y = A*csc(Bx - C) + D, 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.000001 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, and a B smaller than 0.000001 is treated as 0. This exact file has not yet been rerun on a calculator.
- Dependencies
- math, ti_plotlib
- Suggested calculator name
TRIGSC— 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 TRIGSC 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
- 1.0.0 — current version, published . Download this reviewed version
Related learning
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.