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

Edit detail for simplifying Expressions revision 1 of 4

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

changed:
-
Simplification of Expressions

  Suppose we compute

\begin{axiom}
integrate(exp(-x**2/2)/sqrt(2*%pi),x=%minusInfinity..%plusInfinity)
\end{axiom}

*And now I wonder why common factors are not cancelled and why not the
result "1" is produced.*

In general (unlike some other computer math systems) Axiom automatically
performs only a very small number of basic simplifications. This is not
one of them, so we need to provide some help. In particular we need to
tell Axiom how to expand square roots. (Since $\sqrt{\ }$ is a multi-valued
function this rule is true only in a restricted sense for a particular
choice of branches. Consider $a=-1, b=-1$.)

\begin{axiom}
expandSqrt := rule sqrt(a*b)==sqrt(a)*sqrt(b)
\end{axiom}

Next, notice that the output of the integration operation has a complicated
type structure. This would interfere with the simplification, so we first
simplify the type before we apply the rule.

\begin{axiom}
(%% 1)::Expression Integer
expandSqrt %
\end{axiom}

Simplification of Expressions

Suppose we compute

fricas
integrate(exp(-x**2/2)/sqrt(2*%pi),x=%minusInfinity..%plusInfinity)
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) Variable(x) PositiveInteger
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

And now I wonder why common factors are not cancelled and why not the result "1" is produced.

In general (unlike some other computer math systems) Axiom automatically performs only a very small number of basic simplifications. This is not one of them, so we need to provide some help. In particular we need to tell Axiom how to expand square roots. (Since \sqrt{\ } is a multi-valued function this rule is true only in a restricted sense for a particular choice of branches. Consider a=-1, b=-1.)

fricas
expandSqrt := rule sqrt(a*b)==sqrt(a)*sqrt(b)

\label{eq1}{\sqrt{a \  b}}\mbox{\rm = =}{{\sqrt{a}}\ {\sqrt{b}}}(1)
Type: RewriteRule?(Integer,Integer,Expression(Integer))

Next, notice that the output of the integration operation has a complicated type structure. This would interfere with the simplification, so we first simplify the type before we apply the rule.

fricas
(%% 1)::Expression Integer
Cannot convert from type RewriteRule(Integer,Integer,Expression( Integer)) to Expression(Integer) for value +---+ +-+ +-+ \|a b == \|a \|b
expandSqrt %
There are no library operations named expandSqrt Use HyperDoc Browse or issue )what op expandSqrt to learn if there is any operation containing " expandSqrt " in its name.
Cannot find a definition or applicable library operation named expandSqrt with argument type(s) RewriteRule(Integer,Integer,Expression(Integer))
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.