HW_5___MCEN_3030___Computational_Methods___Fall_2022

pdf

School

University of Colorado, Boulder *

*We aren’t endorsed by this school

Course

3030

Subject

Computer Science

Date

Dec 6, 2023

Type

pdf

Pages

2

Uploaded by EarlChimpanzee3848

Report
MCEN 3030 Computational Methods - HW 5 - Fall 2022 Prof. Robert MacCurdy Submission Deadline: October 14th 2022, Friday @ 11.59pm Submission Guidelines: Follow the homework format and submission instructions in the Syllabus and on the course Canvas site! Read all questions carefully and answer all questions. When in doubt, provide more information rather than less. Question 1 - More Norms For the following vectors and matrices ( NOTE: you may use MATLAB builtin functions for Question 1): V 1 = 2 . 6 2 . 8 6 . 4 V 2 = 5 . 6 4 . 8 6 . 2 M 1 = 2 . 3 2 . 2 7 . 3 3 . 9 7 . 9 3 . 3 7 . 7 3 . 5 0 . 5 M 2 = 1 . 6 2 . 8 9 . 2 2 . 5 7 . 9 1 . 3 6 . 4 3 . 3 0 . 5 (a) Calculate the difference between these two vectors, V 1 and V 2 , and quantify the magnitude using the following norm measures. Show these norms in a table and comment on your results. i. The L1 norm. ii. The L2 norm. iii. The Infinity norm. (b) Calculate the difference between these two matrices, M 1 and M 2 , and quantify the magnitude using the following norm measures. Show these norms in a table and comment on your results. i. The L1 norm. ii. The L2 norm. iii. The Frobenius norm. iv. The Infinity norm. Question 2 - Gauss-Seidel Method (a) Write a program to solve an NxN system of equations of the form Ax=b in MATLAB, using your own implementation of the Gauss-Seidel algorithm. Use a stopping criterion such that the answer is correct up to 3 significant digits, and ensure that you use a maximum iterations count in your loop. In your program, you should also include code to check for the Gauss-Seidel convergence criteria and show appropriate outputs based on this check. (b) Use the code you just wrote to compute the solution, and then check your solution by computing the (more precise) solution using the backslash operator and show what the error between the true solution and the Gauss-Seidel method is. ( NOTE: if necessary, you may change the value of a 33 to -10.5) A = 10 . 6 2 . 8 1 . 4 4 . 2 2 . 7 7 . 9 1 . 3 3 . 8 6 . 7 3 . 1 1 . 5 2 . 9 4 . 4 1 . 6 0 . 9 7 . 1 b = 3 4 2 11 Question 3 - 1D Regression You are given the following data of the population (X) of many different cities (in a country that shall remain nameless), and the number of people from each city who prefer Vegemite (Y) to other spreadable “food” products. 1
(a) Write your own program to calculate the equation of a 1D linear regression line for the X and Y data using the least-squares approach (i.e. use eqns 17.6 and 17.7). (b) Compute (and print out) the standard error of the estimate , S y/x , provide your values for a 0 and a 1 and plot the data with the regression line for the X-Y data. Notes: 1. See below for the data table. Also, the data has been included in a .mat file that is uploaded along with the HW5. # Prefer Vegemite City Population 192000 1800000 190400 1790000 191200 1780000 177600 1778000 176800 1750000 178400 1740000 180800 1725000 175200 1725000 174400 1720000 173920 1705000 172800 1710000 163200 1700000 161600 1695000 161600 1695000 160800 1690000 159200 1630000 148800 1640000 115696 1635000 147200 1630000 150400 1620000 152000 1615000 136000 1605000 126240 1590000 123888 1595000 126080 1590000 151680 1600000 152800 1610000 2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help