<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MathPACK Solver &#187; admin</title>
	<atom:link href="http://kritsana.uttamang.com/mathpacksolver/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://kritsana.uttamang.com/mathpacksolver</link>
	<description>The Most Powerful Math Engine on the iOS</description>
	<lastBuildDate>Fri, 24 Mar 2017 04:00:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.38</generator>
	<item>
		<title>Solving Overdetermined System Using Pseudoinverse</title>
		<link>http://kritsana.uttamang.com/mathpacksolver/tutorial/solving-overdetermined-system-using-pseudoinverse/</link>
		<comments>http://kritsana.uttamang.com/mathpacksolver/tutorial/solving-overdetermined-system-using-pseudoinverse/#comments</comments>
		<pubDate>Sat, 30 Nov 2013 04:40:13 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.mathpacksolver.com/main/?p=217</guid>
		<description><![CDATA[The system of linear equations becomes overdetermined system if there are more equations than unknowns. It usually does not have solutions. From the Solving System of Linear Equations, the system of linear equations can be written in the matrix form as: AX = B Where: A is m x n matrix of coefficients. X is [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>The system of linear equations becomes overdetermined system if there are more equations than unknowns. It usually does not have solutions.</p>
<p>From the <a href="http://kritsana.uttamang.com/mathpacksolver/tutorial/solving-system-of-linear-equations/">Solving System of Linear Equations</a>, the system of linear equations can be written in the matrix form as:</p>
<dl>
<dt></dt>
<dd><strong>AX</strong> = <strong>B</strong></dd>
<dt>Where:</dt>
<dd><strong>A</strong> is <em>m</em> x <em>n</em> matrix of coefficients.</dd>
<dd><strong>X</strong> is <em>n</em> x 1 matrix of unknowns.</dd>
<dd><strong>B</strong> is <em>m</em> x 1 matrix of constant terms.</dd>
</dl>
<p>So, the system becomes overdetermined when <em>m</em> &gt; <em>n</em>.<br />
To solve this kind of system, we need to find <strong>X</strong> such that the residual vector</p>
<dl>
<dt></dt>
<dd><strong>R</strong> = <strong>B &#8211; AX</strong></dd>
</dl>
<p>is as small as possible.</p>
<p>The solution <strong>X</strong> given be the least squares method minimizes ||<strong>R</strong>||<sup>2</sup> = ||<strong>B</strong> &#8211; <strong>AX</strong>||<sup>2</sup>. This solution is Least-Squares Solution.</p>
<h2>Least-Squares Solution with Pseudoinverse</h2>
<dl>
<dt>From:</dt>
<dd><strong>AX</strong> = <strong>B</strong></dd>
<dt></dt>
<dt>When <em>m</em> &gt; <em>n</em>, so:</dt>
<dd><strong>A</strong><sup>T</sup><strong>AX</strong> = <strong>A</strong><sup>T</sup><strong>B</strong></dd>
<dt></dt>
<dt>Then</dt>
<dd><strong>X</strong> = (<strong>A</strong><sup>T</sup><strong>A</strong>)<sup>-1</sup><strong>A</strong><sup>T</sup><strong>B</strong></dd>
<dt></dt>
<dt>(<strong>A</strong><sup>T</sup><strong>A</strong>)<sup>-1</sup><strong>A</strong><sup>T</sup> is called <strong>pseudo inverse</strong> of <strong>A</strong></dt>
</dl>
<p>&nbsp;</p>
<h2>Solving with MathPACK Solver</h2>
<p>MathPACK Solver provides <b>inv</b> or <b>pinv</b> function finding invert matrix. If the input matrix to the function, is not squared matrix, the pseudo invert will be returned from the function.</p>
<h3>Function Signature</h3>
<dl>
<dt></dt>
<dd>U = inv(A);</dd>
<dd>U = pinv(A);</dd>
</dl>
<h3>Example</h3>
<dl>
<dt>Find the least-squares solution of the following system of equations:</dt>
<dd>x<sub>1</sub> &#8211; x<sub>2</sub> = 2</dd>
<dd>x<sub>1</sub> + x<sub>2</sub> = 4</dd>
<dd>2x<sub>1</sub> + x<sub>2</sub> = 8</dd>
</dl>
<p><code><br />
<span>    </span>»A = [1,-1; 1, 1; 2, 1]; </code></p>
<div><code><span>    </span>»B = [2; 4; 8]; </code></div>
<div><code><span>    </span>»X = pinv(A)*B </code></div>
<div><code><span>    </span>X = </code></div>
<div><code><span>    <span>    3.2857</span></span> </code></div>
<div><code><span>    <span>    1.1429</span></span> </code></div>
<div>
<dl>
<dt>So, the values of unknown x<sub>1</sub> and x<sub>2</sub> are:</dt>
<dt></dt>
<dd></dd>
<dd>x<sub>1</sub> = 3.2857</dd>
<dd>x<sub>2</sub> = 1.1429</dd>
</dl>
</div>
]]></content:encoded>
			<wfw:commentRss>http://kritsana.uttamang.com/mathpacksolver/tutorial/solving-overdetermined-system-using-pseudoinverse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solving Homogeneous System</title>
		<link>http://kritsana.uttamang.com/mathpacksolver/tutorial/solving-homogeneous-system/</link>
		<comments>http://kritsana.uttamang.com/mathpacksolver/tutorial/solving-homogeneous-system/#comments</comments>
		<pubDate>Sat, 30 Nov 2013 04:08:49 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.mathpacksolver.com/main/?p=207</guid>
		<description><![CDATA[A system of linear equations is homogeneous if all of the constant terms are zero. From Solving System of Linear Equations, the general form of homogeneous system of linear equations can be written as: a11x1 + a12x2 + a13x3 + &#8230; + a1nxn = 0 a21x1 + a22x2 + a23x3 + &#8230; + a2nxn = [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>A system of linear equations is homogeneous if all of the constant terms are zero. From <a href="http://kritsana.uttamang.com/mathpacksolver/tutorial/solving-system-of-linear-equations/">Solving System of Linear Equations</a>, the general form of homogeneous system of linear equations can be written as:</p>
<dl>
<dt></dt>
<dd>a<sub>11</sub>x<sub>1</sub> + a<sub>12</sub>x<sub>2</sub> + a<sub>13</sub>x<sub>3</sub> + &#8230; + a<sub>1n</sub>x<sub>n</sub> = 0</dd>
<dd>a<sub>21</sub>x<sub>1</sub> + a<sub>22</sub>x<sub>2</sub> + a<sub>23</sub>x<sub>3</sub> + &#8230; + a<sub>2n</sub>x<sub>n</sub> = 0</dd>
<dd>&#8230; &#8230; &#8230; &#8230;</dd>
<dd>a<sub>m1</sub>x<sub>1</sub> + a<sub>m2</sub>x<sub>2</sub> + a<sub>m3</sub>x<sub>3</sub> + &#8230; + a<sub>mn</sub>x<sub>n</sub> = 0</dd>
</dl>
<p>which can be written in matrix form</p>
<dl>
<dt></dt>
<dd><strong>AX</strong> = <strong>0</strong></dd>
</dl>
<p>Every homogeneous system of linear equations has at least one solution, which is <strong>X</strong> = <strong>0</strong>. It is called <em>zero solution</em> or <em>trivial solution</em>.</p>
<ul>
<li>If det(A) is non-zero, then it is the unique solution.</li>
<li>if det(A) is zero, then there is an infinite number of solutions.</li>
</ul>
<p>An important technique for solving a homogeneous system of linear equations <strong>AX</strong> = <strong>0</strong> is to form the augmented matrix <strong>M</strong> = [ <strong>A</strong> | <strong>0</strong> ] and reduce <strong>M</strong> to reduced row echelon form.</p>
<h2>Solving with MathPACK Solver</h2>
<p>To reduce the augmented matrix <strong>M</strong> to reduced row echelon form, you can use the function rref() in MathPACK Solver.</p>
<h3>Function Signature</h3>
<dl>
<dt></dt>
<dd>U = rref(A)</dd>
</dl>
<p>&nbsp;</p>
<h3>Example</h3>
<dl>
<dt>Solve the homogeneous linear system of equations.</dt>
<dd>x<sub>1</sub> + x<sub>2</sub> &#8211; 2x<sub>3</sub> = 0</dd>
<dd>3x<sub>1</sub> + 2x<sub>2</sub> + 4x<sub>3</sub> = 0</dd>
<dd>4x<sub>1</sub> + 3x<sub>2</sub> + 2x<sub>3</sub> = 0</dd>
</dl>
<dl>
<dt>From the given system of linear equations, we can write it in the matrix form</dt>
<dd><strong>AX</strong> = <strong>0</strong></dd>
<dt></dt>
<dt>Where:</dt>
<dd>A = [1, 1, -2; 3, 2, 4; 4, 3, 2];</dd>
<dd>X = [x<sub>1</sub>;x<sub>2</sub>;x<sub>3</sub>];</dd>
<dt></dt>
<dt>So, we can create matrix <strong>A</strong> and construct augmented matrix <strong>M</strong> by:</dt>
<dt></dt>
<dd><code><br />
»A = [1, 1, -2; 3, 2, 4; 4, 3, 2]; </code></dd>
<dd><code>»M = zeros(3, 4); </code></dd>
<dd><code>»M(1:3,1:3) = A;<br />
</code></dd>
<dt></dt>
<dt></dt>
<dt></dt>
<dt>Reduce <strong>M</strong> to reduced row echelon form using <strong>rref</strong> bundled function</dt>
<dt></dt>
<dd><code><br />
»rref(M) </code></dd>
<dd><code>ans = </code></dd>
<dd><code><span>    1 0 8 0</span> </code><code> </code></dd>
<dd><code><span>    0 1 -10 0</span> </code></dd>
<dd><code><span>    0 0 0 0</span> </code></dd>
<dd></dd>
<dt></dt>
<dt></dt>
<dt>Rewrite system in the equations form.</dt>
<dt></dt>
<dd>x<sub>1</sub> + 0 + 8x<sub>3</sub> = 0</dd>
<dd>0 + x<sub>2</sub> &#8211; 10x<sub>3</sub> = 0</dd>
<dt></dt>
<dt></dt>
<dt>Thus:</dt>
<dd>x<sub>1</sub> = &#8211; 8x<sub>3</sub></dd>
<dd>x<sub>2</sub> = 10x<sub>3</sub></dd>
<dd></dd>
<dt></dt>
<dt>Let s=x<sub>3</sub>, then</dt>
<dd>x<sub>1</sub> = &#8211; 8s</dd>
<dd>x<sub>2</sub> = 10s</dd>
<dd>x<sub>3</sub> = s</dd>
<dt></dt>
<dt></dt>
<dt></dt>
<dt>The solution vector <strong>X</strong> will be:</dt>
<dd><strong>X</strong> = [-8; 10; 1]s</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://kritsana.uttamang.com/mathpacksolver/tutorial/solving-homogeneous-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solving System of Linear Equations</title>
		<link>http://kritsana.uttamang.com/mathpacksolver/tutorial/solving-system-of-linear-equations/</link>
		<comments>http://kritsana.uttamang.com/mathpacksolver/tutorial/solving-system-of-linear-equations/#comments</comments>
		<pubDate>Wed, 27 Nov 2013 06:38:03 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.mathpacksolver.com/main/?p=1</guid>
		<description><![CDATA[A system of linear equations is a collection of linear equations involving the same set of variables. For example: 5x + 2y &#8211; 3z = 1 -2x &#8211; y + 7z = 8 4x &#8211; 13y + z = -10 is a system of three equations in the three variables x, y and z. A [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>A system of linear equations is a collection of linear equations involving the same set of variables.</p>
<dl>
<dt>For example:</dt>
<dd>5x + 2y &#8211; 3z = 1</dd>
<dd>-2x &#8211; y + 7z = 8</dd>
<dd>4x &#8211; 13y + z = -10</dd>
</dl>
<p>is a system of three equations in the three variables x, y and z.</p>
<p>A general form of system of <i>m</i> linear equations with <i>n</i> unknowns can be written as:</p>
<dl>
<dt></dt>
<dd>a<sub>11</sub>x<sub>1</sub> + a<sub>12</sub>x<sub>2</sub> + a<sub>13</sub>x<sub>3</sub> + &#8230; + a<sub>1n</sub>x<sub>n</sub> = b<sub>1</sub></dd>
<dd>a<sub>21</sub>x<sub>1</sub> + a<sub>22</sub>x<sub>2</sub> + a<sub>23</sub>x<sub>3</sub> + &#8230; + a<sub>2n</sub>x<sub>n</sub> = b<sub>2</sub></dd>
<dd>&#8230; &#8230; &#8230; &#8230;</dd>
<dd>a<sub>m1</sub>x<sub>1</sub> + a<sub>m2</sub>x<sub>2</sub> + a<sub>m3</sub>x<sub>3</sub> + &#8230; + a<sub>mn</sub>x<sub>n</sub> = b<sub>m</sub></dd>
</dl>
<p>From above system of linear equations, x<sub>1</sub>, x<sub>2</sub>, x<sub>3</sub>, &#8230;, x<sub>n</sub> are unknown, a<sub>11</sub>, a<sub>12</sub>, a<sub>13</sub>, &#8230; a<sub>mn</sub> are coefficients of the system, and b<sub>1</sub>, b<sub>2</sub>, b<sub>3</sub>, &#8230;, b<sub>n</sub> are the constant terms. If all constant terms are zero, the system of linear equations is called homogeneous system (see <a href="http://kritsana.uttamang.com/mathpacksolver/tutorial/solving-homogeneous-system/">Solving Homogeneous System</a>).</p>
<h2>Matrix Equation</h2>
<p>The system of linear equations is equivalent to a matrix equation of the form</p>
<dl>
<dt></dt>
<dd><strong>AX</strong>=<strong>B</strong></dd>
</dl>
<dl>
<dt>Where:</dt>
<dd><strong>A</strong> is <em>m</em> x <em>n</em> matrix of coefficients. Element of matrix <strong>A</strong> at <em>i</em> <sup>th</sup>-row and <em>j</em> <sup>th</sup>-column is a<sub><em>ij</em></sub>.</dd>
<dd><strong>X</strong> is <em>n</em> x 1 matrix (column vector with <em>n</em> entries). Element of matrix <strong>X</strong> at <em>i</em> <sup>th</sup>-row is x<sub><em>i</em></sub>.</dd>
<dd><strong>B</strong> is <em>m</em> x 1 matrix (column vector with <em>m</em> entries). Element of matrix <strong>B</strong> at <em>i</em> <sup>th</sup>-row is b<sub><em>i</em></sub>.</dd>
</dl>
<p>&nbsp;</p>
<h2>Solving with MathPACK Solver</h2>
<p>MathPACK Solver can solve the system of linear equations for finding the values of unknowns (matrix <b>X</b>) by using <b>linsolve</b> function. The system of linear equations must be written in the form of Matrix Equation described in previous section and the number of linear equations must be equal to number of unknowns (<b>A</b> must be square matrix : <i>m</i> = <i>n</i>).</p>
<h3>Function Signature</h3>
<p>X = linsolve(A, B);</p>
<h3>Example</h3>
<dl>
<dt></dt>
<dd>5x + 2y &#8211; 3z = 1</dd>
<dd>-2x &#8211; y + 7z = 8</dd>
<dd>4x &#8211; 13y + z = -10</dd>
<dt></dt>
<dt>So, the following expressions must be executed in MathPACK Solver console</dt>
<dt></dt>
<dd><code><br />
»A = [5, 2, -3; -2, -1,7; 4, -13, 1]; </code></dd>
<dd><code>»B = [1; 8; -10]; </code></dd>
<dd><code>»X = linsolve(A, B) </code></dd>
<dd><code>ans = </code></dd>
<dd><code><span>    0.6571</span> </code><code> </code></dd>
<dd><code><span>    1.0857</span> </code><code> </code></dd>
<dd><code><span>    1.4857</span> </code></dd>
<dd> </dd>
<dt>So, the solution will be:</dt>
<dt></dt>
<dd>x = 0.6571</dd>
<dd>y = 1.0857</dd>
<dd>z = 1.4857</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://kritsana.uttamang.com/mathpacksolver/tutorial/solving-system-of-linear-equations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
