clojure-numerics / expresso

Clojure library for symbolic computation
314 stars 20 forks source link

Variable order is vital #9

Closed LittleHelicase closed 10 years ago

LittleHelicase commented 10 years ago

Hi,

I just encountered a problem regarding the ordering of variables when solving for multiple values. Here is a small example:

user=> (solve ['s 'm] 
              (ex (= m (/ t x)))
              (ex (= s (/ m 3)))
              (ex (= t 5))
              (ex (= x 3)))
#{{s 5/9, m 5/3}}
user=> (solve ['m 's]
              (ex (= m (/ t x)))
              (ex (= s (/ m 3)))
              (ex (= t 5))
              (ex (= x 3)))

IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol  clojure.lang.RT.seqFrom (RT.java:505)

The list of equations is exactly the same for both calls only the order of m and s is different.

mschuene commented 10 years ago

Hi, I hope I can look into this this weekend but I am not sure I will manage it. You could look at the expresso.solve namespace and call the more specialized functions from there (for example the solve-linear-system if your equations can be rewritten to a matrix equation Ax=b)

On Thu, Jun 19, 2014 at 7:11 PM, Maximilian Klein notifications@github.com wrote:

Hi,

I just encountered a problem regarding the ordering of variables when solving for multiple values. Here is a small example:

user=> (solve ['s 'm](ex %28= m %28/ t x%29%29) (ex (= s (/ m 3))) (ex (= t 5)) (ex (= x 3)))

{{s 5/9, m 5/3}}

user=> (solve ['m 's](ex %28= m %28/ t x%29%29) (ex (= s (/ m 3))) (ex (= t 5)) (ex (= x 3)))

IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol clojure.lang.RT.seqFrom (RT.java:505)

The list of equations is exactly the same for both calls only the order of m and s is different.

— Reply to this email directly or view it on GitHub https://github.com/clojure-numerics/expresso/issues/9.

mschuene commented 10 years ago

I pushed a new snapshot release to clojars, could you test again with it?

mschuene commented 10 years ago

I think it is resolved now