trigonometry · MIT License
Overview
Type a function and an angle, such as sin pi/4, and get its exact value, or type just an angle to see all six exact values.
- Owner-tested on a TI calculator
- Version 1.0.0
- 1628 bytes
- Uses math
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
- An angle without pi is read as degrees.
- Exact values are given for multiples of 30 and 45 degrees.
- Function names are sin, cos, tan, csc, sec, and cot.
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 look up exact trig values quickly
The idea
Trig values of the standard angles, the multiples of 30 and 45 degrees, come up so often that it pays to know them by sight. Each one is built from a special right triangle and a sign that depends on where the angle ends.
This program is the quick version: type the function and the angle on one line, the way you would read it aloud, and the exact value appears. Type just an angle to see all six values at once.
The formula
sin^2 + cos^2 = 1
tan = sin/cos
csc = 1/sin, sec = 1/cos, cot = 1/tan
pi- a half turn, 180 degrees
undefined- a value with 0 on the bottom, such as tan 90
exact value- a fraction with square roots, such as sqrt(3)/2, in place of a rounded decimal
Using the program
- Type a function and an angle, such as sin pi/4, tan(pi/2), or cos 60. Spaces and parentheses are optional.
- Type only an angle, such as pi/6, to see all six values; press Enter after the first three to see the rest.
- An angle without pi is in degrees. A pi angle is a fraction such as 5pi/6.
- For an angle that is not standard, the program shows sin, cos, and tan as decimals to four places.
- Press Enter with nothing typed to quit.
Worked example
Type sin 5pi/6. The angle is 150 degrees, in Quadrant 2, with a reference angle of 30 degrees, where sine is positive.
sin 150 = sin 30 = 1/2
The program shows Angle = 150 deg and sin = 1/2.
Type pi/4 for all six values. The program shows sin = sqrt(2)/2, cos = sqrt(2)/2, and tan = 1, then csc = sqrt(2), sec = sqrt(2), and cot = 1.
Type tan 90. Cosine is 0 at 90 degrees, so the program shows tan = undefined. Type 20, which is not a standard angle, and the program shows sin = 0.342, cos = 0.9397, and tan = 0.364.
Tips and common mistakes
- Check a value by squaring: sin^2 + cos^2 must equal 1. For pi/4, (sqrt(2)/2)^2 + (sqrt(2)/2)^2 = 1/2 + 1/2 = 1.
- csc, sec, and cot are reciprocals, not inverses: csc 30 = 2, while the inverse sine of 1/2 is 30 degrees.
- Decimals such as 0.342 are rounded; keep the exact value when a question asks for one.
- If the program says Bad angle, check for a typing slip such as pi/0 or a missing number.
Where this comes up
Exact values of the standard angles are used throughout precalculus, physics vector problems, and calculus, wherever a sine or cosine of 30, 45, or 60 degrees appears.
Exact reviewed bytes
Source code
from math import sin,cos,pidef clr():print("\n"*11)def pg():input("[enter]");clr()def fmt(x):r=round(x)return str(int(r)) if abs(x-r)<1e-9 else str(round(x,4))def gcd(a,b):while b:a,b=b,a%breturn adef ex(p,q):g=gcd(p,q);p//=g;q//=g;n=p*q;k=1;d=2while d*d<=n:if n%(d*d):d+=1else:n//=d*d;k*=dg=gcd(k,q);k//=g;q//=gs=str(k) if n==1 else ("" if k==1 else str(k))+"sqrt("+str(n)+")"return s if q==1 else s+"/"+str(q)def sg(x):return (x>1e-9)-(x<-1e-9)def e(p,q,s):if q==0:return "undefined"if s==0:return "0"return ("-" if s<0 else "")+ex(p,q)def go(s):s=s.replace("π","pi").replace("*","").replace(" ","");f=""for n in N:if s.startswith(n):f=n;s=s[3:].strip("()")try:if "pi" in s:a,b=(s+"/1").split("/")[:2];a=a.replace("pi","")t=float(a+"1" if a in("","-") else a)*180/float(b)else:t=float(s)if t-t:raise ValueErrorexcept (ValueError,ZeroDivisionError):print("Bad angle");returnt%=360;x=t*pi/180;r=t%180;r=min(r,180-r);clr()print("Angle =",fmt(t),"deg");S=sg(sin(x));C=sg(cos(x))v=Noneif abs(r-round(r))<1e-6:v={0:(0,1),30:(1,4),45:(1,2),60:(3,4),90:(1,1)}.get(round(r))if not v:print("sin =",fmt(sin(x)));print("cos =",fmt(cos(x)));print("tan =",fmt(sin(x)/cos(x)));pg();returnp,q=v;c=q-pL=[e(p,q,S),e(c,q,C),e(p,c,S*C),e(q,p,S),e(q,c,C),e(c,p,S*C)]for i in range(6):if f in("",N[i]):print(N[i],"=",L[i])if i==2 and not f:pg()pg()N=["sin","cos","tan","csc","sec","cot"]clr();print("TRIG VALUES - DuckieDai\nhiddenwordscanner.com\nType: sin pi/4 or pi/6\nBlank entry = quit")while 1:s=input("Angle? ").strip()if not s:breakgo(s)
- Filename
TRIGV.py- Size
- 1628 bytes
- SHA-256
eb5cca5052305e5734caa793ddf05dadae319e533768067862562eeb9d259d83
Usage
Inputs
- An angle, such as 30 or pi/6, optionally after a function name, such as sin pi/4 or tan(pi/2)
- Enter with nothing typed to quit
Outputs
- The angle in degrees from 0 up to 360
- The exact value of the function asked for, or all six, such as sqrt(3)/2 or undefined
- For other angles, sin, cos, and tan as decimals to four places
Units: Angles in degrees or as a multiple of pi.
Assumptions and limitations
Assumptions
- An angle without pi is read as degrees.
- Exact values are given for multiples of 30 and 45 degrees.
Constraints
- Function names are sin, cos, tan, csc, sec, and cot.
- A pi angle is typed as a fraction such as 5pi/6; inf and nan show Bad angle.
Known failures
- For an angle that is not standard, the program shows sin, cos, and tan as decimals even when one function was asked for.
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 before two changes: the website line was added to the opening screen, and inf or nan typed as an angle now shows Bad angle, where the original stopped with an error. Every other step is unchanged; this exact file has not yet been rerun on a calculator.
- Dependencies
- math
- Suggested calculator name
TRIGV— 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 TRIGV 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.