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
today nolan put a recliner on layaway by making a down payment of 90$ and agreeing to pay 36$ a month starting next month for 12
SashulF [63]

Answer:

In 12 months.


5 0
3 years ago
Read 2 more answers
What is the solution to the following equation? (4 points) 5(2x − 6) + 20 = 10 Group of answer choices
vichka [17]

Answer:

x=2

Step-by-step explanation:

6 0
3 years ago
Order the following integers from least to greatest 6, 11, 16, -8, -5
posledela
-8,-5, 6, 11, 16: reasoning if the number is a higher negative it makes it less
3 0
3 years ago
Error Analysis Your friend says that the volume of this sphere is 44.58
Maurinko [17]

Answer:

  • the given dimension was used as the radius
  • 5.57 m³

Step-by-step explanation:

The volume of a sphere can be found using the formula ...

  V = 4/3πr³ . . . . . where r is the radius

__

The figure points to a diameter line and indicates 2.2 m. The arrowhead is in the middle of a radius line, making it easy to interpret the dimension as the radius of the sphere.

If 2.2 m is used as the radius, the volume is computed to be ...

  V = 4/3π(2.2 m)³ ≈ 44.58 m³

This agrees with your friend's volume, suggesting the diameter was used in place of the radius in the computation.

__

The correct volume, using 2.2 m as the diameter, is ...

  V = 4/3π(1.1 m)³ ≈ 5.57 m³

6 0
2 years ago
What is a point-slope equation of the line with slope -12 that goes through the point (5, 3)?
Sliva [168]

Answer:

A. y- 3 = -12(x - 5)

Step-by-step explanation:

6 0
3 years ago
Other questions:
  • Angie walks from the parking lot along oak trail Then to the picnic area to the pine trail how To the parking lot . how many mil
    7·1 answer
  • 72fl oz is how many cups
    8·2 answers
  • An urn contains 13 red balls and 7 blue balls. Suppose that three balls are taken from the urn, one at a time and without replac
    7·1 answer
  • Find the vertex of y=x²-6x+4
    10·1 answer
  • The interior angles of triangle ABC measure 34°, 63°, and x°. The Interior angles of triangle DEF measure y°, 63°, and 83°.
    8·1 answer
  • There are 5 green skittles, 4 orange skittles, and 3 red Skittles in a bag. What is the probability of red Skittle, Not replacin
    8·1 answer
  • The length of one edge of a cube is 5 units. what is the volume of this cube in cubic units
    10·1 answer
  • PLS HELP WILL MARK YOU BRAINLIEST! NO FAKE ANSWERS!<br> Are the images convex or concave polygons?
    8·1 answer
  • How many positive three-digit integers have the hundreds digit equal to 7 and the units (ones) digit equal to 1?
    12·1 answer
  • Help please i’m not sure if it’s c
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!