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
-1
votes
1 answer

Struggling with recursive code to bisection search a string

So I'm taking a python class online. I would like help spotting the differences between my code and the correct answer code. I didn't annotate mine but the answer is annotated and every thing you need should be there to figure out what I'm trying to…
Jk128711
  • 13
  • 2
-1
votes
1 answer

Expected primary-expression before ‘]’ token(bisection search)

Where have I gone wrong in this? When I compile this ~ bs_01.cpp: In function ‘int main()’: bs_01.cpp:29:25: error: expected primary-expression before ‘]’ token cout << bisection_01(foo[]); #include"std_lib_facilities.h" using namespace…
tomriddle99
  • 105
  • 2
-1
votes
1 answer

Bisection_method in array - numpy

I have an equation where my unknown is h and TR which is an array (2D). I would like to solve the equation below by bisect method and as a result get a new array(2D), which will represent my h Tpow,k,t - constant h = np.empty_like(TR) def f(h): …
Duraa
  • 35
  • 1
  • 6
-1
votes
4 answers

what is wrong here?

I am trying to make a guessing game in python using bisection search. my code goes like this. print('please think of a number between 1 and 100') high=100 low=1 guess=int((high+low)/2) n=input('is your number 50? press y to yes, l to low, h to high…
-1
votes
1 answer

Bisection Method: evaluate a polynomial function

I am implementing the bisection method, and as a first step I need to evaluate the polynomial function, but I do not get the correct result. The polynomial used is 3(x^2)+7(x)+1 with x=2, the result should be 27 public static double evaluaFx(int…
Frank R
  • 1
  • 1
-1
votes
1 answer

How to use in-built bisect to find the index of an item in a list

D = [(20832049, "hello", 3), (2042449014, "bye", 2), (208414004814, "cya", 3) I want to make a function with the arguments: (key, D, hash) where key represents the element at index[1] at each tuple, D is the dictionary example I gave, and hash is…
ayy doe
  • 41
  • 1
  • 3
-1
votes
1 answer

Bisection search code doesnt work

Could you explain where i'm going wrong with this code? I want to do a bisection search which takes input number and repeats bisection search until it finds the same number as input and prints out various statements. num =int( input("Please think of…
LeafTeaNeko
  • 67
  • 1
  • 9
-1
votes
1 answer

Calling a bisection method root finiding function and calingit to solve any function in python

I have written a general bisection method to find roots of the provided function, I want to call it to solve a quadratic function. here's my generalroot.py # generalroot.py # determines the root of any general function def root_bisection(f, a, b,…
bhjghjh
  • 819
  • 1
  • 13
  • 32
-1
votes
1 answer

C++ while loop using bisection method. Help on break

I need some help here. Please excuse the complexity of the code. Basically, I am looking to use the bisection method to find a value "Theta" and each i increment. I know that all the calculations work fine when I know the Theta, and I have the code…
Fitzy
  • 103
  • 2
  • 9
-1
votes
1 answer

Plot loop bisection method matlab

I have the next script in Matlab it's the bisection method function root = biseccion(f,a,b,epsilon, max) if (f(a)*f(b) >= 0) disp('f(a) *f(b) >= 0'); root = 'Can't find the root'; return; else …
Edgar Pisxid
  • 69
  • 1
  • 10
-1
votes
1 answer

Root of polynomial using bisection

I'm new to python and i'm having a hard time trying to find the root of a polynomial via using the bisection method. So far I have 2 methods. One for evaluating the polynomial at value x def eval(x, poly): """ Evaluate the polynomial at the value…
dabrams493
  • 61
  • 5
-1
votes
2 answers

What's the root and what's the useful of finding the root in algorithms like bisection?

I already solved a bisection algorithm using C++ as a language, I think the main purpose is to find the root. I understood the whole algorithm, but I didn't understand what the root will do or what will be the the purpose of root if we find it.
Caffe Latte
  • 1,577
  • 1
  • 12
  • 31
-1
votes
1 answer

Writing values to sheet after each iteration

This code is an iterative solver. How do I write out key values onto an Excel spreadsheet after each iteration? e.g. the iteration number, the Xl, Xu, Xmid, and the error of each iteration. Option Explicit Public Function srkEquation(Temperature,…
-1
votes
3 answers

Bisection Search on the Lowest Payment on Credit Card Debt: Answers are always way off

My code: balance = 320000 annualInterestRate = 0.2 originalBalance = balance month = 1 monthly_interest = annualInterestRate / 12 low = originalBalance/12 high = (originalBalance*(1 + monthly_interest)**12)/12 epsilon = 0.01 min_payment = (high +…
user2066771
  • 133
  • 2
  • 4
  • 11
-2
votes
1 answer

Can someone explain to me why doesn't this piece of code work?

annual_salary = int(input("Your annual salary ")) semi_annual_raise = 0.07 r = 0.04 down_payment = 250000 epsilon = 100 low = 0 high = 10000 guess = (high + low)//2 best_saving_rate = (guess/10000) months = 0 current_savings = 0 steps = 0 while…
bassam ch
  • 1
  • 3
1 2 3
15
16