Question

I need MATLAB code no handwritten solution required. Write a MATLAB script to solve the following...

I need MATLAB code no handwritten solution required.

Write a MATLAB script to solve the following equations using the Cramer’s rule, and compare your results with MATLAB’s root finding method ( 25 pts. ).
8x1 − 2x2 − 1x3 = 5
− 2x1 + 9x2 − 4x3 − x4 = 2
− x1 − 3x2 + 7x3 − x4 − 2x5 = 1
− 4x2 − 2x3 + 12x4 − 5x5 = 1
− 7x3 − 3x4 − 15x5 = 5

Homework Answers

Answer #1

Code:

clc;
clear all;
A = [8 -2 -1 0 0;
-2 9 -4 -1 0;
-1 -3 7 -1 -2;
0 -4 -2 12 -5;
0 0 -7 -3 -15];
B = [5;2;1;1;5];
x = ones(5,1);
a_det = det(A);
for i = 1:5
C = A;
C(:,i) = B;
x(i,1) = det(C)/a_det;
end
x_matlab = A\B;
disp('x by cramers rule:');
disp(x);
disp('x by matlab:');
disp(x_matlab);

Output:

Hope this helps.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
in parts a and b use gaussian elimination to solve the systems of linear equations. show...
in parts a and b use gaussian elimination to solve the systems of linear equations. show all steps. a. x1 - 4x2 - x3 + x4 = 3 3x1 - 12 x2 - 3x4 = 12 2x1 - 8x2 + 4x3 - 10x4 = 12 b. x1 + x2 + x3 - x4 = 2 2x1 + 2x2 - 2x3 = 3 2x1 + 2x2 - x4 = 2
Solve the linear systems that abides by the following rules. Show all steps. I. The first...
Solve the linear systems that abides by the following rules. Show all steps. I. The first nonzero coefficient in each equation is one. II. If an unknown is the first unknown with a nonzero coefficient in some equation, then that unknown doesn't appear in other equations. II. The first unknown to appear in any equation has a larger subscript than the first unknown in any preceding equation. a. x1 + 2x2 - 3x3 + x4 = 1. -x1 - x2...
Consider the following system of equations. x1+2x2+2x3 − 2x4+2x5 = 5 −2x1 − 4x3+ x4 −...
Consider the following system of equations. x1+2x2+2x3 − 2x4+2x5 = 5 −2x1 − 4x3+ x4 − 10x5 = −11 x1+2x2 − x3+3x5 = 4 1. Represent the system as an augmented matrix. 2. Reduce the matrix to row reduced echelon form. (This can be accomplished by hand or by MATLAB. No need to post code.) 3. Write the set of solutions as a linear combination of vectors in R5. (This must be accomplished by hand using the rref form found...
Only MATLAB code is required. No handwritten solution is requested. Use the Newton-Raphson method to determine...
Only MATLAB code is required. No handwritten solution is requested. Use the Newton-Raphson method to determine a root of f (x) =− 0.9x2 + 1.7x + 2.5 using x0 = 5 . Perform the computation until ε a is less 0.01%. Verify the results with the plot. ( 25 pts. )