Thank You.

On Thu, Aug 15, 2013 at 11:34 PM, Aaron Meurer <[email protected]> wrote:

> Unfortunately, unless I am mistaken, there isn't a function to do
> exactly what you want yet. We probably should make one.
>
> I was able to get pretty close using
>
> Add(*[(factor(Add(*i))) for i in sift(Add.make_args(num), lambda i:
> Poly(i, log(R), log(R_1)).total_degree()).values()])
>
> Basically, I split out each term by its degree in terms of log(R) and
> log(R_1), and then factored those terms independently.  This works in
> this case because all the log terms are of the form (log(R) -
> log(R_1))**n for some n, so to get the terms corresponding to the
> factor for each n, one just needs to gather all the terms where the
> total degree in log(R) and log(R_1) equals n.
>
> As for combining the logs at that point, logcombine works, but it goes
> a little too far. We should add some flags to it to allow disabling
> combining of exponents.  You can get what you want using subs(log(R) -
> log(R_1), log(R/R_1)), though, since all the logs are of that form.
> More generally you could use replace with a wild symbol.
>
> Aaron Meurer
>
> On Thu, Aug 15, 2013 at 11:09 AM, Boris Kheyfets <[email protected]>
> wrote:
> > Oh, no problem:
> >
> > Gamma_R**2*R**4*R_1**2 + 4*Gamma_R**2*R**2*R_1**4*log(R)**3 -
> > 12*Gamma_R**2*R**2*R_1**4*log(R)**2*log(R_1) -
> > 8*Gamma_R**2*R**2*R_1**4*log(R)**2 +
> > 12*Gamma_R**2*R**2*R_1**4*log(R)*log(R_1)**2 +
> > 16*Gamma_R**2*R**2*R_1**4*log(R)*log(R_1) +
> 2*Gamma_R**2*R**2*R_1**4*log(R)
> > - 4*Gamma_R**2*R**2*R_1**4*log(R_1)**3 -
> > 8*Gamma_R**2*R**2*R_1**4*log(R_1)**2 - 2*Gamma_R**2*R**2*R_1**4*log(R_1)
> -
> > Gamma_R**2*R**2*R_1**4 - 2*Gamma_R**2*R_1**6*log(R)**2 +
> > 4*Gamma_R**2*R_1**6*log(R)*log(R_1) - 2*Gamma_R**2*R_1**6*log(R_1)**2 +
> > 4*Gamma_R*P*R**4*R_1**2*log(R) - 4*Gamma_R*P*R**4*R_1**2*log(R_1) +
> > 2*Gamma_R*P*R**4*R_1**2 - 8*Gamma_R*P*R**2*R_1**4*log(R)**3 +
> > 24*Gamma_R*P*R**2*R_1**4*log(R)**2*log(R_1) -
> > 8*Gamma_R*P*R**2*R_1**4*log(R)**2 -
> > 24*Gamma_R*P*R**2*R_1**4*log(R)*log(R_1)**2 +
> > 16*Gamma_R*P*R**2*R_1**4*log(R)*log(R_1) +
> > 8*Gamma_R*P*R**2*R_1**4*log(R_1)**3 -
> 8*Gamma_R*P*R**2*R_1**4*log(R_1)**2 -
> > 2*Gamma_R*P*R**2*R_1**4 + 4*Gamma_R*P*R**2*R_1**2*log(R)**2 -
> > 8*Gamma_R*P*R**2*R_1**2*log(R)*log(R_1) - 4*Gamma_R*P*R**2*R_1**2*log(R)
> +
> > 4*Gamma_R*P*R**2*R_1**2*log(R_1)**2 + 4*Gamma_R*P*R**2*R_1**2*log(R_1) -
> > 4*Gamma_R*P*R_1**4*log(R) + 4*Gamma_R*P*R_1**4*log(R_1) +
> > 8*P**2*R**4*R_1**2*log(R)**2 - 16*P**2*R**4*R_1**2*log(R)*log(R_1) +
> > 8*P**2*R**4*R_1**2*log(R_1)**2 + 2*P**2*R**4*R_1**2 - 2*P**2*R**2*R_1**4
> -
> > 8*P**2*R**2*R_1**2*log(R)**2 + 16*P**2*R**2*R_1**2*log(R)*log(R_1) -
> > 8*P**2*R**2*R_1**2*log(R) - 8*P**2*R**2*R_1**2*log(R_1)**2 +
> > 8*P**2*R**2*R_1**2*log(R_1) + 2*P**2*R**2 - 2*P**2*R_1**2
> >
> > I need to combine logs.
> >
> > Here's a py code, just in case:
> >
> > #!/usr/bin/python2.7
> > # -*- coding:utf-8 -*-
> >
> > # =========
> > ## imports:
> >
> > from __future__ import division
> >
> > from sympy import *
> > init_printing(pretty_print=True, use_unicode=True, wrap_line=False,
> > no_global=True)
> >
> >
> > # ======
> > ## init:
> >
> > # real vars:
> >
> > var("""
> > gamma_rr gamma_ff gamma_sum Gamma_R
> > g_l g_0 g__2
> > """, real=True)
> >
> > # positive vars:
> >
> > var("""
> > gamma gamma_R
> > r R_1 R_2 R
> > P
> > """, positive=True)
> >
> >
> > # ===========
> > ## functions:
> >
> > g_l = (
> >     (Gamma_R + 2 * P)
> >     /
> >     (2 * log(R/R_1))
> > )
> >
> > g_0 = (
> >     (Gamma_R * log(R/R_1) + P)
> >     /
> >     (2 * log(R/R_1))
> > )
> >
> > g_2 = (
> >     (R_1**2 * Gamma_R * log(R/R_1) + P)
> >     /
> >     (2 * log(R/R_1))
> > )
> >
> > gamma_ff = (
> >     g_l * ( log(r/R_1) + 1 )
> >     - g_0
> >     - g_2/r**2
> > )
> >
> > R_2 = R
> >
> >
> > intgrl = together(cancel(integrate(gamma_ff**2 * r, (r, R_1, R_2))))
> > den = denom(intgrl)
> > num = numer(intgrl)
> > print str(num)
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "sympy" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [email protected].
> > To post to this group, send email to [email protected].
> > Visit this group at http://groups.google.com/group/sympy.
> > For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "sympy" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sympy/EVt-RDdL1Pg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to