If I define an atom eg L=x^2+x+1, is there a way to rewrite an expression with these atoms? For example: L=x^2+x+1 M=x+(x(x^2+x+1))^(1/2) I would like some way to express this as x+(xL)^(1/2). Is this possible?
If I define an atom eg L=x^2+x+1, is there a way to rewrite an expression with these atoms? For example: L=x^2+x+1 M=x+(x(x^2+x+1))^(1/2) I would like some way to express this as x+(xL)^(1/2). Is this possible?
Ben, one way would be to use a local rule like L:>(x^2+x+1). Your L then does not have a global value, you use it in your expression until you want to substitute it with x^2+x+1, then you just use (your expression)/.L:>(x^2+x+1) It would be easier to answer your question if you'd provide more information about your problem/goals. Regards, Leonid
What you want could be difficult, since M can be expressed in terms of L alone (in 4 ways): Clear[M,L] Factor /@ (M /. Solve[{L == x^2 + x + 1, M == x + (x (x^2 + x + 1))^(1/2)}, M, x]) {1/2 (-1 - Sqrt[-3 + 4 L] - Sqrt[2] Sqrt[-L (1 + Sqrt[-3 + 4 L])]), 1/2 (-1 - Sqrt[-3 + 4 L] + Sqrt[2] Sqrt[-L (1 + Sqrt[-3 + 4 L])]), 1/2 (-1 + Sqrt[-3 + 4 L] - Sqrt[2] Sqrt[L (-1 + Sqrt[-3 + 4 L])]), 1/2 (-1 + Sqrt[-3 + 4 L] + Sqrt[2] Sqrt[L (-1 + Sqrt[-3 + 4 L])])} But pattern matching saves the day: m = x + (x (x^2 + x + 1))^(1/2); ell = x^2 + x + 1; m /. ell -> L x + Sqrt[L x] That required FullForm[ell] to be plainly visible in FullForm[m], so things won't always be so simple. Bobby -- XXXX@XXXXX.COM
M = x + (x (x^2 + x + 1))^(1/2); Simplify[M, L == x^2 + x + 1] Sqrt[L*x] + x M /. x^2 + x + 1 -> L Sqrt[L*x] + x Bob Hanlon ============= If I define an atom eg L=x^2+x+1, is there a way to rewrite an expression with these atoms? For example: L=x^2+x+1 M=x+(x(x^2+x+1))^(1/2) I would like some way to express this as x+(xL)^(1/2). Is this possible?
The first of those solutions (with Simplify) looks brilliant, but I don't think I've ever seen that sort of form anywhere in the Mathematica documentation. I've used the second argument(s) to Simplify often, but didn't know it'd work like that. Is there some obvious way to see that substitutions will work that way, or did you figure it out some other way. In any case, thanks, Bob. I'm going to see what else Simplify can do. Cheers, C.O. -- ================================== Curtis Osterhoudt XXXX@XXXXX.COM PGP Key ID: 0x4DCA2A10 ==================================
Users browsing this forum: No registered users and 49 guest