# How to rearrange terms in an expression I'm totally new to Sage. I was hoping I could use it for simple and complex application problems I run into at work. For example the relationship between flow rate, Q, and pressure drop, dP, for flow of a powerlaw fluid (m, n) in a cylindrical tube (L, R) is:

Q = (pi*R^3/((1/n)+3))*(Tau/m)^(1/n)


So I want to rearrange this expression for dP in terms of Q, m, n, L, R so I can then compute a table of results, plot dP versus Q etc. Now of course I can do the rearrangement by hand with pen and paper (or in my head on better days) but I was hoping that using the Sage notebook I could work through the rearrangement and thus have an digital record of the transformation so that others can follow along. However in all the hours of reading and watching tutorials, I have yet to see this simple process in action.

So far in my sage book I have:

Q, L, R, m, n, dP = var("Q, L, R, m, n, dP")
Tau = dP/(2*L/R)
Q = (pi*R**3/((1/n)+3))*(Tau/m)**(1/n)


(Note that the preview doesn't show the power symbol **, hope it appears in the posted question)

Is there a method, say, Q.rearrange(dP) that yields dP = f(Q, L, R, m, n)? If not, how do I write the intermediate steps in sage speak to give this expression?

Sorry if this is such a basic question.

edit retag close merge delete

Sort by » oldest newest most voted

OK, after more googling I found a link to manipulating symbolic expressions which seems to cover what I want. Here'tis for any others that may be interested.

http://www.sagemath.org/doc/reference...

Good point Evgeny! So here's a simple example

var('x,y,z')

assume(z, 'integer')

eqn = x == y**z

solve(eqn, y)

Note: this will fail without the assume statement (see this response from kcrisman http://ask.sagemath.org/question/318/... ).

more

Can you be more specific about what commands did what you wanted? You should be able to edit your own post. Anyway, that would help others who find this post and want to see the specific details so they can imitate them.