Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / ML Assignment #4   Please read “MATLAB Assignment Submission Guidelines” in Blackboard before submission

ML Assignment #4   Please read “MATLAB Assignment Submission Guidelines” in Blackboard before submission

Math

ML Assignment #4

 

Please read “MATLAB Assignment Submission Guidelines” in Blackboard before submission.  Not following the guidelines will result in loss of credit, even though you may have the correct answer(s).

 

Write code of your own and answer the questions in this assignment.

  • Submit your code through Cody Coursework. 
  • Submit a report through Blackboard

 

 

Pseudocode, the Bisection method, and the Newton-Raphson method are the basis of this assignment. 

 

 

You are working for DOWN THE TOILET COMPANY that makes floats for ABC commodes. The floating ball has a specific gravity of 0.6 and has a radius of 5.5 cm. You are asked to find the depth to which the ball is submerged when floating in water.

 

 

 

 

 

The equation that gives the depth

 (unit of

 is meters) to which the ball is submerged under water when floating is given by

 

??(??) = ??3− 0.165??2 + 3.993 × 10−4 = 0

 

Problem 1: Prepare to program both the bisection and the Newton-Raphson method

 

  1. Plot f(x)

Use any command to plot the function ??(??) between 0 and 0.11.  You may consider using plot, fplot, or ezplot.  Set figure title, axis titles, grid, etc. so that your figure looks professional.

 

  1. Pseudo code

Prepare pseudocode of the Bisection method as well as the Newton-Raphson method based on what you have learned in class.

                 

Problem 2: Solve the equation using the Bisection method

 

Write a MATLAB function to solve the floating ball problem.  Program the bisection method according to your pseudo code.

 

Your function should meet the following requirements:

  • It should be named Bisection
  • The function should have three input arguments: 
    1. lower bound of the initial interval; 
    2. upper bound of the initial interval; and  3) desired number of significant digits.
  • The function should have three output arguments stored as a row vector
    1. final number of iterations; 
    2. final estimate of the root; and
    3. final absolute relative approximate error.
  • The function should check if the initial interval is valid or not. Display the check result as a message on screen. If the initial interval is not valid, return [inf inf inf] as the output.
  • Implement the bisection method using a while-end loop until you find an estimate of the root with the required number of significant digits. Demonstrate this portion of your code in your report.
  • In each iteration, the function should display on screen 
    1. the current iteration number;
    2. the interval at the beginning of the iteration;
    3. the previous estimate of the root;
    4. the current estimate of the root;
    5. the current absolute relative approximate error; and  6) in which half the true root lies.

 

Your solution will be tested three times with both known and randomly generated input arguments.

  • Test 1: with input arguments (0, 0.11, 2)
  • Test 2: with input arguments (0, 0.055, 2)
  • Test 3: with random input arguments

 

                 

 

Problem 3: Solve the equation using the Newton-Raphson method

 

1) Write a MATLAB function to solve the floating ball problem.  Program the Newton-Raphson method according to your pseudocode

 

Your function should meet the following requirements:

  • It should be named NR
  • The function should have three input arguments: 
    1. initial estimate of the root; 
    2. desired number of significant digits; and  3) maximum number of iterations.
  • The function should have three output arguments stored as a row vector
    1. total number of iterations performed; 
    2. the final estimation of the root; and
    3. the final absolute relative approximate error in decimal.

    The function should check if the initial estimate is valid or not in terms of 

  1. whether it is physically meaningful, and 
  2. whether the derivative of the function exists or not (division by zero). 

Display the check result as a message on screen. If the initial interval is not valid, return [inf inf inf] as the output.  Demonstrate this portion of your code in your report.

  • Implement the Newton-Raphson method using a loop until:
    1. you find an estimate of the root with the required number of significant digits; or  2) the maximum number of iterations is reached. Demonstrate this portion of your code in your report.
  • In each iteration, the function should display on screen:
    1. the current iteration number;
    2. the previous estimate of the root;
    3. the current estimate of the root; and
    4. the current absolute relative approximate error.

In each iteration, the function should also check if division by zero is encountered or not. If so, display a message on screen, immediately end the loop, and return the current iteration number, current root estimate, and current absolute relative approximate error.  Demonstrate this portion of your code in your report.

  • At the end of your function, check the following: 
    1. if the desired significant digits is achieved or not; and  2) if the current estimate has any physical meaning or not. 

Display your check results on screen.  Demonstrate this portion of your code in your report.

 

Your solution will be tested three times with both known and randomly generated input arguments.

  • Test 1: with input arguments (0.05, 2, 10)
  • Test 2: with input arguments (0, 2, 10)
  • Test 3: with input arguments (0.5, 2, 10)
  • Test 4: with input arguments (-0.5, 2, 10)
  • Test 5: with random input arguments

 

 

2) Pros and cons of the Newton-Raphson method

 

Vary the initial estimate and answer the following questions.

  • What happens when you set the initial guess very close to zero?
  • Can you code converge to a different root (which may not have physical meaning in this particular problem)?  What initial guesses would lead to a different root?
  • Comment on the advantages and limitations of Newton-Raphson method.

Option 1

Low Cost Option
Download this past answer in few clicks

48.98 USD

PURCHASE SOLUTION

Already member?


Option 2

Custom new solution created by our subject matter experts

GET A QUOTE