symengine.R icon indicating copy to clipboard operation
symengine.R copied to clipboard

solving returns VecBasic of length 0

Open levibaguley opened this issue 4 years ago • 2 comments

I would've put this one on StackOverflow but this package seems pretty new so I thought asking you guys would be the best. I'm trying to solve a function that looks something like this:

P == 1 / (1 + exp(-(b0 + b1 * r + b2 * t)))

It's a logistic function but I want it in terms of r. This is my attempt.

library(symengine)
#> SymEngine Version: 0.4.1
#>  _____           _____         _         
#> |   __|_ _ _____|   __|___ ___|_|___ ___ 
#> |__   | | |     |   __|   | . | |   | -_|
#> |_____|_  |_|_|_|_____|_|_|_  |_|_|_|___|
#>       |___|               |___|

use_vars(b0, b1, b2, P, t, r)
#> Initializing 'b0', 'b1', 'b2', 'P', 't', 'r'
exp <- 1L / (1L + exp(-(b0 + b1 * r + b2 * t))) - P
exp
#> (Add)    -P + (1 + exp(-(b0 + r*b1 + t*b2)))^(-1)
solve(exp, r)
#> VecBasic of length 0
#> V(  )

Is symengine unable to solve this? It isn't clear what VecBasic of length 0 means. When do you think non-polynomials will be able to be solved in this package?

R version 3.6.3 (2020-02-29) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18363)

levibaguley avatar May 15 '20 02:05 levibaguley

Thanks for reporting. Yes currently only polynomials can be solved with this package and it's a bug that it should raise an error instead of returning an empty VecBasic.

There is ongoing effort to integrate SymPy with the package so it could provide a generic solver (hopefully be available soon). But that would require additional setup.

By the way, are you using symengine on Windows?

Marlin-Na avatar May 15 '20 03:05 Marlin-Na

Yes, see edits.

levibaguley avatar May 15 '20 14:05 levibaguley