@c @infoline foo
@c `foo' will appear only in non-TeX output
-@c In TeX output, @tmath{expr} will typeset expr in math mode.
-@c In any output, @expr{expr} will typeset an expression;
+@c @expr{expr} will typeset an expression;
@c $x$ in TeX, @samp{x} otherwise.
@iftex
@macro texline{stuff}
\stuff\
@end macro
-@macro tmath{stuff}
-@tex
-$\stuff\$
-@end tex
-@end macro
@alias infoline=comment
-@c @alias expr=math
@tex
-\gdef\expr#1{\tex
- \let\t\ttfont
- \turnoffactive
- $#1$
- \endgroup}
+\gdef\exprsetup{\tex \let\t\ttfont \turnoffactive}
+\gdef\expr{\exprsetup$\exprfinish}
+\gdef\exprfinish#1{#1$\endgroup}
@end tex
+@alias mathit=expr
@macro cpi{}
@math{@pi{}}
@end macro
\stuff\
@end macro
@alias expr=samp
+@alias mathit=i
@macro cpi{}
@expr{pi}
@end macro
@noindent
Type @kbd{2 @key{RET} 3 + Q} to compute
-@texline @tmath{\sqrt{2+3} = 2.2360679775}.
+@texline @math{\sqrt{2+3} = 2.2360679775}.
@infoline the square root of 2+3, which is 2.2360679775.
@noindent
Type @kbd{P 2 ^} to compute
-@texline @tmath{\pi^2 = 9.86960440109}.
+@texline @math{\pi^2 = 9.86960440109}.
@infoline the value of `pi' squared, 9.86960440109.
@noindent
@noindent
Type @kbd{' sqrt(2+3) @key{RET}} to compute
-@texline @tmath{\sqrt{2+3}}.
+@texline @math{\sqrt{2+3}}.
@infoline the square root of 2+3.
@noindent
Type @kbd{' pi^2 @key{RET}} to enter
-@texline @tmath{\pi^2}.
+@texline @math{\pi^2}.
@infoline `pi' squared.
To evaluate this symbolic formula as a number, type @kbd{=}.
@noindent
Type @kbd{v t} to transpose this
-@texline @tmath{3\times2}
+@texline @math{3\times2}
@infoline 3x2
matrix into a
-@texline @tmath{2\times3}
+@texline @math{2\times3}
@infoline 2x3
matrix. Type @w{@kbd{v u}} to unpack the rows into two separate
vectors. Now type @w{@kbd{V R + @key{TAB} V R +}} to compute the sums
In this case, the trail shows that four numbers (17.3, 3, 2, and 4)
were first entered into the Calculator, then the 2 and 4 were
-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}.
(The @samp{>} symbol shows that this was the most recent calculation.)
-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.
Most Calculator commands deal explicitly with the stack only, but
there is a set of commands that allow you to search back through
Quick Mode is very simple: It prompts you to type any formula in
standard algebraic notation (like @samp{4 - 2/3}) and then displays
-the result at the bottom of the Emacs screen (@i{3.33333333333}
+the result at the bottom of the Emacs screen (@mathit{3.33333333333}
in this case). You are then back in the same editing buffer you
were in before, ready to continue editing or to type @kbd{M-# q}
again to do another quick calculation. The result of the calculation
Calc was originally started as a two-week project to occupy a lull
in the author's schedule. Basically, a friend asked if I remembered
the value of
-@texline @tmath{2^{32}}.
+@texline @math{2^{32}}.
@infoline @expr{2^32}.
I didn't offhand, but I said, ``that's easy, just call up an
@code{xcalc}.'' @code{Xcalc} duly reported that the answer to our
if you're right. @xref{RPN Answer 1, 1}. (@bullet{})
(@bullet{}) @strong{Exercise 2.} Compute
-@texline @tmath{(2\times4) + (7\times9.4) + {5\over4}}
+@texline @math{(2\times4) + (7\times9.4) + {5\over4}}
@infoline @expr{2*4 + 7*9.5 + 5/4}
using the stack. @xref{RPN Answer 2, 2}. (@bullet{})
@end tex
@noindent
-The result of this expression will be the number @i{-6.99999826533}.
+The result of this expression will be the number @mathit{-6.99999826533}.
Calc's order of evaluation is the same as for most computer languages,
except that @samp{*} binds more strongly than @samp{/}, as the above
Operators at the same level are evaluated from left to right, except
that @samp{^} is evaluated from right to left. Thus, @samp{2-3-4} is
-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
to @samp{2^(3^4)} (a very large integer; try it!).
If you tire of typing the apostrophe all the time, there is an
of algebraic entries, using the @kbd{$} sign to tie them together.
In an algebraic formula, @kbd{$} represents the number on the top
of the stack. Here, we perform the calculation
-@texline @tmath{\sqrt{2\times4+1}},
+@texline @math{\sqrt{2\times4+1}},
@infoline @expr{sqrt(2*4+1)},
which on a traditional calculator would be done by pressing
@kbd{2 * 4 + 1 =} and then the square-root key.
@noindent
The shift-@kbd{S} command computes the sine of an angle. The sine
of 45 degrees is
-@texline @tmath{\sqrt{2}/2};
+@texline @math{\sqrt{2}/2};
@infoline @expr{sqrt(2)/2};
squaring this yields @expr{2/4 = 0.5}. However, there has been a slight
roundoff error because the representation of
-@texline @tmath{\sqrt{2}/2}
+@texline @math{\sqrt{2}/2}
@infoline @expr{sqrt(2)/2}
wasn't exact. The @kbd{c 1} command is a handy way to clean up numbers
in this case; it temporarily reduces the precision by one digit while it
@noindent
Here we compute the Inverse Sine of
-@texline @tmath{\sqrt{0.5}},
+@texline @math{\sqrt{0.5}},
@infoline @expr{sqrt(0.5)},
first in radians, then in degrees.
Let's compute the sine and cosine of an angle, and verify the
identity
-@texline @tmath{\sin^2x + \cos^2x = 1}.
+@texline @math{\sin^2x + \cos^2x = 1}.
@infoline @expr{sin(x)^2 + cos(x)^2 = 1}.
-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}.
With the angular mode set to degrees (type @w{@kbd{m d}}), do:
@smallexample
of squares, command.
Another identity is
-@texline @tmath{\displaystyle\tan x = {\sin x \over \cos x}}.
+@texline @math{\displaystyle\tan x = {\sin x \over \cos x}}.
@infoline @expr{tan(x) = sin(x) / cos(x)}.
@smallexample
@group
A physical interpretation of this calculation is that if you move
@expr{0.89879} units downward and @expr{0.43837} units to the right,
-your direction of motion is @i{-64} degrees from horizontal. Suppose
+your direction of motion is @mathit{-64} degrees from horizontal. Suppose
we move in the opposite direction, up and to the left:
@smallexample
A similar identity is supposed to hold for hyperbolic sines and cosines,
except that it is the @emph{difference}
-@texline @tmath{\cosh^2x - \sinh^2x}
+@texline @math{\cosh^2x - \sinh^2x}
@infoline @expr{cosh(x)^2 - sinh(x)^2}
that always equals one. Let's try to verify this identity.
If you take the factorial of a non-integer, Calc uses a generalized
factorial function defined in terms of Euler's Gamma function
-@texline @tmath{\Gamma(n)}
+@texline @math{\Gamma(n)}
@infoline @expr{gamma(n)}
(which is itself available as the @kbd{f g} command).
@noindent
Here we verify the identity
-@texline @tmath{n! = \Gamma(n+1)}.
+@texline @math{n! = \Gamma(n+1)}.
@infoline @expr{@var{n}!@: = gamma(@var{n}+1)}.
The binomial coefficient @var{n}-choose-@var{m}
-@texline or @tmath{\displaystyle {n \choose m}}
+@texline or @math{\displaystyle {n \choose m}}
is defined by
-@texline @tmath{\displaystyle {n! \over m! \, (n-m)!}}
+@texline @math{\displaystyle {n! \over m! \, (n-m)!}}
@infoline @expr{n!@: / m!@: (n-m)!}
for all reals @expr{n} and @expr{m}. The intermediate results in this
formula can become quite large even if the final result is small; the
(@bullet{}) @strong{Exercise 1.} Use @samp{*} to sum along the rows
of the above
-@texline @tmath{2\times3}
+@texline @math{2\times3}
@infoline 2x3
matrix to get @expr{[6, 15]}. Now use @samp{*} to sum along the columns
to get @expr{[5, 7, 9]}.
come out right, and the answer would be incorrect. If you
don't feel safe letting Calc take either interpretation of your
vectors, use explicit
-@texline @tmath{N\times1}
+@texline @math{N\times1}
@infoline Nx1
or
-@texline @tmath{1\times N}
+@texline @math{1\times N}
@infoline 1xN
matrices instead. In this case, you would enter the original column
vector as @samp{[[6], [2], [3]]} or @samp{[6; 2; 3]}.
$A^T A \, X = A^T B$, where $A^T$ is the transpose \samp{trn(A)}.
@end tex
Now
-@texline @tmath{A^T A}
+@texline @math{A^T A}
@infoline @expr{trn(A)*A}
is a square matrix so a solution is possible. It turns out that the
@expr{X} vector you compute in this way will be a ``least-squares''
(@bullet{}) @strong{Exercise 1.} Compute a vector of powers of two
from
-@texline @tmath{2^{-4}}
+@texline @math{2^{-4}}
@infoline @expr{2^-4}
to @expr{2^4}. @xref{List Answer 1, 1}. (@bullet{})
@noindent
where
-@texline @tmath{\sum x}
+@texline @math{\sum x}
@infoline @expr{sum(x)}
represents the sum of all the values of @expr{x}. While there is an
actual @code{sum} function in Calc, it's easier to sum a vector using a
@end smallexample
Let's ``plot'' this straight line approximation,
-@texline @tmath{y \approx m x + b},
+@texline @math{y \approx m x + b},
@infoline @expr{m x + b},
and compare it with the original data.
@cindex Maximizing a function over a list of values
@c [fix-ref Numerical Solutions]
(@bullet{}) @strong{Exercise 8.} Compute a list of values of Bessel's
-@texline @tmath{J_1(x)}
+@texline @math{J_1(x)}
@infoline @expr{J1}
function @samp{besJ(1,x)} for @expr{x} from 0 to 5 in steps of 0.25.
Find the value of @expr{x} (from among the above set of values) for
@cindex Digits, vectors of
(@bullet{}) @strong{Exercise 9.} You are given an integer in the range
-@texline @tmath{0 \le N < 10^m}
+@texline @math{0 \le N < 10^m}
@infoline @expr{0 <= N < 10^m}
for @expr{m=12} (i.e., an integer of less than
twelve digits). Convert this integer into a vector of @expr{m}
(@bullet{}) @strong{Exercise 11.} The area of a circle of radius one
is @cpi{}. The area of the
-@texline @tmath{2\times2}
+@texline @math{2\times2}
@infoline 2x2
square that encloses that circle is 4. So if we throw @var{n} darts at
random points in the square, about @cpiover{4} of them will land inside
the circle. This gives us an entertaining way to estimate the value of
@cpi{}. The @w{@kbd{k r}}
command picks a random number between zero and the value on the stack.
-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
@w{@kbd{2.0 k r 1 -}}. Build a vector of 100 random @expr{(x,y)} points in
this square, then use vector mapping and reduction to count how many
points lie inside the unit circle. Hint: Use the @kbd{v b} command.
of vertical lines with a spacing of one inch. Toss a one-inch matchstick
onto the field. The probability that the matchstick will land crossing
a line turns out to be
-@texline @tmath{2/\pi}.
+@texline @math{2/\pi}.
@infoline @expr{2/pi}.
Toss 100 matchsticks to estimate @cpi{}. (If you want still more fun,
the probability that the GCD (@w{@kbd{k g}}) of two large integers is
one turns out to be
-@texline @tmath{6/\pi^2}.
+@texline @math{6/\pi^2}.
@infoline @expr{6/pi^2}.
That provides yet another way to estimate @cpi{}.)
@xref{List Answer 12, 12}. (@bullet{})
function you give to the starting value 0, 1, 2, up to @var{n} times
and returns a vector of the results. Use this command to create a
``random walk'' of 50 steps. Start with the two-dimensional point
-@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
in both @expr{x} and @expr{y}; then take another step, and so on. Use the
@kbd{g f} command to display this random walk. Now modify your random
walk to walk a unit distance, but in a random direction, at each step.
@end smallexample
@noindent
-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
(@w{@expr{0 + 3i}}), but we can convert it to polar form (3 with a
phase angle of 90 degrees). All the usual arithmetic and scientific
operations are defined on both types of complex numbers.
@noindent
Since infinity is infinitely large, multiplying it by any finite
-number (like @i{-17}) has no effect, except that since @i{-17}
+number (like @mathit{-17}) has no effect, except that since @mathit{-17}
is negative, it changes a plus infinity to a minus infinity.
-(``A huge positive number, multiplied by @i{-17}, yields a huge
+(``A huge positive number, multiplied by @mathit{-17}, yields a huge
negative number.'') Adding any finite number to infinity also
leaves it unchanged. Taking an absolute value gives us plus
infinity again. Finally, we add this plus infinity to the minus
infinity we had earlier. If you work it out, you might expect
-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
lost next to the infinities; by the time we compute @w{@samp{inf - inf}}
the finite difference between them, if any, is undetectable.
So we say the result is @dfn{indeterminate}, which Calc writes
@cindex Torus, volume of
(@bullet{}) @strong{Exercise 7.} The volume of a torus (a donut shape) is
-@texline @tmath{2 \pi^2 R r^2}
+@texline @math{2 \pi^2 R r^2}
@infoline @w{@expr{2 pi^2 R r^2}}
where @expr{R} is the radius of the circle that
defines the center of the tube and @expr{r} is the radius of the tube
@cindex Fermat, primality test of
(@bullet{}) @strong{Exercise 10.} A theorem of Pierre de Fermat
says that
-@texline @w{@tmath{x^{n-1} \bmod n = 1}}
+@texline @w{@math{x^{n-1} \bmod n = 1}}
@infoline @expr{x^(n-1) mod n = 1}
if @expr{n} is a prime number and @expr{x} is an integer less than
@expr{n}. If @expr{n} is @emph{not} a prime number, this will
(@bullet{}) @strong{Exercise 11.} A rule of thumb is that one year
is about
-@texline @tmath{\pi \times 10^7}
+@texline @math{\pi \times 10^7}
@infoline @w{@expr{pi * 10^7}}
seconds. What time will it be that many seconds from right now?
@xref{Types Answer 11, 11}. (@bullet{})
@noindent
Calc has invented the variable @samp{s1} to represent an unknown sign;
-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
the ``let'' command to evaluate the expression when the sign is negative.
If we plugged this into our second derivative we would get the same,
negative, answer, so @expr{x = -1.19023} is also a maximum.
(@bullet{}) @strong{Exercise 3.} Find the integral from 1 to @expr{y}
of
-@texline @tmath{x \sin \pi x}
+@texline @math{x \sin \pi x}
@infoline @w{@expr{x sin(pi x)}}
(where the sine is calculated in radians). Find the values of the
integral for integers @expr{y} from 1 to 5. @xref{Algebra Answer 3,
Calc's integrator can do many simple integrals symbolically, but many
others are beyond its capabilities. Suppose we wish to find the area
under the curve
-@texline @tmath{\sin x \ln x}
+@texline @math{\sin x \ln x}
@infoline @expr{sin(x) ln(x)}
over the same range of @expr{x}. If you entered this formula and typed
@kbd{a i x @key{RET}} (don't bother to try this), Calc would work for a
@end tex
Compute the integral from 1 to 2 of
-@texline @tmath{\sin x \ln x}
+@texline @math{\sin x \ln x}
@infoline @expr{sin(x) ln(x)}
using Simpson's rule with 10 slices.
@xref{Algebra Answer 4, 4}. (@bullet{})
@end ignore
@tindex Si
(@bullet{}) @strong{Exercise 1.} The ``sine integral'' function
-@texline @tmath{{\rm Si}(x)}
+@texline @math{{\rm Si}(x)}
@infoline @expr{Si(x)}
is defined as the integral of @samp{sin(t)/t} for
@expr{t = 0} to @expr{x} in radians. (It was invented because this
@enumerate
@item
Compute
-@texline @tmath{\displaystyle{\sin x \over x}},
+@texline @math{\displaystyle{\sin x \over x}},
@infoline @expr{sin(x) / x},
where @expr{x} is the number on the top of the stack.
@cindex Phi, golden ratio
A fascinating property of the Fibonacci numbers is that the @expr{n}th
Fibonacci number can be found directly by computing
-@texline @tmath{\phi^n / \sqrt{5}}
+@texline @math{\phi^n / \sqrt{5}}
@infoline @expr{phi^n / sqrt(5)}
and then rounding to the nearest integer, where
-@texline @tmath{\phi} (``phi''),
+@texline @math{\phi} (``phi''),
@infoline @expr{phi},
the ``golden ratio,'' is
-@texline @tmath{(1 + \sqrt{5}) / 2}.
+@texline @math{(1 + \sqrt{5}) / 2}.
@infoline @expr{(1 + sqrt(5)) / 2}.
(For convenience, this constant is available from the @code{phi}
variable, or the @kbd{I H P} command.)
@cindex Continued fractions
(@bullet{}) @strong{Exercise 5.} The @dfn{continued fraction}
representation of
-@texline @tmath{\phi}
+@texline @math{\phi}
@infoline @expr{phi}
is
-@texline @tmath{1 + 1/(1 + 1/(1 + 1/( \ldots )))}.
+@texline @math{1 + 1/(1 + 1/(1 + 1/( \ldots )))}.
@infoline @expr{1 + 1/(1 + 1/(1 + 1/( ...@: )))}.
We can compute an approximate value by carrying this however far
and then replacing the innermost
-@texline @tmath{1/( \ldots )}
+@texline @math{1/( \ldots )}
@infoline @expr{1/( ...@: )}
by 1. Approximate
-@texline @tmath{\phi}
+@texline @math{\phi}
@infoline @expr{phi}
using a twenty-term continued fraction.
@xref{Programming Answer 5, 5}. (@bullet{})
property that all of the odd Bernoulli numbers are zero, and the
even ones, while difficult to compute, can be roughly approximated
by the formula
-@texline @tmath{\displaystyle{2 n! \over (2 \pi)^n}}.
+@texline @math{\displaystyle{2 n! \over (2 \pi)^n}}.
@infoline @expr{2 n!@: / (2 pi)^n}.
Let's write a keyboard macro to compute (approximate) Bernoulli numbers.
(Calc has a command, @kbd{k b}, to compute exact Bernoulli numbers, but
@noindent
where @expr{f'(x)} is the derivative of @expr{f}. The @expr{x}
values will quickly converge to a solution, i.e., eventually
-@texline @tmath{x_{\rm new}}
+@texline @math{x_{\rm new}}
@infoline @expr{new_x}
and @expr{x} will be equal to within the limits
of the current precision. Write a program which takes a formula
involving the variable @expr{x}, and an initial guess @expr{x_0},
on the stack, and produces a value of @expr{x} for which the formula
is zero. Use it to find a solution of
-@texline @tmath{\sin(\cos x) = 0.5}
+@texline @math{\sin(\cos x) = 0.5}
@infoline @expr{sin(cos(x)) = 0.5}
near @expr{x = 4.5}. (Use angles measured in radians.) Note that
the built-in @w{@kbd{a R}} (@code{calc-find-root}) command uses Newton's
@cindex Gamma constant, Euler's
@cindex Euler's gamma constant
(@bullet{}) @strong{Exercise 9.} The @dfn{digamma} function
-@texline @tmath{\psi(z) (``psi'')}
+@texline @math{\psi(z) (``psi'')}
@infoline @expr{psi(z)}
is defined as the derivative of
-@texline @tmath{\ln \Gamma(z)}.
+@texline @math{\ln \Gamma(z)}.
@infoline @expr{ln(gamma(z))}.
For large values of @expr{z}, it can be approximated by the infinite sum
@noindent
where
-@texline @tmath{\sum}
+@texline @math{\sum}
@infoline @expr{sum}
represents the sum over @expr{n} from 1 to infinity
(or to some limit high enough to give the desired accuracy), and
While this sum is not guaranteed to converge, in practice it is safe.
An interesting mathematical constant is Euler's gamma, which is equal
to about 0.5772. One way to compute it is by the formula,
-@texline @tmath{\gamma = -\psi(1)}.
+@texline @math{\gamma = -\psi(1)}.
@infoline @expr{gamma = -psi(1)}.
Unfortunately, 1 isn't a large enough argument
for the above formula to work (5 is a much safer value for @expr{z}).
Fortunately, we can compute
-@texline @tmath{\psi(1)}
+@texline @math{\psi(1)}
@infoline @expr{psi(1)}
from
-@texline @tmath{\psi(5)}
+@texline @math{\psi(5)}
@infoline @expr{psi(5)}
using the recurrence
-@texline @tmath{\psi(z+1) = \psi(z) + {1 \over z}}.
+@texline @math{\psi(z+1) = \psi(z) + {1 \over z}}.
@infoline @expr{psi(z+1) = psi(z) + 1/z}.
Your task: Develop a program to compute
-@texline @tmath{\psi(z)};
+@texline @math{\psi(z)};
@infoline @expr{psi(z)};
it should ``pump up'' @expr{z}
if necessary to be greater than 5, then use the above summation
formula. Use looping commands to compute the sum. Use your function
to compute
-@texline @tmath{\gamma}
+@texline @math{\gamma}
@infoline @expr{gamma}
to twelve decimal places. (Calc has a built-in command
for Euler's constant, @kbd{I P}, which you can use to check your answer.)
@kbd{1 @key{RET} 2 @key{RET} 3 @key{RET} 4 + * -}
The result is
-@texline @tmath{1 - (2 \times (3 + 4)) = -13}.
+@texline @math{1 - (2 \times (3 + 4)) = -13}.
@infoline @expr{1 - (2 * (3 + 4)) = -13}.
@node RPN Answer 2, RPN Answer 3, RPN Answer 1, Answers to Exercises
@subsection RPN Tutorial Exercise 2
@noindent
-@texline @tmath{2\times4 + 7\times9.5 + {5\over4} = 75.75}
+@texline @math{2\times4 + 7\times9.5 + {5\over4} = 75.75}
@infoline @expr{2*4 + 7*9.5 + 5/4 = 75.75}
After computing the intermediate term
-@texline @tmath{2\times4 = 8},
+@texline @math{2\times4 = 8},
@infoline @expr{2*4 = 8},
you can leave that result on the stack while you compute the second
term. With both of these results waiting on the stack you can then
down to an integer. Consider @expr{123456789 / 2} when the current
precision is 6 digits. The true answer is @expr{61728394.5}, but
with a precision of 6 this will be rounded to
-@texline @tmath{12345700.0/2.0 = 61728500.0}.
+@texline @math{12345700.0/2.0 = 61728500.0}.
@infoline @expr{12345700.@: / 2.@: = 61728500.}.
The result, when converted to an integer, will be off by 106.
@noindent
To solve
-@texline @tmath{A^T A \, X = A^T B},
+@texline @math{A^T A \, X = A^T B},
@infoline @expr{trn(A) * A * X = trn(A) * B},
first we compute
-@texline @tmath{A' = A^T A}
+@texline @math{A' = A^T A}
@infoline @expr{A2 = trn(A) * A}
and
-@texline @tmath{B' = A^T B};
+@texline @math{B' = A^T B};
@infoline @expr{B2 = trn(A) * B};
now, we have a system
-@texline @tmath{A' X = B'}
+@texline @math{A' X = B'}
@infoline @expr{A2 * X = B2}
which we can solve using Calc's @samp{/} command.
The first step is to enter the coefficient matrix. We'll store it in
quick variable number 7 for later reference. Next, we compute the
-@texline @tmath{B'}
+@texline @math{B'}
@infoline @expr{B2}
vector.
@noindent
Now we compute the matrix
-@texline @tmath{A'}
+@texline @math{A'}
@infoline @expr{A2}
and divide.
round-off error.)
Notice that the answers are similar to those for the
-@texline @tmath{3\times3}
+@texline @math{3\times3}
@infoline 3x3
system solved in the text. That's because the fourth equation that was
added to the system is almost identical to the first one multiplied
by two. (If it were identical, we would have gotten the exact same
answer since the
-@texline @tmath{4\times3}
+@texline @math{4\times3}
@infoline 4x3
system would be equivalent to the original
-@texline @tmath{3\times3}
+@texline @math{3\times3}
@infoline 3x3
system.)
@end tex
Thus we want a
-@texline @tmath{19\times2}
+@texline @math{19\times2}
@infoline 19x2
matrix with our @expr{x} vector as one column and
ones as the other column. So, first we build the column of ones, then
@noindent
Now we compute
-@texline @tmath{A^T y}
+@texline @math{A^T y}
@infoline @expr{trn(A) * y}
and
-@texline @tmath{A^T A}
+@texline @math{A^T A}
@infoline @expr{trn(A) * A}
and divide.
@end smallexample
Since we were solving equations of the form
-@texline @tmath{m \times x + b \times 1 = y},
+@texline @math{m \times x + b \times 1 = y},
@infoline @expr{m*x + b*1 = y},
these numbers should be @expr{m} and @expr{b}, respectively. Sure
enough, they agree exactly with the result computed using @kbd{V M} and
@noindent
A number @expr{j} is a divisor of @expr{n} if
-@texline @tmath{n \mathbin{\hbox{\code{\%}}} j = 0}.
+@texline @math{n \mathbin{\hbox{\code{\%}}} j = 0}.
@infoline @samp{n % j = 0}.
The first step is to get a vector that identifies the divisors.
the job is pretty straightforward.
Incidentally, Calc provides the
-@texline @dfn{M@"obius} @tmath{\mu}
+@texline @dfn{M@"obius} @math{\mu}
@infoline @dfn{Moebius mu}
function which is zero if and only if its argument is square-free. It
would be a much more convenient way to do the above test in practice.
the ``triangular numbers'' (now you know why!). The @expr{n}th
triangular number is the sum of the integers from 1 to @expr{n}, and
can be computed directly by the formula
-@texline @tmath{n (n+1) \over 2}.
+@texline @math{n (n+1) \over 2}.
@infoline @expr{n * (n+1) / 2}.
@smallexample
@noindent
It's a good idea to verify, as in the last step above, that only
one value is equal to the maximum. (After all, a plot of
-@texline @tmath{\sin x}
+@texline @math{\sin x}
@infoline @expr{sin(x)}
might have many points all equal to the maximum value, 1.)
symmetries. First of all, after some thought it's clear that the
@expr{y} axis can be ignored altogether. Just pick a random @expr{x}
component for one end of the match, pick a random direction
-@texline @tmath{\theta},
+@texline @math{\theta},
@infoline @expr{theta},
and see if @expr{x} and
-@texline @tmath{x + \cos \theta}
+@texline @math{x + \cos \theta}
@infoline @expr{x + cos(theta)}
(which is the @expr{x} coordinate of the other endpoint) cross a line.
The lines are at integer coordinates, so this happens when the two
endpoint. The rightmost endpoint will be between 0 and 1 if the
match does not cross a line, or between 1 and 2 if it does. So:
Pick random @expr{x} and
-@texline @tmath{\theta},
+@texline @math{\theta},
@infoline @expr{theta},
compute
-@texline @tmath{x + \cos \theta},
+@texline @math{x + \cos \theta},
@infoline @expr{x + cos(theta)},
and count how many of the results are greater than one. Simple!
@noindent
Aha! It's unlikely that an irrational number would equal a fraction
this simple to within ten digits, so our original number was probably
-@texline @tmath{\sqrt{27 \pi / 53}}.
+@texline @math{\sqrt{27 \pi / 53}}.
@infoline @expr{sqrt(27 pi / 53)}.
Notice that we didn't need to re-round the number when we reduced the
The fourth calculation, @samp{1 / (-10 .. 10)}, has the same problem.
Zero is buried inside the interval, but it's still a possible value.
It's not hard to see that the actual result of @samp{1 / (-10 .. 10)}
-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
the interval goes from minus infinity to plus infinity, with a ``hole''
-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
represent this, so it just reports @samp{[-inf .. inf]} as the answer.
It may be disappointing to hear ``the answer lies somewhere between
minus infinity and plus infinity, inclusive,'' but that's the best
@end smallexample
@noindent
-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
3, its square is between 0 and 9.'' The second case says, ``the product
-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.''
An interval form is not a number; it is a symbol that can stand for
many different numbers. Two identical-looking interval forms can stand
@noindent
Computing
-@texline @tmath{\displaystyle{\sin x \over x}}:
+@texline @math{\displaystyle{\sin x \over x}}:
@infoline @expr{sin(x) / x}:
Using the stack: @kbd{C-x ( @key{RET} S @key{TAB} / C-x )}.
@noindent
This program is quite efficient because Calc knows how to raise a
matrix (or other value) to the power @expr{n} in only
-@texline @tmath{\log_2 n}
+@texline @math{\log_2 n}
@infoline @expr{log(n,2)}
steps. For example, this program can compute the 1000th Fibonacci
number (a 209-digit integer!) in about 10 steps; even though the
@noindent
The first step is to compute the derivative @expr{f'(x)} and thus
the formula
-@texline @tmath{\displaystyle{x - {f(x) \over f'(x)}}}.
+@texline @math{\displaystyle{x - {f(x) \over f'(x)}}}.
@infoline @expr{x - f(x)/f'(x)}.
(Because this definition is long, it will be repeated in concise form
The first step is to adjust @expr{z} to be greater than 5. A simple
``for'' loop will do the job here. If @expr{z} is less than 5, we
reduce the problem using
-@texline @tmath{\psi(z) = \psi(z+1) - 1/z}.
+@texline @math{\psi(z) = \psi(z+1) - 1/z}.
@infoline @expr{psi(z) = psi(z+1) - 1/z}. We go
on to compute
-@texline @tmath{\psi(z+1)},
+@texline @math{\psi(z+1)},
@infoline @expr{psi(z+1)},
and remember to add back a factor of @expr{-1/z} when we're done. This
step is repeated until @expr{z > 5}.
@end smallexample
Now we compute the initial part of the sum:
-@texline @tmath{\ln z - {1 \over 2z}}
+@texline @math{\ln z - {1 \over 2z}}
@infoline @expr{ln(z) - 1/2z}
minus the adjustment factor.
@end smallexample
This is the value of
-@texline @tmath{-\gamma},
+@texline @math{-\gamma},
@infoline @expr{- gamma},
with a slight bit of roundoff error. To get a full 12 digits, let's use
a higher precision:
@noindent
Taking the derivative of a term of the form @expr{x^n} will produce
a term like
-@texline @tmath{n x^{n-1}}.
+@texline @math{n x^{n-1}}.
@infoline @expr{n x^(n-1)}.
Taking the derivative of a constant
produces zero. From this it is easy to see that the @expr{n}th
@kbd{+} key always ``pops'' the top two numbers from the stack, adds them,
and pushes the result (3) back onto the stack. This number is ready for
further calculations: @kbd{5 -} pushes 5 onto the stack, then pops the
-3 and 5, subtracts them, and pushes the result (@i{-2}).
+3 and 5, subtracts them, and pushes the result (@mathit{-2}).
Note that the ``top'' of the stack actually appears at the @emph{bottom}
of the buffer. A line containing a single @samp{.} character signifies
of the number on the top of the stack or the number currently being entered.
The @kbd{_} key begins entry of a negative number or changes the sign of
the number currently being entered. The following sequences all enter the
-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}},
@kbd{5 @key{RET} n}, @kbd{_ 5 @key{RET}}, @kbd{5 _ @key{RET}}.
Some other keys are active during numeric entry, such as @kbd{#} for
Calculations can also be entered in algebraic form. This is accomplished
by typing the apostrophe key, @kbd{'}, followed by the expression in
standard format: @kbd{@key{'} 2+3*4 @key{RET}} computes
-@texline @tmath{2+(3\times4) = 14}
+@texline @math{2+(3\times4) = 14}
@infoline @expr{2+(3*4) = 14}
and pushes that on the stack. If you wish you can
ignore the RPN aspect of Calc altogether and simply enter algebraic
unless you raise the precision still further. Many operations such as
logarithms and sines make use of similarly cached values such as
@cpiover{4} and
-@texline @tmath{\ln 2}.
+@texline @math{\ln 2}.
@infoline @expr{ln(2)}.
The visible effect of caching is that
high-precision computations may seem to do extra work the first time.
notation. The number of significant digits in the fractional part is
governed by the current floating precision (@pxref{Precision}). The
range of acceptable values is from
-@texline @tmath{10^{-3999999}}
+@texline @math{10^{-3999999}}
@infoline @expr{10^-3999999}
(inclusive) to
-@texline @tmath{10^{4000000}}
+@texline @math{10^{4000000}}
@infoline @expr{10^4000000}
(exclusive), plus the corresponding negative values and zero.
notation; @pxref{Complex Formats}.
Polar complex numbers are displayed in the form
-@texline `@t{(}@var{r}@t{;}@tmath{\theta}@t{)}'
+@texline `@t{(}@var{r}@t{;}@math{\theta}@t{)}'
@infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}'
where @var{r} is the nonnegative magnitude and
-@texline @tmath{\theta}
+@texline @math{\theta}
@infoline @var{theta}
is the argument or phase angle. The range of
-@texline @tmath{\theta}
+@texline @math{\theta}
@infoline @var{theta}
depends on the current angular mode (@pxref{Angular Modes}); it is
-generally between @i{-180} and @i{+180} degrees or the equivalent range
+generally between @mathit{-180} and @mathit{+180} degrees or the equivalent range
in radians.
Complex numbers are entered in stages using incomplete objects.
that if @expr{x} got ``all the way to infinity,'' then @expr{1 / x}
would go all the way to zero. Similarly, when they say that
@samp{exp(inf) = inf}, they mean that
-@texline @tmath{e^x}
+@texline @math{e^x}
@infoline @expr{exp(x)}
grows without bound as @expr{x} grows. The symbol @samp{-inf} likewise
stands for an infinitely negative real value; for example, we say that
@tindex vec
Algebraic functions for building vectors include @samp{vec(a, b, c)}
to build @samp{[a, b, c]}, @samp{cvec(a, n, m)} to build an
-@texline @tmath{n\times m}
+@texline @math{n\times m}
@infoline @var{n}x@var{m}
matrix of @samp{a}s, and @samp{index(n)} to build a vector of integers
from 1 to @samp{n}.
The @var{secs} value is a real number between 0 (inclusive) and 60
(exclusive). A positive HMS form is interpreted as @var{hours} +
@var{mins}/60 + @var{secs}/3600. A negative HMS form is interpreted
-as @i{- @var{hours}} @i{-} @var{mins}/60 @i{-} @var{secs}/3600.
+as @mathit{- @var{hours}} @mathit{-} @var{mins}/60 @mathit{-} @var{secs}/3600.
Display format for HMS forms is quite flexible. @xref{HMS Formats}.
HMS forms can be added and subtracted. When they are added to numbers,
Calc uses the Julian calendar for all dates before the year 1752,
including dates BC when the Julian calendar technically had not
-yet been invented. Thus the claim that day number @i{-10000} is
+yet been invented. Thus the claim that day number @mathit{-10000} is
called ``August 16, 28 BC'' should be taken with a grain of salt.
Please note that there is no ``year 0''; the day before
@samp{<Sat Jan 1, +1>} is @samp{<Fri Dec 31, -1>}. These are
-days 0 and @i{-1} respectively in Calc's internal numbering scheme.
+days 0 and @mathit{-1} respectively in Calc's internal numbering scheme.
@cindex Julian day counting
Another day counting system in common use is, confusingly, also
Scaliger, who named it in honor of his father Julius Caesar
Scaliger. For obscure reasons he chose to start his day
numbering on Jan 1, 4713 BC at noon, which in Calc's scheme
-is @i{-1721423.5} (recall that Calc starts at midnight instead
+is @mathit{-1721423.5} (recall that Calc starts at midnight instead
of noon). Thus to convert a Calc date code obtained by
unpacking a date form into a Julian day number, simply add
1721423.5. The Julian code for @samp{6:00am Jan 9, 1991}
often arises in number theory. Modulo forms are written
`@var{a} @t{mod} @var{M}',
where @var{a} and @var{M} are real numbers or HMS forms, and
-@texline @tmath{0 \le a < M}.
+@texline @math{0 \le a < M}.
@infoline @expr{0 <= a < @var{M}}.
In many applications @expr{a} and @expr{M} will be
integers but this is not required.
roots, are not yet supported for modulo forms. (Note that, although
@w{`@t{(}@var{a} @t{mod} @var{M}@t{)^.5}'} will compute a ``modulo square root''
in the sense of reducing
-@texline @tmath{\sqrt a}
+@texline @math{\sqrt a}
@infoline @expr{sqrt(a)}
modulo @expr{M}, this is not a useful definition from the
number-theoretical point of view.)
@cindex Standard deviations
An @dfn{error form} is a number with an associated standard
deviation, as in @samp{2.3 +/- 0.12}. The notation
-@texline `@var{x} @t{+/-} @tmath{\sigma}'
+@texline `@var{x} @t{+/-} @math{\sigma}'
@infoline `@var{x} @t{+/-} sigma'
stands for an uncertain value which follows
a normal or Gaussian distribution of mean @expr{x} and standard
deviation or ``error''
-@texline @tmath{\sigma}.
+@texline @math{\sigma}.
@infoline @expr{sigma}.
Both the mean and the error can be either numbers or
formulas. Generally these are real numbers but the mean may also be
All arithmetic and transcendental functions accept error forms as input.
Operations on the mean-value part work just like operations on regular
numbers. The error part for any function @expr{f(x)} (such as
-@texline @tmath{\sin x}
+@texline @math{\sin x}
@infoline @expr{sin(x)})
is defined by the error of @expr{x} times the derivative of @expr{f}
evaluated at the mean value of @expr{x}. For a two-argument function
of standard deviations. Actual errors often are neither Gaussian-distributed
nor uncorrelated, and the above formulas are valid only when errors
are small. As an example, the error arising from
-@texline `@t{sin(}@var{x} @t{+/-} @tmath{\sigma}@t{)}'
+@texline `@t{sin(}@var{x} @t{+/-} @math{\sigma}@t{)}'
@infoline `@t{sin(}@var{x} @t{+/-} @var{sigma}@t{)}'
is
-@texline `@tmath{\sigma} @t{abs(cos(}@var{x}@t{))}'.
+@texline `@math{\sigma} @t{abs(cos(}@var{x}@t{))}'.
@infoline `@var{sigma} @t{abs(cos(}@var{x}@t{))}'.
When @expr{x} is close to zero,
-@texline @tmath{\cos x}
+@texline @math{\cos x}
@infoline @expr{cos(x)}
is close to one so the error in the sine is close to
-@texline @tmath{\sigma};
+@texline @math{\sigma};
@infoline @expr{sigma};
this makes sense, since
-@texline @tmath{\sin x}
+@texline @math{\sin x}
@infoline @expr{sin(x)}
is approximately @expr{x} near zero, so a given error in @expr{x} will
produce about the same error in the sine. Likewise, near 90 degrees
-@texline @tmath{\cos x}
+@texline @math{\cos x}
@infoline @expr{cos(x)}
is nearly zero and so the computed error is
small: The sine curve is nearly flat in that region, so an error in @expr{x}
has relatively little effect on the value of
-@texline @tmath{\sin x}.
+@texline @math{\sin x}.
@infoline @expr{sin(x)}.
However, consider @samp{sin(90 +/- 1000)}. The cosine of 90 is zero, so
Calc will report zero error! We get an obviously wrong result because
we have violated the small-error approximation underlying the error
analysis. If the error in @expr{x} had been small, the error in
-@texline @tmath{\sin x}
+@texline @math{\sin x}
@infoline @expr{sin(x)}
would indeed have been negligible.
While it may seem that intervals and error forms are similar, they are
based on entirely different concepts of inexact quantities. An error
form
-@texline `@var{x} @t{+/-} @tmath{\sigma}'
+@texline `@var{x} @t{+/-} @math{\sigma}'
@infoline `@var{x} @t{+/-} @var{sigma}'
means a variable is random, and its value could
be anything but is ``probably'' within one
-@texline @tmath{\sigma}
+@texline @math{\sigma}
@infoline @var{sigma}
of the mean value @expr{x}. An interval
`@t{[}@var{a} @t{..@:} @var{b}@t{]}' means a
Note that, unlike in usual computer notation, multiplication binds more
strongly than division: @samp{a*b/c*d} is equivalent to
-@texline @tmath{a b \over c d}.
+@texline @math{a b \over c d}.
@infoline @expr{(a*b)/(c*d)}.
@cindex Multiplication, implicit
element at level @var{n} up to the top. (Compare with @key{LFD},
which copies instead of moving the element in level @var{n}.)
-With a negative argument @i{-@var{n}}, @key{TAB} rotates the stack
+With a negative argument @mathit{-@var{n}}, @key{TAB} rotates the stack
to move the object in level @var{n} to the deepest place in the
-stack, and the object in level @i{@var{n}+1} to the top. @kbd{M-@key{TAB}}
-rotates the deepest stack element to be in level @i{n}, also
-putting the top stack element in level @i{@var{n}+1}.
+stack, and the object in level @mathit{@var{n}+1} to the top. @kbd{M-@key{TAB}}
+rotates the deepest stack element to be in level @mathit{n}, also
+putting the top stack element in level @mathit{@var{n}+1}.
@xref{Selecting Subformulas}, for a way to apply these commands to
any portion of a vector or formula on the stack.
is because you are presumably switching to your @file{~/.emacs} file,
which may contain other things you don't want to reread. You can give
a numeric prefix argument of 1 to @kbd{m F} to force it to read the
-file no matter what its name. Conversely, an argument of @i{-1} tells
-@kbd{m F} @emph{not} to read the new file. An argument of 2 or @i{-2}
+file no matter what its name. Conversely, an argument of @mathit{-1} tells
+@kbd{m F} @emph{not} to read the new file. An argument of 2 or @mathit{-2}
tells @kbd{m F} not to reset the modes to their defaults beforehand,
which is useful if you intend your new file to have a variant of the
modes present in the file you were using before.
If both of these flags are set at once, the effect will be
@code{calc-arcsinh}. (The Hyperbolic flag is also used by some
non-trigonometric commands; for example @kbd{H L} computes a base-10,
-instead of base-@i{e}, logarithm.)
+instead of base-@mathit{e}, logarithm.)
Command names like @code{calc-arcsin} are provided for completeness, and
may be executed with @kbd{x} or @kbd{M-x}. Their effect is simply to
which zero is treated as positive instead of being directionless.
Thus, @samp{1 / 0 = inf} and @samp{-1 / 0 = -inf} in this mode.
Note that zero never actually has a sign in Calc; there are no
-separate representations for @i{+0} and @i{-0}. Positive
+separate representations for @mathit{+0} and @mathit{-0}. Positive
infinite mode merely changes the interpretation given to the
single symbol, @samp{0}. One consequence of this is that, while
you might expect @samp{1 / -0 = -inf}, actually @samp{1 / -0}
Calc uses this information to determine when certain simplifications
of formulas are safe. For example, @samp{(x^y)^z} cannot be
simplified to @samp{x^(y z)} in general; for example,
-@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}.
However, this simplification @emph{is} safe if @code{z} is known
to be an integer, or if @code{x} is known to be a nonnegative
real number. If you have given declarations that allow Calc to
@end table
Calc does not check the declarations for a variable when you store
-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
been declared @code{pos}, @code{int}, or @code{matrix} may have
unexpected effects; Calc may evaluate @samp{sqrt(x^2)} to @expr{3.5}
if it substitutes the value first, or to @expr{-3.5} if @code{x}
current binary word size. (@xref{Binary Functions}, for a discussion of
word size.) If the absolute value of the word size is @expr{w}, all integers
are displayed with at least enough digits to represent
-@texline @tmath{2^w-1}
+@texline @math{2^w-1}
@infoline @expr{(2^w)-1}
in the current radix. (Larger integers will still be displayed in their
entirety.)
parentheses for very simple arguments. During input, curly braces and
parentheses work equally well for grouping, but when the document is
formatted the curly braces will be invisible. Thus the printed result is
-@texline @tmath{\sin{2 x}}
+@texline @math{\sin{2 x}}
@infoline @expr{sin 2x}
but
-@texline @tmath{\sin(2 + x)}.
+@texline @math{\sin(2 + x)}.
@infoline @expr{sin(2 + x)}.
Function and variable names not treated specially by @TeX{} are simply
Command is @kbd{m p}.
@item
-Matrix/scalar mode. Default value is @i{-1}. Value is 0 for scalar
-mode, @i{-2} for matrix mode, or @var{N} for
-@texline @tmath{N\times N}
+Matrix/scalar mode. Default value is @mathit{-1}. Value is 0 for scalar
+mode, @mathit{-2} for matrix mode, or @var{N} for
+@texline @math{N\times N}
@infoline @var{N}x@var{N}
matrix mode. Command is @kbd{m v}.
@item
-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}),
0 for @kbd{m N}, 2 for @kbd{m B}, 3 for @kbd{m A}, 4 for @kbd{m E},
or 5 for @w{@kbd{m U}}. The @kbd{m D} command accepts these prefixes.
@item
-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,
or 0 if the mode is on with positive zeros. Command is @kbd{m i}.
@end enumerate
@tindex -
The @kbd{-} (@code{calc-minus}) command subtracts two values. The top
number on the stack is subtracted from the one behind it, so that the
-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
available for @kbd{+} are available for @kbd{-} as well.
@kindex *
@pindex calc-sign
@tindex sign
The @kbd{f s} (@code{calc-sign}) [@code{sign}] command returns 1 if its
-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
argument is zero. In algebraic form, you can also write @samp{sign(a,x)}
which evaluates to @samp{x * sign(a)}, i.e., either @samp{x}, @samp{-x}, or
zero depending on the sign of @samp{a}.
the ``mantissa'' part @expr{m} of its floating-point argument; @kbd{f X}
(@code{calc-xpon-part}) [@code{xpon}] extracts the ``exponent'' part
@expr{e}. The original number is equal to
-@texline @tmath{m \times 10^e},
+@texline @math{m \times 10^e},
@infoline @expr{m * 10^e},
where @expr{m} is in the interval @samp{[1.0 ..@: 10.0)} except that
@expr{m=e=0} if the original number is zero. For integers
is 6 digits yields @samp{12.3457}. If the current precision had been
8 digits, the result would have been @samp{12.345601}. Incrementing
@samp{0.0} produces
-@texline @tmath{10^{-p}},
+@texline @math{10^{-p}},
@infoline @expr{10^-p},
where @expr{p} is the current
precision. These operations are defined only on integers and floats.
The @kbd{F} (@code{calc-floor}) [@code{floor} or @code{ffloor}] command
truncates a real number to the next lower integer, i.e., toward minus
infinity. Thus @kbd{3.6 F} produces 3, but @kbd{_3.6 F} produces
-@i{-4}.
+@mathit{-4}.
@kindex I F
@pindex calc-ceiling
@kindex H I F
The @kbd{I F} (@code{calc-ceiling}) [@code{ceil} or @code{fceil}]
command truncates toward positive infinity. Thus @kbd{3.6 I F} produces
-4, and @kbd{_3.6 I F} produces @i{-3}.
+4, and @kbd{_3.6 I F} produces @mathit{-3}.
@kindex R
@pindex calc-round
rounds to the nearest integer. When the fractional part is .5 exactly,
this command rounds away from zero. (All other rounding in the
Calculator uses this convention as well.) Thus @kbd{3.5 R} produces 4
-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}.
@kindex I R
@pindex calc-trunc
The @kbd{I R} (@code{calc-trunc}) [@code{trunc} or @code{ftrunc}]
command truncates toward zero. In other words, it ``chops off''
everything after the decimal point. Thus @kbd{3.6 I R} produces 3 and
-@kbd{_3.6 I R} produces @i{-3}.
+@kbd{_3.6 I R} produces @mathit{-3}.
These functions may not be applied meaningfully to error forms, but they
do work for intervals. As a convenience, applying @code{floor} to a
The @kbd{G} (@code{calc-argument}) [@code{arg}] command computes the
``argument'' or polar angle of a complex number. For a number in polar
notation, this is simply the second component of the pair
-@texline `@t{(}@var{r}@t{;}@tmath{\theta}@t{)}'.
+@texline `@t{(}@var{r}@t{;}@math{\theta}@t{)}'.
@infoline `@t{(}@var{r}@t{;}@var{theta}@t{)}'.
The result is expressed according to the current angular mode and will
-be in the range @i{-180} degrees (exclusive) to @i{+180} degrees
+be in the range @mathit{-180} degrees (exclusive) to @mathit{+180} degrees
(inclusive), or the equivalent range in radians.
@pindex calc-imaginary
@pindex calc-pack
The @kbd{v p} (@code{calc-pack}) command can pack the top two numbers on
the stack into a composite object such as a complex number. With
-a prefix argument of @i{-1}, it produces a rectangular complex number;
-with an argument of @i{-2}, it produces a polar complex number.
+a prefix argument of @mathit{-1}, it produces a rectangular complex number;
+with an argument of @mathit{-2}, it produces a polar complex number.
(Also, @pxref{Building Vectors}.)
@ignore
The @kbd{c c} (@code{calc-clean}) [@code{pclean}] command ``cleans'' the
number on the top of the stack. Floating point numbers are re-rounded
according to the current precision. Polar numbers whose angular
-components have strayed from the @i{-180} to @i{+180} degree range
+components have strayed from the @mathit{-180} to @mathit{+180} degree range
are normalized. (Note that results will be undesirable if the current
angular mode is different from the one under which the number was
produced!) Integers and fractions are generally unaffected by this
@var{n} in the range from 1 to 366, @kbd{t Y} computes the
@var{n}th day of the year (366 is treated as 365 in non-leap
years). A prefix argument of 0 computes the last day of the
-year (December 31). A negative prefix argument from @i{-1} to
-@i{-12} computes the first day of the @var{n}th month of the year.
+year (December 31). A negative prefix argument from @mathit{-1} to
+@mathit{-12} computes the first day of the @var{n}th month of the year.
@kindex t W
@pindex calc-new-week
name of a function that is used to compute the daylight savings
adjustment for a given date. The default is
@code{math-std-daylight-savings}, which computes an adjustment
-(either 0 or @i{-1}) using the North American rules given above.
+(either 0 or @mathit{-1}) using the North American rules given above.
The daylight savings hook function is called with four arguments:
The date, as a floating-point number in standard Calc format;
@noindent
The @code{bump} parameter is equal to zero when Calc is converting
from a date form in a generalized time zone into a GMT date value.
-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
adjustments shown above ensure that the conversion behaves correctly
and reasonably around the 2 a.m.@: transition in each direction.
If the word size is negative, binary operations produce 2's complement
integers from
-@texline @tmath{-2^{-w-1}}
+@texline @math{-2^{-w-1}}
@infoline @expr{-(2^(-w-1))}
to
-@texline @tmath{2^{-w-1}-1}
+@texline @math{2^{-w-1}-1}
@infoline @expr{2^(-w-1)-1}
inclusive. Either mode accepts inputs in any range; the sign of
@expr{w} affects only the results produced.
generally is not ``binary.'' (However, @pxref{Simplification Modes},
@code{calc-bin-simplify-mode}.) For example, with a word size of 8
bits @kbd{b c} converts a number to the range 0 to 255; with a word
-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.
@kindex b w
@pindex calc-word-size
optional second (or third) word-size parameter. When a formula like
@samp{and(a,b)} is finally evaluated, the word size current at that time
will be used, but when @samp{and(a,b,-8)} is evaluated, a word size of
-@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
in symbolic form unless the all of its argument(s) are integers or
integer-valued floats.
the value of @cpi{} (at the current precision) onto the stack. With the
Hyperbolic flag, it pushes the value @expr{e}, the base of natural logarithms.
With the Inverse flag, it pushes Euler's constant
-@texline @tmath{\gamma}
+@texline @math{\gamma}
@infoline @expr{gamma}
(about 0.5772). With both Inverse and Hyperbolic, it
pushes the ``golden ratio''
-@texline @tmath{\phi}
+@texline @math{\phi}
@infoline @expr{phi}
(about 1.618). (At present, Euler's constant is not available
to unlimited precision; Calc knows only the first 100 digits.)
it raises ten to a given power.) Note that the common logarithm of a
complex number is computed by taking the natural logarithm and dividing
by
-@texline @tmath{\ln10}.
+@texline @math{\ln10}.
@infoline @expr{ln(10)}.
@kindex B
@tindex alog
The @kbd{B} (@code{calc-log}) [@code{log}] command computes a logarithm
to any base. For example, @kbd{1024 @key{RET} 2 B} produces 10, since
-@texline @tmath{2^{10} = 1024}.
+@texline @math{2^{10} = 1024}.
@infoline @expr{2^10 = 1024}.
In certain cases like @samp{log(3,9)}, the result
will be either @expr{1:2} or @expr{0.5} depending on the current Fraction
@pindex calc-expm1
@tindex expm1
The @kbd{f E} (@code{calc-expm1}) [@code{expm1}] command computes
-@texline @tmath{e^x - 1},
+@texline @math{e^x - 1},
@infoline @expr{exp(x)-1},
but using an algorithm that produces a more accurate
answer when the result is close to zero, i.e., when
-@texline @tmath{e^x}
+@texline @math{e^x}
@infoline @expr{exp(x)}
is close to one.
@pindex calc-lnp1
@tindex lnp1
The @kbd{f L} (@code{calc-lnp1}) [@code{lnp1}] command computes
-@texline @tmath{\ln(x+1)},
+@texline @math{\ln(x+1)},
@infoline @expr{ln(x+1)},
producing a more accurate answer when @expr{x} is close to zero.
@tindex arctan2
The @kbd{f T} (@code{calc-arctan2}) [@code{arctan2}] command takes two
numbers from the stack and computes the arc tangent of their ratio. The
-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}
(inclusive) degrees, or the analogous range in radians. A similar
result would be obtained with @kbd{/} followed by @kbd{I T}, but the
-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
since the division loses information about the signs of the two
components, and an error might result from an explicit division by zero
which @code{arctan2} would avoid. By (arbitrary) definition,
factorial function: @samp{gamma(n+1) = fact(n)}. For general complex
arguments the gamma function can be defined by the following definite
integral:
-@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}.
@infoline @expr{gamma(a) = integ(t^(a-1) exp(t), t, 0, inf)}.
(The actual implementation uses far more efficient computational methods.)
The @kbd{f G} (@code{calc-inc-gamma}) [@code{gammaP}] command computes
the incomplete gamma function, denoted @samp{P(a,x)}. This is defined by
the integral,
-@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)}.
@infoline @expr{gammaP(a,x) = integ(t^(a-1) exp(t), t, 0, x) / gamma(a)}.
This implies that @samp{gammaP(a,inf) = 1} for any @expr{a} (see the
definition of the normal gamma function).
@tindex beta
The @kbd{f b} (@code{calc-beta}) [@code{beta}] command computes the
Euler beta function, which is defined in terms of the gamma function as
-@texline @tmath{B(a,b) = \Gamma(a) \Gamma(b) / \Gamma(a+b)},
+@texline @math{B(a,b) = \Gamma(a) \Gamma(b) / \Gamma(a+b)},
@infoline @expr{beta(a,b) = gamma(a) gamma(b) / gamma(a+b)},
or by
-@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}.
@infoline @expr{beta(a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, 1)}.
@kindex f B
@tindex betaB
The @kbd{f B} (@code{calc-inc-beta}) [@code{betaI}] command computes
the incomplete beta function @expr{I(x,a,b)}. It is defined by
-@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)}.
@infoline @expr{betaI(x,a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, x) / beta(a,b)}.
Once again, the @kbd{H} (hyperbolic) prefix gives the corresponding
un-normalized version [@code{betaB}].
@tindex erfc
The @kbd{f e} (@code{calc-erf}) [@code{erf}] command computes the
error function
-@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}.
@infoline @expr{erf(x) = 2 integ(exp(-(t^2)), t, 0, x) / sqrt(pi)}.
The complementary error function @kbd{I f e} (@code{calc-erfc}) [@code{erfc}]
is the corresponding integral from @samp{x} to infinity; the sum
-@texline @tmath{\hbox{erf}(x) + \hbox{erfc}(x) = 1}.
+@texline @math{\hbox{erf}(x) + \hbox{erfc}(x) = 1}.
@infoline @expr{erf(x) + erfc(x) = 1}.
@kindex f j
For @samp{z1^z2}: This is defined by @samp{exp(ln(z1)*z2)}.
One interesting consequence of this is that @samp{(-8)^1:3} does
-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
number @expr{(1., 1.732)}. Both of these are valid cube roots
-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
less-obvious root for the sake of mathematical consistency.
For @samp{arcsin(z)}: This is defined by @samp{-i*ln(i*z + sqrt(1-z^2))}.
-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.
For @samp{arccos(z)}: This is defined by @samp{-i*ln(z + i*sqrt(1-z^2))},
or equivalently by @samp{pi/2 - arcsin(z)}. The branch cuts are on
-the real axis, less than @i{-1} and greater than 1.
+the real axis, less than @mathit{-1} and greater than 1.
For @samp{arctan(z)}: This is defined by
@samp{(ln(1+i*z) - ln(1-i*z)) / (2*i)}. The branch cuts are on the
real axis less than 1.
For @samp{arctanh(z)}: This is defined by @samp{(ln(1+z) - ln(1-z)) / 2}.
-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.
The following tables for @code{arcsin}, @code{arccos}, and
@code{arctan} assume the current angular mode is radians. The
Given a positive numeric prefix argument @expr{M}, it produces a random
integer @expr{N} in the range
-@texline @tmath{0 \le N < M}.
+@texline @math{0 \le N < M}.
@infoline @expr{0 <= N < M}.
Each of the @expr{M} values appears with equal probability.
while numeric prefix arguments are limited to six digits or so, an @expr{M}
taken from the stack can be arbitrarily large. If @expr{M} is negative,
the result is a random integer in the range
-@texline @tmath{M < N \le 0}.
+@texline @math{M < N \le 0}.
@infoline @expr{M < N <= 0}.
If the value on the stack is a floating-point number @expr{M}, the result
is a random floating-point number @expr{N} in the range
-@texline @tmath{0 \le N < M}
+@texline @math{0 \le N < M}
@infoline @expr{0 <= N < M}
or
-@texline @tmath{M < N \le 0},
+@texline @math{M < N \le 0},
@infoline @expr{M < N <= 0},
according to the sign of @expr{M}.
every other call to this function will be especially fast.
If @expr{M} is an error form
-@texline @tmath{m} @code{+/-} @tmath{\sigma}
+@texline @math{m} @code{+/-} @math{\sigma}
@infoline @samp{m +/- s}
where @var{m} and
-@texline @tmath{\sigma}
+@texline @math{\sigma}
@infoline @var{s}
are both real numbers, the result uses a Gaussian distribution with mean
@var{m} and standard deviation
-@texline @tmath{\sigma}.
+@texline @math{\sigma}.
@var{s}.
If @expr{M} is an interval form, the lower and upper bounds specify the
If @code{RandSeed} contains an integer, Calc uses this integer to
seed an ``additive congruential'' method (Knuth's algorithm 3.2.2A,
computing
-@texline @tmath{X_{n-55} - X_{n-24}}.
+@texline @math{X_{n-55} - X_{n-24}}.
@infoline @expr{X_n-55 - X_n-24}).
This method expands the seed
value into a large table which is maintained internally; the variable
To create a random floating-point number with precision @var{p}, Calc
simply creates a random @var{p}-digit integer and multiplies by
-@texline @tmath{10^{-p}}.
+@texline @math{10^{-p}}.
@infoline @expr{10^-p}.
The resulting random numbers should be very clean, but note
that relatively small numbers will have few significant random digits.
In other words, with a precision of 12, you will occasionally get
numbers on the order of
-@texline @tmath{10^{-9}}
+@texline @math{10^{-9}}
@infoline @expr{10^-9}
or
-@texline @tmath{10^{-10}},
+@texline @math{10^{-10}},
@infoline @expr{10^-10},
but those numbers will only have two or three random digits since they
correspond to small integers times
-@texline @tmath{10^{-12}}.
+@texline @math{10^{-12}}.
@infoline @expr{10^-12}.
To create a random integer in the interval @samp{[0 .. @var{m})}, Calc
The @kbd{k E} (@code{calc-extended-gcd}) [@code{egcd}] command computes
the GCD of two integers @expr{x} and @expr{y} and returns a vector
@expr{[g, a, b]} where
-@texline @tmath{g = \gcd(x,y) = a x + b y}.
+@texline @math{g = \gcd(x,y) = a x + b y}.
@infoline @expr{g = gcd(x,y) = a x + b y}.
@kindex !
are integers, the result is an exact integer. Otherwise, the result is a
floating-point approximation. The binomial coefficient is defined for all
real numbers by
-@texline @tmath{N! \over M! (N-M)!\,}.
+@texline @math{N! \over M! (N-M)!\,}.
@infoline @expr{N! / M! (N-M)!}.
@kindex H k c
@tindex stir2
The @kbd{k s} (@code{calc-stirling-number}) [@code{stir1}] command
computes a Stirling number of the first
-@texline kind@tie{}@tmath{n \brack m},
+@texline kind@tie{}@math{n \brack m},
@infoline kind,
given two integers @expr{n} and @expr{m} on the stack. The @kbd{H k s}
[@code{stir2}] command computes a Stirling number of the second
-@texline kind@tie{}@tmath{n \brace m}.
+@texline kind@tie{}@math{n \brace m}.
@infoline kind.
These are the number of @expr{m}-cycle permutations of @expr{n} objects,
and the number of ways to partition @expr{n} objects into @expr{m}
inputs, prime factors above 5000 may not be found, in which case the
last number in the vector will be an unfactored integer greater than 25
million (with a warning message). For negative integers, the first
-element of the list will be @i{-1}. For inputs @i{-1}, @i{0}, and
-@i{1}, the result is a list of the same number.
+element of the list will be @mathit{-1}. For inputs @mathit{-1}, @mathit{0}, and
+@mathit{1}, the result is a list of the same number.
@kindex k n
@pindex calc-next-prime
@tindex totient
The @kbd{k t} (@code{calc-totient}) [@code{totient}] command computes the
Euler ``totient''
-@texline function@tie{}@tmath{\phi(n)},
+@texline function@tie{}@math{\phi(n)},
@infoline function,
the number of integers less than @expr{n} which
are relatively prime to @expr{n}.
@pindex calc-moebius
@tindex moebius
The @kbd{k m} (@code{calc-moebius}) [@code{moebius}] command computes the
-@texline M@"obius @tmath{\mu}
+@texline M@"obius @math{\mu}
@infoline Moebius ``mu''
function. If the input number is a product of @expr{k}
distinct factors, this is @expr{(-1)^k}. If the input number has any
@end ignore
@tindex ltpc
The @samp{utpc(x,v)} function uses the chi-square distribution with
-@texline @tmath{\nu}
+@texline @math{\nu}
@infoline @expr{v}
degrees of freedom. It is the probability that a model is
correct if its chi-square statistic is @expr{x}.
@tindex ltpf
The @samp{utpf(F,v1,v2)} function uses the F distribution, used in
various statistical tests. The parameters
-@texline @tmath{\nu_1}
+@texline @math{\nu_1}
@infoline @expr{v1}
and
-@texline @tmath{\nu_2}
+@texline @math{\nu_2}
@infoline @expr{v2}
are the degrees of freedom in the numerator and denominator,
respectively, used in computing the statistic @expr{F}.
@tindex ltpn
The @samp{utpn(x,m,s)} function uses a normal (Gaussian) distribution
with mean @expr{m} and standard deviation
-@texline @tmath{\sigma}.
+@texline @math{\sigma}.
@infoline @expr{s}.
It is the probability that such a normal-distributed random variable
would exceed @expr{x}.
@tindex ltpt
The @samp{utpt(t,v)} function uses the Student's ``t'' distribution
with
-@texline @tmath{\nu}
+@texline @math{\nu}
@infoline @expr{v}
degrees of freedom. It is the probability that a
t-distributed random variable will be greater than @expr{t}.
(Note: This computes the distribution function
-@texline @tmath{A(t|\nu)}
+@texline @math{A(t|\nu)}
@infoline @expr{A(t|v)}
where
-@texline @tmath{A(0|\nu) = 1}
+@texline @math{A(0|\nu) = 1}
@infoline @expr{A(0|v) = 1}
and
-@texline @tmath{A(\infty|\nu) \to 0}.
+@texline @math{A(\infty|\nu) \to 0}.
@infoline @expr{A(inf|v) -> 0}.
The @code{UTPT} operation on the HP-48 uses a different definition which
returns half of Calc's value: @samp{UTPT(t,v) = .5*utpt(t,v)}.)
times ten to the power of the exponent.
@item -12
-This is treated the same as @i{-11} by the @kbd{v p} command.
-When unpacking, @i{-12} specifies that a floating-point mantissa
+This is treated the same as @mathit{-11} by the @kbd{v p} command.
+When unpacking, @mathit{-12} specifies that a floating-point mantissa
is desired.
@item -13
If any elements of the vector are negative, other kinds of
packing are done at that level as described above. For
example, @samp{[2, 3, -4]} takes 12 objects and creates a
-@texline @tmath{2\times3}
+@texline @math{2\times3}
@infoline 2x3
matrix of error forms: @samp{[[a +/- b, c +/- d ... ]]}.
Also, @samp{[-4, -10]} will convert four integers into an
@samp{[a, c^2, d]} and @w{@samp{[b, 0, 7]}}.
Note that the prefix argument can have an effect even when the input is
-not a vector. For example, if the input is the number @i{-5}, then
-@kbd{c-u -1 v u} yields @i{-5} and 0 (the components of @i{-5}
+not a vector. For example, if the input is the number @mathit{-5}, then
+@kbd{c-u -1 v u} yields @mathit{-5} and 0 (the components of @mathit{-5}
when viewed as a rectangular complex number); @kbd{C-u -2 v u} yields 5
-and 180 (assuming degrees mode); and @kbd{C-u -10 v u} yields @i{-5}
-and 1 (the numerator and denominator of @i{-5}, viewed as a rational
+and 180 (assuming degrees mode); and @kbd{C-u -10 v u} yields @mathit{-5}
+and 1 (the numerator and denominator of @mathit{-5}, viewed as a rational
number). Plain @kbd{v u} with this input would complain that the input
is not a composite object.
-Unpacking mode @i{-11} converts a float into an integer mantissa and
+Unpacking mode @mathit{-11} converts a float into an integer mantissa and
an integer exponent, where the mantissa is not divisible by 10
(except that 0.0 is represented by a mantissa and exponent of 0).
-Unpacking mode @i{-12} converts a float into a floating-point mantissa
+Unpacking mode @mathit{-12} converts a float into a floating-point mantissa
and integer exponent, where the mantissa (for non-zero numbers)
is guaranteed to lie in the range [1 .. 10). In both cases,
the mantissa is shifted left or right (and the exponent adjusted
the prefix argument is required.
To build a constant square matrix, e.g., a
-@texline @tmath{3\times3}
+@texline @math{3\times3}
@infoline 3x3
matrix filled with ones, use @kbd{0 M-3 v d 1 +}, i.e., build a zero
matrix first and then add a constant value to that matrix. (Another
of consecutive integers from 1 to @var{n}, where @var{n} is the numeric
prefix argument. If you do not provide a prefix argument, you will be
prompted to enter a suitable number. If @var{n} is negative, the result
-is a vector of negative integers from @var{n} to @i{-1}.
+is a vector of negative integers from @var{n} to @mathit{-1}.
With a prefix argument of just @kbd{C-u}, the @kbd{v x} command takes
three values from the stack: @var{n}, @var{start}, and @var{incr} (with
of the dimensions of a vector, matrix, or higher-order object. For
example, @samp{mdims([[a,b,c],[d,e,f]])} returns @samp{[2, 3]} since
its argument is a
-@texline @tmath{2\times3}
+@texline @math{2\times3}
@infoline 2x3
matrix.
suitable for use as a matrix. For example, with the matrix
@samp{[[1, 2], @w{[3, 4]}]} on the stack, @kbd{v a 4} produces
@samp{[[1, 2, 3, 4]]} (a
-@texline @tmath{1\times4}
+@texline @math{1\times4}
@infoline 1x4
matrix), @kbd{v a 1} produces @samp{[[1], [2], [3], [4]]} (a
-@texline @tmath{4\times1}
+@texline @math{4\times1}
@infoline 4x1
matrix), @kbd{v a 2} produces @samp{[[1, 2], [3, 4]]} (the original
-@texline @tmath{2\times2}
+@texline @math{2\times2}
@infoline 2x2
matrix), @w{@kbd{v a 3}} produces @samp{[[1, 2, 3], [4]]} (not a
matrix), and @kbd{v a 0} produces the flattened list
will be the empty vector @samp{[]}. Note that the characters @kbd{V}
and @kbd{^} were chosen to be close to the conventional mathematical
notation for set
-@texline union@tie{}(@tmath{A \cup B})
+@texline union@tie{}(@math{A \cup B})
@infoline union
and
-@texline intersection@tie{}(@tmath{A \cap B}).
+@texline intersection@tie{}(@math{A \cap B}).
@infoline intersection.
@kindex V -
set of integers in the sense of @kbd{V F} (@code{vfloor}). Beware
that a simple input like @samp{[100]} can result in a huge integer
representation
-@texline (@tmath{2^{100}}, a 31-digit integer, in this case).
+@texline (@math{2^{100}}, a 31-digit integer, in this case).
@infoline (@expr{2^100}, a 31-digit integer, in this case).
@node Statistical Operations, Reducing and Mapping, Set Operations, Matrix Functions
The @kbd{u M} (@code{calc-vector-mean}) [@code{vmean}] command
computes the average (arithmetic mean) of the data values.
If the inputs are error forms
-@texline @tmath{x \pm \sigma},
+@texline @math{x \pm \sigma},
@infoline @samp{x +/- s},
this is the weighted mean of the @expr{x} values with weights
-@texline @tmath{1 /\sigma^2}.
+@texline @math{1 /\sigma^2}.
@infoline @expr{1 / s^2}.
@tex
\turnoffactive
Note that a plain number can be considered an error form with
error
-@texline @tmath{\sigma = 0}.
+@texline @math{\sigma = 0}.
@infoline @expr{s = 0}.
If the input to @kbd{u M} is a mixture of
plain numbers and error forms, the result is the mean of the
@cindex Sample statistics
The @kbd{u S} (@code{calc-vector-sdev}) [@code{vsdev}] command
computes the standard
-@texline deviation@tie{}@tmath{\sigma}
+@texline deviation@tie{}@math{\sigma}
@infoline deviation
of the data values. If the values are error forms, the errors are used
as weights just as for @kbd{u M}. This is the @emph{sample} standard
of a single error form is simply the error part. The standard deviation
of a continuous interval happens to equal the difference between the
limits, divided by
-@texline @tmath{\sqrt{12}}.
+@texline @math{\sqrt{12}}.
@infoline @expr{sqrt(12)}.
The standard deviation of an integer interval is the same as the
standard deviation of a vector of those integers.
@kbd{H I u S} (@code{calc-vector-pop-variance}) [@code{vpvar}]
commands compute the variance of the data values. The variance
is the
-@texline square@tie{}@tmath{\sigma^2}
+@texline square@tie{}@math{\sigma^2}
@infoline square
of the standard deviation, i.e., the sum of the
squares of the deviations of the data values from the mean.
way as by the single-variable statistical functions. Given a numeric
prefix argument of 1, these functions instead take one object from
the stack, which must be an
-@texline @tmath{N\times2}
+@texline @math{N\times2}
@infoline Nx2
matrix of data values. Once again, variable names can be used in place
of actual vectors and matrices.
across all elements of the matrix. For example, given the matrix
@expr{[[1, -2, 3], [-4, 5, -6]]}, @kbd{V M A} takes six absolute values to
produce another
-@texline @tmath{3\times2}
+@texline @math{3\times2}
@infoline 3x2
matrix, @expr{[[1, 2, 3], [4, 5, 6]]}.
@kbd{a s}; @pxref{Simplifying Formulas}. If you give a numeric prefix
of 3 or more, it uses extended simplification mode (@kbd{a e}).
-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},
it simplifies in the corresponding mode but only works on the top-level
function call of the formula. For example, @samp{(2 + 3) * (2 + 3)} will
simplify to @samp{(2 + 3)^2}, without simplifying the sub-formulas
The distributive law is used to simplify sums in some cases:
@expr{a x + b x} to @expr{(a + b) x}, where @expr{a} represents
-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})
and similarly for @expr{b}. Use the @kbd{a c}, @w{@kbd{a f}}, or
@kbd{j M} commands to merge sums with non-numeric coefficients
using the distributive law.
The distributive law of products and powers is used for adjacent
terms of the product: @expr{x^a x^b} goes to
-@texline @tmath{x^{a+b}}
+@texline @math{x^{a+b}}
@infoline @expr{x^(a+b)}
where @expr{a} is a number, or an implicit 1 (as in @expr{x}),
or the implicit one-half of @expr{@t{sqrt}(x)}, and similarly for
The product of a negative power times anything but another negative
power is changed to use division:
-@texline @tmath{x^{-2} y}
+@texline @math{x^{-2} y}
@infoline @expr{x^(-2) y}
goes to @expr{y / x^2} unless matrix mode is
in effect and neither @expr{x} nor @expr{y} are scalar (in which
@xref{Infinite Mode}.
The expression
-@texline @tmath{a / b^{-c}}
+@texline @math{a / b^{-c}}
@infoline @expr{a / b^(-c)}
is changed to @expr{a b^c}, where @expr{-c} is any negative-looking
power. Also, @expr{1 / b^c} is changed to
-@texline @tmath{b^{-c}}
+@texline @math{b^{-c}}
@infoline @expr{b^(-c)}
for any power @expr{c}.
are distributed to @expr{a^c b^c}, @expr{a^c / b^c} only if @expr{c}
is an integer, or if either @expr{a} or @expr{b} are nonnegative
real numbers. Powers of powers @expr{(a^b)^c} are simplified to
-@texline @tmath{a^{b c}}
+@texline @math{a^{b c}}
@infoline @expr{a^(b c)}
only when @expr{c} is an integer and @expr{b c} also
evaluates to an integer. Without these restrictions these simplifications
would not be safe because of problems with principal values.
(In other words,
-@texline @tmath{((-3)^{1/2})^2}
+@texline @math{((-3)^{1/2})^2}
@infoline @expr{((-3)^1:2)^2}
is safe to simplify, but
-@texline @tmath{((-3)^2)^{1/2}}
+@texline @math{((-3)^2)^{1/2}}
@infoline @expr{((-3)^2)^1:2}
is not.) @xref{Declarations}, for ways to inform Calc that your
variables satisfy these requirements.
As a special case of this rule, @expr{@t{sqrt}(x)^n} is simplified to
-@texline @tmath{x^{n/2}}
+@texline @math{x^{n/2}}
@infoline @expr{x^(n/2)}
only for even integers @expr{n}.
for any negative-looking expression @expr{-a}.
Square roots @expr{@t{sqrt}(x)} generally act like one-half powers
-@texline @tmath{x^{1:2}}
+@texline @math{x^{1:2}}
@infoline @expr{x^1:2}
for the purposes of the above-listed simplifications.
Also, note that
-@texline @tmath{1 / x^{1:2}}
+@texline @math{1 / x^{1:2}}
@infoline @expr{1 / x^1:2}
is changed to
-@texline @tmath{x^{-1:2}},
+@texline @math{x^{-1:2}},
@infoline @expr{x^(-1:2)},
but @expr{1 / @t{sqrt}(x)} is left alone.
A subtle point is that @expr{(x - y) (y - x)} will @emph{not}
be simplified to @expr{-(x - y)^2}; Calc does not notice that
one term can be written as a constant times the other, even if
-that constant is @i{-1}.
+that constant is @mathit{-1}.
A fraction times any expression, @expr{(a:b) x}, is changed to
a quotient involving integers: @expr{a x / b}. This is not
several ways. (Note that these will be left unevaluated only in
Symbolic mode.) First, square integer or rational factors are
pulled out so that @expr{@t{sqrt}(8)} is rewritten as
-@texline @tmath{$2\,\t{sqrt}(2)$}.
+@texline @math{2\,\t{sqrt}(2)}.
@infoline @expr{2 sqrt(2)}.
Conceptually speaking this implies factoring the argument into primes
and moving pairs of primes out of the square root, but for reasons of
@code{arctan}, @code{arcsinh}, and @code{arctanh}. Note that
@expr{@t{arcsin}(@t{sin}(x))} can @emph{not} safely change to
@expr{x}, since this only correct within an integer multiple of
-@texline @tmath{2 \pi}
+@texline @math{2 \pi}
@infoline @expr{2 pi}
radians or 360 degrees. However, @expr{@t{arcsinh}(@t{sinh}(x))} is
simplified to @expr{x} if @expr{x} is known to be real.
Several simplifications that apply to logarithms and exponentials
are that @expr{@t{exp}(@t{ln}(x))},
-@texline @t{e}@tmath{^{\ln(x)}},
+@texline @t{e}@math{^{\ln(x)}},
@infoline @expr{e^@t{ln}(x)},
and
-@texline @tmath{10^{{\rm log10}(x)}}
+@texline @math{10^{{\rm log10}(x)}}
@infoline @expr{10^@t{log10}(x)}
all reduce to @expr{x}. Also, @expr{@t{ln}(@t{exp}(x))}, etc., can
reduce to @expr{x} if @expr{x} is provably real. The form
@expr{@t{exp}(x)^y} is simplified to @expr{@t{exp}(x y)}. If @expr{x}
is a suitable multiple of
-@texline @tmath{\pi i}
+@texline @math{\pi i}
@infoline @expr{pi i}
(as described above for the trigonometric functions), then
@expr{@t{exp}(x)} or @expr{e^x} will be expanded. Finally,
functions always produce.
Powers of powers @expr{(x^a)^b} are simplified to
-@texline @tmath{x^{a b}}
+@texline @math{x^{a b}}
@infoline @expr{x^(a b)}
for all @expr{a} and @expr{b}. These results will be valid only
in a restricted range of @expr{x}; for example, in
-@texline @tmath{(x^2)^{1:2}}
+@texline @math{(x^2)^{1:2}}
@infoline @expr{(x^2)^1:2}
the powers cancel to get @expr{x}, which is valid for positive values
of @expr{x} but not for negative or complex values.
Similarly, @expr{@t{sqrt}(x^a)} and @expr{@t{sqrt}(x)^a} are both
simplified (possibly unsafely) to
-@texline @tmath{x^{a/2}}.
+@texline @math{x^{a/2}}.
@infoline @expr{x^(a/2)}.
Forms like @expr{@t{sqrt}(1 - sin(x)^2)} are simplified to, e.g.,
For powers and square roots, the ``unsafe'' simplifications
@expr{(a b)^c} to @expr{a^c b^c}, @expr{(a/b)^c} to @expr{a^c / b^c},
and @expr{(a^b)^c} to
-@texline @tmath{a^{b c}}
+@texline @math{a^{b c}}
@infoline @expr{a^(b c)}
are done if the powers are real numbers. (These are safe in the context
of units because all numbers involved can reasonably be assumed to be
is defined in terms of @samp{m^2}, and that the 2 in the power of
@code{m} is a multiple of 2 in @expr{3:2}. Thus, @code{acre^1.5} is
replaced by approximately
-@texline @tmath{(4046 m^2)^{1.5}}
+@texline @math{(4046 m^2)^{1.5}}
@infoline @expr{(4046 m^2)^1.5},
which is then changed to
-@texline @tmath{4046^{1.5} \, (m^2)^{1.5}},
+@texline @math{4046^{1.5} \, (m^2)^{1.5}},
@infoline @expr{4046^1.5 (m^2)^1.5},
then to @expr{257440 m^3}.
If you use the @code{deriv} function directly in an algebraic formula,
you can write @samp{deriv(f,x,x0)} which represents the derivative
of @expr{f} with respect to @expr{x}, evaluated at the point
-@texline @tmath{x=x_0}.
+@texline @math{x=x_0}.
@infoline @expr{x=x0}.
If the formula being differentiated contains functions which Calc does
classes of formulas. In particular, any polynomial or rational function
(a polynomial divided by a polynomial) is acceptable. (Rational functions
don't have to be in explicit quotient form, however;
-@texline @tmath{x/(1+x^{-2})}
+@texline @math{x/(1+x^{-2})}
@infoline @expr{x/(1+x^-2)}
is not strictly a quotient of polynomials, but it is equivalent to
@expr{x^3/(x^2+1)}, which is.) Also, square roots of terms involving
Please note that the current implementation of Calc's integrator sometimes
produces results that are significantly more complex than they need to
be. For example, the integral Calc finds for
-@texline @tmath{1/(x+\sqrt{x^2+1})}
+@texline @math{1/(x+\sqrt{x^2+1})}
@infoline @expr{1/(x+sqrt(x^2+1))}
is several times more complicated than the answer Mathematica
returns for the same input, although the two forms are numerically
an arbitrary constant of integration added to it, although Calc does not
write an explicit constant of integration in its result. For example,
Calc's solution for
-@texline @tmath{1/(1+\tan x)}
+@texline @math{1/(1+\tan x)}
@infoline @expr{1/(1+tan(x))}
differs from the solution given in the @emph{CRC Math Tables} by a
constant factor of
-@texline @tmath{\pi i / 2}
+@texline @math{\pi i / 2}
@infoline @expr{pi i / 2},
due to a different choice of constant of integration.
As a more serious example, the expression @samp{exp(x)/x} cannot be
integrated in terms of the standard functions, so the ``exponential
integral'' function
-@texline @tmath{{\rm Ei}(x)}
+@texline @math{{\rm Ei}(x)}
@infoline @expr{Ei(x)}
was invented to describe it.
We can get Calc to do this integral in terms of a made-up @code{Ei}
This command also works for inequalities, as in @expr{y < 3x + 6}.
Some inequalities cannot be solved where the analogous equation could
be; for example, solving
-@texline @tmath{a < b \, c}
+@texline @math{a < b \, c}
@infoline @expr{a < b c}
for @expr{b} is impossible
without knowing the sign of @expr{c}. In this case, @kbd{a S} will
produce the result
-@texline @tmath{b \mathbin{\hbox{\code{!=}}} a/c}
+@texline @math{b \mathbin{\hbox{\code{!=}}} a/c}
@infoline @expr{b != a/c}
(using the not-equal-to operator) to signify that the direction of the
inequality is now unknown. The inequality
-@texline @tmath{a \le b \, c}
+@texline @math{a \le b \, c}
@infoline @expr{a <= b c}
is not even partially solved. @xref{Declarations}, for a way to tell
Calc that the signs of the variables in a formula are in fact known.
general family of solutions. It will invent variables @code{n1},
@code{n2}, @dots{}, which represent independent arbitrary integers, and
@code{s1}, @code{s2}, @dots{}, which represent independent arbitrary
-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
flag, Calc will use zero in place of all arbitrary integers, and plus
one in place of all arbitrary signs. Note that variables like @code{n1}
and @code{s1} are not given any special interpretation in Calc except by
Note that this command looks for a @emph{local} minimum. Many functions
have more than one minimum; some, like
-@texline @tmath{x \sin x},
+@texline @math{x \sin x},
@infoline @expr{x sin(x)},
have infinitely many. In fact, there is no easy way to define the
``global'' minimum of
-@texline @tmath{x \sin x}
+@texline @math{x \sin x}
@infoline @expr{x sin(x)}
but Calc can still locate any particular local minimum
for you. Calc basically goes downhill from the initial guess until it
The @kbd{a F} command takes the data set to be fitted from the stack.
By default, it expects the data in the form of a matrix. For example,
for a linear or polynomial fit, this would be a
-@texline @tmath{2\times N}
+@texline @math{2\times N}
@infoline 2xN
matrix where the first row is a list of @expr{x} values and the second
row has the corresponding @expr{y} values. For the multilinear fit
@expr{x_3}, and @expr{y}, respectively).
If you happen to have an
-@texline @tmath{N\times2}
+@texline @math{N\times2}
@infoline Nx2
matrix instead of a
-@texline @tmath{2\times N}
+@texline @math{2\times N}
@infoline 2xN
matrix, just press @kbd{v t} first to transpose the matrix.
and increases as various @expr{a + b x_i} values fail to match the
corresponding @expr{y_i} values. There are several reasons why the
summand is squared, one of them being to ensure that
-@texline @tmath{\chi^2 \ge 0}.
+@texline @math{\chi^2 \ge 0}.
@infoline @expr{chi^2 >= 0}.
Least-squares fitting simply chooses the values of @expr{a} and @expr{b}
for which the error
-@texline @tmath{\chi^2}
+@texline @math{\chi^2}
@infoline @expr{chi^2}
is as small as possible.
An important result from the theory of polynomial fitting is that it
is always possible to fit @var{n} data points exactly using a polynomial
-of degree @i{@var{n}-1}, sometimes called an @dfn{interpolating polynomial}.
+of degree @mathit{@var{n}-1}, sometimes called an @dfn{interpolating polynomial}.
Using the modified (14) data matrix, a model number of 4 gives
a polynomial that exactly matches all five data points:
or all be plain numbers. Error forms can go anywhere but generally
go on the numbers in the last row of the data matrix. If the last
row contains error forms
-@texline `@var{y_i}@w{ @t{+/-} }@tmath{\sigma_i}',
+@texline `@var{y_i}@w{ @t{+/-} }@math{\sigma_i}',
@infoline `@var{y_i}@w{ @t{+/-} }@var{sigma_i}',
then the
-@texline @tmath{\chi^2}
+@texline @math{\chi^2}
@infoline @expr{chi^2}
statistic is now,
If there are error forms on other rows of the data matrix, all the
errors for a given data point are combined; the square root of the
sum of the squares of the errors forms the
-@texline @tmath{\sigma_i}
+@texline @math{\sigma_i}
@infoline @expr{sigma_i}
used for the data point.
estimates.
If the input contains error forms but all the
-@texline @tmath{\sigma_i}
+@texline @math{\sigma_i}
@infoline @expr{sigma_i}
values are the same, it is easy to see that the resulting fitted model
will be the same as if the input did not have error forms at all
-@texline (@tmath{\chi^2}
+@texline (@math{\chi^2}
@infoline (@expr{chi^2}
is simply scaled uniformly by
-@texline @tmath{1 / \sigma^2},
+@texline @math{1 / \sigma^2},
@infoline @expr{1 / sigma^2},
which doesn't affect where it has a minimum). But there @emph{will} be
a difference in the estimated errors of the coefficients reported by
@item
The covariance matrix @expr{C} computed from the fit. This is
an @var{m}x@var{m} symmetric matrix; the diagonal elements
-@texline @tmath{C_{jj}}
+@texline @math{C_{jj}}
@infoline @expr{C_j_j}
are the variances
-@texline @tmath{\sigma_j^2}
+@texline @math{\sigma_j^2}
@infoline @expr{sigma_j^2}
of the parameters. The other elements are covariances
-@texline @tmath{\sigma_{ij}^2}
+@texline @math{\sigma_{ij}^2}
@infoline @expr{sigma_i_j^2}
that describe the correlation between pairs of parameters. (A related
set of numbers, the @dfn{linear correlation coefficients}
-@texline @tmath{r_{ij}},
+@texline @math{r_{ij}},
@infoline @expr{r_i_j},
are defined as
-@texline @tmath{\sigma_{ij}^2 / \sigma_i \, \sigma_j}.)
+@texline @math{\sigma_{ij}^2 / \sigma_i \, \sigma_j}.)
@infoline @expr{sigma_i_j^2 / sigma_i sigma_j}.)
@item
@item
The value of
-@texline @tmath{\chi^2}
+@texline @math{\chi^2}
@infoline @expr{chi^2}
for the fit, calculated by the formulas shown above. This gives a
measure of the quality of the fit; statisticians consider
-@texline @tmath{\chi^2 \approx N - M}
+@texline @math{\chi^2 \approx N - M}
@infoline @expr{chi^2 = N - M}
to indicate a moderately good fit (where again @expr{N} is the number of
data points and @expr{M} is the number of parameters).
A measure of goodness of fit expressed as a probability @expr{Q}.
This is computed from the @code{utpc} probability distribution
function using
-@texline @tmath{\chi^2}
+@texline @math{\chi^2}
@infoline @expr{chi^2}
with @expr{N - M} degrees of freedom. A
value of 0.5 implies a good fit; some texts recommend that often
@expr{Q = 0.1} or even 0.001 can signify an acceptable fit. In
particular,
-@texline @tmath{\chi^2}
+@texline @math{\chi^2}
@infoline @expr{chi^2}
statistics assume the errors in your inputs
follow a normal (Gaussian) distribution; if they don't, you may
The @expr{Q} value is computed only if the input included error
estimates. Otherwise, Calc will report the symbol @code{nan}
for @expr{Q}. The reason is that in this case the
-@texline @tmath{\chi^2}
+@texline @math{\chi^2}
@infoline @expr{chi^2}
value has effectively been used to estimate the original errors
in the input, and thus there is no redundant information left
@table @kbd
@item 1
-Linear or multilinear. @i{a + b x + c y + d z}.
+Linear or multilinear. @mathit{a + b x + c y + d z}.
@item 2-9
-Polynomials. @i{a + b x + c x^2 + d x^3}.
+Polynomials. @mathit{a + b x + c x^2 + d x^3}.
@item e
-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)}.
@item E
-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)}.
@item x
-Exponential (alternate notation). @t{exp}@i{(a + b x + c y)}.
+Exponential (alternate notation). @t{exp}@mathit{(a + b x + c y)}.
@item X
-Base-10 exponential (alternate). @t{10^}@i{(a + b x + c y)}.
+Base-10 exponential (alternate). @t{10^}@mathit{(a + b x + c y)}.
@item l
-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)}.
@item L
-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)}.
@item ^
-General exponential. @i{a b^x c^y}.
+General exponential. @mathit{a b^x c^y}.
@item p
-Power law. @i{a x^b y^c}.
+Power law. @mathit{a x^b y^c}.
@item q
-Quadratic. @i{a + b (x-c)^2 + d (x-e)^2}.
+Quadratic. @mathit{a + b (x-c)^2 + d (x-e)^2}.
@item g
Gaussian.
-@texline @tmath{{a \over b \sqrt{2 \pi}} \exp\left( -{1 \over 2} \left( x - c \over b \right)^2 \right)}.
-@infoline @i{(a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2)}.
+@texline @math{{a \over b \sqrt{2 \pi}} \exp\left( -{1 \over 2} \left( x - c \over b \right)^2 \right)}.
+@infoline @mathit{(a / b sqrt(2 pi)) exp(-0.5*((x-c)/b)^2)}.
@end table
All of these models are used in the usual way; just press the appropriate
and @code{arcsin} when doing fits. For example, when you enter
the model @samp{y = sin(a t + b)} Calc actually uses the easier
form @samp{arcsin(y) = a t + b}. The @code{arcsin} function always
-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
equivalent range in radians). Suppose you had data that you
believed to represent roughly three oscillations of a sine wave,
so that the argument of the sine might go from zero to
-@texline @tmath{3\times360}
-@infoline @i{3*360}
+@texline @math{3\times360}
+@infoline @mathit{3*360}
degrees.
The above model would appear to be a good way to determine the
true frequency and phase of the sine wave, but in practice it
would fail utterly. The righthand side of the actual model
@samp{arcsin(y) = a t + b} will grow smoothly with @expr{t}, but
-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.
No values of @expr{a} and @expr{b} can make the two sides match,
even approximately.
@noindent
which matches the desired form with
-@texline @tmath{Y = \ln(y)},
+@texline @math{Y = \ln(y)},
@infoline @expr{Y = ln(y)},
-@texline @tmath{A = \ln(a)},
+@texline @math{A = \ln(a)},
@infoline @expr{A = ln(a)},
@expr{F = 1}, @expr{B = b}, and
-@texline @tmath{G = \ln(x)}.
+@texline @math{G = \ln(x)}.
@infoline @expr{G = ln(x)}.
Calc thus computes the logarithms of your @expr{y} and @expr{x} values,
does a linear fit for @expr{A} and @expr{B}, then solves to get
-@texline @tmath{a = \exp(A)}
+@texline @math{a = \exp(A)}
@infoline @expr{a = exp(A)}
and @expr{b = B}.
@noindent
which matches with @expr{Y = y}, @expr{A = a + b c^2}, @expr{F = 1},
-@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
have been put into @expr{G} instead of @expr{B}), @expr{C = b}, and
@expr{H = x^2}.
A last desperate step would be to use the general-purpose
@code{minimize} function rather than @code{fit}. After all, both
functions solve the problem of minimizing an expression (the
-@texline @tmath{\chi^2}
+@texline @math{\chi^2}
@infoline @expr{chi^2}
sum) by adjusting certain parameters in the expression. The @kbd{a F}
command is able to use a vastly more efficient algorithm due to its
fit is linearizable, and use @code{minimize} on a call to @code{fit}
which efficiently takes care of the rest of the parameters. The thing
to be minimized would be the value of
-@texline @tmath{\chi^2}
+@texline @math{\chi^2}
@infoline @expr{chi^2}
returned as the fifth result of the @code{xfit} function:
form with this combined error. The @expr{Y(x,y,z)} part of the
linearized model is evaluated, and the result should be an error
form. The error part of that result is used for
-@texline @tmath{\sigma_i}
+@texline @math{\sigma_i}
@infoline @expr{sigma_i}
for the data point. If for some reason @expr{Y(x,y,z)} does not return
an error form, the combined error from @expr{z} is used directly for
-@texline @tmath{\sigma_i}.
+@texline @math{\sigma_i}.
@infoline @expr{sigma_i}.
Finally, @expr{z} is also stripped of its error
for use in computing @expr{F(x,y,z)}, @expr{G(x,y,z)} and so on;
depends only on the dependent variable @expr{z}, and in fact is
often simply equal to @expr{z}. For common cases like polynomials
and multilinear models, the combined error is simply used as the
-@texline @tmath{\sigma}
+@texline @math{\sigma}
@infoline @expr{sigma}
for the data point with no further ado.)
positive step size), the result is generally zero. However,
Calc only guarantees a zero result when the upper limit is
exactly one step less than the lower limit, i.e., if the number
-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
but the sum from @samp{n} to @samp{n-2} may report a nonzero value
if Calc used a closed form solution.
Calc will not assume is zero. Better would be to use
@samp{(k != k_0) ? 1/(k-k_0) : 0}; the @samp{? :} operator does
an ``if-then-else'' test: This expression says, ``if
-@texline @tmath{k \ne k_0},
+@texline @math{k \ne k_0},
@infoline @expr{k != k_0},
then @expr{1/(k-k_0)}, else zero.'' Now the formula @expr{1/(k-k_0)}
will not even be evaluated by Calc when @expr{k = k_0}.
all three rules. It is possible to modify the imported rules
slightly: @samp{import(x, v1, x1, v2, x2, @dots{})} imports
the rule set @expr{x} with all occurrences of
-@texline @tmath{v_1},
+@texline @math{v_1},
@infoline @expr{v1},
as either a variable name or a function name, replaced with
-@texline @tmath{x_1}
+@texline @math{x_1}
@infoline @expr{x1}
and so on. (If
-@texline @tmath{v_1}
+@texline @math{v_1}
@infoline @expr{v1}
is used as a function name, then
-@texline @tmath{x_1}
+@texline @math{x_1}
@infoline @expr{x1}
must be either a function name itself or a @w{@samp{< >}} nameless
function; @pxref{Specifying Operators}.) For example, @samp{[g(0) := 0,
units.
Two units, @code{pi} and @code{fsc} (the fine structure constant,
-approximately @i{1/137}) are dimensionless. The units simplification
+approximately @mathit{1/137}) are dimensionless. The units simplification
commands simply treat these names as equivalent to their corresponding
values. However you can, for example, use @kbd{u c} to convert a pure
number into multiples of the fine structure constant, or @kbd{u b} to
order of the operands. If @expr{v} represents the contents of the
variable, and @expr{a} is the value drawn from the stack, then regular
@w{@kbd{s -}} assigns
-@texline @tmath{v \coloneq v - a},
+@texline @math{v \coloneq v - a},
@infoline @expr{v := v - a},
but @kbd{I s -} assigns
-@texline @tmath{v \coloneq a - v}.
+@texline @math{v \coloneq a - v}.
@infoline @expr{v := a - v}.
While @kbd{I s *} might seem pointless, it is
useful if matrix multiplication is involved. Actually, all the
``z'' value must be a matrix with the same number of rows as elements
in ``x'', and the same number of columns as elements in ``y''. The
result is a surface plot where
-@texline @tmath{z_{ij}}
+@texline @math{z_{ij}}
@infoline @expr{z_ij}
is the height of the point
at coordinate @expr{(x_i, y_j)} on the surface. The 3D graph will
they are to look nice on the same graph.)
For example, to plot
-@texline @tmath{\sin n x}
+@texline @math{\sin n x}
@infoline @expr{sin(n x)}
for integers @expr{n}
from 1 to 5, you could use @kbd{v x} to create a vector of integers
the @kbd{g a} and @kbd{g f} commands will use those style numbers
instead of the defaults for new curves that are added to the graph.
An entry should be a positive integer for a specific style, or 0 to let
-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
altogether. If there are more curves than elements in the vector, the
last few curves will continue to have the default styles. Of course,
you can later use @kbd{g s} and @kbd{g S} to change any of these styles.
to a buffer called @samp{*Gnuplot Trail*}, which Calc then displays.
The graph is made the same size as the Emacs screen, which on most
dumb terminals will be
-@texline @tmath{80\times24}
+@texline @math{80\times24}
@infoline 80x24
characters. The graph is displayed in
an Emacs ``recursive edit''; type @kbd{q} or @kbd{M-# M-#} to exit
@xref{Matrix Functions}, to see how to pull the matrix apart into its
constituent rows and columns. (If it is a
-@texline @tmath{1\times1}
+@texline @math{1\times1}
@infoline 1x1
matrix, just hit @kbd{v u} (@code{calc-unpack}) twice.)
@key{INV GCD} computes the LCM (least common multiple) function.
@key{INV FACT} is the gamma function.
-@texline @tmath{\Gamma(x) = (x-1)!}.
+@texline @math{\Gamma(x) = (x-1)!}.
@infoline @expr{gamma(x) = (x-1)!}.
@key{PERM} is the number-of-permutations function, which is on the
is greater than @var{final} the body will not be executed at all.
Note that @var{step} may still be negative in this loop; the prefix
argument merely constrains the loop-finished test. Likewise, a prefix
-argument of @i{-1} forces downward-counting conventions.
+argument of @mathit{-1} forces downward-counting conventions.
@kindex Z @{
@kindex Z @}
@tindex mysin
A somewhat limited sine function could be defined as follows, using the
well-known Taylor series expansion for
-@texline @tmath{\sin x}:
+@texline @math{\sin x}:
@infoline @samp{sin(x)}:
@smallexample
Large integers are stored as lists of the form @samp{(bigpos @var{d0}
@var{d1} @var{d2} @dots{})} for positive integers 1000000 or more, or
@samp{(bigneg @var{d0} @var{d1} @var{d2} @dots{})} for negative integers
-@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
from 0 to 999. The least significant digit is @var{d0}; the last digit,
@var{dn}, which is always nonzero, is the most significant digit. For
-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)}.
The distinction between small and large integers is entirely hidden from
the user. In @code{defmath} definitions, the Lisp predicate @code{integerp}
@samp{10^@var{p}} in absolute value (@var{p} represents the current
precision), and @var{exp} (the ``exponent'') is a fixnum. The value of
the float is @samp{@var{mant} * 10^@var{exp}}. For example, the number
-@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
are that the number 0.0 is always stored as @samp{(float 0 0)}, and,
except for the 0.0 case, the rightmost base-10 digit of @var{mant} is
always nonzero. (If the rightmost digit is zero, the number is
specified, nothing happens. When the argument is two or more,
the binary function @var{func} is reduced across the top @var{arg}
stack elements; when the argument is negative, the function is
-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
top element.
@end defun
@end defun
@defun compare x y
-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
@samp{(lessp @var{x} @var{y})}, 1 if @samp{(lessp @var{y} @var{x})},
0 if @samp{(math-equal @var{x} @var{y})}, or 2 if the order is
undefined or cannot be determined.
@end defun
@defun scale-int x n
-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}}
digits with truncation toward zero.
@end defun
@defun quarter-integer n
If @var{n} is an integer or integer-valued float, this function
returns zero. If @var{n} is a half-integer (i.e., an integer plus
-@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,
it returns 1 or 3. If @var{n} is anything else, this function
returns @code{nil}.
@end defun
@c 20
@item
With a prefix argument of 1, take a single
-@texline @tmath{@var{n}\times2}
-@infoline @i{@var{N}x2}
+@texline @var{n}@math{\times2}
+@infoline @mathit{@var{N}x2}
matrix from the stack instead of two separate data vectors.
@c 21
The variable is replaced by the formula shown on the right. The
Inverse flag reverses the order of the operands, e.g., @kbd{I s - x}
assigns
-@texline @tmath{x \coloneq a-x}.
+@texline @math{x \coloneq a-x}.
@infoline @expr{x := a-x}.
@c 48
Press @kbd{?} repeatedly to see how to choose a model. Answer the
variables prompt with @expr{iv} or @expr{iv;pv} to specify
independent and parameter variables. A positive prefix argument
-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
and a vector from the stack.
@c 49