Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numerical solve system of equations type error #26344

Open
satels opened this issue Mar 10, 2024 · 1 comment
Open

Numerical solve system of equations type error #26344

satels opened this issue Mar 10, 2024 · 1 comment

Comments

@satels
Copy link
Contributor

satels commented Mar 10, 2024

from sympy.abc import x, y
from sympy import nsolve, Eq
equations = [Eq((x - 6)*(y - 5), 0), Eq((y - 2)/(x + y - 8), 3)]
vars = [y, x]
start_points = (-10, 6)
nsolve(equations, vars, start_points, modules=['mpmath', 'sympy'])

The error:

Traceback (most recent call last):
    nsolve(equations, vars, start_points, modules=['mpmath', 'sympy'])
  File "sympy/utilities/decorator.py", line 87, in func_wrapper
    return func(*args, **kwargs)
  File "sympy/solvers/solvers.py", line 3065, in nsolve
    x = findroot(f, x0, J=J, **kwargs)
  File "mpmath/calculus/optimization.py", line 969, in findroot
    for x, error in iterations:
  File "mpmath/calculus/optimization.py", line 660, in __iter__
    s = self.ctx.lu_solve(Jx, fxn)
  File "mpmath/matrices/linalg.py", line 224, in lu_solve
    A, p = ctx.LU_decomp(A)
  File "mpmath/matrices/linalg.py", line 140, in LU_decomp
    ctx.swap_row(A, j, p[j])
  File "mpmath/matrices/matrices.py", line 880, in swap_row
    A[i,k], A[j,k] = A[j,k], A[i,k]
  File "mpmath/matrices/matrices.py", line 490, in __getitem__
    if key[0] >= self.__rows or key[1] >= self.__cols:
TypeError: '>=' not supported between instances of 'NoneType' and 'int'
...
nsolve(equations, vars, start_points, modules=['sympy'])
Traceback (most recent call last):
  nsolve(equations, vars, start_points, modules=['sympy'])
  File "sympy/utilities/decorator.py", line 87, in func_wrapper
    return func(*args, **kwargs)
  File "sympy/solvers/solvers.py", line 3065, in nsolve
    x = findroot(f, x0, J=J, **kwargs)
  File "mpmath/calculus/optimization.py", line 969, in findroot
    for x, error in iterations:
  File "mpmath/calculus/optimization.py", line 91, in __iter__
    f0 = f(x0)
TypeError: _lambdifygenerated() missing 1 required positional argument: 'x'
...
nsolve(equations, vars, start_points, modules=['numpy'])
Traceback (most recent call last):
  nsolve(equations, vars, start_points, modules=['numpy'])
  File "sympy/utilities/decorator.py", line 87, in func_wrapper
    return func(*args, **kwargs)
  File "sympy/solvers/solvers.py", line 3065, in nsolve
    x = findroot(f, x0, J=J, **kwargs)
  File "mpmath/calculus/optimization.py", line 956, in findroot
    if norm(fx) == 0:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
@Rohanberiwal
Copy link

Rohanberiwal commented Mar 13, 2024

I hope this message finds you well.
I'm reaching out regarding the code we've been working on for solving nonlinear systems of equations. I wanted to inquire if it's mandatory to use the nsolve function from SymPy for this purpose ?

Thanks and warm regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants