<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, Matrix question</title>
    <link>http://www.mapleprimes.com/questions/36243-Matrix-Question</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Fri, 12 Jun 2026 23:12:19 GMT</lastBuildDate>
    <pubDate>Fri, 12 Jun 2026 23:12:19 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, Matrix question</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, Matrix question</title>
      <link>http://www.mapleprimes.com/questions/36243-Matrix-Question</link>
    </image>
    <item>
      <title>I have tried  but i get</title>
      <link>http://www.mapleprimes.com/questions/36243-Matrix-Question?ref=Feed:MaplePrimes:Matrix question:Comments#answer61377</link>
      <itunes:summary>&lt;p&gt;I have tried&lt;/p&gt;
&lt;p&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot.png" alt="" /&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-1.png" alt="" /&gt;&lt;maple&gt;k[i] := c^2*s[i]^2 - xs[i]^2 - ys[i]^2 - zs[i]^2&lt;/maple&gt;&lt;/p&gt;
&lt;p&gt;but i get Error, bad index into Vector&lt;/p&gt;
&lt;p&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-2.png" alt="" /&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-3.png" alt="" /&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-4.png" alt="" /&gt;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;I have tried&lt;/p&gt;
&lt;p&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot.png" alt="" /&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-1.png" alt="" /&gt;&lt;maple&gt;k[i] := c^2*s[i]^2 - xs[i]^2 - ys[i]^2 - zs[i]^2&lt;/maple&gt;&lt;/p&gt;
&lt;p&gt;but i get Error, bad index into Vector&lt;/p&gt;
&lt;p&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-2.png" alt="" /&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-3.png" alt="" /&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-4.png" alt="" /&gt;&lt;/p&gt;</description>
      <guid>61377</guid>
      <pubDate>Sat, 28 Nov 2009 05:57:29 Z</pubDate>
      <itunes:author>pirolafire</itunes:author>
      <author>pirolafire</author>
    </item>
    <item>
      <title>Matrix</title>
      <link>http://www.mapleprimes.com/questions/36243-Matrix-Question?ref=Feed:MaplePrimes:Matrix question:Comments#answer61378</link>
      <itunes:summary>&lt;p&gt;One way is to just use the Matrix constructor itself to create the new result.&lt;/p&gt;
&lt;pre&gt;
Mnew := Matrix(5,1,(i,j)-&amp;gt;(c^2*s[i,j]^2-x[i,j]^2-y[i,j]^2-z[i,j]^2));
&lt;/pre&gt;
&lt;p&gt;Another way might be to use `zip` or elementwise `^` to get the Matrices with squared entries, and then just do usual addition &amp;amp; subtraction (or scaling by c^2) with those.&lt;/p&gt;
&lt;p&gt;Have you considered using Vectors instead of 5x1 Matrices for s, x, y, and z? If you did, then you could use the Vector constructor in a similar way,&lt;/p&gt;
&lt;pre&gt;
Vnew := Vector(5,(i)-&amp;gt;(c^2*s[i]^2-x[i]^2-y[i]^2-z[i]^2));
&lt;/pre&gt;
&lt;p&gt;Actually, judging by the error message you showed about, it may even be that you are already using Vectors and not 5x1 matrices as initially claimed. If so, then that Vector constructor call above could serve.&lt;/p&gt;
&lt;p&gt;I don't have Maple in front of me, but what would the new elementwise syntax be for this? Does it work ok for caret? &lt;b&gt;c^2*s^~2 - x^~2 - y^~2 -z^~2&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;acer&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;One way is to just use the Matrix constructor itself to create the new result.&lt;/p&gt;
&lt;pre&gt;
Mnew := Matrix(5,1,(i,j)-&amp;gt;(c^2*s[i,j]^2-x[i,j]^2-y[i,j]^2-z[i,j]^2));
&lt;/pre&gt;
&lt;p&gt;Another way might be to use `zip` or elementwise `^` to get the Matrices with squared entries, and then just do usual addition &amp;amp; subtraction (or scaling by c^2) with those.&lt;/p&gt;
&lt;p&gt;Have you considered using Vectors instead of 5x1 Matrices for s, x, y, and z? If you did, then you could use the Vector constructor in a similar way,&lt;/p&gt;
&lt;pre&gt;
Vnew := Vector(5,(i)-&amp;gt;(c^2*s[i]^2-x[i]^2-y[i]^2-z[i]^2));
&lt;/pre&gt;
&lt;p&gt;Actually, judging by the error message you showed about, it may even be that you are already using Vectors and not 5x1 matrices as initially claimed. If so, then that Vector constructor call above could serve.&lt;/p&gt;
&lt;p&gt;I don't have Maple in front of me, but what would the new elementwise syntax be for this? Does it work ok for caret? &lt;b&gt;c^2*s^~2 - x^~2 - y^~2 -z^~2&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;acer&lt;/p&gt;</description>
      <guid>61378</guid>
      <pubDate>Sat, 28 Nov 2009 09:23:45 Z</pubDate>
      <itunes:author>acer</itunes:author>
      <author>acer</author>
    </item>
    <item>
      <title>Ok, here's how I did it:
