1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2012 - 2016 - Scilab Enterprises
5 * Copyright (C) 2020 - Samuel GOUGEON
7 * This file is hereby licensed under the terms of the GNU GPL v2.0,
8 * pursuant to article 5.3.4 of the CeCILL v.2.1.
9 * This file was originally licensed under the terms of the CeCILL v2.1,
10 * and continues to be available under such terms.
11 * For more information, see the COPYING file which you should have received
12 * along with this program.
15 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
16 xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
17 xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
18 xml:lang="en" xml:id="power">
20 <refname>power</refname>
21 <refpurpose>(^,.^) power operation</refpurpose>
32 <title>Arguments</title>
37 a scalar, vector, or matrix of encoded integers, decimal or complex numbers,
38 polynomials, or rationals.
45 a scalar, vector, or matrix of encoded integers, decimal or complex numbers.
51 If an operand are encoded integers, the other one can be only encoded integers or real
55 If <varname>A</varname> are polynomials or rationals, <varname>b</varname> can only be
56 a single decimal (positive or negative) integer.
60 <title>Description</title>
62 <title>.^ by-element power</title>
64 If <varname>A</varname> or <varname>b</varname> is scalar, it is first
65 replicated to the size of the other, with A*ones(b) or b*ones(A).
66 Otherwise, <varname>A</varname> and <varname>b</varname> must have the same size.
69 Then, for each element of index i, <literal>t(i) = A(i)^b(i)</literal>
74 <title>^ matricial power</title>
76 The ^ operator is equivalent to the .^ by-element power in the following cases:
79 <varname>A</varname> is scalar and <varname>b</varname> is a vector.
82 <varname>A</varname> is a vector and <varname>b</varname> is scalar.
85 Otherwise, <varname>A</varname> or <varname>b</varname> must be a scalar,
86 and the other one must be a square matrix:
90 If <varname>A</varname> is scalar and <varname>b</varname> is
91 a square matrix, then <literal>A^b</literal> is the matrix
92 <literal>expm(log(A) * b)</literal>
97 If <varname>A</varname> is a square matrix and <varname>b</varname>
98 is scalar, then <literal>A^b</literal> is the matrix
99 <varname>A</varname> to the power <varname>b</varname>.
106 <title>Remarks</title>
110 For square matrices <literal>A^p</literal> is computed through successive
111 matrices multiplications if <literal>p</literal> is a positive integer, and by
112 <emphasis>diagonalization</emphasis> if not (see "note 2 and 3" below for details).
117 If <varname>A</varname> is a square and Hermitian matrix and <literal>p</literal>
118 is a non-integer scalar, <literal>A^p</literal> is computed as:
121 <code>A^p = u*diag(diag(s).^p)*u'</code> (For real matrix <varname>A</varname>,
122 only the real part of the answer is taken into account).
125 <literal>u</literal> and <literal>s</literal> are determined by
126 <code>[u,s] = schur(A)</code> .
131 If <varname>A</varname> is not a Hermitian matrix and <literal>p</literal> is a
132 non-integer scalar, <literal>A^p</literal> is computed as:
135 <code>A^p = v*diag(diag(d).^p)*inv(v)</code> (For real matrix <varname>A</varname>,
136 only the real part of the answer is taken into account).
139 <literal>d</literal> and <literal>v</literal> are determined by
140 <code>[d,v] = bdiag(A+0*%i)</code>.
145 If <varname>A</varname> and <literal>p</literal> are real or complex numbers,
146 <literal>A^p</literal> is the <emphasis>principal value</emphasis> determined by
149 <code>A^p = exp(p*log(A))</code>
152 (or <code>A^p = exp(p*(log(abs(A))+ %i*atan(imag(A)/real(A))))</code> ).
157 If <varname>A</varname> is a square matrix and <literal>p</literal> is a real or
158 complex number, <literal>A.^p</literal> is the <emphasis>principal value</emphasis>
162 <code>A.^p = exp(p*log(A))</code> (same as case 4 above).
167 <literal>**</literal> and <literal>^</literal> operators are synonyms.
173 Exponentiation is right-associative in Scilab, contrarily to MatlabĀ® and Octave.
174 For example 2^3^4 is equal to 2^(3^4) in Scilab, but to (2^3)^4 in MatlabĀ® and Octave.
180 <title>Examples</title>
181 <programlisting role="example"><![CDATA[
196 <refsection role="see also">
197 <title>See also</title>
198 <simplelist type="inline">
200 <link linkend="exp">exp</link>
203 <link linkend="expm">expm</link>
206 <link linkend="hat">hat</link>
209 <link linkend="inv">inv</link>
213 <refsection role="history">
214 <title>History</title>
217 <revnumber>6.0.0</revnumber>
219 With decimal or complex numbers, <literal>scalar ^ squareMat</literal> now
220 yields <literal>expm(log(scalar)*squareMat)</literal> instead of
221 <literal>scalar .^ squareMat</literal>