Hi, On Mon, 14 Apr 2008 03:33:18 -0700 (PDT) "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: [...] > For instance > > f(x, mu, gamma): (- gamma * (x-mu)**2 - log(gamma) + log(2*pi)) / 2 > > So how can I ask sympy to decompose f as: > > g1(mu, gamma) * x**2 + g2(mu, gamma) * x + g3(mu, gamma)
I think this will do it (in isympy, otherwise import x aswell) : In [1]: from sympy.abc import gamma, mu In [2]: f = (- gamma * (x-mu)**2 - log(gamma) + log(2*pi)) / 2 In [3]: g1 = Wild('g1', exclude=[x]) In [4]: g2 = Wild('g2', exclude=[x]) In [5]: g3 = Wild('g3', exclude=[x]) In [6]: f.expand().match(g1 * x**2 + g2 * x + g3) Out[6]: ⎧ 2⎫ ⎜ -γ log(2) log(π) log(γ) γ*μ ⎟ ⎨g₁: ──, g₂: γ*μ, g₃: ────── + ────── - ────── - ────⎬ ⎜ 2 2 2 2 2 ⎟ ⎩ ⎭ Hope that helps, Abderrahim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---