Hidden WordScanner
Private scans · No account required

DuckieDai Double and Half Angles

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.

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

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.

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 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

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

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

Download .py

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

  1. from math import sin,cos,sqrt,pi,atan2
  2. def cl():print("\n"*11)
  3. def pg():input("[enter]");cl()
  4. def pk(p,v):
  5. while 1:
  6. c=input(p).strip()
  7. if len(c)==1 and c in v:return int(c)
  8. def g(a,b):
  9. while b:a,b=b,a%b
  10. return abs(a)
  11. def tm(c,k,f):
  12. 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)+")")
  13. def tw(v,D):
  14. for d in range(1,D+1):
  15. for a,b in((1,2),(1,3),(6,2)):
  16. for q in range(25):
  17. q=(q+1)//2*(1-q%2*2);p=(v*d-q*sqrt(b))/sqrt(a);P=round(p)
  18. if abs(p-P)<1e-5*d:
  19. 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 "")
  20. return ("("+s+")" if P and q and e>1 else s)+("/"+str(e) if e>1 else "")
  21. def fr(x):
  22. p,q,P,Q=0,1,1,0;y=x
  23. for i in range(30):
  24. a=int(y//1);p,q,P,Q=P,Q,a*P+p,a*Q+q
  25. if abs(x-P/Q)<1e-4/Q/Q:return P,Q
  26. if Q>20000 or y==a:return
  27. y=1/(y-a)
  28. def ex(v):
  29. if abs(v)<1e-9:return "0"
  30. if v<0:t=ex(-v);return "-"+(t if t[0] in"(s" or "+" not in t and "-" not in t else "("+t+")")
  31. r=fr(v)
  32. if r:return str(r[0])+("/"+str(r[1]) if r[1]>1 else "")
  33. r=fr(v*v)
  34. if r:
  35. d=r[1];N=r[0]*d;k=1;i=2
  36. while i*i<=N:
  37. while N%(i*i)==0:N//=i*i;k*=i
  38. i+=1
  39. h=g(k,d);k//=h;d//=h
  40. return (str(k) if k>1 else "")+"sqrt("+str(N)+")"+("/"+str(d) if d>1 else "")
  41. t=tw(v,12)
  42. if t:return t
  43. for e in range(1,9):
  44. t=tw(v*v*e*e,1)
  45. if t:return "sqrt("+t+")"+("/"+str(e) if e>1 else "")
  46. return "%.6g"%v
  47. def tn(s,c):return "UNDEFINED" if abs(c)<1e-9 else ex(s/c)
  48. def show(u,w):print("sin "+w+" = "+ex(sin(u))+"\ncos "+w+" = "+ex(cos(u))+"\ntan "+w+" = "+tn(sin(u),cos(u)))
  49. cl();print("5.3 DOUBLE & HALF\nfrom sin/cos/tan+quadrant\n ___(o )>\nDuckieDai (TM)\nhiddenwordscanner.com\nAngles: run ANGLE53");pg()
  50. while pk("1 New problem 0 Exit\n> ","01"):
  51. f=pk("Given: 1 sin 2 cos 3 tan\n> ","123")
  52. while 1:
  53. try:
  54. a,b=(input("Value a/b? ").split("/")+["1"])[:2];a,b=int(a),int(b)
  55. if b and (f>2 or abs(a)<abs(b)):break
  56. except ValueError:pass
  57. v=a/b;q=pk("Quadrant? (triangle:1) ","1234");S=1-2*(q>2);C=1-2*(q in(2,3))
  58. if f==1:s=v;c=C*sqrt(1-v*v)
  59. elif f==2:c=v;s=S*sqrt(1-v*v)
  60. else:h=sqrt(1+v*v);c=C/h;s=S*abs(v)/h
  61. u=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

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.