something like: In [1]: a, b, c = symbols('abc')
In [2]: f = a + b + c + a**2 + b**2 + c**2 In [3]: f.subs(a**2 + b**2 + c**2, 1) Out[3]: 1 + a + b + c In [4]: xsq = a**2 + b**2 + c**2 In [5]: xsq.args[0] Out[5]: 2 a In [6]: new_xsq = xsq - a**2 - 1 In [7]: new_xsq Out[7]: 2 2 -1 + b + c In [8]: f.subs(xsq, new_xsq) Out[8]: 2 2 -1 + a + b + c + b + c If not give a snippet of what you want, I get a little confused with all the word place holders. -- Andy On Thu, Dec 4, 2008 at 1:30 PM, Alan Bromborsky <[EMAIL PROTECTED]> wrote: > > Say I have a expression f containing symbols a, b, c, a**2, b**2, and > c**2 and I wish to automate imposing the constraint a**2+b**2+c**2 = > 1. But a,b, and c and their squares are hidden (were generated by other > manipulations) so all I have are f and xsq (xsq = a**2+b**2+c**2). How > do I extract the first square from xsq so that I can: > > new_xsq = xsq-a**2-1 and then substitute new_xsq into f eliminating a**2 > from f (I actually don't care whether I eliminate a**2 or b**2 or c**2). > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---