1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Archy [21]
3 years ago
11

Write a function that solves the matrix equation Ax = b using Gaussian Elimination (book section 6.2). Your function should acce

pt as input a n-by-n matrix A and an n-by-1 vector b, and it should produce a n-by-1 vector x that satisfies Ax = b.
Mathematics
1 answer:
Luba_88 [7]3 years ago
5 0

Answer:

See explaination

Step-by-step explanation:

public class GaussElim{

private static final double eps = 1e-10; % set epsilon value

public static doublic[] fun(double[][] A,double[] b){

int n=b.length; %calculate length of vector b.

for( int j=0;j<n;j++){

int max=j; %find and swap pivot row.

for (int i=j+1;i<n;i++){

if(Math.abs(A[i][j])>Math.abs(A[max][j])){

max=i;

}

}

double[] t1= A[j]; %swap

A[j]=A[max];

A[max]=t1;

double t= b[j]; %swap

b[j]=b[max];

b[max]=t;

if(Math.abs(A[j][j])<=eps){

throw new ArithmeticException("Matrix is singular."); % if matrix A is a singular matrix then throw error.

}

for(int i=j+1;i<n;i++){

double alpha= A[i][j]/A[j][j];

b[i]=b[i]-alpha*b[j];

for(int k=j;k<n;k++){

A[i][k]=A[i][k]-alpha*A[j][k];

}

}

}

double[] x=new double[n]; % back substitution starts here

for(int i=n-1;i>=0;i--){

double sum=0.0;

for(int j=i+1;j<n;j++){

sum=sum+A[i][j]*x[j];

}

x[i]=(b[i]-sum)/A[i][i];

}

return x;

}

public static void main(String[] args){

int n=3;

double[][] A={{1,2,1},{4,2,0},{-1,5,-3}};

double[] b={5,3,21};

double[] x=fun(A,b);

for(int i=0;i<n;i++){

StdOut.println(x[i]);

}

}

}

You might be interested in
[WILL PICK FIRST CORRECT ANSWER AS BRAINLIEST]
riadik2000 [5.3K]
F(3) = 6 - 3 = 3

answer 3
4 0
3 years ago
Read 2 more answers
I try to look this up and people said yes or no I just need a straight answer
Anna11 [10]

start inside the square root, replace X with -7.

-7 + 11 = 4

The number 4 comes out of the square root as 2.

Now there's a minus factor out there. Let's multiply this negative factor by 2 and get -2.

Now let's add -2 and -3.

Our output is -5.

3 0
3 years ago
Use distributive property 5(6+b) *<br> Your answer
EleoNora [17]

Answer:

5b +30

Step-by-step explanation:

5 · 6 = 30

5 · b = 5b

8 0
3 years ago
Slope of (10,8) (2,1)
Reptile [31]

Answer:

slope=7/8

Step-by-step explanation:

8-1/10-2= 7/8

6 0
3 years ago
Which shows the equation below written in the form ax2 + bx + c = 0?
Svetach [21]

Answer:

A

Step-by-step explanation:

X^2 + 6X + 8 =3

TRANSPOSE 3 TO LEFT

X^2 + 6X + 8 - 3 = 0

CALCULATE

X^2 + 6 X + 5 = 0

3 0
3 years ago
Other questions:
  • What does x equal ?​
    11·2 answers
  • 5x-2y+3z-2x-y+4z solve
    13·2 answers
  • Isabella had a week to read a book for a school assignment. She read an average of 36 pages per day for the first three days and
    6·1 answer
  • a motorboat traveled for 2 hours with an 8km/h current. the return trip against the same current took 3 hours. find the speed of
    6·1 answer
  • Lisa is making a juice-mix that uses orange juice and pineapple juice in 6:7 ratio. Which all of the following options describe
    11·1 answer
  • What is 7/8 of 8/9?<br><br> if you could, include an explanation.<br> thanks
    10·2 answers
  • What is the difference between the Right of Occupancy and Original Indian Title?
    6·2 answers
  • Sum of 1/3, 1/5 and 1/6 in simplest form
    9·2 answers
  • 4/12 + 3/12 = ???????
    7·2 answers
  • Write an equation of a line that passes through the point (3, 2) and is parallel to the line y = 3x - 4.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!