title: sage math: how to combine or expand exponents in a symbolic expression?
body: <p>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 <code>(a**b)**c</code> to <code>a**(b*c)</code>, or vise versa?</p>
  
  <p><strong>Examples:</strong></p>
  
  <pre><code>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 &gt; 0)
  sage: expand_exponents( x^(1/3*y) )
  (x^y)^(1/3)
  </code></pre>
  
  <p><strong>What I have already tried:</strong></p>
  
  <pre><code>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)
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p><code>simplify_exp</code> (codelion's answer) works to convert from <code>(a**b)**c</code> to <code>a**(b*c)</code>, but not the other way around. Is it possible to get sage to expand exponents as well? </p>