Simple Algorithms Flashcards
What is a way to find the approximate solution of a cube root?
While the absolute of (guess cubed - cube) is >= epsilon, increment guess by a smaller amount than epsilon
How do you perform a bisection search
Set answer = (high + low)/2. Loop, if answer squared is less than x; low equals answer otherwise high equals answer #Remember to rebind answer
How does bisection search convergence work?
first guess: N/2
nth guess: N/2^n
How do you convert decimal integers to binary?
Take a remainder relative to 2 and concatenate it into a string, divide by 2 (//) to shift to rigtht
When finding the root of a number what condition should stop the loop running?
while abs(guess**2 - x) >= epsilon:
How do you find the root of a solution using Newton-Raphson?
Set guess equal to x divided by 2.
Loop guess = (((guess**2) - x) / (2*guess))