WeBWorK Main Forum

Checking for enough comparison points in advance

Checking for enough comparison points in advance

by Michael Shulman -
Number of replies: 0
I am writing a problem that generates very random functions (for taking derivatives of) by combining basic functions in complicated ways.  This has a tendency to produce functions with odd domains, e.g. ln or sqrt of a polynomial has a disjoint union of intervals as domain.  The result is that for any fixed setting of the "limits" flag, there are still cases that end up with the infamous "Can't generate enough valid points for comparison" error.

I don't want to have to write code that works out the domain of each function I generate in order to set the "limits" flag to something contained in that domain.  I'd rather just check, after I generate the function randomly, whether it will have enough valid comparison points, and if not, go back and generate another function until I get one that is okay.  Is there a way to do that?