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 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227
|
<!DOCTYPE html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="generator" content="hevea 2.32">
<style type="text/css">
.li-itemize{margin:1ex 0ex;}
.li-enumerate{margin:1ex 0ex;}
.dd-description{margin:0ex 0ex 1ex 4ex;}
.dt-description{margin:0ex;}
.toc{list-style:none;}
.footnotetext{margin:0ex; padding:0ex;}
div.footnotetext P{margin:0px; text-indent:1em;}
.thefootnotes{text-align:left;margin:0ex;}
.dt-thefootnotes{margin:0em;}
.dd-thefootnotes{margin:0em 0em 0em 2em;}
.footnoterule{margin:1em auto 1em 0px;width:50%;}
.caption{padding-left:2ex; padding-right:2ex; margin-left:auto; margin-right:auto}
.title{margin:2ex auto;text-align:center}
.titlemain{margin:1ex 2ex 2ex 1ex;}
.titlerest{margin:0ex 2ex;}
.center{text-align:center;margin-left:auto;margin-right:auto;}
.flushleft{text-align:left;margin-left:0ex;margin-right:auto;}
.flushright{text-align:right;margin-left:auto;margin-right:0ex;}
div table{margin-left:inherit;margin-right:inherit;margin-bottom:2px;margin-top:2px}
td table{margin:auto;}
table{border-collapse:collapse;}
td{padding:0;}
.cellpadding0 tr td{padding:0;}
.cellpadding1 tr td{padding:1px;}
pre{text-align:left;margin-left:0ex;margin-right:auto;}
blockquote{margin-left:4ex;margin-right:4ex;text-align:left;}
td p{margin:0px;}
.boxed{border:1px solid black}
.textboxed{border:1px solid black}
.vbar{border:none;width:2px;background-color:black;}
.hbar{border:none;height:2px;width:100%;background-color:black;}
.hfill{border:none;height:1px;width:200%;background-color:black;}
.vdisplay{border-collapse:separate;border-spacing:2px;width:auto; empty-cells:show; border:2px solid red;}
.vdcell{white-space:nowrap;padding:0px; border:2px solid green;}
.display{border-collapse:separate;border-spacing:2px;width:auto; border:none;}
.dcell{white-space:nowrap;padding:0px; border:none;}
.dcenter{margin:0ex auto;}
.vdcenter{border:solid #FF8000 2px; margin:0ex auto;}
.minipage{text-align:left; margin-left:0em; margin-right:auto;}
.marginpar{border:solid thin black; width:20%; text-align:left;}
.marginparleft{float:left; margin-left:0ex; margin-right:1ex;}
.marginparright{float:right; margin-left:1ex; margin-right:0ex;}
.theorem{text-align:left;margin:1ex auto 1ex 0ex;}
.part{margin:2ex auto;text-align:center}
</style>
<title>tutoriel</title>
</head>
<body >
<!--HEVEA command line is: /usr/bin/hevea -fix tutoriel.tex -->
<!--CUT STYLE article--><!--CUT DEF section 1 --><p>
<br>
<br>
<br>
</p><div class="center">
<span style="font-size:xx-large"><span style="font-size:150%">An </span></span><span style="font-size:xx-large"><span style="font-size:150%"><span style="font-family:monospace">Xcas</span></span></span><span style="font-size:xx-large"><span style="font-size:150%"> Tutorial</span></span>
</div><!--TOC section id="sec1" Contents-->
<h2 id="sec1" class="section">Contents</h2><!--SEC END --><ul class="toc"><li class="li-toc">
<a href="#sec2">1  Getting started</a>
<ul class="toc"><li class="li-toc">
<a href="#sec3">1.1  Starting <span style="font-family:monospace">Xcas</span></a>
</li><li class="li-toc"><a href="#sec4">1.2  <span style="font-family:monospace">XCas</span> as a calculator</a>
</li><li class="li-toc"><a href="#sec5">1.3  Functions and variables</a>
</li><li class="li-toc"><a href="#sec6">1.4  Simplifying expressions</a>
</li><li class="li-toc"><a href="#sec7">1.5  Graphs</a>
</li><li class="li-toc"><a href="#sec8">1.6  The Help Index</a>
</li></ul>
</li><li class="li-toc"><a href="#sec9">2  The interface</a>
<ul class="toc"><li class="li-toc">
<a href="#sec10">2.1  Overview</a>
</li><li class="li-toc"><a href="#sec11">2.2  The menu bar</a>
</li><li class="li-toc"><a href="#sec12">2.3  Configuration</a>
</li><li class="li-toc"><a href="#sec13">2.4  The command line</a>
</li></ul>
</li><li class="li-toc"><a href="#sec14">3  Computational objects</a>
<ul class="toc"><li class="li-toc">
<a href="#sec15">3.1  Numbers</a>
</li><li class="li-toc"><a href="#sec16">3.2  Variables</a>
</li><li class="li-toc"><a href="#sec17">3.3  Expressions</a>
</li><li class="li-toc"><a href="#sec18">3.4  Functions</a>
</li><li class="li-toc"><a href="#sec19">3.5  Lists, sequences and sets</a>
</li><li class="li-toc"><a href="#sec20">3.6  Characters and strings</a>
</li><li class="li-toc"><a href="#sec21">3.7  Calculation time and memory space</a>
</li></ul>
</li><li class="li-toc"><a href="#sec22">4  Analysis with <span style="font-family:monospace">Xcas</span></a>
<ul class="toc"><li class="li-toc">
<a href="#sec23">4.1  Derivatives</a>
</li><li class="li-toc"><a href="#sec24">4.2  Limits and series</a>
</li><li class="li-toc"><a href="#sec25">4.3  Antiderivatives and integrals</a>
</li><li class="li-toc"><a href="#sec26">4.4  Solving equations</a>
</li><li class="li-toc"><a href="#sec27">4.5  Differential equations</a>
</li></ul>
</li><li class="li-toc"><a href="#sec28">5  Algebra with <span style="font-family:monospace">Xcas</span></a>
<ul class="toc"><li class="li-toc">
<a href="#sec29">5.1  Integer arithmetic</a>
</li><li class="li-toc"><a href="#sec30">5.2  Polynomials and rational functions</a>
</li><li class="li-toc"><a href="#sec31">5.3  Trigonometry</a>
</li><li class="li-toc"><a href="#sec32">5.4  Vectors and matrices</a>
</li><li class="li-toc"><a href="#sec33">5.5  Linear systems</a>
</li><li class="li-toc"><a href="#sec34">5.6  Matrix reduction</a>
</li></ul>
</li><li class="li-toc"><a href="#sec35">6  Graphs</a>
<ul class="toc"><li class="li-toc">
<a href="#sec36">6.1  Curves</a>
</li><li class="li-toc"><a href="#sec37">6.2  Plane geometry</a>
</li><li class="li-toc"><a href="#sec38">6.3  3D graphical objects</a>
</li></ul>
</li><li class="li-toc"><a href="#sec39">7  Programming</a>
<ul class="toc"><li class="li-toc">
<a href="#sec40">7.1  The language</a>
</li><li class="li-toc"><a href="#sec41">7.2  Some examples</a>
</li><li class="li-toc"><a href="#sec42">7.3  Programming style</a>
</li></ul>
</li><li class="li-toc"><a href="#sec43">8  Exercises</a>
</li></ul><p><span style="font-family:monospace">Xcas</span> is a free (as in Free Software) computer algebra system.
Although there are other computer algebra systems, both free and
commercial, few if any are as versatile as <span style="font-family:monospace">Xcas</span>,
which is capable of, among other things:
</p><ul class="itemize"><li class="li-itemize">
Symbolic and numeric calculation.
</li><li class="li-itemize">Programming.
</li><li class="li-itemize">Graphing functions.
</li><li class="li-itemize">Working with spreadsheets.
</li><li class="li-itemize">Interactive geometry (both two- and three-dimensional).
</li><li class="li-itemize">Turtle geometry.
</li></ul><p>
This tutorial will briefly introduce you to calculating,
programming and graphing with <span style="font-family:monospace">Xcas</span>. The first section,
“Getting started”, will be just enough information to get you
started. The second section will be a brief overview of the
graphic interface and the rest will be more in-depth tutorial.</p><p>For more information, you can refer to the manual or any of the other
sources of information under the <span style="font-family:monospace">Help</span> menu.</p>
<!--TOC section id="sec2" Getting started-->
<h2 id="sec2" class="section">1  Getting started</h2><!--SEC END -->
<!--TOC subsection id="sec3" Starting <span style="font-family:monospace">Xcas</span>-->
<h3 id="sec3" class="subsection">1.1  Starting <span style="font-family:monospace">Xcas</span></h3><!--SEC END --><p>
<a id="hevea_default0"></a></p><p><span style="font-family:monospace">Xcas</span> is available from
<a href="http://www-fourier.ujf-grenoble.fr/~parisse/giac_fr.html"><span style="font-family:monospace">http://www-fourier.ujf-grenoble.fr/~parisse/giac_fr.html</span></a>.
<a id="hevea_default1"></a>
This page also has information on installation. Once installed, the
way to start the program depends on the operating system.
</p><ul class="itemize"><li class="li-itemize">
Under Windows, there should be a shortcut <span style="font-family:monospace">xcasen.bat</span> that
you can click on.
</li><li class="li-itemize">Under Linux, you can either find it on a menu provided by the
desktop environment, or enter <span style="font-family:monospace">xcas &</span> in a terminal window.
</li><li class="li-itemize">Under MacOS, you can click on <span style="font-family:monospace">xcas</span> in the Applications menu.
</li></ul><p>
For this tutorial, you will mostly be working with the
command line, which will be a white rectangle next to the number
<span style="font-family:monospace">1</span>.<a id="hevea_default2"></a> There you can enter a command, after which there will be
a window with the result, followed by another command line with the
number <span style="font-family:monospace">2</span>.</p>
<!--TOC subsection id="sec4" <span style="font-family:monospace">XCas</span> as a calculator-->
<h3 id="sec4" class="subsection">1.2  <span style="font-family:monospace">XCas</span> as a calculator</h3><!--SEC END --><p>Once you have started <span style="font-family:monospace">Xcas</span>, you can immediately use it as a
calculator. Simply type in the expression that you wish to
use using the standard arithmetic operators; namely <span style="font-family:monospace">+</span> for
addition, <span style="font-family:monospace">-</span> for subtraction, <span style="font-family:monospace">*</span> for multiplication,
<span style="font-family:monospace">/</span> for division and <span style="font-family:monospace">^</span> for exponentiation.
If you enter
</p><blockquote class="quote"><span style="font-family:monospace">34+45*12
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
574
</td></tr>
</table><p>
If you enter
</p><blockquote class="quote"><span style="font-family:monospace">2/3 + 98/7
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">44</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">3</td></tr>
</table></td></tr>
</table><p>
The operators have a standard order of operations, and parentheses
can be used for grouping. (Brackets have a different meaning, see
section <a href="#lists">3.5</a>, “Lists, sequences and sets”.)</p><p>Notice that if you enter integers or other exact
values,<a id="hevea_default3"></a>
<span style="font-family:monospace">Xcas</span> will give you the exact result. If you enter an
approximate value, such as a number with a decimal point (computers
regard numbers with decimal points as approximate values), then
<span style="font-family:monospace">Xcas</span> will give you an approximate
result.<a id="hevea_default4"></a> For example, if
you enter
</p><blockquote class="quote"><span style="font-family:monospace">2/3 + 3/2
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">13</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">6</td></tr>
</table></td></tr>
</table><p>
but if you enter
</p><blockquote class="quote"><span style="font-family:monospace">2/3 + 1.5
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
2.16666666667
</td></tr>
</table><p>
You can also get a decimal approximation using the <span style="font-family:monospace">evalf</span>
function.<a id="hevea_default5"></a> If you enter
</p><blockquote class="quote"><span style="font-family:monospace">evalf(2/3 + 3/2)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
2.16666666667
</td></tr>
</table><p>
By default, <span style="font-family:monospace">Xcas</span> will give you 12 decimal places of accuracy
in its approximations, but this is configurable (see section
<a href="#config">2.3</a>, “Configuration”).</p><p><span style="font-family:monospace">Xcas</span> also has the standard functions, such as
<span style="font-family:monospace">sin</span>, <span style="font-family:monospace">cos</span>, <span style="font-family:monospace">asin</span> (for the arcsin),
<span style="font-family:monospace">log</span> (for the natural logarithm).
It also has common constants such as <span style="font-family:monospace">pi</span>, <span style="font-family:monospace">e</span> and <span style="font-family:monospace">i</span>.</p><p>The trigonometric functions assume that angles are measured in
radians. (This can be configured, see section <a href="#config">2.3</a>,
“Configuration”.) If you enter
</p><blockquote class="quote"><span style="font-family:monospace">sin(pi/4)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><table class="display"><tr style="vertical-align:middle"><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" >2</td></tr>
</table></td></tr>
</table></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">2</td></tr>
</table></td></tr>
</table>
<!--TOC subsection id="sec5" Functions and variables-->
<h3 id="sec5" class="subsection">1.3  Functions and variables</h3><!--SEC END --><p><span style="font-family:monospace">Xcas</span> can work with expressions and variables as well as
numbers.<a id="hevea_default6"></a>
A variable in <span style="font-family:monospace">Xcas</span> needs to begin with a letter and can
include numbers and underscores. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">x^2 + x + 2*x + 2
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">x</span><sup>2</sup> + 3*<span style="font-style:italic">x</span> + 2
</td></tr>
</table><p>
You can give a variable a value with the assignment operator,
<span style="font-family:monospace">:=</span>.<a id="hevea_default7"></a> To assign the variable
<span style="font-family:monospace">myvar</span> the value 5, for example, you can enter
</p><blockquote class="quote"><span style="font-family:monospace">myvar := 5
</span></blockquote><p>
If you later use <span style="font-family:monospace">myvar</span> in an expression, it will be replaced
by <span style="font-family:monospace">5</span>; entering
</p><blockquote class="quote"><span style="font-family:monospace">myvar*x + myvar^2
</span></blockquote><p>
will result in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
5*<span style="font-style:italic">x</span> + 25
</td></tr>
</table><p>The assignment operator can also be used to define
functions.<a id="hevea_default8"></a> To
define the squaring function, for example, you can enter
</p><blockquote class="quote"><span style="font-family:monospace">sqr(x) := x^2
</span></blockquote><p>
Afterwards, whenever you enter <span style="font-family:monospace">sqr(expression)</span> you will
get the expression squared. For example, entering
</p><blockquote class="quote"><span style="font-family:monospace">sqr(7)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
49
</td></tr>
</table><p>
and entering
</p><blockquote class="quote"><span style="font-family:monospace">sqr(x+1)
</span></blockquote><p>
will result in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
(<span style="font-style:italic">x</span>+1)<sup>2</sup>
</td></tr>
</table>
<!--TOC subsection id="sec6" Simplifying expressions-->
<h3 id="sec6" class="subsection">1.4  Simplifying expressions</h3><!--SEC END --><p>When you enter an expression into <span style="font-family:monospace">Xcas</span>, some simplifications
will be done automatically. For example, if you enter
</p><blockquote class="quote"><span style="font-family:monospace">a := 3
</span></blockquote><blockquote class="quote"><span style="font-family:monospace">b := 4
</span></blockquote><p>
and
</p><blockquote class="quote"><span style="font-family:monospace">a*b*x + 4*b^2
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
12*<span style="font-style:italic">x</span> + 64
</td></tr>
</table><p><span style="font-family:monospace">Xcas</span> has several transformations in case you want an
expression to be simplified beyond the automatic simplifications, or
perhaps transformed in another way. Some examples are:
</p><dl class="description"><dt class="dt-description">
<span style="font-weight:bold"><span style="font-family:monospace">expand</span></span></dt><dd class="dd-description"><a id="hevea_default9"></a>
This will expand integer powers, and more generally distribute
multiplication across addition. For example, if you enter
<blockquote class="quote"><span style="font-family:monospace">expand((x+1)^3)
</span></blockquote>
you will get
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">x</span><sup>3</sup> + 3*<span style="font-style:italic">x</span><sup>2</sup> + 3*<span style="font-style:italic">x</span> + 1
</td></tr>
</table></dd><dt class="dt-description"><span style="font-weight:bold"><span style="font-family:monospace">factor</span></span></dt><dd class="dd-description"><a id="hevea_default10"></a>
This will factor polynomials. For example, if you enter
<blockquote class="quote"><span style="font-family:monospace">factor(x^2 + 3*x + 2)
</span></blockquote>
you will get
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
(<span style="font-style:italic">x</span> + 1)*(<span style="font-style:italic">x</span> + 2)
</td></tr>
</table>
</dd></dl>
<!--TOC subsection id="sec7" Graphs-->
<h3 id="sec7" class="subsection">1.5  Graphs</h3><!--SEC END --><p><span style="font-family:monospace">Xcas</span> has several functions for plotting graphs; perhaps the
simplest is the <span style="font-family:monospace">plot</span> function.<a id="hevea_default11"></a>
The <span style="font-family:monospace">plot</span> function requires two arguments, an expression to be
graphed and a variable. For example, if you enter
</p><blockquote class="quote"><span style="font-family:monospace">plot(sin(x),x)
</span></blockquote><p>
you will get the graph
</p><div class="center">
<img src="tutoriel001.png">
</div><p>
To the right of the graph will be a panel you can use to control
various aspects. By default, the graph will cover values of the
variable from −10 to 10; this is of course configurable (see
section <a href="#config">2.3</a>, “Configuration”). To plot
over a different interval you can also use a second argument of
<span style="font-style:italic">var</span>=<span style="font-style:italic">min</span>..<span style="font-style:italic">max</span> instead of simply
<span style="font-style:italic">var</span>. For example, if you enter
</p><blockquote class="quote"><span style="font-family:monospace">plot(sin(x),x=-pi..pi)
</span></blockquote><p>
you will get the graph
</p><div class="center">
<img src="tutoriel002.png">
</div>
<!--TOC subsection id="sec8" The Help Index-->
<h3 id="sec8" class="subsection">1.6  The Help Index</h3><!--SEC END --><p>You can get a list of all <span style="font-family:monospace">Xcas</span> commands and variables using the
<span style="font-family:monospace">Help</span>▸<span style="font-family:monospace">Index</span><a id="hevea_default12"></a> menu item.
This will bring up the following window:
</p><div class="center">
<img src="tutoriel003.png">
</div><p>
Under <span style="font-family:monospace">Index</span> will be a scrollable list of all the commands and
variables.
If you begin typing to the right of the question mark, you will be
taken to the part of the list beginning with the characters you typed;
for example, if you type <span style="font-family:monospace">evalf</span>, <a id="hevea_default13"></a>
you will get the following:
</p><div class="center">
<img src="tutoriel004.png">
</div><p>
In the upper right-hand pane under <span style="font-family:monospace">Related</span> is a list of
commands related to the chosen command, below that is a list of
synonyms; you can see that the <span style="font-family:monospace">approx</span> command is the same as
the <span style="font-family:monospace">evalf</span> command. Below the line where you typed the
command name is a description of the command; here you
can see that <span style="font-family:monospace">evalf</span> takes an optional second argument
(brackets in the description indicate that an argument is optional)
which can specify the number of digits in the approximation; for
example,
</p><blockquote class="quote"><span style="font-family:monospace">evalf(pi)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
3.14159265359
</td></tr>
</table><p>
but
</p><blockquote class="quote"><span style="font-family:monospace">evalf(pi,20)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
3.1415926535897932385
</td></tr>
</table><p>
Below the description is a line where you can enter the arguments for
the command; if you enter values in these boxes then the command with
the chosen arguments will be placed on the <span style="font-family:monospace">Xcas</span> command line.
At the bottom of the help window is a list of examples of the command
being used; if you click on one of these examples it will appear on
the <span style="font-family:monospace">Xcas</span> command line.</p><p>As well as using the menu, you can get to the help
index<a id="hevea_default14"></a> by using the
tab key while at the <span style="font-family:monospace">Xcas</span> command line. If you have typed
the beginning of a command before using the tab key, then that
beginning will be presented to you in the help index.</p>
<!--TOC section id="sec9" The interface-->
<h2 id="sec9" class="section">2  The interface</h2><!--SEC END -->
<!--TOC subsection id="sec10" Overview-->
<h3 id="sec10" class="subsection">2.1  Overview</h3><!--SEC END --><p>When you start <span style="font-family:monospace">Xcas</span>, you will be presented with a window which
looks like the following:
</p><div class="center">
<img src="tutoriel005.png">
</div><p>
From top to bottom, there is<a id="hevea_default15"></a>
</p><ul class="itemize"><li class="li-itemize">
A menu bar.<a id="hevea_default16"></a>
</li><li class="li-itemize">A tab indicating the name of the session, or <span style="font-family:monospace">Unnamed</span> if the
session has not been saved. You can run several sessions
simultaneously, in which case each session will get its own tab.
</li><li class="li-itemize">A session management bar, with
<ul class="itemize"><li class="li-itemize">
A <span style="font-family:monospace">?</span> button, which will open the help index.
</li><li class="li-itemize">A <span style="font-family:monospace">save</span> button to save the session.
</li><li class="li-itemize">A configuration button indicating how <span style="font-family:monospace">Xcas</span> is currently
configured. Clicking on this button will open a configuration
window.
</li><li class="li-itemize">A <span style="font-family:monospace">STOP</span> button you can use to interrupt a calculation
which is running on too long.
</li><li class="li-itemize">A <span style="font-family:monospace">Kbd</span> button to bring up an on-screen keyboard which you
can use to help enter your commands. It will come with a control panel
which you can use to display a message window (<span style="font-family:monospace">msg</span>) or
show an extra menu (<span style="font-family:monospace">cmds</span>) at the bottom.
</li><li class="li-itemize">An <span style="font-family:monospace">X</span> button to close the session.
</li></ul>
</li><li class="li-itemize">A numbered command line.
</li></ul>
<!--TOC subsection id="sec11" The menu bar-->
<h3 id="sec11" class="subsection">2.2  The menu bar</h3><!--SEC END --><p>
<a id="hevea_default17"></a>
The menu items have submenus, and sometimes sub-submenus. When
indicating a submenu item, it will be separated from the menu item with
▸; for example, you can save a session with
<span style="font-family:monospace">File</span>▸<span style="font-family:monospace">Save</span>, which is the <span style="font-family:monospace">Save</span>
item in the <span style="font-family:monospace">File</span> menu.</p><p>The menu bar contains the usual menus for graphic programs. It also
contains all of the <span style="font-family:monospace">Xcas</span> commands grouped by themes. For
some commands, if you choose it from a menu then the command will be
put on the command line. If the message window is open (which you can
open with the
<span style="font-family:monospace">Cfg</span>▸<span style="font-family:monospace">Show</span>▸<span style="font-family:monospace">msg</span>
menu item), a brief description of the command will appear in that
window. For other commands, for example the <span style="font-family:monospace">Graphic</span>
commands, you will get a dialog box which lets you specify the
arguments; afterwards, the command with the arguments will be placed
on the command line.</p><p>The <span style="font-family:monospace">Help</span> menu has links to the Help index, various manuals,
as well as the online forum. </p>
<!--TOC subsection id="sec12" Configuration-->
<h3 id="sec12" class="subsection">2.3  Configuration</h3><!--SEC END --><p>
<a id="config"></a></p><p>The <span style="font-family:monospace">Cfg</span> menu has various items that allow you to configure
various aspects of <span style="font-family:monospace">Xcas</span>. This tutorial will
refer to the <span style="font-family:monospace">Cfg</span>▸<span style="font-family:monospace">Cas configuration</span> and
<span style="font-family:monospace">Cfg</span>▸<span style="font-family:monospace">Graph configuration</span> menu items. The
<span style="font-family:monospace">Cfg</span>▸<span style="font-family:monospace">Cas configuration</span> menu item will
bring up the same configuration page as clicking on the status bar.
These items will bring up windows with various entry fields and
check boxes; after you make any changes, you can click the
<span style="font-family:monospace">Apply</span> button to apply them and the <span style="font-family:monospace">Save</span> button to
save them for future sessions.</p><p>The <span style="font-family:monospace">Cfg</span>▸<span style="font-family:monospace">Cas configuration</span> menu item will
bring up a window with options that determine how <span style="font-family:monospace">Xcas</span> computes.
This includes some things mentioned in this tutorial, such as:
</p><ul class="itemize"><li class="li-itemize">
<span style="font-weight:bold">Digits.</span><a id="hevea_default18"></a>
This entry field determines the number of significant digits used in
calculations. This resets the value of the variable <span style="font-family:monospace">Digits</span>,
which you can also reset from the command line.
</li><li class="li-itemize"><span style="font-weight:bold">epsilon.</span><a id="hevea_default19"></a>
This entry field determines how close the fraction returned by
<span style="font-family:monospace">exact</span> will be to the input. This resets the value of the
variable <span style="font-family:monospace">epsilon</span>, which you can also reset from the command
line.
</li><li class="li-itemize"><span style="font-weight:bold">radian.</span><a id="hevea_default20"></a>
This checkbox determines whether angles are measured in radians or
degrees.
</li><li class="li-itemize"><span style="font-weight:bold">Complex.</span><a id="hevea_default21"></a>
This checkbox determines whether computations will find complex
solutions to equations.
</li><li class="li-itemize"><span style="font-weight:bold">All_trig_sol.</span><a id="hevea_default22"></a>
This checkbox determines whether <span style="font-family:monospace">solve</span> will find the
primary solutions to trigonometric equations or all solutions.
</li></ul><p>The <span style="font-family:monospace">Cfg</span>▸<span style="font-family:monospace">Graph configuration</span> menu item
will bring up a window with options that determine how <span style="font-family:monospace">Xcas</span>
draws graphs. This includes the default ranges for the axes; the
<span style="font-style:italic">x</span>-axis will go from <span style="font-family:monospace">X-</span> to <span style="font-family:monospace">X+</span>, the <span style="font-style:italic">y</span>-axis will go
from <span style="font-family:monospace">Y-</span> to <span style="font-family:monospace">Y+</span> and the <span style="font-style:italic">z</span>-axis will go from
<span style="font-family:monospace">Z-</span> to <span style="font-family:monospace">Z+</span>.</p>
<!--TOC subsection id="sec13" The command line-->
<h3 id="sec13" class="subsection">2.4  The command line</h3><!--SEC END --><p>
<a id="hevea_default23"></a></p><p>You can run a command by typing it into the command
line and pressing <span style="font-family:monospace">Enter</span>. If you want to enter more than one
command on a line, you can separate them with semicolons. If you want
to suppress the output of a command, you can end it with a
colon-semicolon (<span style="font-family:monospace">:;</span>).</p><p>If you have enough commands, there will be a scroll bar on the right
which you can use to scroll through different command line levels. The
<span style="font-family:monospace">Edit</span> menu will allow you to merge levels, group levels and
add comments.</p><p>All commands are kept in memory. You can scroll through previous
commands with <span style="font-family:monospace">Ctrl+</span> arrow keys, and modify them if you want.</p>
<!--TOC section id="sec14" Computational objects-->
<h2 id="sec14" class="section">3  Computational objects</h2><!--SEC END -->
<!--TOC subsection id="sec15" Numbers-->
<h3 id="sec15" class="subsection">3.1  Numbers</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Operations</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">+</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >addition</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">-</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >subtraction </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">*</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >multiplication </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">/</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >division</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">^</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >power </td></tr>
</table>
</div><p>
<a id="hevea_default24"></a>
<a id="hevea_default25"></a>
<a id="hevea_default26"></a>
<a id="hevea_default27"></a>
<a id="hevea_default28"></a></p><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Conversions</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">evalf</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >approximate a number</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">exact</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >find an exact number close to the given number</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">epsilon</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >determine how close a fraction has to be to
a floating point number to be returned by
<span style="font-family:monospace">exact</span></td></tr>
</table>
</div><p>
<a id="hevea_default29"></a>
<a id="hevea_default30"></a>
<a id="hevea_default31"></a></p><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Constants</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">pi</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >π≃ 3.14159265359 </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">e</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-style:italic">e</span> ≃ 2.71828182846 </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">i</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-style:italic">i</span>=√<span style="text-decoration:overline">−1</span> </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">infinity</span> or <span style="font-family:monospace">inf</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >∞ </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">+infinity</span> or <span style="font-family:monospace">+inf</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >+∞ </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">-infinity</span> or <span style="font-family:monospace">-inf</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >−∞ </td></tr>
</table>
</div><p>
<a id="hevea_default32"></a>
<a id="hevea_default33"></a>
<a id="hevea_default34"></a>
<a id="hevea_default35"></a>
<a id="hevea_default36"></a></p><p>There are two types of numbers in <span style="font-family:monospace">Xcas</span>, approximate and exact.</p><p>Computer programs like <span style="font-family:monospace">Xcas</span> regard floating point numbers,
which are numbers displayed with decimal points, as
approximations.<a id="hevea_default37"></a> Other
numbers will be regarded as exact.<a id="hevea_default38"></a> For example, the number
<span style="font-family:monospace">2</span> is exactly 2, while <span style="font-family:monospace">2.0</span> represents a number that
equals 2 to within the current precision, which by default is about 12
significant digits (see section <a href="#config">2.3</a>, “Configuration”).
Approximate numbers can be entered by
typing in a number with a decimal point or in scientific notation
(which is a decimal number followed by <span style="font-family:monospace">e</span> and then an integer,
where the integer represents the power of 10). So <span style="font-family:monospace">2000.0</span>,
<span style="font-family:monospace">2e3</span> and <span style="font-family:monospace">2.0e3</span> all represent the same approximate
number.</p><p>Exact numbers are integers, symbolic constants (like <span style="font-style:italic">e</span> and π),
and numeric expressions which only involve exact
numbers.<a id="hevea_default39"></a> For example,
sin(1) will be exact, and so won’t be given a decimal
approximation; if you enter
</p><blockquote class="quote"><span style="font-family:monospace">sin(1)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
sin(1)
</td></tr>
</table><p>
However, sin(1.0) involves the approximate number <span style="font-family:monospace">1.0</span>, and
so will be regarded as approximate itself. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">sin(1.0)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
0.841470984808
</td></tr>
</table><p>As with many computer languages, if you enter an integer beginning
with the digit 0, the <span style="font-family:monospace">Xcas</span> will regard it as an integer
base 8;<a id="hevea_default40"></a> if you enter
</p><blockquote class="quote"><span style="font-family:monospace">011
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
9
</td></tr>
</table><p>
since 11 is the base 8 representation of the decimal number 9.
Similarly, if you write <span style="font-family:monospace">0x</span> at the beginning of an integer,
<span style="font-family:monospace">Xcas</span> will regard it as a hexadecimal (base 16)
integer.<a id="hevea_default41"></a> If you enter
</p><blockquote class="quote"><span style="font-family:monospace">0x11
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
17
</td></tr>
</table><p>
since 11 is the base 16 representation of the decimal number 17.</p><p>The symbolic constants that are built in to <span style="font-family:monospace">Xcas</span> are
<span style="font-family:monospace">pi</span>, <span style="font-family:monospace">e</span>, <span style="font-family:monospace">i</span>, <span style="font-family:monospace">infinity</span>,
<span style="font-family:monospace">+infinity</span> and <span style="font-family:monospace">-infinity</span>.
Note that <span style="font-family:monospace">Xcas</span> distinguishes between <span style="font-family:monospace">+infinity</span>,
<span style="font-family:monospace">-infinity</span> and <span style="font-family:monospace">infinity</span>, which is unsigned infinity.
The distinction can be noted in the following calculations:
</p><blockquote class="quote"><span style="font-family:monospace">1/0
</span></blockquote><p>
will result in <span style="font-family:monospace">infinity</span>,
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
∞
</td></tr>
</table><p>
while
</p><blockquote class="quote"><span style="font-family:monospace">(1/0)^2
</span></blockquote><p>
will result in <span style="font-family:monospace">+infinity</span>,
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
+∞
</td></tr>
</table><p>
and
</p><blockquote class="quote"><span style="font-family:monospace">-(1/0)^2
</span></blockquote><p>
will result in <span style="font-family:monospace">-infinity</span>,
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
−∞
</td></tr>
</table><p>
These variables cannot be reassigned; in particular, the variable
<span style="font-family:monospace">i</span> can’t be used as a loop index.</p><p><span style="font-family:monospace">Xcas</span> can handle integers of arbitrary length; if, for
example, you enter
</p><blockquote class="quote"><span style="font-family:monospace">500!
</span></blockquote><p>
you will be given all 1135 digits of the factorial of 500.</p><p>When <span style="font-family:monospace">Xcas</span> combines two numbers, the result will be exact
unless one of the numbers is approximate, in which case the result
will be approximate. For example, entering
</p><blockquote class="quote"><span style="font-family:monospace">3/2 + 1
</span></blockquote><p>
will return the exact value
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">5</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">2</td></tr>
</table></td></tr>
</table><p>
while entering
</p><blockquote class="quote"><span style="font-family:monospace">1.5 + 1
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
2.5
</td></tr>
</table><p>The <span style="font-family:monospace">evalf</span><a id="hevea_default42"></a> function will
transform a number to an approximate value. While entering
</p><blockquote class="quote"><span style="font-family:monospace">sqrt(2)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" >2</td></tr>
</table></td></tr>
</table><p>
entering
</p><blockquote class="quote"><span style="font-family:monospace">evalf(sqrt(2))
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
1.41421356237
</td></tr>
</table><p>
which is the square root of two to the default precision, in this case
12 digits. The <span style="font-family:monospace">evalf</span> function can also take a second
argument which you can use to specify how many digits of precision
that you want; for example if you want to know the square root of two
to 50 digits, you can enter
</p><blockquote class="quote"><span style="font-family:monospace">evalf(sqrt(2),50)
</span></blockquote><p>
and get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
1.4142135623730950488016887242096980785696718753770
</td></tr>
</table><p>The <span style="font-family:monospace">exact</span><a id="hevea_default43"></a> function will turn
an approximate value into a nearby
exact value. Specifically, given an approximate value <span style="font-style:italic">x</span>,
<span style="font-family:monospace">exact(</span><span style="font-style:italic">x</span><span style="font-family:monospace">)</span> will be a rational number <span style="font-style:italic">r</span> with
|<span style="font-style:italic">x</span> − <span style="font-style:italic">r</span>| < є, where є is the value of the variable
<span style="font-family:monospace">epsilon</span>, which has a default value of 10<sup>−12</sup>. This value
is configurable (see section <a href="#config">2.3</a>, “Configuration”).</p>
<!--TOC subsection id="sec16" Variables-->
<h3 id="sec16" class="subsection">3.2  Variables</h3><!--SEC END --><p>
<a id="hevea_default44"></a></p><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Variables</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">:=</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >assignment </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">subst</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >give a variable a value for a single instance</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">assume</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >put assumptions on variables </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">and</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >combine assumptions</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">or</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >combine assumptions</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">purge</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >remove values and assumptions attached to variables </td></tr>
</table>
</div><p>
<a id="hevea_default45"></a>
<a id="hevea_default46"></a>
<a id="hevea_default47"></a>
<a id="hevea_default48"></a>
<a id="hevea_default49"></a>
<a id="hevea_default50"></a></p><p>A variable in <span style="font-family:monospace">Xcas</span> begins with a letter and can contain
letters, numbers and underscores. </p><p>A variable can be given a value with the assignment operator <span style="font-family:monospace">:=</span>.
If you enter
</p><blockquote class="quote"><span style="font-family:monospace">a := 3
</span></blockquote><p>
then <span style="font-family:monospace">a</span> will be replaced by <span style="font-family:monospace">3</span> in all later
calculations. If you later enter
</p><blockquote class="quote"><span style="font-family:monospace">4*a^2
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
36
</td></tr>
</table><p>
The <span style="font-family:monospace">purge</span> command will unassign a variable; if you enter
</p><blockquote class="quote"><span style="font-family:monospace">purge(a)
</span></blockquote><p>
and then
</p><blockquote class="quote"><span style="font-family:monospace">4*a^2
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
4· <span style="font-style:italic">a</span><sup>2</sup>
</td></tr>
</table><p>The assignment operator <span style="font-family:monospace">:=</span> is one of three types of
equalities used in <span style="font-family:monospace">Xcas</span>. They are
</p><ul class="itemize"><li class="li-itemize">
The assignment operator, <span style="font-family:monospace">:=</span>,<a id="hevea_default51"></a>
which is used to assign values.
</li><li class="li-itemize">The Boolean equality, <span style="font-family:monospace">==</span>,<a id="hevea_default52"></a>
which tells you whether two
quantities are equal to each other or not. If you enter
<span style="font-style:italic">A</span><span style="font-family:monospace">==</span><span style="font-style:italic">B</span>, then you will get either
<span style="font-family:monospace">true</span> or <span style="font-family:monospace">false</span> as a result. The predefined
constants <span style="font-family:monospace">true</span> and <span style="font-family:monospace">True</span> are equal to 1, the
predefined constants <span style="font-family:monospace">false</span> and <span style="font-family:monospace">False</span> are equal to 0.
<a id="hevea_default53"></a>
<a id="hevea_default54"></a>
<a id="hevea_default55"></a>
<a id="hevea_default56"></a>
<a id="hevea_default57"></a>
<a id="hevea_default58"></a>
</li><li class="li-itemize">The equal sign <span style="font-family:monospace">=</span><a id="hevea_default59"></a> is used to define an
equation. In this case, the equation will be the expression.
<a id="hevea_default60"></a>
<a id="hevea_default61"></a>
</li></ul><p>If you want to replace a variable by a value for a single expression,
you can use the <span style="font-family:monospace">subst</span> command. This command takes an
expression and an equation <span style="font-style:italic">var</span> <span style="font-family:monospace">=</span> <span style="font-style:italic">value</span> as a
second argument. If <span style="font-family:monospace">a</span> is an unassigned variable, for example, then
entering
</p><blockquote class="quote"><span style="font-family:monospace">subst(a^2 + 2, a=3)
</span></blockquote><p>
will result in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
11
</td></tr>
</table><p>
Afterwards, <span style="font-family:monospace">a</span> will still be unassigned.</p><p>Even without giving a variable a value, you can still tell
<span style="font-family:monospace">Xcas</span> some of its properties with the <span style="font-family:monospace">assume</span> command.
For example, for a real number <span style="font-style:italic">a</span>, the expression √<span style="text-decoration:overline"><span style="font-style:italic">a</span></span><sup><span style="text-decoration:overline">2</span></sup>
simplifies to |<span style="font-style:italic">a</span>|, since <span style="font-style:italic">a</span> could be positive or negative. If you
enter
</p><blockquote class="quote"><span style="font-family:monospace">sqrt(a^2)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
|<span style="font-style:italic">a</span>|
</td></tr>
</table><p>
If you enter
</p><blockquote class="quote"><span style="font-family:monospace">assume(a<0)
</span></blockquote><p>
beforehand, then <span style="font-family:monospace">Xcas</span> will work under the assumption that
<span style="font-family:monospace">a</span> is negative, and so entering
</p><blockquote class="quote"><span style="font-family:monospace">sqrt(a^2)
</span></blockquote><p>
will result in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
−<span style="font-style:italic">a</span>
</td></tr>
</table><p>
As well as assuming that a variable satifies an equation or
inequality, you can use the keywords <span style="font-family:monospace">and</span> and <span style="font-family:monospace">or</span> to
assume that a variable satisifies more than one inequality. Some
assumptions on a variable require a second argument; for example, to
assume that <span style="font-style:italic">a</span> is an integer you can enter
</p><blockquote class="quote"><span style="font-family:monospace">assume(a,integer)
</span></blockquote><p><a id="hevea_default62"></a>
Afterwards
</p><blockquote class="quote"><span style="font-family:monospace">sin(a*pi)
</span></blockquote><p>
will result in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
0
</td></tr>
</table><p>
The <span style="font-family:monospace">purge</span> command will remove any assumptions about a
variable as well as any assigned values.</p>
<!--TOC subsection id="sec17" Expressions-->
<h3 id="sec17" class="subsection">3.3  Expressions</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Conversions</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">expand</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >expand powers and distribute multiplication </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">normal</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >reduce to lowest terms</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">ratnormal</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >reduce to lowest terms</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">factor</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >factor</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">simplify</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >reduce an expression to simpler form</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">tsimplify</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >reduce and expression to simpler form</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">convert</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >convert an expression to a different type</td></tr>
</table>
</div><p>
<a id="hevea_default63"></a>
<a id="hevea_default64"></a>
<a id="hevea_default65"></a>
<a id="hevea_default66"></a>
<a id="hevea_default67"></a>
<a id="hevea_default68"></a>
<a id="hevea_default69"></a></p><p>An expression is a combination of numbers and variables combined by
arithmetic operators. For example, <span style="font-family:monospace">x^2 + 2*x + c</span> is an
expression. </p><p>When you enter an expression, <span style="font-family:monospace">Xcas</span> will perform some
automatic simplifications,<a id="hevea_default70"></a> such as
</p><ul class="itemize"><li class="li-itemize">
Any variables that have been assigned are replaced by their values.
</li><li class="li-itemize">Operations on numbers are performed.
</li><li class="li-itemize">Trivial simplifications, such as <span style="font-style:italic">x</span>+0=<span style="font-style:italic">x</span> and <span style="font-style:italic">x</span>· 0 = 0, are made.
</li><li class="li-itemize">Some trigonometric forms are rewritten; for example, <span style="font-family:monospace">cos(-x)</span> is
replaced by <span style="font-family:monospace">cos(x)</span> and <span style="font-family:monospace">cos(pi/4)</span> is replaced by √<span style="text-decoration:overline">2</span>/2.
</li></ul><p>Other simplifications are not done automatically, since it isn’t
always clear what sort of simplifications the user might want, and
besides non-trivial simplifications are time-consuming.
The most used commands for simplifying and transforming commands are:
</p><dl class="description"><dt class="dt-description">
<span style="font-weight:bold"><span style="font-family:monospace">expand</span></span></dt><dd class="dd-description">
This will expand integer powers and more generally distribute
multiplication across addition. For example, if you enter
<blockquote class="quote"><span style="font-family:monospace">expand((x+1)^3)
</span></blockquote>
you will get
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">x</span><sup>3</sup> + 3*<span style="font-style:italic">x</span><sup>2</sup> + 3*<span style="font-style:italic">x</span> + 1
</td></tr>
</table></dd><dt class="dt-description"><span style="font-weight:bold"><span style="font-family:monospace">normal</span></span><span style="font-weight:bold"> and </span><span style="font-weight:bold"><span style="font-family:monospace">ratnormal</span></span></dt><dd class="dd-description">
These commands will reduce a rational function to lowest terms. For
example, if you enter
<blockquote class="quote"><span style="font-family:monospace">normal((x^3-1)/(x^2-1))
</span></blockquote>
then <span style="font-family:monospace">Xcas</span> will cancel a common factor of <span style="font-style:italic">x</span>−1 from the top
and bottom and return
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>2</sup>+<span style="font-style:italic">x</span>+1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span>+1</td></tr>
</table></td></tr>
</table>
<span style="font-family:monospace">ratnormal</span> will have the same behavior on this expression.
The difference between the two commands is that <span style="font-family:monospace">ratnormal</span>
does not take into account reductions with algebraic numbers, while
<span style="font-family:monospace">normal</span> does. If you enter
<blockquote class="quote"><span style="font-family:monospace">ratnormal((x^2-2)/(x-sqrt(2)))
</span></blockquote>
you will get
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>2</sup>−2</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><table class="display"><tr style="vertical-align:middle"><td class="dcell"><span style="font-style:italic">x</span>−</td><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" >2</td></tr>
</table></td></tr>
</table></td></tr>
</table></td></tr>
</table>
but if you enter
<blockquote class="quote"><span style="font-family:monospace">normal((x^2-2)/(x-sqrt(2)))
</span></blockquote>
you will get
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">x</span>+</td><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" >2</td></tr>
</table></td></tr>
</table><p>Neither of these commands will take into account relationships
between transcendental functions such as <span style="font-family:monospace">sin</span> and <span style="font-family:monospace">cos</span>.</p></dd><dt class="dt-description"><span style="font-weight:bold"><span style="font-family:monospace">factor</span></span></dt><dd class="dd-description">
This will factor polynomials and reduce rational expressions. This
is a little slower than <span style="font-family:monospace">normal</span> and <span style="font-family:monospace">ratnormal</span> and
different in that it will give the result in factored form. For
example, if you enter
<blockquote class="quote"><span style="font-family:monospace">factor(x^2 + 3*x + 2)
</span></blockquote>
you will get
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
(<span style="font-style:italic">x</span> + 1)*(<span style="font-style:italic">x</span> + 2)
</td></tr>
</table></dd><dt class="dt-description"><span style="font-weight:bold"><span style="font-family:monospace">simplify</span></span></dt><dd class="dd-description">
This command will try to reduce an expression to algebraically
independent variables, then it will apply <span style="font-family:monospace">normal</span>.
Simplifications requiring algebraic extensions (such as roots) may
require two calls to <span style="font-family:monospace">simplify</span> and possibly adding some
assumptions with <span style="font-family:monospace">assume</span>. </dd><dt class="dt-description"><span style="font-weight:bold"><span style="font-family:monospace">tsimplify</span></span></dt><dd class="dd-description">
Like <span style="font-family:monospace">simplify</span>, this will try to reduce an expression to
algebraically independent variables, but will not apply
<span style="font-family:monospace">normal</span> afterwards.
</dd></dl><p>The <span style="font-family:monospace">convert</span> command will rewrite expressions to different
formats; the first argument will be the expression and the second
argument will indicate the format to convert the expression to. For
example, you can convert <span style="font-style:italic">e</span><sup><span style="font-style:italic">i</span> θ</sup> to sines and
cosines<a id="hevea_default71"></a> with
</p><blockquote class="quote"><span style="font-family:monospace">convert(exp(i*theta),sincos)
</span></blockquote><p>
the result will be
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
cos(θ) + <span style="font-style:italic">i</span>*sin(θ)
</td></tr>
</table><p>
You can use <span style="font-family:monospace">convert</span> to find the partial fraction
decomposition of a rational expression with a second argument of
<span style="font-family:monospace">partfrac</span>;<a id="hevea_default72"></a>
for example, if you enter
</p><blockquote class="quote"><span style="font-family:monospace">convert((x-1)/(x^2 - x -2), partfrac)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">2</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">(<span style="font-style:italic">x</span>+1)*3</td></tr>
</table></td><td class="dcell"> + </td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">(<span style="font-style:italic">x</span>−2)*3</td></tr>
</table></td></tr>
</table>
<!--TOC subsection id="sec18" Functions-->
<h3 id="sec18" class="subsection">3.4  Functions</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Common functions</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">abs</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >absolute value</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">sign</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >sign (-1,0,+1)</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">max</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >maximum</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">min</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >minimum</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">round</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >round to the nearest integer </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">floor</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >greatest integer less than or equal to</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">frac</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >fractional part</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">ceil</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >least integer greater than or equal to</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">re</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >real part</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">im</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >imaginary part</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">abs</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >absolute value</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">arg</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >argument</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">conj</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >conjugate</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">coordinates</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the coordinates of a point</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">factorial</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >factorial</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">!</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >factorial</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">sqrt</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >square root</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">exp</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >exponential</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">log</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >natural logarithm</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">ln</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >natural logarithm</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">log10</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >logarithm base 10</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">sin</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >sine</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">cos</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >cosine</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">tan</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >tangent</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">cot</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >cotangent</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">asin</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >arcsine</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">acos</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >arccosine</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">atan</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >arctangent</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">sinh</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >hyperbolic sine</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">cosh</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >hyperbolic cosine</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">tanh</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >hyperbolic tangent</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">asinh</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >inverse hyperbolic sine</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">acosh</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >inverse hyperbolic cosine</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">atanh</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >inverse hyperbolic tangent</td></tr>
</table>
</div><p>
<a id="hevea_default73"></a>
<a id="hevea_default74"></a>
<a id="hevea_default75"></a>
<a id="hevea_default76"></a>
<a id="hevea_default77"></a>
<a id="hevea_default78"></a>
<a id="hevea_default79"></a>
<a id="hevea_default80"></a>
<a id="hevea_default81"></a>
<a id="hevea_default82"></a>
<a id="hevea_default83"></a>
<a id="hevea_default84"></a>
<a id="hevea_default85"></a>
<a id="hevea_default86"></a>
<a id="hevea_default87"></a>
<a id="hevea_default88"></a>
<a id="hevea_default89"></a>
<a id="hevea_default90"></a>
<a id="hevea_default91"></a>
<a id="hevea_default92"></a>
<a id="hevea_default93"></a>
<a id="hevea_default94"></a>
<a id="hevea_default95"></a>
<a id="hevea_default96"></a>
<a id="hevea_default97"></a>
<a id="hevea_default98"></a>
<a id="hevea_default99"></a>
<a id="hevea_default100"></a>
<a id="hevea_default101"></a>
<a id="hevea_default102"></a>
<a id="hevea_default103"></a>
<a id="hevea_default104"></a>
<a id="hevea_default105"></a>
<a id="hevea_default106"></a>
<a id="hevea_default107"></a>
<a id="hevea_default108"></a>
<a id="hevea_default109"></a>
<a id="hevea_default110"></a>
<a id="hevea_default111"></a>
<a id="hevea_default112"></a>
<a id="hevea_default113"></a>
<a id="hevea_default114"></a>
<a id="hevea_default115"></a>
<a id="hevea_default116"></a>
<a id="hevea_default117"></a>
<a id="hevea_default118"></a>
<a id="hevea_default119"></a>
<a id="hevea_default120"></a>
<a id="hevea_default121"></a>
<a id="hevea_default122"></a>
<a id="hevea_default123"></a>
<a id="hevea_default124"></a>
<a id="hevea_default125"></a>
<a id="hevea_default126"></a>
<a id="hevea_default127"></a>
<a id="hevea_default128"></a>
<a id="hevea_default129"></a></p><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Create functions</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">:=</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >assign an expression to a function</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">-></span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >define a function</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">unapply</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >turn an expression into a function</td></tr>
</table>
</div><p>
<a id="hevea_default130"></a>
<a id="hevea_default131"></a></p><p><span style="font-family:monospace">Xcas</span> has many built in functions; you can get a complete list
with the help index. You can also define your own functions with the
assignment (<span style="font-family:monospace">:=</span>) operator.
To define a function <span style="font-style:italic">f</span> given by <span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>) = <span style="font-style:italic">x</span>*exp(<span style="font-style:italic">x</span>), for example, you
can enter
</p><blockquote class="quote"><span style="font-family:monospace">f(x) := x*exp(x)
</span></blockquote><p>
Note that in this case the name of the function is <span style="font-style:italic">f</span>; <span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>) is the
value of the function evaluated at <span style="font-style:italic">x</span>. The function is a rule which
takes an input <span style="font-family:monospace">x</span> and returns <span style="font-family:monospace">x*exp(x)</span>. This rule
can be written without giving it a name as <span style="font-family:monospace">x -> x*exp(x)</span>. In
fact, another way you can define the function <span style="font-style:italic">f</span> as above is
</p><blockquote class="quote"><span style="font-family:monospace">f := x ->x*exp(x)
</span></blockquote><p>
In either case, if you enter
</p><blockquote class="quote"><span style="font-family:monospace">f(2)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
2*exp(2)
</td></tr>
</table><p>You can similarly define functions of more than one variable.
For example, to convert polar coordinates to rectangular coordinates,
you could define
</p><blockquote class="quote"><span style="font-family:monospace">p(r,theta) := (r*cos(theta), r*sin(theta))
</span></blockquote><p>
or equivalently
</p><blockquote class="quote"><span style="font-family:monospace">p := (r, theta) -> (r*cos(theta),r*sin(theta))
</span></blockquote><p>The <span style="font-family:monospace">unapply</span> command will transform an expression into a
function. It takes as arguments an expression and a variable, it will
return the function defined by the expression. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">unapply(x*exp(x),x)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">x</span> −><span style="font-style:italic">x</span>*exp(<span style="font-style:italic">x</span>)
</td></tr>
</table><p>
The <span style="font-family:monospace">unapply</span> command will return the function written in terms
of built in functions; for example, for the function <span style="font-style:italic">f</span> defined
above, if you enter
</p><blockquote class="quote"><span style="font-family:monospace">unapply(f(x),x)
</span></blockquote><p>
you will also get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">x</span> −><span style="font-style:italic">x</span>*exp(<span style="font-style:italic">x</span>)
</td></tr>
</table><p>You can define a function in terms of a function that you previously
defined, but it’s probably better to define any new functions in
terms of built-in functions. For example, if you define
</p><blockquote class="quote"><span style="font-family:monospace">f(x) := exp(x)*sin(x)
</span></blockquote><p>
you can define a new function
</p><blockquote class="quote"><span style="font-family:monospace">g(x) := x*f(x)
</span></blockquote><p>
but it might be better to write
</p><blockquote class="quote"><span style="font-family:monospace">g(x) := x*exp(x)*sin(x)
</span></blockquote><p>
Perhaps a better alternative is to use <span style="font-family:monospace">unapply</span>; you can
define <span style="font-family:monospace">g</span> by
<span style="font-family:monospace">g := unapply(x*f(x),x)</span></p><p>In some cases, it will be necessary to use <span style="font-family:monospace">unapply</span> to define
a function. For example (see section <a href="#deriv">4.1</a>, “Derivatives”),
the <span style="font-family:monospace">diff</span> command will
find the derivative of an expression; if you enter
</p><blockquote class="quote"><span style="font-family:monospace">diff(x*sin(x),x)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
sin(<span style="font-style:italic">x</span>) + <span style="font-style:italic">x</span> * cos(<span style="font-style:italic">x</span>)
</td></tr>
</table><p>
However, you cannot simply define a function
<span style="font-family:monospace">g(x) := diff(x*sin(x),x)</span>
if you tried to do this, then evaluating <span style="font-family:monospace">g(0)</span> for example
would give you <span style="font-family:monospace">diff(0*sin(0),0)</span>, which is not what you want.
Instead, you could define <span style="font-family:monospace">g</span> by
</p><blockquote class="quote"><span style="font-family:monospace">g := unapply(diff(x*sin(x),x)
</span></blockquote><p>Another case where you need to use <span style="font-family:monospace">unapply</span> to define a
function is when you have a function of two variables and you want to
use it to define a function of one variable, where the other variable
is a parameter. For example, consider the polar coordinate function
</p><blockquote class="quote"><span style="font-family:monospace">p(r,theta) := (r*cos(theta), r*sin(theta))
</span></blockquote><p>
If you want to use this to define <span style="font-family:monospace">C(r)</span> as a function of
θ for any value of <span style="font-style:italic">r</span>, you cannot simply define it as
</p><blockquote class="quote"><span style="font-family:monospace">C(r) := p(r,theta)
</span></blockquote><p>
Doing this will define <span style="font-family:monospace">C(r)</span> as an expression involving
θ, not a function of θ. Entering
</p><blockquote class="quote"><span style="font-family:monospace">C(1)(pi/4)
</span></blockquote><p>
would be the same as
</p><blockquote class="quote"><span style="font-family:monospace">(cos(theta),sin(theta))(pi/4)
</span></blockquote><p>
which is not what you want. To define <span style="font-family:monospace">C(r)</span>, you
would have to use <span style="font-family:monospace">unapply</span>:
</p><blockquote class="quote"><span style="font-family:monospace">C(r) := unapply(p(r,theta),theta)
</span></blockquote><p>The necessity of using <span style="font-family:monospace">unapply</span> in these cases is because when
you define a function, the right hand side of the assignment is
not evaluated. For example, if you try to define the squaring
function by
</p><blockquote class="quote"><span style="font-family:monospace">sq := x^2
</span></blockquote><blockquote class="quote"><span style="font-family:monospace">f(x) := sq
</span></blockquote><p>
it will not work; if you enter <span style="font-family:monospace">f(5)</span>, for example, it will
get the value <span style="font-family:monospace">sq</span>, which will then be replaced by its value.
You will end up getting <span style="font-family:monospace">x^2</span> and not <span style="font-family:monospace">5^2</span>. You
should either define the function <span style="font-family:monospace">f</span> by
</p><blockquote class="quote"><span style="font-family:monospace">f(x) := x^2
</span></blockquote><p>
or perhaps
</p><blockquote class="quote"><span style="font-family:monospace">f := unapply(sq,x)
</span></blockquote><p>Functions (not just expressions) can be added and multiplied. To
define a function which is the sine function times the exponential,
instead of defining <span style="font-family:monospace">f(x)</span> as the expression
<span style="font-family:monospace">sin(x)*exp(x)</span>, you could simply enter
</p><blockquote class="quote"><span style="font-family:monospace">f := sin*exp
</span></blockquote><p>
Functions can also be composed with the <span style="font-family:monospace">@</span> symbol. For example, if
you define functions <span style="font-family:monospace">f</span> and <span style="font-family:monospace">g</span> by
</p><blockquote class="quote"><span style="font-family:monospace">f(x) := x^2 + 1
</span></blockquote><blockquote class="quote"><span style="font-family:monospace">g(x) := sin(x)
</span></blockquote><p>
then
</p><blockquote class="quote"><span style="font-family:monospace">f @ g
</span></blockquote><p>
will result in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">x</span> −>(sin(<span style="font-style:italic">x</span>))<sup>2</sup> + 1
</td></tr>
</table><p>
You can use the <span style="font-family:monospace">@</span> operator to compose a function with itself;
<span style="font-family:monospace">f@f(x)</span> is the same as <span style="font-family:monospace">f(f(x))</span>, but if you want to
compose a function with itself several times, you can use the
<span style="font-family:monospace">@@</span> operator. Entering <span style="font-family:monospace">f @@ </span><span style="font-style:italic">n</span> for a positive
integer <span style="font-style:italic">n</span> will give you the composition of <span style="font-style:italic">f</span> with itself <span style="font-style:italic">n</span>
times; for example, if you enter
</p><blockquote class="quote"><span style="font-family:monospace">sin @@ 3
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">x</span> −> sin(sin(sin(<span style="font-style:italic">x</span>)))
</td></tr>
</table>
<!--TOC subsection id="sec19" Lists, sequences and sets-->
<h3 id="sec19" class="subsection">3.5  Lists, sequences and sets</h3><!--SEC END --><p>
<a id="lists"></a></p><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Sequences and lists</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">(  )</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >sequence delimiters</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">[  ]</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >list delimiters</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">%{  %}</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >set delimiters</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">NULL</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >empty sequence</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">E$(k=n..m)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >create a sequence</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">seq(E,k=n..m)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >create a sequence</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">[E$(k=n..m)]</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >create a list</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">makelist(f,k,n,m,p)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >create a list</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">append</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >append an element to a list</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">op(li)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >convert a list to a sequence</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">nop(se)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >convert a sequence to a list</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">nops(li)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the number of elements</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">size(li)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the number of elements</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">mid(li)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >extract a subsequence</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">sum</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the sum of the elements</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">product</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the product of the elements</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">cumSum</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the cumulative sums</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">apply(f,li)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >apply a function to the list elements</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">map(li,f)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >apply a function to the list elements</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">map(li,f,matrix)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >apply a function to the elements of a matrix</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">poly2symb</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >convert a polynomial expression to a polynomial
list</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">symb2poly</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >convert a polynomial list to a polynomial
expression</td></tr>
</table>
</div><p>
<a id="hevea_default132"></a>
<a id="hevea_default133"></a>
<a id="hevea_default134"></a>
<a id="hevea_default135"></a>
<a id="hevea_default136"></a>
<a id="hevea_default137"></a>
<a id="hevea_default138"></a>
<a id="hevea_default139"></a>
<a id="hevea_default140"></a>
<a id="hevea_default141"></a>
<a id="hevea_default142"></a>
<a id="hevea_default143"></a>
<a id="hevea_default144"></a>
<a id="hevea_default145"></a>
<a id="hevea_default146"></a>
<a id="hevea_default147"></a>
<a id="hevea_default148"></a>
<a id="hevea_default149"></a>
<a id="hevea_default150"></a></p><p><span style="font-family:monospace">Xcas</span> can combine objects in several different ways.
</p><dl class="description"><dt class="dt-description">
<span style="font-weight:bold">sequences</span></dt><dd class="dd-description"><a id="hevea_default151"></a>
A sequence is simply several items between parentheses, separated by
commas. For example, <span style="font-family:monospace">(1,2,x,4)</span> is a sequence.
(The parentheses can be omitted, but it’s a good idea to use them.)
Sequences are flat, meaning an element in a sequence cannot be
another sequence.
The empty sequence is denoted <span style="font-family:monospace">NULL</span>.
</dd><dt class="dt-description"><span style="font-weight:bold">lists</span></dt><dd class="dd-description"><a id="hevea_default152"></a>
A list consists of several items between square brackets,
separated by commas. For example, <span style="font-family:monospace">[1,2,x,4]</span> is a
list. A list can contain other lists as elements. Matrices, which
will be discussed later, are lists of lists. The empty list is
denoted <span style="font-family:monospace">[]</span>.
</dd><dt class="dt-description"><span style="font-weight:bold">sets</span></dt><dd class="dd-description"><a id="hevea_default153"></a>
A set consists of several items between <span style="font-family:monospace">%{</span> and
<span style="font-family:monospace">%}</span>, separated by commas. For example,
<span style="font-family:monospace">%{1,2,3%}</span> is a set. In a set, order doesn’t matter and
each item only counts once. The sets <span style="font-family:monospace">%{1,2,3%}</span>
<span style="font-family:monospace">%{3,2,1%}</span> and <span style="font-family:monospace">%{1,2,2,3%}</span> are all the same
set.
</dd><dt class="dt-description"><span style="font-weight:bold">tables</span></dt><dd class="dd-description"><a id="hevea_default154"></a>
Tables are described later.
</dd></dl><p>
A sequence can be turned into a list or a set by putting it between
the appropriate delimiters. For example, if you define a sequence
</p><blockquote class="quote"><span style="font-family:monospace">se := (1,2,4,2)
</span></blockquote><p>
then if you enter
</p><blockquote class="quote"><span style="font-family:monospace">[se]
</span></blockquote><p>
you will get the list
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[1,2,4,2]
</td></tr>
</table><p>
You can turn a set or list into a sequence with the <span style="font-family:monospace">op</span>
command; if you define a set
</p><blockquote class="quote"><span style="font-family:monospace">st := %{1,2,3%}
</span></blockquote><p>
and then enter
</p><blockquote class="quote"><span style="font-family:monospace">op(st)
</span></blockquote><p>
you will get the sequence
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
(1,2,3)
</td></tr>
</table><p>
You can find the number of elements in a sequence, list or set with
the <span style="font-family:monospace">size</span> command; with <span style="font-family:monospace">st</span> as above,
</p><blockquote class="quote"><span style="font-family:monospace">size(st)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
3
</td></tr>
</table><p>Sequences can be built using one of the iteration commands
<span style="font-family:monospace">seq</span> or <span style="font-family:monospace">$</span>. The <span style="font-family:monospace">seq</span> command takes an
expression as the first argument, the second argument will be a
variable followed by a range in the form
<span style="font-style:italic">variable</span><span style="font-family:monospace">=</span><span style="font-style:italic">beginning
value</span><span style="font-family:monospace">..</span><span style="font-style:italic">ending value</span>. The resulting sequence will be
the values of the expression with the variable replaced by the
sequence of values. For example,
</p><blockquote class="quote"><span style="font-family:monospace">seq(k^2,k=-2..2)
</span></blockquote><p>
will result in the sequence
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
(4,1,0,1,4)
</td></tr>
</table><p>
The <span style="font-family:monospace">$</span> operator is an infix version of <span style="font-family:monospace">seq</span>. If you
enter
</p><blockquote class="quote"><span style="font-family:monospace">k^2$k=-2..2
</span></blockquote><p>
you will get, as above,
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
(4,1,0,1,4)
</td></tr>
</table><p>A list can be built by putting a sequence in brackets; if you enter
</p><blockquote class="quote"><span style="font-family:monospace">[k^3,k=1..3]
</span></blockquote><p>
you will get the list
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[1,8,27]
</td></tr>
</table><p>
You can also create a list with the <span style="font-family:monospace">makelist</span> command. It
takes three arguments; a function (not an expression), an initial
value for the variable and an ending value for the variable. If you
enter
</p><blockquote class="quote"><span style="font-family:monospace">makelist(x -> x^2,-2,2)
</span></blockquote><p>
you will get the list
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[4,1,0,1,4]
</td></tr>
</table><p>
There is an optional fourth argument, which will be the step size.</p><p>You can add an element to the end of a list with the <span style="font-family:monospace">append</span>
command. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">append([1,5],3)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[1,5,3]
</td></tr>
</table><p>The elements of sequences and lists are indexed, beginning with the
index 0. You can get an element by following the sequence or
list with the index number in square brackets; if you enter
</p><blockquote class="quote"><span style="font-family:monospace">ls := [A,B,C,D,E,F]
</span></blockquote><p>
then
</p><blockquote class="quote"><span style="font-family:monospace">ls[1]
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">B</span>
</td></tr>
</table><p>
You can get a subsequence<a id="hevea_default155"></a> (or sublist<a id="hevea_default156"></a>)
by putting an interval (a
beginning value and an ending values separated by two dots) in brackets.
If you enter
</p><blockquote class="quote"><span style="font-family:monospace">ls[2..4]
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[<span style="font-style:italic">C</span>,<span style="font-style:italic">D</span>,<span style="font-style:italic">E</span>]
</td></tr>
</table><p>The <span style="font-family:monospace">mid</span><a id="hevea_default157"></a><a id="hevea_default158"></a> command is another
way to get a subsequence or sublist.
Given a sequence or list, a beginning index and a length, then
<span style="font-family:monospace">mid</span> will return the subsequence of the sequence beginning at
the given index of the given length. With <span style="font-family:monospace">ls</span> as above, if
you enter
</p><blockquote class="quote"><span style="font-family:monospace">mid(ls,2,3)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[<span style="font-style:italic">C</span>,<span style="font-style:italic">D</span>,<span style="font-style:italic">E</span>]
</td></tr>
</table><p>
If the length is left off, then the subsequence will go to the end of
the given sequence; if you enter
</p><blockquote class="quote"><span style="font-family:monospace">mid(ls,2)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[<span style="font-style:italic">C</span>,<span style="font-style:italic">D</span>,<span style="font-style:italic">E</span>,<span style="font-style:italic">F</span>]
</td></tr>
</table><p>You can change the element in a particular position with the
<span style="font-family:monospace">:=</span> operator; for example, to change the second element in
<span style="font-family:monospace">ls</span>, you can enter
</p><blockquote class="quote"><span style="font-family:monospace">ls[1] := 7
</span></blockquote><p>
The value of <span style="font-family:monospace">ls</span> will then be
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[<span style="font-style:italic">A</span>,7,<span style="font-style:italic">C</span>,<span style="font-style:italic">D</span>,<span style="font-style:italic">E</span>,<span style="font-style:italic">F</span>]
</td></tr>
</table><p>If a variable <span style="font-style:italic">var</span> is not a list or sequence and you assign a
value to <span style="font-style:italic">var</span><span style="font-family:monospace">[</span><span style="font-style:italic">n</span><span style="font-family:monospace">]</span>, then <span style="font-style:italic">var</span> becomes a
table. A table is like a list, but the indices don’t have to be
integers. If you define
</p><blockquote class="quote"><span style="font-family:monospace">newls := []
</span></blockquote><p>
and then set
</p><blockquote class="quote"><span style="font-family:monospace">newls[2] := 5
</span></blockquote><p>
then since <span style="font-family:monospace">newls</span> was previous a list, it will now be equal to
the list
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[0,0,5]
</td></tr>
</table><p>
If <span style="font-family:monospace">nols</span> is an undefined variable and you set
</p><blockquote class="quote"><span style="font-family:monospace">nols[2] := 5
</span></blockquote><p>
then <span style="font-family:monospace">nols</span> will be a table,<a id="hevea_default159"></a>
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-family:monospace">table</span>(2=5)
</td></tr>
</table><p>When changing an element of a list (or sequence or table) using
<span style="font-family:monospace">:=</span>, the entire list is copied. This can be inefficient. To
save copy time and modify the list element in place, you can use
<span style="font-family:monospace">=<</span>. If you have
</p><blockquote class="quote"><span style="font-family:monospace">ls := [a,b,c]
</span></blockquote><p>
and then enter
</p><blockquote class="quote"><span style="font-family:monospace">ls[2] =< 3
</span></blockquote><p>
then <span style="font-family:monospace">ls</span> will be equal to
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[<span style="font-style:italic">a</span>,<span style="font-style:italic">b</span>,3]
</td></tr>
</table><p>Polynomials are typically given by expressions, but they can also be
given by a list of the coefficients in decreasing order, delimited
with <span style="font-family:monospace">poly1[</span> and <span style="font-family:monospace">]</span>. The <span style="font-family:monospace">symb2poly</span> will
transform a polynomial written as an expression to the list form of
the polynomial. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">symb2poly(2*x^3 - 4*x + 1)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
poly1[2,0,−4,1]
</td></tr>
</table><p>
The <span style="font-family:monospace">poly2symb</span> will transform in the other direction; if you
enter
</p><blockquote class="quote"><span style="font-family:monospace">poly2symb(poly1[2,0,-4,1])
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
2*<span style="font-style:italic">x</span><sup>3</sup> − 4*<span style="font-style:italic">x</span> + 1
</td></tr>
</table><p>
There is also a way to represent a multivariable polynomial with
lists; see the manual for more information.</p>
<!--TOC subsection id="sec20" Characters and strings-->
<h3 id="sec20" class="subsection">3.6  Characters and strings</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">String commands</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">asc</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >convert a string to a list of ASCII codes </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">char</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >convert a list of ASCII codes to a string</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">size</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the number of characters </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">concat</span> or <span style="font-family:monospace">+</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >concatenation </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">mid</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >substring</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">head</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >first character </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">tail</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the string without the first character</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">string</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >convert a number or expression to a string </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">expr</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >convert a string to a number or expression </td></tr>
</table>
</div><p>
<a id="hevea_default160"></a>
<a id="hevea_default161"></a>
<a id="hevea_default162"></a>
<a id="hevea_default163"></a>
<a id="hevea_default164"></a>
<a id="hevea_default165"></a>
<a id="hevea_default166"></a>
<a id="hevea_default167"></a>
<a id="hevea_default168"></a></p><p>A string is simply text enclosed within quotation marks.
You can find out how many characters are in a string with the
<span style="font-family:monospace">size</span> command; if you enter
</p><blockquote class="quote"><span style="font-family:monospace">size("this string")
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
11
</td></tr>
</table><p>A character is simply a string with length 1.<a id="hevea_default169"></a>
The <span style="font-family:monospace">char</span>
command will take an ASCII code (or a list of ASCII codes) and return
the character or string determined by the codes. For example, the
letter “a” has ASCII code 65, so
</p><blockquote class="quote"><span style="font-family:monospace">char(65)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">A</span>
</td></tr>
</table><p>
The <span style="font-family:monospace">asc</span> command will turn a string into the list of ASCII
codes; if you enter
</p><blockquote class="quote"><span style="font-family:monospace">asc("A")
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[65]
</td></tr>
</table><p>The characters in a string are indexed starting with <span style="font-family:monospace">0</span>.
To get the first character, for example, you can enter a string, or
the name of a string, followed by <span style="font-family:monospace">[0]</span>. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">str := "abcde"
</span></blockquote><blockquote class="quote"><span style="font-family:monospace">str[0]
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">a</span>
</td></tr>
</table><p>
You can choose a substring from a string by putting the beginning and
ending indices in the brackets, separated by two periods <span style="font-family:monospace">..</span>.
If you enter
</p><blockquote class="quote"><span style="font-family:monospace">str[1..3]
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">bcd</span>
</td></tr>
</table><p>An alternate way of getting the first character from a string is with
the <span style="font-family:monospace">head</span> command. With <span style="font-family:monospace">str</span> as above,
</p><blockquote class="quote"><span style="font-family:monospace">head(str)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">a</span>
</td></tr>
</table><p>
The <span style="font-family:monospace">tail</span> command will produce the remaining characters;
</p><blockquote class="quote"><span style="font-family:monospace">tail(str)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">bcde</span>
</td></tr>
</table><p>Strings can be combined with the <span style="font-family:monospace">concat</span> command or the infix
<span style="font-family:monospace">+</span> operator. Both
</p><blockquote class="quote"><span style="font-family:monospace">concat("abc","def")
</span></blockquote><p>
and
</p><blockquote class="quote"><span style="font-family:monospace">"abc" + "def"
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">abcdef</span>
</td></tr>
</table><p>If a string represents a number, then the <span style="font-family:monospace">expr</span> command will
convert the string to the number. For example,
</p><blockquote class="quote"><span style="font-family:monospace">expr("123")
</span></blockquote><p>
will return the number 123. More generally, <span style="font-family:monospace">expr</span> will
convert a string representing an expression or command into the
corresponding expression or command. The <span style="font-family:monospace">string</span> command
works in the opposite direction; it will take an expression and
convert it to a string.</p>
<!--TOC subsection id="sec21" Calculation time and memory space-->
<h3 id="sec21" class="subsection">3.7  Calculation time and memory space</h3><!--SEC END --><p>One major issue with symbolic calculations is the complexity of the
intermediate calculations. This complexity takes the form of the
amount of time required for the calculations and the amount of
computer memory needed. The algorithms used by <span style="font-family:monospace">Xcas</span> are
efficient, but not necessarily optimal. The <span style="font-family:monospace">time</span> command
will tell you how long a calculation takes. For very quick
calculations, <span style="font-family:monospace">Xcas</span> will execute it several times and return
the average for a more accurate result. The amount of memory used by
<span style="font-family:monospace">Xcas</span> is shown in the status line of the Unix version of
<span style="font-family:monospace">Xcas</span>. </p><p>If a command that you are timing takes more than a few seconds, you
could have made an input error and you may have to interrupt the
command (with the red <span style="font-family:monospace">STOP</span> button on the status line, for
example). It is a good idea to make a backup of your session beforehand.</p>
<!--TOC section id="sec22" Analysis with <span style="font-family:monospace">Xcas</span>-->
<h2 id="sec22" class="section">4  Analysis with <span style="font-family:monospace">Xcas</span></h2><!--SEC END -->
<!--TOC subsection id="sec23" Derivatives-->
<h3 id="sec23" class="subsection">4.1  Derivatives</h3><!--SEC END --><p>
<a id="deriv"></a></p><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Derivatives</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">diff(ex,t)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the derivative of an expression with respect to t</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">function_diff(f)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the derivative of a function</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">diff(ex,x$n,y$m)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >partial derivatives</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">grad</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >gradient</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">divergence</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >divergence</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">curl</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >curl</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">laplacian</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >laplacian</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">hessian</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >hessian matrix</td></tr>
</table>
</div><p>
<a id="hevea_default170"></a>
<a id="hevea_default171"></a>
<a id="hevea_default172"></a>
<a id="hevea_default173"></a>
<a id="hevea_default174"></a>
<a id="hevea_default175"></a>
<a id="hevea_default176"></a>
<a id="hevea_default177"></a>
<a id="hevea_default178"></a>
<a id="hevea_default179"></a></p><p>The <span style="font-family:monospace">diff</span> function will find the derivative of an expression
and returns the derivative as an expression. If you have a function
<span style="font-style:italic">f</span>, you can find the derivative by entering
</p><blockquote class="quote"><span style="font-family:monospace">diff(f(x),x)
</span></blockquote><p>
Note that the result will itself be an expression; do not define the
deritivave function by <span style="font-family:monospace">fprime(x) := diff(f(x),x)</span>. If you
want to define the derivative as a function, you can use
<span style="font-family:monospace">unapply</span>:<a id="hevea_default180"></a>
</p><blockquote class="quote"><span style="font-family:monospace">fprime := unapply(diff(f(x),x),x)
</span></blockquote><p>
Alternatively, you can use <span style="font-family:monospace">function_diff</span>, which takes a
function (not an expression) as input and returns the derivative
function;
</p><blockquote class="quote"><span style="font-family:monospace">fprime := function_diff(f)
</span></blockquote><p>The <span style="font-family:monospace">diff</span> function can take a sequence of variables as the
second argument, and so can calculate successive partial derivatives.
Given
</p><blockquote class="quote"><span style="font-family:monospace">E := sin(x*y)
</span></blockquote><p>
then
</p><blockquote class="quote"><span style="font-family:monospace">diff(E,x)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">y</span>*cos(<span style="font-style:italic">x</span>*<span style="font-style:italic">y</span>)
</td></tr>
</table><blockquote class="quote"><span style="font-family:monospace">diff(E,y)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">x</span>*cos(<span style="font-style:italic">x</span>*<span style="font-style:italic">y</span>)
</td></tr>
</table><blockquote class="quote"><span style="font-family:monospace">diff(E,x,y)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
−<span style="font-style:italic">x</span>*<span style="font-style:italic">y</span>*sin(<span style="font-style:italic">x</span>*<span style="font-style:italic">y</span>) + cos(<span style="font-style:italic">x</span>*<span style="font-style:italic">y</span>)
</td></tr>
</table><p>
and
</p><blockquote class="quote"><span style="font-family:monospace">diff(E,x $ 2)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
−<span style="font-style:italic">y</span><sup>2</sup>*sin(<span style="font-style:italic">x</span>*<span style="font-style:italic">y</span>)
</td></tr>
</table><p>If the second argument to <span style="font-family:monospace">diff</span> is a list, then a list of
derivatives is returned. For example, to find the gradient of
<span style="font-family:monospace">E</span>, you can enter
</p><blockquote class="quote"><span style="font-family:monospace">diff(E,[x,y])
</span></blockquote><p>
and get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[<span style="font-style:italic">y</span>*cos(<span style="font-style:italic">x</span>*<span style="font-style:italic">y</span>),<span style="font-style:italic">x</span>*cos(<span style="font-style:italic">x</span>*<span style="font-style:italic">y</span>)]
</td></tr>
</table><p>
There is also a special <span style="font-family:monospace">grad</span> command for this, as well as
commands for other types of special derivatives.</p>
<!--TOC subsection id="sec24" Limits and series-->
<h3 id="sec24" class="subsection">4.2  Limits and series</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Limits and series</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">limit</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the limit of an expression</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">taylor</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >Taylor series</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">series</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >Taylor series</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">order_size</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >used in the remainder term of a series expansion</td></tr>
</table>
</div><p>
<a id="hevea_default181"></a>
<a id="hevea_default182"></a>
<a id="hevea_default183"></a>
<a id="hevea_default184"></a>
<a id="hevea_default185"></a></p><p>The <span style="font-family:monospace">limit</span> function will take an expression, a variable and a
point and return the limit at the point. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">limit(sin(x)/x,x,0)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
1
</td></tr>
</table><p>
<span style="font-family:monospace">Xcas</span> can also find limits at plus and minus infinity;
</p><blockquote class="quote"><span style="font-family:monospace">limit(sin(x)/x,x,+infinity)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
0
</td></tr>
</table><p>
as well as limits of infinity;
</p><blockquote class="quote"><span style="font-family:monospace">limit(1/x,x,0)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
∞
</td></tr>
</table><p>
which recall is unsigned infinity.
An optional fourth argument can be used to find one-sided limits; if
the fourth argument is <span style="font-family:monospace">1</span> it will be a right-handed limit and
if the argument is <span style="font-family:monospace">-1</span> it will be a left-handed limit.
Entering
</p><blockquote class="quote"><span style="font-family:monospace">limit(1/x,x,0,-1)
</span></blockquote><p>
will result in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
−∞
</td></tr>
</table><p>Given an expression and a variable, the <span style="font-family:monospace">taylor</span> function will
find the Taylor series of the expression. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">taylor(sin(x)/x,x)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
1−</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>2</sup></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">6</td></tr>
</table></td><td class="dcell"> + </td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>4</sup></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">120</td></tr>
</table></td><td class="dcell"> + <span style="font-style:italic">x</span><sup>6</sup>*<span style="font-family:monospace">order_size</span>(<span style="font-style:italic">x</span>)
</td></tr>
</table><p>
The <span style="font-family:monospace">series</span> function works the same as the <span style="font-family:monospace">taylor</span>
function.</p><p>By default, <span style="font-family:monospace">taylor</span> will find the terms up to the fifth
degree. The <span style="font-family:monospace">order_size(x)</span> represents a factor for which
for all <span style="font-style:italic">a</span>>0, the term <span style="font-style:italic">x</span><sup><span style="font-style:italic">a</span></sup><span style="font-family:monospace">order_size</span>(<span style="font-style:italic">x</span>) will approach 0
as <span style="font-style:italic">x</span> approaches 0. </p><p>The series returned by <span style="font-family:monospace">taylor</span> will also
be centered about 0 by default; if you want to center it around the number
<span style="font-family:monospace">a</span>, you can replace <span style="font-family:monospace">x</span> by <span style="font-family:monospace">x=a</span>;
</p><blockquote class="quote"><span style="font-family:monospace">taylor(exp(x),x=1)
</span></blockquote><p>
will result in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
exp(1)+exp(1)*(<span style="font-style:italic">x</span>−1)+exp(1)*(<span style="font-style:italic">x</span>−1)<sup>2</sup>/2+ exp(1)*(<span style="font-style:italic">x</span>−1)<sup>3</sup>/6+
</td></tr>
</table><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
exp(1)*(<span style="font-style:italic">x</span>−1)<sup>4</sup>/24+exp(1)*(<span style="font-style:italic">x</span>−1)<sup>5</sup>/120+(<span style="font-style:italic">x</span>−1)<sup>6</sup>*<span style="font-family:monospace">order_size</span>(<span style="font-style:italic">x</span>−1)
</td></tr>
</table><p>
You can also give the center of the series with a third argument.
To find the terms to a different you can add an extra argument
giving the order;
</p><blockquote class="quote"><span style="font-family:monospace">taylor(sin(x)/x,x=0,3)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
1−</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>2</sup></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">6</td></tr>
</table></td><td class="dcell"> + <span style="font-style:italic">x</span><sup>4</sup>*<span style="font-family:monospace">order_size</span>(<span style="font-style:italic">x</span>)
</td></tr>
</table><p>
Note that in this case you must explicitly give the center of the
series, even if it is 0.</p><p>To find the Taylor polynomial, you can add an extra argument of
<span style="font-family:monospace">polynom</span>;
</p><blockquote class="quote"><span style="font-family:monospace">taylor(sin(x)/x,x,polynom)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
1−</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>2</sup></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">6</td></tr>
</table></td><td class="dcell"> + </td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>4</sup></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">120</td></tr>
</table></td></tr>
</table>
<!--TOC subsection id="sec25" Antiderivatives and integrals-->
<h3 id="sec25" class="subsection">4.3  Antiderivatives and integrals</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Integrals</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">int</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >antiderivatives and exact integrals</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">romberg</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >approximation of integrals</td></tr>
</table>
</div><p>
<a id="hevea_default186"></a>
<a id="hevea_default187"></a>
<a id="hevea_default188"></a>
<a id="hevea_default189"></a></p><p>The <span style="font-family:monospace">int</span> function will find an antiderivative of an
expression. By default, it will assume that the variable is <span style="font-style:italic">x</span>, to
use another variable you can give it as an argument.
</p><blockquote class="quote"><span style="font-family:monospace">int(x*sin(x))
</span></blockquote><p>
will result in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
sin(<span style="font-style:italic">x</span>) − <span style="font-style:italic">x</span>*cos(<span style="font-style:italic">x</span>)
</td></tr>
</table><p>
and
</p><blockquote class="quote"><span style="font-family:monospace">int(t*sin(t),t)
</span></blockquote><p>
will result in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
sin(<span style="font-style:italic">t</span>) − <span style="font-style:italic">t</span>*cos(<span style="font-style:italic">t</span>)
</td></tr>
</table><p>To compute a definite integral, you can give the limits of integration
as arguments after the variable; to integrate <span style="font-style:italic">x</span>*sin(<span style="font-style:italic">x</span>) from <span style="font-style:italic">x</span>=0 to
<span style="font-style:italic">x</span>=π, you can enter
</p><blockquote class="quote"><span style="font-family:monospace">int(x*sin(x),x,0,pi)
</span></blockquote><p>
and get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
π
</td></tr>
</table><p>
The limits of integration are allowed to be expressions; this can be
useful when computing a multiple integral over a non-rectangular
region. For example, you can integrate <span style="font-style:italic">x</span> <span style="font-style:italic">y</span> over the triangle 0 ≤
<span style="font-style:italic">x</span> ≤ 1, 0 ≤ <span style="font-style:italic">y</span> ≤ <span style="font-style:italic">x</span> with
</p><blockquote class="quote"><span style="font-family:monospace">int(int(x*y,y,0,x),x,0,1)
</span></blockquote><p>
resulting in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">8</td></tr>
</table></td></tr>
</table><p>The <span style="font-family:monospace">romberg</span> function will approximate the value of a definite
integral, for cases when the exact value can’t be computed or you
don’t want to compute it. For example,
</p><blockquote class="quote"><span style="font-family:monospace">romberg(exp(-x^2),x,0,10)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
0.886226925452
</td></tr>
</table>
<!--TOC subsection id="sec26" Solving equations-->
<h3 id="sec26" class="subsection">4.4  Solving equations</h3><!--SEC END --><p>
<a id="solve"></a></p><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Solving equations</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">solve(eq,x)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >exact solutions of an equation</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">solve([eq1,eq2],[x,y])</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >exact solutions of a system of equations</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">fsolve(eq,x)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >approximate solution of an equation</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">fsolve([eq1,eq2],[x,y])</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >approximate solution of a system of equations</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">linsolve</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >solve a linear system</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">proot</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >approximate roots of a polynomial</td></tr>
</table>
</div><p>
<a id="hevea_default190"></a>
<a id="hevea_default191"></a>
<a id="hevea_default192"></a>
<a id="hevea_default193"></a></p><p>Solving equations is important, but it is often impossible to find
exact solutions. <span style="font-family:monospace">Xcas</span> has the ability to find exact
solutions in some cases and to approximate solutions.</p><p>The <span style="font-family:monospace">solve</span> function will attempt to find the exact solution of
an equation that you give it. If you enter an expression that isn’t
an equation, it will try to solve for the expression equal to zero.
By default, the variable will be <span style="font-style:italic">x</span>, but you can give a different
variable as a second argument. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">solve(x^3 -2*x^2 + 1=0, x)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell">⎡<br>
⎢<br>
⎢<br>
⎣</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><table class="display"><tr style="vertical-align:middle"><td class="dcell">−(</td><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" >5</td></tr>
</table></td><td class="dcell">)+1</td></tr>
</table></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">2</td></tr>
</table></td><td class="dcell">,1,</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><table class="display"><tr style="vertical-align:middle"><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" >5</td></tr>
</table></td><td class="dcell">+1</td></tr>
</table></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">2</td></tr>
</table></td><td class="dcell">⎤<br>
⎥<br>
⎥<br>
⎦</td></tr>
</table><p>
By default, <span style="font-family:monospace">solve</span> will only try to find real solutions; if
you enter
</p><blockquote class="quote"><span style="font-family:monospace">solve(x^3+1=0,x)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[−1]
</td></tr>
</table><p>
You can configure <span style="font-family:monospace">Xcas</span> to find complex solutions (see
section <a href="#config">2.3</a>, “Configuration”). If you do that,
then entering
</p><blockquote class="quote"><span style="font-family:monospace">solve(x^3+1=0,x)
</span></blockquote><p>
will result in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell">⎡<br>
⎢<br>
⎢<br>
⎣</td><td class="dcell">−1,</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><table class="display"><tr style="vertical-align:middle"><td class="dcell">−</td><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" >3</td></tr>
</table></td><td class="dcell">*<span style="font-style:italic">i</span>+1</td></tr>
</table></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">2</td></tr>
</table></td><td class="dcell">,</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><table class="display"><tr style="vertical-align:middle"><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" >3</td></tr>
</table></td><td class="dcell">*<span style="font-style:italic">i</span>+1</td></tr>
</table></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">2</td></tr>
</table></td><td class="dcell">⎤<br>
⎥<br>
⎥<br>
⎦</td></tr>
</table><p>For linear and quadratic functions, <span style="font-family:monospace">solve</span> will always return
the exact solution. For higher degree polynomials, <span style="font-family:monospace">solve</span>
will try some approaches, but may return intermediate results or
approximate solutions. (It doesn’t use the Cardan and Ferrari
formulas for polynomials of degrees 3 and 4, since the solutions would
then not be easily managable.)</p><p>For trigonometric equations, the primary solutions are returned. For
example,
</p><blockquote class="quote"><span style="font-family:monospace">solve(cos(x) + sin(x) = 0, x)
</span></blockquote><p>
will result in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell">⎡<br>
⎢<br>
⎢<br>
⎣</td><td class="dcell">−</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">π</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">4</td></tr>
</table></td><td class="dcell">,</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">3*π</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">4</td></tr>
</table></td><td class="dcell">⎤<br>
⎥<br>
⎥<br>
⎦</td></tr>
</table><p>
You can configure <span style="font-family:monospace">Xcas</span> to find all solutions (see section
<a href="#config">2.3</a>, “Configuration”). If you do that, then
</p><blockquote class="quote"><span style="font-family:monospace">solve(cos(x) + sin(x) = 0, x)
</span></blockquote><p>
will result in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell">⎡<br>
⎢<br>
⎢<br>
⎣</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">4*<span style="font-style:italic">n</span><sub>0</sub>*π−π</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">4</td></tr>
</table></td><td class="dcell">⎤<br>
⎥<br>
⎥<br>
⎦</td></tr>
</table><p>
where <span style="font-style:italic">n</span><sub>0</sub> represents an arbitrary integer.</p><p>The <span style="font-family:monospace">solve</span> function can also handle systems of equations.
For this, use a list of equations for the first argument and a list of
variables for the second. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">solve([x^2 + y - 2, x + y^2 - 2],[x,y])
</span></blockquote><p>
you will get all four solutions as a matrix; each row represents one
solution.
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell">⎡<br>
⎢<br>
⎢<br>
⎢<br>
⎢<br>
⎢<br>
⎢<br>
⎢<br>
⎢<br>
⎢<br>
⎢<br>
⎢<br>
⎢<br>
⎢<br>
⎢<br>
⎢<br>
⎣</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >1,</td><td style="text-align:center;white-space:nowrap" >1</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >−2,</td><td style="text-align:center;white-space:nowrap" >−2</td></tr>
<tr><td style="text-align:center;white-space:nowrap" ><table class="display"><tr style="vertical-align:middle"><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><table class="display"><tr style="vertical-align:middle"><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" >5</td></tr>
</table></td><td class="dcell">+1</td></tr>
</table></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">2</td></tr>
</table></td><td class="dcell">,</td></tr>
</table></td><td style="text-align:center;white-space:nowrap" ><table class="display"><tr style="vertical-align:middle"><td class="dcell">−</td><td class="dcell">⎛<br>
⎜<br>
⎜<br>
⎝</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><table class="display"><tr style="vertical-align:middle"><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" >5</td></tr>
</table></td><td class="dcell">+1</td></tr>
</table></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">2</td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎟<br>
⎠</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:left">2</td></tr>
<tr><td class="dcell" style="text-align:left"><br>
<br>
<br>
</td></tr>
<tr><td class="dcell" style="text-align:left"> </td></tr>
</table></td><td class="dcell"> + 2</td></tr>
</table></td></tr>
<tr><td style="text-align:center;white-space:nowrap" ><table class="display"><tr style="vertical-align:middle"><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><table class="display"><tr style="vertical-align:middle"><td class="dcell">−(</td><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" >5</td></tr>
</table></td><td class="dcell">)+1</td></tr>
</table></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">2</td></tr>
</table></td><td class="dcell">,</td></tr>
</table></td><td style="text-align:center;white-space:nowrap" ><table class="display"><tr style="vertical-align:middle"><td class="dcell">−</td><td class="dcell">⎛<br>
⎜<br>
⎜<br>
⎝</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><table class="display"><tr style="vertical-align:middle"><td class="dcell">−(</td><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" >5</td></tr>
</table></td><td class="dcell">)+1</td></tr>
</table></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">2</td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎟<br>
⎠</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:left">2</td></tr>
<tr><td class="dcell" style="text-align:left"><br>
<br>
<br>
</td></tr>
<tr><td class="dcell" style="text-align:left"> </td></tr>
</table></td><td class="dcell"> + 2
</td></tr>
</table></td></tr>
</table></td><td class="dcell">⎤<br>
⎥<br>
⎥<br>
⎥<br>
⎥<br>
⎥<br>
⎥<br>
⎥<br>
⎥<br>
⎥<br>
⎥<br>
⎥<br>
⎥<br>
⎥<br>
⎥<br>
⎥<br>
⎦</td></tr>
</table><p>To approximate a solution to an equation or system of equations,
<span style="font-family:monospace">Xcas</span> provides the <span style="font-family:monospace">fsolve</span> command. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">fsolve(x^3 -3*x + 1,x)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[−1.87938524157,0.347296355334,1.53208888624]
</td></tr>
</table><p>
Algorithms for approximating solutions of equations
typically involve starting with a given point and finding a sequence
which converges to a solution. The <span style="font-family:monospace">fsolve</span> command can take
a starting point, if you enter
</p><blockquote class="quote"><span style="font-family:monospace">fsolve(x^3 -3*x + 1,x,1)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
0.347296355334
</td></tr>
</table>
<!--TOC subsection id="sec27" Differential equations-->
<h3 id="sec27" class="subsection">4.5  Differential equations</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Commands for differential equations</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">desolve</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >exact solution</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">odesolve</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >approximate solution</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">plotode</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >graph of solution</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">plotfield</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >vector field</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">interactive_plotode</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >clickable interface</td></tr>
</table>
</div><p>
<a id="hevea_default194"></a>
<a id="hevea_default195"></a>
<a id="hevea_default196"></a>
<a id="hevea_default197"></a>
<a id="hevea_default198"></a></p><p>The <span style="font-family:monospace">desolve</span> command is used to try to find exact solutions of
differential equations. The first argument is the differential
equation itself, the second argument is the function. The derivative
of an unknown function <span style="font-style:italic">y</span> is denoted <span style="font-family:monospace">diff(y)</span>, which can be
abbreviated <span style="font-family:monospace">y’</span>. The second derivative will be
<span style="font-family:monospace">diff(diff(y))</span> or <span style="font-family:monospace">y’’</span>, etc.
If you enter
</p><blockquote class="quote"><span style="font-family:monospace">desolve(x^2*y’ = y,y)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">c</span><sub>0</sub> * exp(−</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span></td></tr>
</table></td><td class="dcell">)
</td></tr>
</table><p>
where <span style="font-style:italic">c</span><sub>0</sub> is an arbitrary constant. By default the variable is <span style="font-style:italic">x</span>,
if you want to use a different variable, put it in the function in the
second argument;
</p><blockquote class="quote"><span style="font-family:monospace">desolve(t^2*y’ = y,y(t))
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">c</span><sub>0</sub> * exp(−</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">t</span></td></tr>
</table></td><td class="dcell">)
</td></tr>
</table><p>If you want to solve a differential equation with initial conditions,
the first argument should be a list with the differential equation and
the conditions. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">desolve([y’’ + 2*y’ + y = 0, y(0) = 1, y’(0) = 2],y)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
exp(−<span style="font-style:italic">x</span>)*(3*<span style="font-style:italic">x</span>+1)
</td></tr>
</table><p>To solve a differential equation numerically, you can use the
<span style="font-family:monospace">odesolve</span> command. This will allow you to solve the equation
<span style="font-style:italic">y</span>′=<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>,<span style="font-style:italic">y</span>) where the graph passes through a point (<span style="font-style:italic">x</span><sub>0</sub>,<span style="font-style:italic">y</span><sub>0</sub>). The
command
</p><blockquote class="quote"><span style="font-family:monospace">odesolve(f(x,y),[x,y],[x_0,y_0],a)
</span></blockquote><p>
will find <span style="font-style:italic">y</span>(<span style="font-style:italic">a</span>) in this case. For example, to calculate <span style="font-style:italic">y</span>(2) where
<span style="font-style:italic">y</span>(<span style="font-style:italic">x</span>) is the solution of <span style="font-style:italic">y</span>′(<span style="font-style:italic">x</span>) =sin(<span style="font-style:italic">xy</span>) with <span style="font-style:italic">y</span>(0)=1, you can
enter
</p><blockquote class="quote"><span style="font-family:monospace">odesolve(sin(x*y),[x,y],[0,1],2)
</span></blockquote><p>
The result will be
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[1.82241255674]
</td></tr>
</table><p>
The <span style="font-family:monospace">plotode</span> command will plot the graph of the solution; if
you enter
</p><blockquote class="quote"><span style="font-family:monospace">plotode(sin(x*y),[x,y],[0,1])
</span></blockquote><p>
you will get
</p><div class="center">
<img src="tutoriel006.png">
</div><p>
The <span style="font-family:monospace">plotfield</span> command will plot the entire vector field;
</p><blockquote class="quote"><span style="font-family:monospace">plotfield(sin(x*y),[x,y])
</span></blockquote><p>
will result in
</p><div class="center">
<img src="tutoriel007.png">
</div><p>
If you use the <span style="font-family:monospace">interactive_odeplot</span> command, you will get the
vector field and you will be able to click on a point to find the
graph of the solution passing through the point.</p>
<!--TOC section id="sec28" Algebra with <span style="font-family:monospace">Xcas</span>-->
<h2 id="sec28" class="section">5  Algebra with <span style="font-family:monospace">Xcas</span></h2><!--SEC END -->
<!--TOC subsection id="sec29" Integer arithmetic-->
<h3 id="sec29" class="subsection">5.1  Integer arithmetic</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Integers</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">irem</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >remainder</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">iquo</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >quotient</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">iquorem</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >quotient and remainder</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">ifactor</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >prime factorization</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">ifactors</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >list of prime factors</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">idivis</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >list of divisors</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">gcd</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >greatest common divisor</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">lcm</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >least common multiple</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">iegcd</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >Bezout’s identity</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">isprime</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >primality test</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">nextprime</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >next prime number</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">previousprime</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >previous prime number</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">a%p</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-style:italic">a</span> modulo <span style="font-style:italic">p</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">powmod(a,n,p)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-style:italic">a</span><sup><span style="font-style:italic">n</span></sup> modulo <span style="font-style:italic">p</span></td></tr>
</table>
</div><p>
<a id="hevea_default199"></a>
<a id="hevea_default200"></a>
<a id="hevea_default201"></a>
<a id="hevea_default202"></a>
<a id="hevea_default203"></a>
<a id="hevea_default204"></a>
<a id="hevea_default205"></a>
<a id="hevea_default206"></a>
<a id="hevea_default207"></a>
<a id="hevea_default208"></a>
<a id="hevea_default209"></a>
<a id="hevea_default210"></a>
<a id="hevea_default211"></a>
<a id="hevea_default212"></a>
<a id="hevea_default213"></a>
<a id="hevea_default214"></a>
<a id="hevea_default215"></a>
<a id="hevea_default216"></a></p><p><span style="font-family:monospace">Xcas</span> has the usual number theoretic functions. The
<span style="font-family:monospace">iquo</span> command will find the integer quotient of two integers
and <span style="font-family:monospace">irem</span> will find the remainder. The <span style="font-family:monospace">iquorem</span>
command will return a list of both the quotient and remainder; if you
enter
</p><blockquote class="quote"><span style="font-family:monospace">iquorem(30,7)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[4,2]
</td></tr>
</table><p>
since 30 divided by 7 is 4 with a remainder of 2.</p><p>The <span style="font-family:monospace">gcd</span> and <span style="font-family:monospace">lcm</span> commands will find the greatest
common divisor and least common multiple of two integers. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">gcd(72,120)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
24
</td></tr>
</table><p>
The greatest common divisor <span style="font-style:italic">d</span> of two integers <span style="font-style:italic">a</span> and <span style="font-style:italic">b</span> can always be
written in the form <span style="font-style:italic">a</span>*<span style="font-style:italic">u</span> + <span style="font-style:italic">b</span>*<span style="font-style:italic">v</span> = <span style="font-style:italic">d</span> for integers <span style="font-style:italic">u</span> and <span style="font-style:italic">v</span>. (This
is known as Bézout’s Identity.) The <span style="font-family:monospace">iegcd</span> will
return the coefficients <span style="font-style:italic">u</span> and <span style="font-style:italic">v</span> as well as the greatest commond
divisor. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">iegcd(72,120)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[2,−1,24]
</td></tr>
</table><p>
since
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">72· 2 + 120·(−1) = 24</td></tr>
</table><p>The <span style="font-family:monospace">ifactor</span> command will give the prime factorization of an
integer; if you enter
</p><blockquote class="quote"><span style="font-family:monospace">ifactor(250)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
2*5<sup>3</sup>
</td></tr>
</table><p>
You can use <span style="font-family:monospace">ifactors</span> to get a list of the prime factors of an
integer, where in the list each factor is followed by its multiplicity.
If you enter
</p><blockquote class="quote"><span style="font-family:monospace">ifactors(250)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[2,1,5,3]
</td></tr>
</table><p>
since 250 has a prime factor of 2 (it has 1 factor of 2) and a
prime factor of 5 (it has 3 factors of 5).
The <span style="font-family:monospace">idivis</span> command will return a complete list of factors;
</p><blockquote class="quote"><span style="font-family:monospace">idivis(250)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[1,2,5,10,25,50,125,250]
</td></tr>
</table><p>The subject of primes is a difficult one, and you should see the
manual for a discussion of how <span style="font-family:monospace">Xcas</span> checks for primes. But
the command <span style="font-family:monospace">isprime</span> will return <span style="font-family:monospace">true</span> or <span style="font-family:monospace">false</span>
depending on whether or not you enter a prime. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">isprime(37)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">true</span>
</td></tr>
</table><p>
since 37 is a prime number. The commands <span style="font-family:monospace">nextprime</span> and
<span style="font-family:monospace">previousprime</span> will find the first prime after (or before) the
number that you give it; if you enter
</p><blockquote class="quote"><span style="font-family:monospace">nextprime(37)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
41
</td></tr>
</table><p>
since the first prime after 37 is 41.</p><p>Integers modulo <span style="font-style:italic">p</span> are defined by putting <span style="font-family:monospace">% p</span> after them.
Once an integer modulo <span style="font-style:italic">p</span> is defined, then any calculations done with
it are done in ℤ/<span style="font-style:italic">p</span>ℤ. For example, if you define
</p><blockquote class="quote"><span style="font-family:monospace">a := 3 % 5
</span></blockquote><p>
then
</p><blockquote class="quote"><span style="font-family:monospace">a*2
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
1 % 5
</td></tr>
</table><p>
(since 6 mod 5 is reduced to 1 mod 5);
</p><blockquote class="quote"><span style="font-family:monospace">1/a
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
2 % 5
</td></tr>
</table><p>
etc. The <span style="font-family:monospace">powermod</span> or <span style="font-family:monospace">powmod</span> functions can be used
to efficiently calculate powers modulo a number.</p>
<!--TOC subsection id="sec30" Polynomials and rational functions-->
<h3 id="sec30" class="subsection">5.2  Polynomials and rational functions</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Polynomials</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">normal</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >normal form (expanded and reduced)</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">expand</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >expanded form</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">ptayl</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >Taylor form</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">peval</span> or <span style="font-family:monospace">horner</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >evaluation using Horner’s method</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">canonical_form</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >canonical form for a trinomial</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">coeff</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >list of coefficients</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">poly2symb</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >transform an algebraic polynomial to list form</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">symb2poly</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >transform the list form of a polynomial to
algebraic form</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">pcoeff</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >return the polynomial (list form) given a list of zeroes</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">degree</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >degree</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">lcoeff</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the coefficient of the leading term</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">valuation</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the lowest degree of the terms</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">tcoeff</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the coefficient of the term with the lowest degree</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">factor</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >prime factorization</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">factors</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >list of prime factors</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">divis</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >list of divisors</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">froot</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >roots with multiplicities</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">proot</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >approximate values of the roots</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">sturmab</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the number of roots in an interval</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">getNum</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the numerator of a rational function</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">getDenom</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >the denominator of a rational function</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">propfrac</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >writes a rational expression as a whole part and a
proper rational part</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">partfrac</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >partial fraction decomposition</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">quo</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >quotient</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">rem</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >remainder</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">gcd</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >greatest common divisor</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">lcm</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >least common multiple</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">egcd</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >Bezout’s identity
</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">divpc</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >Taylor polynomial for a rational expression</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">randpoly</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >random polynomial</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">cyclotomic</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >cyclotomic polynomial</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">lagrange</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >Lagrange polynomials</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">hermite</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >Hermite polynomials</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">laguerre</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >Laguerre polynomials</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">tchebyshev1</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >Tchebyshev polynomials</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">tchebyshev2</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >Tchebyshev polynomials</td></tr>
</table>
</div><p>
<a id="hevea_default217"></a>
<a id="hevea_default218"></a>
<a id="hevea_default219"></a>
<a id="hevea_default220"></a>
<a id="hevea_default221"></a>
<a id="hevea_default222"></a>
<a id="hevea_default223"></a>
<a id="hevea_default224"></a>
<a id="hevea_default225"></a>
<a id="hevea_default226"></a>
<a id="hevea_default227"></a>
<a id="hevea_default228"></a>
<a id="hevea_default229"></a>
<a id="hevea_default230"></a>
<a id="hevea_default231"></a>
<a id="hevea_default232"></a>
<a id="hevea_default233"></a>
<a id="hevea_default234"></a>
<a id="hevea_default235"></a>
<a id="hevea_default236"></a>
<a id="hevea_default237"></a>
<a id="hevea_default238"></a>
<a id="hevea_default239"></a>
<a id="hevea_default240"></a>
<a id="hevea_default241"></a>
<a id="hevea_default242"></a>
<a id="hevea_default243"></a>
<a id="hevea_default244"></a>
<a id="hevea_default245"></a>
<a id="hevea_default246"></a>
<a id="hevea_default247"></a>
<a id="hevea_default248"></a>
<a id="hevea_default249"></a>
<a id="hevea_default250"></a>
<a id="hevea_default251"></a>
<a id="hevea_default252"></a>
<a id="hevea_default253"></a>
<a id="hevea_default254"></a>
<a id="hevea_default255"></a>
<a id="hevea_default256"></a>
<a id="hevea_default257"></a>
<a id="hevea_default258"></a>
<a id="hevea_default259"></a>
<a id="hevea_default260"></a>
<a id="hevea_default261"></a>
<a id="hevea_default262"></a></p><p>Various polynomial operations are available in the <span style="font-family:monospace">Polynomials</span>
submenu of the <span style="font-family:monospace">Cmds</span> menu.</p><p>The <span style="font-family:monospace">expand</span> and <span style="font-family:monospace">normal</span> operators will distribute
multiplication across addition, and so expand a polynomial completely
out. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">expand((x+1)*(x+2)^2)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<span style="font-style:italic">x</span><sup>3</sup>+5*<span style="font-style:italic">x</span><sup>2</sup>+8*<span style="font-style:italic">x</span>+4
</td></tr>
</table><p>
Additionally, <span style="font-family:monospace">normal</span> will reduce a rational expression to
lowest terms; if you enter
</p><blockquote class="quote"><span style="font-family:monospace">normal((x-1)^2/(x^2-1))
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span>−1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span>+1</td></tr>
</table></td></tr>
</table><p>The <span style="font-family:monospace">factor</span> operator will factor a polynomial.
If you enter
</p><blockquote class="quote"><span style="font-family:monospace">factor(x^3+6*x^2+3*x-10
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
(<span style="font-style:italic">x</span>−1)*(<span style="font-style:italic">x</span>+2)*(<span style="font-style:italic">x</span>+5)
</td></tr>
</table><p>
The result often depends on the number field being used. For example, over the
rational numbers the polynomial <span style="font-style:italic">x</span><sup>4</sup> − 1 factors as
(<span style="font-style:italic">x</span>−1)(<span style="font-style:italic">x</span>+1)(<span style="font-style:italic">x</span><sup>2</sup> + 1), while over the complex numbers it factors as
(<span style="font-style:italic">x</span>−1)(<span style="font-style:italic">x</span>+1)(<span style="font-style:italic">x</span>−<span style="font-style:italic">i</span>)(<span style="font-style:italic">x</span>+<span style="font-style:italic">i</span>). If the coefficients of a polynomial are exact
fractions, then the factoring will be over the rationals. To factor
over the complex numbers, you can configure <span style="font-family:monospace">Xcas</span> to do
complex factorization (see section <a href="#config">2.3</a>, “Configuration”)
or use the <span style="font-family:monospace">cfactor</span> command.
If the coefficients are in ℤ/<span style="font-style:italic">p</span>ℤ then the polynomial will be
factored over ℤ/<span style="font-style:italic">p</span>ℤ.</p>
<!--TOC subsection id="sec31" Trigonometry-->
<h3 id="sec31" class="subsection">5.3  Trigonometry</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Trigonométrie</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">tlin</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >linearize</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">tcollect</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >linearize and regroup</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">texpand</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >expand</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">trig2exp</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >trigonometric to exponential</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">exp2trig</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >exponential to trigonometric</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">hyp2exp</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >hyperbolic to exponential</td></tr>
</table>
</div><p>
<a id="hevea_default263"></a>
<a id="hevea_default264"></a>
<a id="hevea_default265"></a>
<a id="hevea_default266"></a>
<a id="hevea_default267"></a>
<a id="hevea_default268"></a></p><p><span style="font-family:monospace">Xcas</span> has the usual trigonometic functions, both circular and
hyperbolic, as well as their inverses. It also has commands for
manipulating trigonometric expressions; these are in the
<span style="font-family:monospace">Trigo</span> submenus of the <span style="font-family:monospace">Expression</span> menu.</p><p>One example is the <span style="font-family:monospace">tlin</span> command will write products and powers of sines and
cosines as linear combinations of sin(<span style="font-style:italic">n</span> <span style="font-style:italic">x</span>)s and cos(<span style="font-style:italic">n</span> <span style="font-style:italic">x</span>)s. If
you enter
</p><blockquote class="quote"><span style="font-family:monospace">tlin(2*sin(x)^2*cos(3*x))
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
−</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">cos(<span style="font-style:italic">x</span>)</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">2</td></tr>
</table></td><td class="dcell"> + cos(3*<span style="font-style:italic">x</span>) − </td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">cos(5*<span style="font-style:italic">x</span>)</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">2</td></tr>
</table></td></tr>
</table><p>The <span style="font-family:monospace">texpand</span> command will take expressions involving
sin(<span style="font-style:italic">n</span> <span style="font-style:italic">x</span>) and cos(<span style="font-style:italic">n</span> <span style="font-style:italic">x</span>) and write them in terms of powers if
sin(<span style="font-style:italic">x</span>) and cos(<span style="font-style:italic">x</span>). If you enter
</p><blockquote class="quote"><span style="font-family:monospace">texpand(sin(2*x)^2*cos(3*x))
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
16*cos(<span style="font-style:italic">x</span>)<sup>5</sup>*sin(<span style="font-style:italic">x</span>)<sup>2</sup>−12*cos(<span style="font-style:italic">x</span>)<sup>3</sup>*sin(<span style="font-style:italic">x</span>)<sup>2</sup>
</td></tr>
</table>
<!--TOC subsection id="sec32" Vectors and matrices-->
<h3 id="sec32" class="subsection">5.4  Vectors and matrices</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Vectors and matrices</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">v*w</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >scalar product</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">cross(v,w)</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >cross product</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">A*B</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >matrix product</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">A.*B</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >term by term product</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">1/A</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >inverse</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">tran</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >transpose</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">rank</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >rank</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">det</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >determinant</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">ker</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >basis for the kernel</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">image</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >base for the image</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">idn</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >identity matrix</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">ranm</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >matrix with random coefficients</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">makematrix</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >make a matrix from a function</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">matrix</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >make a matrix from a function</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">blockmatrix</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >combine matrices</td></tr>
</table>
</div><p>
<a id="hevea_default269"></a>
<a id="hevea_default270"></a>
<a id="hevea_default271"></a>
<a id="hevea_default272"></a>
<a id="hevea_default273"></a>
<a id="hevea_default274"></a>
<a id="hevea_default275"></a>
<a id="hevea_default276"></a>
<a id="hevea_default277"></a>
<a id="hevea_default278"></a>
<a id="hevea_default279"></a>
<a id="hevea_default280"></a>
<a id="hevea_default281"></a>
<a id="hevea_default282"></a>
<a id="hevea_default283"></a>
<a id="hevea_default284"></a>
<a id="hevea_default285"></a>
<a id="hevea_default286"></a>
<a id="hevea_default287"></a></p><p>A vector is a list of numbers, such as <span style="font-family:monospace">[2,3,5]</span>, and a matrix
is a list of vectors all of the same length, such as
<span style="font-family:monospace">[[1,2,3],[4,5,6]]</span>.</p><p>The usual matrix operations (addition, scalar multiplication, matrix
multiplication) are done with the usual operators <span style="font-family:monospace">+</span> and
<span style="font-family:monospace">*</span>. If you define
</p><blockquote class="quote"><span style="font-family:monospace">A := [[1,2,3],[4,5,6],[7,8,9]]
</span></blockquote><blockquote class="quote"><span style="font-family:monospace">B := [[1,1,1],[2,2,2]]
</span></blockquote><p>
then
</p><blockquote class="quote"><span style="font-family:monospace">3*A
</span></blockquote><p>
will give you
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr style="vertical-align:middle"><td class="dcell">⎛<br>
⎜<br>
⎜<br>
⎝</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >3</td><td style="text-align:center;white-space:nowrap" >6</td><td style="text-align:center;white-space:nowrap" >9</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >12</td><td style="text-align:center;white-space:nowrap" >15</td><td style="text-align:center;white-space:nowrap" >18</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >21</td><td style="text-align:center;white-space:nowrap" >24</td><td style="text-align:center;white-space:nowrap" >27
</td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎟<br>
⎠</td></tr>
</table></td></tr>
</table><p>
and
</p><blockquote class="quote"><span style="font-family:monospace">B*A
</span></blockquote><p>
will give you
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr style="vertical-align:middle"><td class="dcell">⎛<br>
⎜<br>
⎝</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >12</td><td style="text-align:center;white-space:nowrap" >15</td><td style="text-align:center;white-space:nowrap" >18</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >24</td><td style="text-align:center;white-space:nowrap" >30</td><td style="text-align:center;white-space:nowrap" >36
</td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎠</td></tr>
</table></td></tr>
</table><p>
A vector can be regarded as a matrix with one row, except that if a matrix
is multiplied on the right by a vector, the vector will be regarded as
a column. In particular, if <span style="font-family:monospace">v</span> and <span style="font-family:monospace">w</span> are vectors of
the same length, then <span style="font-family:monospace">v*w</span> will return the scalar product.</p><p>The <span style="font-family:monospace">idn</span> command will create an identity matrix;
</p><blockquote class="quote"><span style="font-family:monospace">idn(2)
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr style="vertical-align:middle"><td class="dcell">⎛<br>
⎜<br>
⎝</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >1</td><td style="text-align:center;white-space:nowrap" >0</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >0</td><td style="text-align:center;white-space:nowrap" >1
</td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎠</td></tr>
</table></td></tr>
</table><p>
You can also use <span style="font-family:monospace">makemat</span> or <span style="font-family:monospace">matrix</span> commands to build
a matrix. They both require a real-valued function of two variables,
the number of rows and the number of columns. The indices start at 0,
and with the <span style="font-family:monospace">makemat</span> the function comes first, with
<span style="font-family:monospace">matrix</span> the function comes last. Both
</p><blockquote class="quote"><span style="font-family:monospace">makemat((j,k)->j+k,3,2)
</span></blockquote><p>
and
</p><blockquote class="quote"><span style="font-family:monospace">matrix(3,2,(j,k)->j+k)
</span></blockquote><p>
produce
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr style="vertical-align:middle"><td class="dcell">⎛<br>
⎜<br>
⎜<br>
⎝</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >0</td><td style="text-align:center;white-space:nowrap" >1</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >1</td><td style="text-align:center;white-space:nowrap" >2</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >2</td><td style="text-align:center;white-space:nowrap" >3
</td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎟<br>
⎠</td></tr>
</table></td></tr>
</table><p>Several matrices can be combined into a larger matrix with the
<span style="font-family:monospace">blockmatrix</span> command. To arrange <span style="font-style:italic">m</span> * <span style="font-style:italic">n</span> matrices
into <span style="font-style:italic">m</span> rows and <span style="font-style:italic">n</span> columns, you give <span style="font-family:monospace">blockmatrix</span> the
values <span style="font-style:italic">m</span>, <span style="font-style:italic">n</span> and a list of the matrices. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">A := [[1,2,3],[4,5,6]]
</span></blockquote><blockquote class="quote"><span style="font-family:monospace">B := [[1,2],[2,3]]
</span></blockquote><p>
then
</p><blockquote class="quote"><span style="font-family:monospace">blockmatrix(2,2,[A,B,B,A])
</span></blockquote><p>
will give you
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr style="vertical-align:middle"><td class="dcell">⎛<br>
⎜<br>
⎜<br>
⎜<br>
⎝</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >1</td><td style="text-align:center;white-space:nowrap" >2</td><td style="text-align:center;white-space:nowrap" >3</td><td style="text-align:center;white-space:nowrap" >1</td><td style="text-align:center;white-space:nowrap" >2</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >4</td><td style="text-align:center;white-space:nowrap" >5</td><td style="text-align:center;white-space:nowrap" >6</td><td style="text-align:center;white-space:nowrap" >2</td><td style="text-align:center;white-space:nowrap" >3</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >1</td><td style="text-align:center;white-space:nowrap" >2</td><td style="text-align:center;white-space:nowrap" >1</td><td style="text-align:center;white-space:nowrap" >2</td><td style="text-align:center;white-space:nowrap" >3</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >2</td><td style="text-align:center;white-space:nowrap" >3</td><td style="text-align:center;white-space:nowrap" >4</td><td style="text-align:center;white-space:nowrap" >5</td><td style="text-align:center;white-space:nowrap" >5
</td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎟<br>
⎟<br>
⎠</td></tr>
</table></td></tr>
</table><p>You can get the elements from a matrix by following the matrix with
the indices in brackets, separated by commas. For <span style="font-family:monospace">A</span> as above,
</p><blockquote class="quote"><span style="font-family:monospace">A[1,2]
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
6
</td></tr>
</table><p>
You can extract a submatrix<a id="hevea_default288"></a> by using intervals of indices (the
beginning and end index separated by two periods);
</p><blockquote class="quote"><span style="font-family:monospace">A[0..1,1..2]
</span></blockquote><p>
returns
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr style="vertical-align:middle"><td class="dcell">⎛<br>
⎜<br>
⎝</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >2</td><td style="text-align:center;white-space:nowrap" >3</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >5</td><td style="text-align:center;white-space:nowrap" >6
</td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎠</td></tr>
</table></td></tr>
</table><p>Note that if you change one value of a matrix in <span style="font-family:monospace">Xcas</span>, the
entire matrix will be copied. If a program modifies parts of a large
matrix one element at a time, this time can add up.</p>
<!--TOC subsection id="sec33" Linear systems-->
<h3 id="sec33" class="subsection">5.5  Linear systems</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Linear systems</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">linsolve</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >solution of a linear system</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">simult</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >solutions of many linear systems</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">rref</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >Gauss-Jordan reduction</td></tr>
</table>
</div><p>
<a id="hevea_default289"></a>
<a id="hevea_default290"></a>
<a id="hevea_default291"></a>
<a id="hevea_default292"></a></p><p>The <span style="font-family:monospace">linsolve</span> command will solve a system of linear equations;
its syntax is the same as that of <span style="font-family:monospace">solve</span> (see section
<a href="#solve">4.4</a>, “Solving equations”).
If you enter
</p><blockquote class="quote"><span style="font-family:monospace">linsolve([2*x + 3*y = 4, 5*x + 4*y = 3],[x,y])
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[−1,2]
</td></tr>
</table><p>The <span style="font-family:monospace">simult</span> command can also solve a system of linear
equations; more generally, it can solve several systems with the same
coefficient matrix. To solve the systems
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><span style="font-style:italic">A</span><span style="font-weight:bold"><span style="font-style:italic">x</span></span> = <span style="font-weight:bold"><span style="font-style:italic">b</span></span><sub>1</sub>,…,<span style="font-style:italic">A</span><span style="font-weight:bold"><span style="font-style:italic">x</span></span>=<span style="font-weight:bold"><span style="font-style:italic">b</span></span><sub><span style="font-style:italic">k</span></sub></td></tr>
</table><p>
you can enter
</p><blockquote class="quote"><span style="font-family:monospace">simult(A,B)
</span></blockquote><p>
where
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><span style="font-style:italic">B</span> = </td><td class="dcell">⎛<br>
⎝</td><td class="dcell"><span style="font-weight:bold"><span style="font-style:italic">b</span></span><sub>1</sub> ⋯ <span style="font-weight:bold"><span style="font-style:italic">b</span></span><sub><span style="font-style:italic">k</span></sub></td><td class="dcell">⎞<br>
⎠</td></tr>
</table><p>
The result will be a matrix whose <span style="font-style:italic">j</span>th column is the solution of
<span style="font-style:italic">A</span><span style="font-weight:bold"><span style="font-style:italic">x</span></span>=<span style="font-weight:bold"><span style="font-style:italic">b</span></span><sub><span style="font-style:italic">j</span></sub>.
For example, if you want to solve the systems
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">⎧<br>
⎪<br>
⎨<br>
⎪<br>
⎩</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:left;white-space:nowrap" > <span style="font-style:italic">x</span></td><td style="text-align:left;white-space:nowrap" >+</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">y</span></td><td style="text-align:left;white-space:nowrap" >−</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">z</span></td><td style="text-align:left;white-space:nowrap" >=</td><td style="text-align:right;white-space:nowrap" >1</td></tr>
<tr><td style="text-align:left;white-space:nowrap" > <span style="font-style:italic">x</span></td><td style="text-align:left;white-space:nowrap" >−</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">y</span></td><td style="text-align:left;white-space:nowrap" >+</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">z</span></td><td style="text-align:left;white-space:nowrap" >=</td><td style="text-align:right;white-space:nowrap" >1 </td></tr>
<tr><td style="text-align:left;white-space:nowrap" > −<span style="font-style:italic">x</span></td><td style="text-align:left;white-space:nowrap" >+</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">y</span></td><td style="text-align:left;white-space:nowrap" >+</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">z</span></td><td style="text-align:left;white-space:nowrap" >=</td><td style="text-align:right;white-space:nowrap" >−2 
</td></tr>
</table></td></tr>
</table><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">⎧<br>
⎪<br>
⎨<br>
⎪<br>
⎩</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:left;white-space:nowrap" > <span style="font-style:italic">x</span></td><td style="text-align:left;white-space:nowrap" >+</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">y</span></td><td style="text-align:left;white-space:nowrap" >−</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">z</span></td><td style="text-align:left;white-space:nowrap" >=</td><td style="text-align:right;white-space:nowrap" >−2</td></tr>
<tr><td style="text-align:left;white-space:nowrap" > <span style="font-style:italic">x</span></td><td style="text-align:left;white-space:nowrap" >−</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">y</span></td><td style="text-align:left;white-space:nowrap" >+</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">z</span></td><td style="text-align:left;white-space:nowrap" >=</td><td style="text-align:right;white-space:nowrap" >1 </td></tr>
<tr><td style="text-align:left;white-space:nowrap" > −<span style="font-style:italic">x</span></td><td style="text-align:left;white-space:nowrap" >+</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">y</span></td><td style="text-align:left;white-space:nowrap" >+</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">z</span></td><td style="text-align:left;white-space:nowrap" >=</td><td style="text-align:right;white-space:nowrap" >1 
</td></tr>
</table></td></tr>
</table><p>
which both have the same matrix of coefficients
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><table class="display"><tr style="vertical-align:middle"><td class="dcell">⎛<br>
⎜<br>
⎜<br>
⎝</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >  1</td><td style="text-align:center;white-space:nowrap" >1</td><td style="text-align:center;white-space:nowrap" >−1</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >  1</td><td style="text-align:center;white-space:nowrap" >−1</td><td style="text-align:center;white-space:nowrap" >1</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >  −1</td><td style="text-align:center;white-space:nowrap" >1</td><td style="text-align:center;white-space:nowrap" >1
</td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎟<br>
⎠</td></tr>
</table></td></tr>
</table><p>
you can create the matrix which has one column for each system
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><table class="display"><tr style="vertical-align:middle"><td class="dcell">⎛<br>
⎜<br>
⎜<br>
⎝</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >  1</td><td style="text-align:center;white-space:nowrap" >−2</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >  1</td><td style="text-align:center;white-space:nowrap" >1</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >  −2</td><td style="text-align:center;white-space:nowrap" >1
</td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎟<br>
⎠</td></tr>
</table></td></tr>
</table><p>
If you enter
</p><blockquote class="quote"><span style="font-family:monospace">simult([[1,1,-1],[1,-1,1],[-1,1,1]],[[1,-2],[1,1],[-2,1]])
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr style="vertical-align:middle"><td class="dcell">⎛<br>
⎜<br>
⎜<br>
⎝</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >1</td><td style="text-align:center;white-space:nowrap" >−1/2</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >−1/2</td><td style="text-align:center;white-space:nowrap" >−1/2</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >−1/2</td><td style="text-align:center;white-space:nowrap" >1
</td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎟<br>
⎠</td></tr>
</table></td></tr>
</table><p>
The solution to the first system is the first column,
<span style="font-style:italic">x</span>=1,<span style="font-style:italic">y</span>=−1/2,<span style="font-style:italic">z</span>=−1/2, and the solution to the second system is the
second column, <span style="font-style:italic">x</span>=−1/2,<span style="font-style:italic">y</span>=−1/2,<span style="font-style:italic">z</span>=1.</p><p>When there are no solutions, <span style="font-family:monospace">linsolve</span> will return the empty
list while <span style="font-family:monospace">simult</span> will return an error. When there are
infinitely many solutions, <span style="font-family:monospace">linsolve</span> will return formulas for
all solutions while <span style="font-family:monospace">simult</span> will return one solution.</p>
<!--TOC subsection id="sec34" Matrix reduction-->
<h3 id="sec34" class="subsection">5.6  Matrix reduction</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Matrix reduction</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">jordan</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >diagonalization or Jordan reduction</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">pcar</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >characteristic polynomial (list form)</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">pmin</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >minimal polynomial (list form)</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">eigenvals</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >eigenvalues</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">eigenvects</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >eigenvectors</td></tr>
</table>
</div><p>
<a id="hevea_default293"></a>
<a id="hevea_default294"></a>
<a id="hevea_default295"></a>
<a id="hevea_default296"></a>
<a id="hevea_default297"></a>
<a id="hevea_default298"></a>
<a id="hevea_default299"></a>
<a id="hevea_default300"></a>
<a id="hevea_default301"></a>
<a id="hevea_default302"></a>
<a id="hevea_default303"></a></p><p>The <span style="font-family:monospace">jordan</span> command will take a matrix <span style="font-style:italic">A</span> and returns a
transition matrix <span style="font-style:italic">P</span> and a matrix <span style="font-style:italic">J</span> in Jordan canonical form, so
that <span style="font-style:italic">P</span><sup>−1</sup> <span style="font-style:italic">A</span> <span style="font-style:italic">P</span> = <span style="font-style:italic">J</span>. In particular, if <span style="font-style:italic">A</span> is diagonalizable, then
<span style="font-style:italic">J</span> will be diagonal with the eigenvalues of <span style="font-style:italic">A</span> on the diagonal and
the columns of <span style="font-style:italic">P</span> will be the corresponding eigenvectors.
If you enter
</p><blockquote class="quote"><span style="font-family:monospace">jordan([[4,1],[-8,-5]])
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell">⎛<br>
⎜<br>
⎝</td><td class="dcell"><table class="display"><tr style="vertical-align:middle"><td class="dcell">⎛<br>
⎜<br>
⎝</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >1</td><td style="text-align:center;white-space:nowrap" >1</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >−1</td><td style="text-align:center;white-space:nowrap" >−8 </td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎠</td></tr>
</table></td><td class="dcell">,
</td><td class="dcell"><table class="display"><tr style="vertical-align:middle"><td class="dcell">⎛<br>
⎜<br>
⎝</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >3</td><td style="text-align:center;white-space:nowrap" >0</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >0</td><td style="text-align:center;white-space:nowrap" >−4 </td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎠</td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎠</td></tr>
</table><p>
This means that 3 and −4 (the diagonal elements of the second
matrix) are the eigenvalues of
(</p><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >4</td><td style="text-align:center;white-space:nowrap" >1</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >−8</td><td style="text-align:center;white-space:nowrap" >−5</td></tr>
</table><p>) and the corresponding
eigenvectors are (</p><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >1</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >−1</td></tr>
</table><p>) and
(</p><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >1</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >−8</td></tr>
</table><p>) (the columns of the first matrix).
For diagonalizable matrices you can also get this information with the
<span style="font-family:monospace">eigenvals</span> and <span style="font-family:monospace">eigenvects</span> commands;
</p><blockquote class="quote"><span style="font-family:monospace">eigenvals([[4,1],[-8,-5]])
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
(3,−4)
</td></tr>
</table><p>
and
</p><blockquote class="quote"><span style="font-family:monospace">eigenvects([[4,1],[-8,-5]])
</span></blockquote><p>
will return
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr style="vertical-align:middle"><td class="dcell">⎛<br>
⎜<br>
⎝</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >1</td><td style="text-align:center;white-space:nowrap" >1</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >−1</td><td style="text-align:center;white-space:nowrap" >−8 </td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎠</td></tr>
</table></td></tr>
</table><p>For matrices with exact and symbolic values, the only eigenvalues used
are those computable with <span style="font-family:monospace">solve</span>; for matrices with floating
point numbers, a numerical algorithm is used to find the eigenvalues.
This algorithm may fail in some cases where there are very close
eigenvalues or eigenvalues with multiplicity greater than one.</p><p>If a function is defined by a polynomial, you can evaluate it with an
argument of a square matrix. If a function is given by a series, the
Jordan form of the matrix can be used to define the value of the
function at a matrix. For example, you can find the exponential of a
square matrix;
</p><blockquote class="quote"><span style="font-family:monospace">exp([[0,-1],[1,2]])
</span></blockquote><p>
will result in
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
</td><td class="dcell"><table class="display"><tr style="vertical-align:middle"><td class="dcell">⎛<br>
⎜<br>
⎝</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >0</td><td style="text-align:center;white-space:nowrap" >−exp(1)</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >exp(1)</td><td style="text-align:center;white-space:nowrap" >2*exp(1)
</td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎠</td></tr>
</table></td></tr>
</table>
<!--TOC section id="sec35" Graphs-->
<h2 id="sec35" class="section">6  Graphs</h2><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Plotting graphs</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">plot</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >graph an expression of one variable</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">plotfunc</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >graph an expression of one or two variables</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">tangent</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >tangent to a curve</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">plotparam</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >parametric curve</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">plotpolar</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >polar plotting</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">plotimplicit</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >implicit curve</td></tr>
</table>
</div><p>
<a id="hevea_default304"></a>
<a id="hevea_default305"></a>
<a id="hevea_default306"></a>
<a id="hevea_default307"></a>
<a id="hevea_default308"></a>
<a id="hevea_default309"></a>
<a id="hevea_default310"></a>
<a id="hevea_default311"></a>
<a id="hevea_default312"></a></p><p>The <span style="font-family:monospace">Graphic</span> menu has entries for several graphing commands;
if you choose one you will be given a template you can fill out to
produce a graphic. The appropriate command will be placed on the
command line. If you want several graphs in the same window, you can
put the commands on the same command line separated by semicolons.</p><p>Once you have created a graphic window, there will be a panel to the
right with buttons allowing you to control the image. The default
parameters for graphs, such as the size of the graphs, are
configurable (see section <a href="#config">2.3</a>, “Configuration”).</p><p>As well as being displayed in the <span style="font-family:monospace">Xcas</span> window, the two
dimensional graphics also appear in the DispG (Display Graphics)
window. You can bring that window up with the
<span style="font-family:monospace">Cfg</span>▸<span style="font-family:monospace">Show</span>▸<span style="font-family:monospace">DispG</span> menu item.
This window will contain all two dimensional graphs; they can be
cleared with the <span style="font-family:monospace">ClrGraph</span> command. </p>
<!--TOC subsection id="sec36" Curves-->
<h3 id="sec36" class="subsection">6.1  Curves</h3><!--SEC END --><p>The simplest way to draw graphs is with the templates from the
<span style="font-family:monospace">Graphic</span> menu, but there are command line equivalents. </p><p>The command line instruction for graphing a function is the
<span style="font-family:monospace">plot</span> command. It takes an expression (or list of
expressions) followed by the variable. To use a domain different than
the default, you can indicate the range of the variable by setting it
equal to an interval. If you are plotting several curves, you can
distinguish them by giving them different colors; you can do this with
a third argument <span style="font-family:monospace">color=</span> followed by a list of colors.
If you plot
</p><blockquote class="quote"><span style="font-family:monospace">plot([x^2,x^3],x=-1..1,color=[red,blue])
</span></blockquote><p>
you will get
</p><div class="center">
<img src="tutoriel008.png">
</div><p>You can draw parameterized curves with the <span style="font-family:monospace">plotparam</span> command.
The coordinates of the curve must be given as a single complex
expression; the <span style="font-style:italic">x</span> coordinate will be the real part of the expression
and the <span style="font-style:italic">y</span> coordinate will be the imaginary part. For example, if
you enter
</p><blockquote class="quote"><span style="font-family:monospace">plotparam(sin(t) + i*cos(t),t)
</span></blockquote><p>
you will get the circle
</p><div class="center">
<img src="tutoriel009.png">
</div><p>
(Since the <span style="font-style:italic">x</span>- and <span style="font-style:italic">y</span>-axes are scaled differently, the circle
looks elliptical.)</p><p>You can draw a curve using polar coordinates with the
<span style="font-family:monospace">plotpolar</span> command. This takes the form
<span style="font-family:monospace">plotpolar(f(theta),theta,theta-min,theta-max)</span>.</p><p>You can draw an implicitly defined curve with the
<span style="font-family:monospace">plotimplicit</span> command; the command
<span style="font-family:monospace">plotimplicit(</span><span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>,<span style="font-style:italic">y</span>)<span style="font-family:monospace">,</span><span style="font-style:italic">x</span><span style="font-family:monospace">,</span><span style="font-style:italic">y</span><span style="font-family:monospace">)</span> will draw the curve
<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>,<span style="font-style:italic">y</span>)=0. For example, the command
</p><blockquote class="quote"><span style="font-family:monospace">plotimplicit(x^2 + y^2 = 1,x,y)
</span></blockquote><p>
will draw a circle.</p><p>The <span style="font-family:monospace">tangent</span> command will draw the tangent line to a curve, if
you tell it the curve and the point. To draw the tangent line to the
graph <span style="font-style:italic">y</span>=<span style="font-style:italic">x</span><sup>2</sup> at <span style="font-style:italic">x</span>=1, for example, you can enter
</p><blockquote class="quote"><span style="font-family:monospace">tangent(plotfunc(x^2,x),1)
</span></blockquote><p>
You will get
</p><div class="center">
<img src="tutoriel010.png">
</div>
<!--TOC subsection id="sec37" Plane geometry-->
<h3 id="sec37" class="subsection">6.2  Plane geometry</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">2D graphical objects</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">legend</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >place text starting from a given point</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">point</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >determine a point given a complex number or two
coordinates</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">segment</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >segment determined by 2 points</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">circle</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >circle determined by a point and radius</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">inter</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >find the intersection of curves</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">equation</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >return the cartesian equation of a curve</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">parameq</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >return the parametric equation of a curve</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">polygonplot</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >draw a polygonal line</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">scatterplot</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >draw a cloud of dots</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">polygon</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >draw a closed polygon</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">open_polygon</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >draw an open polygon</td></tr>
</table>
</div><p>
<a id="hevea_default313"></a>
<a id="hevea_default314"></a>
<a id="hevea_default315"></a>
<a id="hevea_default316"></a>
<a id="hevea_default317"></a>
<a id="hevea_default318"></a>
<a id="hevea_default319"></a>
<a id="hevea_default320"></a>
<a id="hevea_default321"></a>
<a id="hevea_default322"></a>
<a id="hevea_default323"></a>
<a id="hevea_default324"></a>
<a id="hevea_default325"></a>
<a id="hevea_default326"></a>
<a id="hevea_default327"></a>
<a id="hevea_default328"></a>
<a id="hevea_default329"></a></p><p>Among its other capabilities, <span style="font-family:monospace">Xcas</span> works with plane geometry.
The <span style="font-family:monospace">Geo</span>▸<span style="font-family:monospace">New figure 2D</span> menu item or the
<span style="font-family:monospace">Alt+g</span> key will bring up the screen for plane geometry.</p><p>A point on the geometry screen can be specified with the
<span style="font-family:monospace">point</span> command, which can take either an ordered pair or real
numbers or a complex number as argument. The <span style="font-family:monospace">Geo</span> menu
contains many commands for drawing geometric objects, such as
<span style="font-family:monospace">circle</span> (which takes a point and a radius as arguments) and
<span style="font-family:monospace">polygon</span> (which takes a sequence of points as arguments).</p><p>Some functions, such as <span style="font-family:monospace">polygonplot</span> and <span style="font-family:monospace">scatterplot</span>,
take lists of <span style="font-style:italic">x</span>-coordinates and <span style="font-style:italic">y</span>-coordinates as arguments. For
example,
</p><blockquote class="quote"><span style="font-family:monospace">polygonplot([0,2,0],[0,0,2])
</span></blockquote><p>
and
</p><blockquote class="quote"><span style="font-family:monospace">open_polygon(point(0,0),point(2,0),point(0,2))
</span></blockquote><p>
will both draw the same segments.</p><p>The <span style="font-family:monospace">legend</span> can be used to place text on the screen; one
simple way of using it is to give it a point and text as arguments.</p>
<!--TOC subsection id="sec38" 3D graphical objects-->
<h3 id="sec38" class="subsection">6.3  3D graphical objects</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">3D graphical objects</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">plotfunc</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >graph of a function</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">plotparam</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >parametric surface</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">point</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >point</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">plane</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >plane</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">sphere</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >sphere with a center and radius</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">cone</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >cone with a center, axis and opening angle</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">inter</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >intersection </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">polygon</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >polygon </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">open_polygon</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >open polygon</td></tr>
</table>
</div><p>
<a id="hevea_default330"></a>
<a id="hevea_default331"></a>
<a id="hevea_default332"></a>
<a id="hevea_default333"></a>
<a id="hevea_default334"></a>
<a id="hevea_default335"></a>
<a id="hevea_default336"></a>
<a id="hevea_default337"></a>
<a id="hevea_default338"></a>
<a id="hevea_default339"></a>
<a id="hevea_default340"></a>
<a id="hevea_default341"></a></p><p><span style="font-family:monospace">Xcas</span> can also handle three-dimensions graphically, either by
drawing curves and graphs in three-dimensions or by drawing
three-dimensional geometric objects. A three-dimensional screen can
be brought up with the <span style="font-family:monospace">Geo</span>▸<span style="font-family:monospace">New figure 3D</span>
menu item or the <span style="font-family:monospace">Alt+h</span> key.
There will controls for the view window to the right of the screen.
You can rotate the visualization cube by using the mouse outside of
the cube or by clicking in the cube and using the <span style="font-family:monospace">x</span>,
<span style="font-family:monospace">y</span> and <span style="font-family:monospace">z</span> keys to rotate and the <span style="font-family:monospace">+</span> and
<span style="font-family:monospace">-</span> keys for zooming.</p><p>You can draw a graph <span style="font-style:italic">z</span> = <span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>,<span style="font-style:italic">y</span>) with the <span style="font-family:monospace">plotfunc</span> command,
which takes an expression and a list of two variables. Like graphs of
functions of one variable, you can use a domain different than the
default by giving the variables their own intervals. The command
</p><blockquote class="quote"><span style="font-family:monospace">plotfunc(y^2 - x^2,[x=-1..1,y=-1..1])
</span></blockquote><p>
will give you the graph
</p><div class="center">
<img src="tutoriel011.png">
</div><p>The <span style="font-family:monospace">plotparam</span> command can be used to draw a parameterized
curves and surfaces in three-dimensions. If the first argument is a
list of three expressions involving two variables and the next two
arguments are the variables (with optional intervals), then
<span style="font-family:monospace">plotparam</span> will plot the surface. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">plotparam([u,u+v,v],u,v)
</span></blockquote><p>
you will get
</p><div class="center">
<img src="tutoriel012.png">
</div><p>
If the first argument is a list of three expressions involving one
variable and the next argument is the variable, then
<span style="font-family:monospace">plotparam</span> will plot the curve. If you enter
</p><blockquote class="quote"><span style="font-family:monospace">plotparam([cos(t),sin(t),t],t)
</span></blockquote><p>
you will get
</p><div class="center">
<img src="tutoriel013.png">
</div><p>A point in three-dimensions is given with the <span style="font-family:monospace">point</span> command
with three arguments. Commands like <span style="font-family:monospace">polygon</span> and
<span style="font-family:monospace">open_polygon</span> work in three-dimensions as well as two, as
well as additional commands such as <span style="font-family:monospace">sphere</span>. A plane can be
drawn with the <span style="font-family:monospace">plane</span> command, which can be given either three
points, a line and two points, or an equation of the form <span style="font-family:monospace">a*x
+ b*y + c*z = d</span>.</p>
<!--TOC section id="sec39" Programming-->
<h2 id="sec39" class="section">7  Programming</h2><!--SEC END -->
<!--TOC subsection id="sec40" The language-->
<h3 id="sec40" class="subsection">7.1  The language</h3><!--SEC END --><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Instructions for </span><span style="font-weight:bold"><span style="font-family:monospace">Xcas</span></span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">a:=2;</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >assignment </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">input("a=",a);</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >input expression </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">textinput("a=",a);</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >string input </td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">print("a=",a);</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >output</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">return(a);</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >return value</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">break;</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >break out of loop</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">continue;</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >go to the next iteration</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">if (<condition>) </span><span style="font-family:monospace"><inst></span><span style="font-family:monospace">;</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >if…then</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">if (<condition>) </span><span style="font-family:monospace"><inst1></span><span style="font-family:monospace"> else </span><span style="font-family:monospace"><inst2></span><span style="font-family:monospace">;</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" > if…then …else</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">for (j:= a;j<=b;j++) </span><span style="font-family:monospace"><inst></span><span style="font-family:monospace">;</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >for loop</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">for (j:= a;j<=b;j:=j+p) </span><span style="font-family:monospace"><inst></span><span style="font-family:monospace">;</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >for loop</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">repeat <inst> until <condition>;</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >repeat loop</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">while (<condition>) </span><span style="font-family:monospace"><inst></span><span style="font-family:monospace">;</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >while loop</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">do <inst1> if (<condition>) break;<inst2> od;</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >do loop</td></tr>
</table>
</div><p>
<a id="hevea_default342"></a>
<a id="hevea_default343"></a>
<a id="hevea_default344"></a>
<a id="hevea_default345"></a></p><div class="center">
<table border=1 style="border-spacing:0;" class="cellpadding1"><tr><td style="text-align:center;border:solid 1px;white-space:nowrap" colspan=2><span style="font-weight:bold">Boolean operators</span></td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">==</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >test for equality</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">!=</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >test for inequality</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace"><</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >test for strictly less than</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">></span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >test for strictly greater than</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace"><=</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >tes for less than or equal</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">>=</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >test for greater than or equal to</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">&&</span>, <span style="font-family:monospace">and</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >infixed “and”</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">||</span>, <span style="font-family:monospace">or</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >infixed “or”</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">true</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >boolean true (same as 1)</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">false</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >boolean false (same as 0)</td></tr>
<tr><td style="vertical-align:top;text-align:left;border:solid 1px;" ><span style="font-family:monospace">not</span>, <span style="font-family:monospace">!</span></td><td style="vertical-align:top;text-align:left;border:solid 1px;" >“not”</td></tr>
</table>
</div><p>
<a id="hevea_default346"></a>
<a id="hevea_default347"></a>
<a id="hevea_default348"></a>
<a id="hevea_default349"></a>
<a id="hevea_default350"></a>
<a id="hevea_default351"></a>
<a id="hevea_default352"></a>
<a id="hevea_default353"></a></p><p>You can extend <span style="font-family:monospace">Xcas</span> by adding desired functions with its
built-in programming language. The main features of the language are:</p><ul class="itemize"><li class="li-itemize">
It is a functional language. The argument of a function can
be another function; in which case you can either give the name of
a function or the definition of the function. If
<span style="font-family:monospace">f(x) := x^2</span>, then
<span style="font-family:monospace">function_diff(f)</span> is the same as
<span style="font-family:monospace">function_diff(x->x^2)</span>.</li><li class="li-itemize">There is no distinction between a program and a function. A
function returns the value of the last evaluated statement or what
follows the reserved word <span style="font-family:monospace">return</span>.</li><li class="li-itemize">The language is untyped. Any variable can take on any value; the
only different types of variables are global variables, which are
not declared, and local variables, which are declared at the
beginning of a function.
</li></ul><p>A function declaration looks like
</p><pre class="verbatim"> function_name (var1, var2, ...) := {
local var_loc1, var_loc2, ... ;
statement1;
statement2;
...
}
</pre><p>
The syntax is similar to <span style="font-family:monospace">C++</span>, although many variants are
recognized, particularly in compatibility mode.
Recall that <span style="font-family:monospace">i</span> is √<span style="text-decoration:overline">−1</span> and cannot be used for a loop
variable.
The conditional tests are Booleans, which are the results of the usual
Boolean operators.</p><p>A program can capture runtime errors with a
<span style="font-family:monospace">try</span>–<span style="font-family:monospace">catch</span> construction, which takes the form
</p><pre class="verbatim"> try
{
block to catch errors
}
catch (variable)
{
block to execute when an error is caught
}
</pre><p>
For example, the following will catch an error caused by incorrect
matrix multiplication:
</p><pre class="verbatim"> try
{ A := idn(2) * idn(3) }
catch (error)
{ print("The error is " + error) }
</pre>
<!--TOC subsection id="sec41" Some examples-->
<h3 id="sec41" class="subsection">7.2  Some examples</h3><!--SEC END --><p>To write a program, it is a good idea to use the program editor that
comes with <span style="font-family:monospace">Xcas</span>, which provides a template and commands
helpful for writing programs. You can open this editor with the
<span style="font-family:monospace">New Program</span> item in the <span style="font-family:monospace">Prg</span> menu or the
<span style="font-family:monospace">Alt+p</span> key.</p><p>Consider the following program, which takes two integers and returns the
quotient and remainder of the Euclidean division algorithm (like the
<span style="font-family:monospace">iquorem</span> function).
</p><pre class="verbatim"> idiv2(a,b) := {
local q,r;
if (b != 0) {
q := iquo(a,b);
r := irem(a,b);
}
else {
q := 0;
r := a;
}
return [q,r];
}
</pre><p>
If you enter this into the editor, you can test it with the
<span style="font-family:monospace">OK</span> button. You can then use the function in the command
line; if you enter
</p><blockquote class="quote"><span style="font-family:monospace">idiv2(25,15)
</span></blockquote><p>
you will get
</p><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
[1,10]
</td></tr>
</table><p>
You can save it in a file; the name <span style="font-family:monospace">idiv2.cxx</span> would be a good
name. You can then use it in later session with the command
</p><blockquote class="quote"><span style="font-family:monospace">read("idiv2.cxx")
</span></blockquote><p>
or by opening it in the program editor and validating it with the
<span style="font-family:monospace">OK</span> button.</p><p>Here are some more programs that you can play with. This first one
computes the GCD of two integers iteratively.
</p><pre class="verbatim"> pgcdi(a,b) := {
local r;
while (b != 0) {
r := irem(a,b);
a := b;
b := r;
}
return a;
}:;
</pre><p>
The second one computes the GCD recursively.
</p><pre class="verbatim"> pgcdr(a,b) := {
if (b == 0) return a;
return pgcdr(b, irem(a,b));
}:;
</pre><p>If a program doesn’t work the way you expect, you can run it in
step-by-step mode with the debug command. For more details, consult
the <span style="font-family:monospace">Interface</span> item of the <span style="font-family:monospace">Help</span> menu. For example,
you can start the debugging by typing
</p><blockquote class="quote"><span style="font-family:monospace">debug(idiv2(25,15))
</span></blockquote><p>
The debugger will automatically display the values of the parameters
<span style="font-family:monospace">a</span> and <span style="font-family:monospace">b</span> and local variables <span style="font-family:monospace">q</span> and
<span style="font-family:monospace">r</span> when executing the program line by line with the
<span style="font-family:monospace">sst</span> button.</p>
<!--TOC subsection id="sec42" Programming style-->
<h3 id="sec42" class="subsection">7.3  Programming style</h3><!--SEC END --><p>The <span style="font-family:monospace">Xcas</span> programming language is interpreted, not compiled.
The run time of an <span style="font-family:monospace">Xcas</span> program is affected by the number of
instructions rather than the number of lines. </p><p>The speed of a program does not always match up with the clarity of
the program; compromises are often necessary. For the most part, the
calculation time isn’t an issue; interpreted languages are often used
to test algorithms and create models. Full scale applications are
written in a compiled language like <span style="font-family:monospace">C++</span>. A <span style="font-family:monospace">C++</span> can
use <span style="font-family:monospace">giac</span> for the formal calculations.</p><p>When you are trying to write a fast program, you may want to take into
account the number of instructions and the speed of the instructions.
For example, it is in general faster to create lists and sequences
than it is to program loops. Recall than in <span style="font-family:monospace">Xcas</span> you can
find out how long it takes to run a command by entering
</p><blockquote class="quote"><span style="font-family:monospace">time(</span><span style="font-family:monospace"><span style="font-style:italic">command</span></span><span style="font-family:monospace">)
</span></blockquote>
<!--TOC section id="sec43" Exercises-->
<h2 id="sec43" class="section">8  Exercises</h2><!--SEC END --><p>There are usually several ways to get the same result in
<span style="font-family:monospace">Xcas</span>. We will try to use the simplest approaches.</p><div class="theorem"><span style="font-weight:bold">Exercise 1</span>  Verify the following identities.
<ol class="enumerate" type=1><li class="li-enumerate">
(2<sup>1/3</sup>+4<sup>1/3</sup>)<sup>3</sup>−6(2<sup>1/3</sup>+4<sup>1/3</sup>)=6
</li><li class="li-enumerate">π /4 = 4arctan(1/5)−arctan(1/239)
</li><li class="li-enumerate">sin(5<span style="font-style:italic">x</span>) = 5sin(<span style="font-style:italic">x</span>)−20sin<sup>3</sup>(<span style="font-style:italic">x</span>)+16sin<sup>5</sup>(<span style="font-style:italic">x</span>)
</li><li class="li-enumerate">(tan(<span style="font-style:italic">x</span>)+tan(<span style="font-style:italic">y</span>))cos(<span style="font-style:italic">x</span>)cos(<span style="font-style:italic">y</span>) = sin(<span style="font-style:italic">x</span>+<span style="font-style:italic">y</span>)
</li><li class="li-enumerate">cos<sup>6</sup>(<span style="font-style:italic">x</span>)+sin<sup>6</sup>(<span style="font-style:italic">x</span>) = 1−3sin<sup>2</sup>(<span style="font-style:italic">x</span>)cos<sup>2</sup>(<span style="font-style:italic">x</span>)
</li><li class="li-enumerate">ln(tan(<span style="font-style:italic">x</span>/2+π/4)) = argsinh(tan(<span style="font-style:italic">x</span>))
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 2</span>  Transform the rational expression
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>4</sup>+<span style="font-style:italic">x</span><sup>3</sup>−4<span style="font-style:italic">x</span><sup>2</sup>−4<span style="font-style:italic">x</span></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>4</sup>+<span style="font-style:italic">x</span><sup>3</sup>−<span style="font-style:italic">x</span><sup>2</sup>−<span style="font-style:italic">x</span></td></tr>
</table></td></tr>
</table>
into the following:
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">(<span style="font-style:italic">x</span>+2)(<span style="font-style:italic">x</span>+1)(<span style="font-style:italic">x</span>−2)</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>3</sup>+<span style="font-style:italic">x</span><sup>2</sup>−<span style="font-style:italic">x</span>−1</td></tr>
</table></td><td class="dcell">
 ,  
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>4</sup>+<span style="font-style:italic">x</span><sup>3</sup>−4<span style="font-style:italic">x</span><sup>2</sup>−4<span style="font-style:italic">x</span></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span>(<span style="font-style:italic">x</span>−1)(<span style="font-style:italic">x</span>+1)<sup>2</sup></td></tr>
</table></td><td class="dcell">
 ,  
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">(<span style="font-style:italic">x</span>+2)(<span style="font-style:italic">x</span>−2)</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">(<span style="font-style:italic">x</span>−1)(<span style="font-style:italic">x</span>+1)</td></tr>
</table></td><td class="dcell"> ,
</td></tr>
</table>
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>2</sup></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">(<span style="font-style:italic">x</span>−1)(<span style="font-style:italic">x</span>+1)</td></tr>
</table></td><td class="dcell">−</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">4</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">(<span style="font-style:italic">x</span>−1)(<span style="font-style:italic">x</span>+1)</td></tr>
</table></td><td class="dcell"> .
</td></tr>
</table>
</div><div class="theorem"><span style="font-weight:bold">Exercise 3</span>  Transform the rational expression
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">2</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>3</sup>−<span style="font-style:italic">yx</span><sup>2</sup>−<span style="font-style:italic">yx</span>+<span style="font-style:italic">y</span><sup>2</sup></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>3</sup>−<span style="font-style:italic">yx</span><sup>2</sup>−<span style="font-style:italic">x</span>+<span style="font-style:italic">y</span></td></tr>
</table></td></tr>
</table>
into the following
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">2</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>2</sup>−<span style="font-style:italic">y</span></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>2</sup>−1</td></tr>
</table></td><td class="dcell">
 ,  
