-
Notifications
You must be signed in to change notification settings - Fork 20
User API examples
Mike Anderson edited this page Jun 27, 2013
·
10 revisions
Purpose of this page it to collect a few "typical" use cases:
User has an expression in terms of one symbol, would like to rearrange it to express it in terms of another symbol:
(def E (ex (= y (/ x y))))
(rearrange [x] E)
=> (= x (* y y))
User has an expression with several variables (come of which may be constants). The user would like to get a new expression which is the derivative of the first:
(def E (ex (+ (* (+ 1 a) x x) (* (+ b c) x) a)))
(derivative [x] E)
=> (+ (* 2 (+ 1 a) x) (+ b c))
User has an expression representing an equation, would like to solve for values of a variable that satisfy the equation
(def E (ex (= [x y z] [z 2 x])))
(solve [y] E)
=> (2)
(solve [x] E)
=> undetermined
Note: need to think about possibility for zero or multiple solutions?