Ask Your Question
0

simplifying/factoring symbolic fractions to fractional powers

asked 2024-08-02 14:14:45 +0100

Max Alekseyev gravatar image

updated 2024-08-02 14:15:26 +0100

Let's start with

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 flag offensive close merge delete

Comments

canonicalize_radical() seems to produce better results.

tolga gravatar imagetolga ( 2024-08-02 15:23:32 +0100 )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.

Max Alekseyev gravatar imageMax Alekseyev ( 2024-08-02 16:15:20 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2024-08-02 16:26:11 +0100

Emmanuel Charpentier gravatar image

updated 2024-08-02 16:31:58 +0100

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
 choice inconsistent with your assumptions.

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,

edit flag offensive delete link more

Comments

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

Max Alekseyev gravatar imageMax Alekseyev ( 2024-08-02 16:46:01 +0100 )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...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-08-03 08:17:12 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-08-02 14:14:45 +0100

Seen: 180 times

Last updated: Aug 02