======================================================================== Mathematica Packages for use with the book "Experiments in Undergraduate Mathematics: A Mathematica-based approach" INFORMATION ON PRACTICE QUESTIONS ======================================================================== (C) Copyright Imperial College of Science, Technology and Medicine, 1996. URL for this document: http://metric.ma.ic.ac.uk/PracticeQuestions.html ---------------------- 1. How to do Practice Questions =============================== A question class is specified by a quoted name defining a small proficiency domain, e.g. "expand and simplify". A randomized question from this class is called by the command GiveQuestion["expand and simplify"] The answer to the most recent question from this class is called by the command LastAnswer["expand and simplify"] 2. How to write Practice Questions ================================== A question class consists of five elements: (i) a question template; (ii) an answer template; (iii) a list of parameter sets; (iv) a question function; (v) an answer function. (i) The question template consists of a string, which defines the form of a question from this class. For example: QuestionTemplate["expand and simplify"] = "Expand the expression `1` and simplify fully."; In this example, there is one placeholder, marked `1`. This marks the place into which a randomized insertion can be put. Further placeholders should be marked `2`, `3`, etc. There should be as many placeholders as there are to be randomized insertions. (ii) The answer template is similarly defined. For example: AnswerTemplate["expand and simplify"] = "The expanded and simplified expression is `1`"; (iii) Each parameter set is specified as a list, and the collection of them is therefore a list of lists. A parameter set may take one of three forms: * a list containing an argument set for the native Mathematica function Random (e.g {Real}, or{Integer, {0,10}}); * a list containing a one-dimensional vector (e.g.{{-2,-1,1,2,x,y}}); * a list containing two one-dimensional vectors of equal length, the second of which must be wholly numeric and non-negative (e.g. { {-2,-1,1,2,x,y}, {1,1,1,1,2,2} }); * a list of the form {WithoutReplacement[, n]}, where n is a positive integer. Calling GiveQuestion causes Mathematica to sample from each of the parameter sets associated with the specified question class, according to the following rules: * if the parameter set is of the first form, this sampling is done by means of a simple call to Random; * if it is of the second form, one of the specified values is chosen, each with equal probability; * if it is of the third form, one of the values specified in the first vector is chosen, with a probability defined by the corresponding element in the second vector (whose elements are automatically renormalised to sum to 1); * if it is of the fourth form, the first argument of WithoutReplacement is sampled n times without replacement. So the list of parameters ends up being longer than the original list of parameter sets. Here is an example of a list of parameter sets: ParameterSets["expand and simplify"] = {{Integer,{2,5}}, {Integer,{2,5}}, {{x,y,z,p,q,r}}, {{-5,-4,-3,-2,-1,1,2,3,4,5}}, {{a,b,c,1}, {1,1,1,3}}, {{-5,-4,-3,-2,-1,1,2,3,4,5}}, {{-5,-4,-3,-2,-1, 0,1,2,3,4,5}, { 1, 1, 1, 1, 1,15,1,1,1,1,1}} }; (iv) The random sampling of the parameter sets outputs a one-dimensional list of parameters, the position of each of which corresponds to that of the set from which it was drawn. What GiveQuestion ultimately requires, though, is another list: the set of insertions which, together with the question template, go to make up a particular question. The process by which the parameter list is converted into the insertion list must be defined by the question function. The question function takes as its argument set the elements of the parameter list, in order. It outputs a list, whose elements will then be inserted, in order, into the question template. For example: QuestionFunction["expand and simplify"][a_,b_,c_,d_,e_,f_,g_] := { a(b c + d e) + f c + g e }; Note that, although the output must be a list, the input is not. Question function definitions which begin like this will not work: QuestionFunction["expand and simplify"][ {a_,b_,c_,d_,e_,f_,g_} ] := For maximum efficiency, the question function can be implemented as a pure function. This is how the "expand and simplify" example really reads: QuestionFunction["expand and simplify"] = { #1(#2 #3 + #4 #5) + #6 #3 + #7 #5 }&; (v) The way the answer function works is exactly similar, for example: AnswerFunction["expand and simplify"]= { Expand[#1(#2 #3 + #4 #5) + #6 #3 + #7 #5] }&; ---- The METRIC Project - 26 June 1996.