Question: What is the best way to make the results of calling solve become procedures?

Let's say we have four equations and four unknowns and we use solve to find a solution.

The return value of solve is a set.

Here is an example

solve({T__1 = m__1*a, a = R*alpha, -R*T__1+R*T__2 = I__s*a/R, g*m__2-T__2 = m__2*a}, {T__1, T__2, a, alpha})

{T__1 = R^2*g*m__2*m__1/(R^2*m__1+R^2*m__2+I__s), T__2 = m__2*g*(R^2*m__1+I__s)/(R^2*m__1+R^2*m__2+I__s), a = R^2*g*m__2/(R^2*m__1+R^2*m__2+I__s), alpha = R*g*m__2/(R^2*m__1+R^2*m__2+I__s)}

(1)

NULL


If we want to make the four expressions above procedures, the manual way is to basically copy the right-hand side of each expression and then write

T__1 := (R,m__1, m__2, g, I__s) -> ...

T__2 := (R,m__1, m__2, g, I__s) -> ...

a := (R,m__1, m__2, g, I__s) -> ...

alpha := (R,m__1, m__2, g, I__s) -> ...

Is there a way to do this automatically from the return value of solve?

If the return value were a list, I would use something like

T__1 := unapply(result[1], R, m__1, m__2, g, I__s)

T__2 := unapply(result[2], R, m__1, m__2, g, I__s)

a := unapply(result[3], R, m__1, m__2, g, I__s)

alpha := unapply(result[4], R, m__1, m__2, g, I__s)

But the return value is not a list.

So, in summary my quesions are

1) what, in general, is the best way to obtain the desired procedures?

2) is there a way to use the strategy I suggested if the result were a list, but for sets?

Download solveEqs.mw

Please Wait...