### math

#### sage math: how to combine or expand exponents in a symbolic expression?

How can I combine or expand the exponents in an expression in sage? In other words, how can I have sage rewrite an expression from (a**b)**c to a**(b*c), or vise versa? Examples: sage: var('x y') (x, y) sage: assume(x, 'rational') sage: assume(y, 'rational') sage: combine_exponents( (x^2)^y ) x^(2*y) sage: assume(x > 0) sage: expand_exponents( x^(1/3*y) ) (x^y)^(1/3) What I have already tried: sage: b = x^(2*y) sage: a = (x^2)^y sage: bool(a == b) True sage: a (x^2)^y sage: simplify(a) (x^2)^y sage: expand(a) (x^2)^y sage: b x^(2*y) sage: expand(b) x^(2*y) Update: simplify_exp (codelion's answer) works to convert from (a**b)**c to a**(b*c), but not the other way around. Is it possible to get sage to expand exponents as well?

Starting from Sage 6.5, to transform a into b, use the method canonicalize_radical. sage: a.canonicalize_radical() x^(2*y) Note that the four methods simplify_exp, exp_simplify, simplify_radical, radical_simplify, which had the same effect, are being deprecated in favour of canonicalize_radical. See Sage trac ticket #11912. I don't know if there is a built-in function to transform b into a. You could define your own function like this: def power_step(expr, step=None): a, b = SR.var('a'), SR.var('b') if str(expr.operator()) == str((a^b).operator()): aa, mm = expr.operands() if step is None: if str(mm.operator()) == str((a*b).operator()): bb = mm.operands().pop() return (aa^bb)^(mm/bb) else: return expr return (aa^step)^(mm/step) else: if step is None: return expr else: return (expr^step)^(1/step) Then you can decompose the powering into steps: sage: x, y = var('x y') sage: power_step(x^(2*y),y) (x^y)^2 sage: power_step(x^(2*y),2) (x^2)^y Note that if you don't specify the step, it won't always pick the first one that is displayed. sage: power_step(2^(x*y)) (2^y)^x sage: power_step(x^(2*y)) (x^2)^y

You can use the simplify_exp() function. So for your example do the following: sage: a.simplify_exp() x^(2*y)

### Related Links

Move point in cartesian coordinate through distance in the given direction

LU-Decomposition factorization error

How to find polygons in a given set of points and edges?

Calculate how much a point is worth based on played games

LibGDX: How to keep an Object at same visual screen position while rotating the camera

Setting the magnitude of a 2D Vector

Convert Lat/Long to X,Y position within a Bounding Box

d3js Cluster Force Layout IV block by Mike

Maximum number of points that lie on the same straight straight line in a 2D plane

How to draw a gps marker on a rotated custom image map

Conversion coordinates from a bound rectangle, to the coordinates of rotated rectangle contained by it

Why isn't this Math.random method working?

Calculate radius of curve/arc formed by line segments (approximate)

The Probability of … After n Trials

Finding minima of a function using genetic algorithm

Number of triangles with N points inside