WeBWorK Problems

Variable in a matrix:why is 'x' ok but not 't'?

Variable in a matrix:why is 'x' ok but not 't'?

by Jack Dockery -
Number of replies: 2
I am trying to use the variable t instead of x in the matrix $M below and can't seem to figure out how to do so and I am not sure why 'x' works. Any help would be great.



## DBchapter(Operation calculus)
## Level(3)

DOCUMENT();

loadMacros(
"PGstandard.pl",
"PGML.pl",
"MathObjects.pl",
"MatrixUnits.pl",
"VectorListCheckers.pl",
"PGchoicemacros.pl",
"contextFraction.pl",
"parserRadioButtons.pl",
#"PGchoicemacros.pl",
"unionLists.pl",
"PGcourse.pl",
);

Context("Matrix");
$S = Matrix([[Compute(random(4,6)),0,0],
[0,Compute(non_zero_random(2,6)),0],
[0,0,Compute(non_zero_random(-10,2))]]);
$s11=$S->element(1,1);
$s22=$S->element(2,2);
$s33=$S->element(3,3);
$M = Matrix(["e^(x*$s11)",0,0],
[0,"e^(x*$s22)",0],
[0,0,"e^(x*$s33)"]);


BEGIN_PGML
Recall that
[`` e^{t} = 1 + t + \frac{t^2}{2!} + \frac{t^3}{3!}+\cdots ``]

With this it seems reasonable to define
[`` e^{Ax} = I + xA + \frac{(xA)^2}{2!} + \frac{(xA)^3}{3!}+\cdots ``]
where [` x `] is a scalar.

Suppose that [` A `] is diagonlizable with eigenvalues [` \lambda_1=[$s11], \lambda_2=[$s22], \lambda_3=[$s33]`] so that
[` A `] is given by
[``A = W [$S] W^{-1}``]
where the columns of [` W `] are the eigenvectors of [` A `]: [` v_1, v_2, v_3 `].

Check to see that
[` (x A)^n = W \left[ \begin{array}{ccc}
([$s11] x)^n & 0 & 0 \\
0 & ([$s22] x)^n &0 \\
0 & 0 & ([$s33] x)^n
\end{array}
\right] W^{-1} `]

Given that, what is:
[``e^{xA} = W``][____]*{$M}[``W^{-1}?``]

END_PGML

ENDDOCUMENT();
In reply to Jack Dockery

Re: Variable in a matrix:why is 'x' ok but not 't'?

by Alex Jordan -
Hi Jack,

When you load a context (Context("Matrix")) the context has a set of variables that can be used. This is how it parses some string that a student or the problem-writer uses. It needs to distinguish variables from constants from function names, etc. By default, "x" is often the only variable that comes with a context. But you can add more with a line like:

Context()->variables->add(t=>'Real');

or replace the allowed variables, like:

Context()->variables->are(t=>'Real');

The 'Real' is because you can have variables that take Complex or other values too.

Put one of these lines after declaring the Matrix context, but before making a matrix that uses "t".

Alex