[system] / trunk / pg / lib / Value / Formula.pm Repository:
ViewVC logotype

Log of /trunk/pg/lib/Value/Formula.pm

Parent Directory Parent Directory


Links to HEAD: (view) (download) (as text) (annotate)
Sticky Revision:

Revision 5517 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Sep 20 18:02:24 2007 UTC (12 years, 2 months ago) by dpvc
File length: 16513 byte(s)
Diff to previous 5509
Make adaptive parameters try again if they fail to be found the first
time (Gavin has found cases where the random points cause the
coefficient matrix to be singular, so a second try should resolve the
problem).

Revision 5509 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Sep 15 00:56:51 2007 UTC (12 years, 3 months ago) by dpvc
File length: 16026 byte(s)
Diff to previous 5382
Formula objects and Context objects contain reference loops, which
prevent them from being freed properly by perl when they are no longer
needed.  This is a source of an important memory leak in WeBWorK.  The
problem has been fixed by using Scalar::Util::weaken for these
recursive references, so these objects can be freed properly when they
go out of scope.  This should cause an improvement in the memory usage
of the httpd child processes.

Revision 5382 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 19 18:00:48 2007 UTC (12 years, 3 months ago) by dpvc
File length: 15994 byte(s)
Diff to previous 5240
The overridden with() method was not preserving all the settings in
the Formula.  This has been fixed.

Revision 5240 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Aug 7 04:33:31 2007 UTC (12 years, 4 months ago) by dpvc
File length: 15914 byte(s)
Diff to previous 5113
Use cached value of context rather than looking it up each time.

Revision 5113 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Jul 2 16:27:13 2007 UTC (12 years, 5 months ago) by dpvc
File length: 15904 byte(s)
Diff to previous 5111
Improve some error messages.
In comparisons, mark the values created by the formulas so that they
will use the formula's tolerances.

Revision 5111 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Jul 2 00:50:14 2007 UTC (12 years, 5 months ago) by dpvc
File length: 15428 byte(s)
Diff to previous 5089
Changed with() to make a copy (as suggested last week).  This one is a
deep copy, however, since the tree is modified and we don't want to
change the original, we need to make a deep copy.

Adjust bop() to remove dependency on hard-coded Parser package name.

Remove stringify, which is now identical to parent version

Move usesOneOf to near isConstant (cosmetic change only).

Revision 5089 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jun 29 22:07:10 2007 UTC (12 years, 5 months ago) by dpvc
File length: 15746 byte(s)
Diff to previous 5042
Transfer flags from parent objects to their children for comparisons
and printing purposes.  Also touch up a few type-coersion issues.  (It
may be possible to not to need Value::isValue() if these can all be
taken care of.)

Revision 5042 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 28 01:31:09 2007 UTC (12 years, 5 months ago) by dpvc
File length: 15724 byte(s)
Diff to previous 5039
Recent changes to automatically do promotion in the Value methods was
a mistake.  I put it back into the subclass methods again.

Revision 5039 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Jun 27 20:22:20 2007 UTC (12 years, 5 months ago) by dpvc
File length: 15713 byte(s)
Diff to previous 5038
OOPS, the example in the previous message is wrong.  You need to use

      $a = Context()->variables->get("a")->{value};
      $b = Context()->variables->get("b")->{value};

(brtaces around the "value").

Revision 5038 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Jun 27 20:20:12 2007 UTC (12 years, 5 months ago) by dpvc
File length: 15712 byte(s)
Diff to previous 5012
Adaptive-parameter values are now stored in the Context so that they
can be retreived if needed.  E.g.,

    Formula("a x + b") == Formula("5 x - 3");
    $a = Context()->variables->get("a")->value;
    $b = Context()->variables->get("b")->value;

will have $a equal to 5 and $b equal to -3.

Revision 5012 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 21 23:10:13 2007 UTC (12 years, 5 months ago) by dpvc
File length: 15597 byte(s)
Diff to previous 5001
Added Package method to the Context object to replace the
Value->Package() calls and simplify the $self->Package calls (don't
have to look up the context again).

