Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 113 lines (111 sloc) 6.555 kb
b03482a Igor Terzic New exercise for triangle inequalities
igorT authored
1 <!DOCTYPE html>
2 <html data-require="math graphie graphie-helpers math-format graphie-geometry">
3 <head>
4e4cb9b Ben Eater lint: tabs->spaces and jQuery->$ for exercises
beneater authored
4 <meta http-equiv="Content-Type" content="text/html; 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>
064281e Ben Eater Fix up exercises that are too wide for tutorials
beneater authored
22 <style type="text/css">
23 #answer_area input[type=text] {
24 width: 40px;
25 }
26 </style>
b03482a Igor Terzic New exercise for triangle inequalities
igorT authored
27 </head>
28 <body>
4e4cb9b Ben Eater lint: tabs->spaces and jQuery->$ for exercises
beneater authored
29 <div class="exercise">
30 <div class="vars">
31 <var id="MAIN">randomTriangleWithSides()</var>
32 <var id="HIDDEN">rand( 3 )</var>
33 <var id="ANSWER">MAIN[ 1 ][ HIDDEN ]</var>
34 <var id="KNOWN">MAIN[ 1 ].slice( 0, HIDDEN ).concat( MAIN[ 1 ].slice( HIDDEN + 1 ) )</var>
35 <var id="MAX">roundTo( 1, parseFloat( KNOWN[ 0 ] ) + parseFloat( KNOWN[ 1 ] ) )</var>
36 <var id="MIN">roundTo( 1, abs( KNOWN[ 0 ] - KNOWN[ 1 ] ) )</var>
37 </div>
b03482a Igor Terzic New exercise for triangle inequalities
igorT authored
38
4e4cb9b Ben Eater lint: tabs->spaces and jQuery->$ for exercises
beneater authored
39 <div class="problems">
40 <div id="range">
41 <div class="problem">
42 What is the range of possible sizes for side x?
43 </div>
44 <div class="question">
45 <div class="graphie">
46 init({
47 range: [ [ -1, 10 ], [ -7.5, 1 ] ]
48 })
49 var tr = new Triangle( [ 3, -6.5 ], MAIN[ 0 ], 5, { "sides" : [ HIDDEN !== 2 ? MAIN[ 1 ][ 2 ] : "x", HIDDEN !== 0 ? MAIN[ 1 ][ 0 ] : "x", HIDDEN !== 1 ? MAIN[ 1 ][ 1 ] : "x" ] } );
50 tr.boxOut( [ [ [ -1, -10 ], [ -1, 10 ] ] ], [ 1, 0 ] );
51 tr.boxOut( [ [ [ 10, -10 ], [ 10, 10 ] ] ], [ -1, 0 ] );
52 tr.draw();
53 tr.drawLabels();
54 </div>
55 </div>
56 <div class="solution" data-type="multiple">
57 <p><span class="sol"><var>MIN</var></span> <code>&lt; x &lt;</code> <span class="sol"><var>MAX</var></span></p>
58 <span class="example">two <em>exact</em> decimals, like <code>0.75</code></span>
59 </div>
60 <div class="hints">
61 <p>The triangle inequality theorem states that any side of a triangle is always shorter than the sum of the other two sides.</p>
62 <p>Therefore the the third side must be less than <code><var>KNOWN[ 0 ]</var> + <var>KNOWN[ 1 ]</var> = <var>MAX</var></code></p>
63 <p>By the same theorem, the third side must be also larger than the difference between the other two sides.</p>
64 <p>Therefore the third side must be larger than <code><var>KNOWN[0] &lt; KNOWN[1] ? KNOWN[1] : KNOWN[0]</var> - <var>KNOWN[0] &lt; KNOWN[1] ? KNOWN[0] : KNOWN[1]</var> = <var>MIN</var></code></p>
65 <p>So <code><var>MIN</var> &lt; x &lt; <var>MAX</var></code></p>
66 </div>
67 </div>
68 <div id="possible">
69 <div class="vars">
70 <var id="MAIN">randomTriangleWithSides()</var>
71 <var id="POSSIBLE">( randRange( 0, 1 ) === 0 )</var>
72 </div>
73 <div class="problem">
74 Can this triangle exist?
75 </div>
76 <div class="question">
77 <div class="graphie">
78 init({
79 range: [ [-1, 10 ], [ -7.5, 1 ] ]
80 })
81 if( !POSSIBLE ){
82 var side = randRange( 0, 2 );
83 var sideValue = ( parseFloat( MAIN[ 1 ][ ( side + 1 ) % 3 ] ) + parseFloat( MAIN[ 1 ][ ( side + 2 ) % 3 ] ) + randRange( 1, 3 ) ).toFixed( 1 );
84 MAIN[ 1 ][ side ] = sideValue;
85 }
86 var tr = new Triangle( [ 3, -6.9 ], MAIN[ 0 ], 5, { "sides" : [ MAIN[ 1 ][ 2 ], MAIN[ 1 ][ 0 ], MAIN[ 1 ][ 1 ] ] } );
87 tr.boxOut( [ [ [ -1, -10 ], [ -1, 10 ] ] ], [ 1, 0 ] );
88 tr.boxOut( [ [ [ 10, -10 ], [ 10, 10 ] ] ], [ -1, 0 ] );
89 tr.draw();
90 tr.drawLabels();
91 </div>
92 </div>
93 <div class="solution"><var>POSSIBLE ? "Yes" : "No"</var></div>
94 <ul class="choices" data-category="true">
95 <li>Yes</li>
96 <li>No</li>
97 </ul>
98 <div class="hints">
99 <p>Triangle inequality theorem states that a side must be smaller than the sum of the other two sides.</p>
100 <p>Let's check for all three sides:</p>
101 <div data-each="MAIN[ 1 ] as i, v">
102 <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>
103 <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 <code><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>
104 </div>
105 <p data-if="POSSIBLE">All three sides conform to the inequality theorem, so this triangle can exist.</p>
106 <p data-else>Not all three sides conform to the inequality theorem, so this triangle cannot exist.</p>
107 </div>
108 </div>
109 </div>
110 </div>
b03482a Igor Terzic New exercise for triangle inequalities
igorT authored
111 </body>
112 </html>
Something went wrong with that request. Please try again.