All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Evaluate x (Posted on 2023-02-25) Difficulty: 3 of 5
For what value of x will the equation

x^5-x=111 .
be true?

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Numeric method, function for generic polynomial | Comment 2 of 4 |
I didn't already have a function to find roots of any polynomial, so I wrote one.  It uses Newton's method.  It's arguments are a list of coefficients, a lower bound and an upper bound on the range where to look for the zero.
It prints out:  2.5766641903207894

------
def findzero(poly,lo,hi):
    """ poly is a list of coefficients of a polynomial and lo and hi are limits
    on where to look for a zero of the function  
    e.g poly = [1,4,3,6] means x^3 + 4x^2 + 3x + 6  
    Use Newton-Raphson method   """
    revPoly = poly[::-1]
    guess = lo
    revDeriv = []
    for i,v in enumerate(revPoly):
        if i == 0:
            continue
        revDeriv.append(i*v)
    def f(x):
        ans = 0
        for i,v in enumerate(revPoly):
            ans += v*x**i
        return ans
    def fPrime(x):
        ans = 0
        for i,v in enumerate(revDeriv):
            ans += v*x**i
        return ans
    finished = False
    while not finished:
        error = abs(f(guess)/fPrime(guess))
        guess = guess - f(guess)/fPrime(guess)
        if error < 10** -10:
            finished = True
    return guess


poly1 = [1,0,0,0,-1,-111]
print(findzero(poly1,2,3))

  Posted by Larry on 2023-02-25 08:24:58
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information