Revision 5001 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Jun 12 04:05:56 2007 UTC (12 years, 6 months ago) by dpvc
File length: 15565 byte(s)
Diff to previous 4991
More fixes for creating items in the corret context.  Also added a
method for looking up the package associated with a particular Parser
class (for consistency with the Value->Package call).

Revision 4991 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jun 8 02:09:21 2007 UTC (12 years, 6 months ago) by dpvc
File length: 15599 byte(s)
Diff to previous 4989
Update new() and make() methods to accept a context as the first
parameter (making it easier to create objects in a given context
without having to resort to a separate call to coerce them to the
given context after the fact).

Revision 4989 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 7 23:47:14 2007 UTC (12 years, 6 months ago) by dpvc
File length: 15673 byte(s)
Diff to previous 4987
can't use inContext() with the "fake" make that produces perl reals,
so remove it for now.  (Perhaps we should just go with the Reals() and
not try to be fancy about it, since it will often get converted to a
Real anyway).  This will need more work.

Revision 4987 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 7 21:54:46 2007 UTC (12 years, 6 months ago) by dpvc
File length: 15670 byte(s)
Diff to previous 4979
Added Value->Package(name[,context]) to look up what package is
currently set to handle the named type.  E.g.,
Value->Package("Complex") usually returns "Value::Complex".  These can
be overridden in the Context so that modified vesions of the
MathObjects can be made to replace the existing ones more easily.  In
particular, the Parser classes should call these (not yet implemented)
when they create objects, so that you can override the object they
create.

Also cleaned up some more context issues (with still more to come).

Revision 4979 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 7 11:59:05 2007 UTC (12 years, 6 months ago) by dpvc
File length: 15847 byte(s)
Diff to previous 4975
More updates for marking MathObjects with the context in which they
were created, so they should now work like the Formula objects in that
respect.  As they are combined via overloaded operators, they should
pass on their contexts correctly.

Also normalized the use of getFlag() to obtain flags from the
MathObject's context rather than looking in the context directly.
This allows the math object to override the flag by setting the flag
value in the object's hash (e.g., $f->{tolerance} = .001).  I've also
added the ability to override context flags via the answerHash (e.g.,
$f->cmp(tolerance => .001)), though some filtering may need to be
added to this at some point.  Note that ONLY the context flags can be
overridden, not other parts of the context.

Revision 4975 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Jun 6 21:44:05 2007 UTC (12 years, 6 months ago) by dpvc
File length: 15936 byte(s)
Diff to previous 4822
This begins some major updates to the Parser and Value libraries.
This may make the MathObjects unstable as things shake down, but I'll
try to keep that to a minimum.

This update reorganizes how the overloading of operations are
implemented.  The base Value class is now overloaded rather than the
individual Value classes.  This makes it easier to make subclasses
that take advantage of the overloading.

The code that handles promoting one MathObject to another has been
updated as a part of this.  This should also make subclassing the
existing MathObjects more flexible.

In the past, Formula objects included a pointer to the Context in
which the object was created, but other MathObject did not.  This
update is the first round of updates to include the context in the
other MathObjects, but more work needs to be done.

The changes here should not affect existing problems; it is possible
that some macro files will need to be updated, but none of the
standard ones in pg/macros seem to need it at the moment.

Revision 4822 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Mar 3 00:11:28 2007 UTC (12 years, 9 months ago) by dpvc
File length: 16554 byte(s)
Diff to previous 4728
Use zeroLevelTol values when checking answers that have adaptive parameters.

Revision 4728 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Dec 16 14:07:58 2006 UTC (13 years ago) by dpvc
File length: 16418 byte(s)
Diff to previous 4663
Use Perl reals rather than Parser Reals in matrix for adaptive
parameters.

