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

  • Home
  • SEARCH
  • 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 8670747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:46:50+00:00 2026-06-12T18:46:50+00:00

I am trying to implement a root finding algorithm. I am using the hybrid

  • 0

I am trying to implement a root finding algorithm. I am using the hybrid Newton-Raphson algorithm found in numerical recipes that works pretty nicely. But I have a problem in bracketing the root.

While implementing the root finding algorithm I realised that in several cases my functions have 1 real root and all the other imaginary (several of them, usually 6 or 9). The only root I am interested is in the real one so the problem is not there. The thing is that the function approaches the root like a cubic function, touching with the point the y=0 axis…

Newton-Rapson method needs some brackets of different sign and all the bracketing methods I found don’t work for this specific case.

What can I do? It is pretty important to find that root in my program…

EDIT: more problems: sometimes due to reaaaaaally small numerical errors, say a variation of 1e-6 in some value the "cubic" function does NOT have that real root, it is just imaginary with a neglectable imaginary part… (checked with matlab)

EDIT 2: Much more information about the problem.

Ok, I need root finding algorithm.

Info I have:

  • The root I need to find is between [0-1] , if there are more roots outside that part I am not interested in them.
  • The root is real, there may be imaginary roots, but I don’t want them.
  • Probably all the rest of the roots will be imaginary
  • The root may be double in that point, but I think that actually doesn’t mater in numerical analysis problems
  • I need to use the root finding algorithm several times during the overall calculations, but the function will always be a polynomial
  • In one of the particular cases of the root finding, my polynomial will be similar to a quadratic function that touches Y=0 with the point. Example of a real case:
    enter image description here
  • The coefficient may not be 100% precise and that really slight imprecision may make the function not to touch the Y=0 axis.
  • I cannot solve for this specific case because in other cases it may be that the polynomial is pretty normal and doesn’t make any "strange" thing.
  • The method I am actually using is NewtonRaphson hybrid, where if the derivative is really small it makes a bisection instead of NewRaph (found in numerical recipes).

Matlab’s answer to the function on the image:
roots:

0.853553390593276 + 0.353553390593278i
0.853553390593276 - 0.353553390593278i
0.146446609406726 + 0.353553390593273i
0.146446609406726 - 0.353553390593273i
0.499999999999996 + 0.000000040142134i
0.499999999999996 - 0.000000040142134i

The function is a real example I prepared where I know that the answer I want is 0.5

