Ask Your Question
1

How to rearrange terms in an expression

asked 14 years ago

mouse gravatar image

updated 14 years ago

Mike Hansen gravatar image

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 14 years ago

mouse gravatar image

updated 14 years ago

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/... ).

Preview: (hide)
link

Comments

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.

kcrisman gravatar imagekcrisman ( 14 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 14 years ago

Seen: 2,461 times

Last updated: Jan 19 '11