Revision 4663 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Nov 26 20:30:17 2006 UTC (13 years ago) by dpvc
File length: 16400 byte(s)
Diff to previous 4512
Added ability to have additional information given when not enough
test points can be generated for a function comparison.  By default,
this information is NOT shown (since it could give students additional
information about what answer is expectd).  Professors can request it
by setting the 'showTestPointErrors' flag in the Context().

Revision 4512 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Sep 21 22:08:49 2006 UTC (13 years, 2 months ago) by dpvc
File length: 16169 byte(s)
Diff to previous 3716
Fix problem with formula comparisons involving vector-valued formulas.
The coordinates for the vectors used in checking equality were plain
Perl reals rather than Parser-based reals, and so the comparisons were
being done using exact rather than fuzzy comparisons.

Revision 3716 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Oct 16 03:37:17 2005 UTC (14 years, 2 months ago) by dpvc
File length: 16143 byte(s)
Diff to previous 3677
In the past, when Value objects were inserted into strings, they would
automatically include parentheses so that if you had $f equal to 1+x
and $g equal to 1-x, then Formula("$f/$g") would mean (1+x)/(1-x)
rather than 1+(x/1)-x, which is what would happen as a straing string
substitution.

The problem is that this would also happen for real numbers, vectors,
and everything else, even when it wasn't necessary.  So if $x=Real(3),
then "Let x = $x" would be "Let x = (3)".

I have changed the behavior of the string concatenation for Value
objects so that parentheses are only added in a few cases: for
Formulas, Complex numbers, and Unions.  This makes the other Value
objects work more like regular variables in strings, but might cause
some problems with strings that are used as formulas.  For example, if
$a = Real(-3), then "x + 2 $a" will become "x + 2 -3", or "x-1" rather
than the expected "x - 6".  (The old approach would have made it "x +
2 (-3)" which would have worked properly).  For the most part, it is
easier to use something like "x + 2*$a" or even "x" + 2*$a in this
case, so the extra trouble of having to avoid parentheses when you
really meant to substitute the value into a string didn't seem worth
it.

Revision 3677 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Oct 1 01:10:27 2005 UTC (14 years, 2 months ago) by dpvc
File length: 16141 byte(s)
Diff to previous 3613
Allow context to override object class used to create formula objects
(so that things like ImplicitPlane can create instances of themselves
automatically when needed).

This mechanism needs to be enlarged to encompass the other Value
object classes as well (like the Context()->{parser}{...} hash).

The real problem is that the List object probably shouldn't create a
formula returning a list when it is passed formulas, since there
really isn't much need for a formula returning a list to be
autogenerated (you can create one by hand using Formula if needed).

Right now, ALL the Value objects make themselves into Formulas when
one of their entries is a formula.  For example, Point(1,"x") produces
the same thing as Formula("(1,x)"), and List(1,"x") is the same as
Formula("1,x").  This is good for points, but not so good for lists.
And it might sometimes be nice to have a Vector of Formulas, or a
Matrix with Formula entries (rather than Formulas returning Vectors or
Matrices).  But this would require some serious changes internally in
the Value objects, which make assumptions about their values being
constant.  Changing that will be for another day...

Revision 3613 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Sep 12 23:28:37 2005 UTC (14 years, 3 months ago) by dpvc
File length: 15892 byte(s)
Diff to previous 3523
Fixed an error where scalar() was used on a hash ref.
Fixed a misfeature where operations on formulas could return Value
objects of other classes; they should always return formulas, even
when the formula is constant.

Revision 3523 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 22:38:39 2005 UTC (14 years, 4 months ago) by dpvc
File length: 15888 byte(s)
Diff to previous 3517
Added canBeInUnion and isSetOfReals methods to the Parser package
(similar to the ones in the Value package), replacing the
canBeInterval flag and other ad hoc checks.

Removed ability to form interval like [a] now that we have sets.

Revision 3517 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 21:31:46 2005 UTC (14 years, 4 months ago) by dpvc
File length: 15897 byte(s)
Diff to previous 3515
Pass the canBeInUnion call on to the Formula's root node

Revision 3515 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 13 20:55:35 2005 UTC (14 years, 4 months ago) by dpvc
File length: 15848 byte(s)
Diff to previous 3487
Make formulas that produce lists get default open and close parens,
and have them retained in Formula() results.

Revision 3487 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Aug 12 17:09:42 2005 UTC (14 years, 4 months ago) by dpvc
File length: 15641 byte(s)
Diff to previous 3470
Changed how Intervals implement the requireParenMatch flag for the
interval and union answer checker.  (Use a Context flag rather than a
flag on the interval itself.)  Moved the getFlag method from
Formula.pm to Value.pm so it can be used by any object class.  New
feature where classes can add more context flags to set (and reset
after the answer checker runs).

Revision 3470 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Aug 11 14:25:53 2005 UTC (14 years, 4 months ago) by dpvc
File length: 16073 byte(s)
Diff to previous 3370
Changes needed for new Set object, and moving of string, TeX and perl
methods to Value.pm

Revision 3370 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Jul 12 22:29:53 2005 UTC (14 years, 5 months ago) by dpvc
File length: 15869 byte(s)
Diff to previous 3369
A first pass at making parser error messages localizable.  The
Context()->{error}{msg} hash can be used to specify translations of
the standard messages.  For example,

    Context()->{error}{msg}{'Division by zero'} = "Don't divide by zero, dude!";
    Context()->{error}{msg}{'Function '%s' has too many inputs'} =
        "You passed too many arguments to '%s'";

(I didn't translate into another language, here, but you could do
that, too.)

The msg hash could also be used within answer checkers to make certain
answer messages more appropriate for the given type of expected answer.

Revision 3369 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Jul 12 21:05:37 2005 UTC (14 years, 5 months ago) by dpvc
File length: 15882 byte(s)
Diff to previous 3342
Fixed various perl compiler warnings (due to extra "my", and so on).

Revision 3342 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Jul 4 15:53:26 2005 UTC (14 years, 5 months ago) by dpvc
File length: 15885 byte(s)
Diff to previous 3339
Better messages when adaptive parameters are too big.

Revision 3339 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Jul 4 15:22:22 2005 UTC (14 years, 5 months ago) by dpvc
File length: 15750 byte(s)
Diff to previous 3296
Don't use the overloaded Real class for doing adaptive parameter
checks (use non-fuzzy checks, since we are checking the fuzziness by hand).

Revision 3296 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 16 04:03:40 2005 UTC (14 years, 6 months ago) by dpvc
File length: 15737 byte(s)
Diff to previous 3264
Fixed a problem with auto-generated functions getting an incomplete
variable list.

Revision 3264 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Jun 5 23:18:01 2005 UTC (14 years, 6 months ago) by dpvc
File length: 15804 byte(s)
Diff to previous 3261
Fix some incorrect calls when the promoting types to higher precedence
object types.

Revision 3261 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Jun 4 13:50:41 2005 UTC (14 years, 6 months ago) by dpvc
File length: 15595 byte(s)
Diff to previous 3258
Avoid possible infinite loop with length and typeref calls.

Revision 3258 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Jun 3 19:14:00 2005 UTC (14 years, 6 months ago) by dpvc
File length: 15547 byte(s)
Diff to previous 3257
Better control over number of points that can be undefined, and
new ability to specify required test points plus additional random
ones.  (Previously, if you set the test points, no random points were
generated.)  For example:

     $f = Formula("(x^2-1)/(x-1)");
     $f->{test_at} = [[1]];  # test at x=1 plus random points

as opposed to

     $f->{test_points} = [[-1],[0],[1]];

which tests only the points x = -1, x = 0 and x = 1.

Revision 3257 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 2 22:50:24 2005 UTC (14 years, 6 months ago) by dpvc
File length: 15217 byte(s)
Diff to previous 3256
Modified the Formula answer checker to allow checking of points where
the functions are undefined (i.e., attempt to check that the domains
agree).  This can be enabled by setting the checkundefinedPoints flag
in the Context(), or in the formula itself.  Test points where the
function is undefined will be retained and the student's answer will
have to be undefined at the same points.  If the points are selected
at random, the points where the function is undefined are kept in
addition to the ones where it is defined, so the required number of
test points where the function IS defined will still need to be
found.  The number of undefined points can be up to the number of
defined points.  This number can be reduced by setting the
max_undefined flag.  If you want to guarantee that a specific
undefined point be tested, you can provide that point using the
test_points field of the formula.  For example:

     Context()->flags->set(checkUndefinedPoints=>1);
     $f = Formula("(x^2-1)/(x-1)");
     $f->{test_points} = [[-1],[0],[1],[2]];
     ANS($f->cmp);

will guarantee that the singularity at x=1 is tested, so the answer
x+1 will not be marked as correct.

If an answer matches at all the test points where the functions are
both defined, but some of the undefind points differ between the two
functions, the answer checker will generate an error message
indicating that the domains of the functions don't agree.  (This is
ONLY generated with the functions match except for that.)  This can be
controlled by setting the showDomainErrors flag in the formula's cmp()
call:

     ANS($f->cmp(showDomainErrors=>0));

The default is to show these errors.

Revision 3256 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Jun 2 19:53:06 2005 UTC (14 years, 6 months ago) by dpvc
File length: 14562 byte(s)
Diff to previous 3218
Fixed an accidental hard-coded operation from always being "add" to
being the correct operation when promoting the operations to an object
of higher precedence.  (But since formulas are normally the highest
precedence, this will never have occurred.)

Revision 3218 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Apr 29 02:37:13 2005 UTC (14 years, 7 months ago) by dpvc
File length: 14513 byte(s)
Diff to previous 3216
Fixed a bug with adaptive parameters where the relative tolerance
was not being properly computed.  This allowed large constants to be
treated as correct when they shouldn't be.

Revision 3216 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Apr 27 21:29:10 2005 UTC (14 years, 7 months ago) by dpvc
File length: 13033 byte(s)
Diff to previous 3192
Use correct form of "x" with lists (rather than hack using split()).

Revision 3192 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Wed Mar 16 13:30:28 2005 UTC (14 years, 9 months ago) by dpvc
File length: 13063 byte(s)
Diff to previous 3177
Update the overloaded operators so that they can be overridden by
subclasses of the predefined object classes.  This involves calling
the objects method rather than using a hard reference to the routine
in the parent class.

Also, change the name of the string comparison routine to
compare_string to avoid conflicts with cmp that is used to produce the
answer checker for the class.

Finally, in Value.pm, promotePrecedence no longer has to do fancy
footwork to get "special" precedence to work (this was a hack to get
around the misfeature of the overloaded operators -- now that that is
being handled correctly, there is no need for it).

Revision 3177 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Feb 18 00:04:09 2005 UTC (14 years, 9 months ago) by dpvc
File length: 12853 byte(s)
Diff to previous 3174
Missed one situation when making the previous update.  Fixed it.

Revision 3174 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Thu Feb 17 16:12:45 2005 UTC (14 years, 9 months ago) by dpvc
File length: 12853 byte(s)
Diff to previous 2800
Fixed it so that direct calls to the add, sub, mult, etc functions
would work as expected (even though there is no need to call them directly).

Revision 2800 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Sep 19 14:27:39 2004 UTC (15 years, 2 months ago) by dpvc
File length: 12853 byte(s)
Diff to previous 2688
Added isZero and isOne checks for Parser::Value objects (i.e., for
constants within formulas).  These now correctly handle vector and
matrices, in particular.  The isOne and isZero checks are used in the
reduce() method to simplify formulas.

