Hidden WordScanner
Private scans · No account required

DuckieDai Right Triangle Solver

Solve a right triangle from two sides or a side and an angle: find the missing side, the two acute angles, and all six trig ratios.

trigonometry · MIT License

Overview

Solve a right triangle from two sides or a side and an angle: find the missing side, the two acute angles, and all six trig ratios.

  • Owner-tested on a TI calculator
  • Version 1.0.0
  • 2499 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
  • Opposite and adjacent are named from the angle you are working with; the hypotenuse is the longest side, across from the right angle.
  • Sides must be positive numbers less than 1e50, typed as decimals or fractions such as 3/2.
  • The hypotenuse must be longer than the other known side, and the angle in option 4 must be less than 90 degrees.

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 solve a right triangle with SOHCAHTOA

The idea

In a right triangle, the trig ratios link an acute angle to the sides. Name the sides from that angle: the opposite side is across from it, the adjacent side is next to it, and the hypotenuse is the longest side, across from the right angle.

Two pieces of information are enough to solve the whole triangle: two sides, or a side and an acute angle. The Pythagorean theorem finds a missing side, and an inverse trig function finds a missing angle.

The formula

sin = opp/hyp, cos = adj/hyp, tan = opp/adj

opp^2 + adj^2 = hyp^2

angle = tan^-1(opp/adj)

opp
the side across from the angle
adj
the side next to the angle that is not the hypotenuse
hyp
the hypotenuse, the longest side
SOHCAHTOA
Sine is Opposite over Hypotenuse, Cosine is Adjacent over Hypotenuse, Tangent is Opposite over Adjacent

Using the program

Worked example

A right triangle has legs 3 and 4. Choose 1, then 1 for opposite and adjacent, and enter 3 and 4.

hyp = sqrt(3^2 + 4^2) = sqrt(25) = 5

The program shows Opp = 3, Adj = 4, and Hyp = 5. Choose 3 with the same sides for the ratios: sin = 3/5, cos = 4/5, and tan = 3/4, then csc = 5/3, sec = 5/4, and cot = 4/3.

Choose 2 with the same sides for the angles. The program shows Angle = 36.869898 deg and Other = 53.130102 deg, which add up to 90.

A ladder 10 long leans at 35 degrees to the ground. Choose 4, type 35, then 3 for hypotenuse, and 10. The program shows Opp = 5.735764, the height reached, and Adj = 8.19152, the distance from the wall.

Tips and common mistakes

Where this comes up

Right triangle trigonometry starts in geometry and continues in precalculus, and physics uses it to split forces and velocities into components.

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) - Right Triangle (TI-84 CE Python)
  2. from math import sqrt,atan,pi,sin,cos
  3. def pause():
  4. input('Enter...')
  5. print('\n'*6)
  6. def get(p):
  7. while True:
  8. try:
  9. s=input(p).strip()
  10. if '/' in s:
  11. a,b=s.split('/');v=float(a)/float(b)
  12. else:v=float(s)
  13. if 0<v<1e50:return v
  14. except (ValueError,ZeroDivisionError,OverflowError):pass
  15. print('Positive number only')
  16. def choose(p,hi):
  17. while True:
  18. try:
  19. v=int(input(p))
  20. if 1<=v<=hi:return v
  21. except ValueError:pass
  22. print('Choose 1-',hi)
  23. def fmt(v):
  24. if abs(v-round(v))<1e-9:return str(int(round(v)))
  25. return str(round(v,6))
  26. def gcd(a,b):
  27. while b:a,b=b,a%b
  28. return a
  29. def ratio(a,b):
  30. # Exact fractions for integer-valued sides; decimal otherwise.
  31. if abs(a-round(a))<1e-9 and abs(b-round(b))<1e-9:
  32. n=int(round(a));d=int(round(b));g=gcd(n,d)
  33. return str(n//g) if d//g==1 else str(n//g)+'/'+str(d//g)
  34. return fmt(a/b)
  35. def sides():
  36. print('KNOWN SIDES')
  37. print('1 Opp + Adj')
  38. print('2 Opp + Hyp')
  39. print('3 Adj + Hyp')
  40. k=choose('Choice? ',3)
  41. if k==1:
  42. o=get('Opp? ');a=get('Adj? ')
  43. return o,a,sqrt(o*o+a*a)
  44. if k==2:
  45. o=get('Opp? ');h=get('Hyp? ')
  46. if h<=o:print('Hyp must be larger');pause();return None
  47. return o,sqrt(h*h-o*o),h
  48. a=get('Adj? ');h=get('Hyp? ')
  49. if h<=a:print('Hyp must be larger');pause();return None
  50. return sqrt(h*h-a*a),a,h
  51. def show(o,a,h):
  52. print('Opp =',fmt(o));print('Adj =',fmt(a));print('Hyp =',fmt(h))
  53. def six(o,a,h):
  54. print('sin =',ratio(o,h));print('cos =',ratio(a,h));print('tan =',ratio(o,a));pause()
  55. print('csc =',ratio(h,o));print('sec =',ratio(h,a));print('cot =',ratio(a,o));pause()
  56. def triangle(mode):
  57. t=sides()
  58. if t is None:return
  59. o,a,h=t
  60. print('\n'*5)
  61. if mode==1:
  62. show(o,a,h)
  63. elif mode==2:
  64. angle=atan(o/a)*180/pi
  65. print('Angle =',fmt(angle),'deg')
  66. print('Other =',fmt(90-angle),'deg')
  67. else:
  68. show(o,a,h);pause();six(o,a,h);return
  69. pause()
  70. def side_angle():
  71. t=get('Angle deg? ')
  72. if t>=90:print('Angle must be <90');pause();return
  73. print('Known: 1 Opp 2 Adj 3 Hyp')
  74. k=choose('Choice? ',3);v=get('Length? ')
  75. r=t*pi/180
  76. if k==1:h=v/sin(r)
  77. elif k==2:h=v/cos(r)
  78. else:h=v
  79. print('\n'*5);show(h*sin(r),h*cos(r),h);pause()
  80. def main():
  81. print('RIGHT TRIANGLE')
  82. print('DuckieDai(TM)')
  83. print('hiddenwordscanner.com');pause()
  84. while True:
  85. print('1 Missing side')
  86. print('2 Missing angle')
  87. print('3 All 6 ratios')
  88. print('4 Side + angle')
  89. print('5 Exit')
  90. k=choose('Choice? ',5)
  91. if k==5:return
  92. if k==4:side_angle()
  93. else:triangle(k)
  94. main()
Filename
RTRIG.py
Size
2499 bytes
SHA-256
150d0ca8876e2b255376416f321be2da567340461b114f2b2feae2ad7fb156ab

Usage

Inputs

  • A menu choice: 1 missing side, 2 missing angle, 3 all six ratios, 4 side and angle, 5 exit
  • Which two sides you know: opposite and adjacent, opposite and hypotenuse, or adjacent and hypotenuse
  • Side lengths, and for option 4 an acute angle in degrees and one side

Outputs

  • The opposite, adjacent, and hypotenuse
  • The angle and the other acute angle, in degrees
  • sin, cos, tan, csc, sec, and cot as fractions when the sides are whole numbers, or as decimals

Units: Any one length unit for every side; angles in degrees.

Assumptions and limitations

Assumptions

  • Opposite and adjacent are named from the angle you are working with; the hypotenuse is the longest side, across from the right angle.

Constraints

  • Sides must be positive numbers less than 1e50, typed as decimals or fractions such as 3/2.
  • The hypotenuse must be longer than the other known side, and the angle in option 4 must be less than 90 degrees.

Known failures

  • A ratio with a square-root side, such as the 1, 1, sqrt(2) triangle, is shown as a decimal, 0.707107, not as sqrt(2)/2.
  • With the opposite side known and an extremely small angle, such as 1e-320 degrees, the hypotenuse is too large for the calculator and the program stops 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 before the website line was added to the opening screen. The steps after the opening screen are unchanged; this exact file has not yet been rerun on a calculator.
Dependencies
math
Suggested calculator name
RTRIG — 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 RTRIG 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.