Ask Your Question
1

How to rearrange terms in an expression

asked 2011-01-16 15:35:34 -0500

mouse gravatar image

updated 2011-01-16 15:55:51 -0500

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2011-01-16 22:34:05 -0500

mouse gravatar image

updated 2011-01-19 11:17:48 -0500

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

edit flag offensive delete link more

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 ( 2011-01-17 05:27:51 -0500 )edit

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: 2011-01-16 15:35:34 -0500

Seen: 1,078 times

Last updated: Jan 19 '11