The basis of finite element analysis (FA) is understanding how to use a system o
ID: 3738833 • Letter: T
Question
The basis of finite element analysis (FA) is understanding how to use a system of linear equations A system of linear equations are a group equations that can solve n equations and unknowns A useful way to write the system is with a matrices (Equation I), where A is m by matrix, X is n by 1 matris, and IB is m by I matris. The solution can he found by taking the inverse of A noted as A (Eiquation 2). If A is a 3x3 matris, one way to find the inverse is found in Equation 3. Each element of A is a constant For example element as is the constant related t the 2 equation and I variable X is a column matris containing the variables B is what each equation is equated to 1?1x1-1 Equation 1-Matrix System of Equations Euation 2 Solution to Equations 12 ay a an 13 a11 22 23 s a an a a22 11 2 Equation 3-Inverse of 3v3 Matrix Problem We need to solve a system of linear equations below. The system has 3 equations and 3 unknowns -3x-2y +z=-17 +2x-5y +3z15 In a C++ Program a) Input Validation-Determine if the square 3x3 matrix has an inverse. That is if and only if det(A) # 0 then A will have an inverse. The user should be notified if A has an inverse or not b) Input Validation Matrix A should only be able to input numbers, matrix X should only be the variables (x y, z), and B should only be able to input numbers c) Output the A, X, and B matrix in correct matrix format d) Calculate the inverse of A using functions, pointers, and 2D Arrays e) Find the solution of the system or equations using functions, pointers, and 2D ArraysExplanation / Answer
here is the code for the above problem
#include<iostream>
using namespace std;
int main(){
int mat[3][3], i, j;
float determinant = 0;
cout<<"Enter elements of matrix row wise: ";
for(i = 0; i < 3; i++)
for(j = 0; j < 3; j++)
cin>>mat[i][j];
printf(" Given matrix is:");
for(i = 0; i < 3; i++){
cout<<" ";
for(j = 0; j < 3; j++)
cout<<mat[i][j]<<" ";
}
for(i = 0; i < 3; i++)
determinant = determinant + (mat[0][i] * (mat[1][(i+1)%3] * mat[2][(i+2)%3] - mat[1][(i+2)%3] * mat[2][(i+1)%3]));
cout<<" determinant: "<<determinant;
cout<<" .................Inverse of matrix is................ ";
for(i = 0; i < 3; i++){
for(j = 0; j < 3; j++)
cout<<((mat[(j+1)%3][(i+1)%3] * mat[(j+2)%3][(i+2)%3]) - (mat[(j+1)%3][(i+2)%3] * mat[(j+2)%3][(i+1)%3]))/ determinant<<" ";
cout<<" ";
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.