login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for simplify exponents revision 1 of 4

1 2 3 4
Editor: 127.0.0.1
Time: 2007/11/15 20:22:56 GMT-8
Note: transferred from axiom-developer

changed:
-
Howto simplify exponents

  How can I make axiom to do 2^a*2^(2*a) -> 2^(3*a) ?

\begin{axiom}
2^a*2^(2*a)
simplify %
\end{axiom}

But I cannot convince Axiom to do 2^(5*a)/2^(4*a) -> 2^a

\begin{axiom}
2^(5*a)/2^(4*a)
simplify %
\end{axiom}

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.

\begin{axiom}
exprule:=rule exp(x*log(n)) == n^x
normalize %% 3
exprule %
\end{axiom}

The second approach uses a single rule to do the whole job.

\begin{axiom}
fracrule:=rule n^m/n^p == n^(m-p)
fracrule %% 3
\end{axiom}

How about 2^a*4^a ?

\begin{axiom}
2^a*4^a
simplify %
\end{axiom}

Here is one approach. First lets define a function that factors a power and a rule that applies this function.

\begin{axiom}
powerFac(n,a) == reduce(*,[(t.factor)^(a*t.exponent) for t in factors(n)])
powerRule := rule n^a == powerFac(n,a)
\end{axiom}

Now we can use the rule and simplify the result
\begin{axiom}
simplify powerRule (2^a*4^a)
\end{axiom}

Apparently, simplifyExp yields the desired result
\begin{axiom}
simplifyExp(2^a*2^(2*a))
\end{axiom}


From BillPage Mon Oct 11 12:48:08 -0500 2004
From: Bill Page
Date: Mon, 11 Oct 2004 12:48:08 -0500
Subject: But ...
Message-ID: <20041011124808-0500@page.axiom-developer.org>

The desired result was

-  2^a*4^a -> 2^(3a)

\begin{axiom}
simplifyExp(2^a*4^a)
\end{axiom}

doesn't do it.

From unknown Mon Oct 11 22:44:30 -0500 2004
From: H.P.
Date: Mon, 11 Oct 2004 22:44:30 -0500
Subject: In the other hand ...
Message-ID: <20041011224430-0500@page.axiom-developer.org>

... it does have some effect:

\begin{axiom}
2**(3*a)*2**(4*a)
simplifyExp(2**(3*a)*2**(4*a))
\end{axiom}

From unknown Thu Apr 7 18:25:36 -0500 2005
From: unknown
Date: Thu, 07 Apr 2005 18:25:36 -0500
Subject: \
Message-ID: <20050407182536-0500@page.axiom-developer.org>



Howto simplify exponents

How can I make axiom to do 2^a2^(2a) -> 2^(3*a) ?

axiom
2^a*2^(2*a)

\label{eq1}{{2}^{a}}\ {{2}^{2 \  a}}(1)
Type: Expression(Integer)
axiom
simplify %

\label{eq2}{2}^{3 \  a}(2)
Type: Expression(Integer)

But I cannot convince Axiom to do 2^(5a)/2^(4a) -> 2^a

axiom
2^(5*a)/2^(4*a)

\label{eq3}{{2}^{5 \  a}}\over{{2}^{4 \  a}}(3)
Type: Expression(Integer)
axiom
simplify %

\label{eq4}{{2}^{5 \  a}}\over{{2}^{4 \  a}}(4)
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

\label{eq5}{{e}^{x \ {\log \left({n}\right)}}}\mbox{\rm = =}{{n}^{x}}(5)
Type: RewriteRule?(Integer,Integer,Expression(Integer))
axiom
normalize %% 3

\label{eq6}{e}^{a \ {\log \left({2}\right)}}(6)
Type: Expression(Integer)
axiom
exprule %

\label{eq7}{2}^{a}(7)
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)

\label{eq8}{{{n}^{m}}\over{{n}^{p}}}\mbox{\rm = =}{{n}^{- p + m}}(8)
Type: RewriteRule?(Integer,Integer,Expression(Integer))
axiom
fracrule %% 3

\label{eq9}{2}^{a}(9)
Type: Expression(Integer)

How about 2^a*4^a ?

axiom
2^a*4^a

\label{eq10}{{2}^{a}}\ {{4}^{a}}(10)
Type: Expression(Integer)
axiom
simplify %

\label{eq11}{{2}^{a}}\ {{4}^{a}}(11)
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)

\label{eq12}{{n}^{a}}\mbox{\rm = =}{{{\tt'}powerFac}\left({n , \: a}\right)}(12)
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)

\label{eq13}{2}^{3 \  a}(13)
Type: Expression(Integer)

Apparently, simplifyExp yields the desired result

axiom
simplifyExp(2^a*2^(2*a))

\label{eq14}{2}^{3 \  a}(14)
Type: Expression(Integer)

The desired result was

  • 2^a*4^a -> 2^(3a)

axiom
simplifyExp(2^a*4^a)

\label{eq15}{{2}^{a}}\ {{4}^{a}}(15)
Type: Expression(Integer)

doesn't do it.

In the other hand ... --H.P., Mon, 11 Oct 2004 22:44:30 -0500 reply
... 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.