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
What is the distance between -789 and 989?
MrRa [10]
200

Hope it’s right
Best luck with your studying
8 0
3 years ago
Read 2 more answers
Is the following a function ?
Vanyuwa [196]
Yes it is a function
6 0
3 years ago
Highest comman factor of 200 and 240
Schach [20]

Answer:

40

Step-by-step explanation:

GCF of 200 and 240 is 40

4 0
3 years ago
Read 2 more answers
A satellite is composed of 30 modular units, each of which is equipped with a set of sensors, some of which have been upgraded.
Anit [1.1K]

Answer:

\frac{1}{7}

Step-by-step explanation:

The satellite has 30 modular units.

There are equal numbers of non-upgraded sensors in each unit.

Let us assume that on the entire satellite there are x numbers of upgraded sensors.

Then as per the given condition, there are \frac{x}{5} number of non-upgraded sensors in one unit.

Therefore, the number of non-upgraded sensors on the entire satellite is \frac{30x}{5} =6x

Hence, total number of sensors in the satellite is (x+ 6x) =7x

Therefore, the required fraction of the upgraded sensors is \frac{x}{7x} =\frac{1}{7}. (Answer)

3 0
3 years ago
a port and a radar station are 2 mi apart on a straight shore running east and west. a ship leaves the port at noon traveling no
Rom4ik [11]

Answer:

The rate of change of the tracking angle is 0.05599 rad/sec

Step-by-step explanation:

Here the ship is traveling at 15 mi/hr north east and

Port to Radar station = 2 miles

Distance traveled by the ship in 30 minutes = 0.5 * 15 = 7.5 miles

Therefore the ship, port and radar makes a triangle with sides

2, 7.5 and x

The value of x is gotten from cosine rule as follows

x² = 2² + 7.5² - 2*2*7.5*cos(45) = 39.04

x = 6.25 miles

By sine rule we have

\frac{sin A}{a} = \frac{sin B}{b}

Therefore,

\frac{sin 45}{6.25} = \frac{sin \alpha }{7.5}

α = Angle between radar and ship α

∴ α = 58.052

Where we put

\frac{sin 45}{6.25} = \frac{sin \alpha }{x} to get

\frac{x}{6.25} = \frac{sin \alpha }{sin 45} and differentiate to get

\frac{\frac{dx}{dt} }{6.25} = cos\alpha\frac{\frac{d\alpha }{dt}  }{sin 45}

\frac{15sin45 }{6.25cos\alpha } =\frac{d\alpha }{dt}  }= 3.208 degrees/second = 0.05599 rad/sec.

6 0
3 years ago
Other questions:
  • Which set of ordered pairs could be generated by an exponential function?
    13·2 answers
  • Nathan bought a pair of boots for $79.95 and 2 shirts for $19.99 each. The sales tax is 7.5%. How much did Nathan pay for all th
    7·1 answer
  • What is mathematical answer to 3^2?
    6·1 answer
  • PLEASE HELP WILL GIVE GOOD RATINGS AND 15 POINTS!! I will give BRAINLIEST
    11·1 answer
  • Please help asap no trolls!
    15·1 answer
  • Please solve this will mark brainlist
    13·1 answer
  • How do I do this I’ll mark u brainliest pls ?
    10·1 answer
  • In the figure, m&lt;1=7x+8, m&lt;2=4x+11, and m&lt;4=12x+7. What is the m&lt;1?
    6·1 answer
  • Nathan had an infection, and his doctor wanted him to take penicillin. Because Nathan's father and paternal grandfather were all
    8·1 answer
  • Manolo and Annalisa make handbags. Manolo made 16 handbags the first day and 12 each day after that. Annalisa made 8 the first d
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!