Issue #10840 has been reported by Ana Johnson.

----------------------------------------
Bug #10840: documentation for Vector#cross_product  in module 'matrix' is inconsistent
https://bugs.ruby-lang.org/issues/10840

* Author: Ana Johnson
* Status: Open
* Priority: Low
* Assignee: 
* ruby -v: http://ruby-doc.org/stdlib-2.1.0/
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
the documentation of cross_product is inconsistent. The doc says:
Vector[1, 0, 0].cross_product Vector[0, 1, 0] => Vector[0, 0, 1]

which seems good to me, but the definition given in the "click to toggle source" actually produces: Vector[0,0,-1], which according to a closed bug report seems to be what the function actually once produced. The documented code is still wrong. this would be correct and clear:

def cross_product(v)
  Vector.Raise ErrDimensionMismatch unless size == v.size && v.size == 3
  Vector[ @elements[1]*v[2] - @elements[2]*v[1],
          @elements[2]*v[0] - @elements[0]*v[2],
          @elements[0]*v[1] - @elements[1]*v[0] ]
end

I recommend also altering the demonstration code so that a reasonably complete test case is shown:

Vector[1, 0, 0].cross_product Vector[0, 1, 0] => Vector[0, 0, 1]
Vector[0, 1, 0].cross_product Vector[0, 0, 1] => Vector[1, 0, 0]
Vector[0, 0, 1].cross_product Vector[1, 0, 0] => Vector[0, 1, 0]



-- 
https://bugs.ruby-lang.org/