Questions tagged [bisection]

Anything related to a class of algorithms where the result is found by searching either the upper or the lower half of a sorted set of items and repeating this procedure recursively. Commonly used to refer to the bisection method (to find a root of an equation) or to the bisection search algorithm (to search a sorted list for a matching element).

Anything related to a class of algorithms where the result is found by searching either the upper or the lower half of a sorted set of items and repeating this procedure recursively, narrowing the search at each step.

Two common examples of bisection algorithms are:

233 questions
0
votes
5 answers

How to break out of a loop in C

I'm writing a bisection method algorithm to find the roots of polynomials. The second part of my code where it says if variable FP is equal to zero or absolute value of b-a it just breaks the if statement I guess. I want the program to stop the for…
user2059456
  • 19
  • 1
  • 2
  • 8
0
votes
1 answer

Bisection method in c programming

I'm trying to write an algorithm to find the roots of f(x) = x^4 -4x +1 I'm supposed to get the 4 roots of this function 2 reals and imaginary. I write this algorithm in c. But do not if it's well written and what kind of initial guess I should…
user2059456
  • 19
  • 1
  • 2
  • 8
0
votes
1 answer

How do I set a function to a variable in MATLAB

As a homework assignment, I'm writing a code that uses the bisection method to calculate the root of a function with one variable within a range. I created a user function that does the calculations, but one of the inputs of the function is supposed…
TheTreeMan
  • 823
  • 7
  • 22
  • 35
0
votes
1 answer

Segmentation Fault - fortran 90 - bisection subroutine

program bisect real(8) :: output call bisection(3.d0,4.d0,2.d0,output) print*, output end program bisect subroutine bisection(a,b,error,result) real(8):: a,b,error,c,result logical:: proceed proceed = .true. do while (proceed) if…
Debanjan Basu
  • 703
  • 1
  • 6
  • 27
0
votes
1 answer

How to show all the midpoints on my bisection code?

I have a code for finding the bisection (and it finally works!), but I need to include 3 more things: output- Root History a vector containing the sequence of midpoints obtained by the algorithm output- the absolute value of the function f(x) at…
Ajay Kejriwal
  • 31
  • 1
  • 3
  • 7
0
votes
1 answer

"bisection search" for MIT

I happened to find this code, which seems to run fine. Surprisingly, (passing the checkings, for the MIT course) it fails only when the annual interest rate is 0.15, being OK for the other cases. I'm quite a newbie, so I don't have any hope to solve…
Gorka Sillero
  • 25
  • 1
  • 4
-1
votes
0 answers

bisect for a list of objects?

So I have a list of objects, who has several attributes, let's call one of them a which is a real number: llist = [obj1, obj2, obj3] I can easily sort this list according to this attribute by either sorted() function or list.sort()…
Ehsan Sh
  • 9
  • 1
-1
votes
0 answers

How exactly does this give error and x as values

everything in bisect(f, a, b, k_max, eps_x, eps_f), is in a function,i just don't understand how the output gives an x and an error value. x, err = bisect(f, a, b, k_max, eps_x, eps_f)
-1
votes
1 answer

Parameter of convergence of bisection method. C code

I stuck with one formula in my code. Changed it many times in different ways but all the time my teacher say that it is not correct. I gave up and have no idea what else I can do. I think I just don't understand the formula correctly that's why I do…
Gelios
  • 3
  • 3
-1
votes
1 answer

What does epsilon do when used in a bisection search algorithm?

x = 25 epsilon = 0.01 numGuesses = 0 ans = 0.0 while abs(ans**2 - x) >= epsilon and ans <= x: ans += 0.00001 numGuesses += 1 print 'numGuesses =', numGuesses if abs(ans**2 - x) >= epsilon: print 'Failed on square root of', x else: …
-1
votes
1 answer

How to take the cube root of floats using python

x = -37 epsilon = 0.01 num_guess = 0 low = 0.0 high = abs(x) ans = ((low + high)/2.0) while abs(ans**3-abs(x)) >= epsilon: #print("low = " + str(low) + " high " + str(high) + " ans = " + str(ans)) if ans**3 < abs(x): low = ans …
-1
votes
1 answer

How do I get a the output of a range() function to interact with my bisection search method?

The following code is supposed to calcualte what the savings rate would be to pay off my down payment in exactly 36 months given certain factors like (salary raises and annual return rates. I am having trouble getting the output of the range…
chanXVI
  • 23
  • 5
-1
votes
1 answer

Weird behaviour of bisect.insort in Python 3

Python 3.8.2 on a linux box, If I create a list and just use insort over it, I get the expected result; on the other hand if I reverse the order of the elements in the container before calling insort this happens >>> a = list(range(10)) >>> a [0, 1,…
xelp
  • 37
  • 4
-1
votes
1 answer

cubic function root bisection search time limit exceeded

I have implemented this solution for finding a root of a cubic function f(x) = ax3 + bx2 + cx + d given a, b, c, and d, ensuring it's being monotonic. After submitting the solution to an online judge without being shown the test cases, I am being…
Nap
  • 91
  • 6
-1
votes
2 answers

I'm not sure how to account for the 36 month period in my bisection search

Forewarning, I have just started learning python so please bear with me on my beginner code. So in the MIT6_0001 course on python. You are given a problem where you are supposed to find the "optimal monthly saving rate" for a 25% downpayment on a 1…
v0iidb0x
  • 1
  • 2