1 <?xml version="1.0" encoding="UTF-8"?>
2 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="power">
4 <refname>power</refname>
5 <refpurpose>(^,.^) power operation</refpurpose>
15 <title>Arguments</title>
20 <para>scalar, polynomial or rational matrix.</para>
26 <para>a scalar, a vector or a scalar matrix.</para>
32 <title>Description</title>
36 If <literal>A</literal> is a square matrix and <literal>b</literal> is a scalar then <literal>A^b</literal> is the matrix <literal>A</literal> to the power <literal>b</literal>.
41 If <literal>b</literal> is a scalar and <literal>A</literal> a matrix then
42 <literal>A.^b</literal> is the matrix formed by the element of
43 <literal>A</literal> to the power <literal>b</literal> (element-wise power). If
44 <literal>A</literal> is a vector and <literal>b</literal> is a scalar then
45 <literal>A^b</literal> and <literal>A.^b</literal> performs the same operation
46 (i.e. element-wise power).
51 If <literal>A</literal> is a scalar and <literal>b</literal> is a square matrix <literal>A^b</literal> is the matrix <literal> expm(log(A) * b)</literal>.
54 If <literal>A</literal> is a scalar and <literal>b</literal> is a vector <literal>A^b</literal> and <literal>A.^b</literal> are the vector formed by <literal> a^(b(i,j))</literal>.
57 If <literal>A</literal> is a scalar and <literal>b</literal> is a matrix <literal>A.^b</literal> is the matrix formed by <literal> a^(b(i,j))</literal>.
62 If <literal>A</literal> and <literal>b</literal> are vectors (matrices) of the same size <literal>A.^b</literal> is the <literal>A(i)^b(i)</literal> vector (<literal>A(i,j)^b(i,j)</literal> matrix).
68 <title>Additional Remarks</title>
73 1. For square matrices <literal>A^p</literal> is computed through successive matrices
74 multiplications if <literal>p</literal> is a positive integer, and by <emphasis>diagonalization</emphasis> if not (see "note 2 and 3" below for details).
77 2. If <varname>A</varname> is a square and Hermitian matrix and <varname>p</varname> is a non-integer scalar,
78 <literal>A^p</literal> is computed as:
81 <code>A^p = u*diag(diag(s).^p)*u'</code> (For real matrix <varname>A</varname>, only the real part of the answer is taken into account).
84 <varname>u</varname> and <varname>s</varname> are determined by <code>[u,s] = schur(A)</code> .
87 3. If <varname>A</varname> is not a Hermitian matrix and <varname>p</varname> is a non-integer scalar,
88 <literal>A^p</literal> is computed as:
91 <code>A^p = v*diag(diag(d).^p)*inv(v)</code> (For real matrix <varname>A</varname>, only the real part of the answer is taken into account).
94 <varname>d</varname> and <varname>v</varname> are determined by <code>[d,v] = bdiag(A+0*%i)</code> .
97 4. If <varname>A</varname> and <varname>p</varname> are real or complex numbers,
98 <literal>A^p</literal> is the <emphasis>principal value</emphasis> determined by:
101 <code>A^p = exp(p*log(A))</code> (or <code>A^p = exp(p*(log(abs(A))+ %i*atan(imag(A)/real(A))))</code> ).
104 5. If <varname>A</varname> is a square matrix and <varname>p</varname> is a real or complex number,
105 <literal>A.^p</literal> is the <emphasis>principal value</emphasis> computed as:
108 <code>A.^p = exp(p*log(A))</code> (same as case 4 above).
111 6. <literal>**</literal> and <literal>^</literal> operators are synonyms.
115 Exponentiation is right-associative in Scilab contrarily to MatlabĀ® and Octave.
116 For example 2^3^4 is equal to 2^(3^4) in Scilab but is equal to (2^3)^4 in MatlabĀ®
122 <title>Examples</title>
123 <programlisting role="example"><![CDATA[
138 <refsection role="see also">
139 <title>See also</title>
140 <simplelist type="inline">
142 <link linkend="exp">exp</link>
145 <link linkend="hat">hat</link>