WeBWorK Problems

Custom checker extracting parts of a vector

Re: Custom checker extracting parts of a vector

by Davide Cervone -
Number of replies: 0
This works fine for constant vectors like <1,2,3>, but can be problematic when the answer is a vector formula. In that case, this only works if the student answers an explicit vector, like <x,y,x+y>, but will fail if the student enters 3<x,y,x+y> or <1,0,0>.<x,y,x+y>. So I recommend using the dot product unless you are using one of the restricted vector contexts that prevents vector formulas.

You can also do

    Vector(2,3,5)->extract(1)
rather than
    (Vector(2,3,5)->value)[0]
to get just the first coordinate.

Note also that there is a Complex-Vector context, so no need to set that up yourself. Just use

    Context("Complex-Vector");
There are also Complex-Point and Complex-Matrix contexts.