Hidden WordScanner
Private scans · No account required

DuckieDai Six Trig Values

Find all six trig values exactly from one known ratio, such as sin = -3/8, and the quadrant the angle is in, with square roots simplified and rationalized.

trigonometry · MIT License

Overview

Find all six trig values exactly from one known ratio, such as sin = -3/8, and the quadrant the angle is in, with square roots simplified and rationalized.

  • Owner-tested on a TI calculator
  • Version 1.0.0
  • 3672 bytes
  • No imports

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
  • The known ratio is typed as a whole-number numerator and denominator, such as -3 and 8 for -3/8.
  • The quadrant sets the signs: x is positive in Quadrants 1 and 4, and y is positive in Quadrants 1 and 2.
  • Numerators and denominators can be whole numbers up to 9999.

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 all six trig values from one ratio and a quadrant

The idea

One trig ratio fixes a right triangle up to its size. If sin = -3/8, the side opposite the angle is 3 and the hypotenuse is 8; the Pythagorean theorem gives the third side, and every other ratio follows.

The quadrant decides the signs. x is negative in Quadrants 2 and 3, and y is negative in Quadrants 3 and 4, so each value takes the sign of the coordinates it uses.

The formula

x^2 + y^2 = r^2

sin = y/r, cos = x/r, tan = y/x

csc = r/y, sec = r/x, cot = x/y

r
the distance from the origin, always positive, like the hypotenuse
rationalized
a fraction rewritten so no square root is left in the denominator
axis angle
an angle such as 90 degrees where one coordinate is 0, which the program does not solve

Using the program

Worked example

sin = -3/8 in Quadrant 3. Choose 1, enter -3 and 8, then quadrant 3. The opposite side y is -3 and r is 8.

x^2 = 8^2 - 3^2 = 55, x = -sqrt(55) in Quadrant 3

The program shows sin = -3/8 and cos = -sqrt(55)/8, then tan = 3*sqrt(55)/55 and csc = -8/3, then sec = -8*sqrt(55)/55 and cot = sqrt(55)/3.

tan = -12/5 in Quadrant 4. Choose 3, enter -12 and 5, then 4. Here x = 5 and y = -12, so r = 13. The program shows sin = -12/13, cos = 5/13, tan = -12/5, csc = -13/12, sec = 13/5, and cot = -5/12.

Tips and common mistakes

Where this comes up

Finding the other five values from one ratio and a quadrant is a standard precalculus and trigonometry question, and it returns in calculus with trig substitution.

Exact reviewed bytes

Source code

