WeBWorK Problems

List of Intervals

by D. Brian Walton -
Number of replies: 2
I am trying to write some problems related to using the first and second derivatives of a function to identify where a function is increasing, decreasing, concave up and concave down. I want the answer to be a list of intervals, not a union, because typically the function is not increasing on the actual union, only on each of the intervals when considered individually.

How do you compare a list of intervals? Is this part of MathObjects or some other method? Also, how would you enter an empty list (in case the function is only increasing--the list of intervals where decreasing should be empty)?

Thanks,
- D. Brian Walton
In reply to D. Brian Walton

Re: List of Intervals

by Danny Glin -
I've attached one of my graph sketching questions which does what you describe using MathObjects.
In each case, you would create a List object with the correct intervals set as Interval objects:
$ans1=List(Interval(-inf,$a),Interval($b,$c));
Then you can pass this to its built in answer evaluator:
ANS($ans1->cmp); In a case where there are no intervals, the List object type has 'NONE' as a built in constant, so students can type 'none' (case insensitive) if they find no appropriate intervals. In reply to D. Brian Walton Re: List of Intervals by Davide Cervone - You can also make lists of intervals using: $ans = Compute("(-inf,$a),($b,inf)");

which has the advantage of making what you type be in the same format as what students type. You do not have to use the List and Interval constructors, though there is nothing wrong with doing so if you prefer.

In the case where you use "NONE" as the answer, you might want to do

    ANS(List("NONE")->cmp(typeCheck=>Interval(0,1)));

so that you can get list-style error messages with type-checking appropriate for intervals.

Davide