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.
Comments
Post a Comment