clojure-numerics / expresso

Clojure library for symbolic computation
312 stars 20 forks source link

Using inverse trigo functions doesn't solve equations fully #27

Closed danielbraun closed 7 years ago

danielbraun commented 7 years ago

Example:

(solve 'x (ex (= 1 (atan x)))) => #{(tan 1)}
(solve 'x (ex (= 1 (asin x)))) => #{(sin 1)}

whereas


(solve 'x (ex (= 1 (sin x)))) => #{1.5707963267948966}
(solve 'x (ex (= 1 (tan x)))) => #{0.7853981633974483}
danielbraun commented 7 years ago

Actually the problem happens with normal trigonometry functions as well:

(solve 'x (ex (= x (* (tan 1) 1))))  => #{(tan 1)}
(solve 'x (ex (= x (* (atan 1) 1)))) => #{0.7853981633974483}
danielbraun commented 7 years ago

Seems like the numeric.expresso.properties/props multi method is missing definitions for sin/cos/tan. Adding the definitions fixes the problem. I'll send a PR with the missing definitions.

mschuene commented 7 years ago

Thanks. The trigonometric functions should be standard and provided by the library. Note that if you have other (nonstandard) functions that you want expresso to execute after simplification you can extend the props multimethod in your application code.