Thanks, that worked perfectly. My final function is:

def ndf(expr, factor): 
    n, d = expr.as_numer_denom() 
    return expand(n*factor)/expand(d*factor)


On Thursday, November 17, 2016 at 2:30:50 PM UTC-5, Aaron Meurer wrote:
>
> Ah, I forgot that if factor is not a number, it won't distribute 
> automatically. You'll want to do something like 
>
> n, d = expr.as_numer_denom() 
> expand(n*factor)/expand(d*factor) 
>
> The way it is now, factor just immediately cancels. 
>
> And by the way, if your goal is to write a rational function in 
> reduced terms, you can use cancel() or factor() (the latter will also 
> factor the numerator and denominator). 
>
> Aaron Meurer 
>
>
> On Thu, Nov 17, 2016 at 8:23 AM, Scott Calabrese Barton 
> <[email protected] <javascript:>> wrote: 
> > Unfortunately that image will not render.  Here's a link to it: 
> > https://goo.gl/J1wn0P 
> > 
> > On Thursday, November 17, 2016 at 8:17:33 AM UTC-5, Scott Calabrese 
> Barton 
> > wrote: 
> >> 
> >> Aaron, thanks, that's definitely the right idea, but doesn't work, 
> >> probably because of simplification. Here's an example: 
> >>> 
> >>> 
> > -- 
> > 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] <javascript:>. 
> > To post to this group, send email to [email protected] 
> <javascript:>. 
> > Visit this group at https://groups.google.com/group/sympy. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/sympy/2d2bbab6-ed5c-4a9a-957f-51986b4f40e8%40googlegroups.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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 https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/55ae0be9-5a0a-44e2-b20a-bf2a8e74b44c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to