Skip to content

Commit 0c3899b

Browse files
authored
Merge pull request #1157 from gajennings/main
Fix bug 4829
2 parents 001fb83 + f8ff55e commit 0c3899b

File tree

1 file changed

+40
-23
lines changed

1 file changed

+40
-23
lines changed

OpenProblemLibrary/PCC/BasicAlgebra/Geometry/TrianglePerimeterArea30.pg

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,31 @@ $ymax = 40;
4242
$xLabelShift = $xmax/40;
4343
$yLabelShift = $ymax/40;
4444

45-
$height = random(20,30,1);
46-
$rightSide = $height + random(2,4,1);
47-
$bigbase = round(sqrt($rightSide**2 - $height**2))+random(10,15,1);
48-
$base = $bigbase - round(sqrt($rightSide**2 - $height**2));
49-
$leftSide = round(sqrt($bigbase**2 + $height**2));
45+
# We want a triangle with integer sides and approximate
46+
# integer height so one can approximate its
47+
# area = (1/2)base*height using these numbers
48+
49+
# Make the sides of the triangle integers
50+
51+
$roughheight = random(20,30,1);
52+
$rightSide = $roughheight + random(2,4,1);
53+
$base = random(10,15,1);
54+
$offset = round(sqrt($rightSide**2 - $roughheight**2));
55+
$bigbase = $base + $offset;
56+
$leftSide = round(sqrt($bigbase**2 + $roughheight**2));
57+
58+
# get the exact area from Heron's formula
59+
60+
$perimeter = $base + $leftSide + $rightSide;
61+
$s = $perimeter/2;
62+
$area = sqrt($s*($s-$leftSide)*($s-$rightSide)*($s-$base));
63+
64+
# approximate the height to the nearest integer
65+
$height = round(2*$area/$base);
66+
67+
# with this approximation the max error in the
68+
# area = base*height/2 formula is
69+
# about (delta height)/height < 0.5/20 = 2.25 %
5070

5171
@x = (($xmax-2*$base)/2,($xmax+2*$base)/2);
5272
@y = (($ymax-$height)/2,($ymax+$height)/2);
@@ -76,32 +96,27 @@ $picture->moveTo($x[0]+$bigbase,$y[0]+$cornersize);
7696
$picture->lineTo($x[0]+$bigbase-$cornersize,$y[0]+$cornersize, darkblue,3);
7797
$picture->lineTo($x[0]+$bigbase-$cornersize,$y[0], darkblue,3);
7898

79-
$perimeter = $base + $leftSide + $rightSide;
80-
$area = $base*$height/2;
99+
$approxarea = $base*$height/2;
81100
$ansP = NumberWithUnits($perimeter,"m");
82-
$ansA = NumberWithUnits($area,"m^2");
101+
$ansA = NumberWithUnits($approxarea,"m^2");
102+
103+
104+
$text = "an obtuse triangle with sides of lengths $base m, $rightSide m, and $leftSide m; its height perpendicular to the side of length $base m is approximately equal to $height m (rounded to the nearest meter).";
83105

84106

85107

86108
##############################################
87109

88-
TEXT(beginproblem());
89110
$refreshCachedImages = 1;
90111

91-
$text = "an obtuse triangle with legs of lengths $base m, $rightSide m, and $leftSide m; its height perpendicular to the side of length $base m is $height m";
92-
93-
BEGIN_TEXT
112+
BEGIN_PGML
94113

95-
Find the perimeter and area of the triangle.$PAR
114+
Find the perimeter (exactly) and area (approximately) of the triangle.
96115

97-
$BCENTER
98-
\{ image(insertGraph( $picture ), tex_size=>400, height=>400, width=>400, extra_html_tags => 'alt = "$text" title = "$text"') \}
99-
$ECENTER
100-
$PAR
101-
END_TEXT
102-
BEGIN_PGML
116+
The height is rounded off to the nearest meter, so if you use it to compute the area your result will only be correct to within 2 or 3 percent of the true area.
117+
>>[@ image(insertGraph( $picture ), tex_size=>400, height=>400, width=>400, extra_html_tags => 'alt = "$text" title = "$text"') @]* <<
103118

104-
Its perimeter is [_____________]{$ansP} and its area is [_____________]{$ansA}.
119+
Its perimeter is [_____________]{$ansP} and its area is [_____________]{$ansA->cmp(tolerance=>0.03,tolType=>'relative')} [`\pm 3 \%`].
105120

106121
(Use *m* for meters and *m[$CARET]2* for square meters.)
107122

@@ -124,16 +139,18 @@ A triangle's area formula is:
124139

125140
[`` \text{triangle area} = \frac{1}{2} \cdot \text{base} \cdot \text{height} ``]
126141

127-
Using this formula, we have:
142+
Using this formula with the approximate height, we have:
128143

129144
[``\begin{aligned}
130145
\text{triangle area} &= \frac{1}{2} \cdot \text{base} \cdot \text{height}\\
131-
& =\frac{1}{2} \cdot [$base] \cdot [$height] \\
132-
& =[$ansA]
146+
& \approx\frac{1}{2} \cdot [$base] \cdot [$height] \pm 3 \%\\
147+
& \approx[$ansA] \pm 3 \%
133148
\end{aligned}``]
134149

135150
Don't forget the area unit [`\textrm{m}^{2}`].
136151

152+
There are other ways to compute the area. One, called *Heron's formula*, uses only the lengths of the sides so it gives an exact result if one knows the side lengths exactly, as we do in this problem. You may look up Heron's formula on the internet or in a geometry textbook. Heron's formula says the area is about [`[$area] \text{ m}^2`].
153+
137154
END_PGML_SOLUTION
138155

139156
ENDDOCUMENT();

0 commit comments

Comments
 (0)