## WeBWorK Problems

### Re: Step Functions Should Not Be Legacious

by Paul Pearson -
Number of replies: 0
Hi,

I know this reply is coming quite a bit after the fact, but it ought to be useful to those who browse the forum in the future. Davide Cervone just pointed out to me that in order to set test_points or test_at for a function that has been added to the context, you must use the syntax $f->with(test_at => ...) as illustrated in the example below. (That is, the syntax for test_points and test_at in http://webwork.maa.org/wiki/FormulaTestPoints doesn't quite work for functions that are added to the context.) loadMacros("PGstandard.pl","MathObjects.pl","parserFunction.pl",); Context("LegacyNumeric"); parserFunction("u(t)" => "step(t)");$a = random(2,4,1);
$f = Formula("5 u(t-$a)");

$answer =$f->with(
limits=>[$a-5,$a+5],
test_at => [[$a-1],[$a],[$a+0.0000001],[$a+1]],
num_points=>10,
);


Notice that to get reliable answer checking, we have set the limits to be centered about the discontinuity, that we use 10 points total for checking the answer, and that in the "test_at" section we have specified four of those points for answer checking, two of which are very close to the discontinuity.

Davide also pointed out that the step() and fact() function (from WeBWorK's equation parser prior to MathObjects) are defined in the LegacyNumeric context. If you don't want fact(), you can use

Context("LegacyNumeric")->functions->disable("fact");

If you are writing questions that have the Heaviside function u(t) in their answer, but students never actually see the values of the function u(t), it is possible to define u(t) as something other than the Heaviside function so that it is possible to use the default settings (limits, test_at, num_points) and have a reliable answer checker. I have explained this in more detail in the right column on the page:

http://webwork.maa.org/wiki/HeavisideStep1

Best Regards,

Paul Pearson