clojure-numerics / expresso

Clojure library for symbolic computation
312 stars 20 forks source link

error in solution to simultaneous equations for affine interpolant #31

Open palisades-lakes opened 5 years ago

palisades-lakes commented 5 years ago

(solve '[a0 a1] (ex (= y0 (+ a0 ( a1 x0)))) (ex (= y1-y0 ( a1 x1-x0))))

returns

{{ a1 (* y1-y0 (/ x1-x0)),

 a0 (+ y0 (* -1 y1-y0 x1-x0 x0))}}

a1 is correct, though I would have expected (/ y1-y0 x1-x0) a0 should be something equivalent to (- y0 (* (/ y1-y0 x1-x0) x0)).

PS: I started with (solve '[a0 a1] (ex (= y0 (+ a0 ( a1 x0)))) (ex (= y1 (+ a0 ( a1 x1)))))

But the answer wasn't useful:

{{a1 (+ (* y1

        (+ (/ x1) 
           (* (** (/ x1) 2) 
              -1 
              x0 
              (/ (+ (/ x1) (- x0) -1)))))
     (* y0 
        (/ (+ (/ x1) (- x0) -1))
        (/ x1))), 

a0 ( (/ (+ (/ x1) (- x0) -1)) (+ ( y1 (/ x1) x0) (- y0)))}} So I tried re-arranging by hand, only to get an incorrect answer.

palisades-lakes commented 5 years ago

PPS: expresso 0.2.2 clojure 1.9.0 openjdk 11.0.1

mschuene commented 5 years ago

thanks for the report, I'll look into it

On Fri, Oct 19, 2018 at 6:32 AM John Alan McDonald notifications@github.com wrote:

PPS: expresso 0.2.2 clojure 1.9.0 openjdk 11.0.1

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/clojure-numerics/expresso/issues/31#issuecomment-431241788, or mute the thread https://github.com/notifications/unsubscribe-auth/AD7eDTLsoqpEbflrEAvNpLwTuWb5CK9dks5umVXagaJpZM4XvpxF .