Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6935147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:03:50+00:00 2026-05-27T12:03:50+00:00

I have to write an algorithm to find the determinant of a matrix, which

  • 0

I have to write an algorithm to find the determinant of a matrix, which is done with the recursive function:

enter image description here

where A_ij is the matrix, which appears when you remove the ith row and the jth column for A. When A has dimension n x n, then the dimension for A_ij is (n-1) x (n-1). I’m not allowed to use Minor[] or Det[].

How do I write this algorithm?


This is the code I have so far:

det1[Mi_ /; Dimensions[Mi][[1]] == Dimensions[Mi][[2]]] :=
  Module[{det1}, 
    det1 = Sum[ 
      If[det1 == 1, Break[], (-1)^(1 + j) *Mi[[1, j]]*det1[Drop[Mi, {1}, {j}]]], 
      {j, 1, Length[Mi]}]; 
    Return[det1 // MatrixForm, Module]
] 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:03:51+00:00Added an answer on May 27, 2026 at 12:03 pm

    Why doesn’t your code work?

    1. MatrixForm is used for formatting (display), but a MatrixForm-wrapped matrix can’t be used in calculations. You simply need to remove it.

    2. Think about your stopping condition for the recursion: the determinant of a 1*1 matrix is just the single element of the matrix. Rewrite the sum and If based on this. If the matrix is of size 1, return its element (it’s impossible to Break[] out of a recursion).

    3. Don’t use a local variable with the same name as your function: this masks the global function and makes it impossible to call recursively.

    4. Finally, this doesn’t break the function, but an explicit Return is not necessary. The last value of a CompoundExpression is simply returned.


    To summarize, det[m_] := If[Length[m] == 1, m[[1,1]], (Laplace expansion here)]. An alternative is to use pattern matching to identify size-1 matrices:

    Clear[det]
    det[{{x_}}] := x
    det[m_] := (Laplace expansion)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an assignment to write an algorithm to find duplicate in a Dynamic
I'm working on an application so i have write an dll which contain a
I have some function to find a value: struct FindPredicate { FindPredicate(const SomeType& t)
I have to figure out an algorithm, which finds a solution for the Connect
I have a homework assignment to write a multi-threaded sudoku solver, which finds all
I need to write a function to find the mode of a array. I'm
I have a BST which has duplicate entries. I am trying to find duplicate
I have been looking for an elegant way to write a function that takes
How can I determine if I have write permission on a remote machine in
I am trying to check if I have write access to a specific key

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.