1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922
|
<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.51
from ./octave.texi on 18 June 1999 -->
<TITLE>GNU Octave - Arithmetic</TITLE>
</HEAD>
<BODY>
Go to the <A HREF="octave_1.html">first</A>, <A HREF="octave_16.html">previous</A>, <A HREF="octave_18.html">next</A>, <A HREF="octave_40.html">last</A> section, <A HREF="octave_toc.html">table of contents</A>.
<P><HR><P>
<H1><A NAME="SEC136" HREF="octave_toc.html#TOC136">Arithmetic</A></H1>
<P>
Unless otherwise noted, all of the functions described in this chapter
will work for real and complex scalar or matrix arguments.
</P>
<H2><A NAME="SEC137" HREF="octave_toc.html#TOC137">Utility Functions</A></H2>
<P>
The following functions are available for working with complex numbers.
Each expects a single argument. They are called <STRONG>mapping functions</STRONG>
because when given a matrix argument, they apply the given function to
each element of the matrix.
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>ceil</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX614"></A>
Return the smallest integer not less than <VAR>x</VAR>. If <VAR>x</VAR> is
complex, return <CODE>ceil (real (<VAR>x</VAR>)) + ceil (imag (<VAR>x</VAR>)) * I</CODE>.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>exp</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX615"></A>
Compute the exponential of <VAR>x</VAR>. To compute the matrix exponential,
see section <A HREF="octave_18.html#SEC143">Linear Algebra</A>.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>fix</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX616"></A>
Truncate <VAR>x</VAR> toward zero. If <VAR>x</VAR> is complex, return
<CODE>fix (real (<VAR>x</VAR>)) + fix (imag (<VAR>x</VAR>)) * I</CODE>.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>floor</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX617"></A>
Return the largest integer not greater than <VAR>x</VAR>. If <VAR>x</VAR> is
complex, return <CODE>floor (real (<VAR>x</VAR>)) + floor (imag (<VAR>x</VAR>)) * I</CODE>.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>gcd</B> <I>(<VAR>x</VAR>, <CODE>...</CODE>)</I>
<DD><A NAME="IDX618"></A>
Compute the greatest common divisor of the elements of <VAR>x</VAR>, or the
list of all the arguments. For example,
</P>
<PRE>
gcd (a1, ..., ak)
</PRE>
<P>
is the same as
</P>
<PRE>
gcd ([a1, ..., ak])
</PRE>
<P>
An optional second return value, <VAR>v</VAR>
contains an integer vector such that
</P>
<PRE>
g = v(1) * a(k) + ... + v(k) * a(k)
</PRE>
</DL>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>lcm</B> <I>(<VAR>x</VAR>, <CODE>...</CODE>)</I>
<DD><A NAME="IDX619"></A>
Compute the least common multiple of the elements elements of <VAR>x</VAR>, or
the list of all the arguments. For example,
</P>
<PRE>
lcm (a1, ..., ak)
</PRE>
<P>
is the same as
</P>
<PRE>
lcm ([a1, ..., ak]).
</PRE>
</DL>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>log</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX620"></A>
Compute the natural logarithm of <VAR>x</VAR>. To compute the matrix logarithm,
see section <A HREF="octave_18.html#SEC143">Linear Algebra</A>.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>log10</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX621"></A>
Compute the base-10 logarithm of <VAR>x</VAR>.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <VAR>y</VAR> = <B>log2</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX622"></A>
<DT><U>Mapping Function:</U> [<VAR>f</VAR>, <VAR>e</VAR>] <B>log2</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX623"></A>
Compute the base-2 logarithm of <VAR>x</VAR>. With two outputs, returns
<VAR>f</VAR> and <VAR>e</VAR> such that
1/2 <= abs(f) < 1 and x = f * 2^e.
</DL>
</P>
<P>
<DL>
<DT><U>Loadable Function:</U> <B>max</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX624"></A>
For a vector argument, return the maximum value. For a matrix argument,
return the maximum value from each column, as a row vector. Thus,
</P>
<PRE>
max (max (<VAR>x</VAR>))
</PRE>
<P>
returns the largest element of <VAR>x</VAR>.
</P>
<P>
For complex arguments, the magnitude of the elements are used for
comparison.
</DL>
</P>
<P>
<DL>
<DT><U>Loadable Function:</U> <B>min</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX625"></A>
Like <CODE>max</CODE>, but return the minimum value.
</DL>
</P>
<P>
<DL>
<DT><U>Function File:</U> <B>nextpow2</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX626"></A>
If <VAR>x</VAR> is a scalar, returns the first integer <VAR>n</VAR> such that
2^n >= abs (x).
</P>
<P>
If <VAR>x</VAR> is a vector, return <CODE>nextpow2 (length (<VAR>x</VAR>))</CODE>.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>pow2</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX627"></A>
<DT><U>Mapping Function:</U> <B>pow2</B> <I>(<VAR>f</VAR>, <VAR>e</VAR>)</I>
<DD><A NAME="IDX628"></A>
With one argument, computes
2 .^ x
for each element of <VAR>x</VAR>. With two arguments, returns
f .* (2 .^ e).
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>rem</B> <I>(<VAR>x</VAR>, <VAR>y</VAR>)</I>
<DD><A NAME="IDX629"></A>
Return the remainder of <CODE><VAR>x</VAR> / <VAR>y</VAR></CODE>, computed using the
expression
</P>
<PRE>
x - y .* fix (x ./ y)
</PRE>
<P>
An error message is printed if the dimensions of the arguments do not
agree, or if either of the arguments is complex.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>round</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX630"></A>
Return the integer nearest to <VAR>x</VAR>. If <VAR>x</VAR> is complex, return
<CODE>round (real (<VAR>x</VAR>)) + round (imag (<VAR>x</VAR>)) * I</CODE>.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>sign</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX631"></A>
Compute the <STRONG>signum</STRONG> function, which is defined as
</P>
<PRE>
-1, x < 0;
sign (x) = 0, x = 0;
1, x > 0.
</PRE>
<P>
For complex arguments, <CODE>sign</CODE> returns <CODE>x ./ abs (<VAR>x</VAR>)</CODE>.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>sqrt</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX632"></A>
Compute the square root of <VAR>x</VAR>. If <VAR>x</VAR> is negative, a complex
result is returned. To compute the matrix square root, see
section <A HREF="octave_18.html#SEC143">Linear Algebra</A>.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>xor</B> <I>(<VAR>x</VAR>, <VAR>y</VAR>)</I>
<DD><A NAME="IDX633"></A>
Return the `exclusive or' of the entries of <VAR>x</VAR> and <VAR>y</VAR>.
For boolean expressions <VAR>x</VAR> and <VAR>y</VAR>,
<CODE>xor (<VAR>x</VAR>, <VAR>y</VAR>)</CODE> is true if and only if <VAR>x</VAR> or <VAR>y</VAR>
is true, but not if both <VAR>x</VAR> and <VAR>y</VAR> are true.
</DL>
</P>
<H2><A NAME="SEC138" HREF="octave_toc.html#TOC138">Complex Arithmetic</A></H2>
<P>
The following functions are available for working with complex
numbers. Each expects a single argument. Given a matrix they work on
an element by element basis. In the descriptions of the following
functions,
<VAR>z</VAR> is the complex number <VAR>x</VAR> + <VAR>i</VAR><VAR>y</VAR>, where <VAR>i</VAR> is
defined as <CODE>sqrt (-1)</CODE>.
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>abs</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX634"></A>
Compute the magnitude of <VAR>z</VAR>, defined as
|<VAR>z</VAR>| = <CODE>sqrt (x^2 + y^2)</CODE>.
</P>
<P>
For example,
</P>
<PRE>
abs (3 + 4i)
=> 5
</PRE>
</DL>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>arg</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX635"></A>
<DT><U>Mapping Function:</U> <B>angle</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX636"></A>
Compute the argument of <VAR>z</VAR>, defined as
<VAR>theta</VAR> = <CODE>atan (<VAR>y</VAR>/<VAR>x</VAR>)</CODE>.
</P>
<P>
in radians.
</P>
<P>
For example,
</P>
<PRE>
arg (3 + 4i)
=> 0.92730
</PRE>
</DL>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>conj</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX637"></A>
Return the complex conjugate of <VAR>z</VAR>, defined as
<CODE>conj (<VAR>z</VAR>)</CODE> = <VAR>x</VAR> - <VAR>i</VAR><VAR>y</VAR>.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>imag</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX638"></A>
Return the imaginary part of <VAR>z</VAR> as a real number.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>real</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX639"></A>
Return the real part of <VAR>z</VAR>.
</DL>
</P>
<H2><A NAME="SEC139" HREF="octave_toc.html#TOC139">Trigonometry</A></H2>
<P>
Octave provides the following trigonometric functions:
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>sin</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX640"></A>
<DT><U>Mapping Function:</U> <B>cos</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX641"></A>
<DT><U>Mapping Function:</U> <B>tan</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX642"></A>
<DT><U>Mapping Function:</U> <B>sec</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX643"></A>
<DT><U>Mapping Function:</U> <B>csc</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX644"></A>
<DT><U>Mapping Function:</U> <B>cot</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX645"></A>
The ordinary trigonometric functions.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>asin</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX646"></A>
<DT><U>Mapping Function:</U> <B>acos</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX647"></A>
<DT><U>Mapping Function:</U> <B>atan</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX648"></A>
<DT><U>Mapping Function:</U> <B>asec</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX649"></A>
<DT><U>Mapping Function:</U> <B>acsc</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX650"></A>
<DT><U>Mapping Function:</U> <B>acot</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX651"></A>
The ordinary inverse trigonometric functions.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>sinh</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX652"></A>
<DT><U>Mapping Function:</U> <B>cosh</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX653"></A>
<DT><U>Mapping Function:</U> <B>tanh</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX654"></A>
<DT><U>Mapping Function:</U> <B>sech</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX655"></A>
<DT><U>Mapping Function:</U> <B>csch</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX656"></A>
<DT><U>Mapping Function:</U> <B>coth</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX657"></A>
Hyperbolic trigonometric functions.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>asinh</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX658"></A>
<DT><U>Mapping Function:</U> <B>acosh</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX659"></A>
<DT><U>Mapping Function:</U> <B>atanh</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX660"></A>
<DT><U>Mapping Function:</U> <B>asech</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX661"></A>
<DT><U>Mapping Function:</U> <B>acsch</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX662"></A>
<DT><U>Mapping Function:</U> <B>acoth</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX663"></A>
Inverse hyperbolic trigonometric functions.
</DL>
</P>
<P>
Each of these functions expect a single argument. For matrix arguments,
they work on an element by element basis. For example,
</P>
<PRE>
sin ([1, 2; 3, 4])
=> 0.84147 0.90930
0.14112 -0.75680
</PRE>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>atan2</B> <I>(<VAR>y</VAR>, <VAR>x</VAR>)</I>
<DD><A NAME="IDX664"></A>
Return the arctangent of <VAR>y</VAR>/<VAR>x</VAR>. The signs of the arguments
are used to determine the quadrant of the result, which is in the range
<CODE>pi</CODE> to -<CODE>pi</CODE>.
</DL>
</P>
<H2><A NAME="SEC140" HREF="octave_toc.html#TOC140">Sums and Products</A></H2>
<P>
<DL>
<DT><U>Built-in Function:</U> <B>sum</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX665"></A>
For a vector argument, return the sum of all the elements. For a matrix
argument, return the sum of the elements in each column, as a row
vector. The sum of an empty matrix is 0 if it has no columns, or a
vector of zeros if it has no rows (see section <A HREF="octave_5.html#SEC50">Empty Matrices</A>).
</DL>
</P>
<P>
<DL>
<DT><U>Built-in Function:</U> <B>prod</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX666"></A>
For a vector argument, return the product of all the elements. For a
matrix argument, return the product of the elements in each column, as a
row vector. The product of an empty matrix is 1 if it has no columns,
or a vector of ones if it has no rows (see section <A HREF="octave_5.html#SEC50">Empty Matrices</A>).
</DL>
</P>
<P>
<DL>
<DT><U>Built-in Function:</U> <B>cumsum</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX667"></A>
Return the cumulative sum of each column of <VAR>x</VAR>. For example,
</P>
<PRE>
cumsum ([1, 2; 3, 4])
=> 1 2
4 6
</PRE>
</DL>
<P>
<DL>
<DT><U>Built-in Function:</U> <B>cumprod</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX668"></A>
Return the cumulative product of each column of <VAR>x</VAR>. For example,
</P>
<PRE>
cumprod ([1, 2; 3, 4])
=> 1 2
3 8
</PRE>
</DL>
<P>
<DL>
<DT><U>Built-in Function:</U> <B>sumsq</B> <I>(<VAR>x</VAR>)</I>
<DD><A NAME="IDX669"></A>
For a vector argument, return the sum of the squares of all the
elements. For a matrix argument, return the sum of the squares of the
elements in each column, as a row vector.
</DL>
</P>
<H2><A NAME="SEC141" HREF="octave_toc.html#TOC141">Special Functions</A></H2>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>besseli</B> <I>(<VAR>alpha</VAR>, <VAR>x</VAR>)</I>
<DD><A NAME="IDX670"></A>
<DT><U>Mapping Function:</U> <B>besselj</B> <I>(<VAR>alpha</VAR>, <VAR>x</VAR>)</I>
<DD><A NAME="IDX671"></A>
<DT><U>Mapping Function:</U> <B>besselk</B> <I>(<VAR>alpha</VAR>, <VAR>x</VAR>)</I>
<DD><A NAME="IDX672"></A>
<DT><U>Mapping Function:</U> <B>bessely</B> <I>(<VAR>alpha</VAR>, <VAR>x</VAR>)</I>
<DD><A NAME="IDX673"></A>
Compute Bessel functions of the following types:
</P>
<DL COMPACT>
<DT><CODE>besselj</CODE>
<DD>
Bessel functions of the first kind.
<DT><CODE>bessely</CODE>
<DD>
Bessel functions of the second kind.
<DT><CODE>besseli</CODE>
<DD>
Modified Bessel functions of the first kind.
<DT><CODE>besselk</CODE>
<DD>
Modified Bessel functions of the second kind.
</DL>
<P>
The second argument, <VAR>x</VAR>, must be a real matrix, vector, or scalar.
</P>
<P>
The first argument, <VAR>alpha</VAR>, must be greater than or equal to zero.
If <VAR>alpha</VAR> is a range, it must have an increment equal to one.
</P>
<P>
If <VAR>alpha</VAR> is a scalar, the result is the same size as <VAR>x</VAR>.
</P>
<P>
If <VAR>alpha</VAR> is a range, <VAR>x</VAR> must be a vector or scalar, and the
result is a matrix with <CODE>length(<VAR>x</VAR>)</CODE> rows and
<CODE>length(<VAR>alpha</VAR>)</CODE> columns.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>beta</B> <I>(<VAR>a</VAR>, <VAR>b</VAR>)</I>
<DD><A NAME="IDX674"></A>
Return the Beta function,
</P>
<PRE>
beta (a, b) = gamma (a) * gamma (b) / gamma (a + b).
</PRE>
</DL>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>betai</B> <I>(<VAR>a</VAR>, <VAR>b</VAR>, <VAR>x</VAR>)</I>
<DD><A NAME="IDX675"></A>
Return the incomplete Beta function,
</P>
<PRE>
x
/
betai (a, b, x) = beta (a, b)^(-1) | t^(a-1) (1-t)^(b-1) dt.
/
t=0
</PRE>
<P>
If x has more than one component, both <VAR>a</VAR> and <VAR>b</VAR> must be
scalars. If <VAR>x</VAR> is a scalar, <VAR>a</VAR> and <VAR>b</VAR> must be of
compatible dimensions.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>bincoeff</B> <I>(<VAR>n</VAR>, <VAR>k</VAR>)</I>
<DD><A NAME="IDX676"></A>
Return the binomial coefficient of <VAR>n</VAR> and <VAR>k</VAR>, defined as
</P>
<PRE>
/ \
| n | n (n-1) (n-2) ... (n-k+1)
| | = -------------------------
| k | k!
\ /
</PRE>
<P>
For example,
</P>
<PRE>
bincoeff (5, 2)
=> 10
</PRE>
</DL>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>erf</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX677"></A>
Computes the error function,
</P>
<PRE>
z
/
erf (z) = (2/sqrt (pi)) | e^(-t^2) dt
/
t=0
</PRE>
</DL>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>erfc</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX678"></A>
Computes the complementary error function,
<CODE>1 - erf (<VAR>z</VAR>)</CODE>.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>erfinv</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX679"></A>
Computes the inverse of the error function,
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>gamma</B> <I>(<VAR>z</VAR>)</I>
<DD><A NAME="IDX680"></A>
Computes the Gamma function,
</P>
<PRE>
infinity
/
gamma (z) = | t^(z-1) exp (-t) dt.
/
t=0
</PRE>
</DL>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>gammai</B> <I>(<VAR>a</VAR>, <VAR>x</VAR>)</I>
<DD><A NAME="IDX681"></A>
Computes the incomplete gamma function,
</P>
<PRE>
x
1 /
gammai (a, x) = --------- | exp (-t) t^(a-1) dt
gamma (a) /
t=0
</PRE>
<P>
If <VAR>a</VAR> is scalar, then <CODE>gammai (<VAR>a</VAR>, <VAR>x</VAR>)</CODE> is returned
for each element of <VAR>x</VAR> and vice versa.
</P>
<P>
If neither <VAR>a</VAR> nor <VAR>x</VAR> is scalar, the sizes of <VAR>a</VAR> and
<VAR>x</VAR> must agree, and <VAR>gammai</VAR> is applied element-by-element.
</DL>
</P>
<P>
<DL>
<DT><U>Mapping Function:</U> <B>lgamma</B> <I>(<VAR>a</VAR>, <VAR>x</VAR>)</I>
<DD><A NAME="IDX682"></A>
<DT><U>Mapping Function:</U> <B>gammaln</B> <I>(<VAR>a</VAR>, <VAR>x</VAR>)</I>
<DD><A NAME="IDX683"></A>
Return the natural logarithm of the gamma function.
</DL>
</P>
<P>
<DL>
<DT><U>Function File:</U> <B>cross</B> <I>(<VAR>x</VAR>, <VAR>y</VAR>)</I>
<DD><A NAME="IDX684"></A>
Computes the vector cross product of the two 3-dimensional vectors
<VAR>x</VAR> and <VAR>y</VAR>. For example,
</P>
<PRE>
cross ([1,1,0], [0,1,1])
=> [ 1; -1; 1 ]
</PRE>
</DL>
<P>
<DL>
<DT><U>Function File:</U> <B>commutation_matrix</B> <I>(<VAR>m</VAR>, <VAR>n</VAR>)</I>
<DD><A NAME="IDX685"></A>
Return the commutation matrix
K(m,n)
which is the unique
<VAR>m</VAR>*<VAR>n</VAR> by <VAR>m</VAR>*<VAR>n</VAR>
matrix such that
<VAR>K</VAR>(<VAR>m</VAR>,<VAR>n</VAR>) * vec (<VAR>A</VAR>) = vec (<VAR>A</VAR>')
for all
<VAR>m</VAR> by <VAR>n</VAR>
matrices
<VAR>A</VAR>.
</P>
<P>
If only one argument <VAR>m</VAR> is given,
K(m,m)
is returned.
</P>
<P>
See Magnus and Neudecker (1988), Matrix differential calculus with
applications in statistics and econometrics.
</DL>
</P>
<P>
<DL>
<DT><U>Function File:</U> <B>duplication_matrix</B> <I>(<VAR>n</VAR>)</I>
<DD><A NAME="IDX686"></A>
Return the duplication matrix
<VAR>D</VAR>_<VAR>n</VAR>
which is the unique
<VAR>n</VAR>^2 by <VAR>n</VAR>*(<VAR>n</VAR>+1)/2
matrix such that
<VAR>D</VAR>_<VAR>n</VAR> \cdot vech (<VAR>A</VAR>) = vec (<VAR>A</VAR>)
for all symmetric
<VAR>n</VAR> by <VAR>n</VAR>
matrices
<VAR>A</VAR>.
</P>
<P>
See Magnus and Neudecker (1988), Matrix differential calculus with
applications in statistics and econometrics.
</DL>
</P>
<H2><A NAME="SEC142" HREF="octave_toc.html#TOC142">Mathematical Constants</A></H2>
<P>
<DL>
<DT><U>Built-in Variable:</U> <B>I</B>
<DD><A NAME="IDX687"></A>
<DT><U>Built-in Variable:</U> <B>J</B>
<DD><A NAME="IDX688"></A>
<DT><U>Built-in Variable:</U> <B>i</B>
<DD><A NAME="IDX689"></A>
<DT><U>Built-in Variable:</U> <B>j</B>
<DD><A NAME="IDX690"></A>
A pure imaginary number, defined as
<CODE>sqrt (-1)</CODE>.
The <CODE>I</CODE> and <CODE>J</CODE> forms are true constants, and cannot be
modified. The <CODE>i</CODE> and <CODE>j</CODE> forms are like ordinary variables,
and may be used for other purposes. However, unlike other variables,
they once again assume their special predefined values if they are
cleared See section <A HREF="octave_8.html#SEC61">Status of Variables</A>.
</DL>
</P>
<P>
<DL>
<DT><U>Built-in Variable:</U> <B>Inf</B>
<DD><A NAME="IDX691"></A>
<DT><U>Built-in Variable:</U> <B>inf</B>
<DD><A NAME="IDX692"></A>
Infinity. This is the result of an operation like 1/0, or an operation
that results in a floating point overflow.
</DL>
</P>
<P>
<DL>
<DT><U>Built-in Variable:</U> <B>NaN</B>
<DD><A NAME="IDX693"></A>
<DT><U>Built-in Variable:</U> <B>nan</B>
<DD><A NAME="IDX694"></A>
Not a number. This is the result of an operation like
0/0, or <SAMP>`Inf - Inf'</SAMP>,
or any operation with a NaN.
</P>
<P>
Note that NaN always compares not equal to NaN. This behavior is
specified by the IEEE standard for floating point arithmetic. To
find NaN values, you must use the <CODE>isnan</CODE> function.
</DL>
</P>
<P>
<DL>
<DT><U>Built-in Variable:</U> <B>pi</B>
<DD><A NAME="IDX695"></A>
The ratio of the circumference of a circle to its diameter.
Internally, <CODE>pi</CODE> is computed as <SAMP>`4.0 * atan (1.0)'</SAMP>.
</DL>
</P>
<P>
<DL>
<DT><U>Built-in Variable:</U> <B>e</B>
<DD><A NAME="IDX696"></A>
The base of natural logarithms. The constant
<VAR>e</VAR>
satisfies the equation
<CODE>log</CODE> (<VAR>e</VAR>) = 1.
</DL>
</P>
<P>
<DL>
<DT><U>Built-in Variable:</U> <B>eps</B>
<DD><A NAME="IDX697"></A>
The machine precision. More precisely, <CODE>eps</CODE> is the largest
relative spacing between any two adjacent numbers in the machine's
floating point system. This number is obviously system-dependent. On
machines that support 64 bit IEEE floating point arithmetic, <CODE>eps</CODE>
is approximately
2.2204e-16.
</DL>
</P>
<P>
<DL>
<DT><U>Built-in Variable:</U> <B>realmax</B>
<DD><A NAME="IDX698"></A>
The largest floating point number that is representable. The actual
value is system-dependent. On machines that support 64 bit IEEE
floating point arithmetic, <CODE>realmax</CODE> is approximately
1.7977e+308
</DL>
</P>
<P>
<DL>
<DT><U>Built-in Variable:</U> <B>realmin</B>
<DD><A NAME="IDX699"></A>
The smallest floating point number that is representable. The actual
value is system-dependent. On machines that support 64 bit IEEE
floating point arithmetic, <CODE>realmin</CODE> is approximately
2.2251e-308
</DL>
</P>
<P><HR><P>
Go to the <A HREF="octave_1.html">first</A>, <A HREF="octave_16.html">previous</A>, <A HREF="octave_18.html">next</A>, <A HREF="octave_40.html">last</A> section, <A HREF="octave_toc.html">table of contents</A>.
</BODY>
</HTML>
|