aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Belanger2012-08-01 13:24:13 -0500
committerJay Belanger2012-08-01 13:24:13 -0500
commit8e7046c395d80058a8a59525a965ff5c71c76cbc (patch)
treeceb48cea6c13a742c066fa401a7e994e4e4f1cbf
parent0f6cabdbbb64e0e73a8b2b1a442e1e8a1083c547 (diff)
downloademacs-8e7046c395d80058a8a59525a965ff5c71c76cbc.tar.gz
emacs-8e7046c395d80058a8a59525a965ff5c71c76cbc.zip
calc.texi (Simplification modes): Mention "basic" simplification.
(The Calc Mode Line): Mention the mode line display for Basic simplification mode. (Simplify Formulas): Refer to 'algebraic' rather than 'default' simplifications. (Basic Simplifications): Rename from "Limited Simplifications" Replace "limited" by "basic" throughout. (Algebraic Simplifications): Indicate that the algebraic simplifications are done by default. (Unsafe Simplifications): Mention `m E'. (Simplification of Units): Mention `m U'. (Trigonometric/Hyperbolic Functions, Reducing and Mapping, Kinds of Declarations, Functions for Declarations): Mention "algebraic simplifications" instead of `a s'.
-rw-r--r--doc/misc/ChangeLog17
-rw-r--r--doc/misc/calc.texi276
2 files changed, 156 insertions, 137 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index d0f60c60234..2efb00a4898 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,20 @@
12012-08-01 Jay Belanger <jay.p.belanger@gmail.com>
2
3 * calc.texi (Simplification modes): Mention "basic" simplification.
4 (The Calc Mode Line): Mention the mode line display for Basic
5 simplification mode.
6 (Simplify Formulas): Refer to 'algebraic' rather than 'default'
7 simplifications.
8 (Basic Simplifications): Rename from "Limited Simplifications"
9 Replace "limited" by "basic" throughout.
10 (Algebraic Simplifications): Indicate that the algebraic
11 simplifications are done by default.
12 (Unsafe Simplifications): Mention `m E'.
13 (Simplification of Units): Mention `m U'.
14 (Trigonometric/Hyperbolic Functions, Reducing and Mapping)
15 (Kinds of Declarations, Functions for Declarations): Mention
16 "algebraic simplifications" instead of `a s'.
17
12012-07-30 Jay Belanger <jay.p.belanger@gmail.com> 182012-07-30 Jay Belanger <jay.p.belanger@gmail.com>
2 19
3 * calc.texi (Getting Started, Tutorial): Change simulated 20 * calc.texi (Getting Started, Tutorial): Change simulated
diff --git a/doc/misc/calc.texi b/doc/misc/calc.texi
index 301866ad65c..f36796b180f 100644
--- a/doc/misc/calc.texi
+++ b/doc/misc/calc.texi
@@ -12569,7 +12569,7 @@ are ``normalized'' when being taken from or pushed onto the stack.
12569Some normalizations are unavoidable, such as rounding floating-point 12569Some normalizations are unavoidable, such as rounding floating-point
12570results to the current precision, and reducing fractions to simplest 12570results to the current precision, and reducing fractions to simplest
12571form. Others, such as simplifying a formula like @expr{a+a} (or @expr{2+3}), 12571form. Others, such as simplifying a formula like @expr{a+a} (or @expr{2+3}),
12572are done by default but can be turned off when necessary. 12572are done automatically but can be turned off when necessary.
12573 12573
12574When you press a key like @kbd{+} when @expr{2} and @expr{3} are on the 12574When you press a key like @kbd{+} when @expr{2} and @expr{3} are on the
12575stack, Calc pops these numbers, normalizes them, creates the formula 12575stack, Calc pops these numbers, normalizes them, creates the formula
@@ -12603,9 +12603,9 @@ A constant is a number or other numeric object (such as a constant
12603error form or modulo form), or a vector all of whose 12603error form or modulo form), or a vector all of whose
12604elements are constant. 12604elements are constant.
12605 12605
12606@kindex m L 12606@kindex m I
12607@pindex calc-limited-simplify-mode 12607@pindex calc-basic-simplify-mode
12608The @kbd{m L} (@code{calc-limited-simplify-mode}) command does limited 12608The @kbd{m I} (@code{calc-basic-simplify-mode}) command does some basic
12609simplifications for all formulas. This includes many easy and 12609simplifications for all formulas. This includes many easy and
12610fast algebraic simplifications such as @expr{a+0} to @expr{a}, and 12610fast algebraic simplifications such as @expr{a+0} to @expr{a}, and
12611@expr{a + 2 a} to @expr{3 a}, as well as evaluating functions like 12611@expr{a + 2 a} to @expr{3 a}, as well as evaluating functions like
@@ -12620,23 +12620,21 @@ to the current binary word size. @xref{Binary Functions}. Real numbers
12620are rounded to the nearest integer and then clipped; other kinds of 12620are rounded to the nearest integer and then clipped; other kinds of
12621results (after the default simplifications) are left alone. 12621results (after the default simplifications) are left alone.
12622 12622
12623@kindex m D 12623@kindex m A
12624@pindex calc-default-simplify-mode 12624@pindex calc-alg-simplify-mode
12625The @kbd{m D} (@code{calc-default-simplify-mode}) mode does standard 12625The @kbd{m A} (@code{calc-alg-simplify-mode}) mode does standard
12626algebraic simplifications. @xref{Algebraic Simplifications}. 12626algebraic simplifications. @xref{Algebraic Simplifications}.
12627 12627
12628@kindex m E 12628@kindex m E
12629@pindex calc-ext-simplify-mode 12629@pindex calc-ext-simplify-mode
12630The @kbd{m E} (@code{calc-ext-simplify-mode}) mode does ``extended'' 12630The @kbd{m E} (@code{calc-ext-simplify-mode}) mode does ``extended'', or
12631algebraic simplification, as by the @kbd{a e} (@code{calc-simplify-extended}) 12631``unsafe'', algebraic simplification. @xref{Unsafe Simplifications}.
12632command. @xref{Unsafe Simplifications}.
12633 12632
12634@kindex m U 12633@kindex m U
12635@pindex calc-units-simplify-mode 12634@pindex calc-units-simplify-mode
12636The @kbd{m U} (@code{calc-units-simplify-mode}) mode does units 12635The @kbd{m U} (@code{calc-units-simplify-mode}) mode does units
12637simplification; it applies the command @kbd{u s} 12636simplification. @xref{Simplification of Units}. These include the
12638(@code{calc-simplify-units}), which in turn 12637algebraic simplifications, plus variable names which
12639is a superset of @kbd{a s}. In this mode, variable names which
12640are identifiable as unit names (like @samp{mm} for ``millimeters'') 12638are identifiable as unit names (like @samp{mm} for ``millimeters'')
12641are simplified with their unit definitions in mind. 12639are simplified with their unit definitions in mind.
12642 12640
@@ -12853,8 +12851,8 @@ roots (if any) will be included in the list.
12853only when certain values are integers (such as @samp{(x^y)^z} 12851only when certain values are integers (such as @samp{(x^y)^z}
12854shown above). 12852shown above).
12855 12853
12856Another command that makes use of declarations is @kbd{a s}, when 12854Calc's algebraic simplifications also make use of declarations when
12857simplifying equations and inequalities. It will cancel @code{x} 12855simplifying equations and inequalities. They will cancel @code{x}
12858from both sides of @samp{a x = b x} only if it is sure @code{x} 12856from both sides of @samp{a x = b x} only if it is sure @code{x}
12859is non-zero, say, because it has a @code{pos} declaration. 12857is non-zero, say, because it has a @code{pos} declaration.
12860To declare specifically that @code{x} is real and non-zero, 12858To declare specifically that @code{x} is real and non-zero,
@@ -12992,10 +12990,10 @@ i.e., is mathematically equal to a real number times @expr{i}.
12992The @code{dpos} function checks for positive (but nonzero) reals. 12990The @code{dpos} function checks for positive (but nonzero) reals.
12993The @code{dneg} function checks for negative reals. The @code{dnonneg} 12991The @code{dneg} function checks for negative reals. The @code{dnonneg}
12994function checks for nonnegative reals, i.e., reals greater than or 12992function checks for nonnegative reals, i.e., reals greater than or
12995equal to zero. Note that the @kbd{a s} command can simplify an 12993equal to zero. Note that Calc's algebraic simplifications, which are
12996expression like @expr{x > 0} to 1 or 0 using @code{dpos}, and that 12994effectively applied to all conditions in rewrite rules, can simplify
12997@kbd{a s} is effectively applied to all conditions in rewrite rules, 12995an expression like @expr{x > 0} to 1 or 0 using @code{dpos}.
12998so the actual functions @code{dpos}, @code{dneg}, and @code{dnonneg} 12996So the actual functions @code{dpos}, @code{dneg}, and @code{dnonneg}
12999are rarely necessary. 12997are rarely necessary.
13000 12998
13001@ignore 12999@ignore
@@ -13021,7 +13019,7 @@ also the set of objects considered ``true'' in conditional contexts.)
13021The @code{deven} function returns 1 if its argument is known to be 13019The @code{deven} function returns 1 if its argument is known to be
13022an even integer (or integer-valued float); it returns 0 if its argument 13020an even integer (or integer-valued float); it returns 0 if its argument
13023is known not to be even (because it is known to be odd or a non-integer). 13021is known not to be even (because it is known to be odd or a non-integer).
13024The @kbd{a s} command uses this to simplify a test of the form 13022Calc's algebraic simplifications use this to simplify a test of the form
13025@samp{x % 2 = 0}. There is also an analogous @code{dodd} function. 13023@samp{x % 2 = 0}. There is also an analogous @code{dodd} function.
13026 13024
13027@ignore 13025@ignore
@@ -15648,7 +15646,7 @@ The exact sequence of events is as follows: When Calc tries a
15648rule, it first matches the pattern as usual. It then substitutes 15646rule, it first matches the pattern as usual. It then substitutes
15649@samp{#1}, @samp{#2}, etc., in the conditions, if any. Next, the 15647@samp{#1}, @samp{#2}, etc., in the conditions, if any. Next, the
15650conditions are simplified and evaluated in order from left to right, 15648conditions are simplified and evaluated in order from left to right,
15651as if by the @w{@kbd{a s}} algebra command (@pxref{Simplifying Formulas}). 15649using the algebraic simplifications (@pxref{Simplifying Formulas}).
15652Each result is true if it is a nonzero number, or an expression 15650Each result is true if it is a nonzero number, or an expression
15653that can be proven to be nonzero (@pxref{Declarations}). If the 15651that can be proven to be nonzero (@pxref{Declarations}). If the
15654results of all conditions are true, the expression (such as 15652results of all conditions are true, the expression (such as
@@ -15876,8 +15874,8 @@ Default simplifications for numeric arguments only (@kbd{m N}).
15876@item BinSimp@var{w} 15874@item BinSimp@var{w}
15877Binary-integer simplification mode; word size @var{w} (@kbd{m B}, @kbd{b w}). 15875Binary-integer simplification mode; word size @var{w} (@kbd{m B}, @kbd{b w}).
15878 15876
15879@item LimSimp 15877@item BasicSimp
15880Limited simplification mode (@kbd{m L}). 15878Basic simplification mode (@kbd{m I}).
15881 15879
15882@item ExtSimp 15880@item ExtSimp
15883Extended algebraic simplification mode (@kbd{m E}). 15881Extended algebraic simplification mode (@kbd{m E}).
@@ -18328,7 +18326,7 @@ reason why changing built-in variables is a bad idea. Arguments of
18328the form @expr{x} plus a multiple of @cpiover{2} are also simplified. 18326the form @expr{x} plus a multiple of @cpiover{2} are also simplified.
18329Calc includes similar formulas for @code{cos} and @code{tan}. 18327Calc includes similar formulas for @code{cos} and @code{tan}.
18330 18328
18331The @kbd{a s} command knows all angles which are integer multiples of 18329Calc's algebraic simplifications know all angles which are integer multiples of
18332@cpiover{12}, @cpiover{10}, or @cpiover{8} radians. In Degrees mode, 18330@cpiover{12}, @cpiover{10}, or @cpiover{8} radians. In Degrees mode,
18333analogous simplifications occur for integer multiples of 15 or 18 18331analogous simplifications occur for integer multiples of 15 or 18
18334degrees, and for arguments plus multiples of 90 degrees. 18332degrees, and for arguments plus multiples of 90 degrees.
@@ -22178,9 +22176,9 @@ but which also substitutes stored values for variables in the formula.
22178Use @kbd{a v} if you want the variables to ignore their stored values. 22176Use @kbd{a v} if you want the variables to ignore their stored values.
22179 22177
22180If you give a numeric prefix argument of 2 to @kbd{a v}, it simplifies 22178If you give a numeric prefix argument of 2 to @kbd{a v}, it simplifies
22181as if in Algebraic Simplification mode. This is equivalent to typing 22179using Calc's algebraic simplifications; @pxref{Simplifying Formulas}.
22182@kbd{a s}; @pxref{Simplifying Formulas}. If you give a numeric prefix 22180If you give a numeric prefix of 3 or more, it uses Extended
22183of 3 or more, it uses Extended Simplification mode (@kbd{a e}). 22181Simplification mode (@kbd{a e}).
22184 22182
22185If you give a negative prefix argument @mathit{-1}, @mathit{-2}, or @mathit{-3}, 22183If you give a negative prefix argument @mathit{-1}, @mathit{-2}, or @mathit{-3},
22186it simplifies in the corresponding mode but only works on the top-level 22184it simplifies in the corresponding mode but only works on the top-level
@@ -22253,8 +22251,8 @@ If inequalities with opposite direction (e.g., @samp{<} and @samp{>})
22253are mapped, the direction of the second inequality is reversed to 22251are mapped, the direction of the second inequality is reversed to
22254match the first: Using @kbd{a M +} on @samp{a < b} and @samp{a > 2} 22252match the first: Using @kbd{a M +} on @samp{a < b} and @samp{a > 2}
22255reverses the latter to get @samp{2 < a}, which then allows the 22253reverses the latter to get @samp{2 < a}, which then allows the
22256combination @samp{a + 2 < b + a}, which the @kbd{a s} command can 22254combination @samp{a + 2 < b + a}, which the algebraic simplifications
22257then simplify to get @samp{2 < b}. 22255can reduce to @samp{2 < b}.
22258 22256
22259Using @kbd{a M *}, @kbd{a M /}, @kbd{a M n}, or @kbd{a M &} to negate 22257Using @kbd{a M *}, @kbd{a M /}, @kbd{a M n}, or @kbd{a M &} to negate
22260or invert an inequality will reverse the direction of the inequality. 22258or invert an inequality will reverse the direction of the inequality.
@@ -22334,19 +22332,20 @@ and rewrite rules. @xref{Rearranging with Selections}.
22334@xref{Rewrite Rules}. 22332@xref{Rewrite Rules}.
22335 22333
22336@xref{Simplification Modes}, for commands to control what level of 22334@xref{Simplification Modes}, for commands to control what level of
22337simplification occurs automatically. Normally only the default 22335simplification occurs automatically. Normally the algebraic
22338algebraic simplifications occur. If you have turned on a 22336simplifications described below occur. If you have turned on a
22339simplification mode which does not do these default simplifications, 22337simplification mode which does not do these algebraic simplifications,
22340you can still perform them on a formula with the @kbd{a s} command. 22338you can still apply them to a formula with the @kbd{a s}
22339(@code{calc-simplify}) [@code{simplify}] command.
22341 22340
22342There are some simplifications that, while sometimes useful, are never 22341There are some simplifications that, while sometimes useful, are never
22343done automatically. For example, the @kbd{I} prefix can be given to 22342done automatically. For example, the @kbd{I} prefix can be given to
22344@kbd{a s}; the @kbd{I a s} command will change any trigonometric 22343@kbd{a s}; the @kbd{I a s} command will change any trigonometric
22345function to the appropriate combination of @samp{sin}s and @samp{cos}s 22344function to the appropriate combination of @samp{sin}s and @samp{cos}s
22346before simplifying. This can be useful in simplifying even mildly 22345before simplifying. This can be useful in simplifying even mildly
22347complicated trigonometric expressions. For example, while @kbd{a s} 22346complicated trigonometric expressions. For example, while the algebraic
22348can reduce @samp{sin(x) csc(x)} to @samp{1}, it will not simplify 22347simplifications can reduce @samp{sin(x) csc(x)} to @samp{1}, they will not
22349@samp{sin(x)^2 csc(x)}. The command @kbd{I a s} can be used to 22348simplify @samp{sin(x)^2 csc(x)}. The command @kbd{I a s} can be used to
22350simplify this latter expression; it will transform @samp{sin(x)^2 22349simplify this latter expression; it will transform @samp{sin(x)^2
22351csc(x)} into @samp{sin(x)}. However, @kbd{I a s} will also perform 22350csc(x)} into @samp{sin(x)}. However, @kbd{I a s} will also perform
22352some ``simplifications'' which may not be desired; for example, it 22351some ``simplifications'' which may not be desired; for example, it
@@ -22357,21 +22356,22 @@ combinations of @samp{sinh}s and @samp{cosh}s before simplifying.
22357 22356
22358 22357
22359@menu 22358@menu
22360* Limited Simplifications:: 22359* Basic Simplifications::
22361* Algebraic Simplifications:: 22360* Algebraic Simplifications::
22362* Unsafe Simplifications:: 22361* Unsafe Simplifications::
22363* Simplification of Units:: 22362* Simplification of Units::
22364@end menu 22363@end menu
22365 22364
22366@node Limited Simplifications, Algebraic Simplifications, Simplifying Formulas, Simplifying Formulas 22365@node Basic Simplifications, Algebraic Simplifications, Simplifying Formulas, Simplifying Formulas
22367@subsection Limited Simplifications 22366@subsection Basic Simplifications
22368 22367
22369@noindent 22368@noindent
22370@cindex Limited simplifications 22369@cindex Basic simplifications
22371This section describes a limited set of simplifications. These, as 22370This section describes basic simplifications which Calc performs in many
22372well as those described in the next section, are normally applied to 22371situations. For example, both binary simplifications and algebraic
22373all results. You can type @kbd{m L} to restrict the simplifications 22372simplifications begin by performing these basic simplifications. You
22374done on the stack to this limited set. 22373can type @kbd{m I} to restrict the simplifications done on the stack to
22374these simplifications.
22375 22375
22376The most basic simplification is the evaluation of functions. 22376The most basic simplification is the evaluation of functions.
22377For example, @expr{2 + 3} is evaluated to @expr{5}, and @expr{@tfn{sqrt}(9)} 22377For example, @expr{2 + 3} is evaluated to @expr{5}, and @expr{@tfn{sqrt}(9)}
@@ -22391,7 +22391,7 @@ operator) do not evaluate their arguments, @code{if} (the @code{? :}
22391operator) does not evaluate all of its arguments, and @code{evalto} 22391operator) does not evaluate all of its arguments, and @code{evalto}
22392does not evaluate its lefthand argument. 22392does not evaluate its lefthand argument.
22393 22393
22394Most commands apply at least these limited simplifications to all 22394Most commands apply at least these basic simplifications to all
22395arguments they take from the stack, perform a particular operation, 22395arguments they take from the stack, perform a particular operation,
22396then simplify the result before pushing it back on the stack. In the 22396then simplify the result before pushing it back on the stack. In the
22397common special case of regular arithmetic commands like @kbd{+} and 22397common special case of regular arithmetic commands like @kbd{+} and
@@ -22400,7 +22400,7 @@ and collected into a suitable function call, which is then simplified
22400(the arguments being simplified first as part of the process, as 22400(the arguments being simplified first as part of the process, as
22401described above). 22401described above).
22402 22402
22403Even the limited set of simplifications are too numerous to describe 22403Even the basic set of simplifications are too numerous to describe
22404completely here, but this section will describe the ones that apply to the 22404completely here, but this section will describe the ones that apply to the
22405major arithmetic operators. This list will be rather technical in 22405major arithmetic operators. This list will be rather technical in
22406nature, and will probably be interesting to you only if you are 22406nature, and will probably be interesting to you only if you are
@@ -22438,11 +22438,11 @@ commutative law (@expr{a + b} to @expr{b + a}) except in a few
22438special cases described below. Some algebra programs always 22438special cases described below. Some algebra programs always
22439rearrange terms into a canonical order, which enables them to 22439rearrange terms into a canonical order, which enables them to
22440see that @expr{a b + b a} can be simplified to @expr{2 a b}. 22440see that @expr{a b + b a} can be simplified to @expr{2 a b}.
22441Calc assumes you have put the terms into the order you want 22441If you are using Basic Simplification mode, Calc assumes you have put
22442and generally leaves that order alone, with the consequence 22442the terms into the order you want and generally leaves that order alone,
22443that formulas like the above will only be simplified if you 22443with the consequence that formulas like the above will only be
22444explicitly give the @kbd{a s} command. @xref{Algebraic 22444simplified if you explicitly give the @kbd{a s} command.
22445Simplifications}. 22445@xref{Algebraic Simplifications}.
22446 22446
22447Differences @expr{a - b} are treated like sums @expr{a + (-b)} 22447Differences @expr{a - b} are treated like sums @expr{a + (-b)}
22448for purposes of simplification; one of the default simplifications 22448for purposes of simplification; one of the default simplifications
@@ -22473,9 +22473,8 @@ for adjacent terms in a larger sum. Thus @expr{a + b + b + c}
22473is simplified to @expr{a + 2 b + c}, but @expr{a + b + c + b} 22473is simplified to @expr{a + 2 b + c}, but @expr{a + b + c + b}
22474is not simplified. The reason is that comparing all terms of a 22474is not simplified. The reason is that comparing all terms of a
22475sum with one another would require time proportional to the 22475sum with one another would require time proportional to the
22476square of the number of terms; Calc relegates potentially slow 22476square of the number of terms; Calc omits potentially slow
22477operations like this to commands that have to be invoked 22477operations like this in basic simplification mode.
22478explicitly, like @kbd{a s}.
22479 22478
22480Finally, @expr{a + 0} and @expr{0 + a} are simplified to @expr{a}. 22479Finally, @expr{a + 0} and @expr{0 + a} are simplified to @expr{a}.
22481A consequence of the above rules is that @expr{0 - a} is simplified 22480A consequence of the above rules is that @expr{0 - a} is simplified
@@ -22672,9 +22671,9 @@ and @expr{b} are known to be real.
22672 22671
22673Functions like @code{sin} and @code{arctan} generally don't have 22672Functions like @code{sin} and @code{arctan} generally don't have
22674any default simplifications beyond simply evaluating the functions 22673any default simplifications beyond simply evaluating the functions
22675for suitable numeric arguments and infinity. The @kbd{a s} command 22674for suitable numeric arguments and infinity. The algebraic
22676described in the next section does provide some simplifications for 22675simplifications described in the next section do provide some
22677these functions, though. 22676simplifications for these functions, though.
22678 22677
22679One important simplification that does occur is that 22678One important simplification that does occur is that
22680@expr{@tfn{ln}(@tfn{e})} is simplified to 1, and @expr{@tfn{ln}(@tfn{e}^x)} is 22679@expr{@tfn{ln}(@tfn{e})} is simplified to 1, and @expr{@tfn{ln}(@tfn{e}^x)} is
@@ -22689,25 +22688,23 @@ and reversing the inequality. While it might seem reasonable to simplify
22689@expr{!!x} to @expr{x}, this would not be valid in general because 22688@expr{!!x} to @expr{x}, this would not be valid in general because
22690@expr{!!2} is 1, not 2. 22689@expr{!!2} is 1, not 2.
22691 22690
22692Most other Calc functions have few if any default simplifications 22691Most other Calc functions have few if any basic simplifications
22693defined, aside of course from evaluation when the arguments are 22692defined, aside of course from evaluation when the arguments are
22694suitable numbers. 22693suitable numbers.
22695 22694
22696@node Algebraic Simplifications, Unsafe Simplifications, Limited Simplifications, Simplifying Formulas 22695@node Algebraic Simplifications, Unsafe Simplifications, Basic Simplifications, Simplifying Formulas
22697@subsection Algebraic Simplifications 22696@subsection Algebraic Simplifications
22698 22697
22699@noindent 22698@noindent
22700@cindex Algebraic simplifications 22699@cindex Algebraic simplifications
22701@kindex a s 22700@kindex a s
22702@kindex I a s 22701@kindex m A
22703@kindex H a s
22704@pindex calc-simplify
22705@tindex simplify
22706This section describes all simplifications that are performed by 22702This section describes all simplifications that are performed by
22707the default algebraic simplification mode. If you have switched to a different 22703the algebraic simplification mode, which is the default simplification
22708simplification mode, you can switch back with the @kbd{m D} command. 22704mode. If you have switched to a different simplification mode, you can
22709Even in other simplification modes, the @kbd{a s} command will use 22705switch back with the @kbd{m A} command. Even in other simplification
22710these algebraic simplifications to simplifies the formula. 22706modes, the @kbd{a s} command will use these algebraic simplifications to
22707simplify the formula.
22711 22708
22712There is a variable, @code{AlgSimpRules}, in which you can put rewrites 22709There is a variable, @code{AlgSimpRules}, in which you can put rewrites
22713to be applied. Its use is analogous to @code{EvalRules}, 22710to be applied. Its use is analogous to @code{EvalRules},
@@ -22715,7 +22712,7 @@ but without the special restrictions. Basically, the simplifier does
22715@samp{@w{a r} AlgSimpRules} with an infinite repeat count on the whole 22712@samp{@w{a r} AlgSimpRules} with an infinite repeat count on the whole
22716expression being simplified, then it traverses the expression applying 22713expression being simplified, then it traverses the expression applying
22717the built-in rules described below. If the result is different from 22714the built-in rules described below. If the result is different from
22718the original expression, the process repeats with the limited 22715the original expression, the process repeats with the basic
22719simplifications (including @code{EvalRules}), then @code{AlgSimpRules}, 22716simplifications (including @code{EvalRules}), then @code{AlgSimpRules},
22720then the built-in simplifications, and so on. 22717then the built-in simplifications, and so on.
22721 22718
@@ -22731,8 +22728,8 @@ commuted to @expr{-x + 2}.
22731 22728
22732Also, terms of sums are combined by the distributive law, as in 22729Also, terms of sums are combined by the distributive law, as in
22733@expr{x + y + 2 x} to @expr{y + 3 x}. This always occurs for 22730@expr{x + y + 2 x} to @expr{y + 3 x}. This always occurs for
22734adjacent terms, but @kbd{a s} compares all pairs of terms including 22731adjacent terms, but Calc's algebraic simplifications compare all pairs
22735non-adjacent ones. 22732of terms including non-adjacent ones.
22736 22733
22737@tex 22734@tex
22738\bigskip 22735\bigskip
@@ -22935,21 +22932,26 @@ as is @expr{x^2 >= 0} if @expr{x} is known to be real.
22935@cindex Unsafe simplifications 22932@cindex Unsafe simplifications
22936@cindex Extended simplification 22933@cindex Extended simplification
22937@kindex a e 22934@kindex a e
22935@kindex m E
22938@pindex calc-simplify-extended 22936@pindex calc-simplify-extended
22939@ignore 22937@ignore
22940@mindex esimpl@idots 22938@mindex esimpl@idots
22941@end ignore 22939@end ignore
22942@tindex esimplify 22940@tindex esimplify
22943The @kbd{a e} (@code{calc-simplify-extended}) [@code{esimplify}] command 22941Calc is capable of performing some simplifications which may sometimes
22944is like @kbd{a s} 22942be desired but which are not ``safe'' in all cases. The @kbd{a e}
22945except that it applies some additional simplifications which are not 22943(@code{calc-simplify-extended}) [@code{esimplify}] command
22946``safe'' in all cases. Use this only if you know the values in your 22944applies the algebraic simplifications as well as these extended, or
22947formula lie in the restricted ranges for which these simplifications 22945``unsafe'', simplifications. Use this only if you know the values in
22948are valid. The symbolic integrator uses @kbd{a e}; 22946your formula lie in the restricted ranges for which these
22949one effect of this is that the integrator's results must be used with 22947simplifications are valid. You can use Extended Simplification mode
22950caution. Where an integral table will often attach conditions like 22948(@kbd{m E}) to have these simplifications done automatically.
22951``for positive @expr{a} only,'' Calc (like most other symbolic 22949
22952integration programs) will simply produce an unqualified result. 22950The symbolic integrator uses these extended simplifications; one effect
22951of this is that the integrator's results must be used with caution.
22952Where an integral table will often attach conditions like ``for positive
22953@expr{a} only,'' Calc (like most other symbolic integration programs)
22954will simply produce an unqualified result.
22953 22955
22954Because @kbd{a e}'s simplifications are unsafe, it is sometimes better 22956Because @kbd{a e}'s simplifications are unsafe, it is sometimes better
22955to type @kbd{C-u -3 a v}, which does extended simplification only 22957to type @kbd{C-u -3 a v}, which does extended simplification only
@@ -22957,21 +22959,20 @@ on the top level of the formula without affecting the sub-formulas.
22957In fact, @kbd{C-u -3 j v} allows you to target extended simplification 22959In fact, @kbd{C-u -3 j v} allows you to target extended simplification
22958to any specific part of a formula. 22960to any specific part of a formula.
22959 22961
22960The variable @code{ExtSimpRules} contains rewrites to be applied by 22962The variable @code{ExtSimpRules} contains rewrites to be applied when
22961the @kbd{a e} command. These are applied in addition to 22963the extended simplifications are used. These are applied in addition to
22962@code{EvalRules} and @code{AlgSimpRules}. (The @kbd{a r AlgSimpRules} 22964@code{EvalRules} and @code{AlgSimpRules}. (The @kbd{a r AlgSimpRules}
22963step described above is simply followed by an @kbd{a r ExtSimpRules} step.) 22965step described above is simply followed by an @kbd{a r ExtSimpRules} step.)
22964 22966
22965Following is a complete list of ``unsafe'' simplifications performed 22967Following is a complete list of the ``unsafe'' simplifications.
22966by @kbd{a e}.
22967 22968
22968@tex 22969@tex
22969\bigskip 22970\bigskip
22970@end tex 22971@end tex
22971 22972
22972Inverse trigonometric or hyperbolic functions, called with their 22973Inverse trigonometric or hyperbolic functions, called with their
22973corresponding non-inverse functions as arguments, are simplified 22974corresponding non-inverse functions as arguments, are simplified.
22974by @kbd{a e}. For example, @expr{@tfn{arcsin}(@tfn{sin}(x))} changes 22975For example, @expr{@tfn{arcsin}(@tfn{sin}(x))} changes
22975to @expr{x}. Also, @expr{@tfn{arcsin}(@tfn{cos}(x))} and 22976to @expr{x}. Also, @expr{@tfn{arcsin}(@tfn{cos}(x))} and
22976@expr{@tfn{arccos}(@tfn{sin}(x))} both change to @expr{@tfn{pi}/2 - x}. 22977@expr{@tfn{arccos}(@tfn{sin}(x))} both change to @expr{@tfn{pi}/2 - x}.
22977These simplifications are unsafe because they are valid only for 22978These simplifications are unsafe because they are valid only for
@@ -23011,8 +23012,8 @@ simplifications are safe if @expr{x} is known to be real).
23011Common factors are canceled from products on both sides of an 23012Common factors are canceled from products on both sides of an
23012equation, even if those factors may be zero: @expr{a x / b x} 23013equation, even if those factors may be zero: @expr{a x / b x}
23013to @expr{a / b}. Such factors are never canceled from 23014to @expr{a / b}. Such factors are never canceled from
23014inequalities: Even @kbd{a e} is not bold enough to reduce 23015inequalities: Even the extended simplifications are not bold enough to
23015@expr{a x < b x} to @expr{a < b} (or @expr{a > b}, depending 23016reduce @expr{a x < b x} to @expr{a < b} (or @expr{a > b}, depending
23016on whether you believe @expr{x} is positive or negative). 23017on whether you believe @expr{x} is positive or negative).
23017The @kbd{a M /} command can be used to divide a factor out of 23018The @kbd{a M /} command can be used to divide a factor out of
23018both sides of an inequality. 23019both sides of an inequality.
@@ -23021,13 +23022,14 @@ both sides of an inequality.
23021@subsection Simplification of Units 23022@subsection Simplification of Units
23022 23023
23023@noindent 23024@noindent
23024The simplifications described in this section are applied by the 23025The simplifications described in this section (as well as the algebraic
23025@kbd{u s} (@code{calc-simplify-units}) command. These are in addition 23026simplifications) are applied when units need to be simplified. They can
23026to the regular @kbd{a s} (but not @kbd{a e}) simplifications described 23027be applied using the @kbd{u s} (@code{calc-simplify-units}) command, or
23027earlier. @xref{Basic Operations on Units}. 23028will be done automatically in Units Simplification mode (@kbd{m U}).
23029@xref{Basic Operations on Units}.
23028 23030
23029The variable @code{UnitSimpRules} contains rewrites to be applied by 23031The variable @code{UnitSimpRules} contains rewrites to be applied by
23030the @kbd{u s} command. These are applied in addition to @code{EvalRules} 23032units simplifications. These are applied in addition to @code{EvalRules}
23031and @code{AlgSimpRules}. 23033and @code{AlgSimpRules}.
23032 23034
23033Scalar mode is automatically put into effect when simplifying units. 23035Scalar mode is automatically put into effect when simplifying units.
@@ -23581,10 +23583,11 @@ forever!)
23581 23583
23582@vindex IntegSimpRules 23584@vindex IntegSimpRules
23583Another set of rules, stored in @code{IntegSimpRules}, are applied 23585Another set of rules, stored in @code{IntegSimpRules}, are applied
23584every time the integrator uses @kbd{a s} to simplify an intermediate 23586every time the integrator uses algebraic simplifications to simplify an
23585result. For example, putting the rule @samp{twice(x) := 2 x} into 23587intermediate result. For example, putting the rule
23586@code{IntegSimpRules} would tell Calc to convert the @code{twice} 23588@samp{twice(x) := 2 x} into @code{IntegSimpRules} would tell Calc to
23587function into a form it knows whenever integration is attempted. 23589convert the @code{twice} function into a form it knows whenever
23590integration is attempted.
23588 23591
23589One more way to influence the integrator is to define a function with 23592One more way to influence the integrator is to define a function with
23590the @kbd{Z F} command (@pxref{Algebraic Definitions}). Calc's 23593the @kbd{Z F} command (@pxref{Algebraic Definitions}). Calc's
@@ -23602,8 +23605,8 @@ above to try to hint at a more direct path to the desired result, or
23602you can use @code{IntegAfterRules}. This is an extra rule set that 23605you can use @code{IntegAfterRules}. This is an extra rule set that
23603runs after the main integrator returns its result; basically, Calc does 23606runs after the main integrator returns its result; basically, Calc does
23604an @kbd{a r IntegAfterRules} on the result before showing it to you. 23607an @kbd{a r IntegAfterRules} on the result before showing it to you.
23605(It also does an @kbd{a s}, without @code{IntegSimpRules}, after that 23608(It also does algebraic simplifications, without @code{IntegSimpRules},
23606to further simplify the result.) For example, Calc's integrator 23609after that to further simplify the result.) For example, Calc's integrator
23607sometimes produces expressions of the form @samp{ln(1+x) - ln(1-x)}; 23610sometimes produces expressions of the form @samp{ln(1+x) - ln(1-x)};
23608the default @code{IntegAfterRules} rewrite this into the more readable 23611the default @code{IntegAfterRules} rewrite this into the more readable
23609form @samp{2 arctanh(x)}. Note that, unlike @code{IntegRules}, 23612form @samp{2 arctanh(x)}. Note that, unlike @code{IntegRules},
@@ -25414,7 +25417,7 @@ The limits of a sum do not need to be integers. For example,
25414@samp{sum(a_k, k, 0, 2 n, n)} produces @samp{a_0 + a_n + a_(2 n)}. 25417@samp{sum(a_k, k, 0, 2 n, n)} produces @samp{a_0 + a_n + a_(2 n)}.
25415Calc computes the number of iterations using the formula 25418Calc computes the number of iterations using the formula
25416@samp{1 + (@var{high} - @var{low}) / @var{step}}, which must, 25419@samp{1 + (@var{high} - @var{low}) / @var{step}}, which must,
25417after simplification as if by @kbd{a s}, evaluate to an integer. 25420after algebraic simplification, evaluate to an integer.
25418 25421
25419If the number of iterations according to the above formula does 25422If the number of iterations according to the above formula does
25420not come out to an integer, the sum is invalid and will be left 25423not come out to an integer, the sum is invalid and will be left
@@ -26038,7 +26041,7 @@ rule, this is an additional condition that must be satisfied before
26038the rule is accepted. Once @var{old} has been successfully matched 26041the rule is accepted. Once @var{old} has been successfully matched
26039to the target expression, @var{cond} is evaluated (with all the 26042to the target expression, @var{cond} is evaluated (with all the
26040meta-variables substituted for the values they matched) and simplified 26043meta-variables substituted for the values they matched) and simplified
26041with @kbd{a s} (@code{calc-simplify}). If the result is a nonzero 26044with Calc's algebraic simplifications. If the result is a nonzero
26042number or any other object known to be nonzero (@pxref{Declarations}), 26045number or any other object known to be nonzero (@pxref{Declarations}),
26043the rule is accepted. If the result is zero or if it is a symbolic 26046the rule is accepted. If the result is zero or if it is a symbolic
26044formula that is not known to be nonzero, the rule is rejected. 26047formula that is not known to be nonzero, the rule is rejected.
@@ -26718,7 +26721,7 @@ whereas @samp{eval(cons(2+3, []))} will be converted to @samp{[5]}.
26718@end ignore 26721@end ignore
26719@tindex evalsimp 26722@tindex evalsimp
26720The formula @expr{x} has meta-variables substituted in the usual 26723The formula @expr{x} has meta-variables substituted in the usual
26721way, then algebraically simplified as if by the @kbd{a s} command. 26724way, then algebraically simplified.
26722 26725
26723@item evalextsimp(x) 26726@item evalextsimp(x)
26724@ignore 26727@ignore
@@ -26741,15 +26744,15 @@ There are also some special functions you can use in conditions.
26741@end ignore 26744@end ignore
26742@tindex let 26745@tindex let
26743The expression @expr{x} is evaluated with meta-variables substituted. 26746The expression @expr{x} is evaluated with meta-variables substituted.
26744The @kbd{a s} command's simplifications are @emph{not} applied by 26747The algebraic simplifications are @emph{not} applied by
26745default, but @expr{x} can include calls to @code{evalsimp} or 26748default, but @expr{x} can include calls to @code{evalsimp} or
26746@code{evalextsimp} as described above to invoke higher levels 26749@code{evalextsimp} as described above to invoke higher levels
26747of simplification. The 26750of simplification. The result of @expr{x} is then bound to the
26748result of @expr{x} is then bound to the meta-variable @expr{v}. As 26751meta-variable @expr{v}. As usual, if this meta-variable has already
26749usual, if this meta-variable has already been matched to something 26752been matched to something else the two values must be equal; if the
26750else the two values must be equal; if the meta-variable is new then 26753meta-variable is new then it is bound to the result of the expression.
26751it is bound to the result of the expression. This variable can then 26754This variable can then appear in later conditions, and on the righthand
26752appear in later conditions, and on the righthand side of the rule. 26755side of the rule.
26753In fact, @expr{v} may be any pattern in which case the result of 26756In fact, @expr{v} may be any pattern in which case the result of
26754evaluating @expr{x} is matched to that pattern, binding any 26757evaluating @expr{x} is matched to that pattern, binding any
26755meta-variables that appear in that pattern. Note that @code{let} 26758meta-variables that appear in that pattern. Note that @code{let}
@@ -27499,17 +27502,19 @@ with @code{apply} as the top-level pattern must be tested against
27499@cindex @code{AlgSimpRules} variable 27502@cindex @code{AlgSimpRules} variable
27500@vindex AlgSimpRules 27503@vindex AlgSimpRules
27501Suppose you want @samp{sin(a + b)} to be expanded out not all the time, 27504Suppose you want @samp{sin(a + b)} to be expanded out not all the time,
27502but only when @kbd{a s} is used to simplify the formula. The variable 27505but only when algebraic simplifications are used to simplify the
27503@code{AlgSimpRules} holds rules for this purpose. The @kbd{a s} command 27506formula. The variable @code{AlgSimpRules} holds rules for this purpose.
27504will apply @code{EvalRules} and @code{AlgSimpRules} to the formula, as 27507The @kbd{a s} command will apply @code{EvalRules} and
27505well as all of its built-in simplifications. 27508@code{AlgSimpRules} to the formula, as well as all of its built-in
27509simplifications.
27506 27510
27507Most of the special limitations for @code{EvalRules} don't apply to 27511Most of the special limitations for @code{EvalRules} don't apply to
27508@code{AlgSimpRules}. Calc simply does an @kbd{a r AlgSimpRules} 27512@code{AlgSimpRules}. Calc simply does an @kbd{a r AlgSimpRules}
27509command with an infinite repeat count as the first step of @kbd{a s}. 27513command with an infinite repeat count as the first step of algebraic
27510It then applies its own built-in simplifications throughout the 27514simplifications. It then applies its own built-in simplifications
27511formula, and then repeats these two steps (along with applying the 27515throughout the formula, and then repeats these two steps (along with
27512default simplifications) until no further changes are possible. 27516applying the default simplifications) until no further changes are
27517possible.
27513 27518
27514@cindex @code{ExtSimpRules} variable 27519@cindex @code{ExtSimpRules} variable
27515@cindex @code{UnitSimpRules} variable 27520@cindex @code{UnitSimpRules} variable
@@ -27689,7 +27694,7 @@ to hit the apostrophe key every time you wish to enter units.
27689@tindex usimplify 27694@tindex usimplify
27690The @kbd{u s} (@code{calc-simplify-units}) [@code{usimplify}] command 27695The @kbd{u s} (@code{calc-simplify-units}) [@code{usimplify}] command
27691simplifies a units 27696simplifies a units
27692expression. It uses @kbd{a s} (@code{calc-simplify}) to simplify the 27697expression. It uses Calc's algebraic simplifications to simplify the
27693expression first as a regular algebraic formula; it then looks for 27698expression first as a regular algebraic formula; it then looks for
27694features that can be further simplified by converting one object's units 27699features that can be further simplified by converting one object's units
27695to be compatible with another's. For example, @samp{5 m + 23 mm} will 27700to be compatible with another's. For example, @samp{5 m + 23 mm} will
@@ -28773,7 +28778,7 @@ Edit @code{AlgSimpRules}. @xref{Algebraic Simplifications}.
28773@item s D 28778@item s D
28774Edit @code{Decls}. @xref{Declarations}. 28779Edit @code{Decls}. @xref{Declarations}.
28775@item s E 28780@item s E
28776Edit @code{EvalRules}. @xref{Limited Simplifications}. 28781Edit @code{EvalRules}. @xref{Basic Simplifications}.
28777@item s F 28782@item s F
28778Edit @code{FitRules}. @xref{Curve Fitting}. 28783Edit @code{FitRules}. @xref{Curve Fitting}.
28779@item s G 28784@item s G
@@ -28943,19 +28948,16 @@ to select the lefthand side, execute your commands, then type
28943 28948
28944All current modes apply when an @samp{=>} operator is computed, 28949All current modes apply when an @samp{=>} operator is computed,
28945including the current simplification mode. Recall that the 28950including the current simplification mode. Recall that the
28946formula @samp{x + y + x} is not handled by Calc's default 28951formula @samp{arcsin(sin(x))} will not be handled by Calc's algebraic
28947simplifications, but the @kbd{a s} command will reduce it to 28952simplifications, but Calc's unsafe simplifications will reduce it to
28948the simpler form @samp{y + 2 x}. You can also type @kbd{m A} 28953@samp{x}. If you enter @samp{arcsin(sin(x)) =>} normally, the result
28949to enable an Algebraic Simplification mode in which the 28954will be @samp{arcsin(sin(x)) => arcsin(sin(x))}. If you change to
28950equivalent of @kbd{a s} is used on all of Calc's results. 28955Extended Simplification mode, the result will be
28951If you enter @samp{x + y + x =>} normally, the result will 28956@samp{arcsin(sin(x)) => x}. However, just pressing @kbd{a e}
28952be @samp{x + y + x => x + y + x}. If you change to 28957once will have no effect on @samp{arcsin(sin(x)) => arcsin(sin(x))},
28953Algebraic Simplification mode, the result will be
28954@samp{x + y + x => y + 2 x}. However, just pressing @kbd{a s}
28955once will have no effect on @samp{x + y + x => x + y + x},
28956because the righthand side depends only on the lefthand side 28958because the righthand side depends only on the lefthand side
28957and the current mode settings, and the lefthand side is not 28959and the current mode settings, and the lefthand side is not
28958affected by commands like @kbd{a s}. 28960affected by commands like @kbd{a e}.
28959 28961
28960The ``let'' command (@kbd{s l}) has an interesting interaction 28962The ``let'' command (@kbd{s l}) has an interesting interaction
28961with the @samp{=>} operator. The @kbd{s l} command evaluates the 28963with the @samp{=>} operator. The @kbd{s l} command evaluates the
@@ -33756,8 +33758,9 @@ will be the same as @code{lessp}. But whereas @code{lessp} considers
33756other types of objects to be unordered, @code{beforep} puts any two 33758other types of objects to be unordered, @code{beforep} puts any two
33757objects into a definite, consistent order. The @code{beforep} 33759objects into a definite, consistent order. The @code{beforep}
33758function is used by the @kbd{V S} vector-sorting command, and also 33760function is used by the @kbd{V S} vector-sorting command, and also
33759by @kbd{a s} to put the terms of a product into canonical order: 33761by Calc's algebraic simplifications to put the terms of a product into
33760This allows @samp{x y + y x} to be simplified easily to @samp{2 x y}. 33762canonical order: This allows @samp{x y + y x} to be simplified easily to
33763@samp{2 x y}.
33761@end defun 33764@end defun
33762 33765
33763@defun equal x y 33766@defun equal x y
@@ -34426,10 +34429,9 @@ sub-formula that is @code{eq} to @var{old} replaced by @var{new}.
34426@end defun 34429@end defun
34427 34430
34428@defun simplify expr 34431@defun simplify expr
34429Simplify the expression @var{expr} by applying various algebraic rules. 34432Simplify the expression @var{expr} by applying Calc's algebraic
34430This is what the @w{@kbd{a s}} (@code{calc-simplify}) command uses. This 34433simplifications. This always returns a copy of the expression; the
34431always returns a copy of the expression; the structure @var{expr} points 34434structure @var{expr} points to remains unchanged in memory.
34432to remains unchanged in memory.
34433 34435
34434More precisely, here is what @code{simplify} does: The expression is 34436More precisely, here is what @code{simplify} does: The expression is
34435first normalized and evaluated by calling @code{normalize}. If any 34437first normalized and evaluated by calling @code{normalize}. If any
@@ -36562,7 +36564,7 @@ A plain @kbd{C-u} prefix means to prompt for the step size.
36562@c 7 36564@c 7
36563@item 36565@item
36564A prefix argument specifies simplification level and depth. 36566A prefix argument specifies simplification level and depth.
365651=Default, 2=like @kbd{a s}, 3=like @kbd{a e}. 365671=Basic simplifications, 2=Algebraic simplifications, 3=Extended simplifications
36566 36568
36567@c 8 36569@c 8
36568@item 36570@item