## Re: [Maxima-discuss] matrix problem

 Re: [Maxima-discuss] matrix problem From: Jan Brosius - 2014-07-08 17:41:19 Attachments: Message as HTML ```On 08 Jul 2014, at 19:37, Jan Brosius wrote: > > On 08 Jul 2014, at 18:35, Barton Willis wrote: > >> Try this: >> >> (%i7) M : genmatrix(A[phi],3,1); > > All information of phi seems to be lost in M. E.g. if I choose phi:3 then M doesn’t change > >> (%o7) matrix([A[phi](1,1)],[A[phi](2,1)],[A[phi](3,1)]) >> >> Nice way to locally define function A[phi] >> >> (%i8) M, A[phi](i,j) := cos(phi); >> (%o8) matrix([cos(phi)],[cos(phi)],[cos(phi)]) >> >> In Maxima, A[phi](i,j) := cos(phi) defines a memoizing function--there are some things about memoizing functions >> can be a tricky--be careful. >> >> Alternatively, you could simply do >> >> (%i9) M : genmatrix(lambda([i,j], cos(phi)),3,1); >> (%o9) matrix([cos(phi)],[cos(phi)],[cos(phi)]) >> >> --Barton >> >> >> >> From: Jan Brosius >> Sent: Tuesday, July 8, 2014 11:17 >> To: maxima-discuss@... >> Subject: [Maxima-discuss] matrix problem >> >> Hi, >> >> I can define >> >> genmatrix(A[phi],3,1} >> >> but how do I assign a value to e.g. A[phi][2,1]. See below the maxima output >> >> (%i1) genmatrix(A[phi],3,1); >> [ A (1, 1) ] >> [ phi ] >> [ ] >> (%o1) [ A (2, 1) ] >> [ phi ] >> [ ] >> [ A (3, 1) ] >> [ phi ] >> (%i2) A[phi][2,1]:=cos(phi); >> >> define: argument cannot be an atom or a subscripted memoizing function; found: >> (A ) >> phi >> 2, 1 >> -- an error. To debug this try: debugmode(true); >> >> (%i3) A[phi][2,1]:cos(phi); >> >> assignment: cannot assign to (A ) >> phi >> 2, 1 >> -- an error. To debug this try: debugmode(true); >> >> thx for any help >> Jan > ```

 [Maxima-discuss] matrix problem From: Jan Brosius - 2014-07-08 16:17:12 Attachments: Message as HTML ```Hi, I can define genmatrix(A[phi],3,1} but how do I assign a value to e.g. A[phi][2,1]. See below the maxima output (%i1) genmatrix(A[phi],3,1); [ A (1, 1) ] [ phi ] [ ] (%o1) [ A (2, 1) ] [ phi ] [ ] [ A (3, 1) ] [ phi ] (%i2) A[phi][2,1]:=cos(phi); define: argument cannot be an atom or a subscripted memoizing function; found: (A ) phi 2, 1 -- an error. To debug this try: debugmode(true); (%i3) A[phi][2,1]:cos(phi); assignment: cannot assign to (A ) phi 2, 1 -- an error. To debug this try: debugmode(true); thx for any help Jan```
 Re: [Maxima-discuss] matrix problem From: Barton Willis - 2014-07-08 16:36:09 Attachments: Message as HTML ```Try this: (%i7) M : genmatrix(A[phi],3,1); (%o7) matrix([A[phi](1,1)],[A[phi](2,1)],[A[phi](3,1)]) Nice way to locally define function A[phi] (%i8) M, A[phi](i,j) := cos(phi); (%o8) matrix([cos(phi)],[cos(phi)],[cos(phi)]) In Maxima, A[phi](i,j) := cos(phi) defines a memoizing function--there are some things about memoizing functions can be a tricky--be careful. Alternatively, you could simply do (%i9) M : genmatrix(lambda([i,j], cos(phi)),3,1); (%o9) matrix([cos(phi)],[cos(phi)],[cos(phi)]) --Barton ________________________________ From: Jan Brosius Sent: Tuesday, July 8, 2014 11:17 To: maxima-discuss@... Subject: [Maxima-discuss] matrix problem Hi, I can define genmatrix(A[phi],3,1} but how do I assign a value to e.g. A[phi][2,1]. See below the maxima output (%i1) genmatrix(A[phi],3,1); [ A (1, 1) ] [ phi ] [ ] (%o1) [ A (2, 1) ] [ phi ] [ ] [ A (3, 1) ] [ phi ] (%i2) A[phi][2,1]:=cos(phi); define: argument cannot be an atom or a subscripted memoizing function; found: (A ) phi 2, 1 -- an error. To debug this try: debugmode(true); (%i3) A[phi][2,1]:cos(phi); assignment: cannot assign to (A ) phi 2, 1 -- an error. To debug this try: debugmode(true); thx for any help Jan ```
 Re: [Maxima-discuss] matrix problem From: Jan Brosius - 2014-07-08 17:41:19 Attachments: Message as HTML ```On 08 Jul 2014, at 19:37, Jan Brosius wrote: > > On 08 Jul 2014, at 18:35, Barton Willis wrote: > >> Try this: >> >> (%i7) M : genmatrix(A[phi],3,1); > > All information of phi seems to be lost in M. E.g. if I choose phi:3 then M doesn’t change > >> (%o7) matrix([A[phi](1,1)],[A[phi](2,1)],[A[phi](3,1)]) >> >> Nice way to locally define function A[phi] >> >> (%i8) M, A[phi](i,j) := cos(phi); >> (%o8) matrix([cos(phi)],[cos(phi)],[cos(phi)]) >> >> In Maxima, A[phi](i,j) := cos(phi) defines a memoizing function--there are some things about memoizing functions >> can be a tricky--be careful. >> >> Alternatively, you could simply do >> >> (%i9) M : genmatrix(lambda([i,j], cos(phi)),3,1); >> (%o9) matrix([cos(phi)],[cos(phi)],[cos(phi)]) >> >> --Barton >> >> >> >> From: Jan Brosius >> Sent: Tuesday, July 8, 2014 11:17 >> To: maxima-discuss@... >> Subject: [Maxima-discuss] matrix problem >> >> Hi, >> >> I can define >> >> genmatrix(A[phi],3,1} >> >> but how do I assign a value to e.g. A[phi][2,1]. See below the maxima output >> >> (%i1) genmatrix(A[phi],3,1); >> [ A (1, 1) ] >> [ phi ] >> [ ] >> (%o1) [ A (2, 1) ] >> [ phi ] >> [ ] >> [ A (3, 1) ] >> [ phi ] >> (%i2) A[phi][2,1]:=cos(phi); >> >> define: argument cannot be an atom or a subscripted memoizing function; found: >> (A ) >> phi >> 2, 1 >> -- an error. To debug this try: debugmode(true); >> >> (%i3) A[phi][2,1]:cos(phi); >> >> assignment: cannot assign to (A ) >> phi >> 2, 1 >> -- an error. To debug this try: debugmode(true); >> >> thx for any help >> Jan > ```
 [Maxima-discuss] Fwd: matrix problem From: Jan Brosius - 2014-07-08 19:05:23 Attachments: Message as HTML ```Hi, below I tried to define a memoising matrix function but without success. However I found an elegant solution see below (%i1) f[x]:=(X[1,1]:cos(x),X[2,1]:cos(x)*2,X[3,1]:sin(x),genmatrix(X,3,1)); (%o1) f := (X : cos(x), X : cos(x) 2, X : sin(x), x 1, 1 2, 1 3, 1 genmatrix(X, 3, 1)) (%i2) numer:true; (%o2) true (%i3) Y:expand(f[3]+matrix([2],[1],[4])); [ 1.010007503399555 ] [ ] (%o3) [ - 0.9799849932008908 ] [ ] [ 4.141120008059867 ] My question is: can I do the same thing but without using the expand function (e.g. are there some variables that I can set to true that work)? Begin forwarded message: > From: Jan Brosius > Subject: matrix problem > Date: 8 Jul 2014 18:17:00 GMT+2 > To: "maxima-discuss@..." > > Hi, > > I can define > > genmatrix(A[phi],3,1} > > but how do I assign a value to e.g. A[phi][2,1]. See below the maxima output > > (%i1) genmatrix(A[phi],3,1); > [ A (1, 1) ] > [ phi ] > [ ] > (%o1) [ A (2, 1) ] > [ phi ] > [ ] > [ A (3, 1) ] > [ phi ] > (%i2) A[phi][2,1]:=cos(phi); > > define: argument cannot be an atom or a subscripted memoizing function; found: > (A ) > phi > 2, 1 > -- an error. To debug this try: debugmode(true); > > (%i3) A[phi][2,1]:cos(phi); > > assignment: cannot assign to (A ) > phi > 2, 1 > -- an error. To debug this try: debugmode(true); > > thx for any help > Jan ```