Skip to content

Determinant of empty matrix should be 1 #2907

@JL102

Description

@JL102

The issues section is used only for bug reports. Please use the Discussions section to ask questions and share ideas and suggestions.

Describe the bug
A clear and concise description of what the bug is.

Attempting to do mathjs.det() of a 0x0 matrix returns the following error:

RangeError: Matrix must be square (size: [0])

According to some mathy folks, the determinant of an empty matrix should be (by definition) 1: https://math.stackexchange.com/questions/1762537/why-is-the-determinant-of-the-0x0-matrix-equal-1

I'm not a mathematician, but as long as you agree with this rule that was described in the above post, I imagine this would be an extremely easy fix. Just add a special case where it returns 1 if the matrix is empty and size 0.

To Reproduce
Steps to reproduce the behavior.

math.det([]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions