PREP 2014 Question Authoring - Archived

setting test points

Re: setting test points

by Davide Cervone -
Number of replies: 0
It is also possible to use two separate contexts (one for each formula) with their limits set differently. For example:
Context("Numeric");
Context()->variables->add(n => ['Real', limits=>[0,10], resolution=>1]);
$ans_causal = Formula("$A*($p1)**n + $B*($p3)**n ")->reduce;

Context("Numeric");
Context()->variables->add(n => ['Real', limits=>[-10,0], resolution=>1]);
$ans_noncausal = Formula("-$C*($p2)**(-n) ")->reduce;
Here, the second Context("Numeric") gets you a fresh copy of the Numeric context, without the previous changes. Since MathObjects retain the context in which they were created, both have the proper limits.

Alternatively, you can set limits on the formulas rather than explicit test points. For example:

$f = Compute("x+1")->with(limits => [0,10], resolution => 1);
$g = Compute("x-1")->with(limits => [-10,0], resolution => 1);