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, 04.07.2019 18:10
Aloaded platform of total mass 500 kg is supported by a dashpot and by a set of springs of effective stiffness 72 kn/m. it is observed that when the platform is depressed through a distance x = 12.5 cm below its equilibrium position and then released without any initial velocity; it reaches its equilibrium position in the shortest possible time without overshoot. find the position and velocity of the loaded platform 0.10 sec. after its release. if a further load of 400 kg is added to the platform, find, i) the frequency of damped vibrations, and i) the amplitude of vibration after 2 complete oscillations, given that the initial amplitude is 15 cm.
Answers: 1
question
Engineering, 04.07.2019 18:10
Acompressor receives the shaft work to decrease the pressure of the fluid. a)- true b)- false
Answers: 3
question
Engineering, 04.07.2019 18:10
Abrake has a normal braking torque of 2.8 kip in and heat-dissipating cast-iron surfaces whose mass is 40 lbm. suppose a load is brought to rest in 8.0 s from an initial angular speed of 1600 rev/min using the normal braking torque; estimate the temperature rise of the heat dissipating surfaces.
Answers: 3
question
Engineering, 04.07.2019 18:10
Aflywheel accelerates for 5 seconds at 2 rad/s2 from a speed of 20 rpm. determine the total number of revolutions of the flywheel during the period of its acceleration. a.5.65 b.8.43 c. 723 d.6.86
Answers: 2
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
Chemistry, 11.06.2020 22:57
question
Mathematics, 11.06.2020 22:57
question
History, 11.06.2020 22:57
Questions on the website: 13722367