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

how to find the shortest distance in geomatry route?
how to reduce dimensionality of vector
Direction from a normalized vector
matrix norm that is invariant through a change of basis
Convert Cartesian point to point on rotated plane (pic)
Spot light cone direction rotation and orientation inversion
Adding two params of a predicate that aren't static
undefined reference to `tan' but math.h has been included
Computing which side of a line a point is [closed]
Solving the recurrence relation for number of nodes in an AVL tree?
how to cluster curve with kmeans?
Mathematical formula for inverse distance in a range [closed]
Drawing a star - what is sine and cosine actually in reference to?
Type-level arithmetics in OCaml
Determining the big Oh for (n-1)+(n-1)
How to store three small numbers into one double?

Categories

HOME
amazon-s3
asp.net-mvc
wpf
matlab
groovy
module
android-sqlite
direction
blogs
path
passwords
intel-xdk
visual-studio-2012
httpbuilder-ng
ionic3
classloader
socrata
jena
boxfuse
development-environment
pouchdb
sonata-admin
openui5
deserialization
pywin32
api-design
graphcool
slowcheetah
gas
jruby
slime
beanstalkd
jpos
jet
mouseevent
php-carbon
esri
pdfa
point-cloud-library
iar
toastr
scom
django-users
azure-api-apps
jtapi
gosublime
advanced-installer
querydsl
jdom-2
bezier
runge-kutta
atlassian-bitbucketserver
visualsvn-server
dxgi
polymer-cli
spark-submit
quicksand
jquery-ui-dialog
zfs
botkit
maven-jetty-plugin
powerpc
oracle-aq
laravel-routing
dwr
jawr
cmsmadesimple
catalina
facebook-canvas
turbo-c
mailcore2
xceed
data-fitting
vlc-android
enhanced-ecommerce
duration
id3
storage-duration
uac
tun
pyenchant
julian
linegraph
boost-coroutine
omap
textmatching
movie
centering
simpleadapter
mysql5
gnat
culture
jet.com-apis
publish-actions
directcompute
bunny
data-quality
jquery-backstretch
xml.modify
tlb
jxta
batman.js
colormatrix
nawk
modx-evolution
repeating
python-dateutil
arbtt
google-provisioning-api
lungojs
arden-syntax
vim-fugitive
obout
molehill
magento-1.5
gemstone
blackberry-jde
mkreversegeocoder
cluetip
noaa
xoom
seam-conversation
program-transformation
queryanalyzer
net-ssh
utility
help-authoring

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App