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
I don’t understand some one help
Mnenie [13.5K]

Answer:

C

Step-by-step explanation:

8 0
3 years ago
What is the opposite of 3 over 4
Hoochie [10]

Answer:

Step-by-step explanation:

Explanation: There is nothing known as opposite in algebra. If you mean additive inverse it is 34 and if you mean multiplicative inverse or reciprocal it is −43 . multiplicative inverse, also called reciprocal, is the number which when multiplied with the number results in 1 , the multiplicative identity element.

6 0
3 years ago
Read 2 more answers
Question 2
prisoha [69]

Answer:

Please check the explanation.

Step-by-step explanation:

<u>Calculating the area of the outer rectangle:</u>

Given

  • The length outer rectangle = l = 3x - 1
  • The width of outer rectangle = w = 5x + 2

Thus,

The area of the outer rectangle:

A = wl

    = (5x + 2) (3x - 1)

    =5x\cdot \:3x+5x\left(-1\right)+2\cdot \:3x+2\left(-1\right)

     =5\cdot \:3xx-5\cdot \:1\cdot \:x+2\cdot \:3x-2\cdot \:1

      =15x^2+x-2

<u>Calculating the area of the inner rectangle:</u>

Given

  • The length inner rectangle = l = x + 7
  • The width of inner rectangle = w = x

Thus,

The area of the outer rectangle:

A = wl

   = x(x+7)

   = x² + 7

<u>Calculating the area of the shaded region:</u>

As

The area of the outer rectangle = 15x² + x - 2

The area of the inner rectangle = x² + 7

  • The area of the shaded region can be determined by subtracting the area of the inner rectangle from the area of the outer rectangle.

Thus,

shaded region Area = Outer Rectangle Area - Inner Rectangle Area

                                  = 15x² + x - 2 - (x² + 7)

                                   =  15x² + x - 2 - x² - 7

                                   = 14x² + x - 9

Therefore, the Area of the shaded region is: 14x² + x - 9

4 0
3 years ago
Find the coordinates of the missing endpoint given E is the midpoint of DF. F(5,8) E(4,3)
masha68 [24]

Answer:

(3,-2)

Step-by-step explanation:

Midpoints bisect a line into two perfectly congruent segments. So, you can find that f was translated down 5=(8-3) and left 1=(5-4). then repeat this step by subtracting x of point e by 1 and the y of point e by 5 to get (3,-2)

7 0
3 years ago
Read 2 more answers
THANKS! Everyone if you answer this
andrew11 [14]

Answer:

Down Below .

Step-by-step explanation:

A. Nickel and Copper.

B. The average temp is 1034.8575. I got that by adding all the temps then dividing it by 4

4 0
3 years ago
Other questions:
  • What value of n makes the equation true?
    6·1 answer
  • Find the inner product for (-2,4,8)(16,4,2)and state whether the vectors are perpendicular.
    5·1 answer
  • What is the value of the (x,y) point (1,3) in the function M = 2.5x + 3y?
    5·1 answer
  • Can someone explain or help me out
    12·1 answer
  • I don't know pls help
    11·1 answer
  • What is the distance between (2,9) and (1,5)
    10·1 answer
  • It's all on the picture ​
    10·2 answers
  • I need help How many more Onions dose katrina need to cut.
    9·2 answers
  • The record low temperatures in Fargo in D is -35°F the recorded high is 114°F what is the difference in the high recorded temper
    5·1 answer
  • F(x) = 2x - 1<br> g(x) = - 3x + 2
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!