Errata for The Mata Book: A Book for Serious Programmers and Those Who Want to Be

The errata for The Mata Book are provided below. Click here for an explanation of how to read an erratum. Click here to learn how to determine the printing number of a book.

(1) Chapter 3, p. 35, third code block
	toret.c1 = c.c1 / distance
	toret.c2 = c.c2 / distance
	toret.c1 = c.x / distance
	toret.c2 = c.y / distance
(1) Chapter 3, p. 37, bottom portion of code block
	real matrix regress::XX(real matrix X)
        ...
	real colvector regress::Xy(real colvector y, real matrix X)
        ...
	real matrix regression::XX(real matrix X)
        ...
	real colvector regression::Xy(real colvector y, real matrix X)
        ...
(1) Chapter 4, p. 51, first while loop example
	while  ( ... {
                    x = x + f(x)/fprime(x)
        }
	while  ( ... {
                    x = x - f(x)/fprime(x)
        }
(1) Chapter 4, p. 51, second while loop example
	while  ( ... {
                    x = x + (x^2-2)/(2*x)
        }
	while  ( ... {
                    x = x - (x^2-2)/(2*x)
        }
(1) Chapter 8, p. 124, first variant of "success"
	_______                _  _  ___
        success = fcn(A, B, C, D, E, ...)
                            -  -  -
	_______                _  _  ___
        success = fcn(A, B, C, D, E, ...)
                      -  -  -
(1) Chapter 8, p. 125, second code block
	real matrix myfcn(real matrix A, real scalar caller_i)
        ...
                 i = caller_i + 1
        ...
	real matrix myfcn(real matrix A, real scalar i)
        ...
                 caller_i = i + 1
        ...
(1) Chapter 8, p. 126, code at the top and bottom of page
	real matrix matrixmanip( ... |, ...
	real matrix matrixmanip( ... ,| ...
(1) Chapter 8, p. 126, first paragraph, first sentence
The vertical bar in front of the comma separates ... The vertical bar after the comma separates ...
(1) Chapter 8, p. 128, code
	... foo( ... |, ...
        {
                  if (eltype(x)... {
                               ...
                  } 
                  if (eltype(x)... {
                               ...
                  } 
        ...
	... foo( ... ,| ...
        {
                  if (eltype(one)...{
                               ...
                  } 
                  if (eltype(one)...{
                               ...
                  } 
        ...
(1) Chapter 9, p. 132, second sentence of second full paragraph
Here you just calculated \(n!(n-k)!/k!\) by using Here you just calculated \(n!/((n-k)! k!)\) by using
(1) Chapter 9, p. 137, second code block
	for (n=1; n<=20; n++) {
        ...
                  // printf("Ch(%f, %f) = %f\n", n, k,
                          n_choose_k(n,k))
        ...
	for (n=1; n<=5; n++) {
        ...
                  /* printf("Ch(%f, %f) = %f\n", n, k,
                          n_choose_k(n,k)) */
        ...
(1) Chapter 10, p. 166, first line of last code block, and p. 167, first line of fifth code block
	void run_regression(..., real matrix y,
	void run_regression(..., real matrix x,
(1) Chapter 10, p. 173, first line of last code block
	void setup(struct simple scalar s) ...
	void setup(struct Simple scalar s) ...
(1) Chapter 10, p. 174, first line of first code block
	void setup2(pointer(struct simple scalar) scalar p) ...
	void setup2(pointer(struct Simple scalar) scalar p) ...
(1) Chapter 10, p. 175, first code block
	struct LrInputs
        {
                pointer ... *X
                pointer ... *y
        ...
	struct LrInputs
        {
                pointer ... X
                pointer ... y
        ...
(1) Chapter 11, p. 216, last code block
	b'   trub
	b' \ trub
(1) Chapter 14, p. 273, second line of first code block
The extra space should be removed in `PositionV'.
(1) Chapter 18, p. 354, line 7 of cols_of_row() code
key should be keys so that the line is subscripts sort(A.AA.keys(), (1,2)).
(1) Chapter 18, p. 364, first code block
The name of the code block should be rows_of_col() instead of rows_of_col_ptr().
        ...
                 return(cols_of_row_ptr(!tA))
        ... 
        ...
                 return(cols_of_row(!tA))
        ...
(1) Chapter 18, p. 366, first code block
The assert command shown does not produce any results.
(1) Appendix A, p. 391, first sentence second to last paragraph
We are done ... "return scalar result = statistic" in xyzsubr(). We are done ... "return scalar statistic = r(result)" in xyzsubr().