f</title>
      <link>http://www.mapleprimes.com/questions/36243-Matrix-Question?ref=Feed:MaplePrimes:Matrix question:Comments#answer61379</link>
      <itunes:summary>&lt;p&gt;Ok, here's how I did it:&lt;/p&gt;
&lt;p&gt;f := (5, (i) -&amp;gt; (c^2*s[i,j]^2-x[i,j]^2-y[i,j]^2-z[i,j]^2));&lt;/p&gt;
&lt;p&gt;k := Matrix(5,1,f);&lt;/p&gt;
&lt;p&gt;and it worked.&lt;/p&gt;
&lt;p&gt;I have another question if you don't mind, sorry I am new with maple&lt;/p&gt;
&lt;p&gt;I want to define a new 5x5 matrix which will be called the coefficient matrix. The matrix k by the way is the constant matrix.&lt;/p&gt;
&lt;p&gt;The first column of the coefficient matrix will be 2 times the &lt;i&gt;x&lt;/i&gt; matrix, the second column will be 2 times the &lt;i&gt;y&lt;/i&gt; matrix, the third will be 2 times the z matrix, the forth will be the constant &lt;i&gt;c&lt;/i&gt; times the &lt;i&gt;s&lt;/i&gt; matrix, and all elements of the last and final column are equal to 1.&lt;/p&gt;
&lt;p&gt;I think I can do it by defining each and every single element of the matrix, but I would like to know how to do it without defining each element one by one.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Ok, here's how I did it:&lt;/p&gt;
&lt;p&gt;f := (5, (i) -&amp;gt; (c^2*s[i,j]^2-x[i,j]^2-y[i,j]^2-z[i,j]^2));&lt;/p&gt;
&lt;p&gt;k := Matrix(5,1,f);&lt;/p&gt;
&lt;p&gt;and it worked.&lt;/p&gt;
&lt;p&gt;I have another question if you don't mind, sorry I am new with maple&lt;/p&gt;
&lt;p&gt;I want to define a new 5x5 matrix which will be called the coefficient matrix. The matrix k by the way is the constant matrix.&lt;/p&gt;
&lt;p&gt;The first column of the coefficient matrix will be 2 times the &lt;i&gt;x&lt;/i&gt; matrix, the second column will be 2 times the &lt;i&gt;y&lt;/i&gt; matrix, the third will be 2 times the z matrix, the forth will be the constant &lt;i&gt;c&lt;/i&gt; times the &lt;i&gt;s&lt;/i&gt; matrix, and all elements of the last and final column are equal to 1.&lt;/p&gt;
&lt;p&gt;I think I can do it by defining each and every single element of the matrix, but I would like to know how to do it without defining each element one by one.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
      <guid>61379</guid>
      <pubDate>Sat, 28 Nov 2009 15:03:20 Z</pubDate>
      <itunes:author>pirolafire</itunes:author>
      <author>pirolafire</author>
    </item>
    <item>
      <title>Ok, heres how I finally did</title>
      <link>http://www.mapleprimes.com/questions/36243-Matrix-Question?ref=Feed:MaplePrimes:Matrix question:Comments#answer61380</link>
      <itunes:summary>&lt;p&gt;Ok, heres how I finally did it:&lt;/p&gt;