Note:
I still haven’t check completely some of the answers I you people have give me (Thank you!), I am just trying to give al the information I already have to complete the question.

  • 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-12T18:46:51+00:00Added an answer on June 12, 2026 at 6:46 pm

    Ander, thanks for responding to my question (about the interval); sorry for the delay in following up – I have very busy work. Also – before I found the additional information you’ve provided – I had in mind to explain quite a few things how to handle this and was contemplating how to present that. However, I now believe your case is not too difficult and we can get at it without too much additional stuff, since you apparently have an explicit polynomial expression (coefficients to the various powers).

    Let’s start with a simple case, to pinpoint the approach.

    Step 1.
    If you have a 2nd degree polynomial, its derivative is first order and has a simple zero (which you can find by bracketing or simply by explicitly solving the equation). (Yes, I know there’s a closed formula for the roots of a 2nd degree polynomial also, but for the sake of the current argument, let us forget that).
    The zero’s of the 2nd degree polynomial are then located one at the left side and one at the right side of the zero of the derivative. So, if you also have the interval where the roots of the original function (the 2nd degree polynomial) are to be found, you now have two intervals – left and right of the derivative-zero, each with one zero.

    It is important to realize that the original function is MONOTONIC on each subinterval (decreasing on one of them, increasing on the other). Therefore, simply by checking the function values at the ends of the (sub)interval you can determine whether or not they actually bracket a zero. If not, there’s a multiple zero (double, in this case) exactly at the zero of the derivative IF the function is zero there (otherwise, it is a double imaginary root of which you’ve now found the real part).

    In case the zero of the derivative lies OUTSIDE the total interval, you will have at most one root inside your interval and you need to check only that particular (sub)interval.

    Step 2.
    Consider now a 3rd order polynomial.
    Its derivative is 2nd order.
    The derivative of THAT 2nd order polynomial is again 1st order and you proceed as before to get two subintervals to find the roots of the derivative of the original function. These two roots give you THREE (at most) intervals where you will find the 3 roots of the original (3rd order) function.
    And also here, you will have intervals (3) where the original function is monotonic (alternatingly increasing/decreasing), making the analysis per subinterval quite easy.

    Again, zeros may coincide (2 or even all 3) and may in addition turn out to be complex-valued (i.e. having non-zero imaginary parts). The analysis of the cases is straightforward: check function values at the borders of the intervals to assess whether not there’s a sign-change (function is monotonic on each subinterval) and/or whether the function is zero at one of the subinterval-borders.

    Step 4.
    Generalize this with the known polynomial. Let’s say – your example – it is 6th order:

    a) construct the 5th derivative (i.e. reducing the original to a 1st order polynomial). Compute it’s zero (it is at precisely 0.5 in your example). In this case you’re already done, but suppose you don’t realize that. So you have now 2 intervals 0..0.5 and 0.5..1

    b) construct the 4th derivative. Inspect its values at the subinterval-boundaries (0, 0.5, 1)
    For each subinterval determine if it has a real zero inside. If so, you re-partition your original interval in 3 subintervals, using the two found zeros (you forget about the zero of the 5th derivative). If they coincide (at the previous cut, 0.5) you stick with that 0.5 (don’t care whether you’ve found a true double zero of your 4th derivative there or a “double imaginary”) and still have only 2 intervals, but for the sake of the argument let’s say you now have 3.

    c) construct the 3rd derivative and do likewise as before. You will then have 4 (at most) intervals.

    d) And so on. After having processed the 2nd derivative in this fashion you have 5 (at most) intervals, and after processing the 1st derivative you have 6 intervals (or less…) and knowing the function is monotonic on each subinterval, you’ll quickly determine in each of them if there’s a real root, as always using the know monotonicity of the function in each of the final subintervals.

    Adding a note on numerical accuracy at evaluating a function:
    A first (probably sufficient, in this case) method to reduce noise is NOT to evaluate your function in the way suggested by the original form (i.e. a6 x*6 + a5 x*5 +..), but to rewrite it as:

    a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*a6)))))

    So, in evaluating you proceed:

    tmp = a6

    tmp = x*tmp + a5

    tmp = x*tmp + a4

    etcetera.

    In case this little rewriting is not sufficient for numerical stability, you should rewrite your polynomial in (for instance) a chebyshev-polynomial expansion and evaluate that one with its recurrence relations. Both (getting the expansion and applying the recurrence relations for evaluation) are rather simple. I can explain, if you need help, but I guess it won’t be necessary here.

    In all cases, you HAVE to allow for some inaccuracy, i.e. accept that a computation will, generally speaking, NEVER give you the mathematically exact function value. So the assessment whether the function is presumably zero at some point must include some “tolerance”, there’s no way around this, unfortunately; the best you can aim for is to minimize the noise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement BST algorithm using Cormen's pseudo code yet having issue.
I'm trying to implement clickable areas on the root window, using python xlib's RECORD
I'm trying implement A* Start path finding in my games(which are written with JavaScript,
Problem statement I'm trying to implement my own virtual keyboard following example softkeyboard, found
I'm trying to implement a HashMap-based tree that'd support O(1) subtree lookup for a
Guys I'm trying to implement deletion algorithm for a Red Black tree and I'm
I'm trying to implement REST API using Jersey with Spring on Tomcat but I'm
I'm trying to implement autoloading in Php5.3 using namespaces but I'm having some issues
I am trying to implement recoemmender code in java dynamic web application using direct
I'm trying to implement a Login with Facebook using the Open Graph API. So

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.