\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/input rules.input}
\author{The Axiom Team}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
\section{License}
<<license>>=
--Copyright The Numerical Algorithms Group Limited 1991.
@
<<*>>=
<<license>>

)clear all
-- first a single rule
logrule := rule log(x) + log(y) == log(x * y)
f := log sin x + log x
logrule f

-- now a pile of several rules
logrules := rule
  log(x) + log(y) == log(x * y)
  y * log x       == log(x ^ y)
f := a * log(sin x) - 2 * log x
logrules f

-- example of a predicate attached to a pattern variable
logrules2 := rule
  log(x) + log(y)          == log(x * y)
  (y | integer? y) * log x == log(x ^ y)
logrules2 f

-- rules for linearizing sines and cosines
trigLinearize := rule
  sin(x) * sin(y)                      == cos(x-y)/2 - cos(x+y)/2
  cos(x) * cos(y)                      == cos(x+y)/2 + cos(x-y)/2
  sin(x) * cos(y)                      == sin(x+y)/2 + sin(x-y)/2
  sin(x) ^ (n | integer? n and n > 1) == (1-cos(2*x))/2 * sin(x)^(n-2)
  cos(x) ^ (n | integer? n and n > 1) == (1+cos(2*x))/2 * cos(x)^(n-2)
g := sin(a)*cos(b) + sin(a)*cos(a) + cos(2*a)*cos(3*a)
trigLinearize g

-- here we show the use of ? to indicate an 'optional' pattern variables
eirule := rule integral((?y + exp x)/x,x) == integral(y/x,x) + Ei x
eirule integral(exp u/u, u)
eirule integral(sin u + exp u/u, u)

-- here we show the use of : to indicate a 'multiple' pattern variables
u := operator u
v := operator v
myrule := rule u(x + y) == u x + v y
h := u(a + b + c + d)
myrule h
myrule2 := rule u(:x + y) == u x + v y
myrule2 h
@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}
