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:

257 questions
0
votes
1 answer

Iterative solution to finding Longest Increasing Subsequence using Python

I am trying to implement an iterative solution for Longest Increasing Subsequence using bisect. My implementation is failing at some point. Help me fix it. Implementation: from bisect import bisect def lis_iterative(seq): buff = [] for n in…
Shankar
  • 3,496
  • 6
  • 25
  • 40
0
votes
3 answers

Python: Unexpected conditional activation in simple bisection search game

I'm wrote some code to determine a secret number between 0 and 100. The user tells the machine the guessed number (which is half the range) is either to high, too low or just right. Based on the input, the machine used bisection search to adjust the…
KGS
  • 277
  • 2
  • 4
  • 11
0
votes
1 answer

Bisection method to calculate credit card repayments

I'm taking the course 6.00.1x Introduction to Computer Science and Programming. I have been asked to come up with a program that calculates the minimum repayments needed to pay off the credit card balance within a year. For this, I need to use…
0
votes
2 answers

How can I optimize bisection-method for polynomial root finding in Java?

double findaroot(double x1, double x2){ //finds the root between two values double gap = Math.abs(x1 - x2); //find the initial interval while(gap > INTERVAL) { //check for precision gap = gap / 2; //halve the interval …
0
votes
2 answers

Python Bisection search overshoots target

I have to create a code to find the exact payment, to the cent, needed to pay off a loan in 12 months using bisection. The code I created for this works but it overshoots it's target. The loan will be payed off within the 12 months but after making…
Pim
  • 45
  • 1
  • 1
  • 3
0
votes
0 answers

Find string using a bisectional search in linked list

I have a Find function that searches a linked list of strings sequentially. This Find functions finds the string and returns it. I also have a remove function that uses this Find function and removes the string from the linked list. Both of my…
WestonBuckeye
  • 45
  • 2
  • 3
  • 11
0
votes
2 answers

Bisection method in CUDA

I was trying to implement the Bisection Method in CUDA. This method is capable to approximate the eigenvalues from an application (Bisection Method). I have some questions about how to do it. Here is my code: #include #include…
ChrisID58
  • 75
  • 7
0
votes
2 answers

Using Bisection Search on Lowest Payments on Credit Card debt and

My code: monthlyInterestRate = annualInterestRate/12.0 low = balance/12 high = (balance*(1+monthlyInterestRate)**12)/12 guess = (low+high)/2 unpaidBalance = balance month = 1 while True: unpaidBalance= unpaidBalance-guess while…
user2066771
  • 153
  • 2
  • 4
  • 11
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
  • 913
  • 8
  • 23
  • 38
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
  • 834
  • 1
  • 8
  • 29
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
  • 41
  • 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
1 answer

Bisection procedure for [f(x) = x² -2] (sqrt2)

I'm trying to write a program that calculates the root of f(x) = x^2 -2, but it does not seem to change the values of x, fa, and fb. int x2(float a, float b) { float tmp = (a + b) / 2; return tmp; } int…