<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Functions of a Matrix (GNU Octave (version 5.1.0))</title> <meta name="description" content="Functions of a Matrix (GNU Octave (version 5.1.0))"> <meta name="keywords" content="Functions of a Matrix (GNU Octave (version 5.1.0))"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="makeinfo"> <link href="index.html#Top" rel="start" title="Top"> <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> <link href="Linear-Algebra.html#Linear-Algebra" rel="up" title="Linear Algebra"> <link href="Specialized-Solvers.html#Specialized-Solvers" rel="next" title="Specialized Solvers"> <link href="Matrix-Factorizations.html#Matrix-Factorizations" rel="prev" title="Matrix Factorizations"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} blockquote.indentedblock {margin-right: 0em} blockquote.smallindentedblock {margin-right: 0em; font-size: smaller} blockquote.smallquotation {font-size: smaller} div.display {margin-left: 3.2em} div.example {margin-left: 3.2em} div.lisp {margin-left: 3.2em} div.smalldisplay {margin-left: 3.2em} div.smallexample {margin-left: 3.2em} div.smalllisp {margin-left: 3.2em} kbd {font-style: oblique} pre.display {font-family: inherit} pre.format {font-family: inherit} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} pre.smalldisplay {font-family: inherit; font-size: smaller} pre.smallexample {font-size: smaller} pre.smallformat {font-family: inherit; font-size: smaller} pre.smalllisp {font-size: smaller} span.nolinebreak {white-space: nowrap} span.roman {font-family: initial; font-weight: normal} span.sansserif {font-family: sans-serif; font-weight: normal} ul.no-bullet {list-style: none} --> </style> <link rel="stylesheet" type="text/css" href="octave.css"> </head> <body lang="en"> <a name="Functions-of-a-Matrix"></a> <div class="header"> <p> Next: <a href="Specialized-Solvers.html#Specialized-Solvers" accesskey="n" rel="next">Specialized Solvers</a>, Previous: <a href="Matrix-Factorizations.html#Matrix-Factorizations" accesskey="p" rel="prev">Matrix Factorizations</a>, Up: <a href="Linear-Algebra.html#Linear-Algebra" accesskey="u" rel="up">Linear Algebra</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> </div> <hr> <a name="Functions-of-a-Matrix-1"></a> <h3 class="section">18.4 Functions of a Matrix</h3> <a name="index-matrix_002c-functions-of"></a> <a name="XREFexpm"></a><dl> <dt><a name="index-expm"></a><em></em> <strong>expm</strong> <em>(<var>A</var>)</em></dt> <dd><p>Return the exponential of a matrix. </p> <p>The matrix exponential is defined as the infinite Taylor series </p> <div class="example"> <pre class="example">expm (A) = I + A + A^2/2! + A^3/3! + … </pre></div> <p>However, the Taylor series is <em>not</em> the way to compute the matrix exponential; see Moler and Van Loan, <cite>Nineteen Dubious Ways to Compute the Exponential of a Matrix</cite>, SIAM Review, 1978. This routine uses Ward’s diagonal Padé approximation method with three step preconditioning (SIAM Journal on Numerical Analysis, 1977). Diagonal Padé approximations are rational polynomials of matrices </p> <div class="example"> <pre class="example"> -1 D (A) N (A) </pre></div> <p>whose Taylor series matches the first <code>2q+1</code> terms of the Taylor series above; direct evaluation of the Taylor series (with the same preconditioning steps) may be desirable in lieu of the Padé approximation when <code>Dq(A)</code> is ill-conditioned. </p> <p><strong>See also:</strong> <a href="#XREFlogm">logm</a>, <a href="#XREFsqrtm">sqrtm</a>. </p></dd></dl> <a name="XREFlogm"></a><dl> <dt><a name="index-logm"></a><em><var>s</var> =</em> <strong>logm</strong> <em>(<var>A</var>)</em></dt> <dt><a name="index-logm-1"></a><em><var>s</var> =</em> <strong>logm</strong> <em>(<var>A</var>, <var>opt_iters</var>)</em></dt> <dt><a name="index-logm-2"></a><em>[<var>s</var>, <var>iters</var>] =</em> <strong>logm</strong> <em>(…)</em></dt> <dd><p>Compute the matrix logarithm of the square matrix <var>A</var>. </p> <p>The implementation utilizes a Padé approximant and the identity </p> <div class="example"> <pre class="example">logm (<var>A</var>) = 2^k * logm (<var>A</var>^(1 / 2^k)) </pre></div> <p>The optional input <var>opt_iters</var> is the maximum number of square roots to compute and defaults to 100. </p> <p>The optional output <var>iters</var> is the number of square roots actually computed. </p> <p><strong>See also:</strong> <a href="#XREFexpm">expm</a>, <a href="#XREFsqrtm">sqrtm</a>. </p></dd></dl> <a name="XREFsqrtm"></a><dl> <dt><a name="index-sqrtm"></a><em><var>s</var> =</em> <strong>sqrtm</strong> <em>(<var>A</var>)</em></dt> <dt><a name="index-sqrtm-1"></a><em>[<var>s</var>, <var>error_estimate</var>] =</em> <strong>sqrtm</strong> <em>(<var>A</var>)</em></dt> <dd><p>Compute the matrix square root of the square matrix <var>A</var>. </p> <p>Ref: N.J. Higham. <cite>A New sqrtm for <small>MATLAB</small></cite>. Numerical Analysis Report No. 336, Manchester Centre for Computational Mathematics, Manchester, England, January 1999. </p> <p><strong>See also:</strong> <a href="#XREFexpm">expm</a>, <a href="#XREFlogm">logm</a>. </p></dd></dl> <a name="XREFkron"></a><dl> <dt><a name="index-kron"></a><em></em> <strong>kron</strong> <em>(<var>A</var>, <var>B</var>)</em></dt> <dt><a name="index-kron-1"></a><em></em> <strong>kron</strong> <em>(<var>A1</var>, <var>A2</var>, …)</em></dt> <dd><p>Form the Kronecker product of two or more matrices. </p> <p>This is defined block by block as </p> <div class="example"> <pre class="example">x = [ a(i,j)*b ] </pre></div> <p>For example: </p> <div class="example"> <pre class="example">kron (1:4, ones (3, 1)) ⇒ 1 2 3 4 1 2 3 4 1 2 3 4 </pre></div> <p>If there are more than two input arguments <var>A1</var>, <var>A2</var>, …, <var>An</var> the Kronecker product is computed as </p> <div class="example"> <pre class="example">kron (kron (<var>A1</var>, <var>A2</var>), …, <var>An</var>) </pre></div> <p>Since the Kronecker product is associative, this is well-defined. </p></dd></dl> <a name="XREFblkmm"></a><dl> <dt><a name="index-blkmm"></a><em></em> <strong>blkmm</strong> <em>(<var>A</var>, <var>B</var>)</em></dt> <dd><p>Compute products of matrix blocks. </p> <p>The blocks are given as 2-dimensional subarrays of the arrays <var>A</var>, <var>B</var>. The size of <var>A</var> must have the form <code>[m,k,…]</code> and size of <var>B</var> must be <code>[k,n,…]</code>. The result is then of size <code>[m,n,…]</code> and is computed as follows: </p> <div class="example"> <pre class="example">for i = 1:prod (size (<var>A</var>)(3:end)) <var>C</var>(:,:,i) = <var>A</var>(:,:,i) * <var>B</var>(:,:,i) endfor </pre></div> </dd></dl> <a name="XREFsylvester"></a><dl> <dt><a name="index-sylvester"></a><em><var>X</var> =</em> <strong>sylvester</strong> <em>(<var>A</var>, <var>B</var>, <var>C</var>)</em></dt> <dd><p>Solve the Sylvester equation. </p> <p>The Sylvester equation is defined as: </p> <div class="example"> <pre class="example">A X + X B = C </pre></div> <p>The solution is computed using standard <small>LAPACK</small> subroutines. </p> <p>For example: </p> <div class="example"> <pre class="example">sylvester ([1, 2; 3, 4], [5, 6; 7, 8], [9, 10; 11, 12]) ⇒ [ 0.50000, 0.66667; 0.66667, 0.50000 ] </pre></div> </dd></dl> <hr> <div class="header"> <p> Next: <a href="Specialized-Solvers.html#Specialized-Solvers" accesskey="n" rel="next">Specialized Solvers</a>, Previous: <a href="Matrix-Factorizations.html#Matrix-Factorizations" accesskey="p" rel="prev">Matrix Factorizations</a>, Up: <a href="Linear-Algebra.html#Linear-Algebra" accesskey="u" rel="up">Linear Algebra</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> </div> </body> </html>