Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem-7 Equations Solving and Performance The ml divide (V) method of solving

ID: 2079972 • Letter: P

Question

Problem-7 Equations Solving and Performance The ml divide (V) method of solving equations is in general faster and more accurate than the matrix inverse (inv). Using both techniques solve the system of equations below and time the execution with the tic and toc functions The tic keyword should be placed before your code and the toc keyword after your code. Using disp or fprintf display the time taken by each method in a sentence. In some cases, you may not be able to tell the difference between the two methods. 3x1 4x2 2x3 -x4 x5 7x6 x7 42 32 x1 2x2 3x3 x4 2xs 4x6 6x7 12 5x1 10x2 4x3 3x4 9xs 2x6 x7 3x1 2x2 2x3 4x4-5x5 6x6 7x7 10 18 x1 2x2 8x3 4x4 2x5 4x6 5x7 17

Explanation / Answer

%part a
disp('Part 1');
A = [3 4 2 -1 1 7 1;
2 -2 3 -4 5 2 8;
1 2 3 1 2 4 6;
5 10 4 3 9 -2 1;
3 2 -2 -4 -5 -6 7;
-2 9 1 3 -3 5 1;
1 -2 -8 4 2 4 5];
b = [42;32;12;-5;10;18;17];
tic
x1 = inv(A)*b;
time1 = toc;
fprintf('Time taken by inverse function: %d ',time1);
tic
x2 = A;
time2 = toc;
fprintf('Time taken by mldivide function: %d ',time2);
disp('Part 2');
A = [1 2 0 -1;
3 1 4 2;
2 -3 -1 5;
1 0 2 2];
b = [0;3;14;-1];
x = A;
e = (A*x) - b;
disp('error');
disp(e);

>> clear all;
Part 1
Time taken by inverse function: 2.423279e-004
Time taken by mldivide function: 2.035554e-004
Part 2
error
1.0e-014 *

0.1332
0
-0.1776
0.0444

>>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote