trigonometry · MIT License
Overview
Review 19 basic trig identities, rewrite a function with its cofunction, and check any identity numerically at an angle you choose.
- Owner-tested on a TI calculator
- Version 1.0.0
- 3417 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, so the cofunction rules use 90-x.
- A check passes when the two sides agree to about seven significant digits.
- A pi angle is typed as a fraction such as 5pi/6; inf, nan, and angles beyond 1e300 degrees 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 the basic trig identities fit together
The idea
A trig identity is an equation that is true for every angle where both sides are defined. A small set of basic identities does most of the work in simplifying expressions and proving harder identities.
The basic ones come in five families: reciprocal identities, such as csc = 1/sin; quotient identities, such as tan = sin/cos; Pythagorean identities, from sin^2 + cos^2 = 1; even-odd identities, such as cos(-x) = cos x; and cofunction identities, such as sin(90 - x) = cos x.
The formula
sin(x)^2 + cos(x)^2 = 1
1 + tan(x)^2 = sec(x)^2
1 + cot(x)^2 = csc(x)^2
sin(90 - x) = cos(x)
reciprocal- csc, sec, and cot are 1 over sin, cos, and tan
cofunction- sine and cosine, tangent and cotangent, and secant and cosecant swap when the angle is replaced by 90 - x, which is pi/2 - x
MATCH- the two sides agree to about seven significant digits at the angle you chose
Using the program
- Choose 1 to page through all 19 identities, eight per screen.
- Choose 2 for a cofunction: pick the function, then type the angle. The program rewrites it with the cofunction of the complementary angle, in degrees or in pi.
- Choose 3 to check an identity: type its number from the list, then an angle. The program shows the left side, the right side, and MATCH, NO MATCH, or Undefined.
- Angles are in degrees unless you type pi, such as pi/6. Press Enter with nothing typed to go back to the menu.
Worked example
Rewrite sin(pi/6) with a cofunction. Choose 2, then 1 for sin, and type pi/6.
sin(pi/6) = cos(pi/2 - pi/6) = cos(pi/3)
The program shows sin(pi/6) = and cos(pi/3). With degrees, tan 20 becomes cot(70).
Check 1 + tan(x)^2 = sec(x)^2 at 60 degrees. Choose 3, type 7, then 60. tan 60 is sqrt(3), so the left side is 1 + 3, and sec 60 is 2, so the right side is 4. The program shows Left = 4, Right = 4, and MATCH.
Check 1/tan(x) = cot(x) at 90 degrees. tan 90 has 0 on the bottom, so the program shows Undefined.
Tips and common mistakes
- A MATCH at one angle is evidence, not a proof: a false equation can match at a lucky angle. Try two or three angles, or prove the identity with algebra.
- When a check says Undefined, one side divides by zero at that angle. Identities only hold where both sides are defined.
- Divide sin^2 + cos^2 = 1 by cos^2 to get 1 + tan^2 = sec^2, or by sin^2 to get 1 + cot^2 = csc^2; you only need to memorise one.
- Cofunction angles add up to 90 degrees: sin 20 = cos 70 and tan 35 = cot 55.
Where this comes up
Trig identities fill the analytic trigonometry unit of precalculus and are used again in calculus to simplify integrals and derivatives.
Exact reviewed bytes
Source code
from math import sin as _s,cos as _c,piR=("1/sin(x)=csc(x)","1/cos(x)=sec(x)","1/tan(x)=cot(x)","sin(x)/cos(x)=tan(x)","cos(x)/sin(x)=cot(x)","sin(x)^2+cos(x)^2=1","1+tan(x)^2=sec(x)^2","1+cot(x)^2=csc(x)^2","csc(x)^2-cot(x)^2=1","sec(x)^2-tan(x)^2=1","sin(-x)=-sin(x)","cos(-x)=cos(x)","tan(-x)=-tan(x)","sin(90-x)=cos(x)","cos(90-x)=sin(x)","tan(90-x)=cot(x)","sec(90-x)=csc(x)","csc(90-x)=sec(x)","cot(90-x)=tan(x)")def clr():print("\n"*11)def pg():input("[enter]");clr()def ask(p):s=input(p).strip()if not s:raise KeyErrorreturn sdef pick(p,n):while 1:try:x=int(ask(p))if 1<=x<=n:return xexcept ValueError:passprint("Pick 1-"+str(n))def fmt(x):r=round(x)return str(int(r)) if abs(x-r)<1e-9 else str(round(x,6))def ang(p):while 1:s=ask(p).replace("π","pi").replace(" ","").replace("*","")try:if "pi" in s:a,b=(s+"/1").split("/")[:2];a=a.replace("pi","")v=float(a+"1" if a in("","-") else a)*180/float(b),1else:v=float(s),0if v[0]-v[0] or abs(v[0])>1e300:raise ValueErrorreturn vexcept (ValueError,ZeroDivisionError):print("Bad angle")def T(f,d):v=f(d*pi/180);return 0 if abs(v)<1e-12 else vS=lambda d:T(_s,d)C=lambda d:T(_c,d)G={"sin":S,"cos":C,"tan":lambda d:S(d)/C(d),"csc":lambda d:1/S(d),"sec":lambda d:1/C(d),"cot":lambda d:C(d)/S(d)}sin,cos,tan,csc,sec,cot=(G[n] for n in ("sin","cos","tan","csc","sec","cot"))# Each rule in R as a pair of functions: the left side and the right side.Q=((lambda x:1/sin(x),lambda x:csc(x)),(lambda x:1/cos(x),lambda x:sec(x)),(lambda x:1/tan(x),lambda x:cot(x)),(lambda x:sin(x)/cos(x),lambda x:tan(x)),(lambda x:cos(x)/sin(x),lambda x:cot(x)),(lambda x:sin(x)**2+cos(x)**2,lambda x:1),(lambda x:1+tan(x)**2,lambda x:sec(x)**2),(lambda x:1+cot(x)**2,lambda x:csc(x)**2),(lambda x:csc(x)**2-cot(x)**2,lambda x:1),(lambda x:sec(x)**2-tan(x)**2,lambda x:1),(lambda x:sin(-x),lambda x:-sin(x)),(lambda x:cos(-x),lambda x:cos(x)),(lambda x:tan(-x),lambda x:-tan(x)),(lambda x:sin(90-x),lambda x:cos(x)),(lambda x:cos(90-x),lambda x:sin(x)),(lambda x:tan(90-x),lambda x:cot(x)),(lambda x:sec(90-x),lambda x:csc(x)),(lambda x:csc(90-x),lambda x:sec(x)),(lambda x:cot(90-x),lambda x:tan(x)))def show(i):print(i+1,R[i])def lib():for i in range(19):show(i)if i%8==7:pg()pg()def pf(z):d=1while abs(z*d/180-round(z*d/180))>1e-9 and d<360:d+=1n=round(z*d/180)if n==0:return "0"return {1:"",-1:"-"}.get(n,str(n))+"pi"+("/"+str(d) if d>1 else "")def cof():N=("sin","cos","tan","csc","sec","cot");O=("cos","sin","cot","sec","csc","tan")for i in range(6):print(i+1,N[i])f=pick("Function? ",6)-1;x,p=ang("Angle? ");clr()z=90-x;h=pf if p else fmtprint(N[f]+"("+h(x)+") =");print(O[f]+"("+h(z)+")");pg()def chk():k=pick("Rule # (1-19)? ",19)-1;show(k);l,r=Q[k]x=ang("Angle? ")[0];clr();show(k)try:L=l(x);V=r(x)print("Left =",fmt(L));print("Right =",fmt(V))print("MATCH" if abs(L-V)<1e-7*max(1,abs(L)) else "NO MATCH")except ZeroDivisionError:print("Undefined")pg()def main():clr();print("TRIG IDENTITIES\n __\n ___(o )> quack!\n \\ <_. )\n `---'")print("DuckieDai (TM)\nhiddenwordscanner.com\nBlank entry = back");pg()while 1:print("TRIG IDENTITIES\n1 All 19 Rules\n2 Cofunction Angle\n3 Numeric Check\n4 Exit")try:c=pick("Choice? ",4);clr()if c==4:break(lib,cof,chk)[c-1]()except KeyError:clr()main()
- Filename
TRIGID.py- Size
- 3417 bytes
- SHA-256
0955b601b4f6fa149e2621188ddbc508726f80bc03f9e45906b6486dbd40076c
Usage
Inputs
- A menu choice: 1 all 19 rules, 2 cofunction angle, 3 numeric check, 4 exit
- For a cofunction, the function: 1 sin to 6 cot, and an angle
- For a check, the rule number from 1 to 19 and an angle
- Enter with nothing typed goes back to the menu
Outputs
- The reciprocal, quotient, Pythagorean, even-odd, and cofunction identities, eight per screen
- The cofunction form, such as sin(pi/6) = cos(pi/3)
- The left and right side of an identity at your angle, and MATCH, NO MATCH, or Undefined
Units: Angles in degrees or as a multiple of pi.
Assumptions and limitations
Assumptions
- An angle without pi is read as degrees, so the cofunction rules use 90-x.
- A check passes when the two sides agree to about seven significant digits.
Constraints
- A pi angle is typed as a fraction such as 5pi/6; inf, nan, and angles beyond 1e300 degrees are asked for again.
Known failures
- A numeric check tests one angle, so a MATCH shows the rule holds there, not that it is proved.
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 angle prompt now asks again when inf, nan, or an angle beyond 1e300 degrees is typed, where the original stopped with an error, and the numeric check now works each rule out with a fixed pair of functions instead of running its text through Python's eval. The results are the same. Every other step is unchanged; this exact file has not yet been rerun on a calculator.
- Dependencies
- math
- Suggested calculator name
TRIGID— 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 TRIGID 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.