MATH2033 Introduction to Scientific Computation

MATH2033 Introduction to Scientific Computation

— Coursework 2 — Submission deadline: 15:00 Friday 20 December 2024 This coursework contributes 10% towards your mark for this module.

Rules It is not permitted to use generative artificial intelligence (AI) software for this coursework. Ensure thatyou have read and have understood the Policy on academic misconduct. One of the things stated inthis policy is that “The submission of work that is generated and/orimproved by software that is notpermitted for that assessment, for the purpose of gaining marks will be regarded as false authorshipand seen as an attempt to gain an unpermitted academic advantage”.This coursework should be your own individual work, with the exceptions that:

  1. You may ask for and receive help from the lecturer Richard Rankin although not all questions will beanswered and those that are will be answered to all students that attend the class.
  1. You may copy from material provided on the Moodle pages:
  • Introduction to Scientific Computation (MATH2033 UNNC) (FCH1 24-25)
  • Analytical and Computational Foundations (MATH1028 UNNC) (FCH1 23-24)
  • Calculus (MATH1027 UNNC) (FCH1 23-24)
  • Linear Mathematics (MATH1030 UNNC) (FCH1 23-24)

Coding Environment You should write and submit a py file. You are strongly encouraged to use the Spyder IDE (integrateddevelopment environment). You should not write or submit an ipynb file and so you should not use

Jupyter NotebookIt will be assumed that numpy is imported as np, and that matplotlib.pyplot is imported as plt.Submission Procedure: To submit, upload your linear systems.py file through the Coursework 2 assignment activity in theCoursework 2 section of the Moodle page Introduction to Scientific Computation (MATH2033 UNNC)(FCH1 24-25).Marking Your linear systems.py file will be mainly marked by running your functions with certain inputs and comparing the output with the correct output.Department of Mathematical SciencesPage 1 of 51. The linear systems.py file contains an unfinished function with the following first line:def smax (w ,s , i ) :

Assume that:

  • The type of the input w is numpy.ndarray.
  • The type of the input s is numpy.ndarray.
  • The type of the input i is int.
  • There exists an int n such that the shape of w is (n,) and the shape of s is (n,).
  • The input i is a nonnegative integer that is less than n.Complete the function smax so that it returns an int p which is the smallest integer for which

. A test that you can perform on your function smax is to run the Question 1 cell of the tests.py fileand check that what is printed is:1[20 marks] Coursework 2Page 2 of 52. Suppose that A R n×n, that det(A) = 0 and that b R n.The linear systems.py file contains an unfinished function with the following first line:def spp (A ,b , c ) :Assume that:

  • The type of the input A is numpy.ndarray.
  • The type of the input b is numpy.ndarray.
  • The type of the input c is int.
  • There exists an int n such that n > 1, the shape of A is (n,n) and the shape of b is (n,1).
  • The input A represents A.
  • The input b represents b.
  • The input c is a positive integer that is less than n.Complete the function spp so that it returns a tuple (U, v) where:
  • U is a numpy.ndarray with shape (n,n) that 代写MATH2033 Introduction to Scientific Computation represents the matrix comprised of the first ncolumns of the matrix arrived at by performing forward elimination withscaled partial pivotingon the matrix  A b  until all of the entries below the main diagonal in the first c columns are0.v is a numpy.ndarray with shape (n,1) that represents the last column of the matrix arrived atby performing forward elimination with scaled partial pivoting on matrix  A b  until all ofthe entries below the main diagonal in the first c columns are 0.A test that you can perform on your function spp is to run the Question 2 cell of the tests.py filand check that what is printed is:Coursework 2Page 3 of 53. Suppose that A R n×n, that det(A) = 0, that all of the entries on the main diagonal of A arnonzero and that b R n. Let x R n be the solution to Ax = b. Let x (k) be the approximation to x obtained after performing k iterations of the Gauss–Seidel method starting with the initialapproximation x (0) .The linear systems.py file contains an unfinished function with the following first line:

def GS (A ,b ,g ,t , N ) :Assume that:

  • The type of the input A is numpy.ndarray.
  • The type of the input b is numpy.ndarray.
  • The type of the input g is numpy.ndarray.
  • The type of the input t is numpy.float64, float or int.
  • The type of the input N is int.
  • There exists an int n such that the shape of A is (n,n), the shape of b is (n,1) and the shapeof g is (n,1).
  • The input A represents A.
  • The input b represents b.
  • The input g represents x (0) .
  • The input t is a real number.
  • The input N is a nonnegative integer.Complete the function GS so that it returns a tuple (y, r) where:
  • y is a numpy.ndarray with shape (n, M + 1) which is such that, for j = 0, 1, . . . , n 1,

 

posted @ 2024-12-17 19:20  一线定乾坤  阅读(2)  评论(0编辑  收藏  举报