&lt;p&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-5.png" alt="" /&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-6.png" alt="" /&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-7.png" alt="" /&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-8.png" alt="" /&gt;A:= &amp;lt;2x|2y|2z|c*s|1,1,1,1,1&amp;gt;;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;One last question if you don't mind. I am trying to access the ith element of a column matrix.&lt;/p&gt;
&lt;p&gt;Let's say the 5x1 matrix is called S, when I use S[1]: to access the first element, I get a 1x1 matrix. Is there a way to get the number itself (so it acts like a normal number), and not a 1x1 matrix containing the number?&lt;/p&gt;
&lt;p&gt;thank you&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Ok, heres how I finally did it:&lt;/p&gt;
&lt;p&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-5.png" alt="" /&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-6.png" alt="" /&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-7.png" alt="" /&gt;&lt;img src="file:///C:/Users/admin/AppData/Local/Temp/moz-screenshot-8.png" alt="" /&gt;A:= &amp;lt;2x|2y|2z|c*s|1,1,1,1,1&amp;gt;;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;One last question if you don't mind. I am trying to access the ith element of a column matrix.&lt;/p&gt;
&lt;p&gt;Let's say the 5x1 matrix is called S, when I use S[1]: to access the first element, I get a 1x1 matrix. Is there a way to get the number itself (so it acts like a normal number), and not a 1x1 matrix containing the number?&lt;/p&gt;
&lt;p&gt;thank you&lt;/p&gt;</description>
      <guid>61380</guid>
      <pubDate>Sat, 28 Nov 2009 20:32:14 Z</pubDate>
      <itunes:author>pirolafire</itunes:author>
      <author>pirolafire</author>
    </item>
    <item>
      <title>Yes, caret syntax works</title>
      <link>http://www.mapleprimes.com/questions/36243-Matrix-Question?ref=Feed:MaplePrimes:Matrix question:Comments#comment61382</link>
      <itunes:summary>&lt;p&gt;You can even enter it in 2D mode by just hitting the keys &amp;quot;x&amp;quot;, &amp;quot;^&amp;quot;, &amp;quot;~&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;right arrow&amp;quot; (to get out of the exponent again) and the tilde will be correctly interpreted. I'd say this is the recommended approach, when using Maple 13. (The ?elementwise operators were not available in Maple 12 or earlier.)&lt;/p&gt;
