Thanks Oscar, Aaron and everyone! I have a few questions to ask, but first
wanted to
say this entire thread has been so meaningful as a learning process for me!
I am an intermediate VB programmer and newbie to python and this single
thread you have
all been so gracefully collaborating together on has taught me more and
helped me to understand
the issues surrounding this than any other source online I have researched
and I am saving this
entire thread for future use and review!
Back to the problem, I have been trying to keep pace with all the excellent
insights and suggestions
as well as potential bottlenecks.
I have been testing out some of the code ideas such as ;
from sympy import mpmath
mpmath.mp.dps = 821
x = mpmath.mpf('1.414213562') ** 6000
But have also been reviewing the problems with the different approaches,
including precision loss
with use of floats, some of the suggested functions, etc.
My hope is to arrive at a method that returns lossless precision, if I dont
have to sacrifice speed then
thats great but if preserving accuracy comes at a cost of speed thats ok
with me.
I'd like also to get the highest precision available, if possible past the
15 digit limit, the larger the better.
Oscar mentioned the solution of using a string value and storing it as a
possibility?
After the collaboration above, what do you guys think is the best code
solution for ;
given any rational between 1.0x and 2, for example "1.414213562"
being raised to a power as high as 6000
with modulus returned of 400
( 1.414213562^6000) % 400) ?
So that the greatest and most accurate precision is kept?
On Monday, April 4, 2016 at 6:59:25 PM UTC-6, Amy Valhausen wrote:
>
> Sympy vs Numpy, better accuracy in precision?
>
> I've been trying to solve a problem with numpy and other code routines
> to raise a base to a large power and then take the modulus.
>
> Precision accuracy is very important, speed isnt as much - although it
> would
> be convenient if I didnt have to wait a long long time for processing.
>
> Constraints Im under is that Im working on a winxp system, Im using
> python 3.4 and numpy version 1.1.
>
> When using numpy Ive been using the code lines;
>
> import numpy
> (np.longdouble(1.4142)** 6000 )%400
>
> I am not sure how accurate the result is, and I have tried using other
> methods too
> but recently I found a post comparing sympy to numpy and it seems someone
> is claiming that sympy can return superior precision results, can anyone
> confirm
> that this is true and do you know if this would be a good solution to run
> on my system?
>
> Link with info comparing the below is shown ;
>
>
> http://stackoverflow.com/questions/25181642/how-set-numpy-floating-point-accuracy
>
> In normal numpy use, the numbers are double. Which means that the accuracy
> will be less than 16 digits. Here is a solved subject that contains the
> same problematic ...
>
> If you need to increase the accuracy, you can use symbolic computation
> .... The library mpmath ... is a quiet good one. The advantage is that you
> can use limitless precision. However, calculations are slower than what
> numpy can do.
>
> Here is an example:
>
> # The library mpmath is a good solution
> >>> import sympy as smp
> >>> mp = smp.mpmath
>
> >>> mp.mp.dps = 50 # Computation precision is 50 digits
> # Notice that the difference between x and y is in the digit before last
> (47th)
> >>> x =
> smp.mpmath.mpf("0.910221324013388510820732335560023784637451171875")
> >>> y =
> smp.mpmath.mpf("0.910221324013388510820732335560023784637451171865")
> >>> x - y # Must be equal to 1e-47 as the difference is on the 47th digit
> mpf('1.000014916280995001003481719184726944958705912691304e-47')
>
> You can't do better with numpy. You can calculate exponentials with a
> better accuracy.
>
> smp.exp(x).evalf(20) = 2.4848724344693696167
>
>
> http://stackoverflow.com/questions/25181642/how-set-numpy-floating-point-accuracy
>
> https://github.com/sympy/sympy/releases
> http://docs.sympy.org/latest/index.html
>
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/7c1ee612-19d7-4fd1-a65b-31ceba165c41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.