Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions source/precalculus/exercises/bank.xml
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@
Use trigonometric functions and the Pythagorean Theorem to solve right triangles.
</description>
</outcome>
<!--
<outcome>
<title>Trigonometric Laws</title>
<slug>TE5</slug>
Expand All @@ -438,7 +437,7 @@
Use the law of sines and/or the law of cosines to solve non-right triangles.
</description>
</outcome>

<!--
<outcome>
<title>Applications of Trigonometry</title>
<slug>TE6</slug>
Expand Down
133 changes: 133 additions & 0 deletions source/precalculus/exercises/outcomes/TE/TE5/generator.sage
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
load("../../../source/common/sagemath/library.sage")
class Generator(BaseGenerator):
def data(self):

tasks=[]

#Law of cosines
if choice([True,False]):
#SSS
sides = sample([5..15],2)
sides.append(choice([abs(sides[1]-sides[0])+1,sides[0]+sides[1]-1]))
shuffle(sides)
a,b,c=sides
C=round(arccos((a^2+b^2-c^2)/(2*a*b))*180/pi,1)
B=round(arccos((a^2+c^2-b^2)/(2*a*c))*180/pi,1)
A=round(arccos((b^2+c^2-a^2)/(2*b*c))*180/pi,1)
given=[f"a={latex(a)}",f"b={latex(b)}",f"c={latex(c)}"]
found=[f"A={latex(A)}^\\circ",f"B={latex(B)}^\\circ",f"C={latex(C)}^\\circ"]
else:
#SAS
sides = sample([5..15],2)
sides.sort()
angle=choice([10,15,..,80])*pi/180
sides.append(sqrt(sides[0]^2+sides[1]^2-2*sides[0]*sides[1]*cos(angle)))
angles = [ round(arcsin(sides[0]*sin(angle)/sides[2])*180/pi,1) ]
angles.append(round(180-angles[0]-angle*180/pi,1))
angles.append(angle*180/pi)

labels=[("a","A"),("b","B"),("c","C")]
shuffle(labels)
given = [f"{labels[0][0]}={sides[0]}",
f"{labels[1][0]}={sides[1]}",
f"{labels[2][1]}={angles[2]}^\\circ"]
found = [f"{labels[0][1]}={angles[0]}^\\circ",
f"{labels[1][1]}={angles[1]}^\\circ",
f"{labels[2][0]}={round(sides[2],1)}"]
shuffle(given)

tasks.append({"given": ",".join(given[:-1])+r",\text{ and }"+given[-1],
"found": ",".join(found[:-1])+r",\text{ and }"+found[-1],
})

#Law of sines
angles=[a*pi/180 for a in sample([10,15,..,80],2)]
angles.append(pi-angles[0]-angles[1])
sides=[choice([5..15])]
sides.extend([round(sides[0]/sin(angles[0])*sin(angles[i]),1) for i in [1,2]])
labels=[("a","A"),("b","B"),("c","C")]
shuffle(labels)
if choice([True,False]):
#AAS
given = [f"{labels[0][1]}={angles[0]*180/pi}^\\circ",
f"{labels[1][1]}={angles[1]*180/pi}^\\circ",
f"{labels[0][0]}={sides[0]}"
]
found = [f"{labels[1][0]}={sides[1]}",
f"{labels[2][0]}={sides[2]}",
f"{labels[2][1]}={angles[2]*180/pi}^\\circ"
]
else:
#ASA
given = [f"{labels[2][1]}={angles[2]*180/pi}^\\circ",
f"{labels[1][1]}={angles[1]*180/pi}^\\circ",
f"{labels[0][0]}={sides[0]}"
]
found = [f"{labels[1][0]}={sides[1]}",
f"{labels[2][0]}={sides[2]}",
f"{labels[0][1]}={angles[0]*180/pi}^\\circ"
]

shuffle(given)
tasks.append({"given": ",".join(given[:-1])+r",\text{ and }"+given[-1],
"found": ",".join(found[:-1])+r",\text{ and }"+found[-1],
})


#Ambiguous case
angles=[choice([10,15,..,70])*pi/180]
#If A is too big and b is too short, no integer values for a work
minb=int(2/(1-sin(angles[0])))+1
b=choice([max(5,minb),..,max(15,minb+5)])
labels=[("a","A"),("b","B"),("c","C")]
shuffle(labels)
if choice([True,False]):
#Two solutions
a=choice([floor(b*sin(angles[0]))+1..b-1])
sides=[a,b]
B=arcsin(sides[1]/sides[0]*sin(angles[0]))
angles1=[angles[0],B,pi-angles[0]-B]
angles2=[angles[0],pi-B,B-angles[0]]
sides1=sides+[round(sqrt(sides[0]^2+sides[1]^2-2*sides[0]*sides[1]*cos(angles1[2])),1)]
sides2=sides+[round(sqrt(sides[0]^2+sides[1]^2-2*sides[0]*sides[1]*cos(angles2[2])),1)]
given = [f"{labels[0][1]}={angles[0]*180/pi}^\\circ",
f"{labels[0][0]}={sides[0]}",
f"{labels[1][0]}={sides[1]}"
]
found1= [f"{labels[2][0]}={sides1[2]}",
f"{labels[1][1]}={round(angles1[1]*180/pi,1)}^\\circ",
f"{labels[2][1]}={round(angles1[2]*180/pi,1)}^\\circ"
]
found2= [f"{labels[2][0]}={sides2[2]}",
f"{labels[1][1]}={round(angles2[1]*180/pi,1)}^\\circ",
f"{labels[2][1]}={round(angles2[2]*180/pi,1)}^\\circ"
]
found=r"\text{There are two possiblities: }"+",".join(found1[:-1])+r",\text{ and }"+found1[-1] + r"\text{ or }" + \
",".join(found2[:-1])+r",\text{ and }"+found2[-1]

else:
#One solution
a=b+choice([2..10])
sides=[a,b]
angles.append(arcsin(sides[1]/sides[0]*sin(angles[0])))
angles.append(pi-angles[0]-angles[1])
sides.append(round(sqrt(sides[0]^2+sides[1]^2-2*sides[0]*sides[1]*cos(angles[2])),1))
given = [f"{labels[0][1]}={angles[0]*180/pi}^\\circ",
f"{labels[0][0]}={sides[0]}",
f"{labels[1][0]}={sides[1]}"
]
found = [f"{labels[2][0]}={sides[2]}",
f"{labels[1][1]}={round(angles[1]*180/pi,1)}^\\circ",
f"{labels[2][1]}={round(angles[2]*180/pi,1)}^\\circ"
]
found=",".join(found[:-1])+r",\text{ and }"+found[-1]

shuffle(given)
tasks.append({"given": ",".join(given[:-1])+r",\text{ and }"+given[-1],
"found": found
})


shuffle(tasks)
return { "tasks": tasks,
}
19 changes: 19 additions & 0 deletions source/precalculus/exercises/outcomes/TE/TE5/template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<knowl mode="exercise" xmlns="https://spatext.clontz.org" version="0.2">
<intro>
<p>Solve each of the following triangles. State whether you used the law of sines
or the law of cosines and explain your choice. In the case where there may be two
solutions, give sufficient work/explanation to show that you checked for that
possibility and give both solutions when appropriate.
</p>
</intro>
{{#tasks}}
<knowl>
<content>
<p>In triangle <m>ABC</m>, <m>{{given}}.</m> Solve the triangle, i.e. find all remaining sides and angles.</p>
</content>
<outtro>
<p><m>{{found}}</m></p>
</outtro>
</knowl>
{{/tasks}}
</knowl>