Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7639 > unrolled thread
| Started by | per@RQNNE.invalid (Per Rønne) |
|---|---|
| First post | 2012-01-07 10:29 +0000 |
| Last post | 2012-01-22 12:32 +0000 |
| Articles | 7 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
MatrixPower problem per@RQNNE.invalid (Per Rønne) - 2012-01-07 10:29 +0000
Re: MatrixPower problem David Bailey <dave@removedbailey.co.uk> - 2012-01-08 09:28 +0000
Re: MatrixPower problem per@RQNNE.invalid (Per Rønne) - 2012-01-09 08:24 +0000
Re: MatrixPower problem roby <roby.nowak@gmail.com> - 2012-01-11 22:24 +0000
Re: MatrixPower problem per@RQNNE.invalid (Per Rønne) - 2012-01-18 11:08 +0000
Re: MatrixPower problem roby <roby.nowak@gmail.com> - 2012-01-19 10:10 +0000
Re: MatrixPower problem per@RQNNE.invalid (Per Rønne) - 2012-01-22 12:32 +0000
| From | per@RQNNE.invalid (Per Rønne) |
|---|---|
| Date | 2012-01-07 10:29 +0000 |
| Subject | MatrixPower problem |
| Message-ID | <je96q1$j7o$1@smc.vnet.net> |
I have defined the following matrix:
P = {{0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0},
{0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0}, {0, 0, 1/3, 0, 1}}
And the following vector:
e1 = {1, 0, 0, 0, 0}
I try to solve:
Limit[MatrixPower[P, k].e1, k -> \[Infinity]]
And get the correct result:
Out[7] = {0, 0, 0, 0, 1}
But if I write the first statement as:
P = {{0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0},
{0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0}, {0, 0, 1/3, 0, 1}}
//MatrixForm
I will not only get a more readle Out-format of the matrix. My
Mathematica 8.1 for Students will also deny to calculate what is
demanded. It will just list
Limit[MatrixPower[P, k].e1, k -> \[Infinity]]
with P replaced with the contents of the 5*5 matrix.
I simply don't understant why.
The output I can be pasted as:
At least I get the following output:
Limit[MatrixPower[\!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"0",
FractionBox["1", "2"], "0",
FractionBox["1", "2"], "0"},
{
FractionBox["1", "2"], "0",
FractionBox["1", "3"], "0", "0"},
{"0",
FractionBox["1", "2"], "0",
FractionBox["1", "2"], "0"},
{
FractionBox["1", "2"], "0",
FractionBox["1", "3"], "0", "0"},
{"0", "0",
FractionBox["1", "3"], "0", "1"}
},
GridBoxAlignment->{
"Columns" -> {{Center}}, "ColumnsIndexed" -> {},
"Rows" -> {{Baseline}}, "RowsIndexed" -> {}},
GridBoxSpacings->{"Columns" -> {
Offset[0.27999999999999997`], {
Offset[0.7]},
Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {
Offset[0.2], {
Offset[0.4]},
Offset[0.2]}, "RowsIndexed" -> {}}], "", ")"}],
Function[BoxForm`e$,
MatrixForm[BoxForm`e$]]]\), k].{1, 0, 0, 0, 0}, k -> \[Infinity]]
--
Per Erik Rønne
http://www.RQNNE.dk
Errare humanum est, sed in errore perseverare turpe
[toc] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2012-01-08 09:28 +0000 |
| Message-ID | <jebnjq$1cs$1@smc.vnet.net> |
| In reply to | #7639 |
On 07/01/2012 10:29, Per R=F8nne wrote:
> I have defined the following matrix:
>
> P = {{0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0},
> {0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0}, {0, 0, 1/3, 0, 1}}
>
> And the following vector:
>
> e1 = {1, 0, 0, 0, 0}
>
> I try to solve:
>
> Limit[MatrixPower[P, k].e1, k -> \[Infinity]]
>
> And get the correct result:
>
> Out[7] = {0, 0, 0, 0, 1}
>
> But if I write the first statement as:
>
> P = {{0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0},
> {0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0}, {0, 0, 1/3, 0, 1}}
> //MatrixForm
>
> I will not only get a more readle Out-format of the matrix. My
> Mathematica 8.1 for Students will also deny to calculate what is
> demanded. It will just list
>
> Limit[MatrixPower[P, k].e1, k -> \[Infinity]]
>
> with P replaced with the contents of the 5*5 matrix.
>
> I simply don't understant why.
>
>
> The output I can be pasted as:
>
> At least I get the following output:
>
> Limit[MatrixPower[\!\(\*
> TagBox[
> RowBox[{"(", "", GridBox[{
> {"0",
> FractionBox["1", "2"], "0",
> FractionBox["1", "2"], "0"},
> {
> FractionBox["1", "2"], "0",
> FractionBox["1", "3"], "0", "0"},
> {"0",
> FractionBox["1", "2"], "0",
> FractionBox["1", "2"], "0"},
> {
> FractionBox["1", "2"], "0",
> FractionBox["1", "3"], "0", "0"},
> {"0", "0",
> FractionBox["1", "3"], "0", "1"}
> },
> GridBoxAlignment->{
> "Columns" -> {{Center}}, "ColumnsIndexed" -> {},
> "Rows" -> {{Baseline}}, "RowsIndexed" -> {}},
> GridBoxSpacings->{"Columns" -> {
> Offset[0.27999999999999997`], {
> Offset[0.7]},
> Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {
> Offset[0.2], {
> Offset[0.4]},
> Offset[0.2]}, "RowsIndexed" -> {}}], "", ")"}],
> Function[BoxForm`e$,
> MatrixForm[BoxForm`e$]]]\), k].{1, 0, 0, 0, 0}, k -> \[Infinity]]
>
The following expression is wrong:
P = {{0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0},
{0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0}, {0, 0, 1/3, 0, 1}}
//MatrixForm
To see what is wrong, type P//FullForm
As you will see, the MatrixForm has become part of the expression
contained in P!
Instead write:
P = {{0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0},
{0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0}, {0, 0, 1/3, 0, 1}};
P//MatrixForm
BTW, it is best to avoid variables that start with a capital letter, as
these can clash with new definitions in later versions of Mathematica.
David Bailey
http://www.dbaileyconsultancy.co.uk
[toc] | [prev] | [next] | [standalone]
| From | per@RQNNE.invalid (Per Rønne) |
|---|---|
| Date | 2012-01-09 08:24 +0000 |
| Message-ID | <jee87q$d1p$1@smc.vnet.net> |
| In reply to | #7662 |
David Bailey <dave@removedbailey.co.uk> wrote:
> On 07/01/2012 10:29, Per R=F8nne wrote:
> > I have defined the following matrix:
> >
> > P = {{0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0},
> > {0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0}, {0, 0, 1/3, 0, 1}}
> >
> > And the following vector:
> >
> > e1 = {1, 0, 0, 0, 0}
> >
> > I try to solve:
> >
> > Limit[MatrixPower[P, k].e1, k -> \[Infinity]]
> >
> > And get the correct result:
> >
> > Out[7] = {0, 0, 0, 0, 1}
> >
> > But if I write the first statement as:
> >
> > P = {{0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0},
> > {0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0}, {0, 0, 1/3, 0, 1}}
> > //MatrixForm
> >
> > I will not only get a more readle Out-format of the matrix. My
> > Mathematica 8.1 for Students will also deny to calculate what is
> > demanded. It will just list
> >
> > Limit[MatrixPower[P, k].e1, k -> \[Infinity]]
> >
> > with P replaced with the contents of the 5*5 matrix.
> >
> > I simply don't understant why.
> >
> >
> > The output I can be pasted as:
> >
> > At least I get the following output:
> >
> > Limit[MatrixPower[\!\(\*
> > TagBox[
> > RowBox[{"(", "", GridBox[{
> > {"0",
> > FractionBox["1", "2"], "0",
> > FractionBox["1", "2"], "0"},
> > {
> > FractionBox["1", "2"], "0",
> > FractionBox["1", "3"], "0", "0"},
> > {"0",
> > FractionBox["1", "2"], "0",
> > FractionBox["1", "2"], "0"},
> > {
> > FractionBox["1", "2"], "0",
> > FractionBox["1", "3"], "0", "0"},
> > {"0", "0",
> > FractionBox["1", "3"], "0", "1"}
> > },
> > GridBoxAlignment->{
> > "Columns" -> {{Center}}, "ColumnsIndexed" -> {},
> > "Rows" -> {{Baseline}}, "RowsIndexed" -> {}},
> > GridBoxSpacings->{"Columns" -> {
> > Offset[0.27999999999999997`], {
> > Offset[0.7]},
> > Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {
> > Offset[0.2], {
> > Offset[0.4]},
> > Offset[0.2]}, "RowsIndexed" -> {}}], "", ")"}],
> > Function[BoxForm`e$,
> > MatrixForm[BoxForm`e$]]]\), k].{1, 0, 0, 0, 0}, k -> \[Infinity]]
> >
>
> The following expression is wrong:
>
> P = {{0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0},
> {0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0}, {0, 0, 1/3, 0, 1}}
> //MatrixForm
>
> To see what is wrong, type P//FullForm
>
> As you will see, the MatrixForm has become part of the expression
> contained in P!
Yes, I see. I just fail to see the purpose of such a behaviour.
> Instead write:
>
> P = {{0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0},
> {0, 1/2, 0, 1/2, 0}, {1/2, 0, 1/3, 0, 0}, {0, 0, 1/3, 0, 1}};
>
> P//MatrixForm
Another poster has suggested I put the assignment statement in
parentheses and place the //MatrixForm after the end parenthesis. A
third that I make a MatrixForm[P] instead of your P//MatrixForm.
Well, I have received two replies in my inbox that have not yet come
through to the moderated usenet group.
> BTW, it is best to avoid variables that start with a capital letter, as
> these can clash with new definitions in later versions of Mathematica.
I know. But in this case it is being used in a Linear Algebra assignment
at college. And in the assignment (meant for another system) capital P is used.
BTW, this other system proved unable to calculate Limit[MatrixPower[P, k].e1, k -> \[Infinity]]. Well, limit(P^k.e1,k=infinity).
Instead, you have to manually simplify the problem before it is handled
over to the other system. Which may be good for learners - but cumbersome for
users.
P contains probabilities. Consequently, every column adds up to 1.
--
Per Erik Rønne
http://www.RQNNE.dk
Errare humanum est, sed in errore perseverare turpe
[toc] | [prev] | [next] | [standalone]
| From | roby <roby.nowak@gmail.com> |
|---|---|
| Date | 2012-01-11 22:24 +0000 |
| Message-ID | <jel26f$ln1$1@smc.vnet.net> |
| In reply to | #7639 |
Hello,
one could check every expression and its sub sub... subexpression for
the occurence of a matrix and force MatrixForm on output for these.
$Post := Map[If[MatrixQ@#, MatrixForm@#, #] &, #, {0, Infinity}] &
Cheers Robert
[toc] | [prev] | [next] | [standalone]
| From | per@RQNNE.invalid (Per Rønne) |
|---|---|
| Date | 2012-01-18 11:08 +0000 |
| Message-ID | <jf697u$ge3$1@smc.vnet.net> |
| In reply to | #7753 |
roby <roby.nowak@gmail.com> wrote:
> one could check every expression and its sub sub... subexpression for
> the occurence of a matrix and force MatrixForm on output for these.
>
> $Post := Map[If[MatrixQ@#, MatrixForm@#, #] &, #, {0, Infinity}] &
Which gives the following error:
Function::slot: Slot[(If[MatrixQ[#1],#1,#1]&)[1]] (in
(If[MatrixQ[#1],#1,#1]&)[Map[(If[MatrixQ[#1],#1,#1]&)[(If[MatrixQ[<<1>>]
,<<1>>,Slot[<<1>>]]&)[If[(<<1>>&)[<<1>>],(<<1>>&)[<<1>>],(<<1>>&)[<<1>>]
]]&],(If[MatrixQ[#1],#1,#1]&)[Slot[(If[MatrixQ[<<1>>],<<1>>,Slot[<<1>>]]
&)[1]]],(If[MatrixQ[#1],#1,#1]&)[{(If[MatrixQ[<<1>>],<<1>>,Slot[<<1>>]]&
)[0],(If[MatrixQ[<<1>>],<<1>>,Slot[<<1>>]]&)[\[Infinity]]}]]]&) should
contain a non-negative integer. >>
--
Per Erik Rønne
http://www.RQNNE.dk
Errare humanum est, sed in errore perseverare turpe
[toc] | [prev] | [next] | [standalone]
| From | roby <roby.nowak@gmail.com> |
|---|---|
| Date | 2012-01-19 10:10 +0000 |
| Message-ID | <jf8q60$3i0$1@smc.vnet.net> |
| In reply to | #7982 |
Well, this is strangely.
When dou you get the error, as soon as you enter: $Post :=
Map[If[MatrixQ@#, MatrixForm@#, #] &, #, {0, Infinity}] &
or not until you enter some matrix ?
Which version of Mathematica do you use ?
I tested flawless with 7.0, 8.0
You could try to replace infinity by some "sufficient" high integer
e.g.: $Post := Map[If[MatrixQ@#, MatrixForm@#, #] &, #, {0, 1000}] &
Cheers Robert
On 18 Jan., 12:08, p...@RQNNE.invalid (Per R=F8nne) wrote:
> roby <roby.no...@gmail.com> wrote:
> > one could check every expression and its sub sub... subexpression for
> > the occurence of a matrix and force MatrixForm on output for these.
>
> > $Post := Map[If[MatrixQ@#, MatrixForm@#, #] &, #, {0, Infinity}] &
>
> Which gives the following error:
>
> Function::slot: Slot[(If[MatrixQ[#1],#1,#1]&)[1]] (in
> (If[MatrixQ[#1],#1,#1]&)[Map[(If[MatrixQ[#1],#1,#1]&)[(If[MatrixQ[<<1>>]
> ,<<1>>,Slot[<<1>>]]&)[If[(<<1>>&)[<<1>>],(<<1>>&)[<<1>>],(<<1>>&)[<<1>>]
> ]]&],(If[MatrixQ[#1],#1,#1]&)[Slot[(If[MatrixQ[<<1>>],<<1>>,Slot[<<1>>]]
> &)[1]]],(If[MatrixQ[#1],#1,#1]&)[{(If[MatrixQ[<<1>>],<<1>>,Slot[<<1>>]]&
> )[0],(If[MatrixQ[<<1>>],<<1>>,Slot[<<1>>]]&)[\[Infinity]]}]]]&) should
> contain a non-negative integer. >>
> --
> Per Erik R=F8nnehttp://www.RQNNE.dk
> Errare humanum est, sed in errore perseverare turpe
[toc] | [prev] | [next] | [standalone]
| From | per@RQNNE.invalid (Per Rønne) |
|---|---|
| Date | 2012-01-22 12:32 +0000 |
| Message-ID | <jfgvkk$pm7$1@smc.vnet.net> |
| In reply to | #7994 |
roby <roby.nowak@gmail.com> wrote:
> Well, this is strangely.
>
> When dou you get the error, as soon as you enter: $Post :=
> Map[If[MatrixQ@#, MatrixForm@#, #] &, #, {0, Infinity}] &
> or not until you enter some matrix ?
>
> Which version of Mathematica do you use ?
8.04.0 for Students.
But now it says:
In[1]:= $Post:=Map[If[MatrixQ@#,MatrixForm@#,#]&,#,{0,Infinity}]&
In[2]:= {1,1}
Out[2]= {1,1}
And when I remove the ampersand, all output is preceded with an #-like
character.
Since it is around a week ago since I posted it, I don't recall how I
did it.
> I tested flawless with 7.0, 8.0
>
> You could try to replace infinity by some "sufficient" high integer
> e.g.: $Post := Map[If[MatrixQ@#, MatrixForm@#, #] &, #, {0, 1000}] &
--
Per Erik Rønne
http://www.RQNNE.dk
Errare humanum est, sed in errore perseverare turpe
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web