2</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>2</sup>−<span style="font-style:italic">y</span></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">(<span style="font-style:italic">x</span>−1)(<span style="font-style:italic">x</span>+1)</td></tr>
</table></td><td class="dcell">
 ,
</td></tr>
</table>
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">2−</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">y</span>−1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span>−1</td></tr>
</table></td><td class="dcell">+</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">y</span>−1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span>+1</td></tr>
</table></td><td class="dcell">
 ,  
2−2</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">y</span>−1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span><sup>2</sup>−1</td></tr>
</table></td><td class="dcell"> .
</td></tr>
</table>
</div><div class="theorem"><span style="font-weight:bold">Exercise 4</span>  For each of the following definitions of a function <span style="font-style:italic">f</span>
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>) = </td><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" ><span style="font-style:italic">e</span><sup><span style="font-style:italic">x</span></sup>−1</td></tr>
</table></td><td class="dcell">
 ,  
<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>) = </td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><table class="display"><tr style="vertical-align:middle"><td class="dcell"><span style="font-style:italic">x</span></td><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" >1+<span style="font-style:italic">x</span><sup>2</sup></td></tr>
</table></td></tr>
</table></td></tr>
</table></td><td class="dcell">
 ,
</td></tr>
</table>
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>) = </td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">1+sin(<span style="font-style:italic">x</span>)+cos(<span style="font-style:italic">x</span>)</td></tr>
</table></td><td class="dcell">
 ,  
