trigonometry · MIT License
Overview
Given sin u, cos u, or tan u as a fraction and the quadrant, find the exact sin, cos, and tan of u, 2u, and u/2 with the double- and half-angle identities.
- Owner-tested on a TI calculator
- Downloaded 11 times
- Version 1.0.0
- 2265 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
- You know one ratio, sin u, cos u, or tan u, as a fraction a/b, and the quadrant of u; for a right triangle choose quadrant 1.
- u is taken between 0 and 2pi, so u/2 lands in quadrant 1 or 2 and its sine is never negative.
- The value is typed as whole numbers a/b, such as 3/5 or -5/12; a whole number alone, such as 2, also works for tan.
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 find sin 2u, cos 2u, and tan(u/2) from one trig ratio and the quadrant
The idea
A common precalculus question gives one ratio, such as sin u = 3/5 with u in Quadrant II, and asks for sin 2u, cos 2u, tan 2u, or the values for u/2. You do not need the angle itself. Draw the reference triangle to find the other two ratios with the right signs, then put them into the double-angle and half-angle identities.
The quadrant decides the signs. For the half angle, if u is between 0 and 2pi, then u/2 is between 0 and pi, so u/2 is in Quadrant I or II and sin(u/2) is positive.
The formula
sin 2u = 2 sin u cos u
cos 2u = cos^2 u - sin^2 u = 1 - 2 sin^2 u = 2 cos^2 u - 1
tan 2u = 2 tan u/(1 - tan^2 u)
sin(u/2) = +-sqrt((1 - cos u)/2), cos(u/2) = +-sqrt((1 + cos u)/2), tan(u/2) = (1 - cos u)/sin u
u- the angle whose ratio you know
quadrant- where u lies, which sets the signs of the other ratios
reference triangle- the right triangle built from the ratio, with the third side from the Pythagorean theorem
Using the program
- Choose 1 for a new problem, then the ratio you know: 1 sin, 2 cos, or 3 tan.
- Type its value as a fraction a/b, such as 3/5 or -5/12. For sin and cos it must be between -1 and 1.
- Choose the quadrant of u, 1 to 4. For a plain right-triangle problem, choose 1.
- Press enter through three screens: the exact values of u, then of 2u, then the quadrant of u/2 and its exact values.
Worked example
sin u = 3/5 with u in Quadrant II. Choose 1, 1, type 3/5, and choose quadrant 2.
cos u = -4/5, sin 2u = 2(3/5)(-4/5) = -24/25, cos 2u = 16/25 - 9/25 = 7/25
The first screen shows sin u = 3/5, cos u = -4/5, and tan u = -3/4. The second shows sin 2u = -24/25, cos 2u = 7/25, and tan 2u = -24/7.
The third screen says u/2 in Q1 and shows sin (u/2) = 3sqrt(10)/10, cos (u/2) = sqrt(10)/10, and tan (u/2) = 3.
For tan u = -5/12 in Quadrant IV, the program shows sin 2u = -120/169 and cos 2u = 119/169, and u/2 in Q2 with tan (u/2) = -1/5.
Tips and common mistakes
- Find all three ratios of u first, with signs from the quadrant, before using any identity.
- Make sure the sign you type matches the quadrant: the program does not check, and a positive sine with quadrant 3 describes a different angle.
- Pick the cos 2u form that uses what you know: 1 - 2 sin^2 u needs only the sine.
- Read 3sqrt(10)/10 as 3 times sqrt(10), over 10.
Where this comes up
Finding sin 2u or cos(u/2) from one ratio and a quadrant is a standard analytic trigonometry question in precalculus, and calculus uses the same identities in integrals.
Exact reviewed bytes
Source code
from math import sin,cos,sqrt,pi,atan2def cl():print("\n"*11)def pg():input("[enter]");cl()def pk(p,v):while 1:c=input(p).strip()if len(c)==1 and c in v:return int(c)def g(a,b):while b:a,b=b,a%breturn abs(a)def tm(c,k,f):a=abs(c);return ("-" if c<0 else "+" if f else "")+("" if a==1 and k>1 else str(a))+("" if k==1 else "sqrt("+str(k)+")")def tw(v,D):for d in range(1,D+1):for a,b in((1,2),(1,3),(6,2)):for q in range(25):q=(q+1)//2*(1-q%2*2);p=(v*d-q*sqrt(b))/sqrt(a);P=round(p)if abs(p-P)<1e-5*d:h=g(g(P,q),d);P//=h;q//=h;e=d//h;s=(tm(P,a,0) if P else "")+(tm(q,b,P) if q else "")return ("("+s+")" if P and q and e>1 else s)+("/"+str(e) if e>1 else "")def fr(x):p,q,P,Q=0,1,1,0;y=xfor i in range(30):a=int(y//1);p,q,P,Q=P,Q,a*P+p,a*Q+qif abs(x-P/Q)<1e-4/Q/Q:return P,Qif Q>20000 or y==a:returny=1/(y-a)def ex(v):if abs(v)<1e-9:return "0"if v<0:t=ex(-v);return "-"+(t if t[0] in"(s" or "+" not in t and "-" not in t else "("+t+")")r=fr(v)if r:return str(r[0])+("/"+str(r[1]) if r[1]>1 else "")r=fr(v*v)if r:d=r[1];N=r[0]*d;k=1;i=2while i*i<=N:while N%(i*i)==0:N//=i*i;k*=ii+=1h=g(k,d);k//=h;d//=hreturn (str(k) if k>1 else "")+"sqrt("+str(N)+")"+("/"+str(d) if d>1 else "")t=tw(v,12)if t:return tfor e in range(1,9):t=tw(v*v*e*e,1)if t:return "sqrt("+t+")"+("/"+str(e) if e>1 else "")return "%.6g"%vdef tn(s,c):return "UNDEFINED" if abs(c)<1e-9 else ex(s/c)def show(u,w):print("sin "+w+" = "+ex(sin(u))+"\ncos "+w+" = "+ex(cos(u))+"\ntan "+w+" = "+tn(sin(u),cos(u)))cl();print("5.3 DOUBLE & HALF\nfrom sin/cos/tan+quadrant\n ___(o )>\nDuckieDai (TM)\nhiddenwordscanner.com\nAngles: run ANGLE53");pg()while pk("1 New problem 0 Exit\n> ","01"):f=pk("Given: 1 sin 2 cos 3 tan\n> ","123")while 1:try:a,b=(input("Value a/b? ").split("/")+["1"])[:2];a,b=int(a),int(b)if b and (f>2 or abs(a)<abs(b)):breakexcept ValueError:passv=a/b;q=pk("Quadrant? (triangle:1) ","1234");S=1-2*(q>2);C=1-2*(q in(2,3))if f==1:s=v;c=C*sqrt(1-v*v)elif f==2:c=v;s=S*sqrt(1-v*v)else:h=sqrt(1+v*v);c=C/h;s=S*abs(v)/hu=atan2(s,c)%(2*pi);cl();show(u,"u");pg();show(2*u,"2u");pg();print("u/2 in Q"+("1" if u<pi else "2"));show(u/2,"(u/2)");pg()
- Filename
TRIG53.py- Size
- 2265 bytes
- SHA-256
0c151e6d3c7853ba9c404c0683557a2e26e92ceaf17a8300d3c95421c9e6ed9e
Usage
Inputs
- 1 new problem or 0 exit
- The ratio you know: 1 sin, 2 cos, or 3 tan
- Its value as a fraction a/b, such as 3/5 or -5/12
- The quadrant of u, 1 to 4 (1 for a triangle problem)
Outputs
- Exact sin, cos, and tan of u, then of 2u
- The quadrant of u/2 and exact sin, cos, and tan of u/2
Units: Ratios as fractions; no units.
Assumptions and limitations
Assumptions
- You know one ratio, sin u, cos u, or tan u, as a fraction a/b, and the quadrant of u; for a right triangle choose quadrant 1.
- u is taken between 0 and 2pi, so u/2 lands in quadrant 1 or 2 and its sine is never negative.
Constraints
- The value is typed as whole numbers a/b, such as 3/5 or -5/12; a whole number alone, such as 2, also works for tan.
- For sin and cos the value must be strictly between -1 and 1; otherwise the program asks again.
Known failures
- The program does not check the sign against the quadrant: a sine typed as positive with quadrant 3 or 4 keeps the positive sine, so the screens describe a quadrant 1 or 2 angle.
- A tan value too large for a float, such as a 400-digit numerator, stops the program with an error.
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. The published file is the owner's tested source.
- Dependencies
- math
- Suggested calculator name
TRIG53— 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 TRIG53 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.