Skip to content

A / A for a matrix is computed elementwise, and so is the undefined product of two columns #2141

Closed

Description

@Rafael-SOWNet

The wiki's Matrices page says division "will first find the inverse of the right operand", and that a multiplication whose shapes do not match does not happen. Where the operation is undefined or different, both eval and simplify instead fall back to doing it element by element:

Input Answer Should be
[[1, 2], [3, 4]] / [[1, 2], [3, 4]] [[1, 1], [1, 1]] [[1, 0], [0, 1]], as [[1, 2], [3, 4]] * [[1, 2], [3, 4]] ^ (-1) gives
[1, 2] * [1, 2] [1, 4] from simplify; eval leaves it unchanged unchanged: a 2×1 matrix by a 2×1 matrix is undefined
[1, 2] ^ 2 [1, 4] unchanged, for the same reason
[1, 2] = [1, 3] [True, False] False. [1, 2] = [1, 2] gives True

A square matrix product is right: [[1, 2], [3, 4]] * [[1, 2], [3, 4]] is [[7, 10], [15, 22]]. The elementwise branch is ExpandOnTwoArguments's (Matrix a, Matrix b) case, which every binary operation reaches when both operands have the same shape.

Found while reading Modenov's Problems in Geometry for #2131.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions