Learning Goal: I’m working on a java multi-part question and need an explanation

Learning Goal: I’m working on a java multi-part question and need an explanation and answer to help me learn.Problem 1:Part 1: Square rootIn this homework assignment, write a function that computes the square root of a given double up to a certain precision. This function should be a member function of of class MyMath and should have signaturepublic static double sqrt(double d)You will use a technique called bisection or binary search for its implementation.Part 2: TestingWrite a code that compares the speed of your MyMath.sqrt with Math.sqrt in the way specified below. This code should go into the public static member function named main of class MyMath.Using a loop, evaluate Math.sqrt on 10,000,000 random numbers between 0 and 100. These random numbers should be generated by calling 100*Math.random(). Measure the time it takes to complete this task using System.nanoTime(). Do the same with MyMath.sqrt. You may want to consult: https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#nanoTime–This time measurement includes the time it takes to generate the random numbers. With a separate loop, measure the time it takes to generate the random numbers without evaluating the square root.Putting these measurements together, output, to the command line, the average execution times per evaluation of the two square root functions with the execution time of the random number generation subtracted out. Note that Java applications run a little bit lag behind the schedule at beginning. Hence, to improve the accuracy of System.nanoTime(), you should write an extra loop (without timing) before the timed one.You will see that Math.sqrt is far superior over MyMath.sqrt. This is to be expected since standard math functions like Math.sqrt are implemented and optimized by a group of experts over many hours.
Requirements: as clear as possible   |   .doc file

Leave a Reply

Your email address will not be published. Required fields are marked *