subject
Engineering, 22.02.2020 05:18 abalth8463

In this problem, we will implement a square root approxi- mater and then an nth root approximater. Recall that the nth root of x, written n√x, is the number when raised to the power n gives x. We learned in class that we can use the concepts of binary search to approx- imate the square root of a number, and we can continue this logic to approximate the nth square root. Please look at Lecture Notes 03, section 4 for a little more detail. We’re going to use the concepts of binary search to try and approximate finding the square root and finding the nth root. You may not use any library functions for these question, except DecimalFormat.

(a) Please fill in the squareRootFinder(int number, int iterations) method. The method should return a string representing an approx- imation of the square root of the number to 5 decimal places.

For example:
squareRootFinder(9, 2) means that we want to approximate the square root of 9 with two iterations of binary search. We know that the square root of 9 must be between 0 and 9. Thus, let’s let the ranges that we look at be (0,9). We see the middle of that to be 4.5. (4.5)2 is equal to 20.25. 20.25 is too high because it’s greater than 9. Thus, we now set our ranges we’re looking at to be (0, 4.5). The middle is now 2.25. (2.25)2 is equal to 5.0625, which is now too low since it’s less than 9. We did 2 iterations. Thus, our best guess for the square root is 2.25000 (remember, 5 decimal point accuracy). If we were doing 3 iterations, we’d now set our new range to (2.25, 4.5).

(b) Please fill in the nthRootFinder(int number, int iterations, int n). Now we’re approximating the nth root of our number. Recall that the nth root of x, written n√x, is the number when raised to the power n gives x. For example, the cubed root of 64 is 3√64 which is equal to 4, since 43 = 64. You’ll do the same binary search method as described in part (a) for squareRootFinder, but now you’re check- ing to see if it’s the nth root.

For example: nthRootFinder(64, 1, 3) is trying to approximate the cubed root of 64 with only one iteration of binary search. Hint: the code for nthRootFinder looks just like the code for squareRootFinder except maybe 3 more lines of code. Remember, you may not use any library functions for these questions, except DecimalFormat.

ansver
Answers: 1

Another question on Engineering

question
Engineering, 03.07.2019 15:10
Two flowing streams of argon gas are adiabatically mixed to form a single flow/stream. one stream is 1.5 kg/s at 400 kpa and 200 c while the second stream is 2kg/s at 500 kpa and 100 ? . it is stated that the exit state of the mixed single flow of argon gas is 150 c and 300 kpa. assuming there is no work output or input during the mixing process, does this process violate either the first or the second law or both? explain and state all your assumptions.
Answers: 1
question
Engineering, 04.07.2019 18:10
Journeyman training is usually related (clo2) a)-to specific tasks b)-to cost analysis of maintenance task c)-to control process to ensure quality d)-to installation of machinery
Answers: 2
question
Engineering, 04.07.2019 19:10
What is the chief metrological difference between measuring with a microscope and with an electronic comparator? a. the microscope is limited to small workpieces.a. the microscope is limited to small workpieces. c. the comparator can only examine one point on the workpiece. d. the microscope carries its own standard.
Answers: 1
question
Engineering, 04.07.2019 19:10
Tom is having a problem with his washing machine. he notices that the machine vibrates violently at a frequency of 1500 rpm due to an unknown rotating unbalance. the machine is mounted on 4 springs each having a stiffness of 10 kn/m. tom wishes to add an undamped vibration absorber attached by a spring under the machine the machine working frequency ranges between 800 rpm to 2000 rpm and its total mass while loaded is assumed to be 80 kg a) what should be the mass of the absorber added to the machine so that the natural frequency falls outside the working range? b) after a first trial of an absorber using a mass of 35 kg, the amplitude of the oscillation was found to be 10 cm. what is the value of the rotating unbalance? c) using me-3.5 kg.m, find the optimal absorber (by minimizing its mass). what would be the amplitude of the oscillation of the absorber?
Answers: 3
You know the right answer?
In this problem, we will implement a square root approxi- mater and then an nth root approximater. R...
Questions
question
Mathematics, 26.06.2019 03:00
Questions on the website: 13722363