Write a program that calculates the determinant of a 3x3 matrix, knowledge of the determinant and its uses is not necessary for this question. The determinant of a 3x3 matrix is calculated via the following method: • First, get the value at `matrix[0][0]`. Multiply this value by the difference: `matrix[1][1] * matrix[2][2] - matrix[2][1] * matrix[1][2]`. • Next, get the value at matrix[0][1]. Multiply this value by the difference: `matrix[1][0] * matrix[2][2] - matrix[2][0] * matrix[1][2]. Multiply the resulting product by -1. • Finally, get the value at matrix[0][2]. Multply this value by the difference: `matrix[1][0] * matrix[2][1] - matrix[2][0] * matrix[1][2]`. The sum of these values is the value of the determinant of matrix. Print the determinant you calculated. You can hardcode the matrix, but make your program work for all inputs. Example Cases: Input: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] Output: 0 Input: [[4, -7, 9], [6, 0, 3], [-1, 7, 0]] Output: 315 Input: [[-6, 0, 5], [-8, -8, -5], [-10, 2, 8]] Output: -156 Input: [[2, -1, -8], [5,-1,-3], [-1,-9, 6]] Output: 329

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Question

Write in Python

Write a program that calculates the determinant of a 3x3 matrix, knowledge of the determinant and its uses is not necessary for this question. The determinant of a 3x3 matrix is calculated via the following
method:
• First, get the value at `matrix[0][0]`. Multiply this value by the difference: `matrix[1][1] * matrix[2][2] - matrix[2][1] * matrix[1][2]`.
• Next, get the value at matrix[0][1]. Multiply this value by the difference: `matrix[1][0] * matrix[2][2] - matrix[2][0] * matrix[1][2]. Multiply the resulting product by -1.
• Finally, get the value at matrix[0][2]. Multply this value by the difference: `matrix[1][0] * matrix[2][1] - matrix[2][0] * matrix[1][2]`.
The sum of these values is the value of the determinant of matrix. Print the determinant you calculated. You can hardcode the matrix, but make your program work for all inputs.
Example Cases:
Input: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] Output: 0
Input: [[4, -7, 9], [6, 0, 3], [-1, 7, 0]] Output: 315
Input: [[-6, 0, 5], [-8, -8, -5], [-10, 2, 8]] Output: -156
Input: [[2, -1, -8], [5,-1,-3], [-1,-9, 6]] Output: 329
Transcribed Image Text:Write a program that calculates the determinant of a 3x3 matrix, knowledge of the determinant and its uses is not necessary for this question. The determinant of a 3x3 matrix is calculated via the following method: • First, get the value at `matrix[0][0]`. Multiply this value by the difference: `matrix[1][1] * matrix[2][2] - matrix[2][1] * matrix[1][2]`. • Next, get the value at matrix[0][1]. Multiply this value by the difference: `matrix[1][0] * matrix[2][2] - matrix[2][0] * matrix[1][2]. Multiply the resulting product by -1. • Finally, get the value at matrix[0][2]. Multply this value by the difference: `matrix[1][0] * matrix[2][1] - matrix[2][0] * matrix[1][2]`. The sum of these values is the value of the determinant of matrix. Print the determinant you calculated. You can hardcode the matrix, but make your program work for all inputs. Example Cases: Input: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] Output: 0 Input: [[4, -7, 9], [6, 0, 3], [-1, 7, 0]] Output: 315 Input: [[-6, 0, 5], [-8, -8, -5], [-10, 2, 8]] Output: -156 Input: [[2, -1, -8], [5,-1,-3], [-1,-9, 6]] Output: 329
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education