Revision 2688 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Aug 27 19:42:59 2004 UTC (15 years, 3 months ago) by dpvc
File length: 12780 byte(s)
Diff to previous 2687
Added in functMaxConstantOfIntegration support in the adaptive
parameter answer checking.  Also added a flag to the formula answer
checker that allows checking a formula up to a constant (for
integration problems).  This really just adds a new parameter to the
context and adds that to the formula, so there is nothing deep about
this.

	ANS(Formula("2x")->cmp(upToConstant=>1));

Finally, don't look for adaptive parameters if they aren't actually
used in the professor's formula (even if they are defined).

Revision 2687 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Fri Aug 27 00:28:27 2004 UTC (15 years, 3 months ago) by dpvc
File length: 12344 byte(s)
Diff to previous 2678
Added ability to have linear adaptive parameters in the function
answer checker.  It only works for real-valued functions, though.
To use a parameter, use

       Context()->variables->add(a=>'Parameter');

and then use 'a' as a variable within your answer.  The student will
not be allowed to enter the parameter, but the professor will.

Note that the correct answer will show the full professor's answer,
including the parameters, even though the student can't type it.  Is
this the right behaviour?

Revision 2678 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Aug 23 23:55:37 2004 UTC (15 years, 3 months ago) by dpvc
File length: 10631 byte(s)
Diff to previous 2671
Modified the parser so that the classes for the various object
constructors are stored in the context table rather than hard-coded
into the parser.  That way, you can override the default classes with
your own.  This gives you even more complete control to modify the
parser.  (You had been able to replace the definitions of operators,
functions and list-like objects, but could not override the behaviour
of numbers, strings, variables, and so on.  Now you can.)

This effects most of the files, but only by changing the name of the
calls that create the various objects.

There are also a couple of other minor fixes.

Revision 2671 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 22 21:18:06 2004 UTC (15 years, 3 months ago) by dpvc
File length: 10559 byte(s)
Diff to previous 2669
Fixed some inconsistencies between handing of matrices within the
parser and Value packages.  Added a predefined Matrix context.

Revision 2669 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 22 15:42:50 2004 UTC (15 years, 3 months ago) by dpvc
File length: 10521 byte(s)
Diff to previous 2668
Made the granularity of the test-point intervals be a parameter that
can be set on a global or variable-by-variable basis, so this is now
controlable from the .pg file.  For example:

            Context("Numeric")->variables->are(
              k=>{limits=>[1,10], resolution=>1},
              x=>{limits=>[-2,2], granularity=>1000},
            );

will make k be a variable that will only take on integer values
between 1 and 10, and x a variable that will take on one of 1000
different values evenly spaced between -2 and 2 (so resolution is
4/1000 in this case).

These parameters can also be set for an individual formula:

           $f = Formula("k^2-1");
           $f->{resolution} = 1;
           $f->{limits} = [0,10];

Revision 2668 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 22 02:55:38 2004 UTC (15 years, 3 months ago) by dpvc
File length: 10149 byte(s)
Diff to previous 2666
Fixed TeX output of Matrices to use \array rather than \matrix for
matrices with formulas as entries (this had already been fixed for
constant matrices).  Made intervals produce formulas when of of the
endpoints is a formula.  Removed unneeded comment.

Revision 2666 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 22 00:56:32 2004 UTC (15 years, 3 months ago) by dpvc
File length: 10204 byte(s)
Diff to previous 2629
Formulas can now be compared even if their variables are complex
numbers, or even points or vectors!  This makes it possible to ask
students for complex functions like z^2+i and so on.

You can specify limits for variables either via
Context()->variables->set(x=>{limits=>[0,1]})  (for reals) or
Context()->variables->set(z=>{limits=>[[-2,2],[0,1]]}) (for complexes).
Similarly for points and vectors (where the number of sub arrays
depends on the dimension).  You can also give the limits for a
specific formula by assigning to its ->{limits} field:

    $f = Formula("sqrt(x-10)");
    $f->{limits} = [10,12];

