<?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: Purpose of inv</title>
	<atom:link href="http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/</link>
	<description>Loren Shure works on design of the MATLAB language at MathWorks. She writes here about once a week on MATLAB programming and related topics.</description>
	<lastBuildDate>Thu, 09 Feb 2012 04:19:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-32305</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Mon, 06 Jun 2011 10:47:30 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-32305</guid>
		<description>Md. Ariful islam-

Best off using the operator \.  It will yieldthe numerically best solution.  inv is likely to NEVER be the best way, or the fastest.

--Loren</description>
		<content:encoded><![CDATA[<p>Md. Ariful islam-</p>
<p>Best off using the operator \.  It will yieldthe numerically best solution.  inv is likely to NEVER be the best way, or the fastest.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Md. Ariful islam</title>
		<link>http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-32303</link>
		<dc:creator>Md. Ariful islam</dc:creator>
		<pubDate>Fri, 03 Jun 2011 20:24:51 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-32303</guid>
		<description>which on is faster to solve Ax=b. Inverse or Lu decompose</description>
		<content:encoded><![CDATA[<p>which on is faster to solve Ax=b. Inverse or Lu decompose</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Davis</title>
		<link>http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-30814</link>
		<dc:creator>Tim Davis</dc:creator>
		<pubDate>Wed, 18 Nov 2009 17:18:23 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-30814</guid>
		<description>If you want to use something that acts like the inverse, but isn&#039;t the inverse, see the FACTORIZE, an object-oriented method:

http://blogs.mathworks.com/pick/2009/06/26/dont-let-that-inv-go-past-your-eyes-to-solve-that-system-factorize/

It lets you write:

&lt;pre&gt;
S = inverse(A)
x = S*b
&lt;/pre&gt;

but it does not actually compute the inverse.  It does the right thing instead, by factorizing A and then using forward/backsolves to compute x=S*b.

So to solve (A+B*inv(C)*D)x=b do this:

S = inverse (A+B*inverse(C)*D) ;
x = S\b ;

and rest assured that you are not actually multiplying by the inverse.</description>
		<content:encoded><![CDATA[<p>If you want to use something that acts like the inverse, but isn&#8217;t the inverse, see the FACTORIZE, an object-oriented method:</p>
<p><a href="http://blogs.mathworks.com/pick/2009/06/26/dont-let-that-inv-go-past-your-eyes-to-solve-that-system-factorize/" rel="nofollow">http://blogs.mathworks.com/pick/2009/06/26/dont-let-that-inv-go-past-your-eyes-to-solve-that-system-factorize/</a></p>
<p>It lets you write:</p>
<pre>
S = inverse(A)
x = S*b
</pre>
<p>but it does not actually compute the inverse.  It does the right thing instead, by factorizing A and then using forward/backsolves to compute x=S*b.</p>
<p>So to solve (A+B*inv(C)*D)x=b do this:</p>
<p>S = inverse (A+B*inverse(C)*D) ;<br />
x = S\b ;</p>
<p>and rest assured that you are not actually multiplying by the inverse.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Huapeng</title>
		<link>http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-30217</link>
		<dc:creator>Huapeng</dc:creator>
		<pubDate>Tue, 21 Apr 2009 06:11:31 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-30217</guid>
		<description>I think it is necessary to keep this function. There are cases where we want to solve Ax=b with vector b variing. If the matrix A is of small dimension, it may be advantageous to calculate and store the inversion of the matrix A. In this way, there is no need to sovle the linear equation again when b varies. I usually write my program in this way. If it is silly, welcome your comments. Thanks!</description>
		<content:encoded><![CDATA[<p>I think it is necessary to keep this function. There are cases where we want to solve Ax=b with vector b variing. If the matrix A is of small dimension, it may be advantageous to calculate and store the inversion of the matrix A. In this way, there is no need to sovle the linear equation again when b varies. I usually write my program in this way. If it is silly, welcome your comments. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William Roberts</title>
		<link>http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-20527</link>
		<dc:creator>William Roberts</dc:creator>
		<pubDate>Tue, 06 Nov 2007 15:07:21 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-20527</guid>
		<description>I can&#039;t see how to calculate the likelihood of a Gaussian vector with arbitrary covariance with out using inv.   Unless, of course, you have the eigen-decomposition of the covariance.</description>
		<content:encoded><![CDATA[<p>I can&#8217;t see how to calculate the likelihood of a Gaussian vector with arbitrary covariance with out using inv.   Unless, of course, you have the eigen-decomposition of the covariance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hamid Dehghani</title>
		<link>http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-16376</link>
		<dc:creator>Hamid Dehghani</dc:creator>
		<pubDate>Wed, 15 Aug 2007 09:24:00 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-16376</guid>
		<description>I have been reading these with interest and am wondering if anyone can help with my problem.
I have a system of equations:
(A+B*inv(C)*D)x=b
where A, B, C and D are large (50,000 x 50,000) sparse (all banded or all dense depending on &#039;optimization&#039;) matricec and I have multiple right hand sides (i.e. b is a size of 20x1).
So, I should never ever calculate inv(C). so what can I do that is computationally fast and efficient?</description>
		<content:encoded><![CDATA[<p>I have been reading these with interest and am wondering if anyone can help with my problem.<br />
I have a system of equations:<br />
(A+B*inv(C)*D)x=b<br />
where A, B, C and D are large (50,000 x 50,000) sparse (all banded or all dense depending on &#8216;optimization&#8217;) matricec and I have multiple right hand sides (i.e. b is a size of 20&#215;1).<br />
So, I should never ever calculate inv(C). so what can I do that is computationally fast and efficient?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Davis</title>
		<link>http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-16261</link>
		<dc:creator>Tim Davis</dc:creator>
		<pubDate>Mon, 04 Jun 2007 17:25:05 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-16261</guid>
		<description>Regarding the use of inv(D) when D is sparse and diagonal - a colleague reminded me of another option.  The following three operations compute the same thing (x1, x2, x3):

n = 1000000 ;
b = rand(n,1);
d = rand(n,1);
D = spdiags (d, 0, n,n) ;
S = inv (D) ;
tic ; x1 = D\b ; toc
tic ; x2 = d .\ b ; toc
tic ; x3 = S*b ; toc

norm (x1-x2)
norm (x1-x3)

The latter two options (d.\b and S*b) are equally fast on my Intel Core Duo (MATLAB 7.4), whereas D\b takes about 50% more time.  In fact, d.\b is a teeny bit faster than S*b.  Using S*b is numerically dubious, of course.  So even for diagonal matrices, there&#039;s no need to use inv(D)*b.  To scale the columns of b, use b./d instead of b/D or b*inv(D).

Richard&#039;s example:

x = b&#039; * (inv(D)).^2 * b

can be written cleanly as

x = b&#039; * (diag(D)).^2 .\ b ;

the latter is faster.  Even faster is
d = full(diag(D)) ;
x = b&#039; * (d.^2 .\b) ;</description>
		<content:encoded><![CDATA[<p>Regarding the use of inv(D) when D is sparse and diagonal &#8211; a colleague reminded me of another option.  The following three operations compute the same thing (x1, x2, x3):</p>
<p>n = 1000000 ;<br />
b = rand(n,1);<br />
d = rand(n,1);<br />
D = spdiags (d, 0, n,n) ;<br />
S = inv (D) ;<br />
tic ; x1 = D\b ; toc<br />
tic ; x2 = d .\ b ; toc<br />
tic ; x3 = S*b ; toc</p>
<p>norm (x1-x2)<br />
norm (x1-x3)</p>
<p>The latter two options (d.\b and S*b) are equally fast on my Intel Core Duo (MATLAB 7.4), whereas D\b takes about 50% more time.  In fact, d.\b is a teeny bit faster than S*b.  Using S*b is numerically dubious, of course.  So even for diagonal matrices, there&#8217;s no need to use inv(D)*b.  To scale the columns of b, use b./d instead of b/D or b*inv(D).</p>
<p>Richard&#8217;s example:</p>
<p>x = b&#8217; * (inv(D)).^2 * b</p>
<p>can be written cleanly as</p>
<p>x = b&#8217; * (diag(D)).^2 .\ b ;</p>
<p>the latter is faster.  Even faster is<br />
d = full(diag(D)) ;<br />
x = b&#8217; * (d.^2 .\b) ;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roger Jeurissen</title>
		<link>http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-16257</link>
		<dc:creator>Roger Jeurissen</dc:creator>
		<pubDate>Wed, 30 May 2007 11:46:07 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-16257</guid>
		<description>There is another use of inv that has not been mentioned: inverting a symbolic matrix. In my case, this was required for computing finite difference expressions from the Taylor series expansion around collocation points. That was the only time I have ever used inv, but it was useful. Greetings,
Roger.</description>
		<content:encoded><![CDATA[<p>There is another use of inv that has not been mentioned: inverting a symbolic matrix. In my case, this was required for computing finite difference expressions from the Taylor series expansion around collocation points. That was the only time I have ever used inv, but it was useful. Greetings,<br />
Roger.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andriy</title>
		<link>http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-16255</link>
		<dc:creator>Andriy</dc:creator>
		<pubDate>Wed, 30 May 2007 01:32:25 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-16255</guid>
		<description>It is really a bit off topic. Tim, thank you anyway.</description>
		<content:encoded><![CDATA[<p>It is really a bit off topic. Tim, thank you anyway.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Davis</title>
		<link>http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-16254</link>
		<dc:creator>Tim Davis</dc:creator>
		<pubDate>Wed, 30 May 2007 01:18:49 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/#comment-16254</guid>
		<description>Oh, the &quot;you may use this code only if you promise not to use inv(A) to solve Ax=b&quot; license was tongue-in-cheek, of course.

Briefly (&quot;Briefly?!&quot; as anyone who knows me will gasp), if all entries in d(t) change at each time step, then it&#039;s a rank-n update and there&#039;s nothing you can do that I know of but to completely refactorize the matrix.  You can reuse the symbolic analysis if the pattern doesn&#039;t change, but MATLAB doesn&#039;t support that except to reuse the fill-reducing ordering (which CHOL computes efficiently anyway...).  So there&#039;s little to gain ... but we&#039;re getting off topic and I&#039;ve already spammed Loren&#039;s blog a little too much ... so drop me an email if you have questions.</description>
		<content:encoded><![CDATA[<p>Oh, the &#8220;you may use this code only if you promise not to use inv(A) to solve Ax=b&#8221; license was tongue-in-cheek, of course.</p>
<p>Briefly (&#8220;Briefly?!&#8221; as anyone who knows me will gasp), if all entries in d(t) change at each time step, then it&#8217;s a rank-n update and there&#8217;s nothing you can do that I know of but to completely refactorize the matrix.  You can reuse the symbolic analysis if the pattern doesn&#8217;t change, but MATLAB doesn&#8217;t support that except to reuse the fill-reducing ordering (which CHOL computes efficiently anyway&#8230;).  So there&#8217;s little to gain &#8230; but we&#8217;re getting off topic and I&#8217;ve already spammed Loren&#8217;s blog a little too much &#8230; so drop me an email if you have questions.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

