Hidden WordScanner
Private scans · No account required

DuckieDai Law of Sines

Solve a triangle with the law of sines from two angles and a side (AAS or ASA) or from two sides and an angle across from one of them (SSA, the ambiguous case, with both triangles when there are two), and find the area from two sides and the angle between them.

trigonometry · MIT License

Overview

Solve a triangle with the law of sines from two angles and a side (AAS or ASA) or from two sides and an angle across from one of them (SSA, the ambiguous case, with both triangles when there are two), and find the area from two sides and the angle between them.

  • Owner-tested on a TI calculator
  • Downloaded 5 times
  • Version 1.0.0
  • 2460 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
  • Sides are named by the angle across from them: side a is across from angle A, b from B, and c from C.
  • Angles are in degrees.
  • For SSA, the known angle is called A and the side across from it a; the other known side is b or c.

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 triangle with the law of sines, including the ambiguous SSA case

The idea

In any triangle, each side divided by the sine of the angle across from it gives the same number. Once you know one side and the angle across from it, that shared ratio gives every other side from its angle, or every other angle from its side.

Two angles and any side (AAS or ASA) always give exactly one triangle: the third angle is 180 minus the other two. Two sides and an angle across from one of them (SSA) is the ambiguous case: it can give no triangle, one triangle, or two different triangles, because an angle B and 180 - B have the same sine.

The formula

a/sin A = b/sin B = c/sin C

SSA: sin B = b sin A / a, then try B and 180 - B

Area = 1/2 a b sin C (C is the angle between sides a and b)

a, b, c
the sides; side a is across from angle A, b from B, and c from C
A, B, C
the angles in degrees, which add to 180
ambiguous case
SSA, where the given side across from the given angle can swing to two positions

Using the program

Worked example

Two angles and a side: A = 40 degrees, B = 60 degrees, and a = 10. Choose 1, type 40 and 60, press Enter at angle C, then choose 1 for side a and type 10.

C = 180 - 40 - 60 = 80, a/sin A = 10/sin 40 = 15.5572

The program shows C = 180 - others = 80, then b = 13.473 and c = 15.3209.

The ambiguous case: A = 30 degrees, a = 6, and b = 10. Choose 2 and type 30, 6, 1 for side b, and 10. sin B = 10 sin 30 / 6 = 0.8333, so B can be 56.4427 or 180 - 56.4427 = 123.5573 degrees, and both leave room for C.

The program shows 2 triangle(s), then TRIANGLE 1 with C = 93.5573 deg and c = 11.9769, and TRIANGLE 2 with C = 26.4427 deg and c = 5.3436.

The area of a triangle with sides 5 and 7 and a 60 degree angle between them: choose 3 and type 5, 7, and 60. The program shows Area = 1/2 (s1)(s2) sin C = 15.1554 sq units.

Tips and common mistakes

Where this comes up

