## WeBWorK Problems

### Variable limits set to a disjoint domain? ### Variable limits set to a disjoint domain?

by Paul Seeburger -
Number of replies: 3

Is it possible to set a variable's limits to a disjoint domain?

For example, I want to set the limits of x to be (-inf, -1] U [1, inf) for the function y = arcsec (x).

I see that I can set domain for a single interval easily using:

Context()->variables->set(x=>{limits=>[$lowerBound,$upperBound]});

Any suggestions?

Thanks! ### Re: Variable limits set to a disjoint domain?

by Davide Cervone -
There is no support for domains other than single intervals at the moment. MathObjects will discard test points that are not in the domain (up to a certain limit), so you could use [-10,10], which would make it less likely (though not impossible) to fail to find enough test points by the time that limit is reached. ### Re: Variable limits set to a disjoint domain?

by Paul Seeburger -

Thanks, Davide!

I can see how that would work.

Another way I figured out to accomplish my goal was to set the limits for x with:

Context()->variables->set(x=>{limits=>[$bound, 10]}); Then I added test points to the function holding the problem answer from the negative part of the domain with: $afunc->{test_at} = [-$bound, -$bound*2, -$bound*10]; This seemed to work well for my goal of checking an antiderivative with arcsec (|u|/a) in it. The variable$bound was determined from the random variables in u and a.

Paul $myFormula = Formula("arcsec(x)"); for my$i (0..4) {$p[$i] = random(-1,1,2) * random(1,2,0.001);};
$myFormula->{test_points} = ~~@p; # or if that last line doesn't work: #$myFormula->{test_points} = [[$p],[$p],[$p],[$p],[\$p]];