DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "scaffold.pl", "parserMultiAnswer.pl", "rank.pl", "CustomBasisChecker_Rows.pl", "weightedGrader.pl", "PGcourse.pl" ); TEXT(beginproblem()); install_weighted_grader(); $showPartialCorrectAnswers = 1; $showPartialCredit = 1; # Set the Numeric context, but forbid using the variable x in answers. Context("Numeric"); Context()->parens->set("[" => {formMatrix => 1}); Context()->variables->remove("x"); Context()->flags->set( tolerance => 0.00000001, tolType => "absolute", ); # ==================================================== # Space where I had problems had correct basis as (1,0,3,4) and (0,1,-1,-1) # The answer (1,2,1,2) and (sqrt(253),2sqrt(253),sqrt(253),2sqrt(253)+t). @given1 = ( [ 1, 0, 3, 4 ] ); @given2 = ( [ 1, 2, 1, 2 ] ); @given3 = ( [ 1, 3, 0, 1 ] ); @given4 = ( [ 1, 4, -1, 0 ] ); $g1 = Matrix( @given1 ); $g2 = Matrix( @given2 ); $g3 = Matrix( @given3 ); $g4 = Matrix( @given4 ); # Sample basis = 2 independent vectors in the space (has dim=2) $vec1 = Matrix([[ 1, 0, 3, 4 ]]); $vec2 = Matrix([[ 0, 1, -1, -1 ]]); ########################################### # The scaffold Scaffold::Begin( can_open => "when_previous_correct", is_open => "correct_or_first_incorrect", instructor_can_open => "always", after_AnswerDate_can_open => "always", hardcopy_is_open => "correct_or_first_incorrect", allow_next_section_to_open_on_preview => 0, prevent_close_by_preview => 1, ); ########################################### Section::Begin("Part 1: Calculate the dimension"); $ans1 = Real("2"); Context()->texStrings; BEGIN_TEXT Consider the following vectors which belong to the vector space \( V = \mathbb{R}^4 \): \[ \begin{array}{lcl} v_1 & = & $g1 \\ v_2 & = & $g2 \\ v_3 & = & $g3 \\ v_4 & = & $g4 \end{array} \] Let \( U \) be the subspace of \( V \) spanned by these vectors: $BCENTER \( U = \text{span} \lbrace v_1, v_2, v_3, v_4 \rbrace \). $ECENTER $PAR The dimension of \( U \) is: \( \text{dim} \; U = {} \) \{ $ans1->ans_array(3) \}. $PAR END_TEXT Context()->normalStrings; WEIGHTED_ANS( $ans1->cmp(), 10 ); Section::End(); ########################################### Section::Begin("Part 2: Find a basis"); Context('Matrix'); $multians1 = MultiAnswer($vec1, $vec2)->with( singleResult => 1, separator => ',', tex_separator => ',', allowBlankAnswers=>0, checker => ~~&basis_checker_rows_tani, ); Context()->texStrings; BEGIN_TEXT Enter a basis \( \mathcal{B} \) of \( U \) below. $BR $BCENTER \( \mathcal{B} = \left\lbrace \;\; \rule{0pt}{20pt} \right. \) \( u_1 = \) \{ $multians1->ans_array(3) \} \( , \) $BR \( \rule{60pt}{0pt} u_2 = \) \{ $multians1->ans_array(3) \} \( \left. \;\; \rule{0pt}{20pt} \;\; \right\rbrace \) $ECENTER END_TEXT Context()->normalStrings; WEIGHTED_ANS( $multians1->cmp(), 90 ); Section::End(); Scaffold::End(); ENDDOCUMENT();