diff options
| author | Jay Belanger | 2005-01-04 14:46:41 +0000 |
|---|---|---|
| committer | Jay Belanger | 2005-01-04 14:46:41 +0000 |
| commit | 8c399bc15fa89678df1aeaf0be874c4f0a2aae77 (patch) | |
| tree | e5dcba91b88b1ba6d153fd842dacc73bfbc3763a | |
| parent | 01d2bd0234ac15607d4fca9ebbc057757cc0e587 (diff) | |
| download | emacs-8c399bc15fa89678df1aeaf0be874c4f0a2aae77.tar.gz emacs-8c399bc15fa89678df1aeaf0be874c4f0a2aae77.zip | |
(Rewrite rules): Remove an exercise (on 0^0) which is no longer applicable.
| -rw-r--r-- | man/calc.texi | 63 |
1 files changed, 9 insertions, 54 deletions
diff --git a/man/calc.texi b/man/calc.texi index 2036c40d84f..96b8d739385 100644 --- a/man/calc.texi +++ b/man/calc.texi | |||
| @@ -5859,15 +5859,7 @@ is one or more non-sum terms separated by @samp{+} or @samp{-} signs, | |||
| 5859 | so that @expr{2 - 3 (x + y) + x y} is a sum of three terms.) | 5859 | so that @expr{2 - 3 (x + y) + x y} is a sum of three terms.) |
| 5860 | @xref{Rewrites Answer 5, 5}. (@bullet{}) | 5860 | @xref{Rewrites Answer 5, 5}. (@bullet{}) |
| 5861 | 5861 | ||
| 5862 | (@bullet{}) @strong{Exercise 6.} Calc considers the form @expr{0^0} | 5862 | (@bullet{}) @strong{Exercise 6.} A Taylor series for a function is an |
| 5863 | to be ``indeterminate,'' and leaves it unevaluated (assuming Infinite | ||
| 5864 | mode is not enabled). Some people prefer to define @expr{0^0 = 1}, | ||
| 5865 | so that the identity @expr{x^0 = 1} can safely be used for all @expr{x}. | ||
| 5866 | Find a way to make Calc follow this convention. What happens if you | ||
| 5867 | now type @kbd{m i} to turn on Infinite mode? | ||
| 5868 | @xref{Rewrites Answer 6, 6}. (@bullet{}) | ||
| 5869 | |||
| 5870 | (@bullet{}) @strong{Exercise 7.} A Taylor series for a function is an | ||
| 5871 | infinite series that exactly equals the value of that function at | 5863 | infinite series that exactly equals the value of that function at |
| 5872 | values of @expr{x} near zero. | 5864 | values of @expr{x} near zero. |
| 5873 | 5865 | ||
| @@ -5913,9 +5905,12 @@ on the stack, we want to be able to type @kbd{*} and get the result | |||
| 5913 | rearranged or if @kbd{a s} needs to be typed after rewriting. (This one | 5905 | rearranged or if @kbd{a s} needs to be typed after rewriting. (This one |
| 5914 | is rather tricky; the solution at the end of this chapter uses 6 rewrite | 5906 | is rather tricky; the solution at the end of this chapter uses 6 rewrite |
| 5915 | rules. Hint: The @samp{constant(x)} condition tests whether @samp{x} is | 5907 | rules. Hint: The @samp{constant(x)} condition tests whether @samp{x} is |
| 5916 | a number.) @xref{Rewrites Answer 7, 7}. (@bullet{}) | 5908 | a number.) @xref{Rewrites Answer 6, 6}. (@bullet{}) |
| 5909 | |||
| 5910 | Just for kicks, try adding the rule @code{2+3 := 6} to @code{EvalRules}. | ||
| 5911 | What happens? (Be sure to remove this rule afterward, or you might get | ||
| 5912 | a nasty surprise when you use Calc to balance your checkbook!) | ||
| 5917 | 5913 | ||
| 5918 | @c [fix-ref Rewrite Rules] | ||
| 5919 | @xref{Rewrite Rules}, for the whole story on rewrite rules. | 5914 | @xref{Rewrite Rules}, for the whole story on rewrite rules. |
| 5920 | 5915 | ||
| 5921 | @node Programming Tutorial, Answers to Exercises, Algebra Tutorial, Tutorial | 5916 | @node Programming Tutorial, Answers to Exercises, Algebra Tutorial, Tutorial |
| @@ -6643,8 +6638,7 @@ This section includes answers to all the exercises in the Calc tutorial. | |||
| 6643 | * Rewrites Answer 3:: Rewriting opt(a) + opt(b) x | 6638 | * Rewrites Answer 3:: Rewriting opt(a) + opt(b) x |
| 6644 | * Rewrites Answer 4:: Sequence of integers | 6639 | * Rewrites Answer 4:: Sequence of integers |
| 6645 | * Rewrites Answer 5:: Number of terms in sum | 6640 | * Rewrites Answer 5:: Number of terms in sum |
| 6646 | * Rewrites Answer 6:: Defining 0^0 = 1 | 6641 | * Rewrites Answer 6:: Truncated Taylor series |
| 6647 | * Rewrites Answer 7:: Truncated Taylor series | ||
| 6648 | * Programming Answer 1:: Fresnel's C(x) | 6642 | * Programming Answer 1:: Fresnel's C(x) |
| 6649 | * Programming Answer 2:: Negate third stack element | 6643 | * Programming Answer 2:: Negate third stack element |
| 6650 | * Programming Answer 3:: Compute sin(x) / x, etc. | 6644 | * Programming Answer 3:: Compute sin(x) / x, etc. |
| @@ -9094,48 +9088,9 @@ Here we have taken advantage of the fact that earlier rules always | |||
| 9094 | match before later rules; @samp{nterms(x)} will only be tried if we | 9088 | match before later rules; @samp{nterms(x)} will only be tried if we |
| 9095 | already know that @samp{x} is not a sum. | 9089 | already know that @samp{x} is not a sum. |
| 9096 | 9090 | ||
| 9097 | @node Rewrites Answer 6, Rewrites Answer 7, Rewrites Answer 5, Answers to Exercises | 9091 | @node Rewrites Answer 6, Programming Answer 1, Rewrites Answer 5, Answers to Exercises |
| 9098 | @subsection Rewrites Tutorial Exercise 6 | 9092 | @subsection Rewrites Tutorial Exercise 6 |
| 9099 | 9093 | ||
| 9100 | Just put the rule @samp{0^0 := 1} into @code{EvalRules}. For example, | ||
| 9101 | before making this definition we have: | ||
| 9102 | |||
| 9103 | @smallexample | ||
| 9104 | @group | ||
| 9105 | 2: [-2, -1, 0, 1, 2] 1: [1, 1, 0^0, 1, 1] | ||
| 9106 | 1: 0 . | ||
| 9107 | . | ||
| 9108 | |||
| 9109 | v x 5 @key{RET} 3 - 0 V M ^ | ||
| 9110 | @end group | ||
| 9111 | @end smallexample | ||
| 9112 | |||
| 9113 | @noindent | ||
| 9114 | But then: | ||
| 9115 | |||
| 9116 | @smallexample | ||
| 9117 | @group | ||
| 9118 | 2: [-2, -1, 0, 1, 2] 1: [1, 1, 1, 1, 1] | ||
| 9119 | 1: 0 . | ||
| 9120 | . | ||
| 9121 | |||
| 9122 | U ' 0^0:=1 @key{RET} s t EvalRules @key{RET} V M ^ | ||
| 9123 | @end group | ||
| 9124 | @end smallexample | ||
| 9125 | |||
| 9126 | Perhaps more surprisingly, this rule still works with Infinite mode | ||
| 9127 | turned on. Calc tries @code{EvalRules} before any built-in rules for | ||
| 9128 | a function. This allows you to override the default behavior of any | ||
| 9129 | Calc feature: Even though Calc now wants to evaluate @expr{0^0} to | ||
| 9130 | @code{nan}, your rule gets there first and evaluates it to 1 instead. | ||
| 9131 | |||
| 9132 | Just for kicks, try adding the rule @code{2+3 := 6} to @code{EvalRules}. | ||
| 9133 | What happens? (Be sure to remove this rule afterward, or you might get | ||
| 9134 | a nasty surprise when you use Calc to balance your checkbook!) | ||
| 9135 | |||
| 9136 | @node Rewrites Answer 7, Programming Answer 1, Rewrites Answer 6, Answers to Exercises | ||
| 9137 | @subsection Rewrites Tutorial Exercise 7 | ||
| 9138 | |||
| 9139 | @noindent | 9094 | @noindent |
| 9140 | Here is a rule set that will do the job: | 9095 | Here is a rule set that will do the job: |
| 9141 | 9096 | ||
| @@ -9208,7 +9163,7 @@ for a way to do this in Calc, although for something as involved as | |||
| 9208 | this it would probably be better to write the formatting routine | 9163 | this it would probably be better to write the formatting routine |
| 9209 | in Lisp.) | 9164 | in Lisp.) |
| 9210 | 9165 | ||
| 9211 | @node Programming Answer 1, Programming Answer 2, Rewrites Answer 7, Answers to Exercises | 9166 | @node Programming Answer 1, Programming Answer 2, Rewrites Answer 6, Answers to Exercises |
| 9212 | @subsection Programming Tutorial Exercise 1 | 9167 | @subsection Programming Tutorial Exercise 1 |
| 9213 | 9168 | ||
| 9214 | @noindent | 9169 | @noindent |