math - How do I use accurate float arithmetic in Python? -


i'm having issue in python float arithmetic. equation i'm solving goes follows:

-a *((x-m)*110.0*(1-m))**b +a*((x-m)*110.0*(1-m))**c large positive number (in hundred thousands) b 1.0000002 c 0.9999998 

when in excel accurate results when in python inaccurate results.

the results same each separate part until multiply -a , a. ((x-m)110.0(1-m))**b , ((x-m)110.0(1-m))**c same excel calculated values when they're multiplied large number change.

how do this? have use different language? problem in python or in languages?

edit: exact same equation in excel in python. same. numbers same until multiply , -a. both off 5 point something. answer in excel around 0.47 x=0.5 , m = 0.265 while answer python around -0.67

mpmath can answer

mpmath pure-python library multiprecision floating-point arithmetic. provides extensive set of transcendental functions, unlimited exponent sizes, complex numbers, interval arithmetic, numerical integration , differentiation, root-finding, linear algebra, , more.

http://code.google.com/p/mpmath/


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -