Hidden WordScanner
Private scans · No account required

DuckieDai Half-Angle Exact Values

Find exact sin, cos, and tan for half angles such as 67.5 degrees or 5pi/8, with nested radicals like sqrt(2+sqrt(2))/2, and double an angle to see the double-angle values.

trigonometry · MIT License

Overview

Find exact sin, cos, and tan for half angles such as 67.5 degrees or 5pi/8, with nested radicals like sqrt(2+sqrt(2))/2, and double an angle to see the double-angle values.

  • Owner-tested on a TI calculator
  • Downloaded 13 times
  • Version 1.0.0
  • 2474 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
  • Choice 1 treats the angle you type as half of a known angle: 67.5 degrees is half of 135, 5pi/8 is half of 5pi/4.
  • Choice 2 doubles the angle you type and gives the exact values of the double angle.
  • In radian mode the number you type is a multiple of pi, so 5/8, 5pi/8, and 0.625pi all mean 5pi/8.

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 exact values like sin 67.5 and tan 5pi/8 with the half-angle formulas

The idea

Angles such as 67.5 degrees, 22.5 degrees, 15 degrees, or 5pi/8 are not on the unit circle you memorized, but each is half of an angle that is: 67.5 is half of 135, 15 is half of 30, and 5pi/8 is half of 5pi/4. The half-angle formulas turn the known cosine of the bigger angle into the sine, cosine, and tangent of the half angle.

The square root in the formula has a plus or minus sign. You choose it from the quadrant the half angle lands in, not the quadrant of the bigger angle. The results are often nested radicals such as sqrt(2+sqrt(2))/2, or two-term radicals such as (sqrt(6)-sqrt(2))/4.

The formula

sin(u/2) = +-sqrt((1 - cos u)/2)

cos(u/2) = +-sqrt((1 + cos u)/2)

tan(u/2) = (1 - cos u)/sin u = sin u/(1 + cos u)

sin 2u = 2 sin u cos u, cos 2u = cos^2 u - sin^2 u, tan 2u = 2 tan u/(1 - tan^2 u)

u
the known angle; the half angle is u/2
+-
the sign comes from the quadrant of u/2
nested radical
a square root with another square root inside, such as sqrt(2+sqrt(2))

Using the program

Worked example

Find the exact values for 67.5 degrees. Choose 1, then 1 for degrees, and type 67.5.

67.5 = 135/2, cos 135 = -sqrt(2)/2, sin 67.5 = sqrt((1 + sqrt(2)/2)/2) = sqrt(2+sqrt(2))/2

The program shows 3pi/8 = half of 3pi/4, then sin 3pi/8 = sqrt(2+sqrt(2))/2, cos 3pi/8 = sqrt(2-sqrt(2))/2, and tan 3pi/8 = 1+sqrt(2).

For 5pi/8, half of 5pi/4, the angle is in Quadrant II, so cosine and tangent are negative: cos 5pi/8 = -sqrt(2-sqrt(2))/2 and tan 5pi/8 = -(1+sqrt(2)).

For pi/12, half of pi/6, the program shows sin pi/12 = (sqrt(6)-sqrt(2))/4 and tan pi/12 = 2-sqrt(3).

Tips and common mistakes

Where this comes up

Half-angle and double-angle formulas are part of the analytic trigonometry unit of precalculus, and exact values like sin 67.5 or tan pi/12 are a classic test question.

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
  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 an(u):
  48. n=round(u*720/pi);h=g(n,720);n//=h;d=720//h
  49. return ("-" if n<0 else "")+("" if abs(n)==1 else str(abs(n)))+"pi"+("/"+str(d) if d>1 else "") if n else "0"
  50. def tn(s,c):return "UNDEFINED" if abs(c)<1e-9 else ex(s/c)
  51. def ang():
  52. u=pk("1 Deg 2 Rad (5pi/8)\n> ","12")
  53. while 1:
  54. s=input("Angle? ").replace(" ","").lower()
  55. try:
  56. if u<2:return float(s)*pi/180
  57. a,b=(s.split("/")+["1"])[:2];a=a.replace("pi","");a={"":"1","-":"-1"}.get(a,a);return float(a)*pi/float(b)
  58. except Exception:0
  59. def show(u,w):print("sin "+w+" = "+ex(sin(u))+"\ncos "+w+" = "+ex(cos(u))+"\ntan "+w+" = "+tn(sin(u),cos(u)))
  60. cl();print("5.3 EXACT ANGLES\n(tan 67.5, sin 5pi/8)\n ___(o )>\nDuckieDai (TM)\nhiddenwordscanner.com");pg()
  61. while 1:
  62. m=pk("1 Exact value (half angle)\n2 Pattern -> double angle\n0 Exit\n> ","012");cl()
  63. if m<1:break
  64. if m<2:u=ang();cl();print(an(u)+" = half of "+an(2*u));show(u,an(u));pg()
  65. else:print("2sin cos -> sin(2u)\ncos^2-sin^2 -> cos(2u)\n2tan/(1-tan^2) -> tan(2u)");u=ang();cl();print(an(u)+" doubled = "+an(2*u));show(2*u,an(2*u));pg()
Filename
ANGLE53.py
Size
2474 bytes
SHA-256
f44214f2de9e4e78382aa5c64e3f1c78b37ee09875035641ff8bd8b535429b33

Usage

Inputs

  • A menu choice: 1 exact value (half angle), 2 pattern to double angle, 0 exit
  • The unit: 1 degrees or 2 radians
  • An angle such as 67.5 in degrees, or 5pi/8, pi/12, or -pi/8 in radians

Outputs

  • The angle and the angle it is half of (or its double) as multiples of pi
  • Exact sin, cos, and tan, such as sqrt(2+sqrt(2))/2 and 1+sqrt(2), or UNDEFINED for tan

Units: Angles in degrees or as a multiple of pi.

Assumptions and limitations

Assumptions

  • Choice 1 treats the angle you type as half of a known angle: 67.5 degrees is half of 135, 5pi/8 is half of 5pi/4.
  • Choice 2 doubles the angle you type and gives the exact values of the double angle.
  • In radian mode the number you type is a multiple of pi, so 5/8, 5pi/8, and 0.625pi all mean 5pi/8.

Constraints

  • Exact forms are fractions, square roots of fractions, two-term radicals such as (sqrt(6)-sqrt(2))/4, and nested roots such as sqrt(2+sqrt(2))/2; anything else is shown as a 6-digit decimal.
  • The angle is named as a multiple of pi to the nearest pi/720 (a quarter of a degree).

Known failures

  • Typing inf or nan as the angle, or an angle too large to hold, stops the program with an error.
  • In radian mode, a number without pi is still read as a multiple of pi, so 2.5 means 2.5pi, not 2.5 radians.

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
ANGLE53 — 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 ANGLE53 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.