&lt;p&gt;The code snippet pirolafire shows below doesn't make much sense to me, to be honest, and it doesn't seem to work on my machine. My guess would be that either j happened to be defined to be 1 in that session, or there was a typo in the definition of f. In the first case, it's not obvious why it works, but by digging a little we can see what's going on. The Matrix definition would expand to&lt;/p&gt;
&lt;pre&gt;
Matrix(5, 1, 5, (i) -&amp;gt; c^2 * s[i, j]^2 - x[i, j]^2 - y[i, j]^2 - z[i, j]^2);&lt;/pre&gt;
&lt;p&gt;This means: create a five-by-one matrix, set all entries to five, then take the procedure i -&amp;gt; c^2*s[i,j]^2 - ... and feed it all &amp;quot;coordinate pairs&amp;quot; for the entries in the matrix, overwriting all the fives just put in there. Because of the way Maple evaluates function calls, calling that procedure with two coordinates just assigns the first coordinate (the row index) to i and discards the column coordinate. In order for this to give the correct result, j has to be defined externally to be equal to one.&lt;/p&gt;
&lt;p&gt;In the second case, this definition of f would make more sense to me:&lt;/p&gt;
&lt;pre&gt;
f := (i, j) -&amp;gt; c^2 * s[i, j]^2 - x[i, j]^2 - y[i, j]^2 - z[i, j]^2;
&lt;/pre&gt;
&lt;p&gt;That said, I still prefer the elementwise operators. It's much cleaner and allows you to express what you want to do in a more mathematical way.&lt;/p&gt;
&lt;p&gt;Hope this helps,&lt;/p&gt;
&lt;p&gt;Erik Postma&lt;br /&gt;
Maplesoft.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;You can even enter it in 2D mode by just hitting the keys &amp;quot;x&amp;quot;, &amp;quot;^&amp;quot;, &amp;quot;~&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;right arrow&amp;quot; (to get out of the exponent again) and the tilde will be correctly interpreted. I'd say this is the recommended approach, when using Maple 13. (The ?elementwise operators were not available in Maple 12 or earlier.)&lt;/p&gt;
&lt;p&gt;The code snippet pirolafire shows below doesn't make much sense to me, to be honest, and it doesn't seem to work on my machine. My guess would be that either j happened to be defined to be 1 in that session, or there was a typo in the definition of f. In the first case, it's not obvious why it works, but by digging a little we can see what's going on. The Matrix definition would expand to&lt;/p&gt;
&lt;pre&gt;
Matrix(5, 1, 5, (i) -&amp;gt; c^2 * s[i, j]^2 - x[i, j]^2 - y[i, j]^2 - z[i, j]^2);&lt;/pre&gt;
&lt;p&gt;This means: create a five-by-one matrix, set all entries to five, then take the procedure i -&amp;gt; c^2*s[i,j]^2 - ... and feed it all &amp;quot;coordinate pairs&amp;quot; for the entries in the matrix, overwriting all the fives just put in there. Because of the way Maple evaluates function calls, calling that procedure with two coordinates just assigns the first coordinate (the row index) to i and discards the column coordinate. In order for this to give the correct result, j has to be defined externally to be equal to one.&lt;/p&gt;
&lt;p&gt;In the second case, this definition of f would make more sense to me:&lt;/p&gt;
&lt;pre&gt;
f := (i, j) -&amp;gt; c^2 * s[i, j]^2 - x[i, j]^2 - y[i, j]^2 - z[i, j]^2;
&lt;/pre&gt;
&lt;p&gt;That said, I still prefer the elementwise operators. It's much cleaner and allows you to express what you want to do in a more mathematical way.&lt;/p&gt;
&lt;p&gt;Hope this helps,&lt;/p&gt;
&lt;p&gt;Erik Postma&lt;br /&gt;
Maplesoft.&lt;/p&gt;</description>
      <guid>61382</guid>
      <pubDate>Tue, 01 Dec 2009 02:22:34 Z</pubDate>
      <itunes:author>epostma</itunes:author>
      <author>epostma</author>
    </item>
    <item>
      <title>5 x 1</title>
      <link>http://www.mapleprimes.com/questions/36243-Matrix-Question?ref=Feed:MaplePrimes:Matrix question:Comments#comment61381</link>
      <itunes:summary>&lt;p&gt;Try S[1,1].&lt;/p&gt;
&lt;p&gt;Notice that there is a difference between a 5-element column Vector and a 5 x 1 Matrix.&amp;nbsp; S[1] would work if S was a Vector.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Try S[1,1].&lt;/p&gt;
&lt;p&gt;Notice that there is a difference between a 5-element column Vector and a 5 x 1 Matrix.&amp;nbsp; S[1] would work if S was a Vector.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
      <guid>61381</guid>
      <pubDate>Sun, 29 Nov 2009 13:13:14 Z</pubDate>
      <itunes:author>Robert Israel</itunes:author>
      <author>Robert Israel</author>
    </item>
  </channel>
</rss>