Rev 6133 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6133 | Rev 11003 | ||
---|---|---|---|
Line 16... | Line 16... | ||
16 | \integer{x=random(-10..10)} |
16 | \integer{x=random(-10..10)} |
17 | \integer{y=random(-10..10)} |
17 | \integer{y=random(-10..10)} |
18 | \real{norm=sqrt((\x)^2+(\y)^2)} |
18 | \real{norm=sqrt((\x)^2+(\y)^2)} |
19 | \statement{What is the length of the vector (\x,\y) in R<sup>2</sup>?} |
19 | \statement{What is the length of the vector (\x,\y) in R<sup>2</sup>?} |
20 | 20 | ||
21 | \hint{The length of a vector (x,y) is equal to |
21 | \hint{The length of a vector (x,y) is equal to |
22 | sqrt(x^2+y^2).} |
22 | sqrt(x^2+y^2).} |
23 | \answer{The length}{\norm} |
23 | \answer{The length}{\norm} |
24 | </pre> |
24 | </pre> |
25 | 25 | ||
26 | In this exercise, one has defined 2 random integers, x et y, who are the |
26 | In this exercise, one has defined 2 random integers, x et y, who are the |
Line 35... | Line 35... | ||
35 | to test it. (You can also copy the source into the menu under raw mode.) |
35 | to test it. (You can also copy the source into the menu under raw mode.) |
36 | 36 | ||
37 | 37 | ||
38 | </li><li> <hr style="width:50%"/> |
38 | </li><li> <hr style="width:50%"/> |
39 | <b>Trace of matrix 2x2</b>, computes the trace of a matrix. The question |
39 | <b>Trace of matrix 2x2</b>, computes the trace of a matrix. The question |
40 | is formatted by TeX, for a better presentation of the matrix. Here is |
40 | is formatted by TeX, for a better presentation of the matrix. Here is |
41 | the complete source of the exercise. |
41 | the complete source of the exercise. |
42 | <pre> |
42 | <pre> |
43 | \title{Trace of matrix 2x2} |
43 | \title{Trace of matrix 2x2} |
44 | \language{en} |
44 | \language{en} |
45 | \computeanswer{yes} |
45 | \computeanswer{yes} |
46 | \format{ |
46 | \format{html} |
47 | 47 | ||
48 | \integer{range=20} |
48 | \integer{range=20} |
49 | \integer{a=random(-\range..\range)} |
49 | \integer{a=random(-\range..\range)} |
50 | \integer{b=random(-\range..\range)} |
50 | \integer{b=random(-\range..\range)} |
51 | \integer{c=random(-\range..\range)} |
51 | \integer{c=random(-\range..\range)} |
52 | \integer{d=random(-\range..\range)} |
52 | \integer{d=random(-\range..\range)} |
53 | \integer{trace=(\a)+(\d)} |
53 | \integer{trace=(\a)+(\d)} |
54 | \statement{Compute the trace of the matrix |
54 | \statement{Compute the trace of the matrix |
55 |
|
55 | \([\a,\b;\c,\d]\).} |
56 | 56 | ||
57 | \answer{The trace}{\trace} |
57 | \answer{The trace}{\trace} |
58 | </pre> |
58 | </pre> |
59 | We have first defined an integer ``range'', to be used to bound the |
59 | We have first defined an integer ``range'', to be used to bound the |
60 | random values a,b,c,d which are the elements of the matrix. And the trace is |
60 | random values a,b,c,d which are the elements of the matrix. And the trace is |
61 | of course defined by the sum of the elements on the diagonal. Please take |
61 | of course defined by the sum of the elements on the diagonal. Please take |
62 | care to the definition <span class="tt">trace=(\a)+(\d)</span>: the pairs of parentheses |
62 | care to the definition <span class="tt">trace=(\a)+(\d)</span>: the pairs of parentheses |
63 | are necessary, for the substitution is literary. If you define |
63 | are necessary, for the substitution is literary. If you define |
64 | <span class="tt">trace=\a+\d</span> and if a and d take the values of 3 and -15 respectively, |
64 | <span class="tt">trace=\a+\d</span> and if a and d take the values of 3 and -15 respectively, |
65 | you woule have <span class="tt">trace=3+-15</span>, a bad mathematical expression. <p> |
65 | you woule have <span class="tt">trace=3+-15</span>, a bad mathematical expression. <p> |
66 | Remark that in this exercise, the non-computed replies are admitted |
66 | Remark that in this exercise, the non-computed replies are admitted |
67 | (such as 2+15 or 3*105). <p> |
67 | (such as 2+15 or 3*105). <p> |
68 | You can |
68 | You can |
69 | !set parm=oef_answercnt=1&oef_choicecnt=0&oef_title=Trace of matrix 2x2&oef_format= |
69 | !set parm=oef_answercnt=1&oef_choicecnt=0&oef_title=Trace of matrix 2x2&oef_format=html&oef_computeanswer=yes&level=2&oef_parms=%5Cinteger%7Brange%3D20%7D%0D%0A%5Cinteger%7Ba%3Drandom%28-%5Crange..%5Crange%29%7D%0D%0A%5Cinteger%7Bb%3Drandom%28-%5Crange..%5Crange%29%7D%0D%0A%5Cinteger%7Bc%3Drandom%28-%5Crange..%5Crange%29%7D%0D%0A%5Cinteger%7Bd%3Drandom%28-%5Crange..%5Crange%29%7D%0D%0A%5Cinteger%7Btrace%3D%28%5Ca%29%2B%28%5Cd%29%7D&oef_statement=Compute the trace of the matrix \\([\a,\b;\c,\d]\\).&ansprompt1=The trace&ansgood1=%5Ctrace&oef_hint= &oef_solution= $ |
70 | !href cmd=reply&mode=guided&$parm load this example into the menu |
70 | !href cmd=reply&mode=guided&$parm load this example into the menu |
71 | to test it. (You can also copy the source into the menu under raw mode.) |
71 | to test it. (You can also copy the source into the menu under raw mode.) |
72 | 72 | ||
73 | </li> |
73 | </li> |
74 | </ol> |
74 | </ol> |