<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>) = </td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">ln(<span style="font-style:italic">x</span>)</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span>(<span style="font-style:italic">x</span><sup>2</sup>+1)<sup>2</sup></td></tr>
</table></td><td class="dcell">
 .
</td></tr>
</table>
<ol class="enumerate" type=1><li class="li-enumerate">
Find an antiderivative <span style="font-style:italic">F</span>.
</li><li class="li-enumerate">Find <span style="font-style:italic">F</span>′(<span style="font-style:italic">x</span>) and show that <span style="font-style:italic">F</span>′(<span style="font-style:italic">x</span>) can be simplified to <span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>).
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 5</span>  For each of the following integrals
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><span style="font-size:xx-large">∫</span></td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:left">−1</td></tr>
<tr><td class="dcell" style="text-align:left"><br>
<br>
</td></tr>
<tr><td class="dcell" style="text-align:left">−2</td></tr>
</table></td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span></td></tr>
</table></td><td class="dcell"> <span style="font-style:italic">dx</span> , 
</td><td class="dcell"><span style="font-size:xx-large">∫</span></td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:left">1</td></tr>
<tr><td class="dcell" style="text-align:left"><br>
<br>
</td></tr>
<tr><td class="dcell" style="text-align:left">0</td></tr>
</table></td><td class="dcell"> <span style="font-style:italic">x</span>arctan(<span style="font-style:italic">x</span>) <span style="font-style:italic">dx</span> ,
</td></tr>
</table>
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><span style="font-size:xx-large">∫</span></td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:left">π/2</td></tr>
<tr><td class="dcell" style="text-align:left"><br>
<br>
</td></tr>
<tr><td class="dcell" style="text-align:left">0</td></tr>
</table></td><td class="dcell"> </td><td class="dcell"><span style="font-size:x-large">√</span></td><td class="dcell"><table style="border:0;border-spacing:1;border-collapse:separate;" class="cellpadding0"><tr><td class="hbar"></td></tr>
<tr><td style="text-align:center;white-space:nowrap" >cos(<span style="font-style:italic">x</span>)</td></tr>
</table></td><td class="dcell"> <span style="font-style:italic">dx</span> , 
</td><td class="dcell"><span style="font-size:xx-large">∫</span></td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:left">π/2</td></tr>
<tr><td class="dcell" style="text-align:left"><br>
<br>
</td></tr>
<tr><td class="dcell" style="text-align:left">0</td></tr>
</table></td><td class="dcell"> <span style="font-style:italic">x</span><sup>4</sup>sin(<span style="font-style:italic">x</span>)cos(<span style="font-style:italic">x</span>) <span style="font-style:italic">dx</span> .
</td></tr>
</table>
<ol class="enumerate" type=1><li class="li-enumerate">
Find the exact value, and find an approximation.
</li><li class="li-enumerate">For <span style="font-style:italic">n</span>=100 and <span style="font-style:italic">n</span>=1000, do the following.
For each <span style="font-style:italic">j</span>=0,…,<span style="font-style:italic">n</span>, let <span style="font-style:italic">x</span><sub><span style="font-style:italic">j</span></sub>=<span style="font-style:italic">a</span>+<span style="font-style:italic">j</span>(<span style="font-style:italic">b</span>−<span style="font-style:italic">a</span>)/<span style="font-style:italic">n</span> and <span style="font-style:italic">y</span><sub><span style="font-style:italic">j</span></sub>=<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span><sub><span style="font-style:italic">j</span></sub>).
Find an approximate value for the integral by using the left endpoint
rule:
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">n</span>−1</td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-size:xx-large">∑</span></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">j</span>=0</td></tr>
</table></td><td class="dcell"> <span style="font-style:italic">f</span>(<span style="font-style:italic">x</span><sub><span style="font-style:italic">j</span></sub>)(<span style="font-style:italic">x</span><sub><span style="font-style:italic">j</span>+1</sub>−<span style="font-style:italic">x</span><sub><span style="font-style:italic">j</span></sub>) .
</td></tr>
</table>
</li><li class="li-enumerate">Do the same as the previous part, except use the trapezoid
method:
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">n</span>−1</td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-size:xx-large">∑</span></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">j</span>=0</td></tr>
</table></td><td class="dcell"> </td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">2</td></tr>
</table></td><td class="dcell">(<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span><sub><span style="font-style:italic">j</span></sub>)+<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span><sub><span style="font-style:italic">j</span>+1</sub>))(<span style="font-style:italic">x</span><sub><span style="font-style:italic">j</span>+1</sub>−<span style="font-style:italic">x</span><sub><span style="font-style:italic">j</span></sub>) .
</td></tr>
</table>
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 6</span>  Define the function <span style="font-style:italic">f</span> by
<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>,<span style="font-style:italic">y</span>)=cos(<span style="font-style:italic">xy</span>).
<ol class="enumerate" type=1><li class="li-enumerate">
Let <span style="font-style:italic">x</span><sub>0</sub>=<span style="font-style:italic">y</span><sub>0</sub>=π/4. Define the function that maps (<span style="font-style:italic">u</span>,<span style="font-style:italic">v</span>,<span style="font-style:italic">t</span>) to
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><span style="font-style:italic">f</span>(<span style="font-style:italic">x</span><sub>0</sub>+<span style="font-style:italic">ut</span>,<span style="font-style:italic">y</span><sub>0</sub>+<span style="font-style:italic">vt</span>) .</td></tr>
</table>
</li><li class="li-enumerate">Define the function <span style="font-style:italic">g</span> which is the partial derivative of the
preceding function with respect to <span style="font-style:italic">t</span> (so this will be a directional
derivative of <span style="font-style:italic">f</span>).
</li><li class="li-enumerate">Find the gradient of <span style="font-style:italic">f</span> at (<span style="font-style:italic">x</span><sub>0</sub>,<span style="font-style:italic">y</span><sub>0</sub>), then find the scalar product
of this gradient with the vector (<span style="font-style:italic">u</span>,<span style="font-style:italic">v</span>). Write this result in terms
of <span style="font-style:italic">g</span>.
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 7</span>  Consider <span style="font-style:italic">x</span><sup>3</sup>−(<span style="font-style:italic">a</span>−1)<span style="font-style:italic">x</span><sup>2</sup>+<span style="font-style:italic">a</span><sup>2</sup><span style="font-style:italic">x</span>−<span style="font-style:italic">a</span><sup>3</sup>=0 as an equation in <span style="font-style:italic">x</span>.
<ol class="enumerate" type=1><li class="li-enumerate">
Graph the solution <span style="font-style:italic">x</span> as a function of <span style="font-style:italic">a</span> using <span style="font-family:monospace">plotimplicit</span>.
</li><li class="li-enumerate">Find the three solutions of the equation. You can use <span style="font-family:monospace">rootof</span>
to find the first solution, then use <span style="font-family:monospace">quo</span> to factor out the
first solution. You can then find the last two solutions by solving
the resulting second degree equation. (You can use <span style="font-family:monospace">coeff</span> to
find the discriminant of the equation.)
</li><li class="li-enumerate">For the values of <span style="font-style:italic">a</span> which give three real roots, graph each of the
roots in different colors on the same graph.
(You can use <span style="font-family:monospace">resultant</span> to find the values of <span style="font-style:italic">a</span> for which the
equation has a multiple root; these values are the possible bounds of
intervals for <span style="font-style:italic">a</span> where each of the roots is real.)
</li><li class="li-enumerate">Find the solutions for <span style="font-style:italic">a</span>=0,1,2.
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 8</span>  For each of the limits
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"> </td></tr>
<tr><td class="dcell" style="text-align:center">lim</td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span>→ 0</td></tr>
</table></td><td class="dcell"> </td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">sin(<span style="font-style:italic">x</span>)</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span></td></tr>
</table></td><td class="dcell">
 , 
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"> </td></tr>
<tr><td class="dcell" style="text-align:center">lim</td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span>→ 0<sup>+</sup></td></tr>
</table></td><td class="dcell"> (sin(<span style="font-style:italic">x</span>))<sup>1/<span style="font-style:italic">x</span></sup>
 , 
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"> </td></tr>
<tr><td class="dcell" style="text-align:center">lim</td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span>→ +∞</td></tr>
</table></td><td class="dcell"> (1+1/<span style="font-style:italic">x</span>)<sup><span style="font-style:italic">x</span></sup>
 , 
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"> </td></tr>
<tr><td class="dcell" style="text-align:center">lim</td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span>→ +∞</td></tr>
</table></td><td class="dcell"> (2<sup><span style="font-style:italic">x</span></sup>+3<sup><span style="font-style:italic">x</span></sup>)<sup>1/<span style="font-style:italic">x</span></sup>
</td></tr>
</table>
<ol class="enumerate" type=1><li class="li-enumerate">
Find the exact value.
</li><li class="li-enumerate">Find a value of <span style="font-style:italic">x</span> such that the distance from <span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>) to the limit is
less than 10<sup>−3</sup>.
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 9</span>  For each function <span style="font-style:italic">f</span>, find ranges for the <span style="font-style:italic">x</span> coordinates and the <span style="font-style:italic">y</span>
coordinates that give the most informative graph.
<ol class="enumerate" type=1><li class="li-enumerate">
<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>)=1/<span style="font-style:italic">x</span>.
</li><li class="li-enumerate"><span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>)=<span style="font-style:italic">e</span><sup><span style="font-style:italic">x</span></sup>.
</li><li class="li-enumerate"><span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>)=1/sin(<span style="font-style:italic">x</span>).
</li><li class="li-enumerate"><span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>)=<span style="font-style:italic">x</span>/sin(<span style="font-style:italic">x</span>).
</li><li class="li-enumerate"><span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>)=sin(<span style="font-style:italic">x</span>)/<span style="font-style:italic">x</span>.
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 10</span>  Let
<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>)=3<span style="font-style:italic">x</span><sup>2</sup>+1+1/π<sup>4</sup>ln((π−<span style="font-style:italic">x</span>)<sup>2</sup>).
<ol class="enumerate" type=1><li class="li-enumerate">
Verify that this function takes negative values on ℝ<sup>+</sup>.
Graph the function over the interval [0,5].
</li><li class="li-enumerate">Find є >0 such that <span style="font-family:monospace">Xcas</span> gives the correct graph of the
function over the interval [π−є,π+є].
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 11</span>   
<ol class="enumerate" type=1><li class="li-enumerate">
Graph the function exp(<span style="font-style:italic">x</span>) over the interval [−1,1].
On the same graph, plot the Taylor polynomials (of orders 1,2,3 and 4)
for this function centered at <span style="font-style:italic">x</span>=0.
</li><li class="li-enumerate">Same question for the interval [1,2].
</li><li class="li-enumerate">Graph the function sin(<span style="font-style:italic">x</span>) on the interval [−π,π].
On the same graph, plot the Taylor polynomials (of orders 1,3 and 5)
for this function centered at <span style="font-style:italic">x</span>=0.
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 12</span>  Plot the following graphs on the same window, with <span style="font-style:italic">x</span> and <span style="font-style:italic">y</span>
coordinates from 0 to 1.
<ol class="enumerate" type=1><li class="li-enumerate">
The line <span style="font-style:italic">y</span>=<span style="font-style:italic">x</span>.
</li><li class="li-enumerate">The graph of the function <span style="font-style:italic">f</span> :  <span style="font-style:italic">x</span>↦ 1/6+<span style="font-style:italic">x</span>/3+<span style="font-style:italic">x</span><sup>2</sup>/2.
</li><li class="li-enumerate">The tangent line to the graph of <span style="font-style:italic">f</span> at <span style="font-style:italic">x</span>=1.
</li><li class="li-enumerate">The vertical line segment from the <span style="font-style:italic">x</span>-axis to the point where the
graph of <span style="font-style:italic">f</span> intersects the line <span style="font-style:italic">y</span>=<span style="font-style:italic">x</span>, and a horizontal line segment
from the <span style="font-style:italic">y</span>-axis to that point of intersection.
</li><li class="li-enumerate">The labels “fixed point” and “tangent”, at the appropriate positions.
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 13</span>  The goal of this exercise is to graph a family of functions on the
same screen. You will need to choose the number of curves, the
interval to graph over to obtain the most informative graphic.
<ol class="enumerate" type=1><li class="li-enumerate">
Functions <span style="font-style:italic">f</span><sub><span style="font-style:italic">a</span></sub>(<span style="font-style:italic">x</span>) = <span style="font-style:italic">x</span><sup><span style="font-style:italic">a</span></sup><span style="font-style:italic">e</span><sup>−<span style="font-style:italic">x</span></sup> for <span style="font-style:italic">a</span> from −1 to 1.
</li><li class="li-enumerate">Functions <span style="font-style:italic">f</span><sub><span style="font-style:italic">a</span></sub>(<span style="font-style:italic">x</span>)=1/(<span style="font-style:italic">x</span>−<span style="font-style:italic">a</span>)<sup>2</sup> for <span style="font-style:italic">a</span> from −1 to 1.
</li><li class="li-enumerate">Functions <span style="font-style:italic">f</span><sub><span style="font-style:italic">a</span></sub>(<span style="font-style:italic">x</span>)=sin(<span style="font-style:italic">ax</span>), for <span style="font-style:italic">a</span> from 0 to 2.
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 14</span>  Graph each of the following curves. You will need to choose a range
of values for the parameter to make sure you have the complete graph.
<ol class="enumerate" type=1><li class="li-enumerate">
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">⎧<br>
⎨<br>
⎩</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">x</span>(<span style="font-style:italic">t</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" >sin(<span style="font-style:italic">t</span>)</td></tr>
<tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">y</span>(<span style="font-style:italic">t</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" >cos<sup>3</sup>(<span style="font-style:italic">t</span>)
</td></tr>
</table></td><td class="dcell">
</td></tr>
</table>
</li><li class="li-enumerate"><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">⎧<br>
⎨<br>
⎩</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">x</span>(<span style="font-style:italic">t</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" >sin(4 <span style="font-style:italic">t</span>)</td></tr>
<tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">y</span>(<span style="font-style:italic">t</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" >cos<sup>3</sup>(6 <span style="font-style:italic">t</span>)
</td></tr>
</table></td><td class="dcell">
</td></tr>
</table>
</li><li class="li-enumerate"><table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">⎧<br>
⎨<br>
⎩</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">x</span>(<span style="font-style:italic">t</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" >sin(132 <span style="font-style:italic">t</span>)</td></tr>
<tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">y</span>(<span style="font-style:italic">t</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" >cos<sup>3</sup>(126 <span style="font-style:italic">t</span>)
</td></tr>
</table></td><td class="dcell">
</td></tr>
</table>
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 15</span>  The goal of this exercise is to visualize in different ways the
surface of the graph <span style="font-style:italic">z</span>=<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>,<span style="font-style:italic">y</span>)=<span style="font-style:italic">x</span> <span style="font-style:italic">y</span><sup>2</sup>. You will need to have a
3-d geometry window open.
<ol class="enumerate" type=1><li class="li-enumerate">
Use <span style="font-family:monospace">plotfunc</span> to draw an informative graph, choosing an
appropriate domain and number of steps.
</li><li class="li-enumerate">Create an editable parameter <span style="font-style:italic">a</span> with <span style="font-family:monospace">assume</span>. Draw the curve
<span style="font-style:italic">z</span>=<span style="font-style:italic">f</span>(<span style="font-style:italic">a</span>,<span style="font-style:italic">y</span>) and vary the parameter with the mouse.
</li><li class="li-enumerate">Create an editable parameter <span style="font-style:italic">b</span> with <span style="font-family:monospace">assume</span>. Draw the curve
<span style="font-style:italic">z</span>=<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span>,<span style="font-style:italic">b</span>) and vary the parameter with the mouse.
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 16</span>  The goal of this exercise is to visualize a cone in different ways.
<ol class="enumerate" type=1><li class="li-enumerate">
Draw the surface given by <span style="font-style:italic">z</span>=1−√<span style="text-decoration:overline"><span style="font-style:italic">x</span></span><sup><span style="text-decoration:overline">2</span></sup><span style="text-decoration:overline">+</span><span style="text-decoration:overline"><span style="font-style:italic">y</span></span><sup><span style="text-decoration:overline">2</span></sup>.
</li><li class="li-enumerate">Sketch the parameterized surface defined by
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">⎧<br>
⎪<br>
⎨<br>
⎪<br>
⎩</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">x</span>(<span style="font-style:italic">u</span>,<span style="font-style:italic">v</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">u</span> cos(<span style="font-style:italic">v</span>)</td></tr>
<tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">y</span>(<span style="font-style:italic">u</span>,<span style="font-style:italic">v</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">u</span> sin(<span style="font-style:italic">v</span>)</td></tr>
<tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">z</span>(<span style="font-style:italic">u</span>,<span style="font-style:italic">v</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" >1−<span style="font-style:italic">u</span> .
</td></tr>
</table></td><td class="dcell">
</td></tr>
</table>
</li><li class="li-enumerate">For a sufficiently large value of <span style="font-style:italic">a</span>, draw the curve parameterized by
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">⎧<br>
⎪<br>
⎨<br>
⎪<br>
⎩</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">x</span>(<span style="font-style:italic">t</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">t</span> cos(<span style="font-style:italic">a</span> <span style="font-style:italic">t</span>)</td></tr>
<tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">y</span>(<span style="font-style:italic">t</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">t</span> sin(<span style="font-style:italic">a</span> <span style="font-style:italic">t</span>)</td></tr>
<tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">z</span>(<span style="font-style:italic">t</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" >1−<span style="font-style:italic">t</span> .
</td></tr>
</table></td><td class="dcell">
</td></tr>
</table></li><li class="li-enumerate">Draw the family of curves parameterized by
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">⎧<br>
⎪<br>
⎨<br>
⎪<br>
⎩</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">x</span>(<span style="font-style:italic">t</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">a</span> cos(<span style="font-style:italic">t</span>)</td></tr>
<tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">y</span>(<span style="font-style:italic">t</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">a</span> sin(<span style="font-style:italic">t</span>)</td></tr>
<tr><td style="text-align:left;white-space:nowrap" ><span style="font-style:italic">z</span>(<span style="font-style:italic">t</span>)</td><td style="text-align:center;white-space:nowrap" >=</td><td style="text-align:left;white-space:nowrap" >1−<span style="font-style:italic">a</span> .
</td></tr>
</table></td><td class="dcell">
</td></tr>
</table>
</li><li class="li-enumerate">Draw the cone using the <span style="font-family:monospace">cone</span> function.
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 17</span>   
<ol class="enumerate" type=1><li class="li-enumerate">
Generate a list ℓ of 100 integers randomly generated between 1 and 9.
</li><li class="li-enumerate">Verify that all values in ℓ are in {1,…,9}.
</li><li class="li-enumerate">Extract from the list ℓ all values greater than or equal to 5.
</li><li class="li-enumerate">For each <span style="font-style:italic">k</span>=1,…,9, find the number of values in ℓ which are
equal to <span style="font-style:italic">k</span>.
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 18</span>  For a real number <span style="font-style:italic">x</span>, the continued fraction for <span style="font-style:italic">x</span> of order <span style="font-style:italic">n</span> is
a list of integers [<span style="font-style:italic">a</span><sub>0</sub>,…,<span style="font-style:italic">a</span><sub><span style="font-style:italic">n</span></sub>] created in the following way:
<ul class="itemize"><li class="li-itemize">
let <span style="font-style:italic">x</span><sub>0</sub> = <span style="font-style:italic">x</span>.
</li><li class="li-itemize">let <span style="font-style:italic">a</span><sub>0</sub> be the integer part of <span style="font-style:italic">x</span><sub>0</sub>.
</li><li class="li-itemize">let <span style="font-style:italic">x</span><sub>1</sub> = 1/(<span style="font-style:italic">x</span><sub>0</sub>−<span style="font-style:italic">a</span><sub>0</sub>).
</li><li class="li-itemize">for <span style="font-style:italic">k</span>=1,…,<span style="font-style:italic">n</span>, let <span style="font-style:italic">a</span><sub><span style="font-style:italic">k</span></sub> be the integer part of <span style="font-style:italic">x</span><sub><span style="font-style:italic">k</span></sub> and let
<span style="font-style:italic">x</span><sub><span style="font-style:italic">k</span>+1</sub> = 1/(<span style="font-style:italic">x</span><sub><span style="font-style:italic">k</span></sub> − <span style="font-style:italic">a</span><sub><span style="font-style:italic">k</span></sub>).
</li></ul>
The list [<span style="font-style:italic">a</span><sub>0</sub>,…,<span style="font-style:italic">a</span><sub><span style="font-style:italic">n</span></sub>] is associated with the fraction
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><span style="font-style:italic">u</span><sub><span style="font-style:italic">n</span></sub> = <span style="font-style:italic">a</span><sub>0</sub>+</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><table class="display"><tr style="vertical-align:middle"><td class="dcell"><span style="font-style:italic">a</span><sub>1</sub>+
</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><table class="display"><tr style="vertical-align:middle"><td class="dcell"><span style="font-style:italic">a</span><sub>2</sub>+</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><table class="display"><tr style="vertical-align:middle"><td class="dcell">⋱+</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">1</td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">a</span><sub><span style="font-style:italic">n</span></sub></td></tr>
</table></td></tr>
</table></td></tr>
</table></td></tr>
</table></td></tr>
</table></td></tr>
</table></td></tr>
</table></td></tr>
</table>
For <span style="font-style:italic">x</span>∈{π,√<span style="text-decoration:overline">2</span>, <span style="font-style:italic">e</span>} and <span style="font-style:italic">n</span>∈ {5,10} :
<ol class="enumerate" type=1><li class="li-enumerate">
Find [<span style="font-style:italic">a</span><sub>0</sub>,…,<span style="font-style:italic">a</span><sub><span style="font-style:italic">n</span></sub>].
</li><li class="li-enumerate">Compare your result with the value given by <span style="font-family:monospace">Xcas</span>’s <span style="font-family:monospace">dfc</span>
function.
</li><li class="li-enumerate">Find <span style="font-style:italic">u</span><sub><span style="font-style:italic">n</span></sub> and the numeric value of <span style="font-style:italic">x</span>−<span style="font-style:italic">u</span><sub><span style="font-style:italic">n</span></sub>.
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 19</span>  Write (without using a loop) the following sequences:
<ol class="enumerate" type=1><li class="li-enumerate">
The numbers from 1 to 3 in steps of 0.1.
</li><li class="li-enumerate">The numbers from 3 to 1 in steps of −0.1.
</li><li class="li-enumerate">The squares of the first 10 integers.
</li><li class="li-enumerate">Numbers of the form (−1)<sup><span style="font-style:italic">n</span></sup> <span style="font-style:italic">n</span><sup>2</sup> for <span style="font-style:italic">n</span>=1,…,10.
</li><li class="li-enumerate">10 “0”s followed by 10 “1”s.
</li><li class="li-enumerate">3 “0”s followed by 3 “1”s, followed by 3 “2”,…,
followed by 3 “9”s.
</li><li class="li-enumerate">“1” followed by 1 “0”, followed by a “2” followed by 2 “0”s,
…, followed by “8” followed by 8 “0”s, followed by “9”.
</li><li class="li-enumerate">1 “1” followed by 2 “2”s, followed by 3 “3”s,…,
followed by 9 “9”s.
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 20</span>   
<ol class="enumerate" type=1><li class="li-enumerate">
Define the following polynomials of degree 6.
<ol class="enumerate" type=a><li class="li-enumerate">
A polynomial whose roots are the integers from 1 to 6.
</li><li class="li-enumerate">A polynomial whose roots are 0 (triple root), 1
(double root) and 2 (simple root).
</li><li class="li-enumerate">The polynomial (<span style="font-style:italic">x</span><sup>2</sup>−1)<sup>3</sup>.
</li><li class="li-enumerate">The polynomial <span style="font-style:italic">x</span><sup>6</sup>−1.
</li></ol>
</li><li class="li-enumerate">Write (without using the <span style="font-family:monospace">companion</span> function)
the companion matrix <span style="font-style:italic">A</span> for each of the polynomials in (1).
Recall the the companion matrix for the polynomial
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><span style="font-style:italic">P</span>=<span style="font-style:italic">x</span><sup><span style="font-style:italic">d</span></sup>+<span style="font-style:italic">a</span><sub><span style="font-style:italic">d</span>−1</sub><span style="font-style:italic">x</span><sup><span style="font-style:italic">d</span>−1</sup>+⋯+<span style="font-style:italic">a</span><sub>1</sub><span style="font-style:italic">x</span>+<span style="font-style:italic">a</span><sub>0</sub> ,
</td></tr>
</table>
is
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">
<a id="compagnon"></a>
<span style="font-style:italic">A</span> = 
</td><td class="dcell">⎛<br>
⎜<br>
⎜<br>
⎜<br>
⎜<br>
⎜<br>
⎜<br>
⎝</td><td class="dcell">
</td><td class="dcell"><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="text-align:center;white-space:nowrap" >0</td><td style="text-align:center;white-space:nowrap" >1</td><td style="text-align:center;white-space:nowrap" >0</td><td style="text-align:center;white-space:nowrap" >…</td><td style="text-align:center;white-space:nowrap" > </td><td style="text-align:center;white-space:nowrap" >0</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >⋮</td><td style="text-align:center;white-space:nowrap" >⋱</td><td style="text-align:center;white-space:nowrap" >⋱</td><td style="text-align:center;white-space:nowrap" >⋱</td><td style="text-align:center;white-space:nowrap" > </td><td style="text-align:center;white-space:nowrap" >⋮</td></tr>
<tr><td style="text-align:center;white-space:nowrap" > </td><td style="text-align:center;white-space:nowrap" > </td><td style="text-align:center;white-space:nowrap" > </td><td style="text-align:center;white-space:nowrap" > </td><td style="text-align:center;white-space:nowrap" > </td><td style="text-align:center;white-space:nowrap" > </td></tr>
<tr><td style="text-align:center;white-space:nowrap" >⋮</td><td style="text-align:center;white-space:nowrap" > </td><td style="text-align:center;white-space:nowrap" > </td><td style="text-align:center;white-space:nowrap" >⋱</td><td style="text-align:center;white-space:nowrap" >⋱</td><td style="text-align:center;white-space:nowrap" >0</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >0</td><td style="text-align:center;white-space:nowrap" >…</td><td style="text-align:center;white-space:nowrap" > </td><td style="text-align:center;white-space:nowrap" >…</td><td style="text-align:center;white-space:nowrap" >0</td><td style="text-align:center;white-space:nowrap" >1</td></tr>
<tr><td style="text-align:center;white-space:nowrap" >−<span style="font-style:italic">a</span><sub>0</sub></td><td style="text-align:center;white-space:nowrap" >−<span style="font-style:italic">a</span><sub>1</sub></td><td style="text-align:center;white-space:nowrap" > </td><td style="text-align:center;white-space:nowrap" >…</td><td style="text-align:center;white-space:nowrap" > </td><td style="text-align:center;white-space:nowrap" >−<span style="font-style:italic">a</span><sub><span style="font-style:italic">d</span>−1</sub>
</td></tr>
</table></td><td class="dcell">
</td><td class="dcell">⎞<br>
⎟<br>
⎟<br>
⎟<br>
⎟<br>
⎟<br>
⎟<br>
⎠</td><td class="dcell"> .
    (1)</td></tr>
</table>
</li><li class="li-enumerate">Find the eigenvalues of the matrix <span style="font-style:italic">A</span>.
</li><li class="li-enumerate">Find the characteristic polynomial of <span style="font-style:italic">A</span>.
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 21</span>   
<ol class="enumerate" type=1><li class="li-enumerate">
For variables <span style="font-style:italic">a</span> and <span style="font-style:italic">b</span>, write the square matrix <span style="font-style:italic">A</span> of order 4 with
<span style="font-style:italic">a</span><sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span></sub>=<span style="font-style:italic">a</span> if <span style="font-style:italic">j</span>=<span style="font-style:italic">k</span> and <span style="font-style:italic">a</span><sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span></sub>=<span style="font-style:italic">b</span> if <span style="font-style:italic">j</span> ≠ <span style="font-style:italic">k</span>.
</li><li class="li-enumerate">Find and factor the characteristic polynomial of <span style="font-style:italic">A</span>.
</li><li class="li-enumerate">Find an orthogonal matrix <span style="font-style:italic">P</span> such that <span style="font-style:italic">P</span><sup><span style="font-style:italic">T</span></sup> <span style="font-style:italic">A</span> <span style="font-style:italic">P</span> is a diagonal
matrix.
</li><li class="li-enumerate">Use your answer to the previous question to define the function that
maps an integer <span style="font-style:italic">n</span> to the matrix <span style="font-style:italic">A</span><sup><span style="font-style:italic">n</span></sup>.
</li><li class="li-enumerate">Find <span style="font-style:italic">A</span><sup><span style="font-style:italic">k</span></sup> for <span style="font-style:italic">k</span>=1,…,6 by finding the matrix products. Check
that the function given in the previous part gives the same results.
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 22</span>   
<ol class="enumerate" type=1><li class="li-enumerate">
Find the square matrix <span style="font-style:italic">N</span> of order 6 given by <span style="font-style:italic">n</span><sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span></sub>=1 if
<span style="font-style:italic">k</span>=<span style="font-style:italic">j</span>+1 and <span style="font-style:italic">n</span><sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span></sub>=0 if <span style="font-style:italic">k</span> ≠ <span style="font-style:italic">j</span>+1.
</li><li class="li-enumerate">Find <span style="font-style:italic">N</span><sup><span style="font-style:italic">p</span></sup> for <span style="font-style:italic">p</span>=1,…,6.
</li><li class="li-enumerate">Write the matrix <span style="font-style:italic">A</span> = <span style="font-style:italic">xI</span>+<span style="font-style:italic">N</span>, where <span style="font-style:italic">x</span> is a variable.
</li><li class="li-enumerate">Find <span style="font-style:italic">A</span><sup><span style="font-style:italic">p</span></sup> for <span style="font-style:italic">p</span>=1,…,6.
</li><li class="li-enumerate">Find exp(<span style="font-style:italic">At</span>) as a function of <span style="font-style:italic">x</span> and <span style="font-style:italic">t</span> :
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">exp(<span style="font-style:italic">At</span>) = <span style="font-style:italic">I</span>+</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">∞</td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-size:xx-large">∑</span></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">p</span>=1</td></tr>
</table></td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">t</span><sup><span style="font-style:italic">p</span></sup></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center"><span style="font-style:italic">p</span>!</td></tr>
</table></td><td class="dcell"> <span style="font-style:italic">A</span><sup><span style="font-style:italic">p</span></sup> .
</td></tr>
</table>
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 23</span>  Define the following functions without using a loop.
<ol class="enumerate" type=1><li class="li-enumerate">
The function <span style="font-style:italic">f</span> which takes as input an integer <span style="font-style:italic">n</span> and two real
numbers <span style="font-style:italic">a</span> and <span style="font-style:italic">b</span> and returns the <span style="font-style:italic">n</span>× <span style="font-style:italic">n</span> matrix <span style="font-style:italic">A</span> whose
diagonal terms are all equal to <span style="font-style:italic">a</span> and whose non-diagonal entries are
equal to <span style="font-style:italic">b</span>.
</li><li class="li-enumerate">The function <span style="font-style:italic">g</span> which takes as input an integer <span style="font-style:italic">n</span> and three real
numbers <span style="font-style:italic">a</span>,<span style="font-style:italic">b</span> and <span style="font-style:italic">c</span>m and returns the matrix
<span style="font-style:italic">A</span>=(<span style="font-style:italic">a</span><sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span></sub>)<sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span>=1,…,<span style="font-style:italic">n</span></sub> whose diagonal elements are equal to
<span style="font-style:italic">a</span>, whose terms <span style="font-style:italic">a</span><sub><span style="font-style:italic">j</span>,<span style="font-style:italic">j</span>+1</sub> are equal to <span style="font-style:italic">b</span> and whose terms <span style="font-style:italic">a</span><sub><span style="font-style:italic">j</span>+1,<span style="font-style:italic">j</span></sub>
are equal to <span style="font-style:italic">c</span>, and whose remaining terms are 0.
</li><li class="li-enumerate">The function <span style="font-style:italic">H</span> which takes as input an integer <span style="font-style:italic">n</span> and returns
Hilbert’s Matrix; the matrix <span style="font-style:italic">A</span>=(<span style="font-style:italic">a</span><sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span></sub>)<sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span>=1,…,<span style="font-style:italic">n</span></sub> where
<span style="font-style:italic">a</span><sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span></sub> = 1/(<span style="font-style:italic">j</span>+<span style="font-style:italic">k</span>+1).
Compare the execution time of your function with that of the
<span style="font-family:monospace">hilbert</span> function.
</li><li class="li-enumerate">The function <span style="font-style:italic">V</span> which takes as input a vector <span style="font-style:italic">x</span>=[<span style="font-style:italic">x</span><sub>1</sub>,…,<span style="font-style:italic">x</span><sub><span style="font-style:italic">n</span></sub>] and
returns Vandermonde’s Matrix; the matrix
<span style="font-style:italic">A</span>=(<span style="font-style:italic">a</span><sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span></sub>)<sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span>=1,…,<span style="font-style:italic">n</span></sub> where <span style="font-style:italic">a</span><sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span></sub> = <span style="font-style:italic">x</span><sub><span style="font-style:italic">k</span></sub><sup><span style="font-style:italic">j</span>−1</sup>.
Compare the execution time of your function with that of the
<span style="font-family:monospace">vandermonde</span> function.
</li><li class="li-enumerate">The function <span style="font-style:italic">T</span> which takes as input a vector <span style="font-style:italic">x</span>=[<span style="font-style:italic">x</span><sub>1</sub>,…,<span style="font-style:italic">x</span><sub><span style="font-style:italic">n</span></sub>] and
returns the Toeplitz Matrix; the matrix
<span style="font-style:italic">A</span>=(<span style="font-style:italic">a</span><sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span></sub>)<sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span>=1,…,<span style="font-style:italic">n</span></sub> where
<span style="font-style:italic">a</span><sub><span style="font-style:italic">j</span>,<span style="font-style:italic">k</span></sub> = <span style="font-style:italic">x</span><sub>|<span style="font-style:italic">j</span>−<span style="font-style:italic">k</span>|+1</sub> .
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 24</span>  Write the following functions, which take as input a function <span style="font-style:italic">f</span>:ℝ
→ ℝ and three real numbers <span style="font-style:italic">x</span><sub><span style="font-style:italic">min</span></sub>, <span style="font-style:italic">x</span><sub>0</sub> and <span style="font-style:italic">x</span><sub><span style="font-style:italic">max</span></sub> with
<span style="font-style:italic">x</span><sub><span style="font-style:italic">min</span></sub>≤ <span style="font-style:italic">x</span><sub>0</sub> ≤ <span style="font-style:italic">x</span><sub><span style="font-style:italic">max</span></sub>.
<ol class="enumerate" type=1><li class="li-enumerate">
<span style="font-family:monospace">derive</span> :
This function calculates and graphs the derivative of <span style="font-style:italic">f</span> over the
interval [<span style="font-style:italic">x</span><sub><span style="font-style:italic">min</span></sub>,<span style="font-style:italic">x</span><sub><span style="font-style:italic">max</span></sub>] and returns <span style="font-style:italic">f</span>′(<span style="font-style:italic">x</span><sub>0</sub>).
</li><li class="li-enumerate"><span style="font-family:monospace">tangent</span> :
This function graphs the function <span style="font-style:italic">f</span> on the interval
[<span style="font-style:italic">x</span><sub><span style="font-style:italic">min</span></sub>,<span style="font-style:italic">x</span><sub><span style="font-style:italic">max</span></sub>] and in the same window draws the tangent to the
graph at <span style="font-style:italic">x</span><sub>0</sub>. It returns the equation for the tangent line as a
first degree polynomial.
</li><li class="li-enumerate"><span style="font-family:monospace">araignee</span> :
This function graphs the function <span style="font-style:italic">f</span> on the [<span style="font-style:italic">x</span><sub><span style="font-style:italic">min</span></sub>,<span style="font-style:italic">x</span><sub><span style="font-style:italic">max</span></sub>], as
well as the line <span style="font-style:italic">y</span>=<span style="font-style:italic">x</span>. It calculates and returns the first 10
iterates of <span style="font-style:italic">f</span> starting at <span style="font-style:italic">x</span><sub>0</sub> (so <span style="font-style:italic">x</span><sub>1</sub> = <span style="font-style:italic">f</span>(<span style="font-style:italic">x</span><sub>0</sub>), <span style="font-style:italic">x</span><sub>2</sub> =
<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span><sub>1</sub>),…). It also draws the sequence of segments, alternately
vertical and horizontal, allowing you to visualize the iterations:
segments joining (<span style="font-style:italic">x</span><sub>0</sub>,0), (<span style="font-style:italic">x</span><sub>0</sub>,<span style="font-style:italic">x</span><sub>1</sub>), (<span style="font-style:italic">x</span><sub>1</sub>,<span style="font-style:italic">x</span><sub>1</sub>),
(<span style="font-style:italic">x</span><sub>1</sub>,<span style="font-style:italic">x</span><sub>2</sub>), (<span style="font-style:italic">x</span><sub>2</sub>,<span style="font-style:italic">x</span><sub>2</sub>), …(compare this to the function <span style="font-family:monospace">plotseq</span>)
</li><li class="li-enumerate"><span style="font-family:monospace">newton_graph</span> :
This function graphs the function <span style="font-style:italic">f</span> over the interval [<span style="font-style:italic">x</span><sub><span style="font-style:italic">min</span></sub>,<span style="font-style:italic">x</span><sub><span style="font-style:italic">max</span></sub>].
It also calculates and returns the first ten iterates of the sequence
starting at <span style="font-style:italic">x</span><sub>0</sub> given by Newton’s Method: <span style="font-style:italic">x</span><sub>1</sub>=<span style="font-style:italic">x</span><sub>0</sub> −<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span><sub>0</sub>)/<span style="font-style:italic">f</span>′(<span style="font-style:italic">x</span><sub>0</sub>),
<span style="font-style:italic">x</span><sub>2</sub>=<span style="font-style:italic">x</span><sub>1</sub> − <span style="font-style:italic">f</span>(<span style="font-style:italic">x</span><sub>1</sub>)/<span style="font-style:italic">f</span>′(<span style="font-style:italic">x</span><sub>1</sub>) …  (The values of the derivative
should be approximated.) This function also graphs in the same window
the segments displaying the iterations: segments joining
(<span style="font-style:italic">x</span><sub>0</sub>,0), (<span style="font-style:italic">x</span><sub>0</sub>,<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span><sub>0</sub>)), (<span style="font-style:italic">x</span><sub>1</sub>,0),
(<span style="font-style:italic">x</span><sub>1</sub>,<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span><sub>1</sub>)), (<span style="font-style:italic">x</span><sub>2</sub>,0), (<span style="font-style:italic">x</span><sub>2</sub>,<span style="font-style:italic">f</span>(<span style="font-style:italic">x</span><sub>2</sub>)),…(compare with the function <span style="font-family:monospace">newton</span>)
</li></ol>
</div><div class="theorem"><span style="font-weight:bold">Exercise 25</span>  Let <span style="font-style:italic">D</span> be the unit square <span style="font-style:italic">D</span>=(0,1)<sup>2</sup>. Let Φ
be the function defined on <span style="font-style:italic">D</span> by
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell">Φ(<span style="font-style:italic">x</span>,<span style="font-style:italic">y</span>) = (<span style="font-style:italic">z</span>(<span style="font-style:italic">x</span>,<span style="font-style:italic">y</span>),<span style="font-style:italic">t</span>(<span style="font-style:italic">x</span>,<span style="font-style:italic">y</span>))=
</td><td class="dcell">⎛<br>
⎜<br>
⎜<br>
⎝</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">x</span></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">1+<span style="font-style:italic">y</span></td></tr>
</table></td><td class="dcell"> , </td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center"><span style="font-style:italic">y</span></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">1+<span style="font-style:italic">x</span></td></tr>
</table></td><td class="dcell">⎞<br>
⎟<br>
⎟<br>
⎠</td><td class="dcell"> .
</td></tr>
</table>
<ol class="enumerate" type=1><li class="li-enumerate">
Find the inverse of Φ.
</li><li class="li-enumerate">Find and graph the image under Φ of the domain <span style="font-style:italic">D</span>: Δ=Φ(<span style="font-style:italic">D</span>).
</li><li class="li-enumerate">Let <span style="font-style:italic">A</span>(<span style="font-style:italic">x</span>,<span style="font-style:italic">y</span>) be the Jacobian matrix of Φ at a point (<span style="font-style:italic">x</span>,<span style="font-style:italic">y</span>) in
<span style="font-style:italic">D</span>, and <span style="font-style:italic">B</span>(<span style="font-style:italic">z</span>,<span style="font-style:italic">t</span>) the Jacobian matrix of Φ<sup>−1</sup> at a point
(<span style="font-style:italic">x</span>,<span style="font-style:italic">y</span>) in Δ. Calculate these two matrices, and verify that
<span style="font-style:italic">B</span>(Φ(<span style="font-style:italic">x</span>,<span style="font-style:italic">y</span>)) and <span style="font-style:italic">A</span>(<span style="font-style:italic">x</span>,<span style="font-style:italic">y</span>) are inverses of each other.
</li><li class="li-enumerate">Let <span style="font-style:italic">J</span>(<span style="font-style:italic">z</span>,<span style="font-style:italic">t</span>) be the determinant of the matrix <span style="font-style:italic">B</span>. Calculate and simplify
<span style="font-style:italic">J</span>(<span style="font-style:italic">z</span>,<span style="font-style:italic">t</span>).
</li><li class="li-enumerate">Evaluate
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><span style="font-style:italic">I</span><sub>1</sub>=</td><td class="dcell"><span style="font-size:xx-large">∬</span></td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:left"> </td></tr>
<tr><td class="dcell" style="text-align:left"><br>
<br>
</td></tr>
<tr><td class="dcell" style="text-align:left"><span style="font-style:italic">D</span></td></tr>
</table></td><td class="dcell"> </td><td class="dcell">⎛<br>
⎜<br>
⎜<br>
⎝</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:center">1+<span style="font-style:italic">x</span>+<span style="font-style:italic">y</span></td></tr>
<tr><td class="hbar"></td></tr>
<tr><td class="dcell" style="text-align:center">(1+<span style="font-style:italic">x</span>)(1+<span style="font-style:italic">y</span>)</td></tr>
</table></td><td class="dcell"> </td><td class="dcell">⎞<br>
⎟<br>
⎟<br>
⎠</td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:left">3</td></tr>
<tr><td class="dcell" style="text-align:left"><br>
<br>
<br>
</td></tr>
<tr><td class="dcell" style="text-align:left"> </td></tr>
</table></td><td class="dcell">  <span style="font-style:italic">dxdy</span> .
</td></tr>
</table>
</li><li class="li-enumerate">Evaluate
<table class="display dcenter"><tr style="vertical-align:middle"><td class="dcell"><span style="font-style:italic">I</span><sub>2</sub>=</td><td class="dcell"><span style="font-size:xx-large">∬</span></td><td class="dcell"><table class="display"><tr><td class="dcell" style="text-align:left"> </td></tr>
<tr><td class="dcell" style="text-align:left"><br>
<br>
</td></tr>
<tr><td class="dcell" style="text-align:left">Δ</td></tr>
</table></td><td class="dcell"> (1+<span style="font-style:italic">z</span>)(1+<span style="font-style:italic">t</span>) <span style="font-style:italic">dzdt</span> ,
</td></tr>
</table>
and verify that <span style="font-style:italic">I</span><sub>1</sub>=<span style="font-style:italic">I</span><sub>2</sub>.
</li></ol>
</div><!--TOC section id="sec44" Index-->
<h2 id="sec44" class="section">Index</h2><!--SEC END --><p></p><table style="border-spacing:6px;border-collapse:separate;" class="cellpading0"><tr><td style="vertical-align:top;text-align:left;" ><ul class="indexenv"><li class="li-indexenv">
<span style="font-family:monospace">()</span>, <a href="#hevea_default135">3.5</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">-></span>, <a href="#hevea_default130">3.4</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">:=</span>, <a href="#hevea_default7">1.3</a>, <a href="#hevea_default45">3.2</a>, <a href="#hevea_default51">3.2</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">=</span>, <a href="#hevea_default59">3.2</a>, <a href="#hevea_default61">3.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">==</span>, <a href="#hevea_default52">3.2</a>, <a href="#hevea_default54">3.2</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">[]</span>, <a href="#hevea_default136">3.5</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">%{ %}</span>, <a href="#hevea_default137">3.5</a>
<br>
<br>
</li><li class="li-indexenv">All_trig_sol, <a href="#hevea_default22">2.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">abs</span>, <a href="#hevea_default73">3.4</a>
</li><li class="li-indexenv">absolute value, <a href="#hevea_default74">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">acos</span>, <a href="#hevea_default120">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">acosh</span>, <a href="#hevea_default126">3.4</a>
</li><li class="li-indexenv">addition, <a href="#hevea_default24">3.1</a>
</li><li class="li-indexenv">and, <a href="#hevea_default346">7.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">and</span>, <a href="#hevea_default48">3.2</a>
</li><li class="li-indexenv">antiderivatives, <a href="#hevea_default189">4.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">append</span>, <a href="#hevea_default144">3.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">apply</span>, <a href="#hevea_default145">3.5</a>
</li><li class="li-indexenv">arc<ul class="indexenv"><li class="li-indexenv">
cosine, <a href="#hevea_default121">3.4</a>
</li><li class="li-indexenv">sine, <a href="#hevea_default119">3.4</a>
</li><li class="li-indexenv">tangent, <a href="#hevea_default123">3.4</a>
</li></ul>
</li><li class="li-indexenv"><span style="font-family:monospace">arg</span>, <a href="#hevea_default92">3.4</a>
</li><li class="li-indexenv">argument, <a href="#hevea_default93">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">asc</span>, <a href="#hevea_default160">3.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">asin</span>, <a href="#hevea_default118">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">asinh</span>, <a href="#hevea_default124">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">assume</span>, <a href="#hevea_default47">3.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">atan</span>, <a href="#hevea_default122">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">atanh</span>, <a href="#hevea_default128">3.4</a>
<br>
<br>
</li><li class="li-indexenv">Bezout, <a href="#hevea_default212">5.1</a>
</li><li class="li-indexenv">Bezout’s identity, <a href="#hevea_default249">5.2</a>
</li><li class="li-indexenv">Booleans, <a href="#hevea_default53">3.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">blockmatrix</span>, <a href="#hevea_default281">5.4</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">canonical_form</span>, <a href="#hevea_default224">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">ceil</span>, <a href="#hevea_default84">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">char</span>, <a href="#hevea_default161">3.6</a>
</li><li class="li-indexenv">characters, <a href="#hevea_default169">3.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">circle</span>, <a href="#hevea_default317">6.2</a>, <a href="#hevea_default326">6.2</a>
</li><li class="li-indexenv">cloud of dots, <a href="#hevea_default325">6.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">coeff</span>, <a href="#hevea_default225">5.2</a>
</li><li class="li-indexenv">command line, <a href="#hevea_default2">1.1</a>, <a href="#hevea_default23">2.4</a>
</li><li class="li-indexenv">complex roots, <a href="#hevea_default21">2.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">concat</span>, <a href="#hevea_default163">3.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">cone</span>, <a href="#hevea_default340">6.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">conj</span>, <a href="#hevea_default90">3.4</a>
</li><li class="li-indexenv">conjugate, <a href="#hevea_default91">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">convert</span>, <a href="#hevea_default69">3.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">coordinates</span>, <a href="#hevea_default94">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">cos</span>, <a href="#hevea_default106">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">cosh</span>, <a href="#hevea_default114">3.4</a>
</li><li class="li-indexenv">cosine, <a href="#hevea_default107">3.4</a>
<ul class="indexenv"><li class="li-indexenv">
hyperbolic, <a href="#hevea_default115">3.4</a>
</li></ul>
</li><li class="li-indexenv">cotangent, <a href="#hevea_default111">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">cumSum</span>, <a href="#hevea_default142">3.5</a>
</li><li class="li-indexenv">cumulative sum, <a href="#hevea_default143">3.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">curl</span>, <a href="#hevea_default176">4.1</a>
</li><li class="li-indexenv">curve<ul class="indexenv"><li class="li-indexenv">
implicit, <a href="#hevea_default312">6</a>
</li><li class="li-indexenv">parametric, <a href="#hevea_default310">6</a>
</li><li class="li-indexenv">polar, <a href="#hevea_default311">6</a>
</li></ul>
</li><li class="li-indexenv"><span style="font-family:monospace">cyclotomic</span>, <a href="#hevea_default252">5.2</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">Digits</span>, <a href="#hevea_default18">2.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">degree</span>, <a href="#hevea_default229">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">desolve</span>, <a href="#hevea_default194">4.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">det</span>, <a href="#hevea_default274">5.4</a>
</li><li class="li-indexenv">determinant, <a href="#hevea_default287">5.4</a>
</li><li class="li-indexenv">diagonalization, <a href="#hevea_default295">5.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">diff</span>, <a href="#hevea_default170">4.1</a>
</li><li class="li-indexenv">divergence, <a href="#hevea_default175">4.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">divergence</span>, <a href="#hevea_default174">4.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">divis</span>, <a href="#hevea_default235">5.2</a>
</li><li class="li-indexenv">division, <a href="#hevea_default27">3.1</a>
</li><li class="li-indexenv">divisors, <a href="#hevea_default236">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">divpc</span>, <a href="#hevea_default250">5.2</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">e</span>, <a href="#hevea_default32">3.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">egcd</span>, <a href="#hevea_default248">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">eigenvals</span>, <a href="#hevea_default298">5.6</a>
</li><li class="li-indexenv">eigenvalues, <a href="#hevea_default302">5.6</a>
</li><li class="li-indexenv">eigenvectors, <a href="#hevea_default303">5.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">eigenvects</span>, <a href="#hevea_default299">5.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">else</span>, <a href="#hevea_default345">7.1</a>, <a href="#hevea_default351">7.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">epsilon</span>, <a href="#hevea_default19">2.3</a>, <a href="#hevea_default31">3.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">equation</span>, <a href="#hevea_default319">6.2</a>, <a href="#hevea_default327">6.2</a>
</li><li class="li-indexenv">equations, <a href="#hevea_default60">3.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">evalf</span>, <a href="#hevea_default5">1.2</a>, <a href="#hevea_default13">1.6</a>, <a href="#hevea_default29">3.1</a>, <a href="#hevea_default42">3.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">exact</span>, <a href="#hevea_default30">3.1</a>, <a href="#hevea_default43">3.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">exp</span>, <a href="#hevea_default98">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">exp2trig</span>, <a href="#hevea_default267">5.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">expand</span>, <a href="#hevea_default9">1.4</a>, <a href="#hevea_default63">3.3</a>, <a href="#hevea_default218">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">expr</span>, <a href="#hevea_default168">3.6</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">False</span>, <a href="#hevea_default58">3.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">factor</span>, <a href="#hevea_default10">1.4</a>, <a href="#hevea_default66">3.3</a>, <a href="#hevea_default233">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">factorial</span>, <a href="#hevea_default95">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">factors</span>, <a href="#hevea_default234">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">false</span>, <a href="#hevea_default57">3.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">floor</span>, <a href="#hevea_default83">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">for</span>, <a href="#hevea_default352">7.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">frac</span>, <a href="#hevea_default81">3.4</a>
</li><li class="li-indexenv">fractional part, <a href="#hevea_default82">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">froot</span>, <a href="#hevea_default237">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">fsolve</span>, <a href="#hevea_default191">4.4</a>
</li><li class="li-indexenv">function<ul class="indexenv"><li class="li-indexenv">
apply to a list, <a href="#hevea_default146">3.5</a>
</li></ul>
</li><li class="li-indexenv"><span style="font-family:monospace">function_diff</span>, <a href="#hevea_default171">4.1</a>
</li><li class="li-indexenv">functions, <a href="#hevea_default8">1.3</a>
<br>
<br>
</li><li class="li-indexenv">Gauss-Jordan, <a href="#hevea_default289">5.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">gcd</span>, <a href="#hevea_default209">5.1</a>, <a href="#hevea_default246">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">getDenom</span>, <a href="#hevea_default241">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">getNum</span>, <a href="#hevea_default240">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">grad</span>, <a href="#hevea_default172">4.1</a>
</li><li class="li-indexenv">gradient, <a href="#hevea_default173">4.1</a>
<br>
<br>
</li><li class="li-indexenv">Help index, <a href="#hevea_default12">1.6</a>, <a href="#hevea_default14">1.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">head</span>, <a href="#hevea_default165">3.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">hermite</span>, <a href="#hevea_default256">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">hessian</span>, <a href="#hevea_default178">4.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">horner</span>, <a href="#hevea_default223">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">hyp2exp</span>, <a href="#hevea_default268">5.3</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">i</span>, <a href="#hevea_default34">3.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">idivis</span>, <a href="#hevea_default208">5.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">idn</span>, <a href="#hevea_default277">5.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">egcd</span>, <a href="#hevea_default211">5.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">if</span>, <a href="#hevea_default344">7.1</a>, <a href="#hevea_default350">7.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">ifactor</span>, <a href="#hevea_default205">5.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">ifactors</span>, <a href="#hevea_default207">5.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">im</span>, <a href="#hevea_default88">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">image</span>, <a href="#hevea_default276">5.4</a>
</li><li class="li-indexenv">imaginary part, <a href="#hevea_default89">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">inf</span>, <a href="#hevea_default36">3.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">infinity</span>, <a href="#hevea_default35">3.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">int</span>, <a href="#hevea_default186">4.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">integer</span>, <a href="#hevea_default62">3.2</a>
</li><li class="li-indexenv">integrals, <a href="#hevea_default188">4.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">inter</span>, <a href="#hevea_default318">6.2</a>, <a href="#hevea_default341">6.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">interactive_plotode</span>, <a href="#hevea_default198">4.5</a>
</li><li class="li-indexenv">interface, <a href="#hevea_default15">2.1</a>
</li><li class="li-indexenv">intersection, <a href="#hevea_default320">6.2</a>
</li><li class="li-indexenv">inverse<ul class="indexenv"><li class="li-indexenv">
cosine hyperbolic, <a href="#hevea_default127">3.4</a>
</li><li class="li-indexenv">sine hyperbolic, <a href="#hevea_default125">3.4</a>
</li><li class="li-indexenv">tangent hyperbolic, <a href="#hevea_default129">3.4</a>
</li></ul>
</li><li class="li-indexenv"><span style="font-family:monospace">iquo</span>, <a href="#hevea_default202">5.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">iquorem</span>, <a href="#hevea_default204">5.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">irem</span>, <a href="#hevea_default200">5.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">isprime</span>, <a href="#hevea_default213">5.1</a>
<br>
<br>
</li><li class="li-indexenv">Jordan form, <a href="#hevea_default294">5.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">jordan</span>, <a href="#hevea_default293">5.6</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">ker</span>, <a href="#hevea_default275">5.4</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">lagrange</span>, <a href="#hevea_default254">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">laguerre</span>, <a href="#hevea_default258">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">laplacian</span>, <a href="#hevea_default177">4.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">lcm</span>, <a href="#hevea_default210">5.1</a>, <a href="#hevea_default247">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">lcoeff</span>, <a href="#hevea_default230">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">legend</span>, <a href="#hevea_default313">6.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">limit</span>, <a href="#hevea_default181">4.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">linsolve</span>, <a href="#hevea_default192">4.4</a>, <a href="#hevea_default290">5.5</a>
</li><li class="li-indexenv">list, <a href="#hevea_default133">3.5</a>
<ul class="indexenv"><li class="li-indexenv">
of coefficients, <a href="#hevea_default150">3.5</a>
</li></ul>
</li></ul></td><td style="vertical-align:top;text-align:left;" ><ul class="indexenv"><li class="li-indexenv">lists, <a href="#hevea_default152">3.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">ln</span>, <a href="#hevea_default100">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">log</span>, <a href="#hevea_default99">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">log10</span>, <a href="#hevea_default103">3.4</a>
</li><li class="li-indexenv">logarithm<ul class="indexenv"><li class="li-indexenv">
base 10, <a href="#hevea_default102">3.4</a>
</li><li class="li-indexenv">natural, <a href="#hevea_default101">3.4</a>
</li></ul>
</li><li class="li-indexenv">loop, <a href="#hevea_default353">7.1</a>
</li><li class="li-indexenv">loops, <a href="#hevea_default343">7.1</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">makematrix</span>, <a href="#hevea_default280">5.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">map</span>, <a href="#hevea_default147">3.5</a>
</li><li class="li-indexenv">matrix<ul class="indexenv"><li class="li-indexenv">
determinant, <a href="#hevea_default286">5.4</a>
</li><li class="li-indexenv">hessian, <a href="#hevea_default179">4.1</a>
</li><li class="li-indexenv">identity, <a href="#hevea_default282">5.4</a>
</li><li class="li-indexenv">image, <a href="#hevea_default285">5.4</a>
</li><li class="li-indexenv">kernel, <a href="#hevea_default284">5.4</a>
</li><li class="li-indexenv">rank, <a href="#hevea_default283">5.4</a>
</li></ul>
</li><li class="li-indexenv"><span style="font-family:monospace">matrix</span>, <a href="#hevea_default279">5.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">max</span>, <a href="#hevea_default76">3.4</a>
</li><li class="li-indexenv">maximum, <a href="#hevea_default77">3.4</a>
</li><li class="li-indexenv">menu bar, <a href="#hevea_default16">2.1</a>, <a href="#hevea_default17">2.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">mid</span>, <a href="#hevea_default139">3.5</a>, <a href="#hevea_default164">3.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">min</span>, <a href="#hevea_default78">3.4</a>
</li><li class="li-indexenv">minimum, <a href="#hevea_default79">3.4</a>
</li><li class="li-indexenv">multiplication, <a href="#hevea_default26">3.1</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">NULL</span>, <a href="#hevea_default138">3.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">nextprime</span>, <a href="#hevea_default215">5.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">normal</span>, <a href="#hevea_default64">3.3</a>, <a href="#hevea_default217">5.2</a>
</li><li class="li-indexenv">not, <a href="#hevea_default348">7.1</a>
</li><li class="li-indexenv">number<ul class="indexenv"><li class="li-indexenv">
prime, <a href="#hevea_default214">5.1</a>
</li></ul>
</li><li class="li-indexenv">numbers<ul class="indexenv"><li class="li-indexenv">
approximate, <a href="#hevea_default4">1.2</a>, <a href="#hevea_default37">3.1</a>
</li><li class="li-indexenv">exact, <a href="#hevea_default3">1.2</a>, <a href="#hevea_default38">3.1</a>, <a href="#hevea_default39">3.1</a>
</li><li class="li-indexenv">hexadecimal, <a href="#hevea_default41">3.1</a>
</li><li class="li-indexenv">octal, <a href="#hevea_default40">3.1</a>
</li></ul>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">odesolve</span>, <a href="#hevea_default195">4.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">open_polygon</span>, <a href="#hevea_default324">6.2</a>, <a href="#hevea_default337">6.3</a>
</li><li class="li-indexenv">or, <a href="#hevea_default347">7.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">or</span>, <a href="#hevea_default49">3.2</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">parameq</span>, <a href="#hevea_default328">6.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">partfrac</span>, <a href="#hevea_default72">3.3</a>, <a href="#hevea_default243">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">pcar</span>, <a href="#hevea_default296">5.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">pcoeff</span>, <a href="#hevea_default228">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">peval</span>, <a href="#hevea_default222">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">pi</span>, <a href="#hevea_default33">3.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">plane</span>, <a href="#hevea_default338">6.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">plotpolar</span>, <a href="#hevea_default308">6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">plot</span>, <a href="#hevea_default11">1.5</a>, <a href="#hevea_default304">6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">plotfield</span>, <a href="#hevea_default196">4.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">plotfunc</span>, <a href="#hevea_default305">6</a>, <a href="#hevea_default331">6.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">plotimplicit</span>, <a href="#hevea_default309">6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">plotode</span>, <a href="#hevea_default197">4.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">plotparam</span>, <a href="#hevea_default307">6</a>, <a href="#hevea_default332">6.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">pmin</span>, <a href="#hevea_default297">5.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">point</span>, <a href="#hevea_default315">6.2</a>, <a href="#hevea_default333">6.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">poly2symb</span>, <a href="#hevea_default148">3.5</a>, <a href="#hevea_default226">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">polygon</span>, <a href="#hevea_default323">6.2</a>, <a href="#hevea_default336">6.3</a>
</li><li class="li-indexenv">polygonal line, <a href="#hevea_default321">6.2</a>, <a href="#hevea_default334">6.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">polygonplot</span>, <a href="#hevea_default322">6.2</a>, <a href="#hevea_default335">6.3</a>
</li><li class="li-indexenv">polynomial<ul class="indexenv"><li class="li-indexenv">
characteristic, <a href="#hevea_default300">5.6</a>
</li><li class="li-indexenv">cyclotomic, <a href="#hevea_default253">5.2</a>
</li><li class="li-indexenv">Hermite, <a href="#hevea_default257">5.2</a>
</li><li class="li-indexenv">Lagrange, <a href="#hevea_default255">5.2</a>
</li><li class="li-indexenv">Laguerre, <a href="#hevea_default259">5.2</a>
</li><li class="li-indexenv">minimal, <a href="#hevea_default301">5.6</a>
</li><li class="li-indexenv">Taylor, <a href="#hevea_default220">5.2</a>
</li><li class="li-indexenv">Tchebyshev, <a href="#hevea_default261">5.2</a>
</li></ul>
</li><li class="li-indexenv">power, <a href="#hevea_default28">3.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">powmod</span>, <a href="#hevea_default199">5.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">previousprime</span>, <a href="#hevea_default216">5.1</a>
</li><li class="li-indexenv">prime factors, <a href="#hevea_default206">5.1</a>
</li><li class="li-indexenv">product<ul class="indexenv"><li class="li-indexenv">
cross, <a href="#hevea_default270">5.4</a>
</li><li class="li-indexenv">matrix, <a href="#hevea_default271">5.4</a>
</li><li class="li-indexenv">scalar, <a href="#hevea_default269">5.4</a>
</li><li class="li-indexenv">term by term, <a href="#hevea_default272">5.4</a>
</li></ul>
</li><li class="li-indexenv"><span style="font-family:monospace">product</span>, <a href="#hevea_default141">3.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">proot</span>, <a href="#hevea_default193">4.4</a>, <a href="#hevea_default238">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">propfrac</span>, <a href="#hevea_default242">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">ptayl</span>, <a href="#hevea_default219">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">purge</span>, <a href="#hevea_default50">3.2</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">quo</span>, <a href="#hevea_default244">5.2</a>
</li><li class="li-indexenv">quotient, <a href="#hevea_default203">5.1</a>
<br>
<br>
</li><li class="li-indexenv">radian, <a href="#hevea_default20">2.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">randpoly</span>, <a href="#hevea_default251">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">rank</span>, <a href="#hevea_default273">5.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">ranm</span>, <a href="#hevea_default278">5.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">ratnormal</span>, <a href="#hevea_default65">3.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">re</span>, <a href="#hevea_default86">3.4</a>
</li><li class="li-indexenv">real part, <a href="#hevea_default87">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">rem</span>, <a href="#hevea_default245">5.2</a>
</li><li class="li-indexenv">remainder, <a href="#hevea_default201">5.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">romberg</span>, <a href="#hevea_default187">4.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">round</span>, <a href="#hevea_default80">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">rref</span>, <a href="#hevea_default292">5.5</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">scatterplot</span>, <a href="#hevea_default329">6.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">segment</span>, <a href="#hevea_default316">6.2</a>
</li><li class="li-indexenv">sequence, <a href="#hevea_default132">3.5</a>
</li><li class="li-indexenv">sequences, <a href="#hevea_default151">3.5</a>
</li><li class="li-indexenv">series, <a href="#hevea_default184">4.2</a>
<ul class="indexenv"><li class="li-indexenv">
Taylor, <a href="#hevea_default185">4.2</a>
</li></ul>
</li><li class="li-indexenv"><span style="font-family:monospace">series</span>, <a href="#hevea_default183">4.2</a>
</li><li class="li-indexenv">set, <a href="#hevea_default134">3.5</a>
</li><li class="li-indexenv">sets, <a href="#hevea_default153">3.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">sign</span>, <a href="#hevea_default75">3.4</a>
</li><li class="li-indexenv">simplifications, <a href="#hevea_default70">3.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">simplify</span>, <a href="#hevea_default67">3.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">simult</span>, <a href="#hevea_default291">5.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">sin</span>, <a href="#hevea_default104">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">sincos</span>, <a href="#hevea_default71">3.3</a>
</li><li class="li-indexenv">sine, <a href="#hevea_default105">3.4</a>
<ul class="indexenv"><li class="li-indexenv">
hyperbolic, <a href="#hevea_default113">3.4</a>
</li></ul>
</li><li class="li-indexenv"><span style="font-family:monospace">sinh</span>, <a href="#hevea_default112">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">size</span>, <a href="#hevea_default162">3.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">solve</span>, <a href="#hevea_default190">4.4</a>
</li><li class="li-indexenv">space, <a href="#hevea_default330">6.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">sphere</span>, <a href="#hevea_default339">6.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">sqrt</span>, <a href="#hevea_default96">3.4</a>
</li><li class="li-indexenv">square root, <a href="#hevea_default97">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">string</span>, <a href="#hevea_default167">3.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">sturmab</span>, <a href="#hevea_default239">5.2</a>
</li><li class="li-indexenv">sublist, <a href="#hevea_default158">3.5</a>
</li><li class="li-indexenv">sublists, <a href="#hevea_default156">3.5</a>
</li><li class="li-indexenv">submatrix, <a href="#hevea_default288">5.4</a>
</li><li class="li-indexenv">subsequence, <a href="#hevea_default157">3.5</a>
</li><li class="li-indexenv">subsequences, <a href="#hevea_default155">3.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">subst</span>, <a href="#hevea_default46">3.2</a>
</li><li class="li-indexenv">subtraction, <a href="#hevea_default25">3.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">sum</span>, <a href="#hevea_default140">3.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">symb2poly</span>, <a href="#hevea_default149">3.5</a>, <a href="#hevea_default227">5.2</a>
<br>
<br>
</li><li class="li-indexenv">Taylor polynomial, <a href="#hevea_default221">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">True</span>, <a href="#hevea_default56">3.2</a>
</li><li class="li-indexenv">tables, <a href="#hevea_default154">3.5</a>, <a href="#hevea_default159">3.5</a>
</li><li class="li-indexenv"><span style="font-family:monospace">tail</span>, <a href="#hevea_default166">3.6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">cot</span>, <a href="#hevea_default110">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">tan</span>, <a href="#hevea_default108">3.4</a>
</li><li class="li-indexenv">tangent, <a href="#hevea_default109">3.4</a>
<ul class="indexenv"><li class="li-indexenv">
hyperbolic, <a href="#hevea_default117">3.4</a>
</li></ul>
</li><li class="li-indexenv"><span style="font-family:monospace">tangent</span>, <a href="#hevea_default306">6</a>
</li><li class="li-indexenv"><span style="font-family:monospace">tanh</span>, <a href="#hevea_default116">3.4</a>
</li><li class="li-indexenv"><span style="font-family:monospace">taylor</span>, <a href="#hevea_default182">4.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">tchebyshev1</span>, <a href="#hevea_default260">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">tchebyshev2</span>, <a href="#hevea_default262">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">tcoeff</span>, <a href="#hevea_default232">5.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">tcollect</span>, <a href="#hevea_default264">5.3</a>
</li><li class="li-indexenv">test, <a href="#hevea_default342">7.1</a>, <a href="#hevea_default349">7.1</a>
</li><li class="li-indexenv"><span style="font-family:monospace">texpand</span>, <a href="#hevea_default265">5.3</a>
</li><li class="li-indexenv">text, <a href="#hevea_default314">6.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">tlin</span>, <a href="#hevea_default263">5.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">trig2exp</span>, <a href="#hevea_default266">5.3</a>
</li><li class="li-indexenv"><span style="font-family:monospace">true</span>, <a href="#hevea_default55">3.2</a>
</li><li class="li-indexenv"><span style="font-family:monospace">tsimplify</span>, <a href="#hevea_default68">3.3</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">unapply</span>, <a href="#hevea_default131">3.4</a>, <a href="#hevea_default180">4.1</a>
<br>
<br>
</li><li class="li-indexenv"><span style="font-family:monospace">valuation</span>, <a href="#hevea_default231">5.2</a>
</li><li class="li-indexenv">variables, <a href="#hevea_default6">1.3</a>, <a href="#hevea_default44">3.2</a>
<br>
<br>
</li><li class="li-indexenv">whole part, <a href="#hevea_default85">3.4</a>
<br>
<br>
</li><li class="li-indexenv">Xcas<ul class="indexenv"><li class="li-indexenv">
getting, <a href="#hevea_default1">1.1</a>
</li><li class="li-indexenv">starting, <a href="#hevea_default0">1.1</a>
</li></ul>
</li></ul></td></tr>
</table><!--CUT END -->
<!--HTMLFOOT-->
<!--ENDHTML-->
<!--FOOTER-->
<hr style="height:2"><blockquote class="quote"><em>This document was translated from L<sup>A</sup>T<sub>E</sub>X by
</em><a href="http://hevea.inria.fr/index.html"><em>H</em><em><span style="font-size:small"><sup>E</sup></span></em><em>V</em><em><span style="font-size:small"><sup>E</sup></span></em><em>A</em></a><em>.</em></blockquote></body>
</html>
|