matlab代写 MATH3501

Mathematical Sciences Institute

MATH3501 — Scientific and Industrial Modelling Assignment 5
Due Monday 29th October, 11.55pm.

Submit online to wattle site. Scanned copies of hand written maths is fine. Computational questions can be uploaded separately as a PDF file. This can be prepared with software such as Word or LaTeX. (You might consider online resources such as ShareLaTeX).
The total point score for this assignment is 30.

Question 1 (Shallow Water Wave Equation) 10 pts

In this question you will be asked to extend the matlab live script riemann.mlx (available from the assignment 5 wattle page) to solve a Riemann problem which joins two states via two rarefaction fans.
Hint: Remember to download the script as a mlx file and do not extract the file.

The riemann.mlx script implements functions to calculate the states that can be connected via simple waves such as rarefaction waves or shocks.
In particular the script defines matlab functions Rone, Rtwo, Sone and Stwo which for an arbitrary state h∗,u∗) provides a function u(h) associated with waves R1, R2, S1 and S2 from the notes.

The live script provides the following:
• A plot (Figure 1) of the accessible states from the state (10, 0) .

• The script solves the problem of joining a left state (10,0) to a right state (1,0) via a R1 rarefaction and then a S2 shock with an intermediate state (3.9617, 7.3370).

• A plot of solution h and u at time t = 1 (Figure 2a-2b).
• Finally a contour plot of the two Riemann Invariants (u + 2c andu − 2c ). These contour plots

essentially provide a plot of the two set of characteristics (Figure 3a-3b). See plots on next page.

Assignment Task

Your task is replicate these 4 results for a left state (5, 0) and a right state (5, 2) which are joined by a R1 rarefaction and then a R2 rarefaction. In particular:

(a) Produce a plot of the accessible states from the state (5,0). Be careful to restrict the plot to positive h . 2 pts

(b) Solve the problem of joining a left state (5, 0) to a right state (5, 2) via a R1 rarefaction wave and then a R2 wave. Determine the intermediate state. 2 pts

(c) Produce solution plots for h and u at time t = 1 for this R1R2 problem (similar to Figure 2a-2b). 3 pts

(d) Produce contour plots of the two Riemann Invariants (u + 2c andu − 2c ). These contour plots essentially provide a plot of the two set of characteristics (similar to Figure 3a-3b). 3 pts

You may provide your answer as a pdf of an appropriately modified version of riemann.mlx, but be sure to document your changes to the script.

Figure 1: Accessible states from the state (10, 0) .

Figure 2: Riemann Solution at time t = 1 left state (10, 0) , right state (1, 0) .

Figure 2: Riemann Invariants, left state (10, 0) , right state (1, 0) .

MATH3501, Page 2 of 4

Question 2 (Cross Validation) 10 pts

In the computer lab in week 11 we used a Radial Basis Function to act as a surrogate for the expensive ODE predator prey model (implemented in function model2). A modified version of that live script is uq_rbf_model2.mlx (and is available from the assignment 5 wattle page). In that script we useasmoothingparametertheta = 0.25.

Why did we choose that particular value? Well actually it was chosen by eye balling. But this question provides a more general method, called cross validation.
The idea is to have two sets of data, a training set and a test set.
In our case, the training set is given by the sample points

Q = [a1,a2] + range*(2*lhsdesign(ninit,2,’iter’,20)-1); together with the corresponding tv values (the training set is used to build the rbf surrogates).

The other will be an independent set of samples,

Qtest = ….

together with the corresponding function values

tvtest = measuretv(Qtest(:,1), Qtest(:,2), a3, owl0, rat0, tfinal);

which together will provide the test set.
The test set is used to measure the accuracy of the surrogate built using the training set for a particular value of theta.
The testing test is usually smaller than the training set. So in our case of a training set of 40 samples, the testing set can have 10 samples. But the testing samples need to be independent of the training set. Using lhsdesign with a smaller sample size of 10 should be fine.

Assignment Task

  1. (a)  Add to the code in uq_rbf_model2.mlx the creation of a test set (Qtest samples and corresponding function values tvtest). 3 pts
  2. (b)  Create a function called cross_validation with the following structure
    function cv = cross_validation(Q, tv, Qtest, tvtest, theta)

        % Calculate rbf values at Qtest locations
        % using the training set Q, tv
        rbftv = ....
    
        cv = norm(rbftv-tvtest)
        end
    

    which takes in the training and test sets, and parameter value theta and tests how well the rbf surrogate fits the test data. 3 pts

  3. (c)  Using the function cross_validation, test various values of theta to find th effect of changing theta. Produce a plot of the cross validation value versus theta. 3 pts

    Hint: There is no need to be very accurate. I suggest using possible values of theta as powers of 2from2−5 to23.

  4. (d)  What is your recommendation for the good choice of theta? 1 pt

You may provide your answer as a pdf of an appropriately modified version of uq_rbf_model2.mlx with obvious comments documenting your additions.

MATH3501, Page 3 of 4

Question 3 (KKT Condition)

Consider the problem

(a) Find all the points satisfying the KKT conditions. (b) Determine the global minimizer.

10 pts

minimize ln x − y
􏰀 x2 +y2 ≤ 4

subject to x ≥ 1

8 pts 2 pts

MATH3501, Page 4 of 4