Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question
0

simplifying/factoring symbolic fractions to fractional powers

asked 0 years ago

Max Alekseyev gravatar image

updated 0 years ago

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?

Preview: (hide)

Comments

canonicalize_radical() seems to produce better results.

tolga gravatar imagetolga ( 0 years ago )

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 qpq+p2qpq. Weird.

Max Alekseyev gravatar imageMax Alekseyev ( 0 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 0 years ago

Emmanuel Charpentier gravatar image

updated 0 years ago

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,

Preview: (hide)
link

Comments

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

Max Alekseyev gravatar imageMax Alekseyev ( 0 years ago )
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 ( 0 years ago )

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: 0 years ago

Seen: 226 times

Last updated: Aug 02 '24