Assignment 3 solution

pdf

School

University of the Fraser Valley *

*We aren’t endorsed by this school

Course

135

Subject

Mathematics

Date

Jan 9, 2024

Type

pdf

Pages

6

Uploaded by CaptainEagle3867

Report
MECE 390 Assignment 3 Instructions Please be sure that your submitted PDF report is formatted such that each of the requested items are easy to find, i.e. use well-named headers and a properly formatted and hyperlinked Table of Contents. Question 1 Part I. Write a MATLAB function called NRroot that finds the root of a function using the Newton Raphson method. - The input parameters are the name of the function and its derivative as well as the initial estimate for the root 𝑥 0. - The output is the value of the root 𝑥 . - The function prints out intermediate root approximations and error estimates. Note: Attach the MATLAB code to the PDF report. Question 1 Part II. Test your function NRroot with the simple function given below. Find both roots of this function and answer the following questions. ? ( 𝑥 )= 𝑥 2 14 𝑥 / 5+9/5 NOTE: - Round your answers to at least 3 decimal places, e.g. 1.235 for 1.23456 - For the convergence criterion, use the relative error with tolerance 10 5 - The initial estimate of the root in the following table is 3.0 - In order to find both roots, try different initial estimates. Also, note that Root 1 is less than Root 2. Iteration x i Approximate relative error Approximate absolute error 0 3.0 1 1 1 2.25 -0.33333 0.75 2 1.9191 -0.17241 0.33088 Maximum number of iterations: 6 or 7 (starting from 0 or 1) Root 1: 1.0 Root 2: 1.8
Question 1 Part III. Test your function NRroot with the function given below. Find both roots of this function, answer the following questions and comment on the results. In particular, comment on the error estimate and measure of convergence. ? ( 𝑥 )= 𝑥 2 +19 𝑥 / 20 Note: - Round your answers to at least 3 decimal places, e.g. 1.235 for 1.23456 - For the convergence criterion, use the relative error with the tolerance 10 5 - The initial estimate of the root in the table given below is 0.8 - Root 1 is less than Root 2 Iteration x i Approximate relative error Approximate absolute error 0 0.8 1 1 1 0.25098 -2.1875 0.54902 2 0.043384 -4.7852 0.2076 Maximum number of iterations: 7 or 8 (starting from 0 or 1) Root 1: -0.95 Root 2: 0 Note: Attach the full the MATLAB Output (Intermediate root approximations and error estimates) to the PDF report. Note: Comment on the method's performance (convergence rate) for the different roots and initial guesses. Note: Comment on the behavior of the approximate relative error in Question 1-Part III. Question 2 Part I. Write a MATLAB function called fpiroot that finds the root of a function using the Fixed-Point Iteration Method - The input parameters are the name of the auxiliary function 𝑥 = ? ( 𝑥 ) and the initial estimate for the root 𝑥 0. - The output is the value of the root 𝑥 . - The function prints out intermediate root approximations and error estimates. Note: Attach MATLAB code to the PDF report Question 2 Part II. Test your function fpiroot with the simple function given below and find its roots. First, find the coefficients for two formulations of ? ( 𝑥 ) given below.
? ( 𝑥 ) = 𝑥 2 27 𝑥 / 10 + 38/25 Note: Please use the fraction format of numbers for the following coefficients (and when defining this function in your MATLAB code) ? 1 ( 𝑥 )= ? 1 𝑥 2 + ? 1 a 1 = 10/27 b 1 = 76/135 ? 2 (𝑥) = √? 2 𝑥 + ? 2 a 2 = 27/10 b 2 = -(38/25) Use ? 2 (𝑥) to find one root of the equation and enter the values below. Note: - Round your answers to at least 3 decimal places, e.g. 1.235 for 1.23456 - For the convergence criterion, use the relative error with the tolerance 10 -5 - The initial estimate of the root in the following table is 3.1 Iteration x i Approximate relative error Approximate absolute error 0 3.1 1 1 1 2.6173 -0.18445 0.48275 2 2.3551 -0.1113 0.26213 Question 2 - Part III Find both roots of the equation. Note: you may need to use two different formulations to find both roots. Enter your answers with Root 1 less than Root 2. Root 1: 0.8 Root 2: 1.9 Question 3 The volume 𝑉 of liquid in a spherical tank of radius 𝑟 is related to the depth of the liquid in the tank, as shown in Figure 1. The volume can be calculated with the formula:
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
𝑉 = 𝜋ℎ 2 (3𝑟 − ℎ) 3 Figure 1: Spherical tank Use your functions NRroot and fpiroot to calculate the depth of liquid in a spherical tank of radius 𝑟 =1.7 𝑚 to provide a volume of liquid 𝑉 =4.8 𝑚 3. For the Fixed-Point Iteration method, use the two formulations given below. Formulation (a): ℎ = ( 3 + 3𝑉 𝜋 3𝑟 ) 1 2 Formulation (b): ℎ = 3𝑟𝜋ℎ 2 −2𝜋ℎ 3 +3𝑉 6𝑟𝜋ℎ−3𝜋ℎ 2 Question 3 Part I Use the function NRroot and answer the following questions. NOTE: - Round your answers to at least 3 decimal places, e.g. 1.235 for 1.23456 - For the convergence criterion, use the relative error with the tolerance 10 5 - The initial estimate of the root in the table given below is 6.8 Iteration x i Approximate relative error Approximate absolute error 0 6.8 1 1 1 5.6006 -0.21416 1.1994 2 5.0519 -0.1086 0.54864 number of iterations: 5 or 6 (starting from 0 or 1) ℎ = 4.9099
Question 3 Part II Use the function fpiroot with formulation (a) and answer the following questions. Note: - Round your answers to at least 3 decimal places, e.g. 1.235 for 1.23456 - For the convergence criterion, use the relative error with the tolerance 10 -5 . - The initial estimate of the root in the table given below is 0.765. Iteration x i Approximate relative error Approximate absolute error 0 0.765 1 1 1 0.99325 0.2298 0.22825 2 1.0445 0.04903 0.051209 number of iterations: 10 or 11 (starting from 0 or 1) ℎ = 1.0659 Question 3 Part III Use the function fpiroot with formulation (b) and answer the following questions. Note: - Round your answers to at least 3 decimal places, e.g. 1.235 for 1.23456 - For the convergence criterion, use the relative error with the tolerance 10 -5 . - The initial estimate of the root in the table given below is -3.4. Iteration x i Approximate relative error Approximate absolute error 0 -3.4 1 1 1 -2.0494 -0.65901 1.3506 2 -1.29 -0.58873 0.75944 number of iterations: 7 or 8 (starting from 0 or 1) ℎ = -0.87581 Question 3 Part IV Which one of the above initial estimates for the fpiroot converges to the physically meaningful root? 0.765 Use this initial estimate and test the following functions. Comment on the convergence rate of each method: - Function NRroot - Function fpiroot using formulation (a)
- Function fpiroot using formulation (b) Maximum number of iterations - NRoot: 4 or 5 (starting from 0 or 1) Maximum number of iterations fpiroot(a): 10 or 11 (starting from 0 or 1) Maximum number of iterations fpiroot(b): 4 or 5 (starting from 0 or 1) Note: Comment on convergence rate of each of the methods above. Report: Assume you are an engineer responsible for the design and manufacture of spherical storage vessels like those mentioned in the problem above, and you wish to write a program to regularly solve the height problem as mentioned for a variety of tank sizes. Which of the two methods (and formulations) would you choose, and why? Also, comment on the potential use of bisection and false-position methods, including suggestions for the initial bracket. This problem assumes that you are solving the same mathematical formula with different inputs, i.e. the function to solve does not change. We must investigate the function itself and the possible roots. We note that the volume can be found as: 𝑉 = 𝜋 2(3 𝑟 −ℎ)3 This is a cubic function, so we expect to find 3 roots (which we found through the lab). However, only one of the three roots is valid. I would choose either the fixed-point iteration approach and formulation (b), or the Newton- Raphson Method. The fixed-point iteration method with formulation (b) converges quickly, and a reasonable initial guess within the realm of what is physically possible would quickly resolve the correct root. For example, one could automatically assume an initial guess of ℎ= 𝑟 (i.e. the tank halfway full) to guarantee convergence. Investigation of its derivative ? ′( 𝑥 ) shows it could converge to any of the three roots, depending on the initial guess. The Newton-Raphson method may also be a good choice, provided the initial guess converges. The derivative is rather trivial to calculate in this context, and for a reasonable guess it converges in very few iterations. The initial guess of ℎ= 𝑟 as mentioned previously would likely be a suitable guess. Though we can't guarantee it will converge to this root for any guess, the function behavior is well-behaved enough it would probably be suitable. The fixed-point iteration method with formulation (a) is slow to converge, though investigation of its derivative ? ′( 𝑥 ) shows that would only converge to this root. Bracketing methods could be quite effective in this scenario. Given the physical limitations (i.e. ℎ must be between 0 and 2 𝑟 ) the problem has a natural initial bracket. Additionally, the behavior of the function in this domain is more or less linear, and thus the false position method would likely converge quite quickly (which, in fact, it does!).
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