Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. Write a subroutine to do the multiplication , of arbitrary sized multi-dimens

ID: 667827 • Letter: 3

Question

3. Write a subroutine to do the multiplication , of arbitrary sized multi-dimensional matrices. The input to the program should be: a. The multidimensional matrix (Al, the maximum value of the indices of i,j and k. b. The second matrix (B]. The output of the subroutine is vector {C). Use your to calculate {C} given that: 4. Write a recursive subroutine to calculate the determinant of a matrix. The input to your subroutine should be matrix [A] along with its number of rows/columns. The output to the subroutine should be the value of determinant. Use your program to calculate the determinant of the following matrix. 5. Derive the vector cross-product formula using the vector dot product formula. (Hint: Use the fact that when 2 vectors are normal to each other their dot product is zero).

Explanation / Answer

4.Program to calculate det of 5*5 matrix

#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<process.h>

void main()
{
int determinant(int[6][6],int);// FUNCTIONS
void read(int[6][6],int);
void print(int[6][6],int);     //           PROTOYPES
int a[6][6],l,n;
int result;
l1:clrscr();
cout<<"

   ENTER ORDER OF MATRIX(max 5*5):";
cin>>l>>n;
if(l!=n)
{                                               //TESTING CONDITION
   cout<<"


               SORRY!!!!!                ONLY SQUARE MATRIX";
   goto l1;
}
read(a,n);
result = determinant(a,n);
print(a,n);
cout<<"


       THE DETERMINANT OF THE ABOVE MATRIX IS:"<<result;
getch();
}


void read(int b[6][6],int m)     //FUNCTION FOR READING MATRIX
{
cout<<"


   ENTER "<<m*m<<" ELEMENTS OF MATRIX(ROW-WISE):";
for(int i=0;i<m;i++)
for(int j=0;j<m;j++)
   cin>>b[i][j];
}


void print(int b[6][6],int m)
{
clrscr();                           //FUNCTION FOR PRINTING MATRIX
cout<<"

   MATRIX IS :-

       ";
for(int i=0;i<m;i++)
{
cout<<"
";
for(int j=0;j<m;j++)
   cout<<"   "<<b[i][j];
}
}

int determinant(int b[6][6],int m)   //FUNCTION TO CALCULATE
DETERMINANT
{
int i,j,sum = 0,c[6][6];
if(m==2)
{                                        //BASE CONDITION
   sum = b[0][0]*b[1][1] - b[0][1]*b[1][0];
   return sum;
}
for(int p=0;p<m;p++)
{
int h = 0,k = 0;
for(i=1;i<m;i++)
{
   for( j=0;j<m;j++)
   {
   if(j==p)
      continue;
   c[h][k] = b[i][j];
   k++;
   if(k == m-1)
      {
       h++;
       k = 0;
      }

   }
}

sum = sum + b[0][p]*pow(-1,p)*determinant(c,m-1);
}
return sum;
}

================================================================

5.Please let me know if you want a program for this question or need a detail explanation on that topic.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote