aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/KERNEL.ht
blob: 90120e6848e1c8b89d296c283dc710cfbfb6e193 (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\KernelXmpTitle}{Kernel}
\newcommand{\KernelXmpNumber}{9.37}
%
% =====================================================================
\begin{page}{KernelXmpPage}{9.37 Kernel}
% =====================================================================
\beginscroll
%

A {\it kernel} is a symbolic function application (such as
\spad{sin(x + y)}) or a symbol (such as \spad{x}).
More precisely, a non-symbol kernel over a set {\it S} is an operator applied
to a given list of arguments from {\it S}.
The operator has type \axiomType{BasicOperator}
(see \downlink{`BasicOperator'}{BasicOperatorXmpPage}\ignore{BasicOperator}) and the kernel object is usually part of
an expression object (see \downlink{`Expression'}{ExpressionXmpPage}\ignore{Expression}).

Kernels are created implicitly for you when you
create expressions.
\xtc{
}{
\spadpaste{x :: Expression Integer}
}
\xtc{
You can directly create a ``symbol'' kernel by using the
\axiomFunFrom{kernel}{Kernel} operation.
}{
\spadpaste{kernel x}
}
\xtc{
This expression has two different kernels.
}{
\spadpaste{sin(x) + cos(x) \bound{sincos}}
}
\xtc{
The operator \axiomFunFrom{kernels}{Expression} returns a list
of the kernels in an object of type \axiomType{Expression}.
}{
\spadpaste{kernels \% \free{sincos}}
}
\xtc{
This expression also has two different kernels.
}{
\spadpaste{sin(x)**2 + sin(x) + cos(x) \bound{sincos2}}
}
\xtc{
The \spad{sin(x)} kernel is used twice.
}{
\spadpaste{kernels \% \free{sincos2}}
}
\xtc{
An expression need not contain any kernels.
}{
\spadpaste{kernels(1 :: Expression Integer)}
}
\xtc{
If one or more kernels are present, one of them is
designated the {\it main} kernel.
}{
\spadpaste{mainKernel(cos(x) + tan(x))}
}
\xtc{
Kernels can be nested. Use \axiomFunFrom{height}{Kernel} to determine
the nesting depth.
}{
\spadpaste{height kernel x}
}
\xtc{
This has height 2 because the \spad{x} has height 1 and then we apply
an operator to that.
}{
\spadpaste{height mainKernel(sin x)}
}
\xtc{
}{
\spadpaste{height mainKernel(sin cos x)}
}
\xtc{
}{
\spadpaste{height mainKernel(sin cos (tan x + sin x))}
}
\xtc{
Use the \axiomFunFrom{operator}{Kernel} operation to extract the
operator component of the kernel.
The operator has type \axiomType{BasicOperator}.
}{
\spadpaste{operator mainKernel(sin cos (tan x + sin x))}
}
\xtc{
Use the \axiomFunFrom{name}{Kernel} operation to extract the name of the
operator component of the kernel.
The name has type \axiomType{Symbol}.
This is really just a shortcut for a two-step process of extracting the
operator and then calling \axiomFunFrom{name}{BasicOperator} on the
operator.
}{
\spadpaste{name mainKernel(sin cos (tan x + sin x))}
}
\Language{} knows about functions such as \axiomFun{sin}, \axiomFun{cos}
and so on and can make kernels and then expressions using them.
To create a kernel and expression using an arbitrary operator, use
\axiomFunFrom{operator}{BasicOperator}.
\xtc{
Now \spad{f} can be used to create symbolic function applications.
}{
\spadpaste{f := operator 'f \bound{f}}
}
\xtc{
}{
\spadpaste{e := f(x, y, 10) \free{f}\bound{e}}
}
\xtc{
Use the \axiomFunFrom{is?}{Kernel} operation to learn if the
operator component of a kernel is equal to a given operator.
}{
\spadpaste{is?(e, f) \free{f e}}
}
\xtc{
You can also use a symbol or a string as the second
argument to \axiomFunFrom{is?}{Kernel}.
}{
\spadpaste{is?(e, 'f) \free{e}}
}
\xtc{
Use the \axiomFunFrom{argument}{Kernel} operation to get a list containing
the argument component of a kernel.
}{
\spadpaste{argument mainKernel e \free{f}\free{e}}
}

Conceptually, an object of type \axiomType{Expression} can be thought
of a quotient of multivariate polynomials, where the ``variables''
are kernels.
The arguments of the kernels are again expressions and so the
structure recurses.
See \downlink{`Expression'}{ExpressionXmpPage}\ignore{Expression} for examples of using kernels to
take apart expression objects.
\endscroll
\autobuttons
\end{page}
%