| … | |
… | |
| 1252 | numPoints -- the number of points to evaluate the function at |
1252 | numPoints -- the number of points to evaluate the function at |
| 1253 | maxConstantOfIntegration -- maximum size of the constant of integration |
1253 | maxConstantOfIntegration -- maximum size of the constant of integration |
| 1254 | zeroLevel -- if the correct answer is this close to zero, then |
1254 | zeroLevel -- if the correct answer is this close to zero, then |
| 1255 | zeroLevelTol applies |
1255 | zeroLevelTol applies |
| 1256 | zeroLevelTol -- absolute tolerance to allow when answer is close to zero |
1256 | zeroLevelTol -- absolute tolerance to allow when answer is close to zero |
|
|
1257 | test_points -- a list of points to use in checking the function, or a list of lists when there is more than one variable. |
| 1257 | params an array of "free" parameters which can be used to adapt |
1258 | params an array of "free" parameters which can be used to adapt |
| 1258 | the correct answer to the submitted answer. (e.g. ['c'] for |
1259 | the correct answer to the submitted answer. (e.g. ['c'] for |
| 1259 | a constant of integration in the answer x^3/3 + c. |
1260 | a constant of integration in the answer x^3/3 + c. |
| 1260 | debug -- when set to 1 this provides extra information while checking the |
1261 | debug -- when set to 1 this provides extra information while checking the |
| 1261 | the answer. |
1262 | the answer. |
| … | |
… | |
| 1293 | [lower_limit. upper_limit], each array corresponding to the lower and upper |
1294 | [lower_limit. upper_limit], each array corresponding to the lower and upper |
| 1294 | endpoints of the (half-open) domain of one variable. For example, |
1295 | endpoints of the (half-open) domain of one variable. For example, |
| 1295 | "vars => 2, limits => [[0,2], [-3,8]]" would cause x to be evaluated in [0,2) and |
1296 | "vars => 2, limits => [[0,2], [-3,8]]" would cause x to be evaluated in [0,2) and |
| 1296 | y to be evaluated in [-3,8). If only one variable is being used, you can write |
1297 | y to be evaluated in [-3,8). If only one variable is being used, you can write |
| 1297 | either "limits => [[0,3]]" for consistency or "limits => [0,3]" as a shortcut. |
1298 | either "limits => [[0,3]]" for consistency or "limits => [0,3]" as a shortcut. |
|
|
1299 | |
|
|
1300 | TEST POINTS: |
|
|
1301 | |
|
|
1302 | In some cases, the problem writer may want to specify the points |
|
|
1303 | used to check a particular function. For example, if you want to |
|
|
1304 | use only integer values, they can be specified. With one variable, |
|
|
1305 | you can specify "test_points => [1,4,5,6]" or "test_points => [[1,4,5,6]]". |
|
|
1306 | With more variables, specify the list for the first variable, then the |
|
|
1307 | second, and so on: "vars=>['x','y'], test_points => [[1,4,5],[7,14,29]]". |
|
|
1308 | |
|
|
1309 | If the problem writer wants random values which need to meet some special |
|
|
1310 | restrictions (such as being integers), they can be generated in the problem: |
|
|
1311 | "test_points=>[random(1,50), random(1,50), random(1,50), random(1,50)]". |
| 1298 | |
1312 | |
| 1299 | EXAMPLES: |
1313 | EXAMPLES: |
| 1300 | |
1314 | |
| 1301 | fun_cmp( "3*x" ) -- standard compare, variable is x |
1315 | fun_cmp( "3*x" ) -- standard compare, variable is x |
| 1302 | fun_cmp( ["3*x", "4*x+3", "3*x**2"] ) -- standard compare, defaults used for all three functions |
1316 | fun_cmp( ["3*x", "4*x+3", "3*x**2"] ) -- standard compare, defaults used for all three functions |
| … | |
… | |
| 1684 | ## mode -- 'std' or 'antider' |
1698 | ## mode -- 'std' or 'antider' |
| 1685 | ## maxConstantOfIntegration -- maximum size of the constant of integration |
1699 | ## maxConstantOfIntegration -- maximum size of the constant of integration |
| 1686 | ## zeroLevel -- if the correct answer is this close to zero, |
1700 | ## zeroLevel -- if the correct answer is this close to zero, |
| 1687 | ## then zeroLevelTol applies |
1701 | ## then zeroLevelTol applies |
| 1688 | ## zeroLevelTol -- absolute tolerance to allow when answer is close to zero |
1702 | ## zeroLevelTol -- absolute tolerance to allow when answer is close to zero |
|
|
1703 | ## test_points -- user supplied points to use for testing the |
|
|
1704 | ## function, either array of arrays, or optionally |
|
|
1705 | ## reference to single array (for one variable) |
| 1689 | |
1706 | |
| 1690 | |
1707 | |
| 1691 | sub FUNCTION_CMP { |
1708 | sub FUNCTION_CMP { |
| 1692 | my %func_params = @_; |
1709 | my %func_params = @_; |
| 1693 | |
1710 | |