Download .py

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

  1. # DuckieDai(TM) - Six Trig Values
  2. # All six from one ratio and a quadrant
  3. def gcd(a,b):
  4. a=abs(a)
  5. b=abs(b)
  6. while b:
  7. a,b=b,a%b
  8. return a
  9. def page(s):
  10. print(s)
  11. input('Enter...')
  12. print('\n'*6)
  13. def intro():
  14. print('DuckieDai (TM)')
  15. print('SIX TRIG VALUES')
  16. print(' __(o )>')
  17. print(' \\ <_. ) QUACK!')
  18. print(" `---'")
  19. page('hiddenwordscanner.com')
  20. def readint(p):
  21. while True:
  22. try:return int(input(p))
  23. except ValueError:print('Whole numbers only')
  24. def radical(n):
  25. # simplify sqrt(n) into coefficient * sqrt(squarefree)
  26. a=1;k=2
  27. while k*k<=n:
  28. while n%(k*k)==0:n//=k*k;a*=k
  29. k+=1
  30. return a,n
  31. def rootfrac(n,d,sign):
  32. # exact sqrt(n)/sqrt(d), rationalized, n>=0 d>0
  33. if n==0:return '0'
  34. # sqrt(n*d)/d, simplify common integer factors
  35. g=gcd(n,d);n//=g;d//=g
  36. # sqrt(n*d) from sqrt(n) and sqrt(d) separately,
  37. # so big numbers stay quick on the calculator
  38. a1,r1=radical(n);a2,r2=radical(d)
  39. c=gcd(r1,r2);a=a1*a2*c;r=(r1//c)*(r2//c)
  40. g=gcd(a,d);a//=g;d//=g
  41. pre='-' if sign<0 else ''
  42. if r==1:return pre+(str(a) if d==1 else str(a)+'/'+str(d))
  43. num=('' if a==1 else str(a)+'*')+'sqrt('+str(r)+')'
  44. return pre+num+('' if d==1 else '/'+str(d))
  45. def frac(n,d):
  46. if d==0:return 'undef'
  47. if n==0:return '0'
  48. if d<0:n=-n;d=-d
  49. g=gcd(abs(n),d);n//=g;d//=g
  50. return str(n) if d==1 else str(n)+'/'+str(d)
  51. def rootratio(num,den,sign):
  52. # sqrt(num/den), rationalized
  53. return rootfrac(num,den,sign)
  54. def display(s,c,t,cs,ss,ct):
  55. page('sin = '+s+'\ncos = '+c)
  56. page('tan = '+t+'\ncsc = '+cs)
  57. page('sec = '+ss+'\ncot = '+ct)
  58. def solve():
  59. print('Known function:')
  60. print('1 sin 2 cos')
  61. print('3 tan 4 csc')
  62. print('5 sec 6 cot')
  63. f=readint('Choice? ')
  64. if f<1 or f>6:page('Choose 1-6');return
  65. page('Enter signed fraction\nExample: -3/8\nnum=-3 den=8')
  66. n=readint('Numerator? ');d=readint('Denominator? ')
  67. if d==0:page('Denominator cannot be 0');return
  68. if d<0:n=-n;d=-d
  69. if abs(n)>9999 or d>9999:page('Use whole numbers\nup to 9999');return
  70. if f in (1,2) and abs(n)>d:page('sin/cos must be\nbetween -1 and 1');return
  71. if f in (4,5) and abs(n)<d:page('csc/sec must have\nabsolute value >=1');return
  72. if f in (4,5) and n==0:page('Reciprocal cannot\nbe zero');return
  73. if f==6 and n==0:page('Axis angles need\na separate case.');return
  74. if f==3 and n==0:pass
  75. print('Quadrant 1,2,3,4')
  76. q=readint('Quadrant? ')
  77. if q not in (1,2,3,4):page('Choose 1-4');return
  78. sx=1 if q in (1,4) else -1
  79. sy=1 if q in (1,2) else -1
  80. st=sx*sy
  81. # signs and consistency of input
  82. expected=(sy,sx,st,sy,sx,st)[f-1]
  83. if n!=0 and (1 if n>0 else -1)!=expected:
  84. page('Sign does not match\nselected quadrant');return
  85. if n==0 and f in (4,5,6):page('Undefined input');return
  86. if f in (1,4):
  87. if f==4:n,d=d,n
  88. if n==0:page('Axis angles need\na separate case.');return
  89. an=abs(n);D=d*d-an*an
  90. if D<=0:page('Axis or invalid\nquadrant value');return
  91. s=frac(n,d);c=rootratio(D,d*d,sx)
  92. t=rootratio(an*an,D,st)
  93. cs=frac(d,n);ss=rootratio(d*d,D,sx);ct=rootratio(D,an*an,st)
  94. elif f in (2,5):
  95. if f==5:n,d=d,n
  96. if n==0:page('Axis angles need\na separate case.');return
  97. an=abs(n);D=d*d-an*an
  98. if D<=0:page('Axis or invalid\nquadrant value');return
  99. c=frac(n,d);s=rootratio(D,d*d,sy)
  100. t=rootratio(D,an*an,st)
  101. ss=frac(d,n);cs=rootratio(d*d,D,sy);ct=rootratio(an*an,D,st)
  102. else:
  103. if f==6:n,d=d,n
  104. if n==0:page('Axis angles need\na separate case.');return
  105. an=abs(n);D=d*d+an*an
  106. t=frac(n,d);ct=frac(d,n)
  107. s=rootratio(an*an,D,sy);c=rootratio(d*d,D,sx)
  108. cs=rootratio(D,an*an,sy);ss=rootratio(D,d*d,sx)
  109. display(s,c,t,cs,ss,ct)
  110. def main():
  111. intro()
  112. while True:
  113. solve()
  114. if input('Again? y/n ').lower()!='y':break
  115. page('DuckieDai (TM)\nhiddenwordscanner.com')
  116. main()
Filename
SIXTRIG.py
Size
3672 bytes
SHA-256
f9153a8b30f72981b4336044863a42c39a39611a01f43b18caec46954f62c192

Usage

Inputs

  • The known function: 1 sin, 2 cos, 3 tan, 4 csc, 5 sec, 6 cot
  • The ratio as a numerator and a denominator, such as -3 and 8
  • The quadrant, 1 to 4
  • y to solve another, anything else to stop

Outputs

  • All six values in exact form, such as cos = -sqrt(55)/8 and tan = 3*sqrt(55)/55
  • A message when the ratio cannot be in the chosen quadrant or the angle is on an axis

Units: Ratios; no units.

Assumptions and limitations

Assumptions

  • The known ratio is typed as a whole-number numerator and denominator, such as -3 and 8 for -3/8.
  • The quadrant sets the signs: x is positive in Quadrants 1 and 4, and y is positive in Quadrants 1 and 2.

Constraints

  • Numerators and denominators can be whole numbers up to 9999.
  • sin and cos must be between -1 and 1, csc and sec at least 1 in size, and the ratio's sign must match the quadrant.

Known failures

  • Angles on an axis, such as sin = 1 or tan = 0, are not solved; the program says they need a separate case.
  • Decimals are not accepted; type 0.6 as 3 and 5.

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 for the owner's original. For publication the program was renamed from TRIGID to SIXTRIG and its title to SIX TRIG VALUES, numbers are limited to 9999 and square roots are simplified a faster way so large ratios do not take minutes, and cot = 0 now says it is an axis angle. Every answer is otherwise unchanged; this exact file has not yet been rerun on a calculator.
Dependencies
No imports
Suggested calculator name
SIXTRIG — 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 SIXTRIG 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.