##DESCRIPTION
##   
##ENDDESCRIPTION

##KEYWORDS('calculus', '', '')

## DBsubject('Calculus - single variable')
## DBchapter('')
## DBsection('')
## Date('6/15/2019')
## Author('K. Andrew Parker')
## Institution('CityTech')

########################################################################

DOCUMENT();      

loadMacros(
   "PGstandard.pl",     # Standard macros for PG language
   "MathObjects.pl",
   "PGML.pl",
   "contextFraction.pl",
   "contextLimitedVector.pl",
   "PGchoicemacros.pl"
);

# Print problem number and point value (weight) for the problem
TEXT(beginproblem());

# Show which answers are correct and which ones are incorrect
$showPartialCorrectAnswers = 1;

##############################################################
#
#  Setup
#
#

Context("Vector2D");
Context()->flags->set(reduceConstants=>0,ijk=>1);
Context()->constants->set(i=>{TeX=>'\vec{i}'});
Context()->constants->set(j=>{TeX=>'\vec{j}'});

@c1i = NchooseK(9,4);
foreach my $c (@c1i) { $c = random(-1,1,2)*($c+2); }
@c1j = NchooseK(9,4);
foreach my $c (@c1j) { $c = random(-1,1,2)*($c+2); }
@c2i = NchooseK(9,4);
foreach my $c (@c2i) { $c = random(-1,1,2)*($c+2); }
@c2j = NchooseK(9,4);
foreach my $c (@c2j) { $c = random(-1,1,2)*($c+2); }


@ai = (); @aj=();
@q = ();
for my $i (0..3) {
    my @terms = (
        Vector("$c1i[$i] i"),
        Vector("$c2i[$i] i"),
        Vector("$c1j[$i] j"),
        Vector("$c2j[$i] j"),
    );
    @terms = @terms[NchooseK(4,4)];
    $q[$i] = Formula("$terms[0]+$terms[1]+$terms[2]+$terms[3]");
    $ai[$i] = Real($c1i[$i]+$c2i[$i])->reduce;
    $aj[$i] = Real($c1j[$i]+$c2j[$i])->reduce;
}

Context("LimitedVector-ijk");
Context()->flags->set(reduceConstants=>0,ijk=>1);
Context()->constants->set(i=>{TeX=>'\vec{i}'});
Context()->constants->set(j=>{TeX=>'\vec{j}'});
Context()->constants->remove(k);
Context()->{error}{msg}{"In this context, '*' can only be used with Numbers or i,j and k"} = "Please simplify your answer and try again.";
Context()->{error}{msg}{"In this context, '+' can only be used with Numbers or i,j and k"} = "Please simplify your answer and try again.";
Context()->{error}{msg}{"In this context, '-' can only be used with Numbers or i,j and k"} = "Please simplify your answer and try again.";

@aij = ();
for my $i (0..3) {
    $aij[$i] = Vector("$ai[$i] i + $aj[$i] j");
}

Context("LimitedVector-coordinate");
Context()->flags->set(reduceConstants=>0);
Context()->{error}{msg}{"In this context, '*' can only be used with Numbers or i,j and k"} = "Please simplify your answer and try again.";
Context()->{error}{msg}{"In this context, '+' can only be used with Numbers or i,j and k"} = "Please simplify your answer and try again.";
Context()->{error}{msg}{"In this context, '-' can only be used with Numbers or i,j and k"} = "Please simplify your answer and try again.";

@acomp = ();
for my $i (0..3) {
    $acomp[$i] = Vector("<$ai[$i], $aj[$i]>");
}



##############################################################
#
#  Text
#
#

BEGIN_PGML
>> ## Standard Unit Vectors ## <<

The vector with magnitude [`1`] in the [`x`]-direction is called "[`\vec{i}`]", and the vector with magnitude [`1`] in the [`y`]-direction is called "[`\vec{j}`]".

In other words, [`\vec{i} = \left<1,0\right>`] and [`\vec{j} = \left<0,1\right>`].

### Practice ###

Simplify [` [$q[0]] `] and write your answer in:
    a. [`\vec{i}\vec{j}`]-form: [__________]{$aij[0]}
    b. component-form: [__________]{$acomp[0]}

Simplify [` [$q[1]] `] and write your answer in:
    a. [`\vec{i}\vec{j}`]-form: [__________]{$aij[1]}
    b. component-form: [__________]{$acomp[1]}

Simplify [` [$q[2]] `] and write your answer in:
    a. [`\vec{i}\vec{j}`]-form: [__________]{$aij[2]}
    b. component-form: [__________]{$acomp[2]}

Simplify [` [$q[3]] `] and write your answer in:
    a. [`\vec{i}\vec{j}`]-form: [__________]{$aij[3]}
    b. component-form: [__________]{$acomp[3]}

END_PGML

##############################################################
#
#  Answers
#
#

BEGIN_PGML_HINT
END_PGML_HINT

BEGIN_PGML_SOLUTION
END_PGML_SOLUTION

ENDDOCUMENT();        
