'Solving multiple equations using R's caracas package

I have multiple equations that I want to solve using caracas. I define my equations using sympy$Eq, then try to solve the equations using sympy$solve. But this gives me an error.

Here is a reproducible example:

library(caracas)
sympy <- get_sympy()

a <- symbol('a')
b <- symbol('b')
c <- symbol('c')
d <- symbol('d')
e <- symbol('e')

mySymbols = c(a,b,c,d,e)

mx = c + d + e
lx = a + b - 3*c - d + e
tx = -a - d - 3*e

fx = sympy$Eq(mx, 1)
gx = sympy$Eq(lx, 1)
hx = sympy$Eq(tx, -2)

sympy$solve(c(fx,gx,hx), mySymbols)

Error in py_call_impl(callable, dots$args, dots$keywords) : 
  TypeError: unhashable type: 'list'

Detailed traceback:
  File "/Users/selcukkorkmaz/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/sympy/solvers/solvers.py", line 849, in solve
    f, symbols = (_sympified_list(w) for w in [f, symbols])
  File "/Users/selcukkorkmaz/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/sympy/solvers/solvers.py", line 849, in <genexpr>
    f, symbols = (_sympified_list(w) for w in [f, symbols])
  File "/Users/selcukkorkmaz/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/sympy/solvers/solvers.py", line 840, in _sympified_list
    return list(map(sympify, w if iterable(w) else [w]))
  File "/Users/selcukkorkmaz/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/sympy/core/sympify.py", line 362, in sympify
    return conv(a)
  File "/Users/selcukkorkmaz/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/sympy/core/containers.py", line 309, in <lambda>
    converter[dic

I also tried to use solve_sys, but this also gives me an error:

solve_sys(c(fx,gx,hx), mySymbols)

Error in py_call_impl(callable, dots$args, dots$keywords) : 
  AttributeError: 'NoneType' object has no attribute 'is_Relational'

Detailed traceback:
  File "/Users/selcukkorkmaz/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/sympy/solvers/solvers.py", line 910, in solve
    if fi.is_Relational:

I tried the same example using the sympy library in python and the correct solution is as follows:

  a =  -d - 3*e + 2
  b =  -d - e + 2
  c =  -d - e + 1

I would appreciate any help. Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source