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
2
votes
2 answers

How to use the bisection method in boost C++ for a function with multiple arguments

I have below function in C++ #include #include #include #include double my_fn(double x, double y) { return x*x - y - 1; }; int main() { double min_x = 0.0; // min value of domain…
Bogaso
  • 2,838
  • 3
  • 24
  • 54
2
votes
0 answers

Why do I need to use another variable called update balance?

I'm creating a program that finds the lowest minimum payment necessary to pay of bank balance that that has interest. Given the initial balance and the annualInterestRate, I need to use a bisection search to find the lowest monthly payment to pay…
ZeOnlyOne
  • 179
  • 1
  • 9
2
votes
0 answers

Expand limits in root finding scipy.optimize (bisection or brentq)

I want to find a root of a function. I know that the root exists but not where it can be on the real line, so if I give some upper and lower bound to scipy.optimize.brentq it is likely that there is no change in signs. Is there any nice way to…
2
votes
1 answer

Bisect with discontinuous monotonous function: Find root using bisection for weakly monotonous function allowing for jumps

I'm looking for a Python algorithm to find the root of a function f(x) using bisection, equivalent to scipy.optimize.bisect, but allowing for discontinuities (jumps) in f. The function f is weakly monotonous. It would be nice but not necessary for…
FlorianH
  • 600
  • 7
  • 18
2
votes
0 answers

ground state energy of a wavefcn with bisection method

I am looking for the ground state energy of the wavefcn that can fit in a given potential: import numpy as np import matplotlib.pyplot as plt import math ximin=-8 ximax=-ximin Nsteps=1001 nu0=4.0 psi = np.linspace(ximin,ximax,Nsteps) h = psi[1] -…
2
votes
1 answer

Bisecting an array of objects: are not all of them enumerated?

This is my bisector: var bisectDate = d3.bisector(function(d: any) { console.log('d date ', d.date); return d.date; }).left; I have array of dates(78 total) but on my bisector it's only logging 5 like below repeatedly? timesDataPath …
gpbaculio
  • 5,693
  • 13
  • 60
  • 102
2
votes
2 answers

Infinite loop when trying to find cube root of a non-perfect cube through bisection search

This code gives pretty accurate result when deltanum = 0.0000000000001 but gets into an infinite loop when deltanum = 0.00000000000001(adding another zero into deltanum). It occurs only for non-perfect cubes, it works fine for perfect cubes like…
g2k
  • 23
  • 4
2
votes
2 answers

Speed comparison between bisect.insort function and list.index and insert function

As Python doc says, I have thought that bisect module is much faster than list built-in method, index and insert to insert item to long ordered list. So, I simply measure the time expense for both functions, bisect_func() and insert_func() like…
namwoo
  • 89
  • 5
2
votes
1 answer

How can user input function in C#

I have made bisection method program in C# Console Application. Bisection method works, but for function which is already written in the code. I want to edit program that user can input function which they want to use for bisection method. For…
2
votes
1 answer

Two-dimensional bisection method in Python?

I am looking for an extension of the optimize.bisect function in Python, some code that allows me to solve a system of two couple self-consistent equations, i.e. y= f(x,y) and x= g(x,y). I was looking for a kind of two dimensional bisection method,…
2
votes
1 answer

Problems finding a number's square root with bisection method

#include #include using namespace std; double bisection(double errorVal, double userNum){ double upper=userNum, lower=0; double mid=(lower+upper)/2.0;; while(mid*mid!=userNum){ double mid=(lower+upper)/2.0; …
2
votes
1 answer

How would I implement root-finding when all I have is a set of points?

I have some code that outputs two arrays that contain x-values and y-values. I now need to root-find using these points, but is this possible without knowing the function? How does one implement, say, the bisection method using only a set of (x, y)…
loltospoon
  • 239
  • 1
  • 9
2
votes
2 answers

Python Bisection Number Guessing Game

I am trying to write a simple bisection method question and it works perfectly fine as long as I don't have a certain conditional statement which I have commented out. What is the reason for this? This is not a homework question. low = 0 high = 100…
Adam Warner
  • 1,334
  • 2
  • 14
  • 30
2
votes
2 answers

Why does an iterative approximation algorithm sometime have fewer iterations despite larger input values?

Why does my iterative approximation loop get executed fewer times when executed for 24690 than 12345 which is half the size? I am using a bisection algorithm or bisecting search. Please help me.
Akshat Patni
  • 161
  • 1
  • 4
  • 10
2
votes
1 answer

d3.bisector using Date() Object does not resolve

Demo jsFiddle I have a basic d3 line graph, using a simple JSON array of UNIX timestamp and float value data, e.g: "value": 10.04,"time": 1401185375354 [...] This timestamp (time) data is converted into a Date() object before the graph is generated.…
SW4
  • 69,876
  • 20
  • 132
  • 137
1 2
3
17 18