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

Simplification of Expressions

Suppose we compute

axiom
integrate(exp(-x**2/2)/sqrt(2*%pi),x=%minusInfinity..%plusInfinity)
LatexWiki Image(1)
Type: Union(f1: OrderedCompletion? Expression Integer,...)

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 LatexWiki Image is a multi-valued function this rule is true only in a restricted sense for a particular choice of branches. Consider LatexWiki Image.)

axiom
expandSqrt := rule sqrt(a*b)==sqrt(a)*sqrt(b)
LatexWiki Image(2)
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.

axiom
(%% 1)::Expression Integer
LatexWiki Image(3)
Type: Expression Integer
axiom
expandSqrt %
LatexWiki Image(4)
Type: Expression Integer




subject:
  ( 7 subscribers )  
Please rate this page: