Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve using Matlab and please solve both problems and all steps Learn how to solve linear systems using the following methods: o MATLAB left division

image text in transcribed
image text in transcribed
image text in transcribedSolve using Matlab and please solve both problems and all steps
Learn how to solve linear systems using the following methods: o MATLAB left division (Gauss elimination) o LU Factorization o Gauss-Seidel Iteration Learn how to test for round off error problems. INSTRUCTIONS: Write a single MATLAB m-file that solves all roblems below. For each problem, write the requested answers to ASCII data files with the exact filenames specified (e.g. "A3.dat"). Submit a printout of your main m-file and all associated m-files me for grading by the due date. For the data files you generate (e.g. "Al.dat"), submit those to me in an email! (This will save on paper.)Your entire assignment should run, generating all of the required data files, by typing the name of the main m-file at the command prompt. Consider the electric circuit shown below: V4 R7 V2 R8 R6 R1 2 R3 V1 R4 R2 R5 V3 By applying Kirchoft's Laws and Ohm's law, the currents 1, /2, 1, and I4 can be solved for with the following linear system: The resistors and voltages have the values given in the table below: Resistor Value(2) R 333 150 1000 15000 3000 500 2000 100 80 Variable -40 60 Work by hand to write this system of linear equations in standard matrix form Ax-b where x is the column vector of the four unknown currents (, 12, Is, and 4) and all of the values on the diagonal of A are positive. a) Calculate the 2-norm condition number of the coefficient matrix A. Note that this step is intended as a check to make sure you have formulated A correctly in addition to giving an indication of the roundoff error potential. b) Varying /2 from 0 to 120 in increments of 0.5, calculate I,. 2Is, and I4 using left division. Save your results in a matrix of 4 columns (results for Ii, 12. 1s and I respectively) and 241 rows. c) Repeat the calculation for part (b) using LU factorization to increase the efficiency of the calculation. Also, for each value of V2, save the intermediate solution (the d vector resulting from the forward substitution step) as a row in a 241x4 matrix for submission to Scorelator. Consider timing sections of your code using the tic and toc commands to measure the computational efficiency gained by using LU factorization. ANSWERS: Write your result for the condition number (1x1) to Al.dat. Write your current results (241x4) for parts (b) and (c) to A2.dat and A3.dat respectively. Write your matrix of intermediate d vectors (241x4) to A4.dat. Consider again the linear system from Problem 1. Note that once the system above is rearranged the coefficient matrix A is diagonally dominant. Repeat the calculation you did for problem lb using Gauss-Seidel iteration (use GS.m or your own version) to solve the linear system for each V2 value. Use an initial guess of I [0, 0,0, 0] for all cases and use a stopping criterion of e,-1E-4. a) Repeat the calculation for part (a) using Jacobi iteration. You will need to write your own function to do this iteration (you can modify GS.m with only one or two small changes depending on how you do it). Use an initial guess of 1-0, 0, 0, 0] for all cases and use a stopping criterion of .-1E-4. More that these solutions may take more than 50 iterations each to converge ) For the two iterative solutions for parts (a) and (b), determine the average number of iterations required for convergence in each case. Save your result in a two-element row vector (Gauss-Seidel first, Jacobi second). d) Calculate the Euclidean norm of the residuals vector for each of the Gauss-Seidel solutions and store the results in a column vector (241x1). ANSWERS: Write your results (241x4) for parts (a) and (b) to A5.dat and A6.dat respectively. Write your average iteration counts from part(c) to A7.dat (1x2). Write your vector of residuals norms from part (d) to A8.dat (241x1). Learn how to solve linear systems using the following methods: o MATLAB left division (Gauss elimination) o LU Factorization o Gauss-Seidel Iteration Learn how to test for round off error problems. INSTRUCTIONS: Write a single MATLAB m-file that solves all roblems below. For each problem, write the requested answers to ASCII data files with the exact filenames specified (e.g. "A3.dat"). Submit a printout of your main m-file and all associated m-files me for grading by the due date. For the data files you generate (e.g. "Al.dat"), submit those to me in an email! (This will save on paper.)Your entire assignment should run, generating all of the required data files, by typing the name of the main m-file at the command prompt. Consider the electric circuit shown below: V4 R7 V2 R8 R6 R1 2 R3 V1 R4 R2 R5 V3 By applying Kirchoft's Laws and Ohm's law, the currents 1, /2, 1, and I4 can be solved for with the following linear system: The resistors and voltages have the values given in the table below: Resistor Value(2) R 333 150 1000 15000 3000 500 2000 100 80 Variable -40 60 Work by hand to write this system of linear equations in standard matrix form Ax-b where x is the column vector of the four unknown currents (, 12, Is, and 4) and all of the values on the diagonal of A are positive. a) Calculate the 2-norm condition number of the coefficient matrix A. Note that this step is intended as a check to make sure you have formulated A correctly in addition to giving an indication of the roundoff error potential. b) Varying /2 from 0 to 120 in increments of 0.5, calculate I,. 2Is, and I4 using left division. Save your results in a matrix of 4 columns (results for Ii, 12. 1s and I respectively) and 241 rows. c) Repeat the calculation for part (b) using LU factorization to increase the efficiency of the calculation. Also, for each value of V2, save the intermediate solution (the d vector resulting from the forward substitution step) as a row in a 241x4 matrix for submission to Scorelator. Consider timing sections of your code using the tic and toc commands to measure the computational efficiency gained by using LU factorization. ANSWERS: Write your result for the condition number (1x1) to Al.dat. Write your current results (241x4) for parts (b) and (c) to A2.dat and A3.dat respectively. Write your matrix of intermediate d vectors (241x4) to A4.dat. Consider again the linear system from Problem 1. Note that once the system above is rearranged the coefficient matrix A is diagonally dominant. Repeat the calculation you did for problem lb using Gauss-Seidel iteration (use GS.m or your own version) to solve the linear system for each V2 value. Use an initial guess of I [0, 0,0, 0] for all cases and use a stopping criterion of e,-1E-4. a) Repeat the calculation for part (a) using Jacobi iteration. You will need to write your own function to do this iteration (you can modify GS.m with only one or two small changes depending on how you do it). Use an initial guess of 1-0, 0, 0, 0] for all cases and use a stopping criterion of .-1E-4. More that these solutions may take more than 50 iterations each to converge ) For the two iterative solutions for parts (a) and (b), determine the average number of iterations required for convergence in each case. Save your result in a two-element row vector (Gauss-Seidel first, Jacobi second). d) Calculate the Euclidean norm of the residuals vector for each of the Gauss-Seidel solutions and store the results in a column vector (241x1). ANSWERS: Write your results (241x4) for parts (a) and (b) to A5.dat and A6.dat respectively. Write your average iteration counts from part(c) to A7.dat (1x2). Write your vector of residuals norms from part (d) to A8.dat (241x1)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions

Question

2. Is this illegal harassment/discrimination?

Answered: 1 week ago