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
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
- 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.
TI-84 Plus CE Python · screen preview
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
- Choose the function you know by number, 1 sin to 6 cot.
- Enter the ratio as a whole-number numerator and denominator: -3/8 is -3 and 8. Numbers can go up to 9999.
- Enter the quadrant, 1 to 4. The sign of your ratio must match it; the program says so if it does not.
- The program shows sin and cos, then tan and csc, then sec and cot, pressing Enter between them. Type y to solve another.
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
- Draw the triangle first. Put the sides on the axes with their signs, then find the missing side; the signs come straight from the picture.
- r is never negative. A negative ratio means x or y is negative, not r.
- Rationalize at the end: 3/sqrt(55) becomes 3*sqrt(55)/55. The program shows every answer this way.
- Check one answer with sin^2 + cos^2 = 1: 9/64 + 55/64 = 1.
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
# DuckieDai(TM) - Six Trig Values# All six from one ratio and a quadrantdef gcd(a,b):a=abs(a)b=abs(b)while b:a,b=b,a%breturn adef page(s):print(s)input('Enter...')print('\n'*6)def intro():print('DuckieDai (TM)')print('SIX TRIG VALUES')print(' __(o )>')print(' \\ <_. ) QUACK!')print(" `---'")page('hiddenwordscanner.com')def readint(p):while True:try:return int(input(p))except ValueError:print('Whole numbers only')def radical(n):# simplify sqrt(n) into coefficient * sqrt(squarefree)a=1;k=2while k*k<=n:while n%(k*k)==0:n//=k*k;a*=kk+=1return a,ndef rootfrac(n,d,sign):# exact sqrt(n)/sqrt(d), rationalized, n>=0 d>0if n==0:return '0'# sqrt(n*d)/d, simplify common integer factorsg=gcd(n,d);n//=g;d//=g# sqrt(n*d) from sqrt(n) and sqrt(d) separately,# so big numbers stay quick on the calculatora1,r1=radical(n);a2,r2=radical(d)c=gcd(r1,r2);a=a1*a2*c;r=(r1//c)*(r2//c)g=gcd(a,d);a//=g;d//=gpre='-' if sign<0 else ''if r==1:return pre+(str(a) if d==1 else str(a)+'/'+str(d))num=('' if a==1 else str(a)+'*')+'sqrt('+str(r)+')'return pre+num+('' if d==1 else '/'+str(d))def frac(n,d):if d==0:return 'undef'if n==0:return '0'if d<0:n=-n;d=-dg=gcd(abs(n),d);n//=g;d//=greturn str(n) if d==1 else str(n)+'/'+str(d)def rootratio(num,den,sign):# sqrt(num/den), rationalizedreturn rootfrac(num,den,sign)def display(s,c,t,cs,ss,ct):page('sin = '+s+'\ncos = '+c)page('tan = '+t+'\ncsc = '+cs)page('sec = '+ss+'\ncot = '+ct)def solve():print('Known function:')print('1 sin 2 cos')print('3 tan 4 csc')print('5 sec 6 cot')f=readint('Choice? ')if f<1 or f>6:page('Choose 1-6');returnpage('Enter signed fraction\nExample: -3/8\nnum=-3 den=8')n=readint('Numerator? ');d=readint('Denominator? ')if d==0:page('Denominator cannot be 0');returnif d<0:n=-n;d=-dif abs(n)>9999 or d>9999:page('Use whole numbers\nup to 9999');returnif f in (1,2) and abs(n)>d:page('sin/cos must be\nbetween -1 and 1');returnif f in (4,5) and abs(n)<d:page('csc/sec must have\nabsolute value >=1');returnif f in (4,5) and n==0:page('Reciprocal cannot\nbe zero');returnif f==6 and n==0:page('Axis angles need\na separate case.');returnif f==3 and n==0:passprint('Quadrant 1,2,3,4')q=readint('Quadrant? ')if q not in (1,2,3,4):page('Choose 1-4');returnsx=1 if q in (1,4) else -1sy=1 if q in (1,2) else -1st=sx*sy# signs and consistency of inputexpected=(sy,sx,st,sy,sx,st)[f-1]if n!=0 and (1 if n>0 else -1)!=expected:page('Sign does not match\nselected quadrant');returnif n==0 and f in (4,5,6):page('Undefined input');returnif f in (1,4):if f==4:n,d=d,nif n==0:page('Axis angles need\na separate case.');returnan=abs(n);D=d*d-an*anif D<=0:page('Axis or invalid\nquadrant value');returns=frac(n,d);c=rootratio(D,d*d,sx)t=rootratio(an*an,D,st)cs=frac(d,n);ss=rootratio(d*d,D,sx);ct=rootratio(D,an*an,st)elif f in (2,5):if f==5:n,d=d,nif n==0:page('Axis angles need\na separate case.');returnan=abs(n);D=d*d-an*anif D<=0:page('Axis or invalid\nquadrant value');returnc=frac(n,d);s=rootratio(D,d*d,sy)t=rootratio(D,an*an,st)ss=frac(d,n);cs=rootratio(d*d,D,sy);ct=rootratio(an*an,D,st)else:if f==6:n,d=d,nif n==0:page('Axis angles need\na separate case.');returnan=abs(n);D=d*d+an*ant=frac(n,d);ct=frac(d,n)s=rootratio(an*an,D,sy);c=rootratio(d*d,D,sx)cs=rootratio(D,an*an,sy);ss=rootratio(D,d*d,sx)display(s,c,t,cs,ss,ct)def main():intro()while True:solve()if input('Again? y/n ').lower()!='y':breakpage('DuckieDai (TM)\nhiddenwordscanner.com')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
- 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.