Howto simplify exponents
How can I make axiom to do 2^a2^(2a) -> 2^(3*a) ?
axiom
2^a*2^(2*a)
Type: Expression(Integer)
axiom
simplify %
Type: Expression(Integer)
But I cannot convince Axiom to do 2^(5a)/2^(4a) -> 2^a
axiom
2^(5*a)/2^(4*a)
Type: Expression(Integer)
axiom
simplify %
Type: Expression(Integer)
Unfortunately this seemingly simple transformation does not seem to be easy to perform in Axiom but I have found two possible ways to do this. The first involves the normalize() operation. Unfortunately normalize takes the process one step too far. This can be undone with a simple rule.
axiom
exprule:=rule exp(x*log(n)) == n^x
Type: RewriteRule
?(Integer,
Integer,
Expression(Integer))
axiom
normalize %% 3
Type: Expression(Integer)
axiom
exprule %
Type: Expression(Integer)
The second approach uses a single rule to do the whole job.
axiom
fracrule:=rule n^m/n^p == n^(m-p)
Type: RewriteRule
?(Integer,
Integer,
Expression(Integer))
axiom
fracrule %% 3
Type: Expression(Integer)
How about 2^a*4^a ?
axiom
2^a*4^a
Type: Expression(Integer)
axiom
simplify %
Type: Expression(Integer)
Here is one approach. First lets define a function that factors a power and a rule that applies this function.
axiom
powerFac(n,a) == reduce(*,[(t.factor)^(a*t.exponent) for t in factors(n)])
Type: Void
axiom
powerRule := rule n^a == powerFac(n,a)
Type: RewriteRule
?(Integer,
Integer,
Expression(Integer))
Now we can use the rule and simplify the result
axiom
simplify powerRule (2^a*4^a)
axiom
Compiling function powerFac with type (PositiveInteger,Variable(a))
-> Expression(Integer)
axiom
Compiling function powerFac with type (PositiveInteger,Polynomial(
Integer)) -> Expression(Integer)
Type: Expression(Integer)
Apparently, simplifyExp yields the desired result
axiom
simplifyExp(2^a*2^(2*a))
Type: Expression(Integer)
The desired result was
axiom
simplifyExp(2^a*4^a)
Type: Expression(Integer)
doesn't do it.
... it does have some effect:
axiom
2**(3*a)*2**(4*a)
There are no library operations named **
Use HyperDoc Browse or issue
)what op **
to learn if there is any operation containing " ** " in its name.
Cannot find a definition or applicable library operation named **
with argument type(s)
PositiveInteger
Polynomial(Integer)
Perhaps you should use "@" to indicate the required return type,
or "$" to specify which version of the function you need.
simplifyExp(2**(3*a)*2**(4*a))
There are no library operations named **
Use HyperDoc Browse or issue
)what op **
to learn if there is any operation containing " ** " in its name.
Cannot find a definition or applicable library operation named **
with argument type(s)
PositiveInteger
Polynomial(Integer)
Perhaps you should use "@" to indicate the required return type,
or "$" to specify which version of the function you need.