Forum archive 2000-2006

Michael Gage - fun_cmp

Michael Gage - fun_cmp

by Arnold Pizer -
Number of replies: 0
fun_cmp topic started 1/4/2001; 10:58:13 PM
last post 1/4/2001; 10:58:13 PM
userMichael Gage - fun_cmp  blueArrow
1/4/2001; 10:58:13 PM (reads: 2596, responses: 0)


Creates an answer evaluator which checks expressions defining functions.


fun_cmp(function_string, options)
fun_cmp([fun_str1, fun_str2], options)


The first argument is the expression defining the correct function, or one or more expressions placed in square brackets. The options are specified in key => value pairs. (see Options)


Option keyOption valueDefault
var either the number of variables or a reference to an array of variable names ['x', 'y']
limits reference to an array of arrays of limits [[0,1],[0,1]]
mode 'std' (default) (function must match exactly)
'antider' (function must match up to a constant)
relTol a number indicating the relative tolerance (as a percentage) for checking each point .01 per cent
tol an absolute tolerance for checking error  
numPoints the number of points to evaluate the function at 4
params an array of "free" parameters which can be used to adapt the correct answer to the submitted answer. (e.g. ['c'] for a constant of integration in the answer x^3/3 + c ). ['']
maxConstantOfIntegration maximum size of the constant of integration and other free parameters. (prevents numerical overload) 10**100
debug1 to obtain additional warning messages for debugging, 0 to turn off 0


One (or more) answer evaluators for expressions defining functions


* fun_cmp('x^2 +3x') checks that the submitted expression matches this quadratic.
* fun_cmp('t^2- sin(t)', var => 't')
* fun_cmp('t^2 - sin(t)', vars => ['t'], limits => [-4,4]). You can also use limits => [[-4,4]] for consistency
* fun_cmp('x^2 + y^2', vars => ['x', 'y'],
limits => [[-4,4],[-2,6]], numPoints => 10 )
* fun_cmp('x^2 + y^2 + c', vars => ['x', 'y'], params =>['c'],
limits => [[-4,4],[-2,6]], numPoints => 10 ) will match 'x^2 +y^2 + 25'.
* fun_cmp( 'cos(x) + a*e^(-x) + b*e^(2x)', params =>['a', 'b']) will accept a linear family of solutions, e.g. solution set to a linear ODE
* fun_cmp( 'x^2 +sin(c*x)' , params =>['c']) will NOT work. The expressions have to be linear in the parameters (but of course they can be non-linear in the variables such as x).


The options can be used in any combination that makes sense, and probably some that don't. One exception: reltol and tol cannot be used together.


<| Post or View Comments |>