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]
4 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]4 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
Which expressions are equivalent?
KIM [24]

Answer:

first one

Step-by-step explanation:

Because the coefficient of x is 3 and coefficient of y is-7

3 0
3 years ago
Read 2 more answers
The larger of two numbers is 15 more than three times the smaller number. If the sum of the two numbers is 63, find the numbers.
bulgar [2K]

Answer:

Let x = the smaller number

Let 3x + 15 = the larger number

x + 3x + 15 = 63

4x = 48

x = 12

3(12) + 15 = 51

Step-by-step explanation:

7 0
2 years ago
Suppose that Aces can be either high or low; that is, that {A, 2, 3, 4, 5} is a straight, and so is {10, Jack, Queen, King, Ace}
Mumz [18]

Answer:

If OR is exclusive in the question, meaning that Ace can either be high or low but not both would give you 36 possible combinations. However the question isn't exactly stated in a way that makes it easy to interpret this. Your logic is right though, and it could be an error on your sources part. The possible combos are

A 2 3 4 5

2 3 4 5 6

3 4 5 6 7

4 5 6 7 8

5 6 7 8 9

6 7 8 9 10

7 8 9 10 J

8 9 10 J Q

9 10 J Q K

10 J Q K A

8 0
3 years ago
0.1x + 9 ≤ 45 what is x?
soldi70 [24.7K]
Hi Robles928518, 

0,1x + 9 ≤ 45
0,1x ≤ 45 - 9
0,1x ≤ 36
x ≤ 360

x ∈ ] - ∞ ; 360 ]
5 0
3 years ago
Read 2 more answers
The number of fish (F) in a fish tank increases when the number of plants (P) increases. Write the correct equation for this sce
ddd [48]
Fx=Px 
<span>Plants=3 
</span>(Fish)x=(Plants)3

8 0
3 years ago
Other questions:
  • An ice chest contains 8 cans of apple​ juice, 5 cans of grape​ juice, 4 cans of orange​ juice, and 2 cans of pineapple juice. su
    8·1 answer
  • A mechanic buys $14.56 worth of parts from a supplier. If he pays for the parts with a $20 bill, how much change will he receive
    8·2 answers
  • Solve the system by graphing y=2x+3 y=-4x+9
    10·1 answer
  • Help me figure out the rate of change &amp; the equation for this table ​
    14·1 answer
  • The function p(s)=−10s2+110s−180 represents a company's profit p made on selling a product for s dollars per unit. Calculate and
    6·1 answer
  • kelly will roll a number cube labeled 1 to 6. what is the probability kelly will roll a number greater than 3?
    7·2 answers
  • ms. cox and her three friends are dining at a restaurant. the food they order cost %80. the bill includes an additional 15% serv
    10·1 answer
  • Jamal travel 210 miles which is 70% of the total trip how many more miles does he have to go on a number line
    15·1 answer
  • Plss help want to know the answer
    12·1 answer
  • A rectangular prism has length of 5 feet and a width of 9 feet. If the surface area of the prism is 174 square feet,
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!