Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9159681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:33:15+00:00 2026-06-17T13:33:15+00:00

I want to make a Python program that will run a bisection method to

  • 0

I want to make a Python program that will run a bisection method to determine the root of:

f(x) = -26 + 85x - 91x2 +44x3 -8x4 + x5

The Bisection method is a numerical method for estimating the roots of a polynomial f(x).

Are there any available pseudocode, algorithms or libraries I could use to tell me the answer?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:33:16+00:00Added an answer on June 17, 2026 at 1:33 pm

    Basic Technique

    Here’s some code showing the basic technique:

    >>> def samesign(a, b):
            return a * b > 0
    
    >>> def bisect(func, low, high):
        'Find root of continuous function where f(low) and f(high) have opposite signs'
    
        assert not samesign(func(low), func(high))
    
        for i in range(54):
            midpoint = (low + high) / 2.0
            if samesign(func(low), func(midpoint)):
                low = midpoint
            else:
                high = midpoint
    
        return midpoint
    
    >>> def f(x):
            return -26 + 85*x - 91*x**2 +44*x**3 -8*x**4 + x**5
    
    >>> x = bisect(f, 0, 1)
    >>> print(x, f(x))
    0.557025516287 3.74700270811e-16
    

    Tolerance

    To exit early when a given tolerance is achieved, add a test at the end of the loop:

    def bisect(func, low, high, tolerance=None):
        assert not samesign(func(low), func(high))   
        for i in range(54):
            midpoint = (low + high) / 2.0
            if samesign(func(low), func(midpoint)):
                low = midpoint
            else:
                high = midpoint
            if tolerance is not None and abs(high - low) < tolerance:
                break   
        return midpoint
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a Python code that will open a program like cmd
I want to make a program in Python that can take video input from
I want to make a python program to run through a string in python:
I want to make a python program that uses PLY to parse Javascript files,
I'm trying to write a program that will take an HTML file and make
I'm trying to make a Python program that interfaces with a different crashy process
I'm trying to make a Python program that retrieves only the body text of
I want to write a background program that will monitor the _changes feed of
I want to make a program in python using pygtk, which would execute my
I have an idea for a simple program to make that will help me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.