# numpy/scipy polyfit precision

I am trying to use numpy to perform a polyfit on a set of very large integers (~256bits).  The points for the line are generated by randomly assigning coefficients and then picking X values at random.  I then try to use numpy to recreate the polynomial from just those points, but the answer is not exact.  It is usually off by less than 10, but it shouldn't be.  Is there a way to turn up the precision for numpy?  matlab is able to crunch these numbers and come up with the exact polynomial, so I would expect numpy to be able to do the same.
LVL 6
###### Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
As far as I know numpy does not support higher than double precision (float64).

Maybe mpmath can be useful for you.
They support real and complex numbers with arbitrary precision.

EDIT:

Forgot to mention there is also mlabwrap which gives you all of Matlab`s functionality in python.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Thanks for pointing out mpmath, it looks promising.

This was a small piece of a larger project, and fitting a polynomial ended up being only one method to get the answer we needed.  So we switched algorithms, so I wont be able to verify any other answers to this question.

the mention of mpmath and mlabwrap is enough to award points I think.
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.