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
Consider a manufacturing process that is producing hypodermic needles that will be used for blood donations. These needles need
Mars2501 [29]

Answer:

\text{Average diameter is 1.65 mm and we decide that it is not 1.65 mm.}                

Step-by-step explanation:

We are given the following in the question:

The needle size should not be too big and too small.

The diameter of the needle should be 1.65 mm.

We design the null and the alternate hypothesis

H_{0}: \mu = 1.65\text{ mm}\\H_A: \mu \neq 1.65\text{ mm}

Sample size, n = 35

Sample mean, \bar{x} = 1.64 mm

Sample standard deviation, s = 0.07 mm

Type I error:

  • It is the error of rejecting the null hypothesis when it is true.
  • It is also known as false positive error.
  • It is the rejecting of a true null hypothesis.

Thus, type I error in this study would mean we reject the null hypothesis that the average diameter is 1.65 mm but actually the average diameters of the needle is 1.65 mm.

Thus, average diameter is 1.65 mm and we decide that it is not 1.65 mm.

8 0
3 years ago
Read 2 more answers
Please help me I need help
dsp73

Answer:

i think it would be 87% i have been working on ths for a mnet and it got confusing for a sec i may be rong but i am pretty shure that this is the answer

btw i cant spell

Step-by-step explanation:

8 0
3 years ago
Does this image have a set of inputs to a set of possible outputs where each input is related to exactly one outputs Yes or No?
borishaifa [10]

Answer: Yes

This graph passes the vertical line test. This is a test where we try to draw a single vertical line through more than one point on the curve. In this case, such a thing is not possible. Any input x leads to exactly one output y. This graph is a function.

3 0
3 years ago
Anyone know the awnser to this?
iragen [17]

Answer:

61

Step-by-step explanation:

straight line = 180 degree

to find the measure of angle QPR,

subtract 119 from 180

=>            180-119

=>            61

angle QPR = 61 degree

6 0
2 years ago
Read 2 more answers
Please Solve for x. ​
Novosadov [1.4K]

Answer:

A: x = 20

Step-by-step explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • A class tossed coins and recorded 165 heads and 172 tails. What is the experimental probability of tails?
    5·2 answers
  • Ryan is trying to determine whether 2.7x – 5.9 is equivalent to 2.8x – 5.9. To test this, he substitutes 0 for x into both expre
    7·2 answers
  • Write the solution of the inequality in set builder notation: 2(3p-11)&gt;=-16
    12·2 answers
  • Can someone help me please with 9 and 7 !!!!
    13·1 answer
  • A plumber charges a rate of $65 per hour for his time but gives a discount of $7 per hour to senior citizens. Write an expressio
    6·1 answer
  • A pine tree that is 150 feet tall is added to the sample. How will this outlier
    14·2 answers
  • What is the IQR of <br>15,19,20,25,25,28,29,30,30,35,37,43<br>​
    9·2 answers
  • HELP WILL GIVE BRAINLIEST!!!
    12·2 answers
  • PLEASE ANSWER ASAP WILL GIVE BRAINLEIST!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    15·1 answer
  • Keisha and Jen went out to eat for dinner their meal together were $45.76 they want to leave a 20% tip how much total
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!