There are now named variable types for 'Point2D', 'Point3D',
'Vector2D' and 'Vector3D', in addition to 'Real' and 'Complex'.
You can also specify a variable type by giving an explicit instance of
a value of the given type.  E.g.

    Context()->variables->add(x=>'Real',y=>0);     # two real variables
    Context()->variables->add(z=>'Complex',w=>i);  # two complexes
    Context()->variables->add(r=>Vector(0,0,0));   # a vector in R^3
    Context()->variables->add(X=>'Vector3D');      # a vector in R^3

There still needs to be more error checking in processing
user-supplied limits, but I'm not sure how much overhead is worth it.

Revision 2629 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Tue Aug 17 02:01:27 2004 UTC (15 years, 4 months ago) by dpvc
File length: 8353 byte(s)
Diff to previous 2625
Fixed a number of minor problems with creating perl functions from
formulas (this is done automatically as part of the function answer
checker, so is showing up now that I have that checker in place).

Also improved error messages in the function answer checker, and fixed
a bug when students enter a constant list or union when the answer
checker expects formulas.

Revision 2625 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Aug 16 18:35:12 2004 UTC (15 years, 4 months ago) by dpvc
File length: 8351 byte(s)
Diff to previous 2624
Added string comparison to all Value object classes (to compare the
string value of an object to another string).

Overloaded perl '.' operator to do dot product when the operands are
formulas returning vectors.  (Part of the auto-generation of
formulas).

A few improvements to real and complex class output results.

Made Union class slightly more robust and removed need for makeUnion
method other than in the Union itself.

Revision 2624 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Mon Aug 16 13:44:45 2004 UTC (15 years, 4 months ago) by dpvc
File length: 8052 byte(s)
Diff to previous 2622
Added support for unorderd list or formulas with partial credit.
Fixed type mismatch reporting in formula answer checker.
Fixed an error with Unions producing incorrect perl versions under
some circumstances.

Revision 2622 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 15 22:46:57 2004 UTC (15 years, 4 months ago) by dpvc
File length: 7897 byte(s)
Diff to previous 2621
Created the first draft of the Parser's function answer checker.  Some
work still needs to be done, in particular, type mismatches are not
being reported, and lists are being processed only as ordered lists
with no partial credit.

This doesn't implement everything from fun_cmp.  In particular, there
is no support for parameter matching at the moment.  This will have to
be added, but I'm not quite sure how to do it when the function's
return value is not a real number (e.g., an interval).

On the other hand, this checker is more forgiving about domain errors:
if tries a point where the professor's function is not defined, it
ignores that one and looks for another (until it decides it can't find
one).  Once it has these points, it tries them on the student's
answer, and if the student's function is undefined, then the student
answer is wrong (since it is not defined somewhere that the
professor's funciton is).  This avoids the "Error evaluating student
function at ..." messages, which just confused most students anyway.

Revision 2621 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sun Aug 15 17:05:41 2004 UTC (15 years, 4 months ago) by dpvc
File length: 3677 byte(s)
Diff to previous 2606
Improved error messages, particularly when the student enters a
formula in an answer that should be constant, and also for incorrect
answers in lists of answers.  There are a few other miscellaneous output
improvements as well.

Revision 2606 - (view) (download) (as text) (annotate) - [select for diffs]
Modified Sat Aug 14 11:25:47 2004 UTC (15 years, 4 months ago) by dpvc
File length: 3508 byte(s)
Diff to previous 2558
Can now specify that the objects stringify themselfs in their TeX
forms rather than their answer-string forms.  This makes it easier to
use the objects in the text of a problem (without having to call ->TeX
explicitly each reference).

Use

       Context()->texStrings

to start outputting TeX strings, and

      Context()->normalStrings

to switch back.

Revision 2558 - (view) (download) (as text) (annotate) - [select for diffs]
Added Wed Jul 28 20:32:33 2004 UTC (15 years, 4 months ago) by sh002i
File length: 3573 byte(s)
merged changes from rel-2-1-a1 -- stop using that branch.

This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, enter a numeric revision.

  Diffs between and
  Type of Diff should be a

Sort log by:

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9