aboutsummaryrefslogtreecommitdiff
path: root/src/input/defs.input.pamphlet
blob: e3b6ea71897178e72e2c4b7d45d3bdf45a219d93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/input defs.input}
\author{The Axiom Team}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
The [[otherwise]] clause is not recognized either in the NAG version
or the OpenAxiom version.
<<fib>>=
)clear all

fib(0) == 1
fib(1) == 1
fib(n) == fib(n-1) + fib(n-2) otherwise
fib(10)
fib(100)
[fib(2**i) for i in 1..]

@
The [[when]] clause is not recognized either in the NAG version or
the OpenAxiom version.
<<chebyshev>>=
chebyshev1: Integer -> UnivariatePolynomial(x,Fraction Integer)
chebyshev1(0) == 1
chebyshev1(1) == x
chebyshev1(n) == 2*x* chebyshev1(n-1) - chebyshev1(n-2) when n > 1
chebyshev1(2)
chebyshev1(7)
chebyshev2 : Integer -> UnivariatePolynomial(x,Fraction Integer)
chebyshev2 == rules
  chebyshev2(0) == 1
  chebyshev2(1) == 2*x
  chebyshev2(n) == 2*x* chebyshev2(n-1) - chebyshev2(n-2) when n > 1
chebyshev2(1)
chebyshev2(4)
chebyshev2(11)

@
<<*>>=

-- Input for page DefinitionsVsMappings
)clear all

square(x) == x*x
square == x +-> x*x
factorial(0) == 1
factorial(n) == n * fact(n - 1) when n > 0
factorial(n) ==
  n = 0 => 1
  n > 0 => n * factorial(n - 1)
factorial == n +->
  n = 0 => 1
  n > 0 => n * factorial(n - 1)

-- Input for page DefinitionsForFunctions
)clear all

define square(x) == x*x
square(x) == x*x
square(111)
square == x +-> x*x
square(1111)
timesY(x) == x * y
timesY == x +-> x * y
timesY(2)
y := 2
timesY(2)
y := 3
timesY(2)

-- Input for page RulesForVariables
)clear all

rule x == y + z
x
rule y == z + 1
x
z := a; y := 1;
x
a := 2/3
x

-- Input for page RulesVsAssignments
)clear all

rule x == y + 1; rule y == z + 1; rule z == 7;
[x,y,z]
rule z == 7; rule y == z + 1; rule x == y + 1; [x, y, z]
rule z == 1; [x, y, z]
a := b + 1; b := c + 1; c := 7;
[a, b, c]
b := 5; [a, b, c]
c := 7; b := c + 1; a := b + 1; [a, b, c]
p := q + 1; rule q == r + 1; r := 7; [p, q, r]
r := 1; [p, q, r]

-- Input for page RecurrenceRelations
<<fib>>
<<chebyshev>>
@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}