Add a warning about associativity.
[scilab.git] / scilab / modules / core / help / en_US / 1_keywords / hat.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) INRIA
5  * 
6  * This file must be used under the terms of the CeCILL.
7  * This source file is licensed as described in the file COPYING, which
8  * you should have received as part of this distribution.  The terms
9  * are also available at    
10  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
11  *
12  -->
13 <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="hat">
14     <refnamediv>
15         <refname>hat</refname>
16         <refpurpose>(^) exponentiation</refpurpose>
17     </refnamediv>
18     <refsynopsisdiv>
19         <title>Calling Sequence</title>
20         <synopsis>A^b</synopsis>
21     </refsynopsisdiv>
22     <refsection>
23         <title>Description</title>
24         <para>
25             Exponentiation of matrices or vectors by a constant vector.
26         </para>
27         <para>
28             If <literal>A</literal> is a vector or a rectangular matrix the exponentiation is done
29             element-wise, with the usual meaning.
30         </para>
31         <para>
32             For square <literal>A</literal> matrix the exponentiation is done in the matrix sense.
33         </para>
34         <para>
35             For boolean, polynomial and rational matrices, the exponent must be an
36             integer.
37         </para>
38         <refsection>
39             <title>Remarks </title>
40             <para>
41                 <literal>123.^b</literal> is interpreted as <literal>(123).^b</literal>. In such
42                 cases dot is part of the operator, not of the number.
43             </para>
44             <para>
45                 For two real or complex numbers <literal>x1</literal> and
46                 <literal>x2</literal> the value of  <literal>x1^x2</literal> is the "principal value"
47                 determined by <literal>x1^x2 = exp(x2*log(x1))</literal>.
48             </para>
49             <para>
50                 <warning>
51                     Exponentiation is right-associative in Scilab contrarily to Matlab&#174; and Octave. For example 2^3^4 is equal to 2^(3^4) in Scilab but is equal to (2^3)^4 in Matlab&#174; and Octave.
52                 </warning>
53             </para>
54         </refsection>
55     </refsection>
56     <refsection>
57         <title>Examples</title>
58         <programlisting role="example"><![CDATA[ 
59 2^4
60 (-0.5)^(1/3)
61 [1 2;2 4]^(1+%i)
62 s=poly(0,"s");
63 [1 2 s]^4
64 [s 1;1  s]^(-1)
65  ]]></programlisting>
66     </refsection>
67     <refsection role="see also">
68         <title>See Also</title>
69         <simplelist type="inline">
70             <member>
71                 <link linkend="exp">exp</link>
72             </member>
73             <member>
74                 <link linkend="log">log</link>
75             </member>
76         </simplelist>
77     </refsection>
78 </refentry>