# simplifying/factoring symbolic fractions to fractional powers

sage: x,p,q = var('x p q')
sage: ( exp(p*x - q*x)^(1/(p-q)) ).full_simplify()
e^x


So far so good. Let's bring an extra factor to the picture:

sage: ( (exp(p*x - q*x)/q)^(1/(p-q)) ).full_simplify()
(e^(p*x - q*x)/q)^(1/(p - q))


There is no simplification here. Why?

Also:

sage: ( (exp(p*x - q*x)/q)^(1/(p-q)) ).factor()
(e^(p*x - q*x)/q)^(1/(p - q))


does not produce the expected exp(x)*q^(-1/(p-q)). How to get that result?

edit retag close merge delete

canonicalize_radical() seems to produce better results.

( 2024-08-02 15:23:32 +0200 )edit

Here is a real-life example. I was able to get almost the desired result with a combination of .canonicalize_radical().simplify_real() but it somehow misses the last rather trivial step in evaluating $\frac{q}{p-q}+\frac{p-2q}{p-q}$. Weird.

( 2024-08-02 16:15:20 +0200 )edit

Sort by ยป oldest newest most voted

The legitimity of the simplifications of poers depend on the values of the argiments and of the exponents.

This well explained in the subparagraph Powers of the sympy's simplify documentation.

As pointed out by @tolga, the canonicalize_radical method of symbolic expressions does some simplifications that full_simplify doesn't. I am not sure that they are always legitimate.

BTW, from x.canonicalize_radical :

Warning:

 As shown in the examples below, a canonical form is not always
returned, i.e., two mathematically identical expressions might be
converted to different expressions.Assumptions are not taken into
account during the transformation. This may result in a branch


Being a wrapper for Maxima's radcan, canonicalize_radical may use Sage's assumptions. However, in your case, it proceeds to simplifications without assumptions :

sage: ( (exp(p*x - q*x)/q)^(1/(p-q)) ).canonicalize_radical()
e^x/q^(1/(p - q))


EDIT : Sympy is more cautious :

sage: ( (exp(p*x - q*x)/q)^(1/(p-q)) )._sympy_().simplify()._sage_()
(e^((p - q)*x)/q)^(1/(p - q))


but does not (currently) uses Sage's assumptions :

sage: with assuming (p, q, "integer", p>q, q>0): ( (exp(p*x - q*x)/q)^(1/(p-q))
....: )._sympy_().simplify()._sage_()
(e^((p - q)*x)/q)^(1/(p - q))


HTH,

more

Why do you assume that p and q are integer? What if they are not?

( 2024-08-02 16:46:01 +0200 )edit
1

Why do you assume that p and q are integer? What if they are not?

That's my point : some power expression simplifications are possibl eif and only if the quantities involved are integers. See the cocumentation I pointed to...

( 2024-08-03 08:17:12 +0200 )edit