Skip to content
This repository
Newer
Older
100644 106 lines (105 sloc) 4.929 kb
b03482a7 » igorT
2011-09-02 New exercise for triangle inequalities
1 <!DOCTYPE html>
2 <html data-require="math graphie graphie-helpers math-format graphie-geometry">
3 <head>
4 <meta charset="UTF-8" />
5 <title>Triangle Inequality Theorem</title>
6 <script src="../khan-exercise.js"></script>
7 <script>
8 function randomTriangleWithSides(){
9 var a = KhanUtil.randRange( 25, 150 );
10 var b = KhanUtil.randRange( 25, 180 - a );
11 if ( a + b > 170 ){
12 a = Math.max( 30, a - 15 );
13 b = Math.max( 30, b - 15 );
14 }
15 var c = 180 - a - b;
16 var sa = KhanUtil.randRange( 4, 8 );
17 var sb = sa * Math.sin( b * Math.PI / 180 ) / Math.sin( a * Math.PI / 180 );
18 var sc = sa * Math.sin( c * Math.PI / 180 ) / Math.sin( a * Math.PI / 180 );
19 return [ [ a, b, c] , [ sa.toFixed( 1 ), sb.toFixed( 1 ), sc.toFixed( 1 ) ] ];
20 }
21 </script>
22 </head>
23 <body>
24 <div class="exercise">
25 <div class="vars">
26 <var id="MAIN">randomTriangleWithSides()</var>
27 <var id="HIDDEN">rand( 3 )</var>
28 <var id="ANSWER">MAIN[ 1 ][ HIDDEN ]</var>
29 <var id="KNOWN">MAIN[ 1 ].slice( 0, HIDDEN ).concat( MAIN[ 1 ].slice( HIDDEN + 1 ) )</var>
92d6acdc » igorT
2011-09-17 fix #2801
30 <var id="MAX">( parseFloat( KNOWN[ 0 ] ) + parseFloat( KNOWN[ 1 ] ) ).toFixed( 1 )</var>
b03482a7 » igorT
2011-09-02 New exercise for triangle inequalities
31 <var id="MIN">Math.abs( KNOWN[ 0 ] - KNOWN[ 1 ] ).toFixed( 1 )</var>
32 </div>
33
34 <div class="problems">
35 <div id="range">
36 <div class="problem">
26b0aff0 » igorT
2011-09-13 triangle inequality exercise finished
37 What is the range of possible sizes for side x?
b03482a7 » igorT
2011-09-02 New exercise for triangle inequalities
38 </div>
39 <div class="question">
40 <div class="graphie">
41 init({
4dbb802e » igorT
2011-09-16 polish of geometry
42 range: [ [ -1, 10 ], [ -7.5, 1 ] ]
b03482a7 » igorT
2011-09-02 New exercise for triangle inequalities
43 })
cef3c713 » igorT
2011-09-15 made angle marking appear in similar triangles
44 var tr = new Triangle( [ 3, -6.5 ], MAIN[ 0 ], 5, { "c" : HIDDEN !== 2 ? MAIN[ 1 ][ 2 ] : "x" , "a" : HIDDEN !== 0 ? MAIN[ 1 ][ 0 ] : "x" , "b" : HIDDEN !== 1 ? MAIN[ 1 ][ 1 ] : "x" } );
4dbb802e » igorT
2011-09-16 polish of geometry
45 tr.boxOut( [ [ [ -1, -10 ], [ -1, 10 ] ] ], [ 1, 0 ] );
46 tr.boxOut( [ [ [ 10, -10 ], [ 10, 10 ] ] ], [ -1, 0 ] );
b03482a7 » igorT
2011-09-02 New exercise for triangle inequalities
47 tr.draw();
48 tr.drawLabels();
49 </div>
50 </div>
51 <div class="solution" data-type="multiple">
52 <p>Maximum = <span class="sol"><var>MAX</var></span></p>
53 <p>Minimum = <span class="sol"><var>MIN</var></span></p>
54 </div>
55 <div class="hints">
56 <p>Triangle inequality theorem states that a side cannot be larger than the sum of the other two sides.</p>
26b0aff0 » igorT
2011-09-13 triangle inequality exercise finished
57 <p>Therefore the the third side cannot be larger than <code><var>KNOWN[ 0 ]</var> + <var>KNOWN[ 1 ]</var> = <var>MAX</var></code></p>
58 <p>By the same theorem, the side can also not be smaller than the difference between the two sides.<p>
59 <p>Therefore the third side cannot be smaller than <code>| <var>KNOWN[ 0 ]</var> - <var>KNOWN[ 1 ]</var> | = <var>MIN</var></code></p>
b03482a7 » igorT
2011-09-02 New exercise for triangle inequalities
60 </div>
61 </div>
cef3c713 » igorT
2011-09-15 made angle marking appear in similar triangles
62 <div id="possible">
26b0aff0 » igorT
2011-09-13 triangle inequality exercise finished
63 <div class="vars">
64 <var id="MAIN">randomTriangleWithSides()</var>
65 <var id="POSSIBLE">( randRange( 0, 1 ) === 0 )</var>
cef3c713 » igorT
2011-09-15 made angle marking appear in similar triangles
66 </div>
b03482a7 » igorT
2011-09-02 New exercise for triangle inequalities
67 <div class="problem">
26b0aff0 » igorT
2011-09-13 triangle inequality exercise finished
68 Can this triangle exist?
b03482a7 » igorT
2011-09-02 New exercise for triangle inequalities
69 </div>
70 <div class="question">
71 <div class="graphie">
72 init({
4dbb802e » igorT
2011-09-16 polish of geometry
73 range: [ [-1, 10 ], [ -7.5, 1 ] ]
b03482a7 » igorT
2011-09-02 New exercise for triangle inequalities
74 })
26b0aff0 » igorT
2011-09-13 triangle inequality exercise finished
75 if( !POSSIBLE ){
76 var side = randRange( 0, 2 );
4dbb802e » igorT
2011-09-16 polish of geometry
77 var sideValue = ( parseFloat( MAIN[ 1 ][ ( side + 1 ) % 3 ] ) + parseFloat( MAIN[ 1 ][ ( side + 2 ) % 3 ] ) + randRange( 1, 3 ) ).toFixed( 1 );
26b0aff0 » igorT
2011-09-13 triangle inequality exercise finished
78 MAIN[ 1 ][ side ] = sideValue;
79 }
4dbb802e » igorT
2011-09-16 polish of geometry
80 var tr = new Triangle( [ 3, -6.9 ], MAIN[ 0 ], 5, { "c" : MAIN[ 1 ][ 2 ], "a" : MAIN[ 1 ][ 0 ] , "b" : MAIN[ 1 ][ 1 ] } );
81 tr.boxOut( [ [ [ -1, -10 ], [ -1, 10 ] ] ], [ 1, 0 ] );
82 tr.boxOut( [ [ [ 10, -10 ], [ 10, 10 ] ] ], [ -1, 0 ] );
b03482a7 » igorT
2011-09-02 New exercise for triangle inequalities
83 tr.draw();
84 tr.drawLabels();
85 </div>
86 </div>
26b0aff0 » igorT
2011-09-13 triangle inequality exercise finished
87 <div class="solution"><var>POSSIBLE ? "Yes" : "No"</var></div>
88 <ul class="choices" data-category="true">
89 <li>Yes</li>
90 <li>No</li>
91 </ul>
b03482a7 » igorT
2011-09-02 New exercise for triangle inequalities
92 <div class="hints">
26b0aff0 » igorT
2011-09-13 triangle inequality exercise finished
93 <p>Triangle inequality theorem states that a side must be smaller than the sum of the other two sides.</p>
94 <p>Lets check for all three sides:</p>
95 <div data-each="MAIN[ 1 ] as i, v">
96 <p><code><var>MAIN[ 1 ][ i ]</var> + <var>MAIN[ 1 ][ ( i + 1 ) % 3 ]</var> = <var>( parseFloat( MAIN[ 1 ][ i ] ) + parseFloat( MAIN[ 1 ][ ( i + 1 ) % 3 ] ) ).toFixed( 1 )</var></code></p>
97 <p><code><var>MAIN[ 1 ][ ( i + 2 ) % 3 ]</var></code> is <span data-if="parseFloat( MAIN[ 1 ][ ( i + 2 ) % 3 ] ) >= ( parseFloat( MAIN[ 1 ][ i ] ) + parseFloat( MAIN[ 1 ][ ( i + 1 ) % 3 ] ) ) ">not</span> smaller than <var>( parseFloat( MAIN[ 1 ][ i ] ) + parseFloat( MAIN[ 1 ][ ( i + 1 ) % 3 ] ) ).toFixed( 1 )</var></code> so the theorem <span data-if="parseFloat( MAIN[ 1 ][ ( i + 2 ) % 3 ] ) >= ( parseFloat( MAIN[ 1 ][ i ] ) + parseFloat( MAIN[ 1 ][ ( i + 1 ) % 3 ] ) )">does not hold</span><span data-else>holds</span>.</p>
98 </div>
99 <p data-if="POSSIBLE">All three sides conform to the inequality theorem, so this triangle can exist.</p>
100 <p data-else>Not all three sides conform to the inequality theorem, so this triangle cannot exist.</p>
b03482a7 » igorT
2011-09-02 New exercise for triangle inequalities
101 </div>
102 </div>
103 </div>
8531c068 » spicyj
2011-09-03 triangle_inequality fixes
104 </div>
b03482a7 » igorT
2011-09-02 New exercise for triangle inequalities
105 </body>
106 </html>
Something went wrong with that request. Please try again.