<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Don&#8217;t invert that matrix</title>
	<atom:link href="http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/</link>
	<description>The blog of John D. Cook</description>
	<lastBuildDate>Sat, 11 Feb 2012 01:10:06 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Yang</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-136192</link>
		<dc:creator>Yang</dc:creator>
		<pubDate>Wed, 08 Feb 2012 20:57:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-136192</guid>
		<description>&quot;In fact, under reasonable assumptions on how the inverse is computed, x=inv(A)*b is as accurate as the solution computed by the best backward-stable solvers.&quot;

http://arxiv.org/pdf/1201.6035v1.pdf</description>
		<content:encoded><![CDATA[<p>&#8220;In fact, under reasonable assumptions on how the inverse is computed, x=inv(A)*b is as accurate as the solution computed by the best backward-stable solvers.&#8221;</p>
<p><a href="http://arxiv.org/pdf/1201.6035v1.pdf" rel="nofollow">http://arxiv.org/pdf/1201.6035v1.pdf</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Example of not inverting a matrix: optimization &#8212; The Endeavour</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-136103</link>
		<dc:creator>Example of not inverting a matrix: optimization &#8212; The Endeavour</dc:creator>
		<pubDate>Wed, 08 Feb 2012 13:02:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-136103</guid>
		<description>[...] are invariably surprised when they hear it&#8217;s hardly ever necessary to invert a matrix. It&#8217;s very often necessary solve linear systems of the form Ax = b, but in practice you [...]</description>
		<content:encoded><![CDATA[<p>[...] are invariably surprised when they hear it&#8217;s hardly ever necessary to invert a matrix. It&#8217;s very often necessary solve linear systems of the form Ax = b, but in practice you [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Warwick Dumas</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-120105</link>
		<dc:creator>Warwick Dumas</dc:creator>
		<pubDate>Tue, 06 Dec 2011 21:05:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-120105</guid>
		<description>Wow someone gave the proper answer.</description>
		<content:encoded><![CDATA[<p>Wow someone gave the proper answer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Warwick Dumas</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-120104</link>
		<dc:creator>Warwick Dumas</dc:creator>
		<pubDate>Tue, 06 Dec 2011 21:03:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-120104</guid>
		<description>OK I could be wrong about this, but a back-of-envelope reckoning indicates that for a vector z, 
z^T HH^T z = sum{columns of H} [ (z.h column j)^2 ]
So according to that, HH^T simply cannot have a nontrivial kernel, unless H itself is something strange.
However, I could always be wrong.

If I am correct that HH^T has to be invertible, then it follows that HPH^T is invertible. 

I don&#039;t see physically why your stepping equation should be insoluble when m &gt; n. In fact I think it should not be insoluble even if m &lt; n, as the Kalman filter is just giving you the best estimate.</description>
		<content:encoded><![CDATA[<p>OK I could be wrong about this, but a back-of-envelope reckoning indicates that for a vector z,<br />
z^T HH^T z = sum{columns of H} [ (z.h column j)^2 ]<br />
So according to that, HH^T simply cannot have a nontrivial kernel, unless H itself is something strange.<br />
However, I could always be wrong.</p>
<p>If I am correct that HH^T has to be invertible, then it follows that HPH^T is invertible. </p>
<p>I don&#8217;t see physically why your stepping equation should be insoluble when m &gt; n. In fact I think it should not be insoluble even if m &lt; n, as the Kalman filter is just giving you the best estimate.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raequin</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-120103</link>
		<dc:creator>raequin</dc:creator>
		<pubDate>Tue, 06 Dec 2011 21:01:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-120103</guid>
		<description>@John Moeller  Thanks, that&#039;s clear.</description>
		<content:encoded><![CDATA[<p>@John Moeller  Thanks, that&#8217;s clear.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Moeller</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-120102</link>
		<dc:creator>John Moeller</dc:creator>
		<pubDate>Tue, 06 Dec 2011 20:59:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-120102</guid>
		<description>If P is PSD, then so is HPH&#039;. Just consider y&#039;HPH&#039;y. x&#039;Px is positive for any x, therefore it&#039;s positive for any H&#039;y. Since y&#039;HPH&#039;y is positive for any y, then HPH&#039; is PSD. 

The sum of two PSD matrices is always PSD (the positive semidefinite matrices form a cone in the vector space of all symmetric matrices; cones are closed under sum). So if P and W are PSD, then so is HPH&#039; + W. If W is not singular, or if H and P are not singular, then HPH&#039; + W is invertible.</description>
		<content:encoded><![CDATA[<p>If P is PSD, then so is HPH&#8217;. Just consider y&#8217;HPH&#8217;y. x&#8217;Px is positive for any x, therefore it&#8217;s positive for any H&#8217;y. Since y&#8217;HPH&#8217;y is positive for any y, then HPH&#8217; is PSD. </p>
<p>The sum of two PSD matrices is always PSD (the positive semidefinite matrices form a cone in the vector space of all symmetric matrices; cones are closed under sum). So if P and W are PSD, then so is HPH&#8217; + W. If W is not singular, or if H and P are not singular, then HPH&#8217; + W is invertible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raequin</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-120095</link>
		<dc:creator>raequin</dc:creator>
		<pubDate>Tue, 06 Dec 2011 20:23:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-120095</guid>
		<description>@Matt  I know that a covariance matrix is positive semidefinite, but I&#039;m not sure about a) the characteristics of HPH&#039;, and b) the characteristics of two positive semidefinite matrices.

@ Warwick  You are correct about my meaning for m &gt; n.  As per your comment on invertibility, I don&#039;t know that I have a sum of invertibles.  HH&#039; is definitely not invertible, am not sure about HPH&#039;.  The current method is to get a least-squares fit with a pseudoinverse.

-----

I hate to clog the comments section like this, so bear with me.  The following excerpt bears directly on my application.  It covers my implementation question I started off asking, but I still don&#039;t see how the matrix sum is guaranteed to be symmetric, positive-definite.  Any thoughts?



From _Kalman Filtering; Theory and Practice Using MATLAB_, second edition, by Grewal and Andrews:

Cholesky decomposition provides an effcient and numerically stable method for solving equations of the form AX = Y when A is a symmetric, positive-definite matrix.  The modified Cholesky decomposition is even better, because it avoids taking scalar square roots.  It is the recommended method for forming the term

(HPH&#039; + R)^-1 H

 in the conventional Kalman filter without explicitly inverting a matrix.  That is, if one
decomposes HPH&#039; + R as UDU&#039; , then

(UDU&#039;)(HPH&#039; + R)^-1 H = H.

It then suffices to solve

UDU&#039;X = H

for X.



I&#039;d say that this answers the implementation question I posed.  There&#039;s still the matter of invertibility of

HPH&#039; + W

but this page is for alternatives to matrix inversion so I&#039;ll leave off posting any more questions here.  Thanks Matt and Warwick!</description>
		<content:encoded><![CDATA[<p>@Matt  I know that a covariance matrix is positive semidefinite, but I&#8217;m not sure about a) the characteristics of HPH&#8217;, and b) the characteristics of two positive semidefinite matrices.</p>
<p>@ Warwick  You are correct about my meaning for m &gt; n.  As per your comment on invertibility, I don&#8217;t know that I have a sum of invertibles.  HH&#8217; is definitely not invertible, am not sure about HPH&#8217;.  The current method is to get a least-squares fit with a pseudoinverse.</p>
<p>&#8212;&#8211;</p>
<p>I hate to clog the comments section like this, so bear with me.  The following excerpt bears directly on my application.  It covers my implementation question I started off asking, but I still don&#8217;t see how the matrix sum is guaranteed to be symmetric, positive-definite.  Any thoughts?</p>
<p>From _Kalman Filtering; Theory and Practice Using MATLAB_, second edition, by Grewal and Andrews:</p>
<p>Cholesky decomposition provides an effcient and numerically stable method for solving equations of the form AX = Y when A is a symmetric, positive-definite matrix.  The modified Cholesky decomposition is even better, because it avoids taking scalar square roots.  It is the recommended method for forming the term</p>
<p>(HPH&#8217; + R)^-1 H</p>
<p> in the conventional Kalman filter without explicitly inverting a matrix.  That is, if one<br />
decomposes HPH&#8217; + R as UDU&#8217; , then</p>
<p>(UDU&#8217;)(HPH&#8217; + R)^-1 H = H.</p>
<p>It then suffices to solve</p>
<p>UDU&#8217;X = H</p>
<p>for X.</p>
<p>I&#8217;d say that this answers the implementation question I posed.  There&#8217;s still the matter of invertibility of</p>
<p>HPH&#8217; + W</p>
<p>but this page is for alternatives to matrix inversion so I&#8217;ll leave off posting any more questions here.  Thanks Matt and Warwick!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Warwick Dumas</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-120081</link>
		<dc:creator>Warwick Dumas</dc:creator>
		<pubDate>Tue, 06 Dec 2011 19:41:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-120081</guid>
		<description>I would have thought (could be wrong) that for the sum of invertibles (with physical meanings) to be noninvertible implies some kind of special relationship between the summands. Given your physical definitions I don&#039;t see how you&#039;d get that. Degenerate matrices don&#039;t occur by chance.

If your equations do not have a solution (overdetermined), then you can get the least-squares fit with a pseudoinverse, and I guess there are then similar decompositions for that. I don&#039;t know whether a Kalman filter should lead to insoluble equations. 

When you say m &gt; n, I am taking it that means your observation y is an m-vector but your underlying process x is an n-vector. Correct?</description>
		<content:encoded><![CDATA[<p>I would have thought (could be wrong) that for the sum of invertibles (with physical meanings) to be noninvertible implies some kind of special relationship between the summands. Given your physical definitions I don&#8217;t see how you&#8217;d get that. Degenerate matrices don&#8217;t occur by chance.</p>
<p>If your equations do not have a solution (overdetermined), then you can get the least-squares fit with a pseudoinverse, and I guess there are then similar decompositions for that. I don&#8217;t know whether a Kalman filter should lead to insoluble equations. </p>
<p>When you say m &gt; n, I am taking it that means your observation y is an m-vector but your underlying process x is an n-vector. Correct?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raequin</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-120072</link>
		<dc:creator>raequin</dc:creator>
		<pubDate>Tue, 06 Dec 2011 18:59:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-120072</guid>
		<description>I still will need to know what to do about the inversion, but it occurs to me that the matrix

S = (HPH&#039; + W)

is not guaranteed to be invertible even if H, P, and W are.  I don&#039;t understand how this update equation can be used then (I&#039;m not saying it can&#039;t, I just don&#039;t see how one is to use an update with an inversion that may not be possible at every step).</description>
		<content:encoded><![CDATA[<p>I still will need to know what to do about the inversion, but it occurs to me that the matrix</p>
<p>S = (HPH&#8217; + W)</p>
<p>is not guaranteed to be invertible even if H, P, and W are.  I don&#8217;t understand how this update equation can be used then (I&#8217;m not saying it can&#8217;t, I just don&#8217;t see how one is to use an update with an inversion that may not be possible at every step).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raequin</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-120070</link>
		<dc:creator>raequin</dc:creator>
		<pubDate>Tue, 06 Dec 2011 18:49:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-120070</guid>
		<description>@Warwick  There is not expected to be an exact solution to the system.  We&#039;ve been using Gauss-Newton (ordinary least squares) to compute the state.  I am working on an alternative with Kalman filtering.  So, I guess I still have the question of invertibility, whether or not I end up doing that or some other method (such as LU)?</description>
		<content:encoded><![CDATA[<p>@Warwick  There is not expected to be an exact solution to the system.  We&#8217;ve been using Gauss-Newton (ordinary least squares) to compute the state.  I am working on an alternative with Kalman filtering.  So, I guess I still have the question of invertibility, whether or not I end up doing that or some other method (such as LU)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-120069</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Tue, 06 Dec 2011 18:47:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-120069</guid>
		<description>@raequin : Cholesky decompositions, like LL^T and LDL^T, are not the only choice. For instance, consider the catalogue of matrix decompositions here (note: only LLT and LDLT have (semi)definetness requirements):
http://eigen.tuxfamily.org/dox-devel/TopicLinearAlgebraDecompositions.html</description>
		<content:encoded><![CDATA[<p>@raequin : Cholesky decompositions, like LL^T and LDL^T, are not the only choice. For instance, consider the catalogue of matrix decompositions here (note: only LLT and LDLT have (semi)definetness requirements):<br />
<a href="http://eigen.tuxfamily.org/dox-devel/TopicLinearAlgebraDecompositions.html" rel="nofollow">http://eigen.tuxfamily.org/dox-devel/TopicLinearAlgebraDecompositions.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Warwick Dumas</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-120068</link>
		<dc:creator>Warwick Dumas</dc:creator>
		<pubDate>Tue, 06 Dec 2011 18:40:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-120068</guid>
		<description>If the matrix is noninvertible then there is not exactly one solution.
If it is invertible then you can use LU.
I expect others more learned will add their comments.</description>
		<content:encoded><![CDATA[<p>If the matrix is noninvertible then there is not exactly one solution.<br />
If it is invertible then you can use LU.<br />
I expect others more learned will add their comments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raequin</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-120054</link>
		<dc:creator>raequin</dc:creator>
		<pubDate>Tue, 06 Dec 2011 17:41:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-120054</guid>
		<description>I came across this article because my equations for Kalman filtering call for a matrix inversion, and I&#039;m not sure about the invertibility of the matrix sum in question.  The following matrix is part of the update step:

(HPH&#039; + W)^-1

where H is my output map, P is the estimate of the error covariance, and W is the covariance matrix for the measurement noise.  I gather that there&#039;s no way to be sure of the invertibility of this sum (besides, though I guess that P and W are invertible I know that H for my case does not have full row rank, as m &gt; n).  Here is the entire equation for the state update.

x_{k+1&#124;k+1} = x_{k&#124;k} + PH(HPH&#039; + W)^-1(y - Hx_{k+1&#124;k})

Anyway, that&#039;s the background for this comment; I thought my matrix was not guaranteed to be invertible.  I&#039;m now looking for tips on how to implement this equation.  Comment #28 states that &quot;implementations [of the Kalman filter] never use the inverse,&quot; but yet the first one I looked at does (http://code.google.com/p/efficient-java-matrix-library/wiki/KalmanFilterExamples).  Other comments above mention Cholesky decomposition for multiplication tasks, so I&#039;m guessing that might be the approach to take.  Though now, after reading a Wikipedia entry, I&#039;m guessing this can&#039;t be the right approach since I don&#039;t think the sum will necessarily be Hermitian, positive definite.  What do I use instead of the inverse here?</description>
		<content:encoded><![CDATA[<p>I came across this article because my equations for Kalman filtering call for a matrix inversion, and I&#8217;m not sure about the invertibility of the matrix sum in question.  The following matrix is part of the update step:</p>
<p>(HPH&#8217; + W)^-1</p>
<p>where H is my output map, P is the estimate of the error covariance, and W is the covariance matrix for the measurement noise.  I gather that there&#8217;s no way to be sure of the invertibility of this sum (besides, though I guess that P and W are invertible I know that H for my case does not have full row rank, as m &gt; n).  Here is the entire equation for the state update.</p>
<p>x_{k+1|k+1} = x_{k|k} + PH(HPH&#8217; + W)^-1(y &#8211; Hx_{k+1|k})</p>
<p>Anyway, that&#8217;s the background for this comment; I thought my matrix was not guaranteed to be invertible.  I&#8217;m now looking for tips on how to implement this equation.  Comment #28 states that &#8220;implementations [of the Kalman filter] never use the inverse,&#8221; but yet the first one I looked at does (<a href="http://code.google.com/p/efficient-java-matrix-library/wiki/KalmanFilterExamples)" rel="nofollow">http://code.google.com/p/efficient-java-matrix-library/wiki/KalmanFilterExamples)</a>.  Other comments above mention Cholesky decomposition for multiplication tasks, so I&#8217;m guessing that might be the approach to take.  Though now, after reading a Wikipedia entry, I&#8217;m guessing this can&#8217;t be the right approach since I don&#8217;t think the sum will necessarily be Hermitian, positive definite.  What do I use instead of the inverse here?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ax = B is not the same as x = A(inv) B &#124; The Python Path</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-110616</link>
		<dc:creator>Ax = B is not the same as x = A(inv) B &#124; The Python Path</dc:creator>
		<pubDate>Thu, 27 Oct 2011 08:13:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-110616</guid>
		<description>[...] against that because it is possibly a lot more computationally intensive than solving directly. John Cook&#8217;s blog explains more about [...]</description>
		<content:encoded><![CDATA[<p>[...] against that because it is possibly a lot more computationally intensive than solving directly. John Cook&#8217;s blog explains more about [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-106284</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Tue, 04 Oct 2011 04:14:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-106284</guid>
		<description>Thanks for the advice. I now see why my matlab scrip is more stable than my C equivalent. In matlab I use b/A, but in C I explicitly calculate the inverse.</description>
		<content:encoded><![CDATA[<p>Thanks for the advice. I now see why my matlab scrip is more stable than my C equivalent. In matlab I use b/A, but in C I explicitly calculate the inverse.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Edwards</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-104434</link>
		<dc:creator>Scott Edwards</dc:creator>
		<pubDate>Wed, 21 Sep 2011 15:16:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-104434</guid>
		<description>Thanks so much for your quick response, John - appreciate your willingness to help a newbie out!  I&#039;ve checked out Ward&#039;s books, and I guess the one titled &quot;linear algebra theory and applications&quot; would be a good place to start and I assume it would address the techniques you are describing. Looks like the 2nd edition just came out, so maybe I can pick the first one up at a discount, since I don&#039;t have $160 at hand right now. :-). Until then ill keep checking out your great blog, as I attempt to make the shift from someone with a pretty good traditional background in stat and research methods to someone like you guys that actually knows how this stuff functions at a deep level - to the point of knowing things like how best to calculate standard deviation (one of your blog entries) - something I always assumed was very cut and dry! Anyway, thanks!</description>
		<content:encoded><![CDATA[<p>Thanks so much for your quick response, John &#8211; appreciate your willingness to help a newbie out!  I&#8217;ve checked out Ward&#8217;s books, and I guess the one titled &#8220;linear algebra theory and applications&#8221; would be a good place to start and I assume it would address the techniques you are describing. Looks like the 2nd edition just came out, so maybe I can pick the first one up at a discount, since I don&#8217;t have $160 at hand right now. <img src='http://www.johndcook.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Until then ill keep checking out your great blog, as I attempt to make the shift from someone with a pretty good traditional background in stat and research methods to someone like you guys that actually knows how this stuff functions at a deep level &#8211; to the point of knowing things like how best to calculate standard deviation (one of your blog entries) &#8211; something I always assumed was very cut and dry! Anyway, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-2/#comment-104314</link>
		<dc:creator>John</dc:creator>
		<pubDate>Tue, 20 Sep 2011 13:07:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-104314</guid>
		<description>The &quot;L&quot; and &quot;U&quot; in LU stand for lower-triangular and upper-triangular. It&#039;s a way of factoring a matrix A into the product of two special matrices L and U.

As for resources, I&#039;d recommend any of the linear algebra books Ward Cheney has written. His latest book is very expensive, but you could look for a used copy or an earlier edition.</description>
		<content:encoded><![CDATA[<p>The &#8220;L&#8221; and &#8220;U&#8221; in LU stand for lower-triangular and upper-triangular. It&#8217;s a way of factoring a matrix A into the product of two special matrices L and U.</p>
<p>As for resources, I&#8217;d recommend any of the linear algebra books Ward Cheney has written. His latest book is very expensive, but you could look for a used copy or an earlier edition.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Edwards</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-1/#comment-104267</link>
		<dc:creator>Scott Edwards</dc:creator>
		<pubDate>Tue, 20 Sep 2011 05:13:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-104267</guid>
		<description>Its clear from the comments above that solving a system of linear equations is NOT best done by finding the inverse of A. So, then what IS the best way to solve them?  I assume some of the acronymns above (eg LU) hold the answer. Sorry, I know you guys are obviously light years ahead of me, but in linear algebra I only learned the &quot;invert the matrix&quot; method. Could you point me to some intro sources?
Thanks!
Scott</description>
		<content:encoded><![CDATA[<p>Its clear from the comments above that solving a system of linear equations is NOT best done by finding the inverse of A. So, then what IS the best way to solve them?  I assume some of the acronymns above (eg LU) hold the answer. Sorry, I know you guys are obviously light years ahead of me, but in linear algebra I only learned the &#8220;invert the matrix&#8221; method. Could you point me to some intro sources?<br />
Thanks!<br />
Scott</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Moeller</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-1/#comment-103310</link>
		<dc:creator>John Moeller</dc:creator>
		<pubDate>Wed, 14 Sep 2011 02:46:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-103310</guid>
		<description>@Dave: Yes, you can do that by taking the inverse of the Cholesky decomposition. I.e., decompose as $latex L^TL=\Sigma$, solve $latex Ly=x$ for $latex y$ (which is fast because $latex L$ is triangular), and then compute $latex y^Ty$. Or you could invert $latex L$ (which is easy because it&#039;s triangular). This is mentioned in comment 11.</description>
		<content:encoded><![CDATA[<p>@Dave: Yes, you can do that by taking the inverse of the Cholesky decomposition. I.e., decompose as $latex L^TL=\Sigma$, solve $latex Ly=x$ for $latex y$ (which is fast because $latex L$ is triangular), and then compute $latex y^Ty$. Or you could invert $latex L$ (which is easy because it&#8217;s triangular). This is mentioned in comment 11.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Webb</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-1/#comment-103286</link>
		<dc:creator>Dave Webb</dc:creator>
		<pubDate>Wed, 14 Sep 2011 00:10:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-103286</guid>
		<description>Question: What if I need to multiply something by the inverse, instead of just solving linear equations?  For example, say I have a positive definite symmetric matrix \Sigma.  If I need to calculate a multivariate normal density with this matrix as the covariance, I need to do something like (X^T * inverse(\Sigma) * X), where X is a column vector.  Can I do this w/o explicitly taking the inverse?</description>
		<content:encoded><![CDATA[<p>Question: What if I need to multiply something by the inverse, instead of just solving linear equations?  For example, say I have a positive definite symmetric matrix \Sigma.  If I need to calculate a multivariate normal density with this matrix as the covariance, I need to do something like (X^T * inverse(\Sigma) * X), where X is a column vector.  Can I do this w/o explicitly taking the inverse?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Samuel</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-1/#comment-103247</link>
		<dc:creator>Samuel</dc:creator>
		<pubDate>Tue, 13 Sep 2011 19:03:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-103247</guid>
		<description>I havent read every comment, but I have a simple question: inverting A is not equivalent to solving A x_1=b_1,...,A x_n = b_n for b_1 = (1,0,...,0) , b_2= (0,1, ,0 ,...,0), etc.  ??</description>
		<content:encoded><![CDATA[<p>I havent read every comment, but I have a simple question: inverting A is not equivalent to solving A x_1=b_1,&#8230;,A x_n = b_n for b_1 = (1,0,&#8230;,0) , b_2= (0,1, ,0 ,&#8230;,0), etc.  ??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Warwick Dumas</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-1/#comment-75038</link>
		<dc:creator>Warwick Dumas</dc:creator>
		<pubDate>Fri, 08 Apr 2011 22:28:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-75038</guid>
		<description>John :

Thanks. I missed your comment (!) but in the end I ended up doing exactly this, using the band-diagonal LU algorithm in Press et al (not sure to whom they credited it). This for a genuine quintic spline curve not a weighted average. This then worked in practice about 10x slower than just taking derivatives using local quadratic approx, but the improvement was worthwhile in certain respects.
Cheers,

Warwick</description>
		<content:encoded><![CDATA[<p>John :</p>
<p>Thanks. I missed your comment (!) but in the end I ended up doing exactly this, using the band-diagonal LU algorithm in Press et al (not sure to whom they credited it). This for a genuine quintic spline curve not a weighted average. This then worked in practice about 10x slower than just taking derivatives using local quadratic approx, but the improvement was worthwhile in certain respects.<br />
Cheers,</p>
<p>Warwick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Moeller</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-1/#comment-75035</link>
		<dc:creator>John Moeller</dc:creator>
		<pubDate>Fri, 08 Apr 2011 22:15:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-75035</guid>
		<description>@zortharg : They went over this in comment 11. You invert a matrix and keep it, but it&#039;s the matrix from the Cholesky decomposition, not the original covariance matrix. You should read all the comments before posting your own.</description>
		<content:encoded><![CDATA[<p>@zortharg : They went over this in comment 11. You invert a matrix and keep it, but it&#8217;s the matrix from the Cholesky decomposition, not the original covariance matrix. You should read all the comments before posting your own.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zortharg</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-1/#comment-75027</link>
		<dc:creator>zortharg</dc:creator>
		<pubDate>Fri, 08 Apr 2011 20:39:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-75027</guid>
		<description>You have assumed a priori that solving Ax=b is THE reason anyone might want to invert a matrix. What if, for example, you want to find the probability density function of a large set of correlated gaussian random variables, and you have a very large covariance matrix. You need to take the covariance matrix and do what with it? Guess! That&#039;s right! You need to invert it! Look up multivariate gaussian on wikipedia if you don&#039;t believe me.</description>
		<content:encoded><![CDATA[<p>You have assumed a priori that solving Ax=b is THE reason anyone might want to invert a matrix. What if, for example, you want to find the probability density function of a large set of correlated gaussian random variables, and you have a very large covariance matrix. You need to take the covariance matrix and do what with it? Guess! That&#8217;s right! You need to invert it! Look up multivariate gaussian on wikipedia if you don&#8217;t believe me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-1/#comment-69500</link>
		<dc:creator>John</dc:creator>
		<pubDate>Mon, 07 Mar 2011 00:22:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-69500</guid>
		<description>Fitting splines leads to banded linear systems. These can be solved very quickly with special algorithms. Solving a banded system takes O(N) operations whereas Gaussian elimination on a dense matrix requires O(N^3) operations.</description>
		<content:encoded><![CDATA[<p>Fitting splines leads to banded linear systems. These can be solved very quickly with special algorithms. Solving a banded system takes O(N) operations whereas Gaussian elimination on a dense matrix requires O(N^3) operations.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Warwick Dumas</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-1/#comment-69498</link>
		<dc:creator>Warwick Dumas</dc:creator>
		<pubDate>Mon, 07 Mar 2011 00:15:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-69498</guid>
		<description>The linear algebra I am doing is very simple: basically I want to create a spline fit to a large set of points, and I decided to try using some averaging between quintic polynomial fits to subsets of 6 points each. The fitting procedure will be repeated say 10^9 times during a program run. Reading this article motivated me not to just invert the relevant matrix. I wouldn&#039;t want to just apply an  inversion routine - performance is crucial - but I did consider inverting it by hand and applying that. 

Instead I am writing LU by hand, and trying my best to exploit the special property involved. Viz, the polynomial takes the form a0 + a1(x-xmid)+a2(x-xmid)^2+..+a5(x-xmid)^5 where if the points are x0,...,x5 then xmid is the average of x2 and x3. Therefore where d corresponds to distance from xmid, one row is 1,d2,d2*d2,d2^3,d2^4,d2^5, and one row is 1,-d2,d2*d2,-d2^3,d2^4,-d2^5. And the first column is all 1&#039;s. Other than that I&#039;m not sure there is much to exploit. 
I wouldn&#039;t prefer to write an LU routine (a la Press et al) because of the pivoting business - trying to keep this really straightforward as well as fast.

I just wondered, since this specific problem is obviously a very common one, does anyone have a standard, numerically stable algorithm for doing it. (This reinventing the wheel is time-consuming, and unfortunately I have to go to work so can only work on this voluntary project at the weekend.)</description>
		<content:encoded><![CDATA[<p>The linear algebra I am doing is very simple: basically I want to create a spline fit to a large set of points, and I decided to try using some averaging between quintic polynomial fits to subsets of 6 points each. The fitting procedure will be repeated say 10^9 times during a program run. Reading this article motivated me not to just invert the relevant matrix. I wouldn&#8217;t want to just apply an  inversion routine &#8211; performance is crucial &#8211; but I did consider inverting it by hand and applying that. </p>
<p>Instead I am writing LU by hand, and trying my best to exploit the special property involved. Viz, the polynomial takes the form a0 + a1(x-xmid)+a2(x-xmid)^2+..+a5(x-xmid)^5 where if the points are x0,&#8230;,x5 then xmid is the average of x2 and x3. Therefore where d corresponds to distance from xmid, one row is 1,d2,d2*d2,d2^3,d2^4,d2^5, and one row is 1,-d2,d2*d2,-d2^3,d2^4,-d2^5. And the first column is all 1&#8217;s. Other than that I&#8217;m not sure there is much to exploit.<br />
I wouldn&#8217;t prefer to write an LU routine (a la Press et al) because of the pivoting business &#8211; trying to keep this really straightforward as well as fast.</p>
<p>I just wondered, since this specific problem is obviously a very common one, does anyone have a standard, numerically stable algorithm for doing it. (This reinventing the wheel is time-consuming, and unfortunately I have to go to work so can only work on this voluntary project at the weekend.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-1/#comment-62481</link>
		<dc:creator>John</dc:creator>
		<pubDate>Wed, 26 Jan 2011 12:51:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-62481</guid>
		<description>I did have large matrices in mind when I wrote this. However, the same considerations apply to small matrices, though to a lesser extent.

To learn about matrix factorizations, &lt;a href=&quot;http://www.amazon.com/gp/product/0801854148?ie=UTF8&amp;tag=theende-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0801854148&quot; rel=&quot;nofollow&quot;&gt;Matrix Computations&lt;/a&gt; by Golub and Van Loan is a classic.</description>
		<content:encoded><![CDATA[<p>I did have large matrices in mind when I wrote this. However, the same considerations apply to small matrices, though to a lesser extent.</p>
<p>To learn about matrix factorizations, <a href="http://www.amazon.com/gp/product/0801854148?ie=UTF8&amp;tag=theende-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0801854148" rel="nofollow">Matrix Computations</a> by Golub and Van Loan is a classic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dirk   Kok</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-1/#comment-62463</link>
		<dc:creator>Dirk   Kok</dc:creator>
		<pubDate>Wed, 26 Jan 2011 10:02:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-62463</guid>
		<description>Hi,

I take it the discussion here is about very large matrices? Or does it apply to small 4x4  matrices as well? For example, I have an iduction motor simulation in matab which is a 4  by 4 matrix and I was wondering if thie factorisation could speed up the simulation? And if so, where can I learn about factorisation of matrices?

Cheers,</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I take it the discussion here is about very large matrices? Or does it apply to small 4&#215;4  matrices as well? For example, I have an iduction motor simulation in matab which is a 4  by 4 matrix and I was wondering if thie factorisation could speed up the simulation? And if so, where can I learn about factorisation of matrices?</p>
<p>Cheers,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens-Peter M. Zemke</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-1/#comment-62376</link>
		<dc:creator>Jens-Peter M. Zemke</dc:creator>
		<pubDate>Tue, 25 Jan 2011 20:38:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-62376</guid>
		<description>In &lt;a href=&quot;http://en.wikipedia.org/wiki/Interval_arithmetic&quot; rel=&quot;nofollow&quot;&gt;Interval Arithmetic&lt;/a&gt; it makes perfect sense to compute (floating point approximations) to the inverse. Needless to say that these approximations are computed using the LU decomposition or such. The best known scheme to compute an enclosure to the solution of some (nonlinear) system of (possibly degenerate) interval equations is based on the  so-called Krawczyk Operator and relies on the explicit computation of an (approximation to an) inverse matrix.</description>
		<content:encoded><![CDATA[<p>In <a href="http://en.wikipedia.org/wiki/Interval_arithmetic" rel="nofollow">Interval Arithmetic</a> it makes perfect sense to compute (floating point approximations) to the inverse. Needless to say that these approximations are computed using the LU decomposition or such. The best known scheme to compute an enclosure to the solution of some (nonlinear) system of (possibly degenerate) interval equations is based on the  so-called Krawczyk Operator and relies on the explicit computation of an (approximation to an) inverse matrix.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/comment-page-1/#comment-56856</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Fri, 24 Dec 2010 18:41:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=4266#comment-56856</guid>
		<description>A number of folks have asked for the diagonal of inv(A&#039;A).

Using the singular value decomposition, A = U S V&#039;, with U&#039;U = V&#039;V = I, S diagonal,

&lt;code&gt;
  A&#039;A = (USV&#039;)&#039;USV&#039; = VSU&#039;USV&#039; = VSSV&#039;
  inv(A&#039;A) = inv(VSSV&#039;) = inv(V&#039;) inv(SS) inv(V) = V inv(SS)&#039; V&#039;
&lt;/code&gt;

Since S is diagonal,
&lt;code&gt;
  inv(A&#039;A) = V inv(S) inv(S)&#039; V&#039; = (V inv(S))  (V inv(S))&#039;
&lt;/code&gt;
For any matrix X, diag(XX&#039;) is the sum of the square of the rows of X or the columns of X&#039;.  With S diagonal, the inverse is just element-wise 1/S, and you can compute the diagonal entries of inv(A&#039;A) by summing the squares of the columns of V&#039; and dividing the result by the corresponding diagonal entry in S.

Paul</description>
		<content:encoded><![CDATA[<p>A number of folks have asked for the diagonal of inv(A&#8217;A).</p>
<p>Using the singular value decomposition, A = U S V&#8217;, with U&#8217;U = V&#8217;V = I, S diagonal,</p>
<p><code><br />
  A'A = (USV')'USV' = VSU'USV' = VSSV'<br />
  inv(A'A) = inv(VSSV') = inv(V') inv(SS) inv(V) = V inv(SS)' V'<br />
</code></p>
<p>Since S is diagonal,<br />
<code><br />
  inv(A'A) = V inv(S) inv(S)' V' = (V inv(S))  (V inv(S))'<br />
</code><br />
For any matrix X, diag(XX&#8217;) is the sum of the square of the rows of X or the columns of X&#8217;.  With S diagonal, the inverse is just element-wise 1/S, and you can compute the diagonal entries of inv(A&#8217;A) by summing the squares of the columns of V&#8217; and dividing the result by the corresponding diagonal entry in S.</p>
<p>Paul</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.533 seconds -->

