Ruby | Matrix determinant() function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The determinant () is an inbuilt method in Ruby returns the determinant of the given matrix. Syntax: mat1.det() Parameters: The function does not accepts any parameter. Return Value: It returns the determinant of the given matrix. Example 1: Ruby # Ruby program for determinant() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[1, Complex(2, 1)], [Complex(8, -9), 18]] # prints the determinant puts mat1.determinant() Output: -7+10i Example 2: Ruby # Ruby program for determinant() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[1, 1, 5], [4, 1, 5], [11, 2, 12]] # prints the determinant puts mat1.determinant() Output: -6 Comment More infoAdvertise with us Next Article Ruby | Matrix element() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Matrix-class Similar Reads Ruby | Matrix element() function The element() is an inbuilt method in Ruby returns the element present at the intersection of i-th row and j-th column. Syntax: mat1.element(i, j) Parameters: The function accepts two parameters i and j which signifies the row_number and column_number. Return Value: It returns the element at mat[i][ 1 min read Ruby | Matrix det() function The det() is an inbuilt method in Ruby returns the determinant of the given matrix Syntax: mat1.det() Parameters: The function does not accepts any parameter. Return Value: It returns the determinant of the given matrix. Example 1: Ruby # Ruby program for det() method in Matrix # Include matrix requ 1 min read Ruby | Matrix eigen() function The eigen() is an inbuilt method in Ruby returns the Eigensystem of the matrix. Syntax: mat1.eigen() Parameters: The function does not accepts any parameter. Return Value: It returns the Eigensystem of the matrix. Example 1: Ruby # Ruby program for eigen() method in Matrix # Include matrix require 1 min read Ruby | Matrix diagonal() function The diagonal is an inbuilt method in Ruby returns a matrix with diagonal elements as the given values. Syntax: mat1.diagonal(val1, val2, val3 ...) Parameters: The function accepts the values which are to be placed in the diagonal of the matrix. Return Value: It returns matrix with values val1, val2, 1 min read Ruby | Matrix diagonal() function The diagonal() is an inbuilt method in Ruby returns true if the given matrix is diagonal, else it returns false. A diagonal matrix is a matrix in which the entries outside the main diagonal are all zero. Syntax: mat1.diagonal() Parameters: The function does not accepts any parameter. Return Value: I 1 min read Ruby | Matrix component() function The component() is an inbuilt method in Ruby returns the element present at the intersection of i-th row and j-th column. Syntax: mat1.component(i, j) Parameters: The function accepts two parameters i and j which signifies the row_number and column_number. Return Value: It returns the element at mat 1 min read Like