Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This needs to written in c You are to write a program that contains a function that will compute the determinant of a matrix. Write

This needs to written in c

You are to write a program that contains a function that will compute the determinant of a matrix. Write your program such that it calls a function from main() that reads the matrix from a file, computes the determinant, and prints the resulting determinant from main(). You may write as many other functions as you desire; however, YOU MUST USE LOOPS. Include a function to explain the program to the user, and write this explanation to the screen. Assume type double for all variables. The determinant of a matrix is a measure of the size of the matrix. We express the determinant of a matrix as det(A).

Any matrix with a determinant of zero cannot have an inverse; and thus, we can evaluate the determinant to see if the inverse of a matrix exists or not. The determinant of matrix is found via the co-factor expansion. For example, assuming a matrix A with values

A = | a b | | c d | 

the determinant of A is found as the co-factor cross product det(A) = ad - bc

For higher dimensional matrices, the determinant is found by expanding the matrix into its individual weighted co-factors and summing up the result in a certain fashion. This expansion must be performed across a single row or column of the matrix, but any row or column may be chosen. So, for a 3x3 matrix

A = | a11 a12 a13 | | a21 a22 a23 | | a31 a32 a33 | 

the determinant of A is found as the co-factor cross product

a11 * (a22a33-a23a32) - a12 * (a21a33-a23a31) + a13 (a21a32-a22a31)

Your output should have the following form:

The determinant of matrix | -7 -3 3| | 6 2 -3| | 11 -5 8| is 80.

it has given me this to start off with and I need to use it:

#include

#include

#define ROWS 3

#define COLS 3

int determinant(int mat33[][3]);

int main(void)

{

FILE *fp;

char filename[20];

/*Declare additional Variables HERE*/

printf("Program to find determinant of 3x3 matrices ");

scanf("%s", filename);

if((fp=fopen(filename,"r")) == NULL)

{

printf("Matrix file %s does not exist ", filename);

exit(1);

}

/* Insert Code Here*/

}

int determinant(int mat33[][3])

{

/* Insert Code Here*/

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago