For 8 + 8/(1+p), apart() will give this form.
In general, it likely depends on the expression which function will do
this. You can use the count method to count how many times a variable
appears in an expression
In [65]: (8 + 8/(1+x)).count(x)
Out[65]: 1
In [66]: (8*(x + 3)/(x + 2)).count(x)
Out[66]: 2
You could use the measure option to simplify to tell it to minimize this:
In [67]: simplify(8 + 8/(1+x), measure=lambda i: i.count(x))
Out[67]:
8
8 + ─────
x + 1
You could also write your own function that tries various functions
and returns the result with the fewest occurrences of the variables.
Aaron Meurer
> --
> 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
sympy+un...@googlegroups.com.
> To post to this group, send email to
sy...@googlegroups.com.
> 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/43f8ff85-9b85-43ad-942b-90722d86a506%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.