# Arbitrary precision
Typically numerical optimization is performed using binary 64 bit IEEE 754 floating point numbers (becuase modern processors offer good performance/precision characteristics for this data type). By using a math library which supports arbitrary precision we can achive higher precision (larger number of significant digits). By using ``pyneqsys`` we only need to write our equations once. We will be using [mpmath](http://www.mpmath.org) as our backend library for arbitrary precision. 


```python
import sympy as sp
from pyneqsys.symbolic import SymbolicSys
sp.init_printing()
```


```python
def f(x):
    return [x[0]**2 + x[1],
            5*x[0]**2 - 3*x[0] + 2*x[1] - 3]

neqsys = SymbolicSys.from_callback(f, 2)
neqsys.exprs
```

Let us now find the roots for this system numerically, if we read the documentation of that library we will see that they recommend that the starting guess is obtained using a conventional solver.

So we will do just that: we will first solve the problem using SciPy's default solver and then we will perform a "refinement" by solving it using ``mpmath``'s solver


```python
x, sol = neqsys.solve([100, 100])
sol, f(sol['x'])
```


```python
mp_neqsys = SymbolicSys.from_callback(f, 2, module='mpmath')
mp_x, mp_sol = mp_neqsys.solve(x, solver='mpmath', dps=50)
mp_sol, f(mp_sol['x'])
```

So that gave us, as requested, close to 50 significant digits‒nifty!

28782980d0347e29ae33907370259e0119cf2221
ipynb
Jupyter Notebook
examples/multiprecision.ipynb
bjodah/pyneqsys
1e8b63ee6e820d33a87b95c057655df03e1e4fc6
BSD-2-Clause
2015-11-12T09:18:36.000Z
2022-03-16T23:25:03.000Z
examples/multiprecision.ipynb
bjodah/pyneqsys
1e8b63ee6e820d33a87b95c057655df03e1e4fc6
BSD-2-Clause
2016-01-01T22:37:28.000Z
2018-08-15T11:17:48.000Z
examples/multiprecision.ipynb
bjodah/pyneqsys
1e8b63ee6e820d33a87b95c057655df03e1e4fc6
BSD-2-Clause
2018-01-17T02:53:21.000Z
2021-02-02T22:52:56.000Z
Qwen/Qwen-72B
1. YES
2. YES