The law of sines opens the oblique-triangle unit of trigonometry and precalculus, right before the law of cosines. Surveying, navigation, and physics problems with forces at angles use it whenever a triangle has no right angle.

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,asin,pi
  2. def pg():input("[enter]");print("\n"*11)
  3. def f(v):return ("%.4f"%v).rstrip("0").rstrip(".")
  4. def num(m,top=1e7):
  5. while 1:
  6. try:
  7. v=float(input(m))
  8. if 0<v<top:return v
  9. except ValueError:pass
  10. print("Positive number"+(" under 180" if top==180 else ""))
  11. def pk(m,o):
  12. while 1:
  13. s=input(m).strip()
  14. if len(s)==1 and s in o:return int(s)
  15. def S(a):return sin(a*pi/180)
  16. def res(A,B,C,a,b,c):print("A = "+f(A)+" deg\nB = "+f(B)+" deg\nC = "+f(C)+" deg\na = "+f(a)+"\nb = "+f(b)+"\nc = "+f(c))
  17. print("\n"*11+"6.1 LAW OF SINES\n ___(o )> quack!\nDuckieDai (TM)\nhiddenwordscanner.com\na is across from A, etc.");pg()
  18. while 1:
  19. k=pk("1 AAS / ASA (any 2 angles)\n2 SSA (ambiguous)\n3 Area (SAS)\n4 Formulas\n0 Exit\n> ","01234");print("\n"*11)
  20. if k<1:break
  21. if k==1:
  22. print("Type 2 angles.\nPress [enter] for the\nunknown one.");G=[]
  23. for n in"ABC":
  24. while 1:
  25. t=input("Angle "+n+": ").strip()
  26. try:
  27. if t=="" or 0<float(t)<180:G+=[t];break
  28. except ValueError:0
  29. if G.count("")!=1:print("Need exactly 2 angles");pg();continue
  30. u=G.index("");G=[float(t) if t else 0 for t in G];G[u]=180-sum(G);A,B,C=G
  31. i=pk("Known side:\n1 a (across A)\n2 b (across B)\n3 c (across C)\n> ","123");v=num("Length: ")
  32. if G[u]<=0:print("NO TRIANGLE\nangles add to 180+")
  33. else:
  34. s=(S(A),S(B),S(C));r=v/s[i-1];print("ABC"[u]+" = 180 - others = "+f(G[u])+"\na/sinA = b/sinB = c/sinC\n= "+f(r));pg();res(A,B,C,r*s[0],r*s[1],r*s[2])
  35. elif k==2:
  36. print("Need angle A and side a\n(across from A)");A=num("Angle A: ",180);a=num("Side a: ");w=pk("Other side given:\n1 b 2 c\n> ","12");L="BC"[w-1];b=num("Side "+L.lower()+": ")
  37. q=b*S(A)/a;print("sin "+L+" = "+L.lower()+" sinA / a\n = "+f(q))
  38. o=[]
  39. if q<=1+1e-9:
  40. B1=90 if q>1-1e-9 else asin(q)*180/pi
  41. for B in(B1,180-B1):
  42. C=180-A-B
  43. if C>1e-8 and not(o and abs(B-o[0][1])<1e-7):o+=[(A,B,C,a,b,a*S(C)/S(A))]
  44. print("sin "+L+" > 1: NO TRIANGLE" if q>1+1e-9 else str(len(o))+" triangle(s)"+("\n("+L+" and 180-"+L+" both work)" if len(o)>1 else ""));pg()
  45. for t in o:
  46. print("TRIANGLE "+str(o.index(t)+1))
  47. if w>1:t=(t[0],t[2],t[1],t[3],t[5],t[4])
  48. res(*t);pg()
  49. continue
  50. elif k==3:p=num("Side 1: ");q=num("Side 2: ");C=num("Angle BETWEEN them: ",180);print("Area = 1/2 (s1)(s2) sin C\n = "+f(p*q*S(C)/2)+" sq units")
  51. else:print("a/sinA = b/sinB = c/sinC\nSSA: try B and 180-B,\n keep if A+B < 180\nArea = 1/2 ab sin C\n(C between a and b)")
  52. pg()
Filename
SINE61.py
Size
2460 bytes
SHA-256
46d149e9a074074e22ecd8590a531326d5923ad55dfe6b7a60de96408094977c

Usage

Inputs

  • A menu choice: 1 AAS or ASA (two angles and a side), 2 SSA (the ambiguous case), 3 area from two sides and the angle between them, 4 formulas, 0 exit
  • Angles in degrees, leaving the unknown angle empty in choice 1
  • Which side is known, and its length

Outputs

  • All three angles and all three sides of the triangle, with the third angle and the ratio a/sinA shown first
  • For SSA: sin B, then no triangle, one triangle, or both triangles of the ambiguous case
  • The area of a triangle from two sides and the angle between them

Units: Angles in degrees; sides in any one unit, and the area in that unit squared.

Assumptions and limitations

Assumptions

  • Sides are named by the angle across from them: side a is across from angle A, b from B, and c from C.
  • Angles are in degrees.
  • For SSA, the known angle is called A and the side across from it a; the other known side is b or c.

Constraints

  • Angles must be between 0 and 180 degrees, and sides between 0 and 10,000,000.
  • Answers are rounded to 4 decimal places, with trailing zeros removed.

Known failures

  • In choice 1 the side is asked for even when the two angles already add to 180 or more; the program then shows NO TRIANGLE.
  • In SSA, when sin B is at most 1 but no angle fits, as when angle A is obtuse and side a is not the longest, the program shows 0 triangle(s).
  • An angle so small that its sine rounds to 0, such as 1e-320, stops the program with a division-by-zero 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 for the original source. The published file changes one line: in the SSA case, when sin B is within 1e 9 of 1 the angle is taken as exactly 90 degrees, so a right triangle such as A = 30, a = 5, b = 10 is shown once instead of twice. This exact file has not yet been rerun on a calculator.
Dependencies
math
Suggested calculator name
SINE61 — 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 SINE61 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.