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 8865625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:33:36+00:00 2026-06-14T16:33:36+00:00

below is my program for finding approximate root for a some 5000th-degree polynomial that

  • 0

below is my program for finding approximate root for a some 5000th-degree polynomial that is given as a series:

def s(r, z):
    sm = 0
    for k in range(1, z+1):
        sm += (900-3*k) * r ** (k-1)
    return sm

target = -600000000000

n = 1
dr = .125
curr = 0
while abs(curr - target) > 1:
    curr = s(n, 5000)
    if curr > target : n+= dr
    else : n-=dr
    dr /= 2

I wanted it rounded to 12 digits behind decimal point, hence

print round(n, 12)

which gave me :

1.00232210863

number is approximate enough, but it is now rounded to 12 digits. I fired up python console and found it myself :

>>> n
1.0023221086328755
>>> round(n, 12)
1.002322108633

Why is my round() function working only inside python console prompt?

  • 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-14T16:33:38+00:00Added an answer on June 14, 2026 at 4:33 pm

    By deafault python’s print rounds numbers to 11 digits when printing.
    Try instead

    print '%0.12f'%n
    

    To be a little more clear, when you are in the interactive console and do:

    >>> x = 1.123456789012345
    >>> x
    1.123456789012345
    >>> print x
    1.12345678901
    

    Remember that the the first call is actually a call to

    x.__repr__() 
    

    which will print as much information about x as it can, while the print statement translates to

    print x.__str__()
    

    and the builting str() method on ints rounds to 11 digits if necessary. You can force as many digits as you like using python’s % formatting as shown above.

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

Sidebar

Related Questions

The program below is finding prime numbers in a given range. for the noprimes
I have the below program that will move files from one directory to other.
I am trying to write a program to check that some C source code
In the below program, as far as in my knowledge once we allocate some
I am looking for some brief explanations on how the below program or code
Below program contains two show() functions in parent and child classes, but first show()
The below program calculates 2 raised to the power n without using any loop,runtime
In the below program,i am not getting values from printf . #include<stdio.h> int main()
In this below program i am printing the contents of the div when i
I have a Enumeration as shown in below program public class Test { public

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.