13 |
@c @infoline foo |
@c @infoline foo |
14 |
@c `foo' will appear only in non-TeX output |
@c `foo' will appear only in non-TeX output |
15 |
|
|
16 |
@c In TeX output, @tmath{expr} will typeset expr in math mode. |
@c @expr{expr} will typeset an expression; |
|
@c In any output, @expr{expr} will typeset an expression; |
|
17 |
@c $x$ in TeX, @samp{x} otherwise. |
@c $x$ in TeX, @samp{x} otherwise. |
18 |
|
|
19 |
@iftex |
@iftex |
20 |
@macro texline{stuff} |
@macro texline{stuff} |
21 |
\stuff\ |
\stuff\ |
22 |
@end macro |
@end macro |
|
@macro tmath{stuff} |
|
|
@tex |
|
|
$\stuff\$ |
|
|
@end tex |
|
|
@end macro |
|
23 |
@alias infoline=comment |
@alias infoline=comment |
|
@c @alias expr=math |
|
24 |
@tex |
@tex |
25 |
\gdef\expr#1{\tex |
\gdef\exprsetup{\tex \let\t\ttfont \turnoffactive} |
26 |
\let\t\ttfont |
\gdef\expr{\exprsetup$\exprfinish} |
27 |
\turnoffactive |
\gdef\exprfinish#1{#1$\endgroup} |
|
$#1$ |
|
|
\endgroup} |
|
28 |
@end tex |
@end tex |
29 |
|
@alias mathit=expr |
30 |
@macro cpi{} |
@macro cpi{} |
31 |
@math{@pi{}} |
@math{@pi{}} |
32 |
@end macro |
@end macro |
41 |
\stuff\ |
\stuff\ |
42 |
@end macro |
@end macro |
43 |
@alias expr=samp |
@alias expr=samp |
44 |
|
@alias mathit=i |
45 |
@macro cpi{} |
@macro cpi{} |
46 |
@expr{pi} |
@expr{pi} |
47 |
@end macro |
@end macro |
617 |
|
|
618 |
@noindent |
@noindent |
619 |
Type @kbd{2 @key{RET} 3 + Q} to compute |
Type @kbd{2 @key{RET} 3 + Q} to compute |
620 |
@texline @tmath{\sqrt{2+3} = 2.2360679775}. |
@texline @math{\sqrt{2+3} = 2.2360679775}. |
621 |
@infoline the square root of 2+3, which is 2.2360679775. |
@infoline the square root of 2+3, which is 2.2360679775. |
622 |
|
|
623 |
@noindent |
@noindent |
624 |
Type @kbd{P 2 ^} to compute |
Type @kbd{P 2 ^} to compute |
625 |
@texline @tmath{\pi^2 = 9.86960440109}. |
@texline @math{\pi^2 = 9.86960440109}. |
626 |
@infoline the value of `pi' squared, 9.86960440109. |
@infoline the value of `pi' squared, 9.86960440109. |
627 |
|
|
628 |
@noindent |
@noindent |
641 |
|
|
642 |
@noindent |
@noindent |
643 |
Type @kbd{' sqrt(2+3) @key{RET}} to compute |
Type @kbd{' sqrt(2+3) @key{RET}} to compute |
644 |
@texline @tmath{\sqrt{2+3}}. |
@texline @math{\sqrt{2+3}}. |
645 |
@infoline the square root of 2+3. |
@infoline the square root of 2+3. |
646 |
|
|
647 |
@noindent |
@noindent |
648 |
Type @kbd{' pi^2 @key{RET}} to enter |
Type @kbd{' pi^2 @key{RET}} to enter |
649 |
@texline @tmath{\pi^2}. |
@texline @math{\pi^2}. |
650 |
@infoline `pi' squared. |
@infoline `pi' squared. |
651 |
To evaluate this symbolic formula as a number, type @kbd{=}. |
To evaluate this symbolic formula as a number, type @kbd{=}. |
652 |
|
|
706 |
|
|
707 |
@noindent |
@noindent |
708 |
Type @kbd{v t} to transpose this |
Type @kbd{v t} to transpose this |
709 |
@texline @tmath{3\times2} |
@texline @math{3\times2} |
710 |
@infoline 3x2 |
@infoline 3x2 |
711 |
matrix into a |
matrix into a |
712 |
@texline @tmath{2\times3} |
@texline @math{2\times3} |
713 |
@infoline 2x3 |
@infoline 2x3 |
714 |
matrix. Type @w{@kbd{v u}} to unpack the rows into two separate |
matrix. Type @w{@kbd{v u}} to unpack the rows into two separate |
715 |
vectors. Now type @w{@kbd{V R + @key{TAB} V R +}} to compute the sums |
vectors. Now type @w{@kbd{V R + @key{TAB} V R +}} to compute the sums |
860 |
|
|
861 |
In this case, the trail shows that four numbers (17.3, 3, 2, and 4) |
In this case, the trail shows that four numbers (17.3, 3, 2, and 4) |
862 |
were first entered into the Calculator, then the 2 and 4 were |
were first entered into the Calculator, then the 2 and 4 were |
863 |
multiplied to get 8, then the 3 and 8 were subtracted to get @i{-5}. |
multiplied to get 8, then the 3 and 8 were subtracted to get @mathit{-5}. |
864 |
(The @samp{>} symbol shows that this was the most recent calculation.) |
(The @samp{>} symbol shows that this was the most recent calculation.) |
865 |
The net result is the two numbers 17.3 and @i{-5} sitting on the stack. |
The net result is the two numbers 17.3 and @mathit{-5} sitting on the stack. |
866 |
|
|
867 |
Most Calculator commands deal explicitly with the stack only, but |
Most Calculator commands deal explicitly with the stack only, but |
868 |
there is a set of commands that allow you to search back through |
there is a set of commands that allow you to search back through |
923 |
|
|
924 |
Quick Mode is very simple: It prompts you to type any formula in |
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 |
standard algebraic notation (like @samp{4 - 2/3}) and then displays |
926 |
the result at the bottom of the Emacs screen (@i{3.33333333333} |
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 |
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} |
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 |
again to do another quick calculation. The result of the calculation |
1336 |
Calc was originally started as a two-week project to occupy a lull |
Calc was originally started as a two-week project to occupy a lull |
1337 |
in the author's schedule. Basically, a friend asked if I remembered |
in the author's schedule. Basically, a friend asked if I remembered |
1338 |
the value of |
the value of |
1339 |
@texline @tmath{2^{32}}. |
@texline @math{2^{32}}. |
1340 |
@infoline @expr{2^32}. |
@infoline @expr{2^32}. |
1341 |
I didn't offhand, but I said, ``that's easy, just call up an |
I didn't offhand, but I said, ``that's easy, just call up an |
1342 |
@code{xcalc}.'' @code{Xcalc} duly reported that the answer to our |
@code{xcalc}.'' @code{Xcalc} duly reported that the answer to our |
1658 |
if you're right. @xref{RPN Answer 1, 1}. (@bullet{}) |
if you're right. @xref{RPN Answer 1, 1}. (@bullet{}) |
1659 |
|
|
1660 |
(@bullet{}) @strong{Exercise 2.} Compute |
(@bullet{}) @strong{Exercise 2.} Compute |
1661 |
@texline @tmath{(2\times4) + (7\times9.4) + {5\over4}} |
@texline @math{(2\times4) + (7\times9.4) + {5\over4}} |
1662 |
@infoline @expr{2*4 + 7*9.5 + 5/4} |
@infoline @expr{2*4 + 7*9.5 + 5/4} |
1663 |
using the stack. @xref{RPN Answer 2, 2}. (@bullet{}) |
using the stack. @xref{RPN Answer 2, 2}. (@bullet{}) |
1664 |
|
|
1993 |
@end tex |
@end tex |
1994 |
|
|
1995 |
@noindent |
@noindent |
1996 |
The result of this expression will be the number @i{-6.99999826533}. |
The result of this expression will be the number @mathit{-6.99999826533}. |
1997 |
|
|
1998 |
Calc's order of evaluation is the same as for most computer languages, |
Calc's order of evaluation is the same as for most computer languages, |
1999 |
except that @samp{*} binds more strongly than @samp{/}, as the above |
except that @samp{*} binds more strongly than @samp{/}, as the above |
2002 |
|
|
2003 |
Operators at the same level are evaluated from left to right, except |
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 |
that @samp{^} is evaluated from right to left. Thus, @samp{2-3-4} is |
2005 |
equivalent to @samp{(2-3)-4} or @i{-5}, whereas @samp{2^3^4} is equivalent |
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!). |
to @samp{2^(3^4)} (a very large integer; try it!). |
2007 |
|
|
2008 |
If you tire of typing the apostrophe all the time, there is an |
If you tire of typing the apostrophe all the time, there is an |
2072 |
of algebraic entries, using the @kbd{$} sign to tie them together. |
of algebraic entries, using the @kbd{$} sign to tie them together. |
2073 |
In an algebraic formula, @kbd{$} represents the number on the top |
In an algebraic formula, @kbd{$} represents the number on the top |
2074 |
of the stack. Here, we perform the calculation |
of the stack. Here, we perform the calculation |
2075 |
@texline @tmath{\sqrt{2\times4+1}}, |
@texline @math{\sqrt{2\times4+1}}, |
2076 |
@infoline @expr{sqrt(2*4+1)}, |
@infoline @expr{sqrt(2*4+1)}, |
2077 |
which on a traditional calculator would be done by pressing |
which on a traditional calculator would be done by pressing |
2078 |
@kbd{2 * 4 + 1 =} and then the square-root key. |
@kbd{2 * 4 + 1 =} and then the square-root key. |
2734 |
@noindent |
@noindent |
2735 |
The shift-@kbd{S} command computes the sine of an angle. The sine |
The shift-@kbd{S} command computes the sine of an angle. The sine |
2736 |
of 45 degrees is |
of 45 degrees is |
2737 |
@texline @tmath{\sqrt{2}/2}; |
@texline @math{\sqrt{2}/2}; |
2738 |
@infoline @expr{sqrt(2)/2}; |
@infoline @expr{sqrt(2)/2}; |
2739 |
squaring this yields @expr{2/4 = 0.5}. However, there has been a slight |
squaring this yields @expr{2/4 = 0.5}. However, there has been a slight |
2740 |
roundoff error because the representation of |
roundoff error because the representation of |
2741 |
@texline @tmath{\sqrt{2}/2} |
@texline @math{\sqrt{2}/2} |
2742 |
@infoline @expr{sqrt(2)/2} |
@infoline @expr{sqrt(2)/2} |
2743 |
wasn't exact. The @kbd{c 1} command is a handy way to clean up numbers |
wasn't exact. The @kbd{c 1} command is a handy way to clean up numbers |
2744 |
in this case; it temporarily reduces the precision by one digit while it |
in this case; it temporarily reduces the precision by one digit while it |
2779 |
|
|
2780 |
@noindent |
@noindent |
2781 |
Here we compute the Inverse Sine of |
Here we compute the Inverse Sine of |
2782 |
@texline @tmath{\sqrt{0.5}}, |
@texline @math{\sqrt{0.5}}, |
2783 |
@infoline @expr{sqrt(0.5)}, |
@infoline @expr{sqrt(0.5)}, |
2784 |
first in radians, then in degrees. |
first in radians, then in degrees. |
2785 |
|
|
2967 |
|
|
2968 |
Let's compute the sine and cosine of an angle, and verify the |
Let's compute the sine and cosine of an angle, and verify the |
2969 |
identity |
identity |
2970 |
@texline @tmath{\sin^2x + \cos^2x = 1}. |
@texline @math{\sin^2x + \cos^2x = 1}. |
2971 |
@infoline @expr{sin(x)^2 + cos(x)^2 = 1}. |
@infoline @expr{sin(x)^2 + cos(x)^2 = 1}. |
2972 |
We'll arbitrarily pick @i{-64} degrees as a good value for @expr{x}. |
We'll arbitrarily pick @mathit{-64} degrees as a good value for @expr{x}. |
2973 |
With the angular mode set to degrees (type @w{@kbd{m d}}), do: |
With the angular mode set to degrees (type @w{@kbd{m d}}), do: |
2974 |
|
|
2975 |
@smallexample |
@smallexample |
2990 |
of squares, command. |
of squares, command. |
2991 |
|
|
2992 |
Another identity is |
Another identity is |
2993 |
@texline @tmath{\displaystyle\tan x = {\sin x \over \cos x}}. |
@texline @math{\displaystyle\tan x = {\sin x \over \cos x}}. |
2994 |
@infoline @expr{tan(x) = sin(x) / cos(x)}. |
@infoline @expr{tan(x) = sin(x) / cos(x)}. |
2995 |
@smallexample |
@smallexample |
2996 |
@group |
@group |
3005 |
|
|
3006 |
A physical interpretation of this calculation is that if you move |
A physical interpretation of this calculation is that if you move |
3007 |
@expr{0.89879} units downward and @expr{0.43837} units to the right, |
@expr{0.89879} units downward and @expr{0.43837} units to the right, |
3008 |
your direction of motion is @i{-64} degrees from horizontal. Suppose |
your direction of motion is @mathit{-64} degrees from horizontal. Suppose |
3009 |
we move in the opposite direction, up and to the left: |
we move in the opposite direction, up and to the left: |
3010 |
|
|
3011 |
@smallexample |
@smallexample |
3053 |
|
|
3054 |
A similar identity is supposed to hold for hyperbolic sines and cosines, |
A similar identity is supposed to hold for hyperbolic sines and cosines, |
3055 |
except that it is the @emph{difference} |
except that it is the @emph{difference} |
3056 |
@texline @tmath{\cosh^2x - \sinh^2x} |
@texline @math{\cosh^2x - \sinh^2x} |
3057 |
@infoline @expr{cosh(x)^2 - sinh(x)^2} |
@infoline @expr{cosh(x)^2 - sinh(x)^2} |
3058 |
that always equals one. Let's try to verify this identity. |
that always equals one. Let's try to verify this identity. |
3059 |
|
|
3160 |
|
|
3161 |
If you take the factorial of a non-integer, Calc uses a generalized |
If you take the factorial of a non-integer, Calc uses a generalized |
3162 |
factorial function defined in terms of Euler's Gamma function |
factorial function defined in terms of Euler's Gamma function |
3163 |
@texline @tmath{\Gamma(n)} |
@texline @math{\Gamma(n)} |
3164 |
@infoline @expr{gamma(n)} |
@infoline @expr{gamma(n)} |
3165 |
(which is itself available as the @kbd{f g} command). |
(which is itself available as the @kbd{f g} command). |
3166 |
|
|
3177 |
|
|
3178 |
@noindent |
@noindent |
3179 |
Here we verify the identity |
Here we verify the identity |
3180 |
@texline @tmath{n! = \Gamma(n+1)}. |
@texline @math{n! = \Gamma(n+1)}. |
3181 |
@infoline @expr{@var{n}!@: = gamma(@var{n}+1)}. |
@infoline @expr{@var{n}!@: = gamma(@var{n}+1)}. |
3182 |
|
|
3183 |
The binomial coefficient @var{n}-choose-@var{m} |
The binomial coefficient @var{n}-choose-@var{m} |
3184 |
@texline or @tmath{\displaystyle {n \choose m}} |
@texline or @math{\displaystyle {n \choose m}} |
3185 |
is defined by |
is defined by |
3186 |
@texline @tmath{\displaystyle {n! \over m! \, (n-m)!}} |
@texline @math{\displaystyle {n! \over m! \, (n-m)!}} |
3187 |
@infoline @expr{n!@: / m!@: (n-m)!} |
@infoline @expr{n!@: / m!@: (n-m)!} |
3188 |
for all reals @expr{n} and @expr{m}. The intermediate results in this |
for all reals @expr{n} and @expr{m}. The intermediate results in this |
3189 |
formula can become quite large even if the final result is small; the |
formula can become quite large even if the final result is small; the |
3468 |
|
|
3469 |
(@bullet{}) @strong{Exercise 1.} Use @samp{*} to sum along the rows |
(@bullet{}) @strong{Exercise 1.} Use @samp{*} to sum along the rows |
3470 |
of the above |
of the above |
3471 |
@texline @tmath{2\times3} |
@texline @math{2\times3} |
3472 |
@infoline 2x3 |
@infoline 2x3 |
3473 |
matrix to get @expr{[6, 15]}. Now use @samp{*} to sum along the columns |
matrix to get @expr{[6, 15]}. Now use @samp{*} to sum along the columns |
3474 |
to get @expr{[5, 7, 9]}. |
to get @expr{[5, 7, 9]}. |
3619 |
come out right, and the answer would be incorrect. If you |
come out right, and the answer would be incorrect. If you |
3620 |
don't feel safe letting Calc take either interpretation of your |
don't feel safe letting Calc take either interpretation of your |
3621 |
vectors, use explicit |
vectors, use explicit |
3622 |
@texline @tmath{N\times1} |
@texline @math{N\times1} |
3623 |
@infoline Nx1 |
@infoline Nx1 |
3624 |
or |
or |
3625 |
@texline @tmath{1\times N} |
@texline @math{1\times N} |
3626 |
@infoline 1xN |
@infoline 1xN |
3627 |
matrices instead. In this case, you would enter the original column |
matrices instead. In this case, you would enter the original column |
3628 |
vector as @samp{[[6], [2], [3]]} or @samp{[6; 2; 3]}. |
vector as @samp{[[6], [2], [3]]} or @samp{[6; 2; 3]}. |
3671 |
$A^T A \, X = A^T B$, where $A^T$ is the transpose \samp{trn(A)}. |
$A^T A \, X = A^T B$, where $A^T$ is the transpose \samp{trn(A)}. |
3672 |
@end tex |
@end tex |
3673 |
Now |
Now |
3674 |
@texline @tmath{A^T A} |
@texline @math{A^T A} |
3675 |
@infoline @expr{trn(A)*A} |
@infoline @expr{trn(A)*A} |
3676 |
is a square matrix so a solution is possible. It turns out that the |
is a square matrix so a solution is possible. It turns out that the |
3677 |
@expr{X} vector you compute in this way will be a ``least-squares'' |
@expr{X} vector you compute in this way will be a ``least-squares'' |
3767 |
|
|
3768 |
(@bullet{}) @strong{Exercise 1.} Compute a vector of powers of two |
(@bullet{}) @strong{Exercise 1.} Compute a vector of powers of two |
3769 |
from |
from |
3770 |
@texline @tmath{2^{-4}} |
@texline @math{2^{-4}} |
3771 |
@infoline @expr{2^-4} |
@infoline @expr{2^-4} |
3772 |
to @expr{2^4}. @xref{List Answer 1, 1}. (@bullet{}) |
to @expr{2^4}. @xref{List Answer 1, 1}. (@bullet{}) |
3773 |
|
|
3971 |
|
|
3972 |
@noindent |
@noindent |
3973 |
where |
where |
3974 |
@texline @tmath{\sum x} |
@texline @math{\sum x} |
3975 |
@infoline @expr{sum(x)} |
@infoline @expr{sum(x)} |
3976 |
represents the sum of all the values of @expr{x}. While there is an |
represents the sum of all the values of @expr{x}. While there is an |
3977 |
actual @code{sum} function in Calc, it's easier to sum a vector using a |
actual @code{sum} function in Calc, it's easier to sum a vector using a |
4076 |
@end smallexample |
@end smallexample |
4077 |
|
|
4078 |
Let's ``plot'' this straight line approximation, |
Let's ``plot'' this straight line approximation, |
4079 |
@texline @tmath{y \approx m x + b}, |
@texline @math{y \approx m x + b}, |
4080 |
@infoline @expr{m x + b}, |
@infoline @expr{m x + b}, |
4081 |
and compare it with the original data. |
and compare it with the original data. |
4082 |
|
|
4329 |
@cindex Maximizing a function over a list of values |
@cindex Maximizing a function over a list of values |
4330 |
@c [fix-ref Numerical Solutions] |
@c [fix-ref Numerical Solutions] |
4331 |
(@bullet{}) @strong{Exercise 8.} Compute a list of values of Bessel's |
(@bullet{}) @strong{Exercise 8.} Compute a list of values of Bessel's |
4332 |
@texline @tmath{J_1(x)} |
@texline @math{J_1(x)} |
4333 |
@infoline @expr{J1} |
@infoline @expr{J1} |
4334 |
function @samp{besJ(1,x)} for @expr{x} from 0 to 5 in steps of 0.25. |
function @samp{besJ(1,x)} for @expr{x} from 0 to 5 in steps of 0.25. |
4335 |
Find the value of @expr{x} (from among the above set of values) for |
Find the value of @expr{x} (from among the above set of values) for |
4341 |
|
|
4342 |
@cindex Digits, vectors of |
@cindex Digits, vectors of |
4343 |
(@bullet{}) @strong{Exercise 9.} You are given an integer in the range |
(@bullet{}) @strong{Exercise 9.} You are given an integer in the range |
4344 |
@texline @tmath{0 \le N < 10^m} |
@texline @math{0 \le N < 10^m} |
4345 |
@infoline @expr{0 <= N < 10^m} |
@infoline @expr{0 <= N < 10^m} |
4346 |
for @expr{m=12} (i.e., an integer of less than |
for @expr{m=12} (i.e., an integer of less than |
4347 |
twelve digits). Convert this integer into a vector of @expr{m} |
twelve digits). Convert this integer into a vector of @expr{m} |
4357 |
|
|
4358 |
(@bullet{}) @strong{Exercise 11.} The area of a circle of radius one |
(@bullet{}) @strong{Exercise 11.} The area of a circle of radius one |
4359 |
is @cpi{}. The area of the |
is @cpi{}. The area of the |
4360 |
@texline @tmath{2\times2} |
@texline @math{2\times2} |
4361 |
@infoline 2x2 |
@infoline 2x2 |
4362 |
square that encloses that circle is 4. So if we throw @var{n} darts at |
square that encloses that circle is 4. So if we throw @var{n} darts at |
4363 |
random points in the square, about @cpiover{4} of them will land inside |
random points in the square, about @cpiover{4} of them will land inside |
4364 |
the circle. This gives us an entertaining way to estimate the value of |
the circle. This gives us an entertaining way to estimate the value of |
4365 |
@cpi{}. The @w{@kbd{k r}} |
@cpi{}. The @w{@kbd{k r}} |
4366 |
command picks a random number between zero and the value on the stack. |
command picks a random number between zero and the value on the stack. |
4367 |
We could get a random floating-point number between @i{-1} and 1 by typing |
We could get a random floating-point number between @mathit{-1} and 1 by typing |
4368 |
@w{@kbd{2.0 k r 1 -}}. Build a vector of 100 random @expr{(x,y)} points in |
@w{@kbd{2.0 k r 1 -}}. Build a vector of 100 random @expr{(x,y)} points in |
4369 |
this square, then use vector mapping and reduction to count how many |
this square, then use vector mapping and reduction to count how many |
4370 |
points lie inside the unit circle. Hint: Use the @kbd{v b} command. |
points lie inside the unit circle. Hint: Use the @kbd{v b} command. |
4376 |
of vertical lines with a spacing of one inch. Toss a one-inch matchstick |
of vertical lines with a spacing of one inch. Toss a one-inch matchstick |
4377 |
onto the field. The probability that the matchstick will land crossing |
onto the field. The probability that the matchstick will land crossing |
4378 |
a line turns out to be |
a line turns out to be |
4379 |
@texline @tmath{2/\pi}. |
@texline @math{2/\pi}. |
4380 |
@infoline @expr{2/pi}. |
@infoline @expr{2/pi}. |
4381 |
Toss 100 matchsticks to estimate @cpi{}. (If you want still more fun, |
Toss 100 matchsticks to estimate @cpi{}. (If you want still more fun, |
4382 |
the probability that the GCD (@w{@kbd{k g}}) of two large integers is |
the probability that the GCD (@w{@kbd{k g}}) of two large integers is |
4383 |
one turns out to be |
one turns out to be |
4384 |
@texline @tmath{6/\pi^2}. |
@texline @math{6/\pi^2}. |
4385 |
@infoline @expr{6/pi^2}. |
@infoline @expr{6/pi^2}. |
4386 |
That provides yet another way to estimate @cpi{}.) |
That provides yet another way to estimate @cpi{}.) |
4387 |
@xref{List Answer 12, 12}. (@bullet{}) |
@xref{List Answer 12, 12}. (@bullet{}) |
4411 |
function you give to the starting value 0, 1, 2, up to @var{n} times |
function you give to the starting value 0, 1, 2, up to @var{n} times |
4412 |
and returns a vector of the results. Use this command to create a |
and returns a vector of the results. Use this command to create a |
4413 |
``random walk'' of 50 steps. Start with the two-dimensional point |
``random walk'' of 50 steps. Start with the two-dimensional point |
4414 |
@expr{(0,0)}; then take one step a random distance between @i{-1} and 1 |
@expr{(0,0)}; then take one step a random distance between @mathit{-1} and 1 |
4415 |
in both @expr{x} and @expr{y}; then take another step, and so on. Use the |
in both @expr{x} and @expr{y}; then take another step, and so on. Use the |
4416 |
@kbd{g f} command to display this random walk. Now modify your random |
@kbd{g f} command to display this random walk. Now modify your random |
4417 |
walk to walk a unit distance, but in a random direction, at each step. |
walk to walk a unit distance, but in a random direction, at each step. |
4490 |
@end smallexample |
@end smallexample |
4491 |
|
|
4492 |
@noindent |
@noindent |
4493 |
The square root of @i{-9} is by default rendered in rectangular form |
The square root of @mathit{-9} is by default rendered in rectangular form |
4494 |
(@w{@expr{0 + 3i}}), but we can convert it to polar form (3 with a |
(@w{@expr{0 + 3i}}), but we can convert it to polar form (3 with a |
4495 |
phase angle of 90 degrees). All the usual arithmetic and scientific |
phase angle of 90 degrees). All the usual arithmetic and scientific |
4496 |
operations are defined on both types of complex numbers. |
operations are defined on both types of complex numbers. |
4515 |
|
|
4516 |
@noindent |
@noindent |
4517 |
Since infinity is infinitely large, multiplying it by any finite |
Since infinity is infinitely large, multiplying it by any finite |
4518 |
number (like @i{-17}) has no effect, except that since @i{-17} |
number (like @mathit{-17}) has no effect, except that since @mathit{-17} |
4519 |
is negative, it changes a plus infinity to a minus infinity. |
is negative, it changes a plus infinity to a minus infinity. |
4520 |
(``A huge positive number, multiplied by @i{-17}, yields a huge |
(``A huge positive number, multiplied by @mathit{-17}, yields a huge |
4521 |
negative number.'') Adding any finite number to infinity also |
negative number.'') Adding any finite number to infinity also |
4522 |
leaves it unchanged. Taking an absolute value gives us plus |
leaves it unchanged. Taking an absolute value gives us plus |
4523 |
infinity again. Finally, we add this plus infinity to the minus |
infinity again. Finally, we add this plus infinity to the minus |
4524 |
infinity we had earlier. If you work it out, you might expect |
infinity we had earlier. If you work it out, you might expect |
4525 |
the answer to be @i{-72} for this. But the 72 has been completely |
the answer to be @mathit{-72} for this. But the 72 has been completely |
4526 |
lost next to the infinities; by the time we compute @w{@samp{inf - inf}} |
lost next to the infinities; by the time we compute @w{@samp{inf - inf}} |
4527 |
the finite difference between them, if any, is undetectable. |
the finite difference between them, if any, is undetectable. |
4528 |
So we say the result is @dfn{indeterminate}, which Calc writes |
So we say the result is @dfn{indeterminate}, which Calc writes |
4679 |
|
|
4680 |
@cindex Torus, volume of |
@cindex Torus, volume of |
4681 |
(@bullet{}) @strong{Exercise 7.} The volume of a torus (a donut shape) is |
(@bullet{}) @strong{Exercise 7.} The volume of a torus (a donut shape) is |
4682 |
@texline @tmath{2 \pi^2 R r^2} |
@texline @math{2 \pi^2 R r^2} |
4683 |
@infoline @w{@expr{2 pi^2 R r^2}} |
@infoline @w{@expr{2 pi^2 R r^2}} |
4684 |
where @expr{R} is the radius of the circle that |
where @expr{R} is the radius of the circle that |
4685 |
defines the center of the tube and @expr{r} is the radius of the tube |
defines the center of the tube and @expr{r} is the radius of the tube |
4779 |
@cindex Fermat, primality test of |
@cindex Fermat, primality test of |
4780 |
(@bullet{}) @strong{Exercise 10.} A theorem of Pierre de Fermat |
(@bullet{}) @strong{Exercise 10.} A theorem of Pierre de Fermat |
4781 |
says that |
says that |
4782 |
@texline @w{@tmath{x^{n-1} \bmod n = 1}} |
@texline @w{@math{x^{n-1} \bmod n = 1}} |
4783 |
@infoline @expr{x^(n-1) mod n = 1} |
@infoline @expr{x^(n-1) mod n = 1} |
4784 |
if @expr{n} is a prime number and @expr{x} is an integer less than |
if @expr{n} is a prime number and @expr{x} is an integer less than |
4785 |
@expr{n}. If @expr{n} is @emph{not} a prime number, this will |
@expr{n}. If @expr{n} is @emph{not} a prime number, this will |
4807 |
|
|
4808 |
(@bullet{}) @strong{Exercise 11.} A rule of thumb is that one year |
(@bullet{}) @strong{Exercise 11.} A rule of thumb is that one year |
4809 |
is about |
is about |
4810 |
@texline @tmath{\pi \times 10^7} |
@texline @math{\pi \times 10^7} |
4811 |
@infoline @w{@expr{pi * 10^7}} |
@infoline @w{@expr{pi * 10^7}} |
4812 |
seconds. What time will it be that many seconds from right now? |
seconds. What time will it be that many seconds from right now? |
4813 |
@xref{Types Answer 11, 11}. (@bullet{}) |
@xref{Types Answer 11, 11}. (@bullet{}) |
5114 |
|
|
5115 |
@noindent |
@noindent |
5116 |
Calc has invented the variable @samp{s1} to represent an unknown sign; |
Calc has invented the variable @samp{s1} to represent an unknown sign; |
5117 |
it is supposed to be either @i{+1} or @i{-1}. Here we have used |
it is supposed to be either @mathit{+1} or @mathit{-1}. Here we have used |
5118 |
the ``let'' command to evaluate the expression when the sign is negative. |
the ``let'' command to evaluate the expression when the sign is negative. |
5119 |
If we plugged this into our second derivative we would get the same, |
If we plugged this into our second derivative we would get the same, |
5120 |
negative, answer, so @expr{x = -1.19023} is also a maximum. |
negative, answer, so @expr{x = -1.19023} is also a maximum. |
5284 |
|
|
5285 |
(@bullet{}) @strong{Exercise 3.} Find the integral from 1 to @expr{y} |
(@bullet{}) @strong{Exercise 3.} Find the integral from 1 to @expr{y} |
5286 |
of |
of |
5287 |
@texline @tmath{x \sin \pi x} |
@texline @math{x \sin \pi x} |
5288 |
@infoline @w{@expr{x sin(pi x)}} |
@infoline @w{@expr{x sin(pi x)}} |
5289 |
(where the sine is calculated in radians). Find the values of the |
(where the sine is calculated in radians). Find the values of the |
5290 |
integral for integers @expr{y} from 1 to 5. @xref{Algebra Answer 3, |
integral for integers @expr{y} from 1 to 5. @xref{Algebra Answer 3, |
5293 |
Calc's integrator can do many simple integrals symbolically, but many |
Calc's integrator can do many simple integrals symbolically, but many |
5294 |
others are beyond its capabilities. Suppose we wish to find the area |
others are beyond its capabilities. Suppose we wish to find the area |
5295 |
under the curve |
under the curve |
5296 |
@texline @tmath{\sin x \ln x} |
@texline @math{\sin x \ln x} |
5297 |
@infoline @expr{sin(x) ln(x)} |
@infoline @expr{sin(x) ln(x)} |
5298 |
over the same range of @expr{x}. If you entered this formula and typed |
over the same range of @expr{x}. If you entered this formula and typed |
5299 |
@kbd{a i x @key{RET}} (don't bother to try this), Calc would work for a |
@kbd{a i x @key{RET}} (don't bother to try this), Calc would work for a |
5435 |
@end tex |
@end tex |
5436 |
|
|
5437 |
Compute the integral from 1 to 2 of |
Compute the integral from 1 to 2 of |
5438 |
@texline @tmath{\sin x \ln x} |
@texline @math{\sin x \ln x} |
5439 |
@infoline @expr{sin(x) ln(x)} |
@infoline @expr{sin(x) ln(x)} |
5440 |
using Simpson's rule with 10 slices. |
using Simpson's rule with 10 slices. |
5441 |
@xref{Algebra Answer 4, 4}. (@bullet{}) |
@xref{Algebra Answer 4, 4}. (@bullet{}) |
5981 |
@end ignore |
@end ignore |
5982 |
@tindex Si |
@tindex Si |
5983 |
(@bullet{}) @strong{Exercise 1.} The ``sine integral'' function |
(@bullet{}) @strong{Exercise 1.} The ``sine integral'' function |
5984 |
@texline @tmath{{\rm Si}(x)} |
@texline @math{{\rm Si}(x)} |
5985 |
@infoline @expr{Si(x)} |
@infoline @expr{Si(x)} |
5986 |
is defined as the integral of @samp{sin(t)/t} for |
is defined as the integral of @samp{sin(t)/t} for |
5987 |
@expr{t = 0} to @expr{x} in radians. (It was invented because this |
@expr{t = 0} to @expr{x} in radians. (It was invented because this |
6059 |
@enumerate |
@enumerate |
6060 |
@item |
@item |
6061 |
Compute |
Compute |
6062 |
@texline @tmath{\displaystyle{\sin x \over x}}, |
@texline @math{\displaystyle{\sin x \over x}}, |
6063 |
@infoline @expr{sin(x) / x}, |
@infoline @expr{sin(x) / x}, |
6064 |
where @expr{x} is the number on the top of the stack. |
where @expr{x} is the number on the top of the stack. |
6065 |
|
|
6125 |
@cindex Phi, golden ratio |
@cindex Phi, golden ratio |
6126 |
A fascinating property of the Fibonacci numbers is that the @expr{n}th |
A fascinating property of the Fibonacci numbers is that the @expr{n}th |
6127 |
Fibonacci number can be found directly by computing |
Fibonacci number can be found directly by computing |
6128 |
@texline @tmath{\phi^n / \sqrt{5}} |
@texline @math{\phi^n / \sqrt{5}} |
6129 |
@infoline @expr{phi^n / sqrt(5)} |
@infoline @expr{phi^n / sqrt(5)} |
6130 |
and then rounding to the nearest integer, where |
and then rounding to the nearest integer, where |
6131 |
@texline @tmath{\phi} (``phi''), |
@texline @math{\phi} (``phi''), |
6132 |
@infoline @expr{phi}, |
@infoline @expr{phi}, |
6133 |
the ``golden ratio,'' is |
the ``golden ratio,'' is |
6134 |
@texline @tmath{(1 + \sqrt{5}) / 2}. |
@texline @math{(1 + \sqrt{5}) / 2}. |
6135 |
@infoline @expr{(1 + sqrt(5)) / 2}. |
@infoline @expr{(1 + sqrt(5)) / 2}. |
6136 |
(For convenience, this constant is available from the @code{phi} |
(For convenience, this constant is available from the @code{phi} |
6137 |
variable, or the @kbd{I H P} command.) |
variable, or the @kbd{I H P} command.) |
6148 |
@cindex Continued fractions |
@cindex Continued fractions |
6149 |
(@bullet{}) @strong{Exercise 5.} The @dfn{continued fraction} |
(@bullet{}) @strong{Exercise 5.} The @dfn{continued fraction} |
6150 |
representation of |
representation of |
6151 |
@texline @tmath{\phi} |
@texline @math{\phi} |
6152 |
@infoline @expr{phi} |
@infoline @expr{phi} |
6153 |
is |
is |
6154 |
@texline @tmath{1 + 1/(1 + 1/(1 + 1/( \ldots )))}. |
@texline @math{1 + 1/(1 + 1/(1 + 1/( \ldots )))}. |
6155 |
@infoline @expr{1 + 1/(1 + 1/(1 + 1/( ...@: )))}. |
@infoline @expr{1 + 1/(1 + 1/(1 + 1/( ...@: )))}. |
6156 |
We can compute an approximate value by carrying this however far |
We can compute an approximate value by carrying this however far |
6157 |
and then replacing the innermost |
and then replacing the innermost |
6158 |
@texline @tmath{1/( \ldots )} |
@texline @math{1/( \ldots )} |
6159 |
@infoline @expr{1/( ...@: )} |
@infoline @expr{1/( ...@: )} |
6160 |
by 1. Approximate |
by 1. Approximate |
6161 |
@texline @tmath{\phi} |
@texline @math{\phi} |
6162 |
@infoline @expr{phi} |
@infoline @expr{phi} |
6163 |
using a twenty-term continued fraction. |
using a twenty-term continued fraction. |
6164 |
@xref{Programming Answer 5, 5}. (@bullet{}) |
@xref{Programming Answer 5, 5}. (@bullet{}) |
6258 |
property that all of the odd Bernoulli numbers are zero, and the |
property that all of the odd Bernoulli numbers are zero, and the |
6259 |
even ones, while difficult to compute, can be roughly approximated |
even ones, while difficult to compute, can be roughly approximated |
6260 |
by the formula |
by the formula |
6261 |
@texline @tmath{\displaystyle{2 n! \over (2 \pi)^n}}. |
@texline @math{\displaystyle{2 n! \over (2 \pi)^n}}. |
6262 |
@infoline @expr{2 n!@: / (2 pi)^n}. |
@infoline @expr{2 n!@: / (2 pi)^n}. |
6263 |
Let's write a keyboard macro to compute (approximate) Bernoulli numbers. |
Let's write a keyboard macro to compute (approximate) Bernoulli numbers. |
6264 |
(Calc has a command, @kbd{k b}, to compute exact Bernoulli numbers, but |
(Calc has a command, @kbd{k b}, to compute exact Bernoulli numbers, but |
6432 |
@noindent |
@noindent |
6433 |
where @expr{f'(x)} is the derivative of @expr{f}. The @expr{x} |
where @expr{f'(x)} is the derivative of @expr{f}. The @expr{x} |
6434 |
values will quickly converge to a solution, i.e., eventually |
values will quickly converge to a solution, i.e., eventually |
6435 |
@texline @tmath{x_{\rm new}} |
@texline @math{x_{\rm new}} |
6436 |
@infoline @expr{new_x} |
@infoline @expr{new_x} |
6437 |
and @expr{x} will be equal to within the limits |
and @expr{x} will be equal to within the limits |
6438 |
of the current precision. Write a program which takes a formula |
of the current precision. Write a program which takes a formula |
6439 |
involving the variable @expr{x}, and an initial guess @expr{x_0}, |
involving the variable @expr{x}, and an initial guess @expr{x_0}, |
6440 |
on the stack, and produces a value of @expr{x} for which the formula |
on the stack, and produces a value of @expr{x} for which the formula |
6441 |
is zero. Use it to find a solution of |
is zero. Use it to find a solution of |
6442 |
@texline @tmath{\sin(\cos x) = 0.5} |
@texline @math{\sin(\cos x) = 0.5} |
6443 |
@infoline @expr{sin(cos(x)) = 0.5} |
@infoline @expr{sin(cos(x)) = 0.5} |
6444 |
near @expr{x = 4.5}. (Use angles measured in radians.) Note that |
near @expr{x = 4.5}. (Use angles measured in radians.) Note that |
6445 |
the built-in @w{@kbd{a R}} (@code{calc-find-root}) command uses Newton's |
the built-in @w{@kbd{a R}} (@code{calc-find-root}) command uses Newton's |
6449 |
@cindex Gamma constant, Euler's |
@cindex Gamma constant, Euler's |
6450 |
@cindex Euler's gamma constant |
@cindex Euler's gamma constant |
6451 |
(@bullet{}) @strong{Exercise 9.} The @dfn{digamma} function |
(@bullet{}) @strong{Exercise 9.} The @dfn{digamma} function |
6452 |
@texline @tmath{\psi(z) (``psi'')} |
@texline @math{\psi(z) (``psi'')} |
6453 |
@infoline @expr{psi(z)} |
@infoline @expr{psi(z)} |
6454 |
is defined as the derivative of |
is defined as the derivative of |
6455 |
@texline @tmath{\ln \Gamma(z)}. |
@texline @math{\ln \Gamma(z)}. |
6456 |
@infoline @expr{ln(gamma(z))}. |
@infoline @expr{ln(gamma(z))}. |
6457 |
For large values of @expr{z}, it can be approximated by the infinite sum |
For large values of @expr{z}, it can be approximated by the infinite sum |
6458 |
|
|
6471 |
|
|
6472 |
@noindent |
@noindent |
6473 |
where |
where |
6474 |
@texline @tmath{\sum} |
@texline @math{\sum} |
6475 |
@infoline @expr{sum} |
@infoline @expr{sum} |
6476 |
represents the sum over @expr{n} from 1 to infinity |
represents the sum over @expr{n} from 1 to infinity |
6477 |
(or to some limit high enough to give the desired accuracy), and |
(or to some limit high enough to give the desired accuracy), and |
6479 |
While this sum is not guaranteed to converge, in practice it is safe. |
While this sum is not guaranteed to converge, in practice it is safe. |
6480 |
An interesting mathematical constant is Euler's gamma, which is equal |
An interesting mathematical constant is Euler's gamma, which is equal |
6481 |
to about 0.5772. One way to compute it is by the formula, |
to about 0.5772. One way to compute it is by the formula, |
6482 |
@texline @tmath{\gamma = -\psi(1)}. |
@texline @math{\gamma = -\psi(1)}. |
6483 |
@infoline @expr{gamma = -psi(1)}. |
@infoline @expr{gamma = -psi(1)}. |
6484 |
Unfortunately, 1 isn't a large enough argument |
Unfortunately, 1 isn't a large enough argument |
6485 |
for the above formula to work (5 is a much safer value for @expr{z}). |
for the above formula to work (5 is a much safer value for @expr{z}). |
6486 |
Fortunately, we can compute |
Fortunately, we can compute |
6487 |
@texline @tmath{\psi(1)} |
@texline @math{\psi(1)} |
6488 |
@infoline @expr{psi(1)} |
@infoline @expr{psi(1)} |
6489 |
from |
from |
6490 |
@texline @tmath{\psi(5)} |
@texline @math{\psi(5)} |
6491 |
@infoline @expr{psi(5)} |
@infoline @expr{psi(5)} |
6492 |
using the recurrence |
using the recurrence |
6493 |
@texline @tmath{\psi(z+1) = \psi(z) + {1 \over z}}. |
@texline @math{\psi(z+1) = \psi(z) + {1 \over z}}. |
6494 |
@infoline @expr{psi(z+1) = psi(z) + 1/z}. |
@infoline @expr{psi(z+1) = psi(z) + 1/z}. |
6495 |
Your task: Develop a program to compute |
Your task: Develop a program to compute |
6496 |
@texline @tmath{\psi(z)}; |
@texline @math{\psi(z)}; |
6497 |
@infoline @expr{psi(z)}; |
@infoline @expr{psi(z)}; |
6498 |
it should ``pump up'' @expr{z} |
it should ``pump up'' @expr{z} |
6499 |
if necessary to be greater than 5, then use the above summation |
if necessary to be greater than 5, then use the above summation |
6500 |
formula. Use looping commands to compute the sum. Use your function |
formula. Use looping commands to compute the sum. Use your function |
6501 |
to compute |
to compute |
6502 |
@texline @tmath{\gamma} |
@texline @math{\gamma} |
6503 |
@infoline @expr{gamma} |
@infoline @expr{gamma} |
6504 |
to twelve decimal places. (Calc has a built-in command |
to twelve decimal places. (Calc has a built-in command |
6505 |
for Euler's constant, @kbd{I P}, which you can use to check your answer.) |
for Euler's constant, @kbd{I P}, which you can use to check your answer.) |
6676 |
@kbd{1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -} |
@kbd{1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -} |
6677 |
|
|
6678 |
The result is |
The result is |
6679 |
@texline @tmath{1 - (2 \times (3 + 4)) = -13}. |
@texline @math{1 - (2 \times (3 + 4)) = -13}. |
6680 |
@infoline @expr{1 - (2 * (3 + 4)) = -13}. |
@infoline @expr{1 - (2 * (3 + 4)) = -13}. |
6681 |
|
|
6682 |
@node RPN Answer 2, RPN Answer 3, RPN Answer 1, Answers to Exercises |
@node RPN Answer 2, RPN Answer 3, RPN Answer 1, Answers to Exercises |
6683 |
@subsection RPN Tutorial Exercise 2 |
@subsection RPN Tutorial Exercise 2 |
6684 |
|
|
6685 |
@noindent |
@noindent |
6686 |
@texline @tmath{2\times4 + 7\times9.5 + {5\over4} = 75.75} |
@texline @math{2\times4 + 7\times9.5 + {5\over4} = 75.75} |
6687 |
@infoline @expr{2*4 + 7*9.5 + 5/4 = 75.75} |
@infoline @expr{2*4 + 7*9.5 + 5/4 = 75.75} |
6688 |
|
|
6689 |
After computing the intermediate term |
After computing the intermediate term |
6690 |
@texline @tmath{2\times4 = 8}, |
@texline @math{2\times4 = 8}, |
6691 |
@infoline @expr{2*4 = 8}, |
@infoline @expr{2*4 = 8}, |
6692 |
you can leave that result on the stack while you compute the second |
you can leave that result on the stack while you compute the second |
6693 |
term. With both of these results waiting on the stack you can then |
term. With both of these results waiting on the stack you can then |
6996 |
down to an integer. Consider @expr{123456789 / 2} when the current |
down to an integer. Consider @expr{123456789 / 2} when the current |
6997 |
precision is 6 digits. The true answer is @expr{61728394.5}, but |
precision is 6 digits. The true answer is @expr{61728394.5}, but |
6998 |
with a precision of 6 this will be rounded to |
with a precision of 6 this will be rounded to |
6999 |
@texline @tmath{12345700.0/2.0 = 61728500.0}. |
@texline @math{12345700.0/2.0 = 61728500.0}. |
7000 |
@infoline @expr{12345700.@: / 2.@: = 61728500.}. |
@infoline @expr{12345700.@: / 2.@: = 61728500.}. |
7001 |
The result, when converted to an integer, will be off by 106. |
The result, when converted to an integer, will be off by 106. |
7002 |
|
|
7107 |
|
|
7108 |
@noindent |
@noindent |
7109 |
To solve |
To solve |
7110 |
@texline @tmath{A^T A \, X = A^T B}, |
@texline @math{A^T A \, X = A^T B}, |
7111 |
@infoline @expr{trn(A) * A * X = trn(A) * B}, |
@infoline @expr{trn(A) * A * X = trn(A) * B}, |
7112 |
first we compute |
first we compute |
7113 |
@texline @tmath{A' = A^T A} |
@texline @math{A' = A^T A} |
7114 |
@infoline @expr{A2 = trn(A) * A} |
@infoline @expr{A2 = trn(A) * A} |
7115 |
and |
and |
7116 |
@texline @tmath{B' = A^T B}; |
@texline @math{B' = A^T B}; |
7117 |
@infoline @expr{B2 = trn(A) * B}; |
@infoline @expr{B2 = trn(A) * B}; |
7118 |
now, we have a system |
now, we have a system |
7119 |
@texline @tmath{A' X = B'} |
@texline @math{A' X = B'} |
7120 |
@infoline @expr{A2 * X = B2} |
@infoline @expr{A2 * X = B2} |
7121 |
which we can solve using Calc's @samp{/} command. |
which we can solve using Calc's @samp{/} command. |
7122 |
|
|
7148 |
|
|
7149 |
The first step is to enter the coefficient matrix. We'll store it in |
The first step is to enter the coefficient matrix. We'll store it in |
7150 |
quick variable number 7 for later reference. Next, we compute the |
quick variable number 7 for later reference. Next, we compute the |
7151 |
@texline @tmath{B'} |
@texline @math{B'} |
7152 |
@infoline @expr{B2} |
@infoline @expr{B2} |
7153 |
vector. |
vector. |
7154 |
|
|
7166 |
|
|
7167 |
@noindent |
@noindent |
7168 |
Now we compute the matrix |
Now we compute the matrix |
7169 |
@texline @tmath{A'} |
@texline @math{A'} |
7170 |
@infoline @expr{A2} |
@infoline @expr{A2} |
7171 |
and divide. |
and divide. |
7172 |
|
|
7187 |
round-off error.) |
round-off error.) |
7188 |
|
|
7189 |
Notice that the answers are similar to those for the |
Notice that the answers are similar to those for the |
7190 |
@texline @tmath{3\times3} |
@texline @math{3\times3} |
7191 |
@infoline 3x3 |
@infoline 3x3 |
7192 |
system solved in the text. That's because the fourth equation that was |
system solved in the text. That's because the fourth equation that was |
7193 |
added to the system is almost identical to the first one multiplied |
added to the system is almost identical to the first one multiplied |
7194 |
by two. (If it were identical, we would have gotten the exact same |
by two. (If it were identical, we would have gotten the exact same |
7195 |
answer since the |
answer since the |
7196 |
@texline @tmath{4\times3} |
@texline @math{4\times3} |
7197 |
@infoline 4x3 |
@infoline 4x3 |
7198 |
system would be equivalent to the original |
system would be equivalent to the original |
7199 |
@texline @tmath{3\times3} |
@texline @math{3\times3} |
7200 |
@infoline 3x3 |
@infoline 3x3 |
7201 |
system.) |
system.) |
7202 |
|
|
7273 |
@end tex |
@end tex |
7274 |
|
|
7275 |
Thus we want a |
Thus we want a |
7276 |
@texline @tmath{19\times2} |
@texline @math{19\times2} |
7277 |
@infoline 19x2 |
@infoline 19x2 |
7278 |
matrix with our @expr{x} vector as one column and |
matrix with our @expr{x} vector as one column and |
7279 |
ones as the other column. So, first we build the column of ones, then |
ones as the other column. So, first we build the column of ones, then |
7292 |
|
|
7293 |
@noindent |
@noindent |
7294 |
Now we compute |
Now we compute |
7295 |
@texline @tmath{A^T y} |
@texline @math{A^T y} |
7296 |
@infoline @expr{trn(A) * y} |
@infoline @expr{trn(A) * y} |
7297 |
and |
and |
7298 |
@texline @tmath{A^T A} |
@texline @math{A^T A} |
7299 |
@infoline @expr{trn(A) * A} |
@infoline @expr{trn(A) * A} |
7300 |
and divide. |
and divide. |
7301 |
|
|
7323 |
@end smallexample |
@end smallexample |
7324 |
|
|
7325 |
Since we were solving equations of the form |
Since we were solving equations of the form |
7326 |
@texline @tmath{m \times x + b \times 1 = y}, |
@texline @math{m \times x + b \times 1 = y}, |
7327 |
@infoline @expr{m*x + b*1 = y}, |
@infoline @expr{m*x + b*1 = y}, |
7328 |
these numbers should be @expr{m} and @expr{b}, respectively. Sure |
these numbers should be @expr{m} and @expr{b}, respectively. Sure |
7329 |
enough, they agree exactly with the result computed using @kbd{V M} and |
enough, they agree exactly with the result computed using @kbd{V M} and |
7386 |
|
|
7387 |
@noindent |
@noindent |
7388 |
A number @expr{j} is a divisor of @expr{n} if |
A number @expr{j} is a divisor of @expr{n} if |
7389 |
@texline @tmath{n \mathbin{\hbox{\code{\%}}} j = 0}. |
@texline @math{n \mathbin{\hbox{\code{\%}}} j = 0}. |
7390 |
@infoline @samp{n % j = 0}. |
@infoline @samp{n % j = 0}. |
7391 |
The first step is to get a vector that identifies the divisors. |
The first step is to get a vector that identifies the divisors. |
7392 |
|
|
7457 |
the job is pretty straightforward. |
the job is pretty straightforward. |
7458 |
|
|
7459 |
Incidentally, Calc provides the |
Incidentally, Calc provides the |
7460 |
@texline @dfn{M@"obius} @tmath{\mu} |
@texline @dfn{M@"obius} @math{\mu} |
7461 |
@infoline @dfn{Moebius mu} |
@infoline @dfn{Moebius mu} |
7462 |
function which is zero if and only if its argument is square-free. It |
function which is zero if and only if its argument is square-free. It |
7463 |
would be a much more convenient way to do the above test in practice. |
would be a much more convenient way to do the above test in practice. |
7491 |
the ``triangular numbers'' (now you know why!). The @expr{n}th |
the ``triangular numbers'' (now you know why!). The @expr{n}th |
7492 |
triangular number is the sum of the integers from 1 to @expr{n}, and |
triangular number is the sum of the integers from 1 to @expr{n}, and |
7493 |
can be computed directly by the formula |
can be computed directly by the formula |
7494 |
@texline @tmath{n (n+1) \over 2}. |
@texline @math{n (n+1) \over 2}. |
7495 |
@infoline @expr{n * (n+1) / 2}. |
@infoline @expr{n * (n+1) / 2}. |
7496 |
|
|
7497 |
@smallexample |
@smallexample |
7587 |
@noindent |
@noindent |
7588 |
It's a good idea to verify, as in the last step above, that only |
It's a good idea to verify, as in the last step above, that only |
7589 |
one value is equal to the maximum. (After all, a plot of |
one value is equal to the maximum. (After all, a plot of |
7590 |
@texline @tmath{\sin x} |
@texline @math{\sin x} |
7591 |
@infoline @expr{sin(x)} |
@infoline @expr{sin(x)} |
7592 |
might have many points all equal to the maximum value, 1.) |
might have many points all equal to the maximum value, 1.) |
7593 |
|
|
7859 |
symmetries. First of all, after some thought it's clear that the |
symmetries. First of all, after some thought it's clear that the |
7860 |
@expr{y} axis can be ignored altogether. Just pick a random @expr{x} |
@expr{y} axis can be ignored altogether. Just pick a random @expr{x} |
7861 |
component for one end of the match, pick a random direction |
component for one end of the match, pick a random direction |
7862 |
@texline @tmath{\theta}, |
@texline @math{\theta}, |
7863 |
@infoline @expr{theta}, |
@infoline @expr{theta}, |
7864 |
and see if @expr{x} and |
and see if @expr{x} and |
7865 |
@texline @tmath{x + \cos \theta} |
@texline @math{x + \cos \theta} |
7866 |
@infoline @expr{x + cos(theta)} |
@infoline @expr{x + cos(theta)} |
7867 |
(which is the @expr{x} coordinate of the other endpoint) cross a line. |
(which is the @expr{x} coordinate of the other endpoint) cross a line. |
7868 |
The lines are at integer coordinates, so this happens when the two |
The lines are at integer coordinates, so this happens when the two |
7879 |
endpoint. The rightmost endpoint will be between 0 and 1 if the |
endpoint. The rightmost endpoint will be between 0 and 1 if the |
7880 |
match does not cross a line, or between 1 and 2 if it does. So: |
match does not cross a line, or between 1 and 2 if it does. So: |
7881 |
Pick random @expr{x} and |
Pick random @expr{x} and |
7882 |
@texline @tmath{\theta}, |
@texline @math{\theta}, |
7883 |
@infoline @expr{theta}, |
@infoline @expr{theta}, |
7884 |
compute |
compute |
7885 |
@texline @tmath{x + \cos \theta}, |
@texline @math{x + \cos \theta}, |
7886 |
@infoline @expr{x + cos(theta)}, |
@infoline @expr{x + cos(theta)}, |
7887 |
and count how many of the results are greater than one. Simple! |
and count how many of the results are greater than one. Simple! |
7888 |
|
|
8207 |
@noindent |
@noindent |
8208 |
Aha! It's unlikely that an irrational number would equal a fraction |
Aha! It's unlikely that an irrational number would equal a fraction |
8209 |
this simple to within ten digits, so our original number was probably |
this simple to within ten digits, so our original number was probably |
8210 |
@texline @tmath{\sqrt{27 \pi / 53}}. |
@texline @math{\sqrt{27 \pi / 53}}. |
8211 |
@infoline @expr{sqrt(27 pi / 53)}. |
@infoline @expr{sqrt(27 pi / 53)}. |
8212 |
|
|
8213 |
Notice that we didn't need to re-round the number when we reduced the |
Notice that we didn't need to re-round the number when we reduced the |
8468 |
The fourth calculation, @samp{1 / (-10 .. 10)}, has the same problem. |
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. |
Zero is buried inside the interval, but it's still a possible value. |
8470 |
It's not hard to see that the actual result of @samp{1 / (-10 .. 10)} |
It's not hard to see that the actual result of @samp{1 / (-10 .. 10)} |
8471 |
will be either greater than @i{0.1}, or less than @i{-0.1}. Thus |
will be either greater than @mathit{0.1}, or less than @mathit{-0.1}. Thus |
8472 |
the interval goes from minus infinity to plus infinity, with a ``hole'' |
the interval goes from minus infinity to plus infinity, with a ``hole'' |
8473 |
in it from @i{-0.1} to @i{0.1}. Calc doesn't have any way to |
in it from @mathit{-0.1} to @mathit{0.1}. Calc doesn't have any way to |
8474 |
represent this, so it just reports @samp{[-inf .. inf]} as the answer. |
represent this, so it just reports @samp{[-inf .. inf]} as the answer. |
8475 |
It may be disappointing to hear ``the answer lies somewhere between |
It may be disappointing to hear ``the answer lies somewhere between |
8476 |
minus infinity and plus infinity, inclusive,'' but that's the best |
minus infinity and plus infinity, inclusive,'' but that's the best |
8490 |
@end smallexample |
@end smallexample |
8491 |
|
|
8492 |
@noindent |
@noindent |
8493 |
In the first case the result says, ``if a number is between @i{-3} and |
In the first case the result says, ``if a number is between @mathit{-3} and |
8494 |
3, its square is between 0 and 9.'' The second case says, ``the product |
3, its square is between 0 and 9.'' The second case says, ``the product |
8495 |
of two numbers each between @i{-3} and 3 is between @i{-9} and 9.'' |
of two numbers each between @mathit{-3} and 3 is between @mathit{-9} and 9.'' |
8496 |
|
|
8497 |
An interval form is not a number; it is a symbol that can stand for |
An interval form is not a number; it is a symbol that can stand for |
8498 |
many different numbers. Two identical-looking interval forms can stand |
many different numbers. Two identical-looking interval forms can stand |
9248 |
|
|
9249 |
@noindent |
@noindent |
9250 |
Computing |
Computing |
9251 |
@texline @tmath{\displaystyle{\sin x \over x}}: |
@texline @math{\displaystyle{\sin x \over x}}: |
9252 |
@infoline @expr{sin(x) / x}: |
@infoline @expr{sin(x) / x}: |
9253 |
|
|
9254 |
Using the stack: @kbd{C-x ( @key{RET} S @key{TAB} / C-x )}. |
Using the stack: @kbd{C-x ( @key{RET} S @key{TAB} / C-x )}. |
9319 |
@noindent |
@noindent |
9320 |
This program is quite efficient because Calc knows how to raise a |
This program is quite efficient because Calc knows how to raise a |
9321 |
matrix (or other value) to the power @expr{n} in only |
matrix (or other value) to the power @expr{n} in only |
9322 |
@texline @tmath{\log_2 n} |
@texline @math{\log_2 n} |
9323 |
@infoline @expr{log(n,2)} |
@infoline @expr{log(n,2)} |
9324 |
steps. For example, this program can compute the 1000th Fibonacci |
steps. For example, this program can compute the 1000th Fibonacci |
9325 |
number (a 209-digit integer!) in about 10 steps; even though the |
number (a 209-digit integer!) in about 10 steps; even though the |
9373 |
@noindent |
@noindent |
9374 |
The first step is to compute the derivative @expr{f'(x)} and thus |
The first step is to compute the derivative @expr{f'(x)} and thus |
9375 |
the formula |
the formula |
9376 |
@texline @tmath{\displaystyle{x - {f(x) \over f'(x)}}}. |
@texline @math{\displaystyle{x - {f(x) \over f'(x)}}}. |
9377 |
@infoline @expr{x - f(x)/f'(x)}. |
@infoline @expr{x - f(x)/f'(x)}. |
9378 |
|
|
9379 |
(Because this definition is long, it will be repeated in concise form |
(Because this definition is long, it will be repeated in concise form |
9490 |
The first step is to adjust @expr{z} to be greater than 5. A simple |
The first step is to adjust @expr{z} to be greater than 5. A simple |
9491 |
``for'' loop will do the job here. If @expr{z} is less than 5, we |
``for'' loop will do the job here. If @expr{z} is less than 5, we |
9492 |
reduce the problem using |
reduce the problem using |
9493 |
@texline @tmath{\psi(z) = \psi(z+1) - 1/z}. |
@texline @math{\psi(z) = \psi(z+1) - 1/z}. |
9494 |
@infoline @expr{psi(z) = psi(z+1) - 1/z}. We go |
@infoline @expr{psi(z) = psi(z+1) - 1/z}. We go |
9495 |
on to compute |
on to compute |
9496 |
@texline @tmath{\psi(z+1)}, |
@texline @math{\psi(z+1)}, |
9497 |
@infoline @expr{psi(z+1)}, |
@infoline @expr{psi(z+1)}, |
9498 |
and remember to add back a factor of @expr{-1/z} when we're done. This |
and remember to add back a factor of @expr{-1/z} when we're done. This |
9499 |
step is repeated until @expr{z > 5}. |
step is repeated until @expr{z > 5}. |
9534 |
@end smallexample |
@end smallexample |
9535 |
|
|
9536 |
Now we compute the initial part of the sum: |
Now we compute the initial part of the sum: |
9537 |
@texline @tmath{\ln z - {1 \over 2z}} |
@texline @math{\ln z - {1 \over 2z}} |
9538 |
@infoline @expr{ln(z) - 1/2z} |
@infoline @expr{ln(z) - 1/2z} |
9539 |
minus the adjustment factor. |
minus the adjustment factor. |
9540 |
|
|
9577 |
@end smallexample |
@end smallexample |
9578 |
|
|
9579 |
This is the value of |
This is the value of |
9580 |
@texline @tmath{-\gamma}, |
@texline @math{-\gamma}, |
9581 |
@infoline @expr{- gamma}, |
@infoline @expr{- gamma}, |
9582 |
with a slight bit of roundoff error. To get a full 12 digits, let's use |
with a slight bit of roundoff error. To get a full 12 digits, let's use |
9583 |
a higher precision: |
a higher precision: |
9612 |
@noindent |
@noindent |
9613 |
Taking the derivative of a term of the form @expr{x^n} will produce |
Taking the derivative of a term of the form @expr{x^n} will produce |
9614 |
a term like |
a term like |
9615 |
@texline @tmath{n x^{n-1}}. |
@texline @math{n x^{n-1}}. |
9616 |
@infoline @expr{n x^(n-1)}. |
@infoline @expr{n x^(n-1)}. |
9617 |
Taking the derivative of a constant |
Taking the derivative of a constant |
9618 |
produces zero. From this it is easy to see that the @expr{n}th |
produces zero. From this it is easy to see that the @expr{n}th |
10186 |
@kbd{+} key always ``pops'' the top two numbers from the stack, adds them, |
@kbd{+} key always ``pops'' the top two numbers from the stack, adds them, |
10187 |
and pushes the result (3) back onto the stack. This number is ready for |
and pushes the result (3) back onto the stack. This number is ready for |
10188 |
further calculations: @kbd{5 -} pushes 5 onto the stack, then pops the |
further calculations: @kbd{5 -} pushes 5 onto the stack, then pops the |
10189 |
3 and 5, subtracts them, and pushes the result (@i{-2}). |
3 and 5, subtracts them, and pushes the result (@mathit{-2}). |
10190 |
|
|
10191 |
Note that the ``top'' of the stack actually appears at the @emph{bottom} |
Note that the ``top'' of the stack actually appears at the @emph{bottom} |
10192 |
of the buffer. A line containing a single @samp{.} character signifies |
of the buffer. A line containing a single @samp{.} character signifies |
10249 |
of the number on the top of the stack or the number currently being entered. |
of the number on the top of the stack or the number currently being entered. |
10250 |
The @kbd{_} key begins entry of a negative number or changes the sign of |
The @kbd{_} key begins entry of a negative number or changes the sign of |
10251 |
the number currently being entered. The following sequences all enter the |
the number currently being entered. The following sequences all enter the |
10252 |
number @i{-5} onto the stack: @kbd{0 @key{RET} 5 -}, @kbd{5 n @key{RET}}, |
number @mathit{-5} onto the stack: @kbd{0 @key{RET} 5 -}, @kbd{5 n @key{RET}}, |
10253 |
@kbd{5 @key{RET} n}, @kbd{_ 5 @key{RET}}, @kbd{5 _ @key{RET}}. |
@kbd{5 @key{RET} n}, @kbd{_ 5 @key{RET}}, @kbd{5 _ @key{RET}}. |
10254 |
|
|
10255 |
Some other keys are active during numeric entry, such as @kbd{#} for |
Some other keys are active during numeric entry, such as @kbd{#} for |
10270 |
Calculations can also be entered in algebraic form. This is accomplished |
Calculations can also be entered in algebraic form. This is accomplished |
10271 |
by typing the apostrophe key, @kbd{'}, followed by the expression in |
by typing the apostrophe key, @kbd{'}, followed by the expression in |
10272 |
standard format: @kbd{@key{'} 2+3*4 @key{RET}} computes |
standard format: @kbd{@key{'} 2+3*4 @key{RET}} computes |
10273 |
@texline @tmath{2+(3\times4) = 14} |
@texline @math{2+(3\times4) = 14} |
10274 |
@infoline @expr{2+(3*4) = 14} |
@infoline @expr{2+(3*4) = 14} |
10275 |
and pushes that on the stack. If you wish you can |
and pushes that on the stack. If you wish you can |
10276 |
ignore the RPN aspect of Calc altogether and simply enter algebraic |
ignore the RPN aspect of Calc altogether and simply enter algebraic |
10680 |
unless you raise the precision still further. Many operations such as |
unless you raise the precision still further. Many operations such as |
10681 |
logarithms and sines make use of similarly cached values such as |
logarithms and sines make use of similarly cached values such as |
10682 |
@cpiover{4} and |
@cpiover{4} and |
10683 |
@texline @tmath{\ln 2}. |
@texline @math{\ln 2}. |
10684 |
@infoline @expr{ln(2)}. |
@infoline @expr{ln(2)}. |
10685 |
The visible effect of caching is that |
The visible effect of caching is that |
10686 |
high-precision computations may seem to do extra work the first time. |
high-precision computations may seem to do extra work the first time. |
10839 |
notation. The number of significant digits in the fractional part is |
notation. The number of significant digits in the fractional part is |
10840 |
governed by the current floating precision (@pxref{Precision}). The |
governed by the current floating precision (@pxref{Precision}). The |
10841 |
range of acceptable values is from |
range of acceptable values is from |
10842 |
@texline @tmath{10^{-3999999}} |
@texline @math{10^{-3999999}} |
10843 |
@infoline @expr{10^-3999999} |
@infoline @expr{10^-3999999} |
10844 |
(inclusive) to |
(inclusive) to |
10845 |
@texline @tmath{10^{4000000}} |
@texline @math{10^{4000000}} |
10846 |
@infoline @expr{10^4000000} |
@infoline @expr{10^4000000} |
10847 |
(exclusive), plus the corresponding negative values and zero. |
(exclusive), plus the corresponding negative values and zero. |
10848 |
|
|
10914 |
notation; @pxref{Complex Formats}. |
notation; @pxref{Complex Formats}. |
10915 |
|
|
10916 |
Polar complex numbers are displayed in the form |
Polar complex numbers are displayed in the form |
10917 |
@texline `@t{(}@var{r}@t{;}@tmath{\theta}@t{)}' |
@texline `@t{(}@var{r}@t{;}@math{\theta}@t{)}' |
10918 |
@infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}' |
@infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}' |
10919 |
where @var{r} is the nonnegative magnitude and |
where @var{r} is the nonnegative magnitude and |
10920 |
@texline @tmath{\theta} |
@texline @math{\theta} |
10921 |
@infoline @var{theta} |
@infoline @var{theta} |
10922 |
is the argument or phase angle. The range of |
is the argument or phase angle. The range of |
10923 |
@texline @tmath{\theta} |
@texline @math{\theta} |
10924 |
@infoline @var{theta} |
@infoline @var{theta} |
10925 |
depends on the current angular mode (@pxref{Angular Modes}); it is |
depends on the current angular mode (@pxref{Angular Modes}); it is |
10926 |
generally between @i{-180} and @i{+180} degrees or the equivalent range |
generally between @mathit{-180} and @mathit{+180} degrees or the equivalent range |
10927 |
in radians. |
in radians. |
10928 |
|
|
10929 |
Complex numbers are entered in stages using incomplete objects. |
Complex numbers are entered in stages using incomplete objects. |
10966 |
that if @expr{x} got ``all the way to infinity,'' then @expr{1 / x} |
that if @expr{x} got ``all the way to infinity,'' then @expr{1 / x} |
10967 |
would go all the way to zero. Similarly, when they say that |
would go all the way to zero. Similarly, when they say that |
10968 |
@samp{exp(inf) = inf}, they mean that |
@samp{exp(inf) = inf}, they mean that |
10969 |
@texline @tmath{e^x} |
@texline @math{e^x} |
10970 |
@infoline @expr{exp(x)} |
@infoline @expr{exp(x)} |
10971 |
grows without bound as @expr{x} grows. The symbol @samp{-inf} likewise |
grows without bound as @expr{x} grows. The symbol @samp{-inf} likewise |
10972 |
stands for an infinitely negative real value; for example, we say that |
stands for an infinitely negative real value; for example, we say that |
11063 |
@tindex vec |
@tindex vec |
11064 |
Algebraic functions for building vectors include @samp{vec(a, b, c)} |
Algebraic functions for building vectors include @samp{vec(a, b, c)} |
11065 |
to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an |
to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an |
11066 |
@texline @tmath{n\times m} |
@texline @math{n\times m} |
11067 |
@infoline @var{n}x@var{m} |
@infoline @var{n}x@var{m} |
11068 |
matrix of @samp{a}s, and @samp{index(n)} to build a vector of integers |
matrix of @samp{a}s, and @samp{index(n)} to build a vector of integers |
11069 |
from 1 to @samp{n}. |
from 1 to @samp{n}. |
11194 |
The @var{secs} value is a real number between 0 (inclusive) and 60 |
The @var{secs} value is a real number between 0 (inclusive) and 60 |
11195 |
(exclusive). A positive HMS form is interpreted as @var{hours} + |
(exclusive). A positive HMS form is interpreted as @var{hours} + |
11196 |
@var{mins}/60 + @var{secs}/3600. A negative HMS form is interpreted |
@var{mins}/60 + @var{secs}/3600. A negative HMS form is interpreted |
11197 |
as @i{- @var{hours}} @i{-} @var{mins}/60 @i{-} @var{secs}/3600. |
as @mathit{- @var{hours}} @mathit{-} @var{mins}/60 @mathit{-} @var{secs}/3600. |
11198 |
Display format for HMS forms is quite flexible. @xref{HMS Formats}. |
Display format for HMS forms is quite flexible. @xref{HMS Formats}. |
11199 |
|
|
11200 |
HMS forms can be added and subtracted. When they are added to numbers, |
HMS forms can be added and subtracted. When they are added to numbers, |
11288 |
|
|
11289 |
Calc uses the Julian calendar for all dates before the year 1752, |
Calc uses the Julian calendar for all dates before the year 1752, |
11290 |
including dates BC when the Julian calendar technically had not |
including dates BC when the Julian calendar technically had not |
11291 |
yet been invented. Thus the claim that day number @i{-10000} is |
yet been invented. Thus the claim that day number @mathit{-10000} is |
11292 |
called ``August 16, 28 BC'' should be taken with a grain of salt. |
called ``August 16, 28 BC'' should be taken with a grain of salt. |
11293 |
|
|
11294 |
Please note that there is no ``year 0''; the day before |
Please note that there is no ``year 0''; the day before |
11295 |
@samp{<Sat Jan 1, +1>} is @samp{<Fri Dec 31, -1>}. These are |
@samp{<Sat Jan 1, +1>} is @samp{<Fri Dec 31, -1>}. These are |
11296 |
days 0 and @i{-1} respectively in Calc's internal numbering scheme. |
days 0 and @mathit{-1} respectively in Calc's internal numbering scheme. |
11297 |
|
|
11298 |
@cindex Julian day counting |
@cindex Julian day counting |
11299 |
Another day counting system in common use is, confusingly, also |
Another day counting system in common use is, confusingly, also |
11301 |
Scaliger, who named it in honor of his father Julius Caesar |
Scaliger, who named it in honor of his father Julius Caesar |
11302 |
Scaliger. For obscure reasons he chose to start his day |
Scaliger. For obscure reasons he chose to start his day |
11303 |
numbering on Jan 1, 4713 BC at noon, which in Calc's scheme |
numbering on Jan 1, 4713 BC at noon, which in Calc's scheme |
11304 |
is @i{-1721423.5} (recall that Calc starts at midnight instead |
is @mathit{-1721423.5} (recall that Calc starts at midnight instead |
11305 |
of noon). Thus to convert a Calc date code obtained by |
of noon). Thus to convert a Calc date code obtained by |
11306 |
unpacking a date form into a Julian day number, simply add |
unpacking a date form into a Julian day number, simply add |
11307 |
1721423.5. The Julian code for @samp{6:00am Jan 9, 1991} |
1721423.5. The Julian code for @samp{6:00am Jan 9, 1991} |
11334 |
often arises in number theory. Modulo forms are written |
often arises in number theory. Modulo forms are written |
11335 |
`@var{a} @t{mod} @var{M}', |
`@var{a} @t{mod} @var{M}', |
11336 |
where @var{a} and @var{M} are real numbers or HMS forms, and |
where @var{a} and @var{M} are real numbers or HMS forms, and |
11337 |
@texline @tmath{0 \le a < M}. |
@texline @math{0 \le a < M}. |
11338 |
@infoline @expr{0 <= a < @var{M}}. |
@infoline @expr{0 <= a < @var{M}}. |
11339 |
In many applications @expr{a} and @expr{M} will be |
In many applications @expr{a} and @expr{M} will be |
11340 |
integers but this is not required. |
integers but this is not required. |
11366 |
roots, are not yet supported for modulo forms. (Note that, although |
roots, are not yet supported for modulo forms. (Note that, although |
11367 |
@w{`@t{(}@var{a} @t{mod} @var{M}@t{)^.5}'} will compute a ``modulo square root'' |
@w{`@t{(}@var{a} @t{mod} @var{M}@t{)^.5}'} will compute a ``modulo square root'' |
11368 |
in the sense of reducing |
in the sense of reducing |
11369 |
@texline @tmath{\sqrt a} |
@texline @math{\sqrt a} |
11370 |
@infoline @expr{sqrt(a)} |
@infoline @expr{sqrt(a)} |
11371 |
modulo @expr{M}, this is not a useful definition from the |
modulo @expr{M}, this is not a useful definition from the |
11372 |
number-theoretical point of view.) |
number-theoretical point of view.) |
11416 |
@cindex Standard deviations |
@cindex Standard deviations |
11417 |
An @dfn{error form} is a number with an associated standard |
An @dfn{error form} is a number with an associated standard |
11418 |
deviation, as in @samp{2.3 +/- 0.12}. The notation |
deviation, as in @samp{2.3 +/- 0.12}. The notation |
11419 |
@texline `@var{x} @t{+/-} @tmath{\sigma}' |
@texline `@var{x} @t{+/-} @math{\sigma}' |
11420 |
@infoline `@var{x} @t{+/-} sigma' |
@infoline `@var{x} @t{+/-} sigma' |
11421 |
stands for an uncertain value which follows |
stands for an uncertain value which follows |
11422 |
a normal or Gaussian distribution of mean @expr{x} and standard |
a normal or Gaussian distribution of mean @expr{x} and standard |
11423 |
deviation or ``error'' |
deviation or ``error'' |
11424 |
@texline @tmath{\sigma}. |
@texline @math{\sigma}. |
11425 |
@infoline @expr{sigma}. |
@infoline @expr{sigma}. |
11426 |
Both the mean and the error can be either numbers or |
Both the mean and the error can be either numbers or |
11427 |
formulas. Generally these are real numbers but the mean may also be |
formulas. Generally these are real numbers but the mean may also be |
11432 |
All arithmetic and transcendental functions accept error forms as input. |
All arithmetic and transcendental functions accept error forms as input. |
11433 |
Operations on the mean-value part work just like operations on regular |
Operations on the mean-value part work just like operations on regular |
11434 |
numbers. The error part for any function @expr{f(x)} (such as |
numbers. The error part for any function @expr{f(x)} (such as |
11435 |
@texline @tmath{\sin x} |
@texline @math{\sin x} |
11436 |
@infoline @expr{sin(x)}) |
@infoline @expr{sin(x)}) |
11437 |
is defined by the error of @expr{x} times the derivative of @expr{f} |
is defined by the error of @expr{x} times the derivative of @expr{f} |
11438 |
evaluated at the mean value of @expr{x}. For a two-argument function |
evaluated at the mean value of @expr{x}. For a two-argument function |
11463 |
of standard deviations. Actual errors often are neither Gaussian-distributed |
of standard deviations. Actual errors often are neither Gaussian-distributed |
11464 |
nor uncorrelated, and the above formulas are valid only when errors |
nor uncorrelated, and the above formulas are valid only when errors |
11465 |
are small. As an example, the error arising from |
are small. As an example, the error arising from |
11466 |
@texline `@t{sin(}@var{x} @t{+/-} @tmath{\sigma}@t{)}' |
@texline `@t{sin(}@var{x} @t{+/-} @math{\sigma}@t{)}' |
11467 |
@infoline `@t{sin(}@var{x} @t{+/-} @var{sigma}@t{)}' |
@infoline `@t{sin(}@var{x} @t{+/-} @var{sigma}@t{)}' |
11468 |
is |
is |
11469 |
@texline `@tmath{\sigma} @t{abs(cos(}@var{x}@t{))}'. |
@texline `@math{\sigma} @t{abs(cos(}@var{x}@t{))}'. |
11470 |
@infoline `@var{sigma} @t{abs(cos(}@var{x}@t{))}'. |
@infoline `@var{sigma} @t{abs(cos(}@var{x}@t{))}'. |
11471 |
When @expr{x} is close to zero, |
When @expr{x} is close to zero, |
11472 |
@texline @tmath{\cos x} |
@texline @math{\cos x} |
11473 |
@infoline @expr{cos(x)} |
@infoline @expr{cos(x)} |
11474 |
is close to one so the error in the sine is close to |
is close to one so the error in the sine is close to |
11475 |
@texline @tmath{\sigma}; |
@texline @math{\sigma}; |
11476 |
@infoline @expr{sigma}; |
@infoline @expr{sigma}; |
11477 |
this makes sense, since |
this makes sense, since |
11478 |
@texline @tmath{\sin x} |
@texline @math{\sin x} |
11479 |
@infoline @expr{sin(x)} |
@infoline @expr{sin(x)} |
11480 |
is approximately @expr{x} near zero, so a given error in @expr{x} will |
is approximately @expr{x} near zero, so a given error in @expr{x} will |
11481 |
produce about the same error in the sine. Likewise, near 90 degrees |
produce about the same error in the sine. Likewise, near 90 degrees |
11482 |
@texline @tmath{\cos x} |
@texline @math{\cos x} |
11483 |
@infoline @expr{cos(x)} |
@infoline @expr{cos(x)} |
11484 |
is nearly zero and so the computed error is |
is nearly zero and so the computed error is |
11485 |
small: The sine curve is nearly flat in that region, so an error in @expr{x} |
small: The sine curve is nearly flat in that region, so an error in @expr{x} |
11486 |
has relatively little effect on the value of |
has relatively little effect on the value of |
11487 |
@texline @tmath{\sin x}. |
@texline @math{\sin x}. |
11488 |
@infoline @expr{sin(x)}. |
@infoline @expr{sin(x)}. |
11489 |
However, consider @samp{sin(90 +/- 1000)}. The cosine of 90 is zero, so |
However, consider @samp{sin(90 +/- 1000)}. The cosine of 90 is zero, so |
11490 |
Calc will report zero error! We get an obviously wrong result because |
Calc will report zero error! We get an obviously wrong result because |
11491 |
we have violated the small-error approximation underlying the error |
we have violated the small-error approximation underlying the error |
11492 |
analysis. If the error in @expr{x} had been small, the error in |
analysis. If the error in @expr{x} had been small, the error in |
11493 |
@texline @tmath{\sin x} |
@texline @math{\sin x} |
11494 |
@infoline @expr{sin(x)} |
@infoline @expr{sin(x)} |
11495 |
would indeed have been negligible. |
would indeed have been negligible. |
11496 |
|
|
11599 |
While it may seem that intervals and error forms are similar, they are |
While it may seem that intervals and error forms are similar, they are |
11600 |
based on entirely different concepts of inexact quantities. An error |
based on entirely different concepts of inexact quantities. An error |
11601 |
form |
form |
11602 |
@texline `@var{x} @t{+/-} @tmath{\sigma}' |
@texline `@var{x} @t{+/-} @math{\sigma}' |
11603 |
@infoline `@var{x} @t{+/-} @var{sigma}' |
@infoline `@var{x} @t{+/-} @var{sigma}' |
11604 |
means a variable is random, and its value could |
means a variable is random, and its value could |
11605 |
be anything but is ``probably'' within one |
be anything but is ``probably'' within one |
11606 |
@texline @tmath{\sigma} |
@texline @math{\sigma} |
11607 |
@infoline @var{sigma} |
@infoline @var{sigma} |
11608 |
of the mean value @expr{x}. An interval |
of the mean value @expr{x}. An interval |
11609 |
`@t{[}@var{a} @t{..@:} @var{b}@t{]}' means a |
`@t{[}@var{a} @t{..@:} @var{b}@t{]}' means a |
11837 |
|
|
11838 |
Note that, unlike in usual computer notation, multiplication binds more |
Note that, unlike in usual computer notation, multiplication binds more |
11839 |
strongly than division: @samp{a*b/c*d} is equivalent to |
strongly than division: @samp{a*b/c*d} is equivalent to |
11840 |
@texline @tmath{a b \over c d}. |
@texline @math{a b \over c d}. |
11841 |
@infoline @expr{(a*b)/(c*d)}. |
@infoline @expr{(a*b)/(c*d)}. |
11842 |
|
|
11843 |
@cindex Multiplication, implicit |
@cindex Multiplication, implicit |
12035 |
element at level @var{n} up to the top. (Compare with @key{LFD}, |
element at level @var{n} up to the top. (Compare with @key{LFD}, |
12036 |
which copies instead of moving the element in level @var{n}.) |
which copies instead of moving the element in level @var{n}.) |
12037 |
|
|
12038 |
With a negative argument @i{-@var{n}}, @key{TAB} rotates the stack |
With a negative argument @mathit{-@var{n}}, @key{TAB} rotates the stack |
12039 |
to move the object in level @var{n} to the deepest place in the |
to move the object in level @var{n} to the deepest place in the |
12040 |
stack, and the object in level @i{@var{n}+1} to the top. @kbd{M-@key{TAB}} |
stack, and the object in level @mathit{@var{n}+1} to the top. @kbd{M-@key{TAB}} |
12041 |
rotates the deepest stack element to be in level @i{n}, also |
rotates the deepest stack element to be in level @mathit{n}, also |
12042 |
putting the top stack element in level @i{@var{n}+1}. |
putting the top stack element in level @mathit{@var{n}+1}. |
12043 |
|
|
12044 |
@xref{Selecting Subformulas}, for a way to apply these commands to |
@xref{Selecting Subformulas}, for a way to apply these commands to |
12045 |
any portion of a vector or formula on the stack. |
any portion of a vector or formula on the stack. |
12334 |
is because you are presumably switching to your @file{~/.emacs} file, |
is because you are presumably switching to your @file{~/.emacs} file, |
12335 |
which may contain other things you don't want to reread. You can give |
which may contain other things you don't want to reread. You can give |
12336 |
a numeric prefix argument of 1 to @kbd{m F} to force it to read the |
a numeric prefix argument of 1 to @kbd{m F} to force it to read the |
12337 |
file no matter what its name. Conversely, an argument of @i{-1} tells |
file no matter what its name. Conversely, an argument of @mathit{-1} tells |
12338 |
@kbd{m F} @emph{not} to read the new file. An argument of 2 or @i{-2} |
@kbd{m F} @emph{not} to read the new file. An argument of 2 or @mathit{-2} |
12339 |
tells @kbd{m F} not to reset the modes to their defaults beforehand, |
tells @kbd{m F} not to reset the modes to their defaults beforehand, |
12340 |
which is useful if you intend your new file to have a variant of the |
which is useful if you intend your new file to have a variant of the |
12341 |
modes present in the file you were using before. |
modes present in the file you were using before. |
12440 |
If both of these flags are set at once, the effect will be |
If both of these flags are set at once, the effect will be |
12441 |
@code{calc-arcsinh}. (The Hyperbolic flag is also used by some |
@code{calc-arcsinh}. (The Hyperbolic flag is also used by some |
12442 |
non-trigonometric commands; for example @kbd{H L} computes a base-10, |
non-trigonometric commands; for example @kbd{H L} computes a base-10, |
12443 |
instead of base-@i{e}, logarithm.) |
instead of base-@mathit{e}, logarithm.) |
12444 |
|
|
12445 |
Command names like @code{calc-arcsin} are provided for completeness, and |
Command names like @code{calc-arcsin} are provided for completeness, and |
12446 |
may be executed with @kbd{x} or @kbd{M-x}. Their effect is simply to |
may be executed with @kbd{x} or @kbd{M-x}. Their effect is simply to |
12584 |
which zero is treated as positive instead of being directionless. |
which zero is treated as positive instead of being directionless. |
12585 |
Thus, @samp{1 / 0 = inf} and @samp{-1 / 0 = -inf} in this mode. |
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 |
Note that zero never actually has a sign in Calc; there are no |
12587 |
separate representations for @i{+0} and @i{-0}. Positive |
separate representations for @mathit{+0} and @mathit{-0}. Positive |
12588 |
infinite mode merely changes the interpretation given to the |
infinite mode merely changes the interpretation given to the |
12589 |
single symbol, @samp{0}. One consequence of this is that, while |
single symbol, @samp{0}. One consequence of this is that, while |
12590 |
you might expect @samp{1 / -0 = -inf}, actually @samp{1 / -0} |
you might expect @samp{1 / -0 = -inf}, actually @samp{1 / -0} |
12975 |
Calc uses this information to determine when certain simplifications |
Calc uses this information to determine when certain simplifications |
12976 |
of formulas are safe. For example, @samp{(x^y)^z} cannot be |
of formulas are safe. For example, @samp{(x^y)^z} cannot be |
12977 |
simplified to @samp{x^(y z)} in general; for example, |
simplified to @samp{x^(y z)} in general; for example, |
12978 |
@samp{((-3)^2)^1:2} is 3, but @samp{(-3)^(2*1:2) = (-3)^1} is @i{-3}. |
@samp{((-3)^2)^1:2} is 3, but @samp{(-3)^(2*1:2) = (-3)^1} is @mathit{-3}. |
12979 |
However, this simplification @emph{is} safe if @code{z} is known |
However, this simplification @emph{is} safe if @code{z} is known |
12980 |
to be an integer, or if @code{x} is known to be a nonnegative |
to be an integer, or if @code{x} is known to be a nonnegative |
12981 |
real number. If you have given declarations that allow Calc to |
real number. If you have given declarations that allow Calc to |
13088 |
@end table |
@end table |
13089 |
|
|
13090 |
Calc does not check the declarations for a variable when you store |
Calc does not check the declarations for a variable when you store |
13091 |
a value in it. However, storing @i{-3.5} in a variable that has |
a value in it. However, storing @mathit{-3.5} in a variable that has |
13092 |
been declared @code{pos}, @code{int}, or @code{matrix} may have |
been declared @code{pos}, @code{int}, or @code{matrix} may have |
13093 |
unexpected effects; Calc may evaluate @samp{sqrt(x^2)} to @expr{3.5} |
unexpected effects; Calc may evaluate @samp{sqrt(x^2)} to @expr{3.5} |
13094 |
if it substitutes the value first, or to @expr{-3.5} if @code{x} |
if it substitutes the value first, or to @expr{-3.5} if @code{x} |
13323 |
current binary word size. (@xref{Binary Functions}, for a discussion of |
current binary word size. (@xref{Binary Functions}, for a discussion of |
13324 |
word size.) If the absolute value of the word size is @expr{w}, all integers |
word size.) If the absolute value of the word size is @expr{w}, all integers |
13325 |
are displayed with at least enough digits to represent |
are displayed with at least enough digits to represent |
13326 |
@texline @tmath{2^w-1} |
@texline @math{2^w-1} |
13327 |
@infoline @expr{(2^w)-1} |
@infoline @expr{(2^w)-1} |
13328 |
in the current radix. (Larger integers will still be displayed in their |
in the current radix. (Larger integers will still be displayed in their |
13329 |
entirety.) |
entirety.) |
14224 |
parentheses for very simple arguments. During input, curly braces and |
parentheses for very simple arguments. During input, curly braces and |
14225 |
parentheses work equally well for grouping, but when the document is |
parentheses work equally well for grouping, but when the document is |
14226 |
formatted the curly braces will be invisible. Thus the printed result is |
formatted the curly braces will be invisible. Thus the printed result is |
14227 |
@texline @tmath{\sin{2 x}} |
@texline @math{\sin{2 x}} |
14228 |
@infoline @expr{sin 2x} |
@infoline @expr{sin 2x} |
14229 |
but |
but |
14230 |
@texline @tmath{\sin(2 + x)}. |
@texline @math{\sin(2 + x)}. |
14231 |
@infoline @expr{sin(2 + x)}. |
@infoline @expr{sin(2 + x)}. |
14232 |
|
|
14233 |
Function and variable names not treated specially by @TeX{} are simply |
Function and variable names not treated specially by @TeX{} are simply |
15721 |
Command is @kbd{m p}. |
Command is @kbd{m p}. |
15722 |
|
|
15723 |
@item |
@item |
15724 |
Matrix/scalar mode. Default value is @i{-1}. Value is 0 for scalar |
Matrix/scalar mode. Default value is @mathit{-1}. Value is 0 for scalar |
15725 |
mode, @i{-2} for matrix mode, or @var{N} for |
mode, @mathit{-2} for matrix mode, or @var{N} for |
15726 |
@texline @tmath{N\times N} |
@texline @math{N\times N} |
15727 |
@infoline @var{N}x@var{N} |
@infoline @var{N}x@var{N} |
15728 |
matrix mode. Command is @kbd{m v}. |
matrix mode. Command is @kbd{m v}. |
15729 |
|
|
15730 |
@item |
@item |
15731 |
Simplification mode. Default is 1. Value is @i{-1} for off (@kbd{m O}), |
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}, |
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. |
or 5 for @w{@kbd{m U}}. The @kbd{m D} command accepts these prefixes. |
15734 |
|
|
15735 |
@item |
@item |
15736 |
Infinite mode. Default is @i{-1} (off). Value is 1 if the mode is on, |
Infinite mode. Default is @mathit{-1} (off). Value is 1 if the mode is on, |
15737 |
or 0 if the mode is on with positive zeros. Command is @kbd{m i}. |
or 0 if the mode is on with positive zeros. Command is @kbd{m i}. |
15738 |
@end enumerate |
@end enumerate |
15739 |
|
|
16074 |
@tindex - |
@tindex - |
16075 |
The @kbd{-} (@code{calc-minus}) command subtracts two values. The top |
The @kbd{-} (@code{calc-minus}) command subtracts two values. The top |
16076 |
number on the stack is subtracted from the one behind it, so that the |
number on the stack is subtracted from the one behind it, so that the |
16077 |
computation @kbd{5 @key{RET} 2 -} produces 3, not @i{-3}. All options |
computation @kbd{5 @key{RET} 2 -} produces 3, not @mathit{-3}. All options |
16078 |
available for @kbd{+} are available for @kbd{-} as well. |
available for @kbd{+} are available for @kbd{-} as well. |
16079 |
|
|
16080 |
@kindex * |
@kindex * |
16218 |
@pindex calc-sign |
@pindex calc-sign |
16219 |
@tindex sign |
@tindex sign |
16220 |
The @kbd{f s} (@code{calc-sign}) [@code{sign}] command returns 1 if its |
The @kbd{f s} (@code{calc-sign}) [@code{sign}] command returns 1 if its |
16221 |
argument is positive, @i{-1} if its argument is negative, or 0 if its |
argument is positive, @mathit{-1} if its argument is negative, or 0 if its |
16222 |
argument is zero. In algebraic form, you can also write @samp{sign(a,x)} |
argument is zero. In algebraic form, you can also write @samp{sign(a,x)} |
16223 |
which evaluates to @samp{x * sign(a)}, i.e., either @samp{x}, @samp{-x}, or |
which evaluates to @samp{x * sign(a)}, i.e., either @samp{x}, @samp{-x}, or |
16224 |
zero depending on the sign of @samp{a}. |
zero depending on the sign of @samp{a}. |
16281 |
the ``mantissa'' part @expr{m} of its floating-point argument; @kbd{f X} |
the ``mantissa'' part @expr{m} of its floating-point argument; @kbd{f X} |
16282 |
(@code{calc-xpon-part}) [@code{xpon}] extracts the ``exponent'' part |
(@code{calc-xpon-part}) [@code{xpon}] extracts the ``exponent'' part |
16283 |
@expr{e}. The original number is equal to |
@expr{e}. The original number is equal to |
16284 |
@texline @tmath{m \times 10^e}, |
@texline @math{m \times 10^e}, |
16285 |
@infoline @expr{m * 10^e}, |
@infoline @expr{m * 10^e}, |
16286 |
where @expr{m} is in the interval @samp{[1.0 ..@: 10.0)} except that |
where @expr{m} is in the interval @samp{[1.0 ..@: 10.0)} except that |
16287 |
@expr{m=e=0} if the original number is zero. For integers |
@expr{m=e=0} if the original number is zero. For integers |
16314 |
is 6 digits yields @samp{12.3457}. If the current precision had been |
is 6 digits yields @samp{12.3457}. If the current precision had been |
16315 |
8 digits, the result would have been @samp{12.345601}. Incrementing |
8 digits, the result would have been @samp{12.345601}. Incrementing |
16316 |
@samp{0.0} produces |
@samp{0.0} produces |
16317 |
@texline @tmath{10^{-p}}, |
@texline @math{10^{-p}}, |
16318 |
@infoline @expr{10^-p}, |
@infoline @expr{10^-p}, |
16319 |
where @expr{p} is the current |
where @expr{p} is the current |
16320 |
precision. These operations are defined only on integers and floats. |
precision. These operations are defined only on integers and floats. |
16355 |
The @kbd{F} (@code{calc-floor}) [@code{floor} or @code{ffloor}] command |
The @kbd{F} (@code{calc-floor}) [@code{floor} or @code{ffloor}] command |
16356 |
truncates a real number to the next lower integer, i.e., toward minus |
truncates a real number to the next lower integer, i.e., toward minus |
16357 |
infinity. Thus @kbd{3.6 F} produces 3, but @kbd{_3.6 F} produces |
infinity. Thus @kbd{3.6 F} produces 3, but @kbd{_3.6 F} produces |
16358 |
@i{-4}. |
@mathit{-4}. |
16359 |
|
|
16360 |
@kindex I F |
@kindex I F |
16361 |
@pindex calc-ceiling |
@pindex calc-ceiling |
16367 |
@kindex H I F |
@kindex H I F |
16368 |
The @kbd{I F} (@code{calc-ceiling}) [@code{ceil} or @code{fceil}] |
The @kbd{I F} (@code{calc-ceiling}) [@code{ceil} or @code{fceil}] |
16369 |
command truncates toward positive infinity. Thus @kbd{3.6 I F} produces |
command truncates toward positive infinity. Thus @kbd{3.6 I F} produces |
16370 |
4, and @kbd{_3.6 I F} produces @i{-3}. |
4, and @kbd{_3.6 I F} produces @mathit{-3}. |
16371 |
|
|
16372 |
@kindex R |
@kindex R |
16373 |
@pindex calc-round |
@pindex calc-round |
16381 |
rounds to the nearest integer. When the fractional part is .5 exactly, |
rounds to the nearest integer. When the fractional part is .5 exactly, |
16382 |
this command rounds away from zero. (All other rounding in the |
this command rounds away from zero. (All other rounding in the |
16383 |
Calculator uses this convention as well.) Thus @kbd{3.5 R} produces 4 |
Calculator uses this convention as well.) Thus @kbd{3.5 R} produces 4 |
16384 |
but @kbd{3.4 R} produces 3; @kbd{_3.5 R} produces @i{-4}. |
but @kbd{3.4 R} produces 3; @kbd{_3.5 R} produces @mathit{-4}. |
16385 |
|
|
16386 |
@kindex I R |
@kindex I R |
16387 |
@pindex calc-trunc |
@pindex calc-trunc |
16394 |
The @kbd{I R} (@code{calc-trunc}) [@code{trunc} or @code{ftrunc}] |
The @kbd{I R} (@code{calc-trunc}) [@code{trunc} or @code{ftrunc}] |
16395 |
command truncates toward zero. In other words, it ``chops off'' |
command truncates toward zero. In other words, it ``chops off'' |
16396 |
everything after the decimal point. Thus @kbd{3.6 I R} produces 3 and |
everything after the decimal point. Thus @kbd{3.6 I R} produces 3 and |
16397 |
@kbd{_3.6 I R} produces @i{-3}. |
@kbd{_3.6 I R} produces @mathit{-3}. |
16398 |
|
|
16399 |
These functions may not be applied meaningfully to error forms, but they |
These functions may not be applied meaningfully to error forms, but they |
16400 |
do work for intervals. As a convenience, applying @code{floor} to a |
do work for intervals. As a convenience, applying @code{floor} to a |
16472 |
The @kbd{G} (@code{calc-argument}) [@code{arg}] command computes the |
The @kbd{G} (@code{calc-argument}) [@code{arg}] command computes the |
16473 |
``argument'' or polar angle of a complex number. For a number in polar |
``argument'' or polar angle of a complex number. For a number in polar |
16474 |
notation, this is simply the second component of the pair |
notation, this is simply the second component of the pair |
16475 |
@texline `@t{(}@var{r}@t{;}@tmath{\theta}@t{)}'. |
@texline `@t{(}@var{r}@t{;}@math{\theta}@t{)}'. |
16476 |
@infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}'. |
@infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}'. |
16477 |
The result is expressed according to the current angular mode and will |
The result is expressed according to the current angular mode and will |
16478 |
be in the range @i{-180} degrees (exclusive) to @i{+180} degrees |
be in the range @mathit{-180} degrees (exclusive) to @mathit{+180} degrees |
16479 |
(inclusive), or the equivalent range in radians. |
(inclusive), or the equivalent range in radians. |
16480 |
|
|
16481 |
@pindex calc-imaginary |
@pindex calc-imaginary |
16506 |
@pindex calc-pack |
@pindex calc-pack |
16507 |
The @kbd{v p} (@code{calc-pack}) command can pack the top two numbers on |
The @kbd{v p} (@code{calc-pack}) command can pack the top two numbers on |
16508 |
the stack into a composite object such as a complex number. With |
the stack into a composite object such as a complex number. With |
16509 |
a prefix argument of @i{-1}, it produces a rectangular complex number; |
a prefix argument of @mathit{-1}, it produces a rectangular complex number; |
16510 |
with an argument of @i{-2}, it produces a polar complex number. |
with an argument of @mathit{-2}, it produces a polar complex number. |
16511 |
(Also, @pxref{Building Vectors}.) |
(Also, @pxref{Building Vectors}.) |
16512 |
|
|
16513 |
@ignore |
@ignore |
16631 |
The @kbd{c c} (@code{calc-clean}) [@code{pclean}] command ``cleans'' the |
The @kbd{c c} (@code{calc-clean}) [@code{pclean}] command ``cleans'' the |
16632 |
number on the top of the stack. Floating point numbers are re-rounded |
number on the top of the stack. Floating point numbers are re-rounded |
16633 |
according to the current precision. Polar numbers whose angular |
according to the current precision. Polar numbers whose angular |
16634 |
components have strayed from the @i{-180} to @i{+180} degree range |
components have strayed from the @mathit{-180} to @mathit{+180} degree range |
16635 |
are normalized. (Note that results will be undesirable if the current |
are normalized. (Note that results will be undesirable if the current |
16636 |
angular mode is different from the one under which the number was |
angular mode is different from the one under which the number was |
16637 |
produced!) Integers and fractions are generally unaffected by this |
produced!) Integers and fractions are generally unaffected by this |
16887 |
@var{n} in the range from 1 to 366, @kbd{t Y} computes the |
@var{n} in the range from 1 to 366, @kbd{t Y} computes the |
16888 |
@var{n}th day of the year (366 is treated as 365 in non-leap |
@var{n}th day of the year (366 is treated as 365 in non-leap |
16889 |
years). A prefix argument of 0 computes the last day of the |
years). A prefix argument of 0 computes the last day of the |
16890 |
year (December 31). A negative prefix argument from @i{-1} to |
year (December 31). A negative prefix argument from @mathit{-1} to |
16891 |
@i{-12} computes the first day of the @var{n}th month of the year. |
@mathit{-12} computes the first day of the @var{n}th month of the year. |
16892 |
|
|
16893 |
@kindex t W |
@kindex t W |
16894 |
@pindex calc-new-week |
@pindex calc-new-week |
17257 |
name of a function that is used to compute the daylight savings |
name of a function that is used to compute the daylight savings |
17258 |
adjustment for a given date. The default is |
adjustment for a given date. The default is |
17259 |
@code{math-std-daylight-savings}, which computes an adjustment |
@code{math-std-daylight-savings}, which computes an adjustment |
17260 |
(either 0 or @i{-1}) using the North American rules given above. |
(either 0 or @mathit{-1}) using the North American rules given above. |
17261 |
|
|
17262 |
The daylight savings hook function is called with four arguments: |
The daylight savings hook function is called with four arguments: |
17263 |
The date, as a floating-point number in standard Calc format; |
The date, as a floating-point number in standard Calc format; |
17305 |
@noindent |
@noindent |
17306 |
The @code{bump} parameter is equal to zero when Calc is converting |
The @code{bump} parameter is equal to zero when Calc is converting |
17307 |
from a date form in a generalized time zone into a GMT date value. |
from a date form in a generalized time zone into a GMT date value. |
17308 |
It is @i{-1} when Calc is converting in the other direction. The |
It is @mathit{-1} when Calc is converting in the other direction. The |
17309 |
adjustments shown above ensure that the conversion behaves correctly |
adjustments shown above ensure that the conversion behaves correctly |
17310 |
and reasonably around the 2 a.m.@: transition in each direction. |
and reasonably around the 2 a.m.@: transition in each direction. |
17311 |
|
|
17932 |
|
|
17933 |
If the word size is negative, binary operations produce 2's complement |
If the word size is negative, binary operations produce 2's complement |
17934 |
integers from |
integers from |
17935 |
@texline @tmath{-2^{-w-1}} |
@texline @math{-2^{-w-1}} |
17936 |
@infoline @expr{-(2^(-w-1))} |
@infoline @expr{-(2^(-w-1))} |
17937 |
to |
to |
17938 |
@texline @tmath{2^{-w-1}-1} |
@texline @math{2^{-w-1}-1} |
17939 |
@infoline @expr{2^(-w-1)-1} |
@infoline @expr{2^(-w-1)-1} |
17940 |
inclusive. Either mode accepts inputs in any range; the sign of |
inclusive. Either mode accepts inputs in any range; the sign of |
17941 |
@expr{w} affects only the results produced. |
@expr{w} affects only the results produced. |
17951 |
generally is not ``binary.'' (However, @pxref{Simplification Modes}, |
generally is not ``binary.'' (However, @pxref{Simplification Modes}, |
17952 |
@code{calc-bin-simplify-mode}.) For example, with a word size of 8 |
@code{calc-bin-simplify-mode}.) For example, with a word size of 8 |
17953 |
bits @kbd{b c} converts a number to the range 0 to 255; with a word |
bits @kbd{b c} converts a number to the range 0 to 255; with a word |
17954 |
size of @i{-8} @kbd{b c} converts to the range @i{-128} to 127. |
size of @mathit{-8} @kbd{b c} converts to the range @mathit{-128} to 127. |
17955 |
|
|
17956 |
@kindex b w |
@kindex b w |
17957 |
@pindex calc-word-size |
@pindex calc-word-size |
17967 |
optional second (or third) word-size parameter. When a formula like |
optional second (or third) word-size parameter. When a formula like |
17968 |
@samp{and(a,b)} is finally evaluated, the word size current at that time |
@samp{and(a,b)} is finally evaluated, the word size current at that time |
17969 |
will be used, but when @samp{and(a,b,-8)} is evaluated, a word size of |
will be used, but when @samp{and(a,b,-8)} is evaluated, a word size of |
17970 |
@i{-8} will always be used. A symbolic binary function will be left |
@mathit{-8} will always be used. A symbolic binary function will be left |
17971 |
in symbolic form unless the all of its argument(s) are integers or |
in symbolic form unless the all of its argument(s) are integers or |
17972 |
integer-valued floats. |
integer-valued floats. |
17973 |
|
|
18119 |
the value of @cpi{} (at the current precision) onto the stack. With the |
the value of @cpi{} (at the current precision) onto the stack. With the |
18120 |
Hyperbolic flag, it pushes the value @expr{e}, the base of natural logarithms. |
Hyperbolic flag, it pushes the value @expr{e}, the base of natural logarithms. |
18121 |
With the Inverse flag, it pushes Euler's constant |
With the Inverse flag, it pushes Euler's constant |
18122 |
@texline @tmath{\gamma} |
@texline @math{\gamma} |
18123 |
@infoline @expr{gamma} |
@infoline @expr{gamma} |
18124 |
(about 0.5772). With both Inverse and Hyperbolic, it |
(about 0.5772). With both Inverse and Hyperbolic, it |
18125 |
pushes the ``golden ratio'' |
pushes the ``golden ratio'' |
18126 |
@texline @tmath{\phi} |
@texline @math{\phi} |
18127 |
@infoline @expr{phi} |
@infoline @expr{phi} |
18128 |
(about 1.618). (At present, Euler's constant is not available |
(about 1.618). (At present, Euler's constant is not available |
18129 |
to unlimited precision; Calc knows only the first 100 digits.) |
to unlimited precision; Calc knows only the first 100 digits.) |
18203 |
it raises ten to a given power.) Note that the common logarithm of a |
it raises ten to a given power.) Note that the common logarithm of a |
18204 |
complex number is computed by taking the natural logarithm and dividing |
complex number is computed by taking the natural logarithm and dividing |
18205 |
by |
by |
18206 |
@texline @tmath{\ln10}. |
@texline @math{\ln10}. |
18207 |
@infoline @expr{ln(10)}. |
@infoline @expr{ln(10)}. |
18208 |
|
|
18209 |
@kindex B |
@kindex B |
18213 |
@tindex alog |
@tindex alog |
18214 |
The @kbd{B} (@code{calc-log}) [@code{log}] command computes a logarithm |
The @kbd{B} (@code{calc-log}) [@code{log}] command computes a logarithm |
18215 |
to any base. For example, @kbd{1024 @key{RET} 2 B} produces 10, since |
to any base. For example, @kbd{1024 @key{RET} 2 B} produces 10, since |
18216 |
@texline @tmath{2^{10} = 1024}. |
@texline @math{2^{10} = 1024}. |
18217 |
@infoline @expr{2^10 = 1024}. |
@infoline @expr{2^10 = 1024}. |
18218 |
In certain cases like @samp{log(3,9)}, the result |
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 |
will be either @expr{1:2} or @expr{0.5} depending on the current Fraction |
18235 |
@pindex calc-expm1 |
@pindex calc-expm1 |
18236 |
@tindex expm1 |
@tindex expm1 |
18237 |
The @kbd{f E} (@code{calc-expm1}) [@code{expm1}] command computes |
The @kbd{f E} (@code{calc-expm1}) [@code{expm1}] command computes |
18238 |
@texline @tmath{e^x - 1}, |
@texline @math{e^x - 1}, |
18239 |
@infoline @expr{exp(x)-1}, |
@infoline @expr{exp(x)-1}, |
18240 |
but using an algorithm that produces a more accurate |
but using an algorithm that produces a more accurate |
18241 |
answer when the result is close to zero, i.e., when |
answer when the result is close to zero, i.e., when |
18242 |
@texline @tmath{e^x} |
@texline @math{e^x} |
18243 |
@infoline @expr{exp(x)} |
@infoline @expr{exp(x)} |
18244 |
is close to one. |
is close to one. |
18245 |
|
|
18247 |
@pindex calc-lnp1 |
@pindex calc-lnp1 |
18248 |
@tindex lnp1 |
@tindex lnp1 |
18249 |
The @kbd{f L} (@code{calc-lnp1}) [@code{lnp1}] command computes |
The @kbd{f L} (@code{calc-lnp1}) [@code{lnp1}] command computes |
18250 |
@texline @tmath{\ln(x+1)}, |
@texline @math{\ln(x+1)}, |
18251 |
@infoline @expr{ln(x+1)}, |
@infoline @expr{ln(x+1)}, |
18252 |
producing a more accurate answer when @expr{x} is close to zero. |
producing a more accurate answer when @expr{x} is close to zero. |
18253 |
|
|
18381 |
@tindex arctan2 |
@tindex arctan2 |
18382 |
The @kbd{f T} (@code{calc-arctan2}) [@code{arctan2}] command takes two |
The @kbd{f T} (@code{calc-arctan2}) [@code{arctan2}] command takes two |
18383 |
numbers from the stack and computes the arc tangent of their ratio. The |
numbers from the stack and computes the arc tangent of their ratio. The |
18384 |
result is in the full range from @i{-180} (exclusive) to @i{+180} |
result is in the full range from @mathit{-180} (exclusive) to @mathit{+180} |
18385 |
(inclusive) degrees, or the analogous range in radians. A similar |
(inclusive) degrees, or the analogous range in radians. A similar |
18386 |
result would be obtained with @kbd{/} followed by @kbd{I T}, but the |
result would be obtained with @kbd{/} followed by @kbd{I T}, but the |
18387 |
value would only be in the range from @i{-90} to @i{+90} degrees |
value would only be in the range from @mathit{-90} to @mathit{+90} degrees |
18388 |
since the division loses information about the signs of the two |
since the division loses information about the signs of the two |
18389 |
components, and an error might result from an explicit division by zero |
components, and an error might result from an explicit division by zero |
18390 |
which @code{arctan2} would avoid. By (arbitrary) definition, |
which @code{arctan2} would avoid. By (arbitrary) definition, |
18433 |
factorial function: @samp{gamma(n+1) = fact(n)}. For general complex |
factorial function: @samp{gamma(n+1) = fact(n)}. For general complex |
18434 |
arguments the gamma function can be defined by the following definite |
arguments the gamma function can be defined by the following definite |
18435 |
integral: |
integral: |
18436 |
@texline @tmath{\Gamma(a) = \int_0^\infty t^{a-1} e^t dt}. |
@texline @math{\Gamma(a) = \int_0^\infty t^{a-1} e^t dt}. |
18437 |
@infoline @expr{gamma(a) = integ(t^(a-1) exp(t), t, 0, inf)}. |
@infoline @expr{gamma(a) = integ(t^(a-1) exp(t), t, 0, inf)}. |
18438 |
(The actual implementation uses far more efficient computational methods.) |
(The actual implementation uses far more efficient computational methods.) |
18439 |
|
|
18467 |
The @kbd{f G} (@code{calc-inc-gamma}) [@code{gammaP}] command computes |
The @kbd{f G} (@code{calc-inc-gamma}) [@code{gammaP}] command computes |
18468 |
the incomplete gamma function, denoted @samp{P(a,x)}. This is defined by |
the incomplete gamma function, denoted @samp{P(a,x)}. This is defined by |
18469 |
the integral, |
the integral, |
18470 |
@texline @tmath{P(a,x) = \left( \int_0^x t^{a-1} e^t dt \right) / \Gamma(a)}. |
@texline @math{P(a,x) = \left( \int_0^x t^{a-1} e^t dt \right) / \Gamma(a)}. |
18471 |
@infoline @expr{gammaP(a,x) = integ(t^(a-1) exp(t), t, 0, x) / gamma(a)}. |
@infoline @expr{gammaP(a,x) = integ(t^(a-1) exp(t), t, 0, x) / gamma(a)}. |
18472 |
This implies that @samp{gammaP(a,inf) = 1} for any @expr{a} (see the |
This implies that @samp{gammaP(a,inf) = 1} for any @expr{a} (see the |
18473 |
definition of the normal gamma function). |
definition of the normal gamma function). |
18500 |
@tindex beta |
@tindex beta |
18501 |
The @kbd{f b} (@code{calc-beta}) [@code{beta}] command computes the |
The @kbd{f b} (@code{calc-beta}) [@code{beta}] command computes the |
18502 |
Euler beta function, which is defined in terms of the gamma function as |
Euler beta function, which is defined in terms of the gamma function as |
18503 |
@texline @tmath{B(a,b) = \Gamma(a) \Gamma(b) / \Gamma(a+b)}, |
@texline @math{B(a,b) = \Gamma(a) \Gamma(b) / \Gamma(a+b)}, |
18504 |
@infoline @expr{beta(a,b) = gamma(a) gamma(b) / gamma(a+b)}, |
@infoline @expr{beta(a,b) = gamma(a) gamma(b) / gamma(a+b)}, |
18505 |
or by |
or by |
18506 |
@texline @tmath{B(a,b) = \int_0^1 t^{a-1} (1-t)^{b-1} dt}. |
@texline @math{B(a,b) = \int_0^1 t^{a-1} (1-t)^{b-1} dt}. |
18507 |
@infoline @expr{beta(a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, 1)}. |
@infoline @expr{beta(a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, 1)}. |
18508 |
|
|
18509 |
@kindex f B |
@kindex f B |
18513 |
@tindex betaB |
@tindex betaB |
18514 |
The @kbd{f B} (@code{calc-inc-beta}) [@code{betaI}] command computes |
The @kbd{f B} (@code{calc-inc-beta}) [@code{betaI}] command computes |
18515 |
the incomplete beta function @expr{I(x,a,b)}. It is defined by |
the incomplete beta function @expr{I(x,a,b)}. It is defined by |
18516 |
@texline @tmath{I(x,a,b) = \left( \int_0^x t^{a-1} (1-t)^{b-1} dt \right) / B(a,b)}. |
@texline @math{I(x,a,b) = \left( \int_0^x t^{a-1} (1-t)^{b-1} dt \right) / B(a,b)}. |
18517 |
@infoline @expr{betaI(x,a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, x) / beta(a,b)}. |
@infoline @expr{betaI(x,a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, x) / beta(a,b)}. |
18518 |
Once again, the @kbd{H} (hyperbolic) prefix gives the corresponding |
Once again, the @kbd{H} (hyperbolic) prefix gives the corresponding |
18519 |
un-normalized version [@code{betaB}]. |
un-normalized version [@code{betaB}]. |
18525 |
@tindex erfc |
@tindex erfc |
18526 |
The @kbd{f e} (@code{calc-erf}) [@code{erf}] command computes the |
The @kbd{f e} (@code{calc-erf}) [@code{erf}] command computes the |
18527 |
error function |
error function |
18528 |
@texline @tmath{\hbox{erf}(x) = {2 \over \sqrt{\pi}} \int_0^x e^{-t^2} dt}. |
@texline @math{\hbox{erf}(x) = {2 \over \sqrt{\pi}} \int_0^x e^{-t^2} dt}. |
18529 |
@infoline @expr{erf(x) = 2 integ(exp(-(t^2)), t, 0, x) / sqrt(pi)}. |
@infoline @expr{erf(x) = 2 integ(exp(-(t^2)), t, 0, x) / sqrt(pi)}. |
18530 |
The complementary error function @kbd{I f e} (@code{calc-erfc}) [@code{erfc}] |
The complementary error function @kbd{I f e} (@code{calc-erfc}) [@code{erfc}] |
18531 |
is the corresponding integral from @samp{x} to infinity; the sum |
is the corresponding integral from @samp{x} to infinity; the sum |
18532 |
@texline @tmath{\hbox{erf}(x) + \hbox{erfc}(x) = 1}. |
@texline @math{\hbox{erf}(x) + \hbox{erfc}(x) = 1}. |
18533 |
@infoline @expr{erf(x) + erfc(x) = 1}. |
@infoline @expr{erf(x) + erfc(x) = 1}. |
18534 |
|
|
18535 |
@kindex f j |
@kindex f j |
18605 |
|
|
18606 |
For @samp{z1^z2}: This is defined by @samp{exp(ln(z1)*z2)}. |
For @samp{z1^z2}: This is defined by @samp{exp(ln(z1)*z2)}. |
18607 |
One interesting consequence of this is that @samp{(-8)^1:3} does |
One interesting consequence of this is that @samp{(-8)^1:3} does |
18608 |
not evaluate to @i{-2} as you might expect, but to the complex |
not evaluate to @mathit{-2} as you might expect, but to the complex |
18609 |
number @expr{(1., 1.732)}. Both of these are valid cube roots |
number @expr{(1., 1.732)}. Both of these are valid cube roots |
18610 |
of @i{-8} (as is @expr{(1., -1.732)}); Calc chooses a perhaps |
of @mathit{-8} (as is @expr{(1., -1.732)}); Calc chooses a perhaps |
18611 |
less-obvious root for the sake of mathematical consistency. |
less-obvious root for the sake of mathematical consistency. |
18612 |
|
|
18613 |
For @samp{arcsin(z)}: This is defined by @samp{-i*ln(i*z + sqrt(1-z^2))}. |
For @samp{arcsin(z)}: This is defined by @samp{-i*ln(i*z + sqrt(1-z^2))}. |
18614 |
The branch cuts are on the real axis, less than @i{-1} and greater than 1. |
The branch cuts are on the real axis, less than @mathit{-1} and greater than 1. |
18615 |
|
|
18616 |
For @samp{arccos(z)}: This is defined by @samp{-i*ln(z + i*sqrt(1-z^2))}, |
For @samp{arccos(z)}: This is defined by @samp{-i*ln(z + i*sqrt(1-z^2))}, |
18617 |
or equivalently by @samp{pi/2 - arcsin(z)}. The branch cuts are on |
or equivalently by @samp{pi/2 - arcsin(z)}. The branch cuts are on |
18618 |
the real axis, less than @i{-1} and greater than 1. |
the real axis, less than @mathit{-1} and greater than 1. |
18619 |
|
|
18620 |
For @samp{arctan(z)}: This is defined by |
For @samp{arctan(z)}: This is defined by |
18621 |
@samp{(ln(1+i*z) - ln(1-i*z)) / (2*i)}. The branch cuts are on the |
@samp{(ln(1+i*z) - ln(1-i*z)) / (2*i)}. The branch cuts are on the |
18630 |
real axis less than 1. |
real axis less than 1. |
18631 |
|
|
18632 |
For @samp{arctanh(z)}: This is defined by @samp{(ln(1+z) - ln(1-z)) / 2}. |
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 @i{-1} and greater than 1. |
The branch cuts are on the real axis, less than @mathit{-1} and greater than 1. |
18634 |
|
|
18635 |
The following tables for @code{arcsin}, @code{arccos}, and |
The following tables for @code{arcsin}, @code{arccos}, and |
18636 |
@code{arctan} assume the current angular mode is radians. The |
@code{arctan} assume the current angular mode is radians. The |
18703 |
|
|
18704 |
Given a positive numeric prefix argument @expr{M}, it produces a random |
Given a positive numeric prefix argument @expr{M}, it produces a random |
18705 |
integer @expr{N} in the range |
integer @expr{N} in the range |
18706 |
@texline @tmath{0 \le N < M}. |
@texline @math{0 \le N < M}. |
18707 |
@infoline @expr{0 <= N < M}. |
@infoline @expr{0 <= N < M}. |
18708 |
Each of the @expr{M} values appears with equal probability. |
Each of the @expr{M} values appears with equal probability. |
18709 |
|
|
18713 |
while numeric prefix arguments are limited to six digits or so, an @expr{M} |
while numeric prefix arguments are limited to six digits or so, an @expr{M} |
18714 |
taken from the stack can be arbitrarily large. If @expr{M} is negative, |
taken from the stack can be arbitrarily large. If @expr{M} is negative, |
18715 |
the result is a random integer in the range |
the result is a random integer in the range |
18716 |
@texline @tmath{M < N \le 0}. |
@texline @math{M < N \le 0}. |
18717 |
@infoline @expr{M < N <= 0}. |
@infoline @expr{M < N <= 0}. |
18718 |
|
|
18719 |
If the value on the stack is a floating-point number @expr{M}, the result |
If the value on the stack is a floating-point number @expr{M}, the result |
18720 |
is a random floating-point number @expr{N} in the range |
is a random floating-point number @expr{N} in the range |
18721 |
@texline @tmath{0 \le N < M} |
@texline @math{0 \le N < M} |
18722 |
@infoline @expr{0 <= N < M} |
@infoline @expr{0 <= N < M} |
18723 |
or |
or |
18724 |
@texline @tmath{M < N \le 0}, |
@texline @math{M < N \le 0}, |
18725 |
@infoline @expr{M < N <= 0}, |
@infoline @expr{M < N <= 0}, |
18726 |
according to the sign of @expr{M}. |
according to the sign of @expr{M}. |
18727 |
|
|
18731 |
every other call to this function will be especially fast. |
every other call to this function will be especially fast. |
18732 |
|
|
18733 |
If @expr{M} is an error form |
If @expr{M} is an error form |
18734 |
@texline @tmath{m} @code{+/-} @tmath{\sigma} |
@texline @math{m} @code{+/-} @math{\sigma} |
18735 |
@infoline @samp{m +/- s} |
@infoline @samp{m +/- s} |
18736 |
where @var{m} and |
where @var{m} and |
18737 |
@texline @tmath{\sigma} |
@texline @math{\sigma} |
18738 |
@infoline @var{s} |
@infoline @var{s} |
18739 |
are both real numbers, the result uses a Gaussian distribution with mean |
are both real numbers, the result uses a Gaussian distribution with mean |
18740 |
@var{m} and standard deviation |
@var{m} and standard deviation |
18741 |
@texline @tmath{\sigma}. |
@texline @math{\sigma}. |
18742 |
@var{s}. |
@var{s}. |
18743 |
|
|
18744 |
If @expr{M} is an interval form, the lower and upper bounds specify the |
If @expr{M} is an interval form, the lower and upper bounds specify the |
18851 |
If @code{RandSeed} contains an integer, Calc uses this integer to |
If @code{RandSeed} contains an integer, Calc uses this integer to |
18852 |
seed an ``additive congruential'' method (Knuth's algorithm 3.2.2A, |
seed an ``additive congruential'' method (Knuth's algorithm 3.2.2A, |
18853 |
computing |
computing |
18854 |
@texline @tmath{X_{n-55} - X_{n-24}}. |
@texline @math{X_{n-55} - X_{n-24}}. |
18855 |
@infoline @expr{X_n-55 - X_n-24}). |
@infoline @expr{X_n-55 - X_n-24}). |
18856 |
This method expands the seed |
This method expands the seed |
18857 |
value into a large table which is maintained internally; the variable |
value into a large table which is maintained internally; the variable |
18887 |
|
|
18888 |
To create a random floating-point number with precision @var{p}, Calc |
To create a random floating-point number with precision @var{p}, Calc |
18889 |
simply creates a random @var{p}-digit integer and multiplies by |
simply creates a random @var{p}-digit integer and multiplies by |
18890 |
@texline @tmath{10^{-p}}. |
@texline @math{10^{-p}}. |
18891 |
@infoline @expr{10^-p}. |
@infoline @expr{10^-p}. |
18892 |
The resulting random numbers should be very clean, but note |
The resulting random numbers should be very clean, but note |
18893 |
that relatively small numbers will have few significant random digits. |
that relatively small numbers will have few significant random digits. |
18894 |
In other words, with a precision of 12, you will occasionally get |
In other words, with a precision of 12, you will occasionally get |
18895 |
numbers on the order of |
numbers on the order of |
18896 |
@texline @tmath{10^{-9}} |
@texline @math{10^{-9}} |
18897 |
@infoline @expr{10^-9} |
@infoline @expr{10^-9} |
18898 |
or |
or |
18899 |
@texline @tmath{10^{-10}}, |
@texline @math{10^{-10}}, |
18900 |
@infoline @expr{10^-10}, |
@infoline @expr{10^-10}, |
18901 |
but those numbers will only have two or three random digits since they |
but those numbers will only have two or three random digits since they |
18902 |
correspond to small integers times |
correspond to small integers times |
18903 |
@texline @tmath{10^{-12}}. |
@texline @math{10^{-12}}. |
18904 |
@infoline @expr{10^-12}. |
@infoline @expr{10^-12}. |
18905 |
|
|
18906 |
To create a random integer in the interval @samp{[0 .. @var{m})}, Calc |
To create a random integer in the interval @samp{[0 .. @var{m})}, Calc |
18951 |
The @kbd{k E} (@code{calc-extended-gcd}) [@code{egcd}] command computes |
The @kbd{k E} (@code{calc-extended-gcd}) [@code{egcd}] command computes |
18952 |
the GCD of two integers @expr{x} and @expr{y} and returns a vector |
the GCD of two integers @expr{x} and @expr{y} and returns a vector |
18953 |
@expr{[g, a, b]} where |
@expr{[g, a, b]} where |
18954 |
@texline @tmath{g = \gcd(x,y) = a x + b y}. |
@texline @math{g = \gcd(x,y) = a x + b y}. |
18955 |
@infoline @expr{g = gcd(x,y) = a x + b y}. |
@infoline @expr{g = gcd(x,y) = a x + b y}. |
18956 |
|
|
18957 |
@kindex ! |
@kindex ! |
18995 |
are integers, the result is an exact integer. Otherwise, the result is a |
are integers, the result is an exact integer. Otherwise, the result is a |
18996 |
floating-point approximation. The binomial coefficient is defined for all |
floating-point approximation. The binomial coefficient is defined for all |
18997 |
real numbers by |
real numbers by |
18998 |
@texline @tmath{N! \over M! (N-M)!\,}. |
@texline @math{N! \over M! (N-M)!\,}. |
18999 |
@infoline @expr{N! / M! (N-M)!}. |
@infoline @expr{N! / M! (N-M)!}. |
19000 |
|
|
19001 |
@kindex H k c |
@kindex H k c |
19038 |
@tindex stir2 |
@tindex stir2 |
19039 |
The @kbd{k s} (@code{calc-stirling-number}) [@code{stir1}] command |
The @kbd{k s} (@code{calc-stirling-number}) [@code{stir1}] command |
19040 |
computes a Stirling number of the first |
computes a Stirling number of the first |
19041 |
@texline kind@tie{}@tmath{n \brack m}, |
@texline kind@tie{}@math{n \brack m}, |
19042 |
@infoline kind, |
@infoline kind, |
19043 |
given two integers @expr{n} and @expr{m} on the stack. The @kbd{H k s} |
given two integers @expr{n} and @expr{m} on the stack. The @kbd{H k s} |
19044 |
[@code{stir2}] command computes a Stirling number of the second |
[@code{stir2}] command computes a Stirling number of the second |
19045 |
@texline kind@tie{}@tmath{n \brace m}. |
@texline kind@tie{}@math{n \brace m}. |
19046 |
@infoline kind. |
@infoline kind. |
19047 |
These are the number of @expr{m}-cycle permutations of @expr{n} objects, |
These are the number of @expr{m}-cycle permutations of @expr{n} objects, |
19048 |
and the number of ways to partition @expr{n} objects into @expr{m} |
and the number of ways to partition @expr{n} objects into @expr{m} |
19086 |
inputs, prime factors above 5000 may not be found, in which case the |
inputs, prime factors above 5000 may not be found, in which case the |
19087 |
last number in the vector will be an unfactored integer greater than 25 |
last number in the vector will be an unfactored integer greater than 25 |
19088 |
million (with a warning message). For negative integers, the first |
million (with a warning message). For negative integers, the first |
19089 |
element of the list will be @i{-1}. For inputs @i{-1}, @i{0}, and |
element of the list will be @mathit{-1}. For inputs @mathit{-1}, @mathit{0}, and |
19090 |
@i{1}, the result is a list of the same number. |
@mathit{1}, the result is a list of the same number. |
19091 |
|
|
19092 |
@kindex k n |
@kindex k n |
19093 |
@pindex calc-next-prime |
@pindex calc-next-prime |
19121 |
@tindex totient |
@tindex totient |
19122 |
The @kbd{k t} (@code{calc-totient}) [@code{totient}] command computes the |
The @kbd{k t} (@code{calc-totient}) [@code{totient}] command computes the |
19123 |
Euler ``totient'' |
Euler ``totient'' |
19124 |
@texline function@tie{}@tmath{\phi(n)}, |
@texline function@tie{}@math{\phi(n)}, |
19125 |
@infoline function, |
@infoline function, |
19126 |
the number of integers less than @expr{n} which |
the number of integers less than @expr{n} which |
19127 |
are relatively prime to @expr{n}. |
are relatively prime to @expr{n}. |
19130 |
@pindex calc-moebius |
@pindex calc-moebius |
19131 |
@tindex moebius |
@tindex moebius |
19132 |
The @kbd{k m} (@code{calc-moebius}) [@code{moebius}] command computes the |
The @kbd{k m} (@code{calc-moebius}) [@code{moebius}] command computes the |
19133 |
@texline M@"obius @tmath{\mu} |
@texline M@"obius @math{\mu} |
19134 |
@infoline Moebius ``mu'' |
@infoline Moebius ``mu'' |
19135 |
function. If the input number is a product of @expr{k} |
function. If the input number is a product of @expr{k} |
19136 |
distinct factors, this is @expr{(-1)^k}. If the input number has any |
distinct factors, this is @expr{(-1)^k}. If the input number has any |
19194 |
@end ignore |
@end ignore |
19195 |
@tindex ltpc |
@tindex ltpc |
19196 |
The @samp{utpc(x,v)} function uses the chi-square distribution with |
The @samp{utpc(x,v)} function uses the chi-square distribution with |
19197 |
@texline @tmath{\nu} |
@texline @math{\nu} |
19198 |
@infoline @expr{v} |
@infoline @expr{v} |
19199 |
degrees of freedom. It is the probability that a model is |
degrees of freedom. It is the probability that a model is |
19200 |
correct if its chi-square statistic is @expr{x}. |
correct if its chi-square statistic is @expr{x}. |
19212 |
@tindex ltpf |
@tindex ltpf |
19213 |
The @samp{utpf(F,v1,v2)} function uses the F distribution, used in |
The @samp{utpf(F,v1,v2)} function uses the F distribution, used in |
19214 |
various statistical tests. The parameters |
various statistical tests. The parameters |
19215 |
@texline @tmath{\nu_1} |
@texline @math{\nu_1} |
19216 |
@infoline @expr{v1} |
@infoline @expr{v1} |
19217 |
and |
and |
19218 |
@texline @tmath{\nu_2} |
@texline @math{\nu_2} |
19219 |
@infoline @expr{v2} |
@infoline @expr{v2} |
19220 |
are the degrees of freedom in the numerator and denominator, |
are the degrees of freedom in the numerator and denominator, |
19221 |
respectively, used in computing the statistic @expr{F}. |
respectively, used in computing the statistic @expr{F}. |
19233 |
@tindex ltpn |
@tindex ltpn |
19234 |
The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution |
The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution |
19235 |
with mean @expr{m} and standard deviation |
with mean @expr{m} and standard deviation |
19236 |
@texline @tmath{\sigma}. |
@texline @math{\sigma}. |
19237 |
@infoline @expr{s}. |
@infoline @expr{s}. |
19238 |
It is the probability that such a normal-distributed random variable |
It is the probability that such a normal-distributed random variable |
19239 |
would exceed @expr{x}. |
would exceed @expr{x}. |
19266 |
@tindex ltpt |
@tindex ltpt |
19267 |
The @samp{utpt(t,v)} function uses the Student's ``t'' distribution |
The @samp{utpt(t,v)} function uses the Student's ``t'' distribution |
19268 |
with |
with |
19269 |
@texline @tmath{\nu} |
@texline @math{\nu} |
19270 |
@infoline @expr{v} |
@infoline @expr{v} |
19271 |
degrees of freedom. It is the probability that a |
degrees of freedom. It is the probability that a |
19272 |
t-distributed random variable will be greater than @expr{t}. |
t-distributed random variable will be greater than @expr{t}. |
19273 |
(Note: This computes the distribution function |
(Note: This computes the distribution function |
19274 |
@texline @tmath{A(t|\nu)} |
@texline @math{A(t|\nu)} |
19275 |
@infoline @expr{A(t|v)} |
@infoline @expr{A(t|v)} |
19276 |
where |
where |
19277 |
@texline @tmath{A(0|\nu) = 1} |
@texline @math{A(0|\nu) = 1} |
19278 |
@infoline @expr{A(0|v) = 1} |
@infoline @expr{A(0|v) = 1} |
19279 |
and |
and |
19280 |
@texline @tmath{A(\infty|\nu) \to 0}. |
@texline @math{A(\infty|\nu) \to 0}. |
19281 |
@infoline @expr{A(inf|v) -> 0}. |
@infoline @expr{A(inf|v) -> 0}. |
19282 |
The @code{UTPT} operation on the HP-48 uses a different definition which |
The @code{UTPT} operation on the HP-48 uses a different definition which |
19283 |
returns half of Calc's value: @samp{UTPT(t,v) = .5*utpt(t,v)}.) |
returns half of Calc's value: @samp{UTPT(t,v) = .5*utpt(t,v)}.) |
19397 |
times ten to the power of the exponent. |
times ten to the power of the exponent. |
19398 |
|
|
19399 |
@item -12 |
@item -12 |
19400 |
This is treated the same as @i{-11} by the @kbd{v p} command. |
This is treated the same as @mathit{-11} by the @kbd{v p} command. |
19401 |
When unpacking, @i{-12} specifies that a floating-point mantissa |
When unpacking, @mathit{-12} specifies that a floating-point mantissa |
19402 |
is desired. |
is desired. |
19403 |
|
|
19404 |
@item -13 |
@item -13 |
19437 |
If any elements of the vector are negative, other kinds of |
If any elements of the vector are negative, other kinds of |
19438 |
packing are done at that level as described above. For |
packing are done at that level as described above. For |
19439 |
example, @samp{[2, 3, -4]} takes 12 objects and creates a |
example, @samp{[2, 3, -4]} takes 12 objects and creates a |
19440 |
@texline @tmath{2\times3} |
@texline @math{2\times3} |
19441 |
@infoline 2x3 |
@infoline 2x3 |
19442 |
matrix of error forms: @samp{[[a +/- b, c +/- d ... ]]}. |
matrix of error forms: @samp{[[a +/- b, c +/- d ... ]]}. |
19443 |
Also, @samp{[-4, -10]} will convert four integers into an |
Also, @samp{[-4, -10]} will convert four integers into an |
19475 |
@samp{[a, c^2, d]} and @w{@samp{[b, 0, 7]}}. |
@samp{[a, c^2, d]} and @w{@samp{[b, 0, 7]}}. |
19476 |
|
|
19477 |
Note that the prefix argument can have an effect even when the input is |
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 @i{-5}, then |
not a vector. For example, if the input is the number @mathit{-5}, then |
19479 |
@kbd{c-u -1 v u} yields @i{-5} and 0 (the components of @i{-5} |
@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 |
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 @i{-5} |
and 180 (assuming degrees mode); and @kbd{C-u -10 v u} yields @mathit{-5} |
19482 |
and 1 (the numerator and denominator of @i{-5}, viewed as a rational |
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 |
number). Plain @kbd{v u} with this input would complain that the input |
19484 |
is not a composite object. |
is not a composite object. |
19485 |
|
|
19486 |
Unpacking mode @i{-11} converts a float into an integer mantissa and |
Unpacking mode @mathit{-11} converts a float into an integer mantissa and |
19487 |
an integer exponent, where the mantissa is not divisible by 10 |
an integer exponent, where the mantissa is not divisible by 10 |
19488 |
(except that 0.0 is represented by a mantissa and exponent of 0). |
(except that 0.0 is represented by a mantissa and exponent of 0). |
19489 |
Unpacking mode @i{-12} converts a float into a floating-point mantissa |
Unpacking mode @mathit{-12} converts a float into a floating-point mantissa |
19490 |
and integer exponent, where the mantissa (for non-zero numbers) |
and integer exponent, where the mantissa (for non-zero numbers) |
19491 |
is guaranteed to lie in the range [1 .. 10). In both cases, |
is guaranteed to lie in the range [1 .. 10). In both cases, |
19492 |
the mantissa is shifted left or right (and the exponent adjusted |
the mantissa is shifted left or right (and the exponent adjusted |
19586 |
the prefix argument is required. |
the prefix argument is required. |
19587 |
|
|
19588 |
To build a constant square matrix, e.g., a |
To build a constant square matrix, e.g., a |
19589 |
@texline @tmath{3\times3} |
@texline @math{3\times3} |
19590 |
@infoline 3x3 |
@infoline 3x3 |
19591 |
matrix filled with ones, use @kbd{0 M-3 v d 1 +}, i.e., build a zero |
matrix filled with ones, use @kbd{0 M-3 v d 1 +}, i.e., build a zero |
19592 |
matrix first and then add a constant value to that matrix. (Another |
matrix first and then add a constant value to that matrix. (Another |
19619 |
of consecutive integers from 1 to @var{n}, where @var{n} is the numeric |
of consecutive integers from 1 to @var{n}, where @var{n} is the numeric |
19620 |
prefix argument. If you do not provide a prefix argument, you will be |
prefix argument. If you do not provide a prefix argument, you will be |
19621 |
prompted to enter a suitable number. If @var{n} is negative, the result |
prompted to enter a suitable number. If @var{n} is negative, the result |
19622 |
is a vector of negative integers from @var{n} to @i{-1}. |
is a vector of negative integers from @var{n} to @mathit{-1}. |
19623 |
|
|
19624 |
With a prefix argument of just @kbd{C-u}, the @kbd{v x} command takes |
With a prefix argument of just @kbd{C-u}, the @kbd{v x} command takes |
19625 |
three values from the stack: @var{n}, @var{start}, and @var{incr} (with |
three values from the stack: @var{n}, @var{start}, and @var{incr} (with |
19812 |
of the dimensions of a vector, matrix, or higher-order object. For |
of the dimensions of a vector, matrix, or higher-order object. For |
19813 |
example, @samp{mdims([[a,b,c],[d,e,f]])} returns @samp{[2, 3]} since |
example, @samp{mdims([[a,b,c],[d,e,f]])} returns @samp{[2, 3]} since |
19814 |
its argument is a |
its argument is a |
19815 |
@texline @tmath{2\times3} |
@texline @math{2\times3} |
19816 |
@infoline 2x3 |
@infoline 2x3 |
19817 |
matrix. |
matrix. |
19818 |
|
|
19844 |
suitable for use as a matrix. For example, with the matrix |
suitable for use as a matrix. For example, with the matrix |
19845 |
@samp{[[1, 2], @w{[3, 4]}]} on the stack, @kbd{v a 4} produces |
@samp{[[1, 2], @w{[3, 4]}]} on the stack, @kbd{v a 4} produces |
19846 |
@samp{[[1, 2, 3, 4]]} (a |
@samp{[[1, 2, 3, 4]]} (a |
19847 |
@texline @tmath{1\times4} |
@texline @math{1\times4} |
19848 |
@infoline 1x4 |
@infoline 1x4 |
19849 |
matrix), @kbd{v a 1} produces @samp{[[1], [2], [3], [4]]} (a |
matrix), @kbd{v a 1} produces @samp{[[1], [2], [3], [4]]} (a |
19850 |
@texline @tmath{4\times1} |
@texline @math{4\times1} |
19851 |
@infoline 4x1 |
@infoline 4x1 |
19852 |
matrix), @kbd{v a 2} produces @samp{[[1, 2], [3, 4]]} (the original |
matrix), @kbd{v a 2} produces @samp{[[1, 2], [3, 4]]} (the original |
19853 |
@texline @tmath{2\times2} |
@texline @math{2\times2} |
19854 |
@infoline 2x2 |
@infoline 2x2 |
19855 |
matrix), @w{@kbd{v a 3}} produces @samp{[[1, 2, 3], [4]]} (not a |
matrix), @w{@kbd{v a 3}} produces @samp{[[1, 2, 3], [4]]} (not a |
19856 |
matrix), and @kbd{v a 0} produces the flattened list |
matrix), and @kbd{v a 0} produces the flattened list |
20170 |
will be the empty vector @samp{[]}. Note that the characters @kbd{V} |
will be the empty vector @samp{[]}. Note that the characters @kbd{V} |
20171 |
and @kbd{^} were chosen to be close to the conventional mathematical |
and @kbd{^} were chosen to be close to the conventional mathematical |
20172 |
notation for set |
notation for set |
20173 |
@texline union@tie{}(@tmath{A \cup B}) |
@texline union@tie{}(@math{A \cup B}) |
20174 |
@infoline union |
@infoline union |
20175 |
and |
and |
20176 |
@texline intersection@tie{}(@tmath{A \cap B}). |
@texline intersection@tie{}(@math{A \cap B}). |
20177 |
@infoline intersection. |
@infoline intersection. |
20178 |
|
|
20179 |
@kindex V - |
@kindex V - |
20282 |
set of integers in the sense of @kbd{V F} (@code{vfloor}). Beware |
set of integers in the sense of @kbd{V F} (@code{vfloor}). Beware |
20283 |
that a simple input like @samp{[100]} can result in a huge integer |
that a simple input like @samp{[100]} can result in a huge integer |
20284 |
representation |
representation |
20285 |
@texline (@tmath{2^{100}}, a 31-digit integer, in this case). |
@texline (@math{2^{100}}, a 31-digit integer, in this case). |
20286 |
@infoline (@expr{2^100}, a 31-digit integer, in this case). |
@infoline (@expr{2^100}, a 31-digit integer, in this case). |
20287 |
|
|
20288 |
@node Statistical Operations, Reducing and Mapping, Set Operations, Matrix Functions |
@node Statistical Operations, Reducing and Mapping, Set Operations, Matrix Functions |
20394 |
The @kbd{u M} (@code{calc-vector-mean}) [@code{vmean}] command |
The @kbd{u M} (@code{calc-vector-mean}) [@code{vmean}] command |
20395 |
computes the average (arithmetic mean) of the data values. |
computes the average (arithmetic mean) of the data values. |
20396 |
If the inputs are error forms |
If the inputs are error forms |
20397 |
@texline @tmath{x \pm \sigma}, |
@texline @math{x \pm \sigma}, |
20398 |
@infoline @samp{x +/- s}, |
@infoline @samp{x +/- s}, |
20399 |
this is the weighted mean of the @expr{x} values with weights |
this is the weighted mean of the @expr{x} values with weights |
20400 |
@texline @tmath{1 /\sigma^2}. |
@texline @math{1 /\sigma^2}. |
20401 |
@infoline @expr{1 / s^2}. |
@infoline @expr{1 / s^2}. |
20402 |
@tex |
@tex |
20403 |
\turnoffactive |
\turnoffactive |
20409 |
|
|
20410 |
Note that a plain number can be considered an error form with |
Note that a plain number can be considered an error form with |
20411 |
error |
error |
20412 |
@texline @tmath{\sigma = 0}. |
@texline @math{\sigma = 0}. |
20413 |
@infoline @expr{s = 0}. |
@infoline @expr{s = 0}. |
20414 |
If the input to @kbd{u M} is a mixture of |
If the input to @kbd{u M} is a mixture of |
20415 |
plain numbers and error forms, the result is the mean of the |
plain numbers and error forms, the result is the mean of the |
20518 |
@cindex Sample statistics |
@cindex Sample statistics |
20519 |
The @kbd{u S} (@code{calc-vector-sdev}) [@code{vsdev}] command |
The @kbd{u S} (@code{calc-vector-sdev}) [@code{vsdev}] command |
20520 |
computes the standard |
computes the standard |
20521 |
@texline deviation@tie{}@tmath{\sigma} |
@texline deviation@tie{}@math{\sigma} |
20522 |
@infoline deviation |
@infoline deviation |
20523 |
of the data values. If the values are error forms, the errors are used |
of the data values. If the values are error forms, the errors are used |
20524 |
as weights just as for @kbd{u M}. This is the @emph{sample} standard |
as weights just as for @kbd{u M}. This is the @emph{sample} standard |
20534 |
of a single error form is simply the error part. The standard deviation |
of a single error form is simply the error part. The standard deviation |
20535 |
of a continuous interval happens to equal the difference between the |
of a continuous interval happens to equal the difference between the |
20536 |
limits, divided by |
limits, divided by |
20537 |
@texline @tmath{\sqrt{12}}. |
@texline @math{\sqrt{12}}. |
20538 |
@infoline @expr{sqrt(12)}. |
@infoline @expr{sqrt(12)}. |
20539 |
The standard deviation of an integer interval is the same as the |
The standard deviation of an integer interval is the same as the |
20540 |
standard deviation of a vector of those integers. |
standard deviation of a vector of those integers. |
20572 |
@kbd{H I u S} (@code{calc-vector-pop-variance}) [@code{vpvar}] |
@kbd{H I u S} (@code{calc-vector-pop-variance}) [@code{vpvar}] |
20573 |
commands compute the variance of the data values. The variance |
commands compute the variance of the data values. The variance |
20574 |
is the |
is the |
20575 |
@texline square@tie{}@tmath{\sigma^2} |
@texline square@tie{}@math{\sigma^2} |
20576 |
@infoline square |
@infoline square |
20577 |
of the standard deviation, i.e., the sum of the |
of the standard deviation, i.e., the sum of the |
20578 |
squares of the deviations of the data values from the mean. |
squares of the deviations of the data values from the mean. |
20596 |
way as by the single-variable statistical functions. Given a numeric |
way as by the single-variable statistical functions. Given a numeric |
20597 |
prefix argument of 1, these functions instead take one object from |
prefix argument of 1, these functions instead take one object from |
20598 |
the stack, which must be an |
the stack, which must be an |
20599 |
@texline @tmath{N\times2} |
@texline @math{N\times2} |
20600 |
@infoline Nx2 |
@infoline Nx2 |
20601 |
matrix of data values. Once again, variable names can be used in place |
matrix of data values. Once again, variable names can be used in place |
20602 |
of actual vectors and matrices. |
of actual vectors and matrices. |
20854 |
across all elements of the matrix. For example, given the matrix |
across all elements of the matrix. For example, given the matrix |
20855 |
@expr{[[1, -2, 3], [-4, 5, -6]]}, @kbd{V M A} takes six absolute values to |
@expr{[[1, -2, 3], [-4, 5, -6]]}, @kbd{V M A} takes six absolute values to |
20856 |
produce another |
produce another |
20857 |
@texline @tmath{3\times2} |
@texline @math{3\times2} |
20858 |
@infoline 3x2 |
@infoline 3x2 |
20859 |
matrix, @expr{[[1, 2, 3], [4, 5, 6]]}. |
matrix, @expr{[[1, 2, 3], [4, 5, 6]]}. |
20860 |
|
|
22007 |
@kbd{a s}; @pxref{Simplifying Formulas}. If you give a numeric prefix |
@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}). |
of 3 or more, it uses extended simplification mode (@kbd{a e}). |
22009 |
|
|
22010 |
If you give a negative prefix argument @i{-1}, @i{-2}, or @i{-3}, |
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 |
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 |
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 |
simplify to @samp{(2 + 3)^2}, without simplifying the sub-formulas |
22279 |
|
|
22280 |
The distributive law is used to simplify sums in some cases: |
The distributive law is used to simplify sums in some cases: |
22281 |
@expr{a x + b x} to @expr{(a + b) x}, where @expr{a} represents |
@expr{a x + b x} to @expr{(a + b) x}, where @expr{a} represents |
22282 |
a number or an implicit 1 or @i{-1} (as in @expr{x} or @expr{-x}) |
a number or an implicit 1 or @mathit{-1} (as in @expr{x} or @expr{-x}) |
22283 |
and similarly for @expr{b}. Use the @kbd{a c}, @w{@kbd{a f}}, or |
and similarly for @expr{b}. Use the @kbd{a c}, @w{@kbd{a f}}, or |
22284 |
@kbd{j M} commands to merge sums with non-numeric coefficients |
@kbd{j M} commands to merge sums with non-numeric coefficients |
22285 |
using the distributive law. |
using the distributive law. |
22323 |
|
|
22324 |
The distributive law of products and powers is used for adjacent |
The distributive law of products and powers is used for adjacent |
22325 |
terms of the product: @expr{x^a x^b} goes to |
terms of the product: @expr{x^a x^b} goes to |
22326 |
@texline @tmath{x^{a+b}} |
@texline @math{x^{a+b}} |
22327 |
@infoline @expr{x^(a+b)} |
@infoline @expr{x^(a+b)} |
22328 |
where @expr{a} is a number, or an implicit 1 (as in @expr{x}), |
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 |
or the implicit one-half of @expr{@t{sqrt}(x)}, and similarly for |
22334 |
|
|
22335 |
The product of a negative power times anything but another negative |
The product of a negative power times anything but another negative |
22336 |
power is changed to use division: |
power is changed to use division: |
22337 |
@texline @tmath{x^{-2} y} |
@texline @math{x^{-2} y} |
22338 |
@infoline @expr{x^(-2) y} |
@infoline @expr{x^(-2) y} |
22339 |
goes to @expr{y / x^2} unless matrix mode is |
goes to @expr{y / x^2} unless matrix mode is |
22340 |
in effect and neither @expr{x} nor @expr{y} are scalar (in which |
in effect and neither @expr{x} nor @expr{y} are scalar (in which |
22358 |
@xref{Infinite Mode}. |
@xref{Infinite Mode}. |
22359 |
|
|
22360 |
The expression |
The expression |
22361 |
@texline @tmath{a / b^{-c}} |
@texline @math{a / b^{-c}} |
22362 |
@infoline @expr{a / b^(-c)} |
@infoline @expr{a / b^(-c)} |
22363 |
is changed to @expr{a b^c}, where @expr{-c} is any negative-looking |
is changed to @expr{a b^c}, where @expr{-c} is any negative-looking |
22364 |
power. Also, @expr{1 / b^c} is changed to |
power. Also, @expr{1 / b^c} is changed to |
22365 |
@texline @tmath{b^{-c}} |
@texline @math{b^{-c}} |
22366 |
@infoline @expr{b^(-c)} |
@infoline @expr{b^(-c)} |
22367 |
for any power @expr{c}. |
for any power @expr{c}. |
22368 |
|
|
22403 |
are distributed to @expr{a^c b^c}, @expr{a^c / b^c} only if @expr{c} |
are distributed to @expr{a^c b^c}, @expr{a^c / b^c} only if @expr{c} |
22404 |
is an integer, or if either @expr{a} or @expr{b} are nonnegative |
is an integer, or if either @expr{a} or @expr{b} are nonnegative |
22405 |
real numbers. Powers of powers @expr{(a^b)^c} are simplified to |
real numbers. Powers of powers @expr{(a^b)^c} are simplified to |
22406 |
@texline @tmath{a^{b c}} |
@texline @math{a^{b c}} |
22407 |
@infoline @expr{a^(b c)} |
@infoline @expr{a^(b c)} |
22408 |
only when @expr{c} is an integer and @expr{b c} also |
only when @expr{c} is an integer and @expr{b c} also |
22409 |
evaluates to an integer. Without these restrictions these simplifications |
evaluates to an integer. Without these restrictions these simplifications |
22410 |
would not be safe because of problems with principal values. |
would not be safe because of problems with principal values. |
22411 |
(In other words, |
(In other words, |
22412 |
@texline @tmath{((-3)^{1/2})^2} |
@texline @math{((-3)^{1/2})^2} |
22413 |
@infoline @expr{((-3)^1:2)^2} |
@infoline @expr{((-3)^1:2)^2} |
22414 |
is safe to simplify, but |
is safe to simplify, but |
22415 |
@texline @tmath{((-3)^2)^{1/2}} |
@texline @math{((-3)^2)^{1/2}} |
22416 |
@infoline @expr{((-3)^2)^1:2} |
@infoline @expr{((-3)^2)^1:2} |
22417 |
is not.) @xref{Declarations}, for ways to inform Calc that your |
is not.) @xref{Declarations}, for ways to inform Calc that your |
22418 |
variables satisfy these requirements. |
variables satisfy these requirements. |
22419 |
|
|
22420 |
As a special case of this rule, @expr{@t{sqrt}(x)^n} is simplified to |
As a special case of this rule, @expr{@t{sqrt}(x)^n} is simplified to |
22421 |
@texline @tmath{x^{n/2}} |
@texline @math{x^{n/2}} |
22422 |
@infoline @expr{x^(n/2)} |
@infoline @expr{x^(n/2)} |
22423 |
only for even integers @expr{n}. |
only for even integers @expr{n}. |
22424 |
|
|
22431 |
for any negative-looking expression @expr{-a}. |
for any negative-looking expression @expr{-a}. |
22432 |
|
|
22433 |
Square roots @expr{@t{sqrt}(x)} generally act like one-half powers |
Square roots @expr{@t{sqrt}(x)} generally act like one-half powers |
22434 |
@texline @tmath{x^{1:2}} |
@texline @math{x^{1:2}} |
22435 |
@infoline @expr{x^1:2} |
@infoline @expr{x^1:2} |
22436 |
for the purposes of the above-listed simplifications. |
for the purposes of the above-listed simplifications. |
22437 |
|
|
22438 |
Also, note that |
Also, note that |
22439 |
@texline @tmath{1 / x^{1:2}} |
@texline @math{1 / x^{1:2}} |
22440 |
@infoline @expr{1 / x^1:2} |
@infoline @expr{1 / x^1:2} |
22441 |
is changed to |
is changed to |
22442 |
@texline @tmath{x^{-1:2}}, |
@texline @math{x^{-1:2}}, |
22443 |
@infoline @expr{x^(-1:2)}, |
@infoline @expr{x^(-1:2)}, |
22444 |
but @expr{1 / @t{sqrt}(x)} is left alone. |
but @expr{1 / @t{sqrt}(x)} is left alone. |
22445 |
|
|
22582 |
A subtle point is that @expr{(x - y) (y - x)} will @emph{not} |
A subtle point is that @expr{(x - y) (y - x)} will @emph{not} |
22583 |
be simplified to @expr{-(x - y)^2}; Calc does not notice that |
be simplified to @expr{-(x - y)^2}; Calc does not notice that |
22584 |
one term can be written as a constant times the other, even if |
one term can be written as a constant times the other, even if |
22585 |
that constant is @i{-1}. |
that constant is @mathit{-1}. |
22586 |
|
|
22587 |
A fraction times any expression, @expr{(a:b) x}, is changed to |
A fraction times any expression, @expr{(a:b) x}, is changed to |
22588 |
a quotient involving integers: @expr{a x / b}. This is not |
a quotient involving integers: @expr{a x / b}. This is not |
22625 |
several ways. (Note that these will be left unevaluated only in |
several ways. (Note that these will be left unevaluated only in |
22626 |
Symbolic mode.) First, square integer or rational factors are |
Symbolic mode.) First, square integer or rational factors are |
22627 |
pulled out so that @expr{@t{sqrt}(8)} is rewritten as |
pulled out so that @expr{@t{sqrt}(8)} is rewritten as |
22628 |
@texline @tmath{$2\,\t{sqrt}(2)$}. |
@texline @math{2\,\t{sqrt}(2)}. |
22629 |
@infoline @expr{2 sqrt(2)}. |
@infoline @expr{2 sqrt(2)}. |
22630 |
Conceptually speaking this implies factoring the argument into primes |
Conceptually speaking this implies factoring the argument into primes |
22631 |
and moving pairs of primes out of the square root, but for reasons of |
and moving pairs of primes out of the square root, but for reasons of |
22687 |
@code{arctan}, @code{arcsinh}, and @code{arctanh}. Note that |
@code{arctan}, @code{arcsinh}, and @code{arctanh}. Note that |
22688 |
@expr{@t{arcsin}(@t{sin}(x))} can @emph{not} safely change to |
@expr{@t{arcsin}(@t{sin}(x))} can @emph{not} safely change to |
22689 |
@expr{x}, since this only correct within an integer multiple of |
@expr{x}, since this only correct within an integer multiple of |
22690 |
@texline @tmath{2 \pi} |
@texline @math{2 \pi} |
22691 |
@infoline @expr{2 pi} |
@infoline @expr{2 pi} |
22692 |
radians or 360 degrees. However, @expr{@t{arcsinh}(@t{sinh}(x))} is |
radians or 360 degrees. However, @expr{@t{arcsinh}(@t{sinh}(x))} is |
22693 |
simplified to @expr{x} if @expr{x} is known to be real. |
simplified to @expr{x} if @expr{x} is known to be real. |
22694 |
|
|
22695 |
Several simplifications that apply to logarithms and exponentials |
Several simplifications that apply to logarithms and exponentials |
22696 |
are that @expr{@t{exp}(@t{ln}(x))}, |
are that @expr{@t{exp}(@t{ln}(x))}, |
22697 |
@texline @t{e}@tmath{^{\ln(x)}}, |
@texline @t{e}@math{^{\ln(x)}}, |
22698 |
@infoline @expr{e^@t{ln}(x)}, |
@infoline @expr{e^@t{ln}(x)}, |
22699 |
and |
and |
22700 |
@texline @tmath{10^{{\rm log10}(x)}} |
@texline @math{10^{{\rm log10}(x)}} |
22701 |
@infoline @expr{10^@t{log10}(x)} |
@infoline @expr{10^@t{log10}(x)} |
22702 |
all reduce to @expr{x}. Also, @expr{@t{ln}(@t{exp}(x))}, etc., can |
all reduce to @expr{x}. Also, @expr{@t{ln}(@t{exp}(x))}, etc., can |
22703 |
reduce to @expr{x} if @expr{x} is provably real. The form |
reduce to @expr{x} if @expr{x} is provably real. The form |
22704 |
@expr{@t{exp}(x)^y} is simplified to @expr{@t{exp}(x y)}. If @expr{x} |
@expr{@t{exp}(x)^y} is simplified to @expr{@t{exp}(x y)}. If @expr{x} |
22705 |
is a suitable multiple of |
is a suitable multiple of |
22706 |
@texline @tmath{\pi i} |
@texline @math{\pi i} |
22707 |
@infoline @expr{pi i} |
@infoline @expr{pi i} |
22708 |
(as described above for the trigonometric functions), then |
(as described above for the trigonometric functions), then |
22709 |
@expr{@t{exp}(x)} or @expr{e^x} will be expanded. Finally, |
@expr{@t{exp}(x)} or @expr{e^x} will be expanded. Finally, |
22788 |
functions always produce. |
functions always produce. |
22789 |
|
|
22790 |
Powers of powers @expr{(x^a)^b} are simplified to |
Powers of powers @expr{(x^a)^b} are simplified to |
22791 |
@texline @tmath{x^{a b}} |
@texline @math{x^{a b}} |
22792 |
@infoline @expr{x^(a b)} |
@infoline @expr{x^(a b)} |
22793 |
for all @expr{a} and @expr{b}. These results will be valid only |
for all @expr{a} and @expr{b}. These results will be valid only |
22794 |
in a restricted range of @expr{x}; for example, in |
in a restricted range of @expr{x}; for example, in |
22795 |
@texline @tmath{(x^2)^{1:2}} |
@texline @math{(x^2)^{1:2}} |
22796 |
@infoline @expr{(x^2)^1:2} |
@infoline @expr{(x^2)^1:2} |
22797 |
the powers cancel to get @expr{x}, which is valid for positive values |
the powers cancel to get @expr{x}, which is valid for positive values |
22798 |
of @expr{x} but not for negative or complex values. |
of @expr{x} but not for negative or complex values. |
22799 |
|
|
22800 |
Similarly, @expr{@t{sqrt}(x^a)} and @expr{@t{sqrt}(x)^a} are both |
Similarly, @expr{@t{sqrt}(x^a)} and @expr{@t{sqrt}(x)^a} are both |
22801 |
simplified (possibly unsafely) to |
simplified (possibly unsafely) to |
22802 |
@texline @tmath{x^{a/2}}. |
@texline @math{x^{a/2}}. |
22803 |
@infoline @expr{x^(a/2)}. |
@infoline @expr{x^(a/2)}. |
22804 |
|
|
22805 |
Forms like @expr{@t{sqrt}(1 - sin(x)^2)} are simplified to, e.g., |
Forms like @expr{@t{sqrt}(1 - sin(x)^2)} are simplified to, e.g., |
22875 |
For powers and square roots, the ``unsafe'' simplifications |
For powers and square roots, the ``unsafe'' simplifications |
22876 |
@expr{(a b)^c} to @expr{a^c b^c}, @expr{(a/b)^c} to @expr{a^c / b^c}, |
@expr{(a b)^c} to @expr{a^c b^c}, @expr{(a/b)^c} to @expr{a^c / b^c}, |
22877 |
and @expr{(a^b)^c} to |
and @expr{(a^b)^c} to |
22878 |
@texline @tmath{a^{b c}} |
@texline @math{a^{b c}} |
22879 |
@infoline @expr{a^(b c)} |
@infoline @expr{a^(b c)} |
22880 |
are done if the powers are real numbers. (These are safe in the context |
are done if the powers are real numbers. (These are safe in the context |
22881 |
of units because all numbers involved can reasonably be assumed to be |
of units because all numbers involved can reasonably be assumed to be |
22890 |
is defined in terms of @samp{m^2}, and that the 2 in the power of |
is defined in terms of @samp{m^2}, and that the 2 in the power of |
22891 |
@code{m} is a multiple of 2 in @expr{3:2}. Thus, @code{acre^1.5} is |
@code{m} is a multiple of 2 in @expr{3:2}. Thus, @code{acre^1.5} is |
22892 |
replaced by approximately |
replaced by approximately |
22893 |
@texline @tmath{(4046 m^2)^{1.5}} |
@texline @math{(4046 m^2)^{1.5}} |
22894 |
@infoline @expr{(4046 m^2)^1.5}, |
@infoline @expr{(4046 m^2)^1.5}, |
22895 |
which is then changed to |
which is then changed to |
22896 |
@texline @tmath{4046^{1.5} \, (m^2)^{1.5}}, |
@texline @math{4046^{1.5} \, (m^2)^{1.5}}, |
22897 |
@infoline @expr{4046^1.5 (m^2)^1.5}, |
@infoline @expr{4046^1.5 (m^2)^1.5}, |
22898 |
then to @expr{257440 m^3}. |
then to @expr{257440 m^3}. |
22899 |
|
|
23183 |
If you use the @code{deriv} function directly in an algebraic formula, |
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 |
you can write @samp{deriv(f,x,x0)} which represents the derivative |
23185 |
of @expr{f} with respect to @expr{x}, evaluated at the point |
of @expr{f} with respect to @expr{x}, evaluated at the point |
23186 |
@texline @tmath{x=x_0}. |
@texline @math{x=x_0}. |
23187 |
@infoline @expr{x=x0}. |
@infoline @expr{x=x0}. |
23188 |
|
|
23189 |
If the formula being differentiated contains functions which Calc does |
If the formula being differentiated contains functions which Calc does |
23223 |
classes of formulas. In particular, any polynomial or rational function |
classes of formulas. In particular, any polynomial or rational function |
23224 |
(a polynomial divided by a polynomial) is acceptable. (Rational functions |
(a polynomial divided by a polynomial) is acceptable. (Rational functions |
23225 |
don't have to be in explicit quotient form, however; |
don't have to be in explicit quotient form, however; |
23226 |
@texline @tmath{x/(1+x^{-2})} |
@texline @math{x/(1+x^{-2})} |
23227 |
@infoline @expr{x/(1+x^-2)} |
@infoline @expr{x/(1+x^-2)} |
23228 |
is not strictly a quotient of polynomials, but it is equivalent to |
is not strictly a quotient of polynomials, but it is equivalent to |
23229 |
@expr{x^3/(x^2+1)}, which is.) Also, square roots of terms involving |
@expr{x^3/(x^2+1)}, which is.) Also, square roots of terms involving |
23249 |
Please note that the current implementation of Calc's integrator sometimes |
Please note that the current implementation of Calc's integrator sometimes |
23250 |
produces results that are significantly more complex than they need to |
produces results that are significantly more complex than they need to |
23251 |
be. For example, the integral Calc finds for |
be. For example, the integral Calc finds for |
23252 |
@texline @tmath{1/(x+\sqrt{x^2+1})} |
@texline @math{1/(x+\sqrt{x^2+1})} |
23253 |
@infoline @expr{1/(x+sqrt(x^2+1))} |
@infoline @expr{1/(x+sqrt(x^2+1))} |
23254 |
is several times more complicated than the answer Mathematica |
is several times more complicated than the answer Mathematica |
23255 |
returns for the same input, although the two forms are numerically |
returns for the same input, although the two forms are numerically |
23257 |
an arbitrary constant of integration added to it, although Calc does not |
an arbitrary constant of integration added to it, although Calc does not |
23258 |
write an explicit constant of integration in its result. For example, |
write an explicit constant of integration in its result. For example, |
23259 |
Calc's solution for |
Calc's solution for |
23260 |
@texline @tmath{1/(1+\tan x)} |
@texline @math{1/(1+\tan x)} |
23261 |
@infoline @expr{1/(1+tan(x))} |
@infoline @expr{1/(1+tan(x))} |
23262 |
differs from the solution given in the @emph{CRC Math Tables} by a |
differs from the solution given in the @emph{CRC Math Tables} by a |
23263 |
constant factor of |
constant factor of |
23264 |
@texline @tmath{\pi i / 2} |
@texline @math{\pi i / 2} |
23265 |
@infoline @expr{pi i / 2}, |
@infoline @expr{pi i / 2}, |
23266 |
due to a different choice of constant of integration. |
due to a different choice of constant of integration. |
23267 |
|
|
23321 |
As a more serious example, the expression @samp{exp(x)/x} cannot be |
As a more serious example, the expression @samp{exp(x)/x} cannot be |
23322 |
integrated in terms of the standard functions, so the ``exponential |
integrated in terms of the standard functions, so the ``exponential |
23323 |
integral'' function |
integral'' function |
23324 |
@texline @tmath{{\rm Ei}(x)} |
@texline @math{{\rm Ei}(x)} |
23325 |
@infoline @expr{Ei(x)} |
@infoline @expr{Ei(x)} |
23326 |
was invented to describe it. |
was invented to describe it. |
23327 |
We can get Calc to do this integral in terms of a made-up @code{Ei} |
We can get Calc to do this integral in terms of a made-up @code{Ei} |
23494 |
This command also works for inequalities, as in @expr{y < 3x + 6}. |
This command also works for inequalities, as in @expr{y < 3x + 6}. |
23495 |
Some inequalities cannot be solved where the analogous equation could |
Some inequalities cannot be solved where the analogous equation could |
23496 |
be; for example, solving |
be; for example, solving |
23497 |
@texline @tmath{a < b \, c} |
@texline @math{a < b \, c} |
23498 |
@infoline @expr{a < b c} |
@infoline @expr{a < b c} |
23499 |
for @expr{b} is impossible |
for @expr{b} is impossible |
23500 |
without knowing the sign of @expr{c}. In this case, @kbd{a S} will |
without knowing the sign of @expr{c}. In this case, @kbd{a S} will |
23501 |
produce the result |
produce the result |
23502 |
@texline @tmath{b \mathbin{\hbox{\code{!=}}} a/c} |
@texline @math{b \mathbin{\hbox{\code{!=}}} a/c} |
23503 |
@infoline @expr{b != a/c} |
@infoline @expr{b != a/c} |
23504 |
(using the not-equal-to operator) to signify that the direction of the |
(using the not-equal-to operator) to signify that the direction of the |
23505 |
inequality is now unknown. The inequality |
inequality is now unknown. The inequality |
23506 |
@texline @tmath{a \le b \, c} |
@texline @math{a \le b \, c} |
23507 |
@infoline @expr{a <= b c} |
@infoline @expr{a <= b c} |
23508 |
is not even partially solved. @xref{Declarations}, for a way to tell |
is not even partially solved. @xref{Declarations}, for a way to tell |
23509 |
Calc that the signs of the variables in a formula are in fact known. |
Calc that the signs of the variables in a formula are in fact known. |
23530 |
general family of solutions. It will invent variables @code{n1}, |
general family of solutions. It will invent variables @code{n1}, |
23531 |
@code{n2}, @dots{}, which represent independent arbitrary integers, and |
@code{n2}, @dots{}, which represent independent arbitrary integers, and |
23532 |
@code{s1}, @code{s2}, @dots{}, which represent independent arbitrary |
@code{s1}, @code{s2}, @dots{}, which represent independent arbitrary |
23533 |
signs (either @i{+1} or @i{-1}). If you don't use the Hyperbolic |
signs (either @mathit{+1} or @mathit{-1}). If you don't use the Hyperbolic |
23534 |
flag, Calc will use zero in place of all arbitrary integers, and plus |
flag, Calc will use zero in place of all arbitrary integers, and plus |
23535 |
one in place of all arbitrary signs. Note that variables like @code{n1} |
one in place of all arbitrary signs. Note that variables like @code{n1} |
23536 |
and @code{s1} are not given any special interpretation in Calc except by |
and @code{s1} are not given any special interpretation in Calc except by |
23963 |
|
|
23964 |
Note that this command looks for a @emph{local} minimum. Many functions |
Note that this command looks for a @emph{local} minimum. Many functions |
23965 |
have more than one minimum; some, like |
have more than one minimum; some, like |
23966 |
@texline @tmath{x \sin x}, |
@texline @math{x \sin x}, |
23967 |
@infoline @expr{x sin(x)}, |
@infoline @expr{x sin(x)}, |
23968 |
have infinitely many. In fact, there is no easy way to define the |
have infinitely many. In fact, there is no easy way to define the |
23969 |
``global'' minimum of |
``global'' minimum of |
23970 |
@texline @tmath{x \sin x} |
@texline @math{x \sin x} |
23971 |
@infoline @expr{x sin(x)} |
@infoline @expr{x sin(x)} |
23972 |
but Calc can still locate any particular local minimum |
but Calc can still locate any particular local minimum |
23973 |
for you. Calc basically goes downhill from the initial guess until it |
for you. Calc basically goes downhill from the initial guess until it |
24090 |
The @kbd{a F} command takes the data set to be fitted from the stack. |
The @kbd{a F} command takes the data set to be fitted from the stack. |
24091 |
By default, it expects the data in the form of a matrix. For example, |
By default, it expects the data in the form of a matrix. For example, |
24092 |
for a linear or polynomial fit, this would be a |
for a linear or polynomial fit, this would be a |
24093 |
@texline @tmath{2\times N} |
@texline @math{2\times N} |
24094 |
@infoline 2xN |
@infoline 2xN |
24095 |
matrix where the first row is a list of @expr{x} values and the second |
matrix where the first row is a list of @expr{x} values and the second |
24096 |
row has the corresponding @expr{y} values. For the multilinear fit |
row has the corresponding @expr{y} values. For the multilinear fit |
24098 |
@expr{x_3}, and @expr{y}, respectively). |
@expr{x_3}, and @expr{y}, respectively). |
24099 |
|
|
24100 |
If you happen to have an |
If you happen to have an |
24101 |
@texline @tmath{N\times2} |
@texline @math{N\times2} |
24102 |
@infoline Nx2 |
@infoline Nx2 |
24103 |
matrix instead of a |
matrix instead of a |
24104 |
@texline @tmath{2\times N} |
@texline @math{2\times N} |
24105 |
@infoline 2xN |
@infoline 2xN |
24106 |
matrix, just press @kbd{v t} first to transpose the matrix. |
matrix, just press @kbd{v t} first to transpose the matrix. |
24107 |
|
|
24199 |
and increases as various @expr{a + b x_i} values fail to match the |
and increases as various @expr{a + b x_i} values fail to match the |
24200 |
corresponding @expr{y_i} values. There are several reasons why the |
corresponding @expr{y_i} values. There are several reasons why the |
24201 |
summand is squared, one of them being to ensure that |
summand is squared, one of them being to ensure that |
24202 |
@texline @tmath{\chi^2 \ge 0}. |
@texline @math{\chi^2 \ge 0}. |
24203 |
@infoline @expr{chi^2 >= 0}. |
@infoline @expr{chi^2 >= 0}. |
24204 |
Least-squares fitting simply chooses the values of @expr{a} and @expr{b} |
Least-squares fitting simply chooses the values of @expr{a} and @expr{b} |
24205 |
for which the error |
for which the error |
24206 |
@texline @tmath{\chi^2} |
@texline @math{\chi^2} |
24207 |
@infoline @expr{chi^2} |
@infoline @expr{chi^2} |
24208 |
is as small as possible. |
is as small as possible. |
24209 |
|
|
24259 |
|
|
24260 |
An important result from the theory of polynomial fitting is that it |
An important result from the theory of polynomial fitting is that it |
24261 |
is always possible to fit @var{n} data points exactly using a polynomial |
is always possible to fit @var{n} data points exactly using a polynomial |
24262 |
of degree @i{@var{n}-1}, sometimes called an @dfn{interpolating polynomial}. |
of degree @mathit{@var{n}-1}, sometimes called an @dfn{interpolating polynomial}. |
24263 |
Using the modified (14) data matrix, a model number of 4 gives |
Using the modified (14) data matrix, a model number of 4 gives |
24264 |
a polynomial that exactly matches all five data points: |
a polynomial that exactly matches all five data points: |
24265 |
|
|
24364 |
or all be plain numbers. Error forms can go anywhere but generally |
or all be plain numbers. Error forms can go anywhere but generally |
24365 |
go on the numbers in the last row of the data matrix. If the last |
go on the numbers in the last row of the data matrix. If the last |
24366 |
row contains error forms |
row contains error forms |
24367 |
@texline `@var{y_i}@w{ @t{+/-} }@tmath{\sigma_i}', |
@texline `@var{y_i}@w{ @t{+/-} }@math{\sigma_i}', |
24368 |
@infoline `@var{y_i}@w{ @t{+/-} }@var{sigma_i}', |
@infoline `@var{y_i}@w{ @t{+/-} }@var{sigma_i}', |
24369 |
then the |
then the |
24370 |
@texline @tmath{\chi^2} |
@texline @math{\chi^2} |
24371 |
@infoline @expr{chi^2} |
@infoline @expr{chi^2} |
24372 |
statistic is now, |
statistic is now, |
24373 |
|
|
24390 |
If there are error forms on other rows of the data matrix, all the |
If there are error forms on other rows of the data matrix, all the |
24391 |
errors for a given data point are combined; the square root of the |
errors for a given data point are combined; the square root of the |
24392 |
sum of the squares of the errors forms the |
sum of the squares of the errors forms the |
24393 |
@texline @tmath{\sigma_i} |
@texline @math{\sigma_i} |
24394 |
@infoline @expr{sigma_i} |
@infoline @expr{sigma_i} |
24395 |
used for the data point. |
used for the data point. |
24396 |
|
|
24400 |
estimates. |
estimates. |
24401 |
|
|
24402 |
If the input contains error forms but all the |
If the input contains error forms but all the |
24403 |
@texline @tmath{\sigma_i} |
@texline @math{\sigma_i} |
24404 |
@infoline @expr{sigma_i} |
@infoline @expr{sigma_i} |
24405 |
values are the same, it is easy to see that the resulting fitted model |
values are the same, it is easy to see that the resulting fitted model |
24406 |
will be the same as if the input did not have error forms at all |
will be the same as if the input did not have error forms at all |
24407 |
@texline (@tmath{\chi^2} |
@texline (@math{\chi^2} |
24408 |
@infoline (@expr{chi^2} |
@infoline (@expr{chi^2} |
24409 |
is simply scaled uniformly by |
is simply scaled uniformly by |
24410 |
@texline @tmath{1 / \sigma^2}, |
@texline @math{1 / \sigma^2}, |
24411 |
@infoline @expr{1 / sigma^2}, |
@infoline @expr{1 / sigma^2}, |
24412 |
which doesn't affect where it has a minimum). But there @emph{will} be |
which doesn't affect where it has a minimum). But there @emph{will} be |
24413 |
a difference in the estimated errors of the coefficients reported by |
a difference in the estimated errors of the coefficients reported by |
24442 |
@item |
@item |
24443 |
The covariance matrix @expr{C} computed from the fit. This is |
The covariance matrix @expr{C} computed from the fit. This is |
24444 |
an @var{m}x@var{m} symmetric matrix; the diagonal elements |
an @var{m}x@var{m} symmetric matrix; the diagonal elements |
24445 |
@texline @tmath{C_{jj}} |
@texline @math{C_{jj}} |
24446 |
@infoline @expr{C_j_j} |
@infoline @expr{C_j_j} |
24447 |
are the variances |
are the variances |
24448 |
@texline @tmath{\sigma_j^2} |
@texline @math{\sigma_j^2} |
24449 |
@infoline @expr{sigma_j^2} |
@infoline @expr{sigma_j^2} |
24450 |
of the parameters. The other elements are covariances |
of the parameters. The other elements are covariances |
24451 |
@texline @tmath{\sigma_{ij}^2} |
@texline @math{\sigma_{ij}^2} |
24452 |
@infoline @expr{sigma_i_j^2} |
@infoline @expr{sigma_i_j^2} |
24453 |
that describe the correlation between pairs of parameters. (A related |
that describe the correlation between pairs of parameters. (A related |
24454 |
set of numbers, the @dfn{linear correlation coefficients} |
set of numbers, the @dfn{linear correlation coefficients} |
24455 |
@texline @tmath{r_{ij}}, |
@texline @math{r_{ij}}, |
24456 |
@infoline @expr{r_i_j}, |
@infoline @expr{r_i_j}, |
24457 |
are defined as |
are defined as |
24458 |
@texline @tmath{\sigma_{ij}^2 / \sigma_i \, \sigma_j}.) |
@texline @math{\sigma_{ij}^2 / \sigma_i \, \sigma_j}.) |
24459 |
@infoline @expr{sigma_i_j^2 / sigma_i sigma_j}.) |
@infoline @expr{sigma_i_j^2 / sigma_i sigma_j}.) |
24460 |
|
|
24461 |
@item |
@item |
24466 |
|
|
24467 |
@item |
@item |
24468 |
The value of |
The value of |
24469 |
@texline @tmath{\chi^2} |
@texline @math{\chi^2} |
24470 |
@infoline @expr{chi^2} |
@infoline @expr{chi^2} |
24471 |
for the fit, calculated by the formulas shown above. This gives a |
for the fit, calculated by the formulas shown above. This gives a |
24472 |
measure of the quality of the fit; statisticians consider |
measure of the quality of the fit; statisticians consider |
24473 |
@texline @tmath{\chi^2 \approx N - M} |
@texline @math{\chi^2 \approx N - M} |
24474 |
@infoline @expr{chi^2 = N - M} |
@infoline @expr{chi^2 = N - M} |
24475 |
to indicate a moderately good fit (where again @expr{N} is the number of |
to indicate a moderately good fit (where again @expr{N} is the number of |
24476 |
data points and @expr{M} is the number of parameters). |
data points and @expr{M} is the number of parameters). |
24479 |
A measure of goodness of fit expressed as a probability @expr{Q}. |
A measure of goodness of fit expressed as a probability @expr{Q}. |
24480 |
This is computed from the @code{utpc} probability distribution |
This is computed from the @code{utpc} probability distribution |
24481 |
function using |
function using |
24482 |
@texline @tmath{\chi^2} |
@texline @math{\chi^2} |
24483 |
@infoline @expr{chi^2} |
@infoline @expr{chi^2} |
24484 |
with @expr{N - M} degrees of freedom. A |
with @expr{N - M} degrees of freedom. A |
24485 |
value of 0.5 implies a good fit; some texts recommend that often |
value of 0.5 implies a good fit; some texts recommend that often |
24486 |
@expr{Q = 0.1} or even 0.001 can signify an acceptable fit. In |
@expr{Q = 0.1} or even 0.001 can signify an acceptable fit. In |
24487 |
particular, |
particular, |
24488 |
@texline @tmath{\chi^2} |
@texline @math{\chi^2} |
24489 |
@infoline @expr{chi^2} |
@infoline @expr{chi^2} |
24490 |
statistics assume the errors in your inputs |
statistics assume the errors in your inputs |
24491 |
follow a normal (Gaussian) distribution; if they don't, you may |
follow a normal (Gaussian) distribution; if they don't, you may |
24494 |
The @expr{Q} value is computed only if the input included error |
The @expr{Q} value is computed only if the input included error |
24495 |
estimates. Otherwise, Calc will report the symbol @code{nan} |
estimates. Otherwise, Calc will report the symbol @code{nan} |
24496 |
for @expr{Q}. The reason is that in this case the |
for @expr{Q}. The reason is that in this case the |
24497 |
@texline @tmath{\chi^2} |
@texline @math{\chi^2} |
24498 |
@infoline @expr{chi^2} |
@infoline @expr{chi^2} |
24499 |
value has effectively been used to estimate the original errors |
value has effectively been used to estimate the original errors |
24500 |
in the input, and thus there is no redundant information left |
in the input, and thus there is no redundant information left |
24513 |
|
|
24514 |
@table @kbd |
@table @kbd |
24515 |
@item 1 |
@item 1 |
24516 |
Linear or multilinear. @i{a + b x + c y + d z}. |
Linear or multilinear. @mathit{a + b x + c y + d z}. |
24517 |
@item 2-9 |
@item 2-9 |
24518 |
Polynomials. @i{a + b x + c x^2 + d x^3}. |
Polynomials. @mathit{a + b x + c x^2 + d x^3}. |
24519 |
@item e |
@item e |
24520 |
Exponential. @i{a} @t{exp}@i{(b x)} @t{exp}@i{(c y)}. |
Exponential. @mathit{a} @t{exp}@mathit{(b x)} @t{exp}@mathit{(c y)}. |
24521 |
@item E |
@item E |
24522 |
Base-10 exponential. @i{a} @t{10^}@i{(b x)} @t{10^}@i{(c y)}. |
Base-10 exponential. @mathit{a} @t{10^}@mathit{(b x)} @t{10^}@mathit{(c y)}. |
24523 |
@item x |
@item x |
24524 |
Exponential (alternate notation). @t{exp}@i{(a + b x + c y)}. |
Exponential (alternate notation). @t{exp}@mathit{(a + b x + c y)}. |
24525 |
@item X |
@item X |
24526 |
Base-10 exponential (alternate). @t{10^}@i{(a + b x + c y)}. |
Base-10 exponential (alternate). @t{10^}@mathit{(a + b x + c y)}. |
24527 |
@item l |
@item l |
24528 |
Logarithmic. @i{a + b} @t{ln}@i{(x) + c} @t{ln}@i{(y)}. |
Logarithmic. @mathit{a + b} @t{ln}@mathit{(x) + c} @t{ln}@mathit{(y)}. |
24529 |
@item L |
@item L |
24530 |
Base-10 logarithmic. @i{a + b} @t{log10}@i{(x) + c} @t{log10}@i{(y)}. |
Base-10 logarithmic. @mathit{a + b} @t{log10}@mathit{(x) + c} @t{log10}@mathit{(y)}. |
24531 |
@item ^ |
@item ^ |
24532 |
General exponential. @i{a b^x c^y}. |
General exponential. @mathit{a b^x c^y}. |
24533 |
@item p |
@item p |
24534 |
Power law. @i{a x^b y^c}. |
Power law. @mathit{a x^b y^c}. |
24535 |
@item q |
@item q |
24536 |
Quadratic. @i{a + b (x-c)^2 + d (x-e)^2}. |
Quadratic. @mathit{a + b (x-c)^2 + d (x-e)^2}. |
24537 |
@item g |
@item g |
24538 |
Gaussian. |
Gaussian. |
24539 |
@texline @tmath{{a \over b \sqrt{2 \pi}} \exp\left( -{1 \over 2} \left( x - c \over b \right)^2 \right)}. |
@texline @math{{a \over b \sqrt{2 \pi}} \exp\left( -{1 \over 2} \left( x - c \over b \right)^2 \right)}. |
24540 |
@infoline @i{(a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2)}. |
@infoline @mathit{(a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2)}. |
24541 |
@end table |
@end table |
24542 |
|
|
24543 |
All of these models are used in the usual way; just press the appropriate |
All of these models are used in the usual way; just press the appropriate |
24649 |
and @code{arcsin} when doing fits. For example, when you enter |
and @code{arcsin} when doing fits. For example, when you enter |
24650 |
the model @samp{y = sin(a t + b)} Calc actually uses the easier |
the model @samp{y = sin(a t + b)} Calc actually uses the easier |
24651 |
form @samp{arcsin(y) = a t + b}. The @code{arcsin} function always |
form @samp{arcsin(y) = a t + b}. The @code{arcsin} function always |
24652 |
returns results in the range from @i{-90} to 90 degrees (or the |
returns results in the range from @mathit{-90} to 90 degrees (or the |
24653 |
equivalent range in radians). Suppose you had data that you |
equivalent range in radians). Suppose you had data that you |
24654 |
believed to represent roughly three oscillations of a sine wave, |
believed to represent roughly three oscillations of a sine wave, |
24655 |
so that the argument of the sine might go from zero to |
so that the argument of the sine might go from zero to |
24656 |
@texline @tmath{3\times360} |
@texline @math{3\times360} |
24657 |
@infoline @i{3*360} |
@infoline @mathit{3*360} |
24658 |
degrees. |
degrees. |
24659 |
The above model would appear to be a good way to determine the |
The above model would appear to be a good way to determine the |
24660 |
true frequency and phase of the sine wave, but in practice it |
true frequency and phase of the sine wave, but in practice it |
24661 |
would fail utterly. The righthand side of the actual model |
would fail utterly. The righthand side of the actual model |
24662 |
@samp{arcsin(y) = a t + b} will grow smoothly with @expr{t}, but |
@samp{arcsin(y) = a t + b} will grow smoothly with @expr{t}, but |
24663 |
the lefthand side will bounce back and forth between @i{-90} and 90. |
the lefthand side will bounce back and forth between @mathit{-90} and 90. |
24664 |
No values of @expr{a} and @expr{b} can make the two sides match, |
No values of @expr{a} and @expr{b} can make the two sides match, |
24665 |
even approximately. |
even approximately. |
24666 |
|
|
24715 |
|
|
24716 |
@noindent |
@noindent |
24717 |
which matches the desired form with |
which matches the desired form with |
24718 |
@texline @tmath{Y = \ln(y)}, |
@texline @math{Y = \ln(y)}, |
24719 |
@infoline @expr{Y = ln(y)}, |
@infoline @expr{Y = ln(y)}, |
24720 |
@texline @tmath{A = \ln(a)}, |
@texline @math{A = \ln(a)}, |
24721 |
@infoline @expr{A = ln(a)}, |
@infoline @expr{A = ln(a)}, |
24722 |
@expr{F = 1}, @expr{B = b}, and |
@expr{F = 1}, @expr{B = b}, and |
24723 |
@texline @tmath{G = \ln(x)}. |
@texline @math{G = \ln(x)}. |
24724 |
@infoline @expr{G = ln(x)}. |
@infoline @expr{G = ln(x)}. |
24725 |
Calc thus computes the logarithms of your @expr{y} and @expr{x} values, |
Calc thus computes the logarithms of your @expr{y} and @expr{x} values, |
24726 |
does a linear fit for @expr{A} and @expr{B}, then solves to get |
does a linear fit for @expr{A} and @expr{B}, then solves to get |
24727 |
@texline @tmath{a = \exp(A)} |
@texline @math{a = \exp(A)} |
24728 |
@infoline @expr{a = exp(A)} |
@infoline @expr{a = exp(A)} |
24729 |
and @expr{b = B}. |
and @expr{b = B}. |
24730 |
|
|
24738 |
|
|
24739 |
@noindent |
@noindent |
24740 |
which matches with @expr{Y = y}, @expr{A = a + b c^2}, @expr{F = 1}, |
which matches with @expr{Y = y}, @expr{A = a + b c^2}, @expr{F = 1}, |
24741 |
@expr{B = -2 b c}, @expr{G = x} (the @i{-2} factor could just as easily |
@expr{B = -2 b c}, @expr{G = x} (the @mathit{-2} factor could just as easily |
24742 |
have been put into @expr{G} instead of @expr{B}), @expr{C = b}, and |
have been put into @expr{G} instead of @expr{B}), @expr{C = b}, and |
24743 |
@expr{H = x^2}. |
@expr{H = x^2}. |
24744 |
|
|
24770 |
A last desperate step would be to use the general-purpose |
A last desperate step would be to use the general-purpose |
24771 |
@code{minimize} function rather than @code{fit}. After all, both |
@code{minimize} function rather than @code{fit}. After all, both |
24772 |
functions solve the problem of minimizing an expression (the |
functions solve the problem of minimizing an expression (the |
24773 |
@texline @tmath{\chi^2} |
@texline @math{\chi^2} |
24774 |
@infoline @expr{chi^2} |
@infoline @expr{chi^2} |
24775 |
sum) by adjusting certain parameters in the expression. The @kbd{a F} |
sum) by adjusting certain parameters in the expression. The @kbd{a F} |
24776 |
command is able to use a vastly more efficient algorithm due to its |
command is able to use a vastly more efficient algorithm due to its |
24781 |
fit is linearizable, and use @code{minimize} on a call to @code{fit} |
fit is linearizable, and use @code{minimize} on a call to @code{fit} |
24782 |
which efficiently takes care of the rest of the parameters. The thing |
which efficiently takes care of the rest of the parameters. The thing |
24783 |
to be minimized would be the value of |
to be minimized would be the value of |
24784 |
@texline @tmath{\chi^2} |
@texline @math{\chi^2} |
24785 |
@infoline @expr{chi^2} |
@infoline @expr{chi^2} |
24786 |
returned as the fifth result of the @code{xfit} function: |
returned as the fifth result of the @code{xfit} function: |
24787 |
|
|
24841 |
form with this combined error. The @expr{Y(x,y,z)} part of the |
form with this combined error. The @expr{Y(x,y,z)} part of the |
24842 |
linearized model is evaluated, and the result should be an error |
linearized model is evaluated, and the result should be an error |
24843 |
form. The error part of that result is used for |
form. The error part of that result is used for |
24844 |
@texline @tmath{\sigma_i} |
@texline @math{\sigma_i} |
24845 |
@infoline @expr{sigma_i} |
@infoline @expr{sigma_i} |
24846 |
for the data point. If for some reason @expr{Y(x,y,z)} does not return |
for the data point. If for some reason @expr{Y(x,y,z)} does not return |
24847 |
an error form, the combined error from @expr{z} is used directly for |
an error form, the combined error from @expr{z} is used directly for |
24848 |
@texline @tmath{\sigma_i}. |
@texline @math{\sigma_i}. |
24849 |
@infoline @expr{sigma_i}. |
@infoline @expr{sigma_i}. |
24850 |
Finally, @expr{z} is also stripped of its error |
Finally, @expr{z} is also stripped of its error |
24851 |
for use in computing @expr{F(x,y,z)}, @expr{G(x,y,z)} and so on; |
for use in computing @expr{F(x,y,z)}, @expr{G(x,y,z)} and so on; |
24857 |
depends only on the dependent variable @expr{z}, and in fact is |
depends only on the dependent variable @expr{z}, and in fact is |
24858 |
often simply equal to @expr{z}. For common cases like polynomials |
often simply equal to @expr{z}. For common cases like polynomials |
24859 |
and multilinear models, the combined error is simply used as the |
and multilinear models, the combined error is simply used as the |
24860 |
@texline @tmath{\sigma} |
@texline @math{\sigma} |
24861 |
@infoline @expr{sigma} |
@infoline @expr{sigma} |
24862 |
for the data point with no further ado.) |
for the data point with no further ado.) |
24863 |
|
|
25211 |
positive step size), the result is generally zero. However, |
positive step size), the result is generally zero. However, |
25212 |
Calc only guarantees a zero result when the upper limit is |
Calc only guarantees a zero result when the upper limit is |
25213 |
exactly one step less than the lower limit, i.e., if the number |
exactly one step less than the lower limit, i.e., if the number |
25214 |
of iterations is @i{-1}. Thus @samp{sum(f(k), k, n, n-1)} is zero |
of iterations is @mathit{-1}. Thus @samp{sum(f(k), k, n, n-1)} is zero |
25215 |
but the sum from @samp{n} to @samp{n-2} may report a nonzero value |
but the sum from @samp{n} to @samp{n-2} may report a nonzero value |
25216 |
if Calc used a closed form solution. |
if Calc used a closed form solution. |
25217 |
|
|
25237 |
Calc will not assume is zero. Better would be to use |
Calc will not assume is zero. Better would be to use |
25238 |
@samp{(k != k_0) ? 1/(k-k_0) : 0}; the @samp{? :} operator does |
@samp{(k != k_0) ? 1/(k-k_0) : 0}; the @samp{? :} operator does |
25239 |
an ``if-then-else'' test: This expression says, ``if |
an ``if-then-else'' test: This expression says, ``if |
25240 |
@texline @tmath{k \ne k_0}, |
@texline @math{k \ne k_0}, |
25241 |
@infoline @expr{k != k_0}, |
@infoline @expr{k != k_0}, |
25242 |
then @expr{1/(k-k_0)}, else zero.'' Now the formula @expr{1/(k-k_0)} |
then @expr{1/(k-k_0)}, else zero.'' Now the formula @expr{1/(k-k_0)} |
25243 |
will not even be evaluated by Calc when @expr{k = k_0}. |
will not even be evaluated by Calc when @expr{k = k_0}. |
26252 |
all three rules. It is possible to modify the imported rules |
all three rules. It is possible to modify the imported rules |
26253 |
slightly: @samp{import(x, v1, x1, v2, x2, @dots{})} imports |
slightly: @samp{import(x, v1, x1, v2, x2, @dots{})} imports |
26254 |
the rule set @expr{x} with all occurrences of |
the rule set @expr{x} with all occurrences of |
26255 |
@texline @tmath{v_1}, |
@texline @math{v_1}, |
26256 |
@infoline @expr{v1}, |
@infoline @expr{v1}, |
26257 |
as either a variable name or a function name, replaced with |
as either a variable name or a function name, replaced with |
26258 |
@texline @tmath{x_1} |
@texline @math{x_1} |
26259 |
@infoline @expr{x1} |
@infoline @expr{x1} |
26260 |
and so on. (If |
and so on. (If |
26261 |
@texline @tmath{v_1} |
@texline @math{v_1} |
26262 |
@infoline @expr{v1} |
@infoline @expr{v1} |
26263 |
is used as a function name, then |
is used as a function name, then |
26264 |
@texline @tmath{x_1} |
@texline @math{x_1} |
26265 |
@infoline @expr{x1} |
@infoline @expr{x1} |
26266 |
must be either a function name itself or a @w{@samp{< >}} nameless |
must be either a function name itself or a @w{@samp{< >}} nameless |
26267 |
function; @pxref{Specifying Operators}.) For example, @samp{[g(0) := 0, |
function; @pxref{Specifying Operators}.) For example, @samp{[g(0) := 0, |
27727 |
units. |
units. |
27728 |
|
|
27729 |
Two units, @code{pi} and @code{fsc} (the fine structure constant, |
Two units, @code{pi} and @code{fsc} (the fine structure constant, |
27730 |
approximately @i{1/137}) are dimensionless. The units simplification |
approximately @mathit{1/137}) are dimensionless. The units simplification |
27731 |
commands simply treat these names as equivalent to their corresponding |
commands simply treat these names as equivalent to their corresponding |
27732 |
values. However you can, for example, use @kbd{u c} to convert a pure |
values. However you can, for example, use @kbd{u c} to convert a pure |
27733 |
number into multiples of the fine structure constant, or @kbd{u b} to |
number into multiples of the fine structure constant, or @kbd{u b} to |
27944 |
order of the operands. If @expr{v} represents the contents of the |
order of the operands. If @expr{v} represents the contents of the |
27945 |
variable, and @expr{a} is the value drawn from the stack, then regular |
variable, and @expr{a} is the value drawn from the stack, then regular |
27946 |
@w{@kbd{s -}} assigns |
@w{@kbd{s -}} assigns |
27947 |
@texline @tmath{v \coloneq v - a}, |
@texline @math{v \coloneq v - a}, |
27948 |
@infoline @expr{v := v - a}, |
@infoline @expr{v := v - a}, |
27949 |
but @kbd{I s -} assigns |
but @kbd{I s -} assigns |
27950 |
@texline @tmath{v \coloneq a - v}. |
@texline @math{v \coloneq a - v}. |
27951 |
@infoline @expr{v := a - v}. |
@infoline @expr{v := a - v}. |
27952 |
While @kbd{I s *} might seem pointless, it is |
While @kbd{I s *} might seem pointless, it is |
27953 |
useful if matrix multiplication is involved. Actually, all the |
useful if matrix multiplication is involved. Actually, all the |
28534 |
``z'' value must be a matrix with the same number of rows as elements |
``z'' value must be a matrix with the same number of rows as elements |
28535 |
in ``x'', and the same number of columns as elements in ``y''. The |
in ``x'', and the same number of columns as elements in ``y''. The |
28536 |
result is a surface plot where |
result is a surface plot where |
28537 |
@texline @tmath{z_{ij}} |
@texline @math{z_{ij}} |
28538 |
@infoline @expr{z_ij} |
@infoline @expr{z_ij} |
28539 |
is the height of the point |
is the height of the point |
28540 |
at coordinate @expr{(x_i, y_j)} on the surface. The 3D graph will |
at coordinate @expr{(x_i, y_j)} on the surface. The 3D graph will |
28645 |
they are to look nice on the same graph.) |
they are to look nice on the same graph.) |
28646 |
|
|
28647 |
For example, to plot |
For example, to plot |
28648 |
@texline @tmath{\sin n x} |
@texline @math{\sin n x} |
28649 |
@infoline @expr{sin(n x)} |
@infoline @expr{sin(n x)} |
28650 |
for integers @expr{n} |
for integers @expr{n} |
28651 |
from 1 to 5, you could use @kbd{v x} to create a vector of integers |
from 1 to 5, you could use @kbd{v x} to create a vector of integers |
28896 |
the @kbd{g a} and @kbd{g f} commands will use those style numbers |
the @kbd{g a} and @kbd{g f} commands will use those style numbers |
28897 |
instead of the defaults for new curves that are added to the graph. |
instead of the defaults for new curves that are added to the graph. |
28898 |
An entry should be a positive integer for a specific style, or 0 to let |
An entry should be a positive integer for a specific style, or 0 to let |
28899 |
the style be chosen automatically, or @i{-1} to turn off lines or points |
the style be chosen automatically, or @mathit{-1} to turn off lines or points |
28900 |
altogether. If there are more curves than elements in the vector, the |
altogether. If there are more curves than elements in the vector, the |
28901 |
last few curves will continue to have the default styles. Of course, |
last few curves will continue to have the default styles. Of course, |
28902 |
you can later use @kbd{g s} and @kbd{g S} to change any of these styles. |
you can later use @kbd{g s} and @kbd{g S} to change any of these styles. |
28935 |
to a buffer called @samp{*Gnuplot Trail*}, which Calc then displays. |
to a buffer called @samp{*Gnuplot Trail*}, which Calc then displays. |
28936 |
The graph is made the same size as the Emacs screen, which on most |
The graph is made the same size as the Emacs screen, which on most |
28937 |
dumb terminals will be |
dumb terminals will be |
28938 |
@texline @tmath{80\times24} |
@texline @math{80\times24} |
28939 |
@infoline 80x24 |
@infoline 80x24 |
28940 |
characters. The graph is displayed in |
characters. The graph is displayed in |
28941 |
an Emacs ``recursive edit''; type @kbd{q} or @kbd{M-# M-#} to exit |
an Emacs ``recursive edit''; type @kbd{q} or @kbd{M-# M-#} to exit |
29245 |
|
|
29246 |
@xref{Matrix Functions}, to see how to pull the matrix apart into its |
@xref{Matrix Functions}, to see how to pull the matrix apart into its |
29247 |
constituent rows and columns. (If it is a |
constituent rows and columns. (If it is a |
29248 |
@texline @tmath{1\times1} |
@texline @math{1\times1} |
29249 |
@infoline 1x1 |
@infoline 1x1 |
29250 |
matrix, just hit @kbd{v u} (@code{calc-unpack}) twice.) |
matrix, just hit @kbd{v u} (@code{calc-unpack}) twice.) |
29251 |
|
|
29583 |
@key{INV GCD} computes the LCM (least common multiple) function. |
@key{INV GCD} computes the LCM (least common multiple) function. |
29584 |
|
|
29585 |
@key{INV FACT} is the gamma function. |
@key{INV FACT} is the gamma function. |
29586 |
@texline @tmath{\Gamma(x) = (x-1)!}. |
@texline @math{\Gamma(x) = (x-1)!}. |
29587 |
@infoline @expr{gamma(x) = (x-1)!}. |
@infoline @expr{gamma(x) = (x-1)!}. |
29588 |
|
|
29589 |
@key{PERM} is the number-of-permutations function, which is on the |
@key{PERM} is the number-of-permutations function, which is on the |
31011 |
is greater than @var{final} the body will not be executed at all. |
is greater than @var{final} the body will not be executed at all. |
31012 |
Note that @var{step} may still be negative in this loop; the prefix |
Note that @var{step} may still be negative in this loop; the prefix |
31013 |
argument merely constrains the loop-finished test. Likewise, a prefix |
argument merely constrains the loop-finished test. Likewise, a prefix |
31014 |
argument of @i{-1} forces downward-counting conventions. |
argument of @mathit{-1} forces downward-counting conventions. |
31015 |
|
|
31016 |
@kindex Z @{ |
@kindex Z @{ |
31017 |
@kindex Z @} |
@kindex Z @} |
31982 |
@tindex mysin |
@tindex mysin |
31983 |
A somewhat limited sine function could be defined as follows, using the |
A somewhat limited sine function could be defined as follows, using the |
31984 |
well-known Taylor series expansion for |
well-known Taylor series expansion for |
31985 |
@texline @tmath{\sin x}: |
@texline @math{\sin x}: |
31986 |
@infoline @samp{sin(x)}: |
@infoline @samp{sin(x)}: |
31987 |
|
|
31988 |
@smallexample |
@smallexample |
32505 |
Large integers are stored as lists of the form @samp{(bigpos @var{d0} |
Large integers are stored as lists of the form @samp{(bigpos @var{d0} |
32506 |
@var{d1} @var{d2} @dots{})} for positive integers 1000000 or more, or |
@var{d1} @var{d2} @dots{})} for positive integers 1000000 or more, or |
32507 |
@samp{(bigneg @var{d0} @var{d1} @var{d2} @dots{})} for negative integers |
@samp{(bigneg @var{d0} @var{d1} @var{d2} @dots{})} for negative integers |
32508 |
@i{-1000000} or less. Each @var{d} is a base-1000 ``digit,'' a Lisp integer |
@mathit{-1000000} or less. Each @var{d} is a base-1000 ``digit,'' a Lisp integer |
32509 |
from 0 to 999. The least significant digit is @var{d0}; the last digit, |
from 0 to 999. The least significant digit is @var{d0}; the last digit, |
32510 |
@var{dn}, which is always nonzero, is the most significant digit. For |
@var{dn}, which is always nonzero, is the most significant digit. For |
32511 |
example, the integer @i{-12345678} is stored as @samp{(bigneg 678 345 12)}. |
example, the integer @mathit{-12345678} is stored as @samp{(bigneg 678 345 12)}. |
32512 |
|
|
32513 |
The distinction between small and large integers is entirely hidden from |
The distinction between small and large integers is entirely hidden from |
32514 |
the user. In @code{defmath} definitions, the Lisp predicate @code{integerp} |
the user. In @code{defmath} definitions, the Lisp predicate @code{integerp} |
32529 |
@samp{10^@var{p}} in absolute value (@var{p} represents the current |
@samp{10^@var{p}} in absolute value (@var{p} represents the current |
32530 |
precision), and @var{exp} (the ``exponent'') is a fixnum. The value of |
precision), and @var{exp} (the ``exponent'') is a fixnum. The value of |
32531 |
the float is @samp{@var{mant} * 10^@var{exp}}. For example, the number |
the float is @samp{@var{mant} * 10^@var{exp}}. For example, the number |
32532 |
@i{-3.14} is stored as @samp{(float -314 -2) = -314*10^-2}. Other constraints |
@mathit{-3.14} is stored as @samp{(float -314 -2) = -314*10^-2}. Other constraints |
32533 |
are that the number 0.0 is always stored as @samp{(float 0 0)}, and, |
are that the number 0.0 is always stored as @samp{(float 0 0)}, and, |
32534 |
except for the 0.0 case, the rightmost base-10 digit of @var{mant} is |
except for the 0.0 case, the rightmost base-10 digit of @var{mant} is |
32535 |
always nonzero. (If the rightmost digit is zero, the number is |
always nonzero. (If the rightmost digit is zero, the number is |
32841 |
specified, nothing happens. When the argument is two or more, |
specified, nothing happens. When the argument is two or more, |
32842 |
the binary function @var{func} is reduced across the top @var{arg} |
the binary function @var{func} is reduced across the top @var{arg} |
32843 |
stack elements; when the argument is negative, the function is |
stack elements; when the argument is negative, the function is |
32844 |
mapped between the next-to-top @i{-@var{arg}} stack elements and the |
mapped between the next-to-top @mathit{-@var{arg}} stack elements and the |
32845 |
top element. |
top element. |
32846 |
@end defun |
@end defun |
32847 |
|
|
33260 |
@end defun |
@end defun |
33261 |
|
|
33262 |
@defun compare x y |
@defun compare x y |
33263 |
Compare the numbers @var{x} and @var{y}, and return @i{-1} if |
Compare the numbers @var{x} and @var{y}, and return @mathit{-1} if |
33264 |
@samp{(lessp @var{x} @var{y})}, 1 if @samp{(lessp @var{y} @var{x})}, |
@samp{(lessp @var{x} @var{y})}, 1 if @samp{(lessp @var{y} @var{x})}, |
33265 |
0 if @samp{(math-equal @var{x} @var{y})}, or 2 if the order is |
0 if @samp{(math-equal @var{x} @var{y})}, or 2 if the order is |
33266 |
undefined or cannot be determined. |
undefined or cannot be determined. |
33273 |
@end defun |
@end defun |
33274 |
|
|
33275 |
@defun scale-int x n |
@defun scale-int x n |
33276 |
Shift integer @var{x} left @var{n} decimal digits, or right @i{-@var{n}} |
Shift integer @var{x} left @var{n} decimal digits, or right @mathit{-@var{n}} |
33277 |
digits with truncation toward zero. |
digits with truncation toward zero. |
33278 |
@end defun |
@end defun |
33279 |
|
|
33481 |
@defun quarter-integer n |
@defun quarter-integer n |
33482 |
If @var{n} is an integer or integer-valued float, this function |
If @var{n} is an integer or integer-valued float, this function |
33483 |
returns zero. If @var{n} is a half-integer (i.e., an integer plus |
returns zero. If @var{n} is a half-integer (i.e., an integer plus |
33484 |
@i{1:2} or 0.5), it returns 2. If @var{n} is a quarter-integer, |
@mathit{1:2} or 0.5), it returns 2. If @var{n} is a quarter-integer, |
33485 |
it returns 1 or 3. If @var{n} is anything else, this function |
it returns 1 or 3. If @var{n} is anything else, this function |
33486 |
returns @code{nil}. |
returns @code{nil}. |
33487 |
@end defun |
@end defun |
35624 |
@c 20 |
@c 20 |
35625 |
@item |
@item |
35626 |
With a prefix argument of 1, take a single |
With a prefix argument of 1, take a single |
35627 |
@texline @tmath{@var{n}\times2} |
@texline @var{n}@math{\times2} |
35628 |
@infoline @i{@var{N}x2} |
@infoline @mathit{@var{N}x2} |
35629 |
matrix from the stack instead of two separate data vectors. |
matrix from the stack instead of two separate data vectors. |
35630 |
|
|
35631 |
@c 21 |
@c 21 |
35827 |
The variable is replaced by the formula shown on the right. The |
The variable is replaced by the formula shown on the right. The |
35828 |
Inverse flag reverses the order of the operands, e.g., @kbd{I s - x} |
Inverse flag reverses the order of the operands, e.g., @kbd{I s - x} |
35829 |
assigns |
assigns |
35830 |
@texline @tmath{x \coloneq a-x}. |
@texline @math{x \coloneq a-x}. |
35831 |
@infoline @expr{x := a-x}. |
@infoline @expr{x := a-x}. |
35832 |
|
|
35833 |
@c 48 |
@c 48 |
35835 |
Press @kbd{?} repeatedly to see how to choose a model. Answer the |
Press @kbd{?} repeatedly to see how to choose a model. Answer the |
35836 |
variables prompt with @expr{iv} or @expr{iv;pv} to specify |
variables prompt with @expr{iv} or @expr{iv;pv} to specify |
35837 |
independent and parameter variables. A positive prefix argument |
independent and parameter variables. A positive prefix argument |
35838 |
takes @i{@var{n}+1} vectors from the stack; a zero prefix takes a matrix |
takes @mathit{@var{n}+1} vectors from the stack; a zero prefix takes a matrix |
35839 |
and a vector from the stack. |
and a vector from the stack. |
35840 |
|
|
35841 |
@c 49 |
@c 49 |