comparison man/calc.texi @ 58970:3dc0b0b0b0cb

Consistently capitalized all mode names. (Answers to Exercises): Mention that an answer can be a fraction when in Fraction mode.
author Jay Belanger <jay.p.belanger@gmail.com>
date Wed, 15 Dec 2004 06:33:24 +0000
parents 061e79e10789
children ba6d401365b5
comparison
equal deleted inserted replaced
58969:eae7969f1b06 58970:3dc0b0b0b0cb
461 461
462 @item 462 @item
463 Moving data to and from regular editing buffers. 463 Moving data to and from regular editing buffers.
464 464
465 @item 465 @item
466 ``Embedded mode'' for manipulating Calc formulas and data directly 466 Embedded mode for manipulating Calc formulas and data directly
467 inside any editing buffer. 467 inside any editing buffer.
468 468
469 @item 469 @item
470 Graphics using GNUPLOT, a versatile (and free) plotting program. 470 Graphics using GNUPLOT, a versatile (and free) plotting program.
471 471
764 @section Using Calc 764 @section Using Calc
765 765
766 @noindent 766 @noindent
767 Calc has several user interfaces that are specialized for 767 Calc has several user interfaces that are specialized for
768 different kinds of tasks. As well as Calc's standard interface, 768 different kinds of tasks. As well as Calc's standard interface,
769 there are Quick Mode, Keypad Mode, and Embedded Mode. 769 there are Quick mode, Keypad mode, and Embedded mode.
770 770
771 @menu 771 @menu
772 * Starting Calc:: 772 * Starting Calc::
773 * The Standard Interface:: 773 * The Standard Interface::
774 * Quick Mode Overview:: 774 * Quick Mode Overview::
799 you will follow @kbd{M-#} with a letter (upper- or lower-case, it 799 you will follow @kbd{M-#} with a letter (upper- or lower-case, it
800 doesn't matter for @kbd{M-#}) that says which Calc interface you 800 doesn't matter for @kbd{M-#}) that says which Calc interface you
801 want to use. 801 want to use.
802 802
803 To get Calc's standard interface, type @kbd{M-# c}. To get 803 To get Calc's standard interface, type @kbd{M-# c}. To get
804 Keypad Mode, type @kbd{M-# k}. Type @kbd{M-# ?} to get a brief 804 Keypad mode, type @kbd{M-# k}. Type @kbd{M-# ?} to get a brief
805 list of the available options, and type a second @kbd{?} to get 805 list of the available options, and type a second @kbd{?} to get
806 a complete list. 806 a complete list.
807 807
808 To ease typing, @kbd{M-# M-#} (or @kbd{M-# #} if that's easier) 808 To ease typing, @kbd{M-# M-#} (or @kbd{M-# #} if that's easier)
809 also works to start Calc. It starts the same interface (either 809 also works to start Calc. It starts the same interface (either
812 a special function key set up to act like @kbd{M-#}, hitting that 812 a special function key set up to act like @kbd{M-#}, hitting that
813 function key twice is just like hitting @kbd{M-# M-#}.) 813 function key twice is just like hitting @kbd{M-# M-#}.)
814 814
815 If @kbd{M-#} doesn't work for you, you can always type explicit 815 If @kbd{M-#} doesn't work for you, you can always type explicit
816 commands like @kbd{M-x calc} (for the standard user interface) or 816 commands like @kbd{M-x calc} (for the standard user interface) or
817 @w{@kbd{M-x calc-keypad}} (for Keypad Mode). First type @kbd{M-x} 817 @w{@kbd{M-x calc-keypad}} (for Keypad mode). First type @kbd{M-x}
818 (that's Meta with the letter @kbd{x}), then, at the prompt, 818 (that's Meta with the letter @kbd{x}), then, at the prompt,
819 type the full command (like @kbd{calc-keypad}) and press Return. 819 type the full command (like @kbd{calc-keypad}) and press Return.
820 820
821 The same commands (like @kbd{M-# c} or @kbd{M-# M-#}) that start 821 The same commands (like @kbd{M-# c} or @kbd{M-# M-#}) that start
822 the Calculator also turn it off if it is already on. 822 the Calculator also turn it off if it is already on.
915 915
916 @node Quick Mode Overview, Keypad Mode Overview, The Standard Interface, Using Calc 916 @node Quick Mode Overview, Keypad Mode Overview, The Standard Interface, Using Calc
917 @subsection Quick Mode (Overview) 917 @subsection Quick Mode (Overview)
918 918
919 @noindent 919 @noindent
920 @dfn{Quick Mode} is a quick way to use Calc when you don't need the 920 @dfn{Quick mode} is a quick way to use Calc when you don't need the
921 full complexity of the stack and trail. To use it, type @kbd{M-# q} 921 full complexity of the stack and trail. To use it, type @kbd{M-# q}
922 (@code{quick-calc}) in any regular editing buffer. 922 (@code{quick-calc}) in any regular editing buffer.
923 923
924 Quick Mode is very simple: It prompts you to type any formula in 924 Quick mode is very simple: It prompts you to type any formula in
925 standard algebraic notation (like @samp{4 - 2/3}) and then displays 925 standard algebraic notation (like @samp{4 - 2/3}) and then displays
926 the result at the bottom of the Emacs screen (@mathit{3.33333333333} 926 the result at the bottom of the Emacs screen (@mathit{3.33333333333}
927 in this case). You are then back in the same editing buffer you 927 in this case). You are then back in the same editing buffer you
928 were in before, ready to continue editing or to type @kbd{M-# q} 928 were in before, ready to continue editing or to type @kbd{M-# q}
929 again to do another quick calculation. The result of the calculation 929 again to do another quick calculation. The result of the calculation
930 will also be in the Emacs ``kill ring'' so that a @kbd{C-y} command 930 will also be in the Emacs ``kill ring'' so that a @kbd{C-y} command
931 at this point will yank the result into your editing buffer. 931 at this point will yank the result into your editing buffer.
932 932
933 Calc mode settings affect Quick Mode, too, though you will have to 933 Calc mode settings affect Quick mode, too, though you will have to
934 go into regular Calc (with @kbd{M-# c}) to change the mode settings. 934 go into regular Calc (with @kbd{M-# c}) to change the mode settings.
935 935
936 @c [fix-ref Quick Calculator mode] 936 @c [fix-ref Quick Calculator mode]
937 @xref{Quick Calculator}, for further information. 937 @xref{Quick Calculator}, for further information.
938 938
939 @node Keypad Mode Overview, Standalone Operation, Quick Mode Overview, Using Calc 939 @node Keypad Mode Overview, Standalone Operation, Quick Mode Overview, Using Calc
940 @subsection Keypad Mode (Overview) 940 @subsection Keypad Mode (Overview)
941 941
942 @noindent 942 @noindent
943 @dfn{Keypad Mode} is a mouse-based interface to the Calculator. 943 @dfn{Keypad mode} is a mouse-based interface to the Calculator.
944 It is designed for use with terminals that support a mouse. If you 944 It is designed for use with terminals that support a mouse. If you
945 don't have a mouse, you will have to operate keypad mode with your 945 don't have a mouse, you will have to operate Keypad mode with your
946 arrow keys (which is probably more trouble than it's worth). 946 arrow keys (which is probably more trouble than it's worth).
947 947
948 Type @kbd{M-# k} to turn Keypad Mode on or off. Once again you 948 Type @kbd{M-# k} to turn Keypad mode on or off. Once again you
949 get two new windows, this time on the righthand side of the screen 949 get two new windows, this time on the righthand side of the screen
950 instead of at the bottom. The upper window is the familiar Calc 950 instead of at the bottom. The upper window is the familiar Calc
951 Stack; the lower window is a picture of a typical calculator keypad. 951 Stack; the lower window is a picture of a typical calculator keypad.
952 952
953 @tex 953 @tex
979 |-----+-----+-----+-----+-----| 979 |-----+-----+-----+-----+-----|
980 | OFF | 0 | . | PI | + | 980 | OFF | 0 | . | PI | + |
981 |-----+-----+-----+-----+-----+ 981 |-----+-----+-----+-----+-----+
982 @end smallexample 982 @end smallexample
983 983
984 Keypad Mode is much easier for beginners to learn, because there 984 Keypad mode is much easier for beginners to learn, because there
985 is no need to memorize lots of obscure key sequences. But not all 985 is no need to memorize lots of obscure key sequences. But not all
986 commands in regular Calc are available on the Keypad. You can 986 commands in regular Calc are available on the Keypad. You can
987 always switch the cursor into the Calc stack window to use 987 always switch the cursor into the Calc stack window to use
988 standard Calc commands if you need. Serious Calc users, though, 988 standard Calc commands if you need. Serious Calc users, though,
989 often find they prefer the standard interface over Keypad Mode. 989 often find they prefer the standard interface over Keypad mode.
990 990
991 To operate the Calculator, just click on the ``buttons'' of the 991 To operate the Calculator, just click on the ``buttons'' of the
992 keypad using your left mouse button. To enter the two numbers 992 keypad using your left mouse button. To enter the two numbers
993 shown here you would click @w{@kbd{1 7 .@: 3 ENTER 5 +/- ENTER}}; to 993 shown here you would click @w{@kbd{1 7 .@: 3 ENTER 5 +/- ENTER}}; to
994 add them together you would then click @kbd{+} (to get 12.3 on 994 add them together you would then click @kbd{+} (to get 12.3 on
997 If you click the right mouse button, the top three rows of the 997 If you click the right mouse button, the top three rows of the
998 keypad change to show other sets of commands, such as advanced 998 keypad change to show other sets of commands, such as advanced
999 math functions, vector operations, and operations on binary 999 math functions, vector operations, and operations on binary
1000 numbers. 1000 numbers.
1001 1001
1002 Because Keypad Mode doesn't use the regular keyboard, Calc leaves 1002 Because Keypad mode doesn't use the regular keyboard, Calc leaves
1003 the cursor in your original editing buffer. You can type in 1003 the cursor in your original editing buffer. You can type in
1004 this buffer in the usual way while also clicking on the Calculator 1004 this buffer in the usual way while also clicking on the Calculator
1005 keypad. One advantage of Keypad Mode is that you don't need an 1005 keypad. One advantage of Keypad mode is that you don't need an
1006 explicit command to switch between editing and calculating. 1006 explicit command to switch between editing and calculating.
1007 1007
1008 If you press @kbd{M-# b} first, you get a full-screen Keypad Mode 1008 If you press @kbd{M-# b} first, you get a full-screen Keypad mode
1009 (@code{full-calc-keypad}) with three windows: The keypad in the lower 1009 (@code{full-calc-keypad}) with three windows: The keypad in the lower
1010 left, the stack in the lower right, and the trail on top. 1010 left, the stack in the lower right, and the trail on top.
1011 1011
1012 @c [fix-ref Keypad Mode] 1012 @c [fix-ref Keypad Mode]
1013 @xref{Keypad Mode}, for further information. 1013 @xref{Keypad Mode}, for further information.
1041 1041
1042 @node Embedded Mode Overview, Other M-# Commands, Standalone Operation, Using Calc 1042 @node Embedded Mode Overview, Other M-# Commands, Standalone Operation, Using Calc
1043 @subsection Embedded Mode (Overview) 1043 @subsection Embedded Mode (Overview)
1044 1044
1045 @noindent 1045 @noindent
1046 @dfn{Embedded Mode} is a way to use Calc directly from inside an 1046 @dfn{Embedded mode} is a way to use Calc directly from inside an
1047 editing buffer. Suppose you have a formula written as part of a 1047 editing buffer. Suppose you have a formula written as part of a
1048 document like this: 1048 document like this:
1049 1049
1050 @smallexample 1050 @smallexample
1051 @group 1051 @group
1058 @end smallexample 1058 @end smallexample
1059 1059
1060 @noindent 1060 @noindent
1061 and you wish to have Calc compute and format the derivative for 1061 and you wish to have Calc compute and format the derivative for
1062 you and store this derivative in the buffer automatically. To 1062 you and store this derivative in the buffer automatically. To
1063 do this with Embedded Mode, first copy the formula down to where 1063 do this with Embedded mode, first copy the formula down to where
1064 you want the result to be: 1064 you want the result to be:
1065 1065
1066 @smallexample 1066 @smallexample
1067 @group 1067 @group
1068 The derivative of 1068 The derivative of
1097 1 / ln(x) x 1097 1 / ln(x) x
1098 @end group 1098 @end group
1099 @end smallexample 1099 @end smallexample
1100 1100
1101 To make this look nicer, you might want to press @kbd{d =} to center 1101 To make this look nicer, you might want to press @kbd{d =} to center
1102 the formula, and even @kbd{d B} to use ``big'' display mode. 1102 the formula, and even @kbd{d B} to use Big display mode.
1103 1103
1104 @smallexample 1104 @smallexample
1105 @group 1105 @group
1106 The derivative of 1106 The derivative of
1107 1107
1137 ------- (1) 1137 ------- (1)
1138 ln(x) x 1138 ln(x) x
1139 @end group 1139 @end group
1140 @end smallexample 1140 @end smallexample
1141 1141
1142 To leave Embedded Mode, type @kbd{M-# e} again. The mode line 1142 To leave Embedded mode, type @kbd{M-# e} again. The mode line
1143 and keyboard will revert to the way they were before. (If you have 1143 and keyboard will revert to the way they were before. (If you have
1144 actually been trying this as you read along, you'll want to press 1144 actually been trying this as you read along, you'll want to press
1145 @kbd{M-# 0} [with the digit zero] now to reset the modes you changed.) 1145 @kbd{M-# 0} [with the digit zero] now to reset the modes you changed.)
1146 1146
1147 The related command @kbd{M-# w} operates on a single word, which 1147 The related command @kbd{M-# w} operates on a single word, which
1152 @smallexample 1152 @smallexample
1153 A slope of one-third corresponds to an angle of 1 degrees. 1153 A slope of one-third corresponds to an angle of 1 degrees.
1154 @end smallexample 1154 @end smallexample
1155 1155
1156 Place the cursor on the @samp{1}, then type @kbd{M-# w} to enable 1156 Place the cursor on the @samp{1}, then type @kbd{M-# w} to enable
1157 Embedded Mode on that number. Now type @kbd{3 /} (to get one-third), 1157 Embedded mode on that number. Now type @kbd{3 /} (to get one-third),
1158 and @kbd{I T} (the Inverse Tangent converts a slope into an angle), 1158 and @kbd{I T} (the Inverse Tangent converts a slope into an angle),
1159 then @w{@kbd{M-# w}} again to exit Embedded mode. 1159 then @w{@kbd{M-# w}} again to exit Embedded mode.
1160 1160
1161 @smallexample 1161 @smallexample
1162 A slope of one-third corresponds to an angle of 18.4349488229 degrees. 1162 A slope of one-third corresponds to an angle of 18.4349488229 degrees.
1219 1219
1220 @item B 1220 @item B
1221 Control whether @kbd{M-# c} and @kbd{M-# k} use the full screen. 1221 Control whether @kbd{M-# c} and @kbd{M-# k} use the full screen.
1222 1222
1223 @item Q 1223 @item Q
1224 Use Quick Mode for a single short calculation. 1224 Use Quick mode for a single short calculation.
1225 1225
1226 @item K 1226 @item K
1227 Turn Calc Keypad mode on or off. 1227 Turn Calc Keypad mode on or off.
1228 1228
1229 @item E 1229 @item E
1268 @iftex 1268 @iftex
1269 @sp 2 1269 @sp 2
1270 @end iftex 1270 @end iftex
1271 1271
1272 @noindent 1272 @noindent
1273 Commands for use with Embedded Mode: 1273 Commands for use with Embedded mode:
1274 1274
1275 @table @kbd 1275 @table @kbd
1276 @item A 1276 @item A
1277 ``Activate'' the current buffer. Locate all formulas that 1277 ``Activate'' the current buffer. Locate all formulas that
1278 contain @samp{:=} or @samp{=>} symbols and record their locations 1278 contain @samp{:=} or @samp{=>} symbols and record their locations
1476 @c [when-split] 1476 @c [when-split]
1477 @c to skip on to volume II of this manual, the @dfn{Calc Reference}. 1477 @c to skip on to volume II of this manual, the @dfn{Calc Reference}.
1478 1478
1479 @c [fix-ref Embedded Mode] 1479 @c [fix-ref Embedded Mode]
1480 This tutorial describes the standard user interface of Calc only. 1480 This tutorial describes the standard user interface of Calc only.
1481 The ``Quick Mode'' and ``Keypad Mode'' interfaces are fairly 1481 The Quick mode and Keypad mode interfaces are fairly
1482 self-explanatory. @xref{Embedded Mode}, for a description of 1482 self-explanatory. @xref{Embedded Mode}, for a description of
1483 the ``Embedded Mode'' interface. 1483 the Embedded mode interface.
1484 1484
1485 @ifinfo 1485 @ifinfo
1486 The easiest way to read this tutorial on-line is to have two windows on 1486 The easiest way to read this tutorial on-line is to have two windows on
1487 your Emacs screen, one with Calc and one with the Info system. (If you 1487 your Emacs screen, one with Calc and one with the Info system. (If you
1488 have a printed copy of the manual you can use that instead.) Press 1488 have a printed copy of the manual you can use that instead.) Press
1938 @node Algebraic Tutorial, Undo Tutorial, RPN Tutorial, Basic Tutorial 1938 @node Algebraic Tutorial, Undo Tutorial, RPN Tutorial, Basic Tutorial
1939 @subsection Algebraic-Style Calculations 1939 @subsection Algebraic-Style Calculations
1940 1940
1941 @noindent 1941 @noindent
1942 If you are not used to RPN notation, you may prefer to operate the 1942 If you are not used to RPN notation, you may prefer to operate the
1943 Calculator in ``algebraic mode,'' which is closer to the way 1943 Calculator in Algebraic mode, which is closer to the way
1944 non-RPN calculators work. In algebraic mode, you enter formulas 1944 non-RPN calculators work. In Algebraic mode, you enter formulas
1945 in traditional @expr{2+3} notation. 1945 in traditional @expr{2+3} notation.
1946 1946
1947 You don't really need any special ``mode'' to enter algebraic formulas. 1947 You don't really need any special ``mode'' to enter algebraic formulas.
1948 You can enter a formula at any time by pressing the apostrophe (@kbd{'}) 1948 You can enter a formula at any time by pressing the apostrophe (@kbd{'})
1949 key. Answer the prompt with the desired formula, then press @key{RET}. 1949 key. Answer the prompt with the desired formula, then press @key{RET}.
2003 Operators at the same level are evaluated from left to right, except 2003 Operators at the same level are evaluated from left to right, except
2004 that @samp{^} is evaluated from right to left. Thus, @samp{2-3-4} is 2004 that @samp{^} is evaluated from right to left. Thus, @samp{2-3-4} is
2005 equivalent to @samp{(2-3)-4} or @mathit{-5}, whereas @samp{2^3^4} is equivalent 2005 equivalent to @samp{(2-3)-4} or @mathit{-5}, whereas @samp{2^3^4} is equivalent
2006 to @samp{2^(3^4)} (a very large integer; try it!). 2006 to @samp{2^(3^4)} (a very large integer; try it!).
2007 2007
2008 If you tire of typing the apostrophe all the time, there is an 2008 If you tire of typing the apostrophe all the time, there is
2009 ``algebraic mode'' you can select in which Calc automatically senses 2009 Algebraic mode, where Calc automatically senses
2010 when you are about to type an algebraic expression. To enter this 2010 when you are about to type an algebraic expression. To enter this
2011 mode, press the two letters @w{@kbd{m a}}. (An @samp{Alg} indicator 2011 mode, press the two letters @w{@kbd{m a}}. (An @samp{Alg} indicator
2012 should appear in the Calc window's mode line.) 2012 should appear in the Calc window's mode line.)
2013 2013
2014 Press @kbd{m a}, then @kbd{2+3+4} with no apostrophe, then @key{RET}. 2014 Press @kbd{m a}, then @kbd{2+3+4} with no apostrophe, then @key{RET}.
2015 2015
2016 In algebraic mode, when you press any key that would normally begin 2016 In Algebraic mode, when you press any key that would normally begin
2017 entering a number (such as a digit, a decimal point, or the @kbd{_} 2017 entering a number (such as a digit, a decimal point, or the @kbd{_}
2018 key), or if you press @kbd{(} or @kbd{[}, Calc automatically begins 2018 key), or if you press @kbd{(} or @kbd{[}, Calc automatically begins
2019 an algebraic entry. 2019 an algebraic entry.
2020 2020
2021 Functions which do not have operator symbols like @samp{+} and @samp{*} 2021 Functions which do not have operator symbols like @samp{+} and @samp{*}
2026 2026
2027 Press the apostrophe, then type @kbd{sqrt(5*2) - 3}. The result should 2027 Press the apostrophe, then type @kbd{sqrt(5*2) - 3}. The result should
2028 be @expr{0.16227766017}. 2028 be @expr{0.16227766017}.
2029 2029
2030 Note that if the formula begins with a function name, you need to use 2030 Note that if the formula begins with a function name, you need to use
2031 the apostrophe even if you are in algebraic mode. If you type @kbd{arcsin} 2031 the apostrophe even if you are in Algebraic mode. If you type @kbd{arcsin}
2032 out of the blue, the @kbd{a r} will be taken as an Algebraic Rewrite 2032 out of the blue, the @kbd{a r} will be taken as an Algebraic Rewrite
2033 command, and the @kbd{csin} will be taken as the name of the rewrite 2033 command, and the @kbd{csin} will be taken as the name of the rewrite
2034 rule to use! 2034 rule to use!
2035 2035
2036 Some people prefer to enter complex numbers and vectors in algebraic 2036 Some people prefer to enter complex numbers and vectors in algebraic
2037 form because they find RPN entry with incomplete objects to be too 2037 form because they find RPN entry with incomplete objects to be too
2038 distracting, even though they otherwise use Calc as an RPN calculator. 2038 distracting, even though they otherwise use Calc as an RPN calculator.
2039 2039
2040 Still in algebraic mode, type: 2040 Still in Algebraic mode, type:
2041 2041
2042 @smallexample 2042 @smallexample
2043 @group 2043 @group
2044 1: (2, 3) 2: (2, 3) 1: (8, -1) 2: (8, -1) 1: (9, -1) 2044 1: (2, 3) 2: (2, 3) 1: (8, -1) 2: (8, -1) 1: (9, -1)
2045 . 1: (1, -2) . 1: 1 . 2045 . 1: (1, -2) . 1: 1 .
2051 2051
2052 Algebraic mode allows us to enter complex numbers without pressing 2052 Algebraic mode allows us to enter complex numbers without pressing
2053 an apostrophe first, but it also means we need to press @key{RET} 2053 an apostrophe first, but it also means we need to press @key{RET}
2054 after every entry, even for a simple number like @expr{1}. 2054 after every entry, even for a simple number like @expr{1}.
2055 2055
2056 (You can type @kbd{C-u m a} to enable a special ``incomplete algebraic 2056 (You can type @kbd{C-u m a} to enable a special Incomplete Algebraic
2057 mode'' in which the @kbd{(} and @kbd{[} keys use algebraic entry even 2057 mode in which the @kbd{(} and @kbd{[} keys use algebraic entry even
2058 though regular numeric keys still use RPN numeric entry. There is also 2058 though regular numeric keys still use RPN numeric entry. There is also
2059 a ``total algebraic mode,'' started by typing @kbd{m t}, in which all 2059 Total Algebraic mode, started by typing @kbd{m t}, in which all
2060 normal keys begin algebraic entry. You must then use the @key{META} key 2060 normal keys begin algebraic entry. You must then use the @key{META} key
2061 to type Calc commands: @kbd{M-m t} to get back out of total algebraic 2061 to type Calc commands: @kbd{M-m t} to get back out of Total Algebraic
2062 mode, @kbd{M-q} to quit, etc.) 2062 mode, @kbd{M-q} to quit, etc.)
2063 2063
2064 If you're still in algebraic mode, press @kbd{m a} again to turn it off. 2064 If you're still in Algebraic mode, press @kbd{m a} again to turn it off.
2065 2065
2066 Actual non-RPN calculators use a mixture of algebraic and RPN styles. 2066 Actual non-RPN calculators use a mixture of algebraic and RPN styles.
2067 In general, operators of two numbers (like @kbd{+} and @kbd{*}) 2067 In general, operators of two numbers (like @kbd{+} and @kbd{*})
2068 use algebraic form, but operators of one number (like @kbd{n} and @kbd{Q}) 2068 use algebraic form, but operators of one number (like @kbd{n} and @kbd{Q})
2069 use RPN form. Also, a non-RPN calculator allows you to see the 2069 use RPN form. Also, a non-RPN calculator allows you to see the
2374 @subsection Mode-Setting Commands 2374 @subsection Mode-Setting Commands
2375 2375
2376 @noindent 2376 @noindent
2377 Calc has many types of @dfn{modes} that affect the way it interprets 2377 Calc has many types of @dfn{modes} that affect the way it interprets
2378 your commands or the way it displays data. We have already seen one 2378 your commands or the way it displays data. We have already seen one
2379 mode, namely algebraic mode. There are many others, too; we'll 2379 mode, namely Algebraic mode. There are many others, too; we'll
2380 try some of the most common ones here. 2380 try some of the most common ones here.
2381 2381
2382 Perhaps the most fundamental mode in Calc is the current @dfn{precision}. 2382 Perhaps the most fundamental mode in Calc is the current @dfn{precision}.
2383 Notice the @samp{12} on the Calc window's mode line: 2383 Notice the @samp{12} on the Calc window's mode line:
2384 2384
2793 2793
2794 45 c r c d 2794 45 c r c d
2795 @end group 2795 @end group
2796 @end smallexample 2796 @end smallexample
2797 2797
2798 Another interesting mode is @dfn{fraction mode}. Normally, 2798 Another interesting mode is @dfn{Fraction mode}. Normally,
2799 dividing two integers produces a floating-point result if the 2799 dividing two integers produces a floating-point result if the
2800 quotient can't be expressed as an exact integer. Fraction mode 2800 quotient can't be expressed as an exact integer. Fraction mode
2801 causes integer division to produce a fraction, i.e., a rational 2801 causes integer division to produce a fraction, i.e., a rational
2802 number, instead. 2802 number, instead.
2803 2803
2817 2817
2818 You can enter a fraction at any time using @kbd{:} notation. 2818 You can enter a fraction at any time using @kbd{:} notation.
2819 (Calc uses @kbd{:} instead of @kbd{/} as the fraction separator 2819 (Calc uses @kbd{:} instead of @kbd{/} as the fraction separator
2820 because @kbd{/} is already used to divide the top two stack 2820 because @kbd{/} is already used to divide the top two stack
2821 elements.) Calculations involving fractions will always 2821 elements.) Calculations involving fractions will always
2822 produce exact fractional results; fraction mode only says 2822 produce exact fractional results; Fraction mode only says
2823 what to do when dividing two integers. 2823 what to do when dividing two integers.
2824 2824
2825 @cindex Fractions vs. floats 2825 @cindex Fractions vs. floats
2826 @cindex Floats vs. fractions 2826 @cindex Floats vs. fractions
2827 (@bullet{}) @strong{Exercise 4.} If fractional arithmetic is exact, 2827 (@bullet{}) @strong{Exercise 4.} If fractional arithmetic is exact,
2828 why would you ever use floating-point numbers instead? 2828 why would you ever use floating-point numbers instead?
2829 @xref{Modes Answer 4, 4}. (@bullet{}) 2829 @xref{Modes Answer 4, 4}. (@bullet{})
2830 2830
2831 Typing @kbd{m f} doesn't change any existing values in the stack. 2831 Typing @kbd{m f} doesn't change any existing values in the stack.
2832 In the above example, we had to Undo the division and do it over 2832 In the above example, we had to Undo the division and do it over
2833 again when we changed to fraction mode. But if you use the 2833 again when we changed to Fraction mode. But if you use the
2834 evaluates-to operator you can get commands like @kbd{m f} to 2834 evaluates-to operator you can get commands like @kbd{m f} to
2835 recompute for you. 2835 recompute for you.
2836 2836
2837 @smallexample 2837 @smallexample
2838 @group 2838 @group
2844 @end smallexample 2844 @end smallexample
2845 2845
2846 @noindent 2846 @noindent
2847 In this example, the righthand side of the @samp{=>} operator 2847 In this example, the righthand side of the @samp{=>} operator
2848 on the stack is recomputed when we change the precision, then 2848 on the stack is recomputed when we change the precision, then
2849 again when we change to fraction mode. All @samp{=>} expressions 2849 again when we change to Fraction mode. All @samp{=>} expressions
2850 on the stack are recomputed every time you change any mode that 2850 on the stack are recomputed every time you change any mode that
2851 might affect their values. 2851 might affect their values.
2852 2852
2853 @node Arithmetic Tutorial, Vector/Matrix Tutorial, Basic Tutorial, Tutorial 2853 @node Arithmetic Tutorial, Vector/Matrix Tutorial, Basic Tutorial, Tutorial
2854 @section Arithmetic Tutorial 2854 @section Arithmetic Tutorial
4528 So we say the result is @dfn{indeterminate}, which Calc writes 4528 So we say the result is @dfn{indeterminate}, which Calc writes
4529 with the symbol @code{nan} (for Not A Number). 4529 with the symbol @code{nan} (for Not A Number).
4530 4530
4531 Dividing by zero is normally treated as an error, but you can get 4531 Dividing by zero is normally treated as an error, but you can get
4532 Calc to write an answer in terms of infinity by pressing @kbd{m i} 4532 Calc to write an answer in terms of infinity by pressing @kbd{m i}
4533 to turn on ``infinite mode.'' 4533 to turn on Infinite mode.
4534 4534
4535 @smallexample 4535 @smallexample
4536 @group 4536 @group
4537 3: nan 2: nan 2: nan 2: nan 1: nan 4537 3: nan 2: nan 2: nan 2: nan 1: nan
4538 2: 1 1: 1 / 0 1: uinf 1: uinf . 4538 2: 1 1: 1 / 0 1: uinf 1: uinf .
4958 4958
4959 @node Basic Algebra Tutorial, Rewrites Tutorial, Algebra Tutorial, Algebra Tutorial 4959 @node Basic Algebra Tutorial, Rewrites Tutorial, Algebra Tutorial, Algebra Tutorial
4960 @subsection Basic Algebra 4960 @subsection Basic Algebra
4961 4961
4962 @noindent 4962 @noindent
4963 If you enter a formula in algebraic mode that refers to variables, 4963 If you enter a formula in Algebraic mode that refers to variables,
4964 the formula itself is pushed onto the stack. You can manipulate 4964 the formula itself is pushed onto the stack. You can manipulate
4965 formulas as regular data objects. 4965 formulas as regular data objects.
4966 4966
4967 @smallexample 4967 @smallexample
4968 @group 4968 @group
5179 sequence of commands would you use to reconstruct the original 5179 sequence of commands would you use to reconstruct the original
5180 polynomial? (The answer will be unique to within a constant 5180 polynomial? (The answer will be unique to within a constant
5181 multiple; choose the solution where the leading coefficient is one.) 5181 multiple; choose the solution where the leading coefficient is one.)
5182 @xref{Algebra Answer 2, 2}. (@bullet{}) 5182 @xref{Algebra Answer 2, 2}. (@bullet{})
5183 5183
5184 The @kbd{m s} command enables ``symbolic mode,'' in which formulas 5184 The @kbd{m s} command enables Symbolic mode, in which formulas
5185 like @samp{sqrt(5)} that can't be evaluated exactly are left in 5185 like @samp{sqrt(5)} that can't be evaluated exactly are left in
5186 symbolic form rather than giving a floating-point approximate answer. 5186 symbolic form rather than giving a floating-point approximate answer.
5187 Fraction mode (@kbd{m f}) is also useful when doing algebra. 5187 Fraction mode (@kbd{m f}) is also useful when doing algebra.
5188 5188
5189 @smallexample 5189 @smallexample
5194 5194
5195 r 2 @key{RET} m s m f a P x @key{RET} 5195 r 2 @key{RET} m s m f a P x @key{RET}
5196 @end group 5196 @end group
5197 @end smallexample 5197 @end smallexample
5198 5198
5199 One more mode that makes reading formulas easier is ``Big mode.'' 5199 One more mode that makes reading formulas easier is Big mode.
5200 5200
5201 @smallexample 5201 @smallexample
5202 @group 5202 @group
5203 3 5203 3
5204 2: 34 x - 24 x 5204 2: 34 x - 24 x
5342 @end group 5342 @end group
5343 @end smallexample 5343 @end smallexample
5344 5344
5345 @noindent 5345 @noindent
5346 (If you got wildly different results, did you remember to switch 5346 (If you got wildly different results, did you remember to switch
5347 to radians mode?) 5347 to Radians mode?)
5348 5348
5349 Here we have divided the curve into ten segments of equal width; 5349 Here we have divided the curve into ten segments of equal width;
5350 approximating these segments as rectangular boxes (i.e., assuming 5350 approximating these segments as rectangular boxes (i.e., assuming
5351 the curve is nearly flat at that resolution), we compute the areas 5351 the curve is nearly flat at that resolution), we compute the areas
5352 of the boxes (height times width), then sum the areas. (It is 5352 of the boxes (height times width), then sum the areas. (It is
5598 efficiently. If the rule is stored in a variable, Calc compiles it 5598 efficiently. If the rule is stored in a variable, Calc compiles it
5599 only once and stores the compiled form along with the variable. That's 5599 only once and stores the compiled form along with the variable. That's
5600 another good reason to store your rules in variables rather than 5600 another good reason to store your rules in variables rather than
5601 entering them on the fly. 5601 entering them on the fly.
5602 5602
5603 (@bullet{}) @strong{Exercise 1.} Type @kbd{m s} to get symbolic 5603 (@bullet{}) @strong{Exercise 1.} Type @kbd{m s} to get Symbolic
5604 mode, then enter the formula @samp{@w{(2 + sqrt(2))} / @w{(1 + sqrt(2))}}. 5604 mode, then enter the formula @samp{@w{(2 + sqrt(2))} / @w{(1 + sqrt(2))}}.
5605 Using a rewrite rule, simplify this formula by multiplying both 5605 Using a rewrite rule, simplify this formula by multiplying both
5606 sides by the conjugate @w{@samp{1 - sqrt(2)}}. The result will have 5606 sides by the conjugate @w{@samp{1 - sqrt(2)}}. The result will have
5607 to be expanded by the distributive law; do this with another 5607 to be expanded by the distributive law; do this with another
5608 rewrite. @xref{Rewrites Answer 1, 1}. (@bullet{}) 5608 rewrite. @xref{Rewrites Answer 1, 1}. (@bullet{})
5857 is one or more non-sum terms separated by @samp{+} or @samp{-} signs, 5857 is one or more non-sum terms separated by @samp{+} or @samp{-} signs,
5858 so that @expr{2 - 3 (x + y) + x y} is a sum of three terms.) 5858 so that @expr{2 - 3 (x + y) + x y} is a sum of three terms.)
5859 @xref{Rewrites Answer 5, 5}. (@bullet{}) 5859 @xref{Rewrites Answer 5, 5}. (@bullet{})
5860 5860
5861 (@bullet{}) @strong{Exercise 6.} Calc considers the form @expr{0^0} 5861 (@bullet{}) @strong{Exercise 6.} Calc considers the form @expr{0^0}
5862 to be ``indeterminate,'' and leaves it unevaluated (assuming infinite 5862 to be ``indeterminate,'' and leaves it unevaluated (assuming Infinite
5863 mode is not enabled). Some people prefer to define @expr{0^0 = 1}, 5863 mode is not enabled). Some people prefer to define @expr{0^0 = 1},
5864 so that the identity @expr{x^0 = 1} can safely be used for all @expr{x}. 5864 so that the identity @expr{x^0 = 1} can safely be used for all @expr{x}.
5865 Find a way to make Calc follow this convention. What happens if you 5865 Find a way to make Calc follow this convention. What happens if you
5866 now type @kbd{m i} to turn on infinite mode? 5866 now type @kbd{m i} to turn on Infinite mode?
5867 @xref{Rewrites Answer 6, 6}. (@bullet{}) 5867 @xref{Rewrites Answer 6, 6}. (@bullet{})
5868 5868
5869 (@bullet{}) @strong{Exercise 7.} A Taylor series for a function is an 5869 (@bullet{}) @strong{Exercise 7.} A Taylor series for a function is an
5870 infinite series that exactly equals the value of that function at 5870 infinite series that exactly equals the value of that function at
5871 values of @expr{x} near zero. 5871 values of @expr{x} near zero.
6836 is zero, so it is left in symbolic form. When you now type @kbd{0 *}, 6836 is zero, so it is left in symbolic form. When you now type @kbd{0 *},
6837 the result will be zero because Calc uses the general rule that ``zero 6837 the result will be zero because Calc uses the general rule that ``zero
6838 times anything is zero.'' 6838 times anything is zero.''
6839 6839
6840 @c [fix-ref Infinities] 6840 @c [fix-ref Infinities]
6841 The @kbd{m i} command enables an @dfn{infinite mode} in which @expr{1 / 0} 6841 The @kbd{m i} command enables an @dfn{Infinite mode} in which @expr{1 / 0}
6842 results in a special symbol that represents ``infinity.'' If you 6842 results in a special symbol that represents ``infinity.'' If you
6843 multiply infinity by zero, Calc uses another special new symbol to 6843 multiply infinity by zero, Calc uses another special new symbol to
6844 show that the answer is ``indeterminate.'' @xref{Infinities}, for 6844 show that the answer is ``indeterminate.'' @xref{Infinities}, for
6845 further discussion of infinite and indeterminate values. 6845 further discussion of infinite and indeterminate values.
6846 6846
7000 @infoline @expr{12345700.@: / 2.@: = 61728500.}. 7000 @infoline @expr{12345700.@: / 2.@: = 61728500.}.
7001 The result, when converted to an integer, will be off by 106. 7001 The result, when converted to an integer, will be off by 106.
7002 7002
7003 Here are two solutions: Raise the precision enough that the 7003 Here are two solutions: Raise the precision enough that the
7004 floating-point round-off error is strictly to the right of the 7004 floating-point round-off error is strictly to the right of the
7005 decimal point. Or, convert to fraction mode so that @expr{123456789 / 2} 7005 decimal point. Or, convert to Fraction mode so that @expr{123456789 / 2}
7006 produces the exact fraction @expr{123456789:2}, which can be rounded 7006 produces the exact fraction @expr{123456789:2}, which can be rounded
7007 down by the @kbd{F} command without ever switching to floating-point 7007 down by the @kbd{F} command without ever switching to floating-point
7008 format. 7008 format.
7009 7009
7010 @node Arithmetic Answer 2, Vector Answer 1, Arithmetic Answer 1, Answers to Exercises 7010 @node Arithmetic Answer 2, Vector Answer 1, Arithmetic Answer 1, Answers to Exercises
7013 @noindent 7013 @noindent
7014 @kbd{27 @key{RET} 9 B} could give the exact result @expr{3:2}, but it 7014 @kbd{27 @key{RET} 9 B} could give the exact result @expr{3:2}, but it
7015 does a floating-point calculation instead and produces @expr{1.5}. 7015 does a floating-point calculation instead and produces @expr{1.5}.
7016 7016
7017 Calc will find an exact result for a logarithm if the result is an integer 7017 Calc will find an exact result for a logarithm if the result is an integer
7018 or the reciprocal of an integer. But there is no efficient way to search 7018 or (when in Fraction mode) the reciprocal of an integer. But there is
7019 the space of all possible rational numbers for an exact answer, so Calc 7019 no efficient way to search the space of all possible rational numbers
7020 doesn't try. 7020 for an exact answer, so Calc doesn't try.
7021 7021
7022 @node Vector Answer 1, Vector Answer 2, Arithmetic Answer 2, Answers to Exercises 7022 @node Vector Answer 1, Vector Answer 2, Arithmetic Answer 2, Answers to Exercises
7023 @subsection Vector Tutorial Exercise 1 7023 @subsection Vector Tutorial Exercise 1
7024 7024
7025 @noindent 7025 @noindent
7087 7087
7088 ' [6 10] @key{RET} ' [1 a; 1 b] @key{RET} / 7088 ' [6 10] @key{RET} ' [1 a; 1 b] @key{RET} /
7089 @end group 7089 @end group
7090 @end smallexample 7090 @end smallexample
7091 7091
7092 This can be made more readable using @kbd{d B} to enable ``big'' display 7092 This can be made more readable using @kbd{d B} to enable Big display
7093 mode: 7093 mode:
7094 7094
7095 @smallexample 7095 @smallexample
7096 @group 7096 @group
7097 4 a 4 7097 4 a 4
7098 1: [6 - -----, -----] 7098 1: [6 - -----, -----]
7099 b - a b - a 7099 b - a b - a
7100 @end group 7100 @end group
7101 @end smallexample 7101 @end smallexample
7102 7102
7103 Type @kbd{d N} to return to ``normal'' display mode afterwards. 7103 Type @kbd{d N} to return to Normal display mode afterwards.
7104 7104
7105 @node Matrix Answer 3, List Answer 1, Matrix Answer 2, Answers to Exercises 7105 @node Matrix Answer 3, List Answer 1, Matrix Answer 2, Answers to Exercises
7106 @subsection Matrix Tutorial Exercise 3 7106 @subsection Matrix Tutorial Exercise 3
7107 7107
7108 @noindent 7108 @noindent
8245 @samp{abs(uinf) = inf}. No matter which direction @expr{x} points, 8245 @samp{abs(uinf) = inf}. No matter which direction @expr{x} points,
8246 @samp{abs(x)} always points along the positive real axis. 8246 @samp{abs(x)} always points along the positive real axis.
8247 8247
8248 @samp{ln(0) = -inf}. Here we have an infinite answer to a finite 8248 @samp{ln(0) = -inf}. Here we have an infinite answer to a finite
8249 input. As in the @expr{1 / 0} case, Calc will only use infinities 8249 input. As in the @expr{1 / 0} case, Calc will only use infinities
8250 here if you have turned on ``infinite'' mode. Otherwise, it will 8250 here if you have turned on Infinite mode. Otherwise, it will
8251 treat @samp{ln(0)} as an error. 8251 treat @samp{ln(0)} as an error.
8252 8252
8253 @node Types Answer 3, Types Answer 4, Types Answer 2, Answers to Exercises 8253 @node Types Answer 3, Types Answer 4, Types Answer 2, Answers to Exercises
8254 @subsection Types Tutorial Exercise 3 8254 @subsection Types Tutorial Exercise 3
8255 8255
8459 Calc normally treats division by zero as an error, so that the formula 8459 Calc normally treats division by zero as an error, so that the formula
8460 @w{@samp{1 / 0}} is left unsimplified. Our third problem, 8460 @w{@samp{1 / 0}} is left unsimplified. Our third problem,
8461 @w{@samp{1 / [0 .. 10]}}, also (potentially) divides by zero because zero 8461 @w{@samp{1 / [0 .. 10]}}, also (potentially) divides by zero because zero
8462 is now a member of the interval. So Calc leaves this one unevaluated, too. 8462 is now a member of the interval. So Calc leaves this one unevaluated, too.
8463 8463
8464 If you turn on ``infinite'' mode by pressing @kbd{m i}, you will 8464 If you turn on Infinite mode by pressing @kbd{m i}, you will
8465 instead get the answer @samp{[0.1 .. inf]}, which includes infinity 8465 instead get the answer @samp{[0.1 .. inf]}, which includes infinity
8466 as a possible value. 8466 as a possible value.
8467 8467
8468 The fourth calculation, @samp{1 / (-10 .. 10)}, has the same problem. 8468 The fourth calculation, @samp{1 / (-10 .. 10)}, has the same problem.
8469 Zero is buried inside the interval, but it's still a possible value. 8469 Zero is buried inside the interval, but it's still a possible value.
9122 9122
9123 U ' 0^0:=1 @key{RET} s t EvalRules @key{RET} V M ^ 9123 U ' 0^0:=1 @key{RET} s t EvalRules @key{RET} V M ^
9124 @end group 9124 @end group
9125 @end smallexample 9125 @end smallexample
9126 9126
9127 Perhaps more surprisingly, this rule still works with infinite mode 9127 Perhaps more surprisingly, this rule still works with Infinite mode
9128 turned on. Calc tries @code{EvalRules} before any built-in rules for 9128 turned on. Calc tries @code{EvalRules} before any built-in rules for
9129 a function. This allows you to override the default behavior of any 9129 a function. This allows you to override the default behavior of any
9130 Calc feature: Even though Calc now wants to evaluate @expr{0^0} to 9130 Calc feature: Even though Calc now wants to evaluate @expr{0^0} to
9131 @code{nan}, your rule gets there first and evaluates it to 1 instead. 9131 @code{nan}, your rule gets there first and evaluates it to 1 instead.
9132 9132
9887 To start the Calculator in its standard interface, type @kbd{M-x calc}. 9887 To start the Calculator in its standard interface, type @kbd{M-x calc}.
9888 By default this creates a pair of small windows, @samp{*Calculator*} 9888 By default this creates a pair of small windows, @samp{*Calculator*}
9889 and @samp{*Calc Trail*}. The former displays the contents of the 9889 and @samp{*Calc Trail*}. The former displays the contents of the
9890 Calculator stack and is manipulated exclusively through Calc commands. 9890 Calculator stack and is manipulated exclusively through Calc commands.
9891 It is possible (though not usually necessary) to create several Calc 9891 It is possible (though not usually necessary) to create several Calc
9892 Mode buffers each of which has an independent stack, undo list, and 9892 mode buffers each of which has an independent stack, undo list, and
9893 mode settings. There is exactly one Calc Trail buffer; it records a 9893 mode settings. There is exactly one Calc Trail buffer; it records a
9894 list of the results of all calculations that have been done. The 9894 list of the results of all calculations that have been done. The
9895 Calc Trail buffer uses a variant of Calc Mode, so Calculator commands 9895 Calc Trail buffer uses a variant of Calc mode, so Calculator commands
9896 still work when the trail buffer's window is selected. It is possible 9896 still work when the trail buffer's window is selected. It is possible
9897 to turn the trail window off, but the @samp{*Calc Trail*} buffer itself 9897 to turn the trail window off, but the @samp{*Calc Trail*} buffer itself
9898 still exists and is updated silently. @xref{Trail Commands}. 9898 still exists and is updated silently. @xref{Trail Commands}.
9899 9899
9900 @kindex M-# c 9900 @kindex M-# c
9904 @end ignore 9904 @end ignore
9905 @kindex M-# # 9905 @kindex M-# #
9906 In most installations, the @kbd{M-# c} key sequence is a more 9906 In most installations, the @kbd{M-# c} key sequence is a more
9907 convenient way to start the Calculator. Also, @kbd{M-# M-#} and 9907 convenient way to start the Calculator. Also, @kbd{M-# M-#} and
9908 @kbd{M-# #} are synonyms for @kbd{M-# c} unless you last used Calc 9908 @kbd{M-# #} are synonyms for @kbd{M-# c} unless you last used Calc
9909 in its ``keypad'' mode. 9909 in its Keypad mode.
9910 9910
9911 @kindex x 9911 @kindex x
9912 @kindex M-x 9912 @kindex M-x
9913 @pindex calc-execute-extended-command 9913 @pindex calc-execute-extended-command
9914 Most Calc commands use one or two keystrokes. Lower- and upper-case 9914 Most Calc commands use one or two keystrokes. Lower- and upper-case
9976 9976
9977 @kindex q 9977 @kindex q
9978 @pindex calc-quit 9978 @pindex calc-quit
9979 @cindex Quitting the Calculator 9979 @cindex Quitting the Calculator
9980 @cindex Exiting the Calculator 9980 @cindex Exiting the Calculator
9981 The @kbd{q} key (@code{calc-quit}) exits Calc Mode and closes the 9981 The @kbd{q} key (@code{calc-quit}) exits Calc mode and closes the
9982 Calculator's window(s). It does not delete the Calculator buffers. 9982 Calculator's window(s). It does not delete the Calculator buffers.
9983 If you type @kbd{M-x calc} again, the Calculator will reappear with the 9983 If you type @kbd{M-x calc} again, the Calculator will reappear with the
9984 contents of the stack intact. Typing @kbd{M-# c} or @kbd{M-# M-#} 9984 contents of the stack intact. Typing @kbd{M-# c} or @kbd{M-# M-#}
9985 again from inside the Calculator buffer is equivalent to executing 9985 again from inside the Calculator buffer is equivalent to executing
9986 @code{calc-quit}; you can think of @kbd{M-# M-#} as toggling the 9986 @code{calc-quit}; you can think of @kbd{M-# M-#} as toggling the
10276 ignore the RPN aspect of Calc altogether and simply enter algebraic 10276 ignore the RPN aspect of Calc altogether and simply enter algebraic
10277 expressions in this way. You may want to use @key{DEL} every so often to 10277 expressions in this way. You may want to use @key{DEL} every so often to
10278 clear previous results off the stack. 10278 clear previous results off the stack.
10279 10279
10280 You can press the apostrophe key during normal numeric entry to switch 10280 You can press the apostrophe key during normal numeric entry to switch
10281 the half-entered number into algebraic entry mode. One reason to do this 10281 the half-entered number into Algebraic entry mode. One reason to do this
10282 would be to use the full Emacs cursor motion and editing keys, which are 10282 would be to use the full Emacs cursor motion and editing keys, which are
10283 available during algebraic entry but not during numeric entry. 10283 available during algebraic entry but not during numeric entry.
10284 10284
10285 In the same vein, during either numeric or algebraic entry you can 10285 In the same vein, during either numeric or algebraic entry you can
10286 press @kbd{`} (backquote) to switch to @code{calc-edit} mode, where 10286 press @kbd{`} (backquote) to switch to @code{calc-edit} mode, where
10287 you complete your half-finished entry in a separate buffer. 10287 you complete your half-finished entry in a separate buffer.
10288 @xref{Editing Stack Entries}. 10288 @xref{Editing Stack Entries}.
10289 10289
10290 @kindex m a 10290 @kindex m a
10291 @pindex calc-algebraic-mode 10291 @pindex calc-algebraic-mode
10292 @cindex Algebraic mode 10292 @cindex Algebraic Mode
10293 If you prefer algebraic entry, you can use the command @kbd{m a} 10293 If you prefer algebraic entry, you can use the command @kbd{m a}
10294 (@code{calc-algebraic-mode}) to set Algebraic mode. In this mode, 10294 (@code{calc-algebraic-mode}) to set Algebraic mode. In this mode,
10295 digits and other keys that would normally start numeric entry instead 10295 digits and other keys that would normally start numeric entry instead
10296 start full algebraic entry; as long as your formula begins with a digit 10296 start full algebraic entry; as long as your formula begins with a digit
10297 you can omit the apostrophe. Open parentheses and square brackets also 10297 you can omit the apostrophe. Open parentheses and square brackets also
10298 begin algebraic entry. You can still do RPN calculations in this mode, 10298 begin algebraic entry. You can still do RPN calculations in this mode,
10299 but you will have to press @key{RET} to terminate every number: 10299 but you will have to press @key{RET} to terminate every number:
10300 @kbd{2 @key{RET} 3 @key{RET} * 4 @key{RET} +} would accomplish the same 10300 @kbd{2 @key{RET} 3 @key{RET} * 4 @key{RET} +} would accomplish the same
10301 thing as @kbd{2*3+4 @key{RET}}. 10301 thing as @kbd{2*3+4 @key{RET}}.
10302 10302
10303 @cindex Incomplete algebraic mode 10303 @cindex Incomplete Algebraic Mode
10304 If you give a numeric prefix argument like @kbd{C-u} to the @kbd{m a} 10304 If you give a numeric prefix argument like @kbd{C-u} to the @kbd{m a}
10305 command, it enables Incomplete Algebraic mode; this is like regular 10305 command, it enables Incomplete Algebraic mode; this is like regular
10306 Algebraic mode except that it applies to the @kbd{(} and @kbd{[} keys 10306 Algebraic mode except that it applies to the @kbd{(} and @kbd{[} keys
10307 only. Numeric keys still begin a numeric entry in this mode. 10307 only. Numeric keys still begin a numeric entry in this mode.
10308 10308
10309 @kindex m t 10309 @kindex m t
10310 @pindex calc-total-algebraic-mode 10310 @pindex calc-total-algebraic-mode
10311 @cindex Total algebraic mode 10311 @cindex Total Algebraic Mode
10312 The @kbd{m t} (@code{calc-total-algebraic-mode}) gives you an even 10312 The @kbd{m t} (@code{calc-total-algebraic-mode}) gives you an even
10313 stronger algebraic-entry mode, in which @emph{all} regular letter and 10313 stronger algebraic-entry mode, in which @emph{all} regular letter and
10314 punctuation keys begin algebraic entry. Use this if you prefer typing 10314 punctuation keys begin algebraic entry. Use this if you prefer typing
10315 @w{@kbd{sqrt( )}} instead of @kbd{Q}, @w{@kbd{factor( )}} instead of 10315 @w{@kbd{sqrt( )}} instead of @kbd{Q}, @w{@kbd{factor( )}} instead of
10316 @kbd{a f}, and so on. To type regular Calc commands when you are in 10316 @kbd{a f}, and so on. To type regular Calc commands when you are in
10317 ``total'' algebraic mode, hold down the @key{META} key. Thus @kbd{M-q} 10317 Total Algebraic mode, hold down the @key{META} key. Thus @kbd{M-q}
10318 is the command to quit Calc, @kbd{M-p} sets the precision, and 10318 is the command to quit Calc, @kbd{M-p} sets the precision, and
10319 @kbd{M-m t} (or @kbd{M-m M-t}, if you prefer) turns total algebraic 10319 @kbd{M-m t} (or @kbd{M-m M-t}, if you prefer) turns Total Algebraic
10320 mode back off again. Meta keys also terminate algebraic entry, so 10320 mode back off again. Meta keys also terminate algebraic entry, so
10321 that @kbd{2+3 M-S} is equivalent to @kbd{2+3 @key{RET} M-S}. The symbol 10321 that @kbd{2+3 M-S} is equivalent to @kbd{2+3 @key{RET} M-S}. The symbol
10322 @samp{Alg*} will appear in the mode line whenever you are in this mode. 10322 @samp{Alg*} will appear in the mode line whenever you are in this mode.
10323 10323
10324 Pressing @kbd{'} (the apostrophe) a second time re-enters the previous 10324 Pressing @kbd{'} (the apostrophe) a second time re-enters the previous
10575 @node Multiple Calculators, Troubleshooting Commands, Error Messages, Introduction 10575 @node Multiple Calculators, Troubleshooting Commands, Error Messages, Introduction
10576 @section Multiple Calculators 10576 @section Multiple Calculators
10577 10577
10578 @noindent 10578 @noindent
10579 @pindex another-calc 10579 @pindex another-calc
10580 It is possible to have any number of Calc Mode buffers at once. 10580 It is possible to have any number of Calc mode buffers at once.
10581 Usually this is done by executing @kbd{M-x another-calc}, which 10581 Usually this is done by executing @kbd{M-x another-calc}, which
10582 is similar to @kbd{M-# c} except that if a @samp{*Calculator*} 10582 is similar to @kbd{M-# c} except that if a @samp{*Calculator*}
10583 buffer already exists, a new, independent one with a name of the 10583 buffer already exists, a new, independent one with a name of the
10584 form @samp{*Calculator*<@var{n}>} is created. You can also use the 10584 form @samp{*Calculator*<@var{n}>} is created. You can also use the
10585 command @code{calc-mode} to put any buffer into Calculator mode, but 10585 command @code{calc-mode} to put any buffer into Calculator mode, but
10790 @cindex Integers 10790 @cindex Integers
10791 The Calculator stores integers to arbitrary precision. Addition, 10791 The Calculator stores integers to arbitrary precision. Addition,
10792 subtraction, and multiplication of integers always yields an exact 10792 subtraction, and multiplication of integers always yields an exact
10793 integer result. (If the result of a division or exponentiation of 10793 integer result. (If the result of a division or exponentiation of
10794 integers is not an integer, it is expressed in fractional or 10794 integers is not an integer, it is expressed in fractional or
10795 floating-point form according to the current Fraction Mode. 10795 floating-point form according to the current Fraction mode.
10796 @xref{Fraction Mode}.) 10796 @xref{Fraction Mode}.)
10797 10797
10798 A decimal integer is represented as an optional sign followed by a 10798 A decimal integer is represented as an optional sign followed by a
10799 sequence of digits. Grouping (@pxref{Grouping Digits}) can be used to 10799 sequence of digits. Grouping (@pxref{Grouping Digits}) can be used to
10800 insert a comma at every third digit for display purposes, but you 10800 insert a comma at every third digit for display purposes, but you
10816 @cindex Fractions 10816 @cindex Fractions
10817 A @dfn{fraction} is a ratio of two integers. Fractions are traditionally 10817 A @dfn{fraction} is a ratio of two integers. Fractions are traditionally
10818 written ``2/3'' but Calc uses the notation @samp{2:3}. (The @kbd{/} key 10818 written ``2/3'' but Calc uses the notation @samp{2:3}. (The @kbd{/} key
10819 performs RPN division; the following two sequences push the number 10819 performs RPN division; the following two sequences push the number
10820 @samp{2:3} on the stack: @kbd{2 :@: 3 @key{RET}}, or @kbd{2 @key{RET} 3 /} 10820 @samp{2:3} on the stack: @kbd{2 :@: 3 @key{RET}}, or @kbd{2 @key{RET} 3 /}
10821 assuming Fraction Mode has been enabled.) 10821 assuming Fraction mode has been enabled.)
10822 When the Calculator produces a fractional result it always reduces it to 10822 When the Calculator produces a fractional result it always reduces it to
10823 simplest form, which may in fact be an integer. 10823 simplest form, which may in fact be an integer.
10824 10824
10825 Fractions may also be entered in a three-part form, where @samp{2:3:4} 10825 Fractions may also be entered in a three-part form, where @samp{2:3:4}
10826 represents two-and-three-quarters. @xref{Fraction Formats}, for fraction 10826 represents two-and-three-quarters. @xref{Fraction Formats}, for fraction
10930 @xref{Incomplete Objects}. 10930 @xref{Incomplete Objects}.
10931 10931
10932 Operations on rectangular complex numbers yield rectangular complex 10932 Operations on rectangular complex numbers yield rectangular complex
10933 results, and similarly for polar complex numbers. Where the two types 10933 results, and similarly for polar complex numbers. Where the two types
10934 are mixed, or where new complex numbers arise (as for the square root of 10934 are mixed, or where new complex numbers arise (as for the square root of
10935 a negative real), the current @dfn{Polar Mode} is used to determine the 10935 a negative real), the current @dfn{Polar mode} is used to determine the
10936 type. @xref{Polar Mode}. 10936 type. @xref{Polar Mode}.
10937 10937
10938 A complex result in which the imaginary part is zero (or the phase angle 10938 A complex result in which the imaginary part is zero (or the phase angle
10939 is 0 or 180 degrees or @cpi{} radians) is automatically converted to a real 10939 is 0 or 180 degrees or @cpi{} radians) is automatically converted to a real
10940 number. 10940 number.
11018 misnomer, since @code{nan} @emph{does} stand for some number or 11018 misnomer, since @code{nan} @emph{does} stand for some number or
11019 infinity, it's just that @emph{which} number it stands for 11019 infinity, it's just that @emph{which} number it stands for
11020 cannot be determined.) In Calc's notation, @samp{0 * inf = nan} 11020 cannot be determined.) In Calc's notation, @samp{0 * inf = nan}
11021 and @samp{inf / inf = nan}. A few other common indeterminate 11021 and @samp{inf / inf = nan}. A few other common indeterminate
11022 expressions are @samp{inf - inf} and @samp{inf ^ 0}. Also, 11022 expressions are @samp{inf - inf} and @samp{inf ^ 0}. Also,
11023 @samp{0 / 0 = nan} if you have turned on ``infinite mode'' 11023 @samp{0 / 0 = nan} if you have turned on Infinite mode
11024 (as described above). 11024 (as described above).
11025 11025
11026 Infinities are especially useful as parts of @dfn{intervals}. 11026 Infinities are especially useful as parts of @dfn{intervals}.
11027 @xref{Interval Forms}. 11027 @xref{Interval Forms}.
11028 11028
11584 left to right, so that @samp{1...1e2} is interpreted as @samp{1.0 ..@: 1e2} 11584 left to right, so that @samp{1...1e2} is interpreted as @samp{1.0 ..@: 1e2}
11585 rather than @samp{1 ..@: 0.1e2}. Add spaces or zeros if you want to 11585 rather than @samp{1 ..@: 0.1e2}. Add spaces or zeros if you want to
11586 get the other interpretation. If you omit the lower or upper limit, 11586 get the other interpretation. If you omit the lower or upper limit,
11587 a default of @samp{-inf} or @samp{inf} (respectively) is furnished. 11587 a default of @samp{-inf} or @samp{inf} (respectively) is furnished.
11588 11588
11589 ``Infinite mode'' also affects operations on intervals 11589 Infinite mode also affects operations on intervals
11590 (@pxref{Infinities}). Calc will always introduce an open infinity, 11590 (@pxref{Infinities}). Calc will always introduce an open infinity,
11591 as in @samp{1 / (0 .. 2] = [0.5 .. inf)}. But closed infinities, 11591 as in @samp{1 / (0 .. 2] = [0.5 .. inf)}. But closed infinities,
11592 @w{@samp{1 / [0 .. 2] = [0.5 .. inf]}}, arise only in infinite mode; 11592 @w{@samp{1 / [0 .. 2] = [0.5 .. inf]}}, arise only in Infinite mode;
11593 otherwise they are left unevaluated. Note that the ``direction'' of 11593 otherwise they are left unevaluated. Note that the ``direction'' of
11594 a zero is not an issue in this case since the zero is always assumed 11594 a zero is not an issue in this case since the zero is always assumed
11595 to be continuous with the rest of the interval. For intervals that 11595 to be continuous with the rest of the interval. For intervals that
11596 contain zero inside them Calc is forced to give the result, 11596 contain zero inside them Calc is forced to give the result,
11597 @samp{1 / (-2 .. 2) = [-inf .. inf]}. 11597 @samp{1 / (-2 .. 2) = [-inf .. inf]}.
11902 11902
11903 Commands that interpret (``parse'') text as algebraic formulas include 11903 Commands that interpret (``parse'') text as algebraic formulas include
11904 algebraic entry (@kbd{'}), editing commands like @kbd{`} which parse 11904 algebraic entry (@kbd{'}), editing commands like @kbd{`} which parse
11905 the contents of the editing buffer when you finish, the @kbd{M-# g} 11905 the contents of the editing buffer when you finish, the @kbd{M-# g}
11906 and @w{@kbd{M-# r}} commands, the @kbd{C-y} command, the X window system 11906 and @w{@kbd{M-# r}} commands, the @kbd{C-y} command, the X window system
11907 ``paste'' mouse operation, and Embedded Mode. All of these operations 11907 ``paste'' mouse operation, and Embedded mode. All of these operations
11908 use the same rules for parsing formulas; in particular, language modes 11908 use the same rules for parsing formulas; in particular, language modes
11909 (@pxref{Language Modes}) affect them all in the same way. 11909 (@pxref{Language Modes}) affect them all in the same way.
11910 11910
11911 When you read a large amount of text into the Calculator (say a vector 11911 When you read a large amount of text into the Calculator (say a vector
11912 which represents a big set of rewrite rules; @pxref{Rewrite Rules}), 11912 which represents a big set of rewrite rules; @pxref{Rewrite Rules}),
12311 12311
12312 @kindex m R 12312 @kindex m R
12313 @pindex calc-mode-record-mode 12313 @pindex calc-mode-record-mode
12314 The @kbd{m R} (@code{calc-mode-record-mode}) command tells Calc to 12314 The @kbd{m R} (@code{calc-mode-record-mode}) command tells Calc to
12315 record the new mode settings (as if by pressing @kbd{m m}) every 12315 record the new mode settings (as if by pressing @kbd{m m}) every
12316 time a mode setting changes. If Embedded Mode is enabled, other 12316 time a mode setting changes. If Embedded mode is enabled, other
12317 options are available; @pxref{Mode Settings in Embedded Mode}. 12317 options are available; @pxref{Mode Settings in Embedded Mode}.
12318 12318
12319 @kindex m F 12319 @kindex m F
12320 @pindex calc-settings-file-name 12320 @pindex calc-settings-file-name
12321 The @kbd{m F} (@code{calc-settings-file-name}) command allows you to 12321 The @kbd{m F} (@code{calc-settings-file-name}) command allows you to
12492 12492
12493 Functions that compute angles produce a number in radians, a number in 12493 Functions that compute angles produce a number in radians, a number in
12494 degrees, or an HMS form depending on the current angular mode. If the 12494 degrees, or an HMS form depending on the current angular mode. If the
12495 result is a complex number and the current mode is HMS, the number is 12495 result is a complex number and the current mode is HMS, the number is
12496 instead expressed in degrees. (Complex-number calculations would 12496 instead expressed in degrees. (Complex-number calculations would
12497 normally be done in radians mode, though. Complex numbers are converted 12497 normally be done in Radians mode, though. Complex numbers are converted
12498 to degrees by calculating the complex result in radians and then 12498 to degrees by calculating the complex result in radians and then
12499 multiplying by 180 over @cpi{}.) 12499 multiplying by 180 over @cpi{}.)
12500 12500
12501 @kindex m r 12501 @kindex m r
12502 @pindex calc-radians-mode 12502 @pindex calc-radians-mode
12505 @kindex m h 12505 @kindex m h
12506 @pindex calc-hms-mode 12506 @pindex calc-hms-mode
12507 The @kbd{m r} (@code{calc-radians-mode}), @kbd{m d} (@code{calc-degrees-mode}), 12507 The @kbd{m r} (@code{calc-radians-mode}), @kbd{m d} (@code{calc-degrees-mode}),
12508 and @kbd{m h} (@code{calc-hms-mode}) commands control the angular mode. 12508 and @kbd{m h} (@code{calc-hms-mode}) commands control the angular mode.
12509 The current angular mode is displayed on the Emacs mode line. 12509 The current angular mode is displayed on the Emacs mode line.
12510 The default angular mode is degrees. 12510 The default angular mode is Degrees.
12511 12511
12512 @node Polar Mode, Fraction Mode, Angular Modes, Calculation Modes 12512 @node Polar Mode, Fraction Mode, Angular Modes, Calculation Modes
12513 @subsection Polar Mode 12513 @subsection Polar Mode
12514 12514
12515 @noindent 12515 @noindent
12521 number, or by entering @kbd{( 2 @key{SPC} 3 )}. 12521 number, or by entering @kbd{( 2 @key{SPC} 3 )}.
12522 12522
12523 @kindex m p 12523 @kindex m p
12524 @pindex calc-polar-mode 12524 @pindex calc-polar-mode
12525 The @kbd{m p} (@code{calc-polar-mode}) command toggles complex-number 12525 The @kbd{m p} (@code{calc-polar-mode}) command toggles complex-number
12526 preference between rectangular and polar forms. In polar mode, all 12526 preference between rectangular and polar forms. In Polar mode, all
12527 of the above example situations would produce polar complex numbers. 12527 of the above example situations would produce polar complex numbers.
12528 12528
12529 @node Fraction Mode, Infinite Mode, Polar Mode, Calculation Modes 12529 @node Fraction Mode, Infinite Mode, Polar Mode, Calculation Modes
12530 @subsection Fraction Mode 12530 @subsection Fraction Mode
12531 12531
12541 @kindex m f 12541 @kindex m f
12542 @pindex calc-frac-mode 12542 @pindex calc-frac-mode
12543 To set the Calculator to produce fractional results for normal integer 12543 To set the Calculator to produce fractional results for normal integer
12544 divisions, use the @kbd{m f} (@code{calc-frac-mode}) command. 12544 divisions, use the @kbd{m f} (@code{calc-frac-mode}) command.
12545 For example, @expr{8/4} produces @expr{2} in either mode, 12545 For example, @expr{8/4} produces @expr{2} in either mode,
12546 but @expr{6/4} produces @expr{3:2} in Fraction Mode, @expr{1.5} in 12546 but @expr{6/4} produces @expr{3:2} in Fraction mode, @expr{1.5} in
12547 Float Mode. 12547 Float mode.
12548 12548
12549 At any time you can use @kbd{c f} (@code{calc-float}) to convert a 12549 At any time you can use @kbd{c f} (@code{calc-float}) to convert a
12550 fraction to a float, or @kbd{c F} (@code{calc-fraction}) to convert a 12550 fraction to a float, or @kbd{c F} (@code{calc-fraction}) to convert a
12551 float to a fraction. @xref{Conversions}. 12551 float to a fraction. @xref{Conversions}.
12552 12552
12565 The @kbd{m i} (@code{calc-infinite-mode}) command turns this mode 12565 The @kbd{m i} (@code{calc-infinite-mode}) command turns this mode
12566 on and off. When the mode is off, infinities do not arise except 12566 on and off. When the mode is off, infinities do not arise except
12567 in calculations that already had infinities as inputs. (One exception 12567 in calculations that already had infinities as inputs. (One exception
12568 is that infinite open intervals like @samp{[0 .. inf)} can be 12568 is that infinite open intervals like @samp{[0 .. inf)} can be
12569 generated; however, intervals closed at infinity (@samp{[0 .. inf]}) 12569 generated; however, intervals closed at infinity (@samp{[0 .. inf]})
12570 will not be generated when infinite mode is off.) 12570 will not be generated when Infinite mode is off.)
12571 12571
12572 With infinite mode turned on, @samp{1 / 0} will generate @code{uinf}, 12572 With Infinite mode turned on, @samp{1 / 0} will generate @code{uinf},
12573 an undirected infinity. @xref{Infinities}, for a discussion of the 12573 an undirected infinity. @xref{Infinities}, for a discussion of the
12574 difference between @code{inf} and @code{uinf}. Also, @expr{0 / 0} 12574 difference between @code{inf} and @code{uinf}. Also, @expr{0 / 0}
12575 evaluates to @code{nan}, the ``indeterminate'' symbol. Various other 12575 evaluates to @code{nan}, the ``indeterminate'' symbol. Various other
12576 functions can also return infinities in this mode; for example, 12576 functions can also return infinities in this mode; for example,
12577 @samp{ln(0) = -inf}, and @samp{gamma(-7) = uinf}. Once again, 12577 @samp{ln(0) = -inf}, and @samp{gamma(-7) = uinf}. Once again,
12578 note that @samp{exp(inf) = inf} regardless of infinite mode because 12578 note that @samp{exp(inf) = inf} regardless of Infinite mode because
12579 this calculation has infinity as an input. 12579 this calculation has infinity as an input.
12580 12580
12581 @cindex Positive infinite mode 12581 @cindex Positive Infinite mode
12582 The @kbd{m i} command with a numeric prefix argument of zero, 12582 The @kbd{m i} command with a numeric prefix argument of zero,
12583 i.e., @kbd{C-u 0 m i}, turns on a ``positive infinite mode'' in 12583 i.e., @kbd{C-u 0 m i}, turns on a Positive Infinite mode in
12584 which zero is treated as positive instead of being directionless. 12584 which zero is treated as positive instead of being directionless.
12585 Thus, @samp{1 / 0 = inf} and @samp{-1 / 0 = -inf} in this mode. 12585 Thus, @samp{1 / 0 = inf} and @samp{-1 / 0 = -inf} in this mode.
12586 Note that zero never actually has a sign in Calc; there are no 12586 Note that zero never actually has a sign in Calc; there are no
12587 separate representations for @mathit{+0} and @mathit{-0}. Positive 12587 separate representations for @mathit{+0} and @mathit{-0}. Positive
12588 infinite mode merely changes the interpretation given to the 12588 Infinite mode merely changes the interpretation given to the
12589 single symbol, @samp{0}. One consequence of this is that, while 12589 single symbol, @samp{0}. One consequence of this is that, while
12590 you might expect @samp{1 / -0 = -inf}, actually @samp{1 / -0} 12590 you might expect @samp{1 / -0 = -inf}, actually @samp{1 / -0}
12591 is equivalent to @samp{1 / 0}, which is equal to positive @code{inf}. 12591 is equivalent to @samp{1 / 0}, which is equal to positive @code{inf}.
12592 12592
12593 @node Symbolic Mode, Matrix Mode, Infinite Mode, Calculation Modes 12593 @node Symbolic Mode, Matrix Mode, Infinite Mode, Calculation Modes
12602 number or a symbolic expression if the argument is an expression: 12602 number or a symbolic expression if the argument is an expression:
12603 @kbd{2 Q} pushes 1.4142 but @kbd{@key{'} x+1 @key{RET} Q} pushes @samp{sqrt(x+1)}. 12603 @kbd{2 Q} pushes 1.4142 but @kbd{@key{'} x+1 @key{RET} Q} pushes @samp{sqrt(x+1)}.
12604 12604
12605 @kindex m s 12605 @kindex m s
12606 @pindex calc-symbolic-mode 12606 @pindex calc-symbolic-mode
12607 In @dfn{symbolic mode}, controlled by the @kbd{m s} (@code{calc-symbolic-mode}) 12607 In @dfn{Symbolic mode}, controlled by the @kbd{m s} (@code{calc-symbolic-mode})
12608 command, functions which would produce inexact, irrational results are 12608 command, functions which would produce inexact, irrational results are
12609 left in symbolic form. Thus @kbd{16 Q} pushes 4, but @kbd{2 Q} pushes 12609 left in symbolic form. Thus @kbd{16 Q} pushes 4, but @kbd{2 Q} pushes
12610 @samp{sqrt(2)}. 12610 @samp{sqrt(2)}.
12611 12611
12612 @kindex N 12612 @kindex N
12629 @noindent 12629 @noindent
12630 @cindex Matrix mode 12630 @cindex Matrix mode
12631 @cindex Scalar mode 12631 @cindex Scalar mode
12632 Calc sometimes makes assumptions during algebraic manipulation that 12632 Calc sometimes makes assumptions during algebraic manipulation that
12633 are awkward or incorrect when vectors and matrices are involved. 12633 are awkward or incorrect when vectors and matrices are involved.
12634 Calc has two modes, @dfn{matrix mode} and @dfn{scalar mode}, which 12634 Calc has two modes, @dfn{Matrix mode} and @dfn{Scalar mode}, which
12635 modify its behavior around vectors in useful ways. 12635 modify its behavior around vectors in useful ways.
12636 12636
12637 @kindex m v 12637 @kindex m v
12638 @pindex calc-matrix-mode 12638 @pindex calc-matrix-mode
12639 Press @kbd{m v} (@code{calc-matrix-mode}) once to enter matrix mode. 12639 Press @kbd{m v} (@code{calc-matrix-mode}) once to enter Matrix mode.
12640 In this mode, all objects are assumed to be matrices unless provably 12640 In this mode, all objects are assumed to be matrices unless provably
12641 otherwise. One major effect is that Calc will no longer consider 12641 otherwise. One major effect is that Calc will no longer consider
12642 multiplication to be commutative. (Recall that in matrix arithmetic, 12642 multiplication to be commutative. (Recall that in matrix arithmetic,
12643 @samp{A*B} is not the same as @samp{B*A}.) This assumption affects 12643 @samp{A*B} is not the same as @samp{B*A}.) This assumption affects
12644 rewrite rules and algebraic simplification. Another effect of this 12644 rewrite rules and algebraic simplification. Another effect of this
12653 with a matrix whose size is known, it will be converted into 12653 with a matrix whose size is known, it will be converted into
12654 a true identity matrix of the appropriate size. On the other hand, 12654 a true identity matrix of the appropriate size. On the other hand,
12655 if it is combined with a scalar (as in @samp{idn(1) + 2}), Calc 12655 if it is combined with a scalar (as in @samp{idn(1) + 2}), Calc
12656 will assume it really was a scalar after all and produce, e.g., 3. 12656 will assume it really was a scalar after all and produce, e.g., 3.
12657 12657
12658 Press @kbd{m v} a second time to get scalar mode. Here, objects are 12658 Press @kbd{m v} a second time to get Scalar mode. Here, objects are
12659 assumed @emph{not} to be vectors or matrices unless provably so. 12659 assumed @emph{not} to be vectors or matrices unless provably so.
12660 For example, normally adding a variable to a vector, as in 12660 For example, normally adding a variable to a vector, as in
12661 @samp{[x, y, z] + a}, will leave the sum in symbolic form because 12661 @samp{[x, y, z] + a}, will leave the sum in symbolic form because
12662 as far as Calc knows, @samp{a} could represent either a number or 12662 as far as Calc knows, @samp{a} could represent either a number or
12663 another 3-vector. In scalar mode, @samp{a} is assumed to be a 12663 another 3-vector. In Scalar mode, @samp{a} is assumed to be a
12664 non-vector, and the addition is evaluated to @samp{[x+a, y+a, z+a]}. 12664 non-vector, and the addition is evaluated to @samp{[x+a, y+a, z+a]}.
12665 12665
12666 Press @kbd{m v} a third time to return to the normal mode of operation. 12666 Press @kbd{m v} a third time to return to the normal mode of operation.
12667 12667
12668 If you press @kbd{m v} with a numeric prefix argument @var{n}, you 12668 If you press @kbd{m v} with a numeric prefix argument @var{n}, you
12669 get a special ``dimensioned matrix mode'' in which matrices of 12669 get a special ``dimensioned'' Matrix mode in which matrices of
12670 unknown size are assumed to be @var{n}x@var{n} square matrices. 12670 unknown size are assumed to be @var{n}x@var{n} square matrices.
12671 Then, the function call @samp{idn(1)} will expand into an actual 12671 Then, the function call @samp{idn(1)} will expand into an actual
12672 matrix rather than representing a ``generic'' matrix. 12672 matrix rather than representing a ``generic'' matrix.
12673 12673
12674 @cindex Declaring scalar variables 12674 @cindex Declaring scalar variables
12685 @samp{[1, 2, 3]} in @samp{a}. The result would not be the same as 12685 @samp{[1, 2, 3]} in @samp{a}. The result would not be the same as
12686 for @samp{[x, y, z] + [1, 2, 3]}, but that's because you have broken 12686 for @samp{[x, y, z] + [1, 2, 3]}, but that's because you have broken
12687 your earlier promise to Calc that @samp{a} would be scalar. 12687 your earlier promise to Calc that @samp{a} would be scalar.
12688 12688
12689 Another way to mix scalars and matrices is to use selections 12689 Another way to mix scalars and matrices is to use selections
12690 (@pxref{Selecting Subformulas}). Use matrix mode when operating on 12690 (@pxref{Selecting Subformulas}). Use Matrix mode when operating on
12691 your formula normally; then, to apply scalar mode to a certain part 12691 your formula normally; then, to apply Scalar mode to a certain part
12692 of the formula without affecting the rest just select that part, 12692 of the formula without affecting the rest just select that part,
12693 change into scalar mode and press @kbd{=} to resimplify the part 12693 change into Scalar mode and press @kbd{=} to resimplify the part
12694 under this mode, then change back to matrix mode before deselecting. 12694 under this mode, then change back to Matrix mode before deselecting.
12695 12695
12696 @node Automatic Recomputation, Working Message, Matrix Mode, Calculation Modes 12696 @node Automatic Recomputation, Working Message, Matrix Mode, Calculation Modes
12697 @subsection Automatic Recomputation 12697 @subsection Automatic Recomputation
12698 12698
12699 @noindent 12699 @noindent
12705 @kindex m C 12705 @kindex m C
12706 @pindex calc-auto-recompute 12706 @pindex calc-auto-recompute
12707 The @kbd{m C} (@code{calc-auto-recompute}) command turns this 12707 The @kbd{m C} (@code{calc-auto-recompute}) command turns this
12708 automatic recomputation on and off. If you turn it off, Calc will 12708 automatic recomputation on and off. If you turn it off, Calc will
12709 not update @samp{=>} operators on the stack (nor those in the 12709 not update @samp{=>} operators on the stack (nor those in the
12710 attached Embedded Mode buffer, if there is one). They will not 12710 attached Embedded mode buffer, if there is one). They will not
12711 be updated unless you explicitly do so by pressing @kbd{=} or until 12711 be updated unless you explicitly do so by pressing @kbd{=} or until
12712 you press @kbd{m C} to turn recomputation back on. (While automatic 12712 you press @kbd{m C} to turn recomputation back on. (While automatic
12713 recomputation is off, you can think of @kbd{m C m C} as a command 12713 recomputation is off, you can think of @kbd{m C m C} as a command
12714 to update all @samp{=>} operators while leaving recomputation off.) 12714 to update all @samp{=>} operators while leaving recomputation off.)
12715 12715
12826 12826
12827 A common technique is to set the simplification mode down to the lowest 12827 A common technique is to set the simplification mode down to the lowest
12828 amount of simplification you will allow to be applied automatically, then 12828 amount of simplification you will allow to be applied automatically, then
12829 use manual commands like @kbd{a s} and @kbd{c c} (@code{calc-clean}) to 12829 use manual commands like @kbd{a s} and @kbd{c c} (@code{calc-clean}) to
12830 perform higher types of simplifications on demand. @xref{Algebraic 12830 perform higher types of simplifications on demand. @xref{Algebraic
12831 Definitions}, for another sample use of no-simplification mode. 12831 Definitions}, for another sample use of No-Simplification mode.
12832 12832
12833 @node Declarations, Display Modes, Simplification Modes, Mode Settings 12833 @node Declarations, Display Modes, Simplification Modes, Mode Settings
12834 @section Declarations 12834 @section Declarations
12835 12835
12836 @noindent 12836 @noindent
13073 but the terms in @samp{x y} will never be exchanged if both @code{x} 13073 but the terms in @samp{x y} will never be exchanged if both @code{x}
13074 and @code{y} are known to be vectors or matrices. (Calc currently 13074 and @code{y} are known to be vectors or matrices. (Calc currently
13075 never distinguishes between @code{vector} and @code{matrix} 13075 never distinguishes between @code{vector} and @code{matrix}
13076 declarations.) 13076 declarations.)
13077 13077
13078 @xref{Matrix Mode}, for a discussion of ``matrix mode'' and 13078 @xref{Matrix Mode}, for a discussion of Matrix mode and
13079 ``scalar mode,'' which are similar to declaring @samp{[All, matrix]} 13079 Scalar mode, which are similar to declaring @samp{[All, matrix]}
13080 or @samp{[All, scalar]} but much more convenient. 13080 or @samp{[All, scalar]} but much more convenient.
13081 13081
13082 One more type symbol that is recognized is used with the @kbd{H a d} 13082 One more type symbol that is recognized is used with the @kbd{H a d}
13083 command for taking total derivatives of a formula. @xref{Calculus}. 13083 command for taking total derivatives of a formula. @xref{Calculus}.
13084 13084
13226 @starindex 13226 @starindex
13227 @end ignore 13227 @end ignore
13228 @tindex dscalar 13228 @tindex dscalar
13229 The @code{dscalar} function returns 1 if its argument is provably 13229 The @code{dscalar} function returns 1 if its argument is provably
13230 scalar, or 0 if its argument is provably non-scalar. It is left 13230 scalar, or 0 if its argument is provably non-scalar. It is left
13231 unevaluated if this cannot be determined. (If matrix mode or scalar 13231 unevaluated if this cannot be determined. (If Matrix mode or Scalar
13232 mode are in effect, this function returns 1 or 0, respectively, 13232 mode is in effect, this function returns 1 or 0, respectively,
13233 if it has no other information.) When Calc interprets a condition 13233 if it has no other information.) When Calc interprets a condition
13234 (say, in a rewrite rule) it considers an unevaluated formula to be 13234 (say, in a rewrite rule) it considers an unevaluated formula to be
13235 ``false.'' Thus, @samp{dscalar(a)} is ``true'' only if @code{a} is 13235 ``false.'' Thus, @samp{dscalar(a)} is ``true'' only if @code{a} is
13236 provably scalar, and @samp{!dscalar(a)} is ``true'' only if @code{a} 13236 provably scalar, and @samp{!dscalar(a)} is ``true'' only if @code{a}
13237 is provably non-scalar; both are ``false'' if there is insufficient 13237 is provably non-scalar; both are ``false'' if there is insufficient
13336 @pindex calc-group-digits 13336 @pindex calc-group-digits
13337 @cindex Grouping digits 13337 @cindex Grouping digits
13338 @cindex Digit grouping 13338 @cindex Digit grouping
13339 Long numbers can be hard to read if they have too many digits. For 13339 Long numbers can be hard to read if they have too many digits. For
13340 example, the factorial of 30 is 33 digits long! Press @kbd{d g} 13340 example, the factorial of 30 is 33 digits long! Press @kbd{d g}
13341 (@code{calc-group-digits}) to enable @dfn{grouping} mode, in which digits 13341 (@code{calc-group-digits}) to enable @dfn{Grouping} mode, in which digits
13342 are displayed in clumps of 3 or 4 (depending on the current radix) 13342 are displayed in clumps of 3 or 4 (depending on the current radix)
13343 separated by commas. 13343 separated by commas.
13344 13344
13345 The @kbd{d g} command toggles grouping on and off. 13345 The @kbd{d g} command toggles grouping on and off.
13346 With a numerix prefix of 0, this command displays the current state of 13346 With a numerix prefix of 0, this command displays the current state of
13882 @kindex d > 13882 @kindex d >
13883 @pindex calc-right-justify 13883 @pindex calc-right-justify
13884 Values on the stack are normally left-justified in the window. You can 13884 Values on the stack are normally left-justified in the window. You can
13885 control this arrangement by typing @kbd{d <} (@code{calc-left-justify}), 13885 control this arrangement by typing @kbd{d <} (@code{calc-left-justify}),
13886 @kbd{d >} (@code{calc-right-justify}), or @kbd{d =} 13886 @kbd{d >} (@code{calc-right-justify}), or @kbd{d =}
13887 (@code{calc-center-justify}). For example, in right-justification mode, 13887 (@code{calc-center-justify}). For example, in Right-Justification mode,
13888 stack entries are displayed flush-right against the right edge of the 13888 stack entries are displayed flush-right against the right edge of the
13889 window. 13889 window.
13890 13890
13891 If you change the width of the Calculator window you may have to type 13891 If you change the width of the Calculator window you may have to type
13892 @kbd{d @key{SPC}} (@code{calc-refresh}) to re-align right-justified or centered 13892 @kbd{d @key{SPC}} (@code{calc-refresh}) to re-align right-justified or centered
13903 Language Modes}). For reference, the precise rules for formatting and 13903 Language Modes}). For reference, the precise rules for formatting and
13904 breaking lines are given below. Notice that the interaction between 13904 breaking lines are given below. Notice that the interaction between
13905 origin and line width is slightly different in each justification 13905 origin and line width is slightly different in each justification
13906 mode. 13906 mode.
13907 13907
13908 In left-justified mode, the line is indented by a number of spaces 13908 In Left-Justified mode, the line is indented by a number of spaces
13909 given by the origin (default zero). If the result is longer than the 13909 given by the origin (default zero). If the result is longer than the
13910 maximum line width, if given, or too wide to fit in the Calc window 13910 maximum line width, if given, or too wide to fit in the Calc window
13911 otherwise, then it is broken into lines which will fit; each broken 13911 otherwise, then it is broken into lines which will fit; each broken
13912 line is indented to the origin. 13912 line is indented to the origin.
13913 13913
13914 In right-justified mode, lines are shifted right so that the rightmost 13914 In Right-Justified mode, lines are shifted right so that the rightmost
13915 character is just before the origin, or just before the current 13915 character is just before the origin, or just before the current
13916 window width if no origin was specified. If the line is too long 13916 window width if no origin was specified. If the line is too long
13917 for this, then it is broken; the current line width is used, if 13917 for this, then it is broken; the current line width is used, if
13918 specified, or else the origin is used as a width if that is 13918 specified, or else the origin is used as a width if that is
13919 specified, or else the line is broken to fit in the window. 13919 specified, or else the line is broken to fit in the window.
13920 13920
13921 In centering mode, the origin is the column number of the center of 13921 In Centering mode, the origin is the column number of the center of
13922 each stack entry. If a line width is specified, lines will not be 13922 each stack entry. If a line width is specified, lines will not be
13923 allowed to go past that width; Calc will either indent less or 13923 allowed to go past that width; Calc will either indent less or
13924 break the lines if necessary. If no origin is specified, half the 13924 break the lines if necessary. If no origin is specified, half the
13925 line width or Calc window width is used. 13925 line width or Calc window width is used.
13926 13926
13951 @kindex d @} 13951 @kindex d @}
13952 @pindex calc-right-label 13952 @pindex calc-right-label
13953 The @kbd{d @}} (@code{calc-right-label}) command similarly adds a 13953 The @kbd{d @}} (@code{calc-right-label}) command similarly adds a
13954 label on the righthand side. It does not affect positioning of 13954 label on the righthand side. It does not affect positioning of
13955 the stack entries unless they are right-justified. Also, if both 13955 the stack entries unless they are right-justified. Also, if both
13956 a line width and an origin are given in right-justified mode, the 13956 a line width and an origin are given in Right-Justified mode, the
13957 stack entry is justified to the origin and the righthand label is 13957 stack entry is justified to the origin and the righthand label is
13958 justified to the line width. 13958 justified to the line width.
13959 13959
13960 One application of labels would be to add equation numbers to 13960 One application of labels would be to add equation numbers to
13961 formulas you are manipulating in Calc and then copying into a 13961 formulas you are manipulating in Calc and then copying into a
13962 document (possibly using Embedded Mode). The equations would 13962 document (possibly using Embedded mode). The equations would
13963 typically be centered, and the equation numbers would be on the 13963 typically be centered, and the equation numbers would be on the
13964 left or right as you prefer. 13964 left or right as you prefer.
13965 13965
13966 @node Language Modes, Modes Variable, Display Modes, Mode Settings 13966 @node Language Modes, Modes Variable, Display Modes, Mode Settings
13967 @section Language Modes 13967 @section Language Modes
14059 @end example 14059 @end example
14060 14060
14061 @noindent 14061 @noindent
14062 in place of @samp{sqrt((a+1)/b + c^2)}. 14062 in place of @samp{sqrt((a+1)/b + c^2)}.
14063 14063
14064 Subscripts like @samp{a_i} are displayed as actual subscripts in ``big'' 14064 Subscripts like @samp{a_i} are displayed as actual subscripts in Big
14065 mode. Double subscripts, @samp{a_i_j} (@samp{subscr(subscr(a, i), j)}) 14065 mode. Double subscripts, @samp{a_i_j} (@samp{subscr(subscr(a, i), j)})
14066 are displayed as @samp{a} with subscripts separated by commas: 14066 are displayed as @samp{a} with subscripts separated by commas:
14067 @samp{i, j}. They must still be entered in the usual underscore 14067 @samp{i, j}. They must still be entered in the usual underscore
14068 notation. 14068 notation.
14069 14069
14132 14132
14133 In C mode, vectors and matrices use curly braces instead of brackets. 14133 In C mode, vectors and matrices use curly braces instead of brackets.
14134 Octal and hexadecimal values are written with leading @samp{0} or @samp{0x} 14134 Octal and hexadecimal values are written with leading @samp{0} or @samp{0x}
14135 rather than using the @samp{#} symbol. Array subscripting is 14135 rather than using the @samp{#} symbol. Array subscripting is
14136 translated into @code{subscr} calls, so that @samp{a[i]} in C 14136 translated into @code{subscr} calls, so that @samp{a[i]} in C
14137 mode is the same as @samp{a_i} in normal mode. Assignments 14137 mode is the same as @samp{a_i} in Normal mode. Assignments
14138 turn into the @code{assign} function, which Calc normally displays 14138 turn into the @code{assign} function, which Calc normally displays
14139 using the @samp{:=} symbol. 14139 using the @samp{:=} symbol.
14140 14140
14141 The variables @code{var-pi} and @code{var-e} would be displayed @samp{pi} 14141 The variables @code{var-pi} and @code{var-e} would be displayed @samp{pi}
14142 and @samp{e} in normal mode, but in C mode they are displayed as 14142 and @samp{e} in Normal mode, but in C mode they are displayed as
14143 @samp{M_PI} and @samp{M_E}, corresponding to the names of constants 14143 @samp{M_PI} and @samp{M_E}, corresponding to the names of constants
14144 typically provided in the @file{<math.h>} header. Functions whose 14144 typically provided in the @file{<math.h>} header. Functions whose
14145 names are different in C are translated automatically for entry and 14145 names are different in C are translated automatically for entry and
14146 display purposes. For example, entering @samp{asin(x)} will push the 14146 display purposes. For example, entering @samp{asin(x)} will push the
14147 formula @samp{arcsin(x)} onto the stack; this formula will be displayed 14147 formula @samp{arcsin(x)} onto the stack; this formula will be displayed
14179 vector (or unless @code{a} happens to be the name of a built-in 14179 vector (or unless @code{a} happens to be the name of a built-in
14180 function!). 14180 function!).
14181 14181
14182 Underscores are allowed in variable and function names in all of these 14182 Underscores are allowed in variable and function names in all of these
14183 language modes. The underscore here is equivalent to the @samp{#} in 14183 language modes. The underscore here is equivalent to the @samp{#} in
14184 normal mode, or to hyphens in the underlying Emacs Lisp variable names. 14184 Normal mode, or to hyphens in the underlying Emacs Lisp variable names.
14185 14185
14186 FORTRAN and Pascal modes normally do not adjust the case of letters in 14186 FORTRAN and Pascal modes normally do not adjust the case of letters in
14187 formulas. Most built-in Calc names use lower-case letters. If you use a 14187 formulas. Most built-in Calc names use lower-case letters. If you use a
14188 positive numeric prefix argument with @kbd{d P} or @kbd{d F}, these 14188 positive numeric prefix argument with @kbd{d P} or @kbd{d F}, these
14189 modes will use upper-case letters exclusively for display, and will 14189 modes will use upper-case letters exclusively for display, and will
14821 @starindex 14821 @starindex
14822 @end ignore 14822 @end ignore
14823 @tindex choriz 14823 @tindex choriz
14824 The @code{choriz} function takes a vector of objects and composes 14824 The @code{choriz} function takes a vector of objects and composes
14825 them horizontally. For example, @samp{choriz([17, a b/c, d])} formats 14825 them horizontally. For example, @samp{choriz([17, a b/c, d])} formats
14826 as @w{@samp{17a b / cd}} in normal language mode, or as 14826 as @w{@samp{17a b / cd}} in Normal language mode, or as
14827 14827
14828 @example 14828 @example
14829 @group 14829 @group
14830 a b 14830 a b
14831 17---d 14831 17---d
15084 @starindex 15084 @starindex
15085 @end ignore 15085 @end ignore
15086 @tindex cwidth 15086 @tindex cwidth
15087 The @code{cwidth} function measures the width, in characters, of a 15087 The @code{cwidth} function measures the width, in characters, of a
15088 composition. For example, @samp{cwidth(a + b)} is 5, and 15088 composition. For example, @samp{cwidth(a + b)} is 5, and
15089 @samp{cwidth(a / b)} is 5 in normal mode, 1 in Big mode, and 11 in 15089 @samp{cwidth(a / b)} is 5 in Normal mode, 1 in Big mode, and 11 in
15090 @TeX{} mode (for @samp{@{a \over b@}}). The argument may involve 15090 @TeX{} mode (for @samp{@{a \over b@}}). The argument may involve
15091 the composition functions described in this section. 15091 the composition functions described in this section.
15092 15092
15093 @ignore 15093 @ignore
15094 @starindex 15094 @starindex
15260 15260
15261 @kindex Z S 15261 @kindex Z S
15262 @pindex calc-edit-user-syntax 15262 @pindex calc-edit-user-syntax
15263 The @kbd{Z S} (@code{calc-edit-user-syntax}) command edits the 15263 The @kbd{Z S} (@code{calc-edit-user-syntax}) command edits the
15264 syntax table for the current language mode. If you want your 15264 syntax table for the current language mode. If you want your
15265 syntax to work in any language, define it in the normal language 15265 syntax to work in any language, define it in the Normal language
15266 mode. Type @kbd{M-# M-#} to finish editing the syntax table, or 15266 mode. Type @kbd{M-# M-#} to finish editing the syntax table, or
15267 @kbd{M-# x} to cancel the edit. The @kbd{m m} command saves all 15267 @kbd{M-# x} to cancel the edit. The @kbd{m m} command saves all
15268 the syntax tables along with the other mode settings; 15268 the syntax tables along with the other mode settings;
15269 @pxref{General Mode Commands}. 15269 @pxref{General Mode Commands}.
15270 15270
15291 zero or more expressions separated by commas, and @samp{)}.'' 15291 zero or more expressions separated by commas, and @samp{)}.''
15292 15292
15293 A @dfn{syntax table} is a list of user-defined @dfn{syntax rules}, 15293 A @dfn{syntax table} is a list of user-defined @dfn{syntax rules},
15294 which allow you to specify new patterns to define your own 15294 which allow you to specify new patterns to define your own
15295 favorite input notations. Calc's parser always checks the syntax 15295 favorite input notations. Calc's parser always checks the syntax
15296 table for the current language mode, then the table for the normal 15296 table for the current language mode, then the table for the Normal
15297 language mode, before it uses its built-in rules to parse an 15297 language mode, before it uses its built-in rules to parse an
15298 algebraic formula you have entered. Each syntax rule should go on 15298 algebraic formula you have entered. Each syntax rule should go on
15299 its own line; it consists of a @dfn{pattern}, a @samp{:=} symbol, 15299 its own line; it consists of a @dfn{pattern}, a @samp{:=} symbol,
15300 and a Calc formula with an optional @dfn{condition}. (Syntax rules 15300 and a Calc formula with an optional @dfn{condition}. (Syntax rules
15301 resemble algebraic rewrite rules, but the notation for patterns is 15301 resemble algebraic rewrite rules, but the notation for patterns is
15646 This is another way to implement the Maple mode @code{sum} notation. 15646 This is another way to implement the Maple mode @code{sum} notation.
15647 In this approach, we allow @samp{#2} to equal the whole expression 15647 In this approach, we allow @samp{#2} to equal the whole expression
15648 @samp{i=1..10}. Then, we use @code{matches} to break it apart into 15648 @samp{i=1..10}. Then, we use @code{matches} to break it apart into
15649 its components. If the expression turns out not to match the pattern, 15649 its components. If the expression turns out not to match the pattern,
15650 the syntax rule will fail. Note that @kbd{Z S} always uses Calc's 15650 the syntax rule will fail. Note that @kbd{Z S} always uses Calc's
15651 normal language mode for editing expressions in syntax rules, so we 15651 Normal language mode for editing expressions in syntax rules, so we
15652 must use regular Calc notation for the interval @samp{[b..c]} that 15652 must use regular Calc notation for the interval @samp{[b..c]} that
15653 will correspond to the Maple mode interval @samp{1..10}. 15653 will correspond to the Maple mode interval @samp{1..10}.
15654 15654
15655 @node Modes Variable, Calc Mode Line, Language Modes, Mode Settings 15655 @node Modes Variable, Calc Mode Line, Language Modes, Mode Settings
15656 @section The @code{Modes} Variable 15656 @section The @code{Modes} Variable
15719 @item 15719 @item
15720 Polar mode. Value is 0 (rectangular) or 1 (polar); default is 0. 15720 Polar mode. Value is 0 (rectangular) or 1 (polar); default is 0.
15721 Command is @kbd{m p}. 15721 Command is @kbd{m p}.
15722 15722
15723 @item 15723 @item
15724 Matrix/scalar mode. Default value is @mathit{-1}. Value is 0 for scalar 15724 Matrix/Scalar mode. Default value is @mathit{-1}. Value is 0 for Scalar
15725 mode, @mathit{-2} for matrix mode, or @var{N} for 15725 mode, @mathit{-2} for Matrix mode, or @var{N} for
15726 @texline @math{N\times N} 15726 @texline @math{N\times N}
15727 @infoline @var{N}x@var{N} 15727 @infoline @var{N}x@var{N}
15728 matrix mode. Command is @kbd{m v}. 15728 Matrix mode. Command is @kbd{m v}.
15729 15729
15730 @item 15730 @item
15731 Simplification mode. Default is 1. Value is @mathit{-1} for off (@kbd{m O}), 15731 Simplification mode. Default is 1. Value is @mathit{-1} for off (@kbd{m O}),
15732 0 for @kbd{m N}, 2 for @kbd{m B}, 3 for @kbd{m A}, 4 for @kbd{m E}, 15732 0 for @kbd{m N}, 2 for @kbd{m B}, 3 for @kbd{m A}, 4 for @kbd{m E},
15733 or 5 for @w{@kbd{m U}}. The @kbd{m D} command accepts these prefixes. 15733 or 5 for @w{@kbd{m U}}. The @kbd{m D} command accepts these prefixes.
15758 15758
15759 @noindent 15759 @noindent
15760 @cindex Mode line indicators 15760 @cindex Mode line indicators
15761 This section is a summary of all symbols that can appear on the 15761 This section is a summary of all symbols that can appear on the
15762 Calc mode line, the highlighted bar that appears under the Calc 15762 Calc mode line, the highlighted bar that appears under the Calc
15763 stack window (or under an editing window in Embedded Mode). 15763 stack window (or under an editing window in Embedded mode).
15764 15764
15765 The basic mode line format is: 15765 The basic mode line format is:
15766 15766
15767 @example 15767 @example
15768 --%%-Calc: 12 Deg @var{other modes} (Calculator) 15768 --%%-Calc: 12 Deg @var{other modes} (Calculator)
15770 15770
15771 The @samp{%%} is the Emacs symbol for ``read-only''; it shows that 15771 The @samp{%%} is the Emacs symbol for ``read-only''; it shows that
15772 regular Emacs commands are not allowed to edit the stack buffer 15772 regular Emacs commands are not allowed to edit the stack buffer
15773 as if it were text. 15773 as if it were text.
15774 15774
15775 The word @samp{Calc:} changes to @samp{CalcEmbed:} if Embedded Mode 15775 The word @samp{Calc:} changes to @samp{CalcEmbed:} if Embedded mode
15776 is enabled. The words after this describe the various Calc modes 15776 is enabled. The words after this describe the various Calc modes
15777 that are in effect. 15777 that are in effect.
15778 15778
15779 The first mode is always the current precision, an integer. 15779 The first mode is always the current precision, an integer.
15780 The second mode is always the angular mode, either @code{Deg}, 15780 The second mode is always the angular mode, either @code{Deg},
15798 15798
15799 @item Matrix 15799 @item Matrix
15800 Matrix mode (@kbd{m v}; @pxref{Matrix Mode}). 15800 Matrix mode (@kbd{m v}; @pxref{Matrix Mode}).
15801 15801
15802 @item Matrix@var{n} 15802 @item Matrix@var{n}
15803 Dimensioned matrix mode (@kbd{C-u @var{n} m v}). 15803 Dimensioned Matrix mode (@kbd{C-u @var{n} m v}).
15804 15804
15805 @item Scalar 15805 @item Scalar
15806 Scalar mode (@kbd{m v}; @pxref{Matrix Mode}). 15806 Scalar mode (@kbd{m v}; @pxref{Matrix Mode}).
15807 15807
15808 @item Polar 15808 @item Polar
15813 15813
15814 @item Inf 15814 @item Inf
15815 Infinite mode (@kbd{m i}; @pxref{Infinite Mode}). 15815 Infinite mode (@kbd{m i}; @pxref{Infinite Mode}).
15816 15816
15817 @item +Inf 15817 @item +Inf
15818 Positive infinite mode (@kbd{C-u 0 m i}). 15818 Positive Infinite mode (@kbd{C-u 0 m i}).
15819 15819
15820 @item NoSimp 15820 @item NoSimp
15821 Default simplifications off (@kbd{m O}; @pxref{Simplification Modes}). 15821 Default simplifications off (@kbd{m O}; @pxref{Simplification Modes}).
15822 15822
15823 @item NumSimp 15823 @item NumSimp
16021 safest assumption. @xref{Reducing and Mapping}, for a way to add @samp{x} 16021 safest assumption. @xref{Reducing and Mapping}, for a way to add @samp{x}
16022 to every element of a vector. 16022 to every element of a vector.
16023 16023
16024 If either argument of @kbd{+} is a complex number, the result will in general 16024 If either argument of @kbd{+} is a complex number, the result will in general
16025 be complex. If one argument is in rectangular form and the other polar, 16025 be complex. If one argument is in rectangular form and the other polar,
16026 the current Polar Mode determines the form of the result. If Symbolic 16026 the current Polar mode determines the form of the result. If Symbolic
16027 Mode is enabled, the sum may be left as a formula if the necessary 16027 mode is enabled, the sum may be left as a formula if the necessary
16028 conversions for polar addition are non-trivial. 16028 conversions for polar addition are non-trivial.
16029 16029
16030 If both arguments of @kbd{+} are HMS forms, the forms are added according to 16030 If both arguments of @kbd{+} are HMS forms, the forms are added according to
16031 the usual conventions of hours-minutes-seconds notation. If one argument 16031 the usual conventions of hours-minutes-seconds notation. If one argument
16032 is an HMS form and the other is a number, that number is converted from 16032 is an HMS form and the other is a number, that number is converted from
16033 degrees or radians (depending on the current Angular Mode) to HMS format 16033 degrees or radians (depending on the current Angular mode) to HMS format
16034 and then the two HMS forms are added. 16034 and then the two HMS forms are added.
16035 16035
16036 If one argument of @kbd{+} is a date form, the other can be either a 16036 If one argument of @kbd{+} is a date form, the other can be either a
16037 real number, which advances the date by a certain number of days, or 16037 real number, which advances the date by a certain number of days, or
16038 an HMS form, which advances the date by a certain amount of time. 16038 an HMS form, which advances the date by a certain amount of time.
16180 @kindex : 16180 @kindex :
16181 @pindex calc-fdiv 16181 @pindex calc-fdiv
16182 @tindex fdiv 16182 @tindex fdiv
16183 The @kbd{:} (@code{calc-fdiv}) command [@code{fdiv} function in a formula] 16183 The @kbd{:} (@code{calc-fdiv}) command [@code{fdiv} function in a formula]
16184 divides the two integers on the top of the stack to produce a fractional 16184 divides the two integers on the top of the stack to produce a fractional
16185 result. This is a convenient shorthand for enabling Fraction Mode (with 16185 result. This is a convenient shorthand for enabling Fraction mode (with
16186 @kbd{m f}) temporarily and using @samp{/}. Note that during numeric entry 16186 @kbd{m f}) temporarily and using @samp{/}. Note that during numeric entry
16187 the @kbd{:} key is interpreted as a fraction separator, so to divide 8 by 6 16187 the @kbd{:} key is interpreted as a fraction separator, so to divide 8 by 6
16188 you would have to type @kbd{8 @key{RET} 6 @key{RET} :}. (Of course, in 16188 you would have to type @kbd{8 @key{RET} 6 @key{RET} :}. (Of course, in
16189 this case, it would be much easier simply to enter the fraction directly 16189 this case, it would be much easier simply to enter the fraction directly
16190 as @kbd{8:6 @key{RET}}!) 16190 as @kbd{8:6 @key{RET}}!)
16234 @kindex Q 16234 @kindex Q
16235 @pindex calc-sqrt 16235 @pindex calc-sqrt
16236 @tindex sqrt 16236 @tindex sqrt
16237 The @kbd{Q} (@code{calc-sqrt}) [@code{sqrt}] command computes the square 16237 The @kbd{Q} (@code{calc-sqrt}) [@code{sqrt}] command computes the square
16238 root of a number. For a negative real argument, the result will be a 16238 root of a number. For a negative real argument, the result will be a
16239 complex number whose form is determined by the current Polar Mode. 16239 complex number whose form is determined by the current Polar mode.
16240 16240
16241 @kindex f h 16241 @kindex f h
16242 @pindex calc-hypot 16242 @pindex calc-hypot
16243 @tindex hypot 16243 @tindex hypot
16244 The @kbd{f h} (@code{calc-hypot}) [@code{hypot}] command computes the square 16244 The @kbd{f h} (@code{calc-hypot}) [@code{hypot}] command computes the square
16296 @tindex scf 16296 @tindex scf
16297 The @kbd{f S} (@code{calc-scale-float}) [@code{scf}] function scales a number 16297 The @kbd{f S} (@code{calc-scale-float}) [@code{scf}] function scales a number
16298 by a given power of ten. Thus, @samp{scf(mant(x), xpon(x)) = x} for any 16298 by a given power of ten. Thus, @samp{scf(mant(x), xpon(x)) = x} for any
16299 real @samp{x}. The second argument must be an integer, but the first 16299 real @samp{x}. The second argument must be an integer, but the first
16300 may actually be any numeric value. For example, @samp{scf(5,-2) = 0.05} 16300 may actually be any numeric value. For example, @samp{scf(5,-2) = 0.05}
16301 or @samp{1:20} depending on the current Fraction Mode. 16301 or @samp{1:20} depending on the current Fraction mode.
16302 16302
16303 @kindex f [ 16303 @kindex f [
16304 @kindex f ] 16304 @kindex f ]
16305 @pindex calc-decrement 16305 @pindex calc-decrement
16306 @pindex calc-increment 16306 @pindex calc-increment
16480 16480
16481 @pindex calc-imaginary 16481 @pindex calc-imaginary
16482 The @code{calc-imaginary} command multiplies the number on the 16482 The @code{calc-imaginary} command multiplies the number on the
16483 top of the stack by the imaginary number @expr{i = (0,1)}. This 16483 top of the stack by the imaginary number @expr{i = (0,1)}. This
16484 command is not normally bound to a key in Calc, but it is available 16484 command is not normally bound to a key in Calc, but it is available
16485 on the @key{IMAG} button in Keypad Mode. 16485 on the @key{IMAG} button in Keypad mode.
16486 16486
16487 @kindex f r 16487 @kindex f r
16488 @pindex calc-re 16488 @pindex calc-re
16489 @tindex re 16489 @tindex re
16490 The @kbd{f r} (@code{calc-re}) [@code{re}] command replaces a complex number 16490 The @kbd{f r} (@code{calc-re}) [@code{re}] command replaces a complex number
17759 formulas below for symbolic arguments only when you use the @kbd{a "} 17759 formulas below for symbolic arguments only when you use the @kbd{a "}
17760 (@code{calc-expand-formula}) command, or when taking derivatives or 17760 (@code{calc-expand-formula}) command, or when taking derivatives or
17761 integrals or solving equations involving the functions. 17761 integrals or solving equations involving the functions.
17762 17762
17763 @ifinfo 17763 @ifinfo
17764 These formulas are shown using the conventions of ``Big'' display 17764 These formulas are shown using the conventions of Big display
17765 mode (@kbd{d B}); for example, the formula for @code{fv} written 17765 mode (@kbd{d B}); for example, the formula for @code{fv} written
17766 linearly is @samp{pmt * ((1 + rate)^n) - 1) / rate}. 17766 linearly is @samp{pmt * ((1 + rate)^n) - 1) / rate}.
17767 17767
17768 @example 17768 @example
17769 n 17769 n
18215 to any base. For example, @kbd{1024 @key{RET} 2 B} produces 10, since 18215 to any base. For example, @kbd{1024 @key{RET} 2 B} produces 10, since
18216 @texline @math{2^{10} = 1024}. 18216 @texline @math{2^{10} = 1024}.
18217 @infoline @expr{2^10 = 1024}. 18217 @infoline @expr{2^10 = 1024}.
18218 In certain cases like @samp{log(3,9)}, the result 18218 In certain cases like @samp{log(3,9)}, the result
18219 will be either @expr{1:2} or @expr{0.5} depending on the current Fraction 18219 will be either @expr{1:2} or @expr{0.5} depending on the current Fraction
18220 Mode setting. With the Inverse flag [@code{alog}], this command is 18220 mode setting. With the Inverse flag [@code{alog}], this command is
18221 similar to @kbd{^} except that the order of the arguments is reversed. 18221 similar to @kbd{^} except that the order of the arguments is reversed.
18222 18222
18223 @kindex f I 18223 @kindex f I
18224 @pindex calc-ilog 18224 @pindex calc-ilog
18225 @tindex ilog 18225 @tindex ilog
18271 of the current angular mode. @xref{Basic Operations on Units}. 18271 of the current angular mode. @xref{Basic Operations on Units}.
18272 18272
18273 Also, the symbolic variable @code{pi} is not ordinarily recognized in 18273 Also, the symbolic variable @code{pi} is not ordinarily recognized in
18274 arguments to trigonometric functions, as in @samp{sin(3 pi / 4)}, but 18274 arguments to trigonometric functions, as in @samp{sin(3 pi / 4)}, but
18275 the @kbd{a s} (@code{calc-simplify}) command recognizes many such 18275 the @kbd{a s} (@code{calc-simplify}) command recognizes many such
18276 formulas when the current angular mode is radians @emph{and} symbolic 18276 formulas when the current angular mode is Radians @emph{and} Symbolic
18277 mode is enabled; this example would be replaced by @samp{sqrt(2) / 2}. 18277 mode is enabled; this example would be replaced by @samp{sqrt(2) / 2}.
18278 @xref{Symbolic Mode}. Beware, this simplification occurs even if you 18278 @xref{Symbolic Mode}. Beware, this simplification occurs even if you
18279 have stored a different value in the variable @samp{pi}; this is one 18279 have stored a different value in the variable @samp{pi}; this is one
18280 reason why changing built-in variables is a bad idea. Arguments of 18280 reason why changing built-in variables is a bad idea. Arguments of
18281 the form @expr{x} plus a multiple of @cpiover{2} are also simplified. 18281 the form @expr{x} plus a multiple of @cpiover{2} are also simplified.
18282 Calc includes similar formulas for @code{cos} and @code{tan}. 18282 Calc includes similar formulas for @code{cos} and @code{tan}.
18283 18283
18284 The @kbd{a s} command knows all angles which are integer multiples of 18284 The @kbd{a s} command knows all angles which are integer multiples of
18285 @cpiover{12}, @cpiover{10}, or @cpiover{8} radians. In degrees mode, 18285 @cpiover{12}, @cpiover{10}, or @cpiover{8} radians. In Degrees mode,
18286 analogous simplifications occur for integer multiples of 15 or 18 18286 analogous simplifications occur for integer multiples of 15 or 18
18287 degrees, and for arguments plus multiples of 90 degrees. 18287 degrees, and for arguments plus multiples of 90 degrees.
18288 18288
18289 @kindex I S 18289 @kindex I S
18290 @pindex calc-arcsin 18290 @pindex calc-arcsin
18631 18631
18632 For @samp{arctanh(z)}: This is defined by @samp{(ln(1+z) - ln(1-z)) / 2}. 18632 For @samp{arctanh(z)}: This is defined by @samp{(ln(1+z) - ln(1-z)) / 2}.
18633 The branch cuts are on the real axis, less than @mathit{-1} and greater than 1. 18633 The branch cuts are on the real axis, less than @mathit{-1} and greater than 1.
18634 18634
18635 The following tables for @code{arcsin}, @code{arccos}, and 18635 The following tables for @code{arcsin}, @code{arccos}, and
18636 @code{arctan} assume the current angular mode is radians. The 18636 @code{arctan} assume the current angular mode is Radians. The
18637 hyperbolic functions operate independently of the angular mode. 18637 hyperbolic functions operate independently of the angular mode.
18638 18638
18639 @smallexample 18639 @smallexample
18640 z arcsin(z) arccos(z) 18640 z arcsin(z) arccos(z)
18641 ------------------------------------------------------- 18641 -------------------------------------------------------
19476 19476
19477 Note that the prefix argument can have an effect even when the input is 19477 Note that the prefix argument can have an effect even when the input is
19478 not a vector. For example, if the input is the number @mathit{-5}, then 19478 not a vector. For example, if the input is the number @mathit{-5}, then
19479 @kbd{c-u -1 v u} yields @mathit{-5} and 0 (the components of @mathit{-5} 19479 @kbd{c-u -1 v u} yields @mathit{-5} and 0 (the components of @mathit{-5}
19480 when viewed as a rectangular complex number); @kbd{C-u -2 v u} yields 5 19480 when viewed as a rectangular complex number); @kbd{C-u -2 v u} yields 5
19481 and 180 (assuming degrees mode); and @kbd{C-u -10 v u} yields @mathit{-5} 19481 and 180 (assuming Degrees mode); and @kbd{C-u -10 v u} yields @mathit{-5}
19482 and 1 (the numerator and denominator of @mathit{-5}, viewed as a rational 19482 and 1 (the numerator and denominator of @mathit{-5}, viewed as a rational
19483 number). Plain @kbd{v u} with this input would complain that the input 19483 number). Plain @kbd{v u} with this input would complain that the input
19484 is not a composite object. 19484 is not a composite object.
19485 19485
19486 Unpacking mode @mathit{-11} converts a float into an integer mantissa and 19486 Unpacking mode @mathit{-11} converts a float into an integer mantissa and
19606 identity matrix of unknown size. Calc can operate algebraically on 19606 identity matrix of unknown size. Calc can operate algebraically on
19607 such generic identity matrices, and if one is combined with a matrix 19607 such generic identity matrices, and if one is combined with a matrix
19608 whose size is known, it is converted automatically to an identity 19608 whose size is known, it is converted automatically to an identity
19609 matrix of a suitable matching size. The @kbd{v i} command with an 19609 matrix of a suitable matching size. The @kbd{v i} command with an
19610 argument of zero creates a generic identity matrix, @samp{idn(1)}. 19610 argument of zero creates a generic identity matrix, @samp{idn(1)}.
19611 Note that in dimensioned matrix mode (@pxref{Matrix Mode}), generic 19611 Note that in dimensioned Matrix mode (@pxref{Matrix Mode}), generic
19612 identity matrices are immediately expanded to the current default 19612 identity matrices are immediately expanded to the current default
19613 dimensions. 19613 dimensions.
19614 19614
19615 @kindex v x 19615 @kindex v x
19616 @pindex calc-index 19616 @pindex calc-index
21263 21263
21264 @xref{Editing Stack Entries}, to see how to manipulate formulas 21264 @xref{Editing Stack Entries}, to see how to manipulate formulas
21265 using regular Emacs editing commands. 21265 using regular Emacs editing commands.
21266 21266
21267 When doing algebraic work, you may find several of the Calculator's 21267 When doing algebraic work, you may find several of the Calculator's
21268 modes to be helpful, including algebraic-simplification mode (@kbd{m A}) 21268 modes to be helpful, including Algebraic Simplification mode (@kbd{m A})
21269 or no-simplification mode (@kbd{m O}), 21269 or No-Simplification mode (@kbd{m O}),
21270 algebraic-entry mode (@kbd{m a}), fraction mode (@kbd{m f}), and 21270 Algebraic entry mode (@kbd{m a}), Fraction mode (@kbd{m f}), and
21271 symbolic mode (@kbd{m s}). @xref{Mode Settings}, for discussions 21271 Symbolic mode (@kbd{m s}). @xref{Mode Settings}, for discussions
21272 of these modes. You may also wish to select ``big'' display mode (@kbd{d B}). 21272 of these modes. You may also wish to select Big display mode (@kbd{d B}).
21273 @xref{Normal Language Modes}. 21273 @xref{Normal Language Modes}.
21274 21274
21275 @menu 21275 @menu
21276 * Selecting Subformulas:: 21276 * Selecting Subformulas::
21277 * Algebraic Manipulation:: 21277 * Algebraic Manipulation::
21321 To select a sub-formula, move the Emacs cursor to any character in that 21321 To select a sub-formula, move the Emacs cursor to any character in that
21322 sub-formula, and press @w{@kbd{j s}} (@code{calc-select-here}). Calc will 21322 sub-formula, and press @w{@kbd{j s}} (@code{calc-select-here}). Calc will
21323 highlight the smallest portion of the formula that contains that 21323 highlight the smallest portion of the formula that contains that
21324 character. By default the sub-formula is highlighted by blanking out 21324 character. By default the sub-formula is highlighted by blanking out
21325 all of the rest of the formula with dots. Selection works in any 21325 all of the rest of the formula with dots. Selection works in any
21326 display mode but is perhaps easiest in ``big'' (@kbd{d B}) mode. 21326 display mode but is perhaps easiest in Big mode (@kbd{d B}).
21327 Suppose you enter the following formula: 21327 Suppose you enter the following formula:
21328 21328
21329 @smallexample 21329 @smallexample
21330 @group 21330 @group
21331 3 ___ 21331 3 ___
21351 21351
21352 @noindent 21352 @noindent
21353 Every character not part of the sub-formula @samp{b} has been changed 21353 Every character not part of the sub-formula @samp{b} has been changed
21354 to a dot. The @samp{*} next to the line number is to remind you that 21354 to a dot. The @samp{*} next to the line number is to remind you that
21355 the formula has a portion of it selected. (In this case, it's very 21355 the formula has a portion of it selected. (In this case, it's very
21356 obvious, but it might not always be. If Embedded Mode is enabled, 21356 obvious, but it might not always be. If Embedded mode is enabled,
21357 the word @samp{Sel} also appears in the mode line because the stack 21357 the word @samp{Sel} also appears in the mode line because the stack
21358 may not be visible. @pxref{Embedded Mode}.) 21358 may not be visible. @pxref{Embedded Mode}.)
21359 21359
21360 If you had instead placed the cursor on the parenthesis immediately to 21360 If you had instead placed the cursor on the parenthesis immediately to
21361 the right of the @samp{b}, the selection would have been: 21361 the right of the @samp{b}, the selection would have been:
22001 It is often more convenient to type @kbd{=}, which is like @kbd{a v} 22001 It is often more convenient to type @kbd{=}, which is like @kbd{a v}
22002 but which also substitutes stored values for variables in the formula. 22002 but which also substitutes stored values for variables in the formula.
22003 Use @kbd{a v} if you want the variables to ignore their stored values. 22003 Use @kbd{a v} if you want the variables to ignore their stored values.
22004 22004
22005 If you give a numeric prefix argument of 2 to @kbd{a v}, it simplifies 22005 If you give a numeric prefix argument of 2 to @kbd{a v}, it simplifies
22006 as if in algebraic simplification mode. This is equivalent to typing 22006 as if in Algebraic Simplification mode. This is equivalent to typing
22007 @kbd{a s}; @pxref{Simplifying Formulas}. If you give a numeric prefix 22007 @kbd{a s}; @pxref{Simplifying Formulas}. If you give a numeric prefix
22008 of 3 or more, it uses extended simplification mode (@kbd{a e}). 22008 of 3 or more, it uses Extended Simplification mode (@kbd{a e}).
22009 22009
22010 If you give a negative prefix argument @mathit{-1}, @mathit{-2}, or @mathit{-3}, 22010 If you give a negative prefix argument @mathit{-1}, @mathit{-2}, or @mathit{-3},
22011 it simplifies in the corresponding mode but only works on the top-level 22011 it simplifies in the corresponding mode but only works on the top-level
22012 function call of the formula. For example, @samp{(2 + 3) * (2 + 3)} will 22012 function call of the formula. For example, @samp{(2 + 3) * (2 + 3)} will
22013 simplify to @samp{(2 + 3)^2}, without simplifying the sub-formulas 22013 simplify to @samp{(2 + 3)^2}, without simplifying the sub-formulas
22014 @samp{2 + 3}. As another example, typing @kbd{V R +} to sum the vector 22014 @samp{2 + 3}. As another example, typing @kbd{V R +} to sum the vector
22015 @samp{[1, 2, 3, 4]} produces the formula @samp{reduce(add, [1, 2, 3, 4])} 22015 @samp{[1, 2, 3, 4]} produces the formula @samp{reduce(add, [1, 2, 3, 4])}
22016 in no-simplify mode. Using @kbd{a v} will evaluate this all the way to 22016 in No-Simplify mode. Using @kbd{a v} will evaluate this all the way to
22017 10; using @kbd{C-u - a v} will evaluate it only to @samp{1 + 2 + 3 + 4}. 22017 10; using @kbd{C-u - a v} will evaluate it only to @samp{1 + 2 + 3 + 4}.
22018 (@xref{Reducing and Mapping}.) 22018 (@xref{Reducing and Mapping}.)
22019 22019
22020 @tindex evalv 22020 @tindex evalv
22021 @tindex evalvn 22021 @tindex evalvn
22022 The @kbd{=} command corresponds to the @code{evalv} function, and 22022 The @kbd{=} command corresponds to the @code{evalv} function, and
22023 the related @kbd{N} command, which is like @kbd{=} but temporarily 22023 the related @kbd{N} command, which is like @kbd{=} but temporarily
22024 disables symbolic (@kbd{m s}) mode during the evaluation, corresponds 22024 disables Symbolic mode (@kbd{m s}) during the evaluation, corresponds
22025 to the @code{evalvn} function. (These commands interpret their prefix 22025 to the @code{evalvn} function. (These commands interpret their prefix
22026 arguments differently than @kbd{a v}; @kbd{=} treats the prefix as 22026 arguments differently than @kbd{a v}; @kbd{=} treats the prefix as
22027 the number of stack elements to evaluate at once, and @kbd{N} treats 22027 the number of stack elements to evaluate at once, and @kbd{N} treats
22028 it as a temporary different working precision.) 22028 it as a temporary different working precision.)
22029 22029
22194 For example, @expr{2 + 3} is evaluated to @expr{5}, and @expr{@t{sqrt}(9)} 22194 For example, @expr{2 + 3} is evaluated to @expr{5}, and @expr{@t{sqrt}(9)}
22195 is evaluated to @expr{3}. Evaluation does not occur if the arguments 22195 is evaluated to @expr{3}. Evaluation does not occur if the arguments
22196 to a function are somehow of the wrong type @expr{@t{tan}([2,3,4])}), 22196 to a function are somehow of the wrong type @expr{@t{tan}([2,3,4])}),
22197 range (@expr{@t{tan}(90)}), or number (@expr{@t{tan}(3,5)}), 22197 range (@expr{@t{tan}(90)}), or number (@expr{@t{tan}(3,5)}),
22198 or if the function name is not recognized (@expr{@t{f}(5)}), or if 22198 or if the function name is not recognized (@expr{@t{f}(5)}), or if
22199 ``symbolic'' mode (@pxref{Symbolic Mode}) prevents evaluation 22199 Symbolic mode (@pxref{Symbolic Mode}) prevents evaluation
22200 (@expr{@t{sqrt}(2)}). 22200 (@expr{@t{sqrt}(2)}).
22201 22201
22202 Calc simplifies (evaluates) the arguments to a function before it 22202 Calc simplifies (evaluates) the arguments to a function before it
22203 simplifies the function itself. Thus @expr{@t{sqrt}(5+4)} is 22203 simplifies the function itself. Thus @expr{@t{sqrt}(5+4)} is
22204 simplified to @expr{@t{sqrt}(9)} before the @code{sqrt} function 22204 simplified to @expr{@t{sqrt}(9)} before the @code{sqrt} function
22302 @end tex 22302 @end tex
22303 22303
22304 The products @expr{1 a} and @expr{a 1} are simplified to @expr{a}; 22304 The products @expr{1 a} and @expr{a 1} are simplified to @expr{a};
22305 @expr{(-1) a} and @expr{a (-1)} are simplified to @expr{-a}; 22305 @expr{(-1) a} and @expr{a (-1)} are simplified to @expr{-a};
22306 @expr{0 a} and @expr{a 0} are simplified to @expr{0}, except that 22306 @expr{0 a} and @expr{a 0} are simplified to @expr{0}, except that
22307 in matrix mode where @expr{a} is not provably scalar the result 22307 in Matrix mode where @expr{a} is not provably scalar the result
22308 is the generic zero matrix @samp{idn(0)}, and that if @expr{a} is 22308 is the generic zero matrix @samp{idn(0)}, and that if @expr{a} is
22309 infinite the result is @samp{nan}. 22309 infinite the result is @samp{nan}.
22310 22310
22311 Also, @expr{(-a) b} and @expr{a (-b)} are simplified to @expr{-(a b)}, 22311 Also, @expr{(-a) b} and @expr{a (-b)} are simplified to @expr{-(a b)},
22312 where this occurs for negated formulas but not for regular negative 22312 where this occurs for negated formulas but not for regular negative
22328 where @expr{a} is a number, or an implicit 1 (as in @expr{x}), 22328 where @expr{a} is a number, or an implicit 1 (as in @expr{x}),
22329 or the implicit one-half of @expr{@t{sqrt}(x)}, and similarly for 22329 or the implicit one-half of @expr{@t{sqrt}(x)}, and similarly for
22330 @expr{b}. The result is written using @samp{sqrt} or @samp{1/sqrt} 22330 @expr{b}. The result is written using @samp{sqrt} or @samp{1/sqrt}
22331 if the sum of the powers is @expr{1/2} or @expr{-1/2}, respectively. 22331 if the sum of the powers is @expr{1/2} or @expr{-1/2}, respectively.
22332 If the sum of the powers is zero, the product is simplified to 22332 If the sum of the powers is zero, the product is simplified to
22333 @expr{1} or to @samp{idn(1)} if matrix mode is enabled. 22333 @expr{1} or to @samp{idn(1)} if Matrix mode is enabled.
22334 22334
22335 The product of a negative power times anything but another negative 22335 The product of a negative power times anything but another negative
22336 power is changed to use division: 22336 power is changed to use division:
22337 @texline @math{x^{-2} y} 22337 @texline @math{x^{-2} y}
22338 @infoline @expr{x^(-2) y} 22338 @infoline @expr{x^(-2) y}
22339 goes to @expr{y / x^2} unless matrix mode is 22339 goes to @expr{y / x^2} unless Matrix mode is
22340 in effect and neither @expr{x} nor @expr{y} are scalar (in which 22340 in effect and neither @expr{x} nor @expr{y} are scalar (in which
22341 case it is considered unsafe to rearrange the order of the terms). 22341 case it is considered unsafe to rearrange the order of the terms).
22342 22342
22343 Finally, @expr{a (b/c)} is rewritten to @expr{(a b)/c}, and also 22343 Finally, @expr{a (b/c)} is rewritten to @expr{(a b)/c}, and also
22344 @expr{(a/b) c} is changed to @expr{(a c)/b} unless in matrix mode. 22344 @expr{(a/b) c} is changed to @expr{(a c)/b} unless in Matrix mode.
22345 22345
22346 @tex 22346 @tex
22347 \bigskip 22347 \bigskip
22348 @end tex 22348 @end tex
22349 22349
22366 @infoline @expr{b^(-c)} 22366 @infoline @expr{b^(-c)}
22367 for any power @expr{c}. 22367 for any power @expr{c}.
22368 22368
22369 Also, @expr{(-a) / b} and @expr{a / (-b)} go to @expr{-(a/b)}; 22369 Also, @expr{(-a) / b} and @expr{a / (-b)} go to @expr{-(a/b)};
22370 @expr{(a/b) / c} goes to @expr{a / (b c)}; and @expr{a / (b/c)} 22370 @expr{(a/b) / c} goes to @expr{a / (b c)}; and @expr{a / (b/c)}
22371 goes to @expr{(a c) / b} unless matrix mode prevents this 22371 goes to @expr{(a c) / b} unless Matrix mode prevents this
22372 rearrangement. Similarly, @expr{a / (b:c)} is simplified to 22372 rearrangement. Similarly, @expr{a / (b:c)} is simplified to
22373 @expr{(c:b) a} for any fraction @expr{b:c}. 22373 @expr{(c:b) a} for any fraction @expr{b:c}.
22374 22374
22375 The distributive law is applied to @expr{(a + b) / c} only if 22375 The distributive law is applied to @expr{(a + b) / c} only if
22376 @expr{c} and at least one of @expr{a} and @expr{b} are numbers. 22376 @expr{c} and at least one of @expr{a} and @expr{b} are numbers.
22390 @tex 22390 @tex
22391 \bigskip 22391 \bigskip
22392 @end tex 22392 @end tex
22393 22393
22394 The formula @expr{x^0} is simplified to @expr{1}, or to @samp{idn(1)} 22394 The formula @expr{x^0} is simplified to @expr{1}, or to @samp{idn(1)}
22395 in matrix mode. The formula @expr{0^x} is simplified to @expr{0} 22395 in Matrix mode. The formula @expr{0^x} is simplified to @expr{0}
22396 unless @expr{x} is a negative number or complex number, in which 22396 unless @expr{x} is a negative number or complex number, in which
22397 case the result is an infinity or an unsimplified formula according 22397 case the result is an infinity or an unsimplified formula according
22398 to the current infinite mode. Note that @expr{0^0} is an 22398 to the current infinite mode. Note that @expr{0^0} is an
22399 indeterminate form, as evidenced by the fact that the simplifications 22399 indeterminate form, as evidenced by the fact that the simplifications
22400 for @expr{x^0} and @expr{0^x} conflict when @expr{x=0}. 22400 for @expr{x^0} and @expr{0^x} conflict when @expr{x=0}.
22566 The canonical ordering used to sort terms of products has the 22566 The canonical ordering used to sort terms of products has the
22567 property that real-valued numbers, interval forms and infinities 22567 property that real-valued numbers, interval forms and infinities
22568 come first, and are sorted into increasing order. The @kbd{V S} 22568 come first, and are sorted into increasing order. The @kbd{V S}
22569 command uses the same ordering when sorting a vector. 22569 command uses the same ordering when sorting a vector.
22570 22570
22571 Sorting of terms of products is inhibited when matrix mode is 22571 Sorting of terms of products is inhibited when Matrix mode is
22572 turned on; in this case, Calc will never exchange the order of 22572 turned on; in this case, Calc will never exchange the order of
22573 two terms unless it knows at least one of the terms is a scalar. 22573 two terms unless it knows at least one of the terms is a scalar.
22574 22574
22575 Products of powers are distributed by comparing all pairs of 22575 Products of powers are distributed by comparing all pairs of
22576 terms, using the same method that the default simplifications 22576 terms, using the same method that the default simplifications
23174 23174
23175 With a numeric prefix argument @var{n}, this command computes the 23175 With a numeric prefix argument @var{n}, this command computes the
23176 @var{n}th derivative. 23176 @var{n}th derivative.
23177 23177
23178 When working with trigonometric functions, it is best to switch to 23178 When working with trigonometric functions, it is best to switch to
23179 radians mode first (with @w{@kbd{m r}}). The derivative of @samp{sin(x)} 23179 Radians mode first (with @w{@kbd{m r}}). The derivative of @samp{sin(x)}
23180 in degrees is @samp{(pi/180) cos(x)}, probably not the expected 23180 in degrees is @samp{(pi/180) cos(x)}, probably not the expected
23181 answer! 23181 answer!
23182 23182
23183 If you use the @code{deriv} function directly in an algebraic formula, 23183 If you use the @code{deriv} function directly in an algebraic formula,
23184 you can write @samp{deriv(f,x,x0)} which represents the derivative 23184 you can write @samp{deriv(f,x,x0)} which represents the derivative
23265 @infoline @expr{pi i / 2}, 23265 @infoline @expr{pi i / 2},
23266 due to a different choice of constant of integration. 23266 due to a different choice of constant of integration.
23267 23267
23268 The Calculator remembers all the integrals it has done. If conditions 23268 The Calculator remembers all the integrals it has done. If conditions
23269 change in a way that would invalidate the old integrals, say, a switch 23269 change in a way that would invalidate the old integrals, say, a switch
23270 from degrees to radians mode, then they will be thrown out. If you 23270 from Degrees to Radians mode, then they will be thrown out. If you
23271 suspect this is not happening when it should, use the 23271 suspect this is not happening when it should, use the
23272 @code{calc-flush-caches} command; @pxref{Caches}. 23272 @code{calc-flush-caches} command; @pxref{Caches}.
23273 23273
23274 @vindex IntegLimit 23274 @vindex IntegLimit
23275 Calc normally will pursue integration by substitution or integration by 23275 Calc normally will pursue integration by substitution or integration by
23624 can be: @expr{x^6 + x^3 + 1} is converted to @expr{(x^3)^2 + (x^3) + 1}, 23624 can be: @expr{x^6 + x^3 + 1} is converted to @expr{(x^3)^2 + (x^3) + 1},
23625 which can be solved for @expr{x^3} using the quadratic equation, and then 23625 which can be solved for @expr{x^3} using the quadratic equation, and then
23626 for @expr{x} by taking cube roots. But in many cases, like 23626 for @expr{x} by taking cube roots. But in many cases, like
23627 @expr{x^6 + x + 1}, Calc does not know how to rewrite the polynomial 23627 @expr{x^6 + x + 1}, Calc does not know how to rewrite the polynomial
23628 into a form it can solve. The @kbd{a P} command can still deliver a 23628 into a form it can solve. The @kbd{a P} command can still deliver a
23629 list of numerical roots, however, provided that symbolic mode (@kbd{m s}) 23629 list of numerical roots, however, provided that Symbolic mode (@kbd{m s})
23630 is not turned on. (If you work with symbolic mode on, recall that the 23630 is not turned on. (If you work with Symbolic mode on, recall that the
23631 @kbd{N} (@code{calc-eval-num}) key is a handy way to reevaluate the 23631 @kbd{N} (@code{calc-eval-num}) key is a handy way to reevaluate the
23632 formula on the stack with symbolic mode temporarily off.) Naturally, 23632 formula on the stack with Symbolic mode temporarily off.) Naturally,
23633 @kbd{a P} can only provide numerical roots if the polynomial coefficients 23633 @kbd{a P} can only provide numerical roots if the polynomial coefficients
23634 are all numbers (real or complex). 23634 are all numbers (real or complex).
23635 23635
23636 @node Solving Systems of Equations, Decomposing Polynomials, Multiple Solutions, Solving Equations 23636 @node Solving Systems of Equations, Decomposing Polynomials, Multiple Solutions, Solving Equations
23637 @subsection Solving Systems of Equations 23637 @subsection Solving Systems of Equations
24242 24242
24243 Note that since the constant and linear terms are enough to fit the 24243 Note that since the constant and linear terms are enough to fit the
24244 data exactly, it's no surprise that Calc chose a tiny contribution 24244 data exactly, it's no surprise that Calc chose a tiny contribution
24245 for @expr{x^2}. (The fact that it's not exactly zero is due only 24245 for @expr{x^2}. (The fact that it's not exactly zero is due only
24246 to roundoff error. Since our data are exact integers, we could get 24246 to roundoff error. Since our data are exact integers, we could get
24247 an exact answer by typing @kbd{m f} first to get fraction mode. 24247 an exact answer by typing @kbd{m f} first to get Fraction mode.
24248 Then the @expr{x^2} term would vanish altogether. Usually, though, 24248 Then the @expr{x^2} term would vanish altogether. Usually, though,
24249 the data being fitted will be approximate floats so fraction mode 24249 the data being fitted will be approximate floats so Fraction mode
24250 won't help.) 24250 won't help.)
24251 24251
24252 Doing the @kbd{a F 2} fit on the data set with 14 instead of 13 24252 Doing the @kbd{a F 2} fit on the data set with 14 instead of 13
24253 gives a much larger @expr{x^2} contribution, as Calc bends the 24253 gives a much larger @expr{x^2} contribution, as Calc bends the
24254 line slightly to improve the fit. 24254 line slightly to improve the fit.
24269 24269
24270 The actual coefficients we get with a precision of 12, like 24270 The actual coefficients we get with a precision of 12, like
24271 @expr{0.0416666663588}, clearly suffer from loss of precision. 24271 @expr{0.0416666663588}, clearly suffer from loss of precision.
24272 It is a good idea to increase the working precision to several 24272 It is a good idea to increase the working precision to several
24273 digits beyond what you need when you do a fitting operation. 24273 digits beyond what you need when you do a fitting operation.
24274 Or, if your data are exact, use fraction mode to get exact 24274 Or, if your data are exact, use Fraction mode to get exact
24275 results. 24275 results.
24276 24276
24277 You can type @kbd{i} instead of a digit at the model prompt to fit 24277 You can type @kbd{i} instead of a digit at the model prompt to fit
24278 the data exactly to a polynomial. This just counts the number of 24278 the data exactly to a polynomial. This just counts the number of
24279 columns of the data matrix to choose the degree of the polynomial 24279 columns of the data matrix to choose the degree of the polynomial
25940 four terms with @samp{a} matching the remainder. Half-and-half matches, 25940 four terms with @samp{a} matching the remainder. Half-and-half matches,
25941 like @samp{(x + y) + (z - w)}, are not tried. 25941 like @samp{(x + y) + (z - w)}, are not tried.
25942 25942
25943 Note that @samp{*} is not commutative when applied to matrices, but 25943 Note that @samp{*} is not commutative when applied to matrices, but
25944 rewrite rules pretend that it is. If you type @kbd{m v} to enable 25944 rewrite rules pretend that it is. If you type @kbd{m v} to enable
25945 matrix mode (@pxref{Matrix Mode}), rewrite rules will match @samp{*} 25945 Matrix mode (@pxref{Matrix Mode}), rewrite rules will match @samp{*}
25946 literally, ignoring its usual commutativity property. (In the 25946 literally, ignoring its usual commutativity property. (In the
25947 current implementation, the associativity also vanishes---it is as 25947 current implementation, the associativity also vanishes---it is as
25948 if the pattern had been enclosed in a @code{plain} marker; see below.) 25948 if the pattern had been enclosed in a @code{plain} marker; see below.)
25949 If you are applying rewrites to formulas with matrices, it's best to 25949 If you are applying rewrites to formulas with matrices, it's best to
25950 enable matrix mode first to prevent algebraically incorrect rewrites 25950 enable Matrix mode first to prevent algebraically incorrect rewrites
25951 from occurring. 25951 from occurring.
25952 25952
25953 The pattern @samp{-x} will actually match any expression. For example, 25953 The pattern @samp{-x} will actually match any expression. For example,
25954 the rule 25954 the rule
25955 25955
26422 26422
26423 You must use @code{apply} for meta-variables with function names 26423 You must use @code{apply} for meta-variables with function names
26424 on both sides of a rewrite rule: @samp{apply(f, [x]) := f(x+1)} 26424 on both sides of a rewrite rule: @samp{apply(f, [x]) := f(x+1)}
26425 is @emph{not} correct, because it rewrites @samp{spam(6)} into 26425 is @emph{not} correct, because it rewrites @samp{spam(6)} into
26426 @samp{f(7)}. The righthand side should be @samp{apply(f, [x+1])}. 26426 @samp{f(7)}. The righthand side should be @samp{apply(f, [x+1])}.
26427 Also note that you will have to use no-simplify (@kbd{m O}) 26427 Also note that you will have to use No-Simplify mode (@kbd{m O})
26428 mode when entering this rule so that the @code{apply} isn't 26428 when entering this rule so that the @code{apply} isn't
26429 evaluated immediately to get the new rule @samp{f(x) := f(x+1)}. 26429 evaluated immediately to get the new rule @samp{f(x) := f(x+1)}.
26430 Or, use @kbd{s e} to enter the rule without going through the stack, 26430 Or, use @kbd{s e} to enter the rule without going through the stack,
26431 or enter the rule as @samp{apply(f, [x]) := apply(f, [x+1]) @w{:: 1}}. 26431 or enter the rule as @samp{apply(f, [x]) := apply(f, [x+1]) @w{:: 1}}.
26432 @xref{Conditional Rewrite Rules}. 26432 @xref{Conditional Rewrite Rules}.
26433 26433
27158 To apply these manually, you could put them in a variable called 27158 To apply these manually, you could put them in a variable called
27159 @code{trigexp} and then use @kbd{a r trigexp} every time you wanted 27159 @code{trigexp} and then use @kbd{a r trigexp} every time you wanted
27160 to expand trig functions. But if instead you store them in the 27160 to expand trig functions. But if instead you store them in the
27161 variable @code{EvalRules}, they will automatically be applied to all 27161 variable @code{EvalRules}, they will automatically be applied to all
27162 sines and cosines of sums. Then, with @samp{2 x} and @samp{45} on 27162 sines and cosines of sums. Then, with @samp{2 x} and @samp{45} on
27163 the stack, typing @kbd{+ S} will (assuming degrees mode) result in 27163 the stack, typing @kbd{+ S} will (assuming Degrees mode) result in
27164 @samp{0.7071 sin(2 x) + 0.7071 cos(2 x)} automatically. 27164 @samp{0.7071 sin(2 x) + 0.7071 cos(2 x)} automatically.
27165 27165
27166 As each level of a formula is evaluated, the rules from 27166 As each level of a formula is evaluated, the rules from
27167 @code{EvalRules} are applied before the default simplifications. 27167 @code{EvalRules} are applied before the default simplifications.
27168 Rewriting continues until no further @code{EvalRules} apply. 27168 Rewriting continues until no further @code{EvalRules} apply.
27234 functions. For example, when you take the absolute value of the complex 27234 functions. For example, when you take the absolute value of the complex
27235 number @expr{(2, 3)}, Calc computes @samp{sqrt(2*2 + 3*3)} by calling 27235 number @expr{(2, 3)}, Calc computes @samp{sqrt(2*2 + 3*3)} by calling
27236 the multiplication, addition, and square root functions directly rather 27236 the multiplication, addition, and square root functions directly rather
27237 than applying the default simplifications to this formula. So an 27237 than applying the default simplifications to this formula. So an
27238 @code{EvalRules} rule that (perversely) rewrites @samp{sqrt(13) := 6} 27238 @code{EvalRules} rule that (perversely) rewrites @samp{sqrt(13) := 6}
27239 would not apply. (However, if you put Calc into symbolic mode so that 27239 would not apply. (However, if you put Calc into Symbolic mode so that
27240 @samp{sqrt(13)} will be left in symbolic form by the built-in square 27240 @samp{sqrt(13)} will be left in symbolic form by the built-in square
27241 root function, your rule will be able to apply. But if the complex 27241 root function, your rule will be able to apply. But if the complex
27242 number were @expr{(3,4)}, so that @samp{sqrt(25)} must be calculated, 27242 number were @expr{(3,4)}, so that @samp{sqrt(25)} must be calculated,
27243 then symbolic mode will not help because @samp{sqrt(25)} can be 27243 then Symbolic mode will not help because @samp{sqrt(25)} can be
27244 evaluated exactly to 5.) 27244 evaluated exactly to 5.)
27245 27245
27246 One subtle restriction that normally only manifests itself with 27246 One subtle restriction that normally only manifests itself with
27247 @code{EvalRules} is that while a given rewrite rule is in the process 27247 @code{EvalRules} is that while a given rewrite rule is in the process
27248 of being checked, that same rule cannot be recursively applied. Calc 27248 of being checked, that same rule cannot be recursively applied. Calc
27345 27345
27346 A surprisingly useful rewrite rule is @samp{a/(b-c) := a*(b+c)/(b^2-c^2)}. 27346 A surprisingly useful rewrite rule is @samp{a/(b-c) := a*(b+c)/(b^2-c^2)}.
27347 This will simplify the formula whenever @expr{b} and/or @expr{c} can 27347 This will simplify the formula whenever @expr{b} and/or @expr{c} can
27348 be made simpler by squaring. For example, applying this rule to 27348 be made simpler by squaring. For example, applying this rule to
27349 @samp{2 / (sqrt(2) + 3)} yields @samp{6:7 - 2:7 sqrt(2)} (assuming 27349 @samp{2 / (sqrt(2) + 3)} yields @samp{6:7 - 2:7 sqrt(2)} (assuming
27350 Symbolic Mode has been enabled to keep the square root from being 27350 Symbolic mode has been enabled to keep the square root from being
27351 evaluated to a floating-point approximation). This rule is also 27351 evaluated to a floating-point approximation). This rule is also
27352 useful when working with symbolic complex numbers, e.g., 27352 useful when working with symbolic complex numbers, e.g.,
27353 @samp{(a + b i) / (c + d i)}. 27353 @samp{(a + b i) / (c + d i)}.
27354 27354
27355 As another example, we could define our own ``triangular numbers'' function 27355 As another example, we could define our own ``triangular numbers'' function
27455 it will be removed by the Calculator's automatic algebra routines: The 27455 it will be removed by the Calculator's automatic algebra routines: The
27456 formula @samp{1 mm} is ``simplified'' to @samp{mm}. This is only a 27456 formula @samp{1 mm} is ``simplified'' to @samp{mm}. This is only a
27457 display anomaly, however; @samp{mm} will work just fine as a 27457 display anomaly, however; @samp{mm} will work just fine as a
27458 representation of one millimeter. 27458 representation of one millimeter.
27459 27459
27460 You may find that Algebraic Mode (@pxref{Algebraic Entry}) makes working 27460 You may find that Algebraic mode (@pxref{Algebraic Entry}) makes working
27461 with units expressions easier. Otherwise, you will have to remember 27461 with units expressions easier. Otherwise, you will have to remember
27462 to hit the apostrophe key every time you wish to enter units. 27462 to hit the apostrophe key every time you wish to enter units.
27463 27463
27464 @kindex u s 27464 @kindex u s
27465 @pindex calc-simplify-units 27465 @pindex calc-simplify-units
28344 All current modes apply when an @samp{=>} operator is computed, 28344 All current modes apply when an @samp{=>} operator is computed,
28345 including the current simplification mode. Recall that the 28345 including the current simplification mode. Recall that the
28346 formula @samp{x + y + x} is not handled by Calc's default 28346 formula @samp{x + y + x} is not handled by Calc's default
28347 simplifications, but the @kbd{a s} command will reduce it to 28347 simplifications, but the @kbd{a s} command will reduce it to
28348 the simpler form @samp{y + 2 x}. You can also type @kbd{m A} 28348 the simpler form @samp{y + 2 x}. You can also type @kbd{m A}
28349 to enable an algebraic-simplification mode in which the 28349 to enable an Algebraic Simplification mode in which the
28350 equivalent of @kbd{a s} is used on all of Calc's results. 28350 equivalent of @kbd{a s} is used on all of Calc's results.
28351 If you enter @samp{x + y + x =>} normally, the result will 28351 If you enter @samp{x + y + x =>} normally, the result will
28352 be @samp{x + y + x => x + y + x}. If you change to 28352 be @samp{x + y + x => x + y + x}. If you change to
28353 algebraic-simplification mode, the result will be 28353 Algebraic Simplification mode, the result will be
28354 @samp{x + y + x => y + 2 x}. However, just pressing @kbd{a s} 28354 @samp{x + y + x => y + 2 x}. However, just pressing @kbd{a s}
28355 once will have no effect on @samp{x + y + x => x + y + x}, 28355 once will have no effect on @samp{x + y + x => x + y + x},
28356 because the righthand side depends only on the lefthand side 28356 because the righthand side depends only on the lefthand side
28357 and the current mode settings, and the lefthand side is not 28357 and the current mode settings, and the lefthand side is not
28358 affected by commands like @kbd{a s}. 28358 affected by commands like @kbd{a s}.
28387 28387
28388 @kindex s : 28388 @kindex s :
28389 @pindex calc-assign 28389 @pindex calc-assign
28390 @tindex assign 28390 @tindex assign
28391 @tindex := 28391 @tindex :=
28392 Embedded Mode also uses @samp{=>} operators. In embedded mode, 28392 Embedded mode also uses @samp{=>} operators. In Embedded mode,
28393 the lefthand side of an @samp{=>} operator can refer to variables 28393 the lefthand side of an @samp{=>} operator can refer to variables
28394 assigned elsewhere in the file by @samp{:=} operators. The 28394 assigned elsewhere in the file by @samp{:=} operators. The
28395 assignment operator @samp{a := 17} does not actually do anything 28395 assignment operator @samp{a := 17} does not actually do anything
28396 by itself. But Embedded Mode recognizes it and marks it as a sort 28396 by itself. But Embedded mode recognizes it and marks it as a sort
28397 of file-local definition of the variable. You can enter @samp{:=} 28397 of file-local definition of the variable. You can enter @samp{:=}
28398 operators in algebraic mode, or by using the @kbd{s :} 28398 operators in Algebraic mode, or by using the @kbd{s :}
28399 (@code{calc-assign}) [@code{assign}] command which takes a variable 28399 (@code{calc-assign}) [@code{assign}] command which takes a variable
28400 and value from the stack and replaces them with an assignment. 28400 and value from the stack and replaces them with an assignment.
28401 28401
28402 @xref{TeX Language Mode}, for the way @samp{=>} appears in 28402 @xref{TeX Language Mode}, for the way @samp{=>} appears in
28403 @TeX{} language output. The @dfn{eqn} mode gives similar 28403 @TeX{} language output. The @dfn{eqn} mode gives similar
29094 29094
29095 @noindent 29095 @noindent
29096 The commands in this chapter move information between the Calculator and 29096 The commands in this chapter move information between the Calculator and
29097 other Emacs editing buffers. 29097 other Emacs editing buffers.
29098 29098
29099 In many cases Embedded Mode is an easier and more natural way to 29099 In many cases Embedded mode is an easier and more natural way to
29100 work with Calc from a regular editing buffer. @xref{Embedded Mode}. 29100 work with Calc from a regular editing buffer. @xref{Embedded Mode}.
29101 29101
29102 @menu 29102 @menu
29103 * Killing From Stack:: 29103 * Killing From Stack::
29104 * Yanking Into Stack:: 29104 * Yanking Into Stack::
29365 whole line. So you can usually transfer a single number into Calc 29365 whole line. So you can usually transfer a single number into Calc
29366 just by double-clicking on it in the shell, then middle-clicking 29366 just by double-clicking on it in the shell, then middle-clicking
29367 in the Calc window. 29367 in the Calc window.
29368 29368
29369 @node Keypad Mode, Embedded Mode, Kill and Yank, Introduction 29369 @node Keypad Mode, Embedded Mode, Kill and Yank, Introduction
29370 @chapter ``Keypad'' Mode 29370 @chapter Keypad Mode
29371 29371
29372 @noindent 29372 @noindent
29373 @kindex M-# k 29373 @kindex M-# k
29374 @pindex calc-keypad 29374 @pindex calc-keypad
29375 The @kbd{M-# k} (@code{calc-keypad}) command starts the Calculator 29375 The @kbd{M-# k} (@code{calc-keypad}) command starts the Calculator
29376 and displays a picture of a calculator-style keypad. If you are using 29376 and displays a picture of a calculator-style keypad. If you are using
29377 the X window system, you can click on any of the ``keys'' in the 29377 the X window system, you can click on any of the ``keys'' in the
29378 keypad using the left mouse button to operate the calculator. 29378 keypad using the left mouse button to operate the calculator.
29379 The original window remains the selected window; in keypad mode 29379 The original window remains the selected window; in Keypad mode
29380 you can type in your file while simultaneously performing 29380 you can type in your file while simultaneously performing
29381 calculations with the mouse. 29381 calculations with the mouse.
29382 29382
29383 @pindex full-calc-keypad 29383 @pindex full-calc-keypad
29384 If you have used @kbd{M-# b} first, @kbd{M-# k} instead invokes 29384 If you have used @kbd{M-# b} first, @kbd{M-# k} instead invokes
29390 If you aren't using the X window system, you must switch into 29390 If you aren't using the X window system, you must switch into
29391 the @samp{*Calc Keypad*} window, place the cursor on the desired 29391 the @samp{*Calc Keypad*} window, place the cursor on the desired
29392 ``key,'' and type @key{SPC} or @key{RET}. If you think this 29392 ``key,'' and type @key{SPC} or @key{RET}. If you think this
29393 is easier than using Calc normally, go right ahead. 29393 is easier than using Calc normally, go right ahead.
29394 29394
29395 Calc commands are more or less the same in keypad mode. Certain 29395 Calc commands are more or less the same in Keypad mode. Certain
29396 keypad keys differ slightly from the corresponding normal Calc 29396 keypad keys differ slightly from the corresponding normal Calc
29397 keystrokes; all such deviations are described below. 29397 keystrokes; all such deviations are described below.
29398 29398
29399 Keypad Mode includes many more commands than will fit on the keypad 29399 Keypad mode includes many more commands than will fit on the keypad
29400 at once. Click the right mouse button [@code{calc-keypad-menu}] 29400 at once. Click the right mouse button [@code{calc-keypad-menu}]
29401 to switch to the next menu. The bottom five rows of the keypad 29401 to switch to the next menu. The bottom five rows of the keypad
29402 stay the same; the top three rows change to a new set of commands. 29402 stay the same; the top three rows change to a new set of commands.
29403 To return to earlier menus, click the middle mouse button 29403 To return to earlier menus, click the middle mouse button
29404 [@code{calc-keypad-menu-back}] or simply advance through the menus 29404 [@code{calc-keypad-menu-back}] or simply advance through the menus
29442 |-----+-----+-----+-----+-----+ 29442 |-----+-----+-----+-----+-----+
29443 @end group 29443 @end group
29444 @end smallexample 29444 @end smallexample
29445 29445
29446 @noindent 29446 @noindent
29447 This is the menu that appears the first time you start Keypad Mode. 29447 This is the menu that appears the first time you start Keypad mode.
29448 It will show up in a vertical window on the right side of your screen. 29448 It will show up in a vertical window on the right side of your screen.
29449 Above this menu is the traditional Calc stack display. On a 24-line 29449 Above this menu is the traditional Calc stack display. On a 24-line
29450 screen you will be able to see the top three stack entries. 29450 screen you will be able to see the top three stack entries.
29451 29451
29452 The ten digit keys, decimal point, and @key{EEX} key are used for 29452 The ten digit keys, decimal point, and @key{EEX} key are used for
29459 numeric entry it changes the sign of the number or of the exponent. 29459 numeric entry it changes the sign of the number or of the exponent.
29460 At other times it changes the sign of the number on the top of the 29460 At other times it changes the sign of the number on the top of the
29461 stack. 29461 stack.
29462 29462
29463 The @key{INV} and @key{HYP} keys modify other keys. As well as 29463 The @key{INV} and @key{HYP} keys modify other keys. As well as
29464 having the effects described elsewhere in this manual, Keypad Mode 29464 having the effects described elsewhere in this manual, Keypad mode
29465 defines several other ``inverse'' operations. These are described 29465 defines several other ``inverse'' operations. These are described
29466 below and in the following sections. 29466 below and in the following sections.
29467 29467
29468 The @key{ENTER} key finishes the current numeric entry, or otherwise 29468 The @key{ENTER} key finishes the current numeric entry, or otherwise
29469 duplicates the top entry on the stack. 29469 duplicates the top entry on the stack.
29479 29479
29480 The @key{EXEC} key prompts you to enter any keystroke sequence 29480 The @key{EXEC} key prompts you to enter any keystroke sequence
29481 that would normally work in Calc mode. This can include a 29481 that would normally work in Calc mode. This can include a
29482 numeric prefix if you wish. It is also possible simply to 29482 numeric prefix if you wish. It is also possible simply to
29483 switch into the Calc window and type commands in it; there is 29483 switch into the Calc window and type commands in it; there is
29484 nothing ``magic'' about this window when Keypad Mode is active. 29484 nothing ``magic'' about this window when Keypad mode is active.
29485 29485
29486 The other keys in this display perform their obvious calculator 29486 The other keys in this display perform their obvious calculator
29487 functions. @key{CLN2} rounds the top-of-stack by temporarily 29487 functions. @key{CLN2} rounds the top-of-stack by temporarily
29488 reducing the precision by 2 digits. @key{FLT} converts an 29488 reducing the precision by 2 digits. @key{FLT} converts an
29489 integer or fraction on the top of the stack to floating-point. 29489 integer or fraction on the top of the stack to floating-point.
29758 The @key{OVER} key duplicates the second-to-top stack element. 29758 The @key{OVER} key duplicates the second-to-top stack element.
29759 29759
29760 The @key{STO} and @key{RCL} keys are analogous to @kbd{s t} and 29760 The @key{STO} and @key{RCL} keys are analogous to @kbd{s t} and
29761 @kbd{s r} in regular Calc. @xref{Store and Recall}. Click the 29761 @kbd{s r} in regular Calc. @xref{Store and Recall}. Click the
29762 @key{STO} or @key{RCL} key, then one of the ten digits. (Named 29762 @key{STO} or @key{RCL} key, then one of the ten digits. (Named
29763 variables are not available in Keypad Mode.) You can also use, 29763 variables are not available in Keypad mode.) You can also use,
29764 for example, @kbd{STO + 3} to add to register 3. 29764 for example, @kbd{STO + 3} to add to register 3.
29765 29765
29766 @node Embedded Mode, Programming, Keypad Mode, Top 29766 @node Embedded Mode, Programming, Keypad Mode, Top
29767 @chapter Embedded Mode 29767 @chapter Embedded Mode
29768 29768
29769 @noindent 29769 @noindent
29770 Embedded Mode in Calc provides an alternative to copying numbers 29770 Embedded mode in Calc provides an alternative to copying numbers
29771 and formulas back and forth between editing buffers and the Calc 29771 and formulas back and forth between editing buffers and the Calc
29772 stack. In Embedded Mode, your editing buffer becomes temporarily 29772 stack. In Embedded mode, your editing buffer becomes temporarily
29773 linked to the stack and this copying is taken care of automatically. 29773 linked to the stack and this copying is taken care of automatically.
29774 29774
29775 @menu 29775 @menu
29776 * Basic Embedded Mode:: 29776 * Basic Embedded Mode::
29777 * More About Embedded Mode:: 29777 * More About Embedded Mode::
29792 like most Calc commands, but rather in regular editing buffers that 29792 like most Calc commands, but rather in regular editing buffers that
29793 are visiting your own files. 29793 are visiting your own files.
29794 29794
29795 Calc normally scans backward and forward in the buffer for the 29795 Calc normally scans backward and forward in the buffer for the
29796 nearest opening and closing @dfn{formula delimiters}. The simplest 29796 nearest opening and closing @dfn{formula delimiters}. The simplest
29797 delimiters are blank lines. Other delimiters that Embedded Mode 29797 delimiters are blank lines. Other delimiters that Embedded mode
29798 understands are: 29798 understands are:
29799 29799
29800 @enumerate 29800 @enumerate
29801 @item 29801 @item
29802 The @TeX{} and La@TeX{} math delimiters @samp{$ $}, @samp{$$ $$}, 29802 The @TeX{} and La@TeX{} math delimiters @samp{$ $}, @samp{$$ $$},
30350 30350
30351 @node Mode Settings in Embedded Mode, Customizing Embedded Mode, Assignments in Embedded Mode, Embedded Mode 30351 @node Mode Settings in Embedded Mode, Customizing Embedded Mode, Assignments in Embedded Mode, Embedded Mode
30352 @section Mode Settings in Embedded Mode 30352 @section Mode Settings in Embedded Mode
30353 30353
30354 @noindent 30354 @noindent
30355 Embedded Mode has a rather complicated mechanism for handling mode 30355 Embedded mode has a rather complicated mechanism for handling mode
30356 settings in Embedded formulas. It is possible to put annotations 30356 settings in Embedded formulas. It is possible to put annotations
30357 in the file that specify mode settings either global to the entire 30357 in the file that specify mode settings either global to the entire
30358 file or local to a particular formula or formulas. In the latter 30358 file or local to a particular formula or formulas. In the latter
30359 case, different modes can be specified for use when a formula 30359 case, different modes can be specified for use when a formula
30360 is the enabled Embedded Mode formula. 30360 is the enabled Embedded mode formula.
30361 30361
30362 When you give any mode-setting command, like @kbd{m f} (for fraction 30362 When you give any mode-setting command, like @kbd{m f} (for Fraction
30363 mode) or @kbd{d s} (for scientific notation), Embedded Mode adds 30363 mode) or @kbd{d s} (for scientific notation), Embedded mode adds
30364 a line like the following one to the file just before the opening 30364 a line like the following one to the file just before the opening
30365 delimiter of the formula. 30365 delimiter of the formula.
30366 30366
30367 @example 30367 @example
30368 % [calc-mode: fractions: t] 30368 % [calc-mode: fractions: t]
30411 second parts are ignored. The third part is not checked to make 30411 second parts are ignored. The third part is not checked to make
30412 sure the value is of a legal type or range; if you write an 30412 sure the value is of a legal type or range; if you write an
30413 annotation by hand, be sure to give a proper value or results 30413 annotation by hand, be sure to give a proper value or results
30414 will be unpredictable. Mode-setting annotations are case-sensitive. 30414 will be unpredictable. Mode-setting annotations are case-sensitive.
30415 30415
30416 While Embedded Mode is enabled, the word @code{Local} appears in 30416 While Embedded mode is enabled, the word @code{Local} appears in
30417 the mode line. This is to show that mode setting commands generate 30417 the mode line. This is to show that mode setting commands generate
30418 annotations that are ``local'' to the current formula or set of 30418 annotations that are ``local'' to the current formula or set of
30419 formulas. The @kbd{m R} (@code{calc-mode-record-mode}) command 30419 formulas. The @kbd{m R} (@code{calc-mode-record-mode}) command
30420 causes Calc to generate different kinds of annotations. Pressing 30420 causes Calc to generate different kinds of annotations. Pressing
30421 @kbd{m R} repeatedly cycles through the possible modes. 30421 @kbd{m R} repeatedly cycles through the possible modes.
30427 % [calc-edit-mode: float-format: (sci 0)] 30427 % [calc-edit-mode: float-format: (sci 0)]
30428 % [calc-perm-mode: float-format: (sci 5)] 30428 % [calc-perm-mode: float-format: (sci 5)]
30429 @end example 30429 @end example
30430 30430
30431 The first kind of annotation will be used only while a formula 30431 The first kind of annotation will be used only while a formula
30432 is enabled in Embedded Mode. The second kind will be used only 30432 is enabled in Embedded mode. The second kind will be used only
30433 when the formula is @emph{not} enabled. (Whether the formula 30433 when the formula is @emph{not} enabled. (Whether the formula
30434 is ``active'' or not, i.e., whether Calc has seen this formula 30434 is ``active'' or not, i.e., whether Calc has seen this formula
30435 yet, is not relevant here.) 30435 yet, is not relevant here.)
30436 30436
30437 @code{Global} mode generates an annotation like this at the end 30437 @code{Global} mode generates an annotation like this at the end
30469 30469
30470 We would have to go down to the other formula and press @kbd{M-# u} 30470 We would have to go down to the other formula and press @kbd{M-# u}
30471 on it in order to get it to notice the new annotation. 30471 on it in order to get it to notice the new annotation.
30472 30472
30473 Two more mode-recording modes selectable by @kbd{m R} are @code{Save} 30473 Two more mode-recording modes selectable by @kbd{m R} are @code{Save}
30474 (which works even outside of Embedded Mode), in which mode settings 30474 (which works even outside of Embedded mode), in which mode settings
30475 are recorded permanently in your Emacs startup file @file{~/.emacs} 30475 are recorded permanently in your Emacs startup file @file{~/.emacs}
30476 rather than by annotating the current document, and no-recording 30476 rather than by annotating the current document, and no-recording
30477 mode (where there is no symbol like @code{Save} or @code{Local} in 30477 mode (where there is no symbol like @code{Save} or @code{Local} in
30478 the mode line), in which mode-changing commands do not leave any 30478 the mode line), in which mode-changing commands do not leave any
30479 annotations at all. 30479 annotations at all.
30480 30480
30481 When Embedded Mode is not enabled, mode-recording modes except 30481 When Embedded mode is not enabled, mode-recording modes except
30482 for @code{Save} have no effect. 30482 for @code{Save} have no effect.
30483 30483
30484 @node Customizing Embedded Mode, , Mode Settings in Embedded Mode, Embedded Mode 30484 @node Customizing Embedded Mode, , Mode Settings in Embedded Mode, Embedded Mode
30485 @section Customizing Embedded Mode 30485 @section Customizing Embedded Mode
30486 30486
30487 @noindent 30487 @noindent
30488 You can modify Embedded Mode's behavior by setting various Lisp 30488 You can modify Embedded mode's behavior by setting various Lisp
30489 variables described here. Use @kbd{M-x set-variable} or 30489 variables described here. Use @kbd{M-x set-variable} or
30490 @kbd{M-x edit-options} to adjust a variable on the fly, or 30490 @kbd{M-x edit-options} to adjust a variable on the fly, or
30491 put a suitable @code{setq} statement in your @file{~/.emacs} 30491 put a suitable @code{setq} statement in your @file{~/.emacs}
30492 file to set a variable permanently. (Another possibility would 30492 file to set a variable permanently. (Another possibility would
30493 be to use a file-local variable annotation at the end of the 30493 be to use a file-local variable annotation at the end of the
30494 file; @pxref{File Variables, , Local Variables in Files, emacs, the 30494 file; @pxref{File Variables, , Local Variables in Files, emacs, the
30495 Emacs manual}.) 30495 Emacs manual}.)
30496 30496
30497 While none of these variables will be buffer-local by default, you 30497 While none of these variables will be buffer-local by default, you
30498 can make any of them local to any embedded-mode buffer. (Their 30498 can make any of them local to any Embedded mode buffer. (Their
30499 values in the @samp{*Calculator*} buffer are never used.) 30499 values in the @samp{*Calculator*} buffer are never used.)
30500 30500
30501 @vindex calc-embedded-open-formula 30501 @vindex calc-embedded-open-formula
30502 The @code{calc-embedded-open-formula} variable holds a regular 30502 The @code{calc-embedded-open-formula} variable holds a regular
30503 expression for the opening delimiter of a formula. @xref{Regexp Search, 30503 expression for the opening delimiter of a formula. @xref{Regexp Search,
30582 The default string is @code{"%%% "} (note the trailing space). 30582 The default string is @code{"%%% "} (note the trailing space).
30583 30583
30584 @vindex calc-embedded-close-plain 30584 @vindex calc-embedded-close-plain
30585 The @code{calc-embedded-close-plain} variable is a string which 30585 The @code{calc-embedded-close-plain} variable is a string which
30586 ends a ``plain'' formula. The default is @code{" %%%\n"}. Without 30586 ends a ``plain'' formula. The default is @code{" %%%\n"}. Without
30587 the trailing newline here, the first line of a ``big'' mode formula 30587 the trailing newline here, the first line of a Big mode formula
30588 that followed might be shifted over with respect to the other lines. 30588 that followed might be shifted over with respect to the other lines.
30589 30589
30590 @vindex calc-embedded-open-new-formula 30590 @vindex calc-embedded-open-new-formula
30591 The @code{calc-embedded-open-new-formula} variable is a string 30591 The @code{calc-embedded-open-new-formula} variable is a string
30592 which is inserted at the front of a new formula when you type 30592 which is inserted at the front of a new formula when you type
31043 @noindent 31043 @noindent
31044 @cindex Local variables 31044 @cindex Local variables
31045 @cindex Restoring saved modes 31045 @cindex Restoring saved modes
31046 Keyboard macros sometimes want to operate under known conditions 31046 Keyboard macros sometimes want to operate under known conditions
31047 without affecting surrounding conditions. For example, a keyboard 31047 without affecting surrounding conditions. For example, a keyboard
31048 macro may wish to turn on Fraction Mode, or set a particular 31048 macro may wish to turn on Fraction mode, or set a particular
31049 precision, independent of the user's normal setting for those 31049 precision, independent of the user's normal setting for those
31050 modes. 31050 modes.
31051 31051
31052 @kindex Z ` 31052 @kindex Z `
31053 @kindex Z ' 31053 @kindex Z '
31092 for all mode-setting commands inside the macro. 31092 for all mode-setting commands inside the macro.
31093 31093
31094 In fact, @kbd{C-u Z `} is like @kbd{Z `} except that it sets the modes 31094 In fact, @kbd{C-u Z `} is like @kbd{Z `} except that it sets the modes
31095 listed above to their default values. As usual, the matching @kbd{Z '} 31095 listed above to their default values. As usual, the matching @kbd{Z '}
31096 will restore the modes to their settings from before the @kbd{C-u Z `}. 31096 will restore the modes to their settings from before the @kbd{C-u Z `}.
31097 Also, @w{@kbd{Z `}} with a negative prefix argument resets algebraic mode 31097 Also, @w{@kbd{Z `}} with a negative prefix argument resets the algebraic mode
31098 to its default (off) but leaves the other modes the same as they were 31098 to its default (off) but leaves the other modes the same as they were
31099 outside the construct. 31099 outside the construct.
31100 31100
31101 The contents of the stack and trail, values of non-quick variables, and 31101 The contents of the stack and trail, values of non-quick variables, and
31102 other settings such as the language mode and the various display modes, 31102 other settings such as the language mode and the various display modes,
32164 @noindent 32164 @noindent
32165 If the first argument to @code{calc-eval} is a list whose first 32165 If the first argument to @code{calc-eval} is a list whose first
32166 element is a formula string, then @code{calc-eval} sets all the 32166 element is a formula string, then @code{calc-eval} sets all the
32167 various Calc modes to their default values while the formula is 32167 various Calc modes to their default values while the formula is
32168 evaluated and formatted. For example, the precision is set to 12 32168 evaluated and formatted. For example, the precision is set to 12
32169 digits, digit grouping is turned off, and the normal language 32169 digits, digit grouping is turned off, and the Normal language
32170 mode is used. 32170 mode is used.
32171 32171
32172 This same principle applies to the other options discussed below. 32172 This same principle applies to the other options discussed below.
32173 If the first argument would normally be @var{x}, then it can also 32173 If the first argument would normally be @var{x}, then it can also
32174 be the list @samp{(@var{x})} to use the default mode settings. 32174 be the list @samp{(@var{x})} to use the default mode settings.
32187 32187
32188 It's usually best to use this form of @code{calc-eval} unless your 32188 It's usually best to use this form of @code{calc-eval} unless your
32189 program actually considers the interaction with Calc's mode settings 32189 program actually considers the interaction with Calc's mode settings
32190 to be a feature. This will avoid all sorts of potential ``gotchas''; 32190 to be a feature. This will avoid all sorts of potential ``gotchas'';
32191 consider what happens with @samp{(calc-eval "sqrt(2)" 'num)} 32191 consider what happens with @samp{(calc-eval "sqrt(2)" 'num)}
32192 when the user has left Calc in symbolic mode or no-simplify mode. 32192 when the user has left Calc in Symbolic mode or No-Simplify mode.
32193 32193
32194 As another example, @samp{(equal (calc-eval '("$<$$") nil a b) "1")} 32194 As another example, @samp{(equal (calc-eval '("$<$$") nil a b) "1")}
32195 checks if the number in string @expr{a} is less than the one in 32195 checks if the number in string @expr{a} is less than the one in
32196 string @expr{b}. Without using a list, the integer 1 might 32196 string @expr{b}. Without using a list, the integer 1 might
32197 come out in a variety of formats which would be hard to test for 32197 come out in a variety of formats which would be hard to test for
32763 32763
32764 @defun calc-normalize n 32764 @defun calc-normalize n
32765 This function takes a Calc object and ``normalizes'' it. At the very 32765 This function takes a Calc object and ``normalizes'' it. At the very
32766 least this involves re-rounding floating-point values according to the 32766 least this involves re-rounding floating-point values according to the
32767 current precision and other similar jobs. Also, unless the user has 32767 current precision and other similar jobs. Also, unless the user has
32768 selected no-simplify mode (@pxref{Simplification Modes}), this involves 32768 selected No-Simplify mode (@pxref{Simplification Modes}), this involves
32769 actually evaluating a formula object by executing the function calls 32769 actually evaluating a formula object by executing the function calls
32770 it contains, and possibly also doing algebraic simplification, etc. 32770 it contains, and possibly also doing algebraic simplification, etc.
32771 @end defun 32771 @end defun
32772 32772
32773 @defun calc-top-list-n n m 32773 @defun calc-top-list-n n m
33125 Lisp error which @code{normalize} will trap. The net effect is that the 33125 Lisp error which @code{normalize} will trap. The net effect is that the
33126 function call which led here will be left in symbolic form. 33126 function call which led here will be left in symbolic form.
33127 @end defun 33127 @end defun
33128 33128
33129 @defun inexact-value 33129 @defun inexact-value
33130 If Symbolic Mode is enabled, this will signal an error that causes 33130 If Symbolic mode is enabled, this will signal an error that causes
33131 @code{normalize} to leave the formula in symbolic form, with the message 33131 @code{normalize} to leave the formula in symbolic form, with the message
33132 ``Inexact result.'' (This function has no effect when not in Symbolic Mode.) 33132 ``Inexact result.'' (This function has no effect when not in Symbolic mode.)
33133 Note that if your function calls @samp{(sin 5)} in Symbolic Mode, the 33133 Note that if your function calls @samp{(sin 5)} in Symbolic mode, the
33134 @code{sin} function will call @code{inexact-value}, which will cause your 33134 @code{sin} function will call @code{inexact-value}, which will cause your
33135 function to be left unsimplified. You may instead wish to call 33135 function to be left unsimplified. You may instead wish to call
33136 @samp{(normalize (list 'calcFunc-sin 5))}, which in Symbolic Mode will 33136 @samp{(normalize (list 'calcFunc-sin 5))}, which in Symbolic mode will
33137 return the formula @samp{sin(5)} to your function. 33137 return the formula @samp{sin(5)} to your function.
33138 @end defun 33138 @end defun
33139 33139
33140 @defun overflow 33140 @defun overflow
33141 This signals an error that will be reported as a floating-point overflow. 33141 This signals an error that will be reported as a floating-point overflow.
33177 If a function call fails, because the function is void or has the wrong 33177 If a function call fails, because the function is void or has the wrong
33178 number of parameters, or because it returns @code{nil} or calls 33178 number of parameters, or because it returns @code{nil} or calls
33179 @code{reject-arg} or @code{inexact-result}, @code{normalize} returns 33179 @code{reject-arg} or @code{inexact-result}, @code{normalize} returns
33180 the formula still in symbolic form. 33180 the formula still in symbolic form.
33181 33181
33182 If the current Simplification Mode is ``none'' or ``numeric arguments 33182 If the current simplification mode is ``none'' or ``numeric arguments
33183 only,'' @code{normalize} will act appropriately. However, the more 33183 only,'' @code{normalize} will act appropriately. However, the more
33184 powerful simplification modes (like algebraic simplification) are 33184 powerful simplification modes (like Algebraic Simplification) are
33185 not handled by @code{normalize}. They are handled by @code{calc-normalize}, 33185 not handled by @code{normalize}. They are handled by @code{calc-normalize},
33186 which calls @code{normalize} and possibly some other routines, such 33186 which calls @code{normalize} and possibly some other routines, such
33187 as @code{simplify} or @code{simplify-units}. Programs generally will 33187 as @code{simplify} or @code{simplify-units}. Programs generally will
33188 never call @code{calc-normalize} except when popping or pushing values 33188 never call @code{calc-normalize} except when popping or pushing values
33189 on the stack. 33189 on the stack.
33367 @findex quarter-circle 33367 @findex quarter-circle
33368 @defun full-circle symb 33368 @defun full-circle symb
33369 If the current angular mode is Degrees or HMS, this function returns the 33369 If the current angular mode is Degrees or HMS, this function returns the
33370 integer 360. In Radians mode, this function returns either the 33370 integer 360. In Radians mode, this function returns either the
33371 corresponding value in radians to the current precision, or the formula 33371 corresponding value in radians to the current precision, or the formula
33372 @samp{2*pi}, depending on the Symbolic Mode. There are also similar 33372 @samp{2*pi}, depending on the Symbolic mode. There are also similar
33373 function @code{half-circle} and @code{quarter-circle}. 33373 function @code{half-circle} and @code{quarter-circle}.
33374 @end defun 33374 @end defun
33375 33375
33376 @defun power-of-2 n 33376 @defun power-of-2 n
33377 Compute two to the integer power @var{n}, as a (potentially very large) 33377 Compute two to the integer power @var{n}, as a (potentially very large)
33425 Convert the number @var{a} from radians to the current angular mode. 33425 Convert the number @var{a} from radians to the current angular mode.
33426 If @var{a} is a formula, this returns the formula @samp{deg(@var{a})}. 33426 If @var{a} is a formula, this returns the formula @samp{deg(@var{a})}.
33427 @end defun 33427 @end defun
33428 33428
33429 @defun to-radians-2 a 33429 @defun to-radians-2 a
33430 Like @code{to-radians}, except that in Symbolic Mode a degrees to 33430 Like @code{to-radians}, except that in Symbolic mode a degrees to
33431 radians conversion yields a formula like @samp{@var{a}*pi/180}. 33431 radians conversion yields a formula like @samp{@var{a}*pi/180}.
33432 @end defun 33432 @end defun
33433 33433
33434 @defun from-radians-2 a 33434 @defun from-radians-2 a
33435 Like @code{from-radians}, except that in Symbolic Mode a radians to 33435 Like @code{from-radians}, except that in Symbolic mode a radians to
33436 degrees conversion yields a formula like @samp{@var{a}*180/pi}. 33436 degrees conversion yields a formula like @samp{@var{a}*180/pi}.
33437 @end defun 33437 @end defun
33438 33438
33439 @defun random-digit 33439 @defun random-digit
33440 Produce a random base-1000 digit in the range 0 to 999. 33440 Produce a random base-1000 digit in the range 0 to 999.