You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/usage/constructors.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,14 @@
1
-
```@setup using-pkgs
2
-
using ApproxFun
1
+
```@meta
2
+
DocTestSetup = quote
3
+
using ApproxFun, LinearAlgebra
4
+
end
3
5
```
4
6
5
7
# Constructors
6
8
7
9
`Fun`s in ApproxFun are instances of Julia types with one field to store coefficients and another to describe the function space. Similarly, each function space has one field describing its domain, or another function space. Let's explore:
8
10
9
-
```@repl using-pkgs
11
+
```@repl
10
12
x = Fun(identity,-1..1);
11
13
f = exp(x);
12
14
g = f/sqrt(1-x^2);
@@ -16,7 +18,7 @@ space(g) # Output is pretty version of JacobiWeight(-0.5,-0.5,Interval(-1.0,1.0
16
18
17
19
The absolute value is another case where the space of the output is inferred from the operation:
18
20
19
-
```@repl using-pkgs
21
+
```@repl
20
22
f = Fun(x->cospi(5x),-1..1);
21
23
g = abs(f);
22
24
space(f)
@@ -51,7 +53,7 @@ x = Fun()
51
53
52
54
It is sometimes necessary to specify coefficients explicitly. This is possible via specifying the space followed by a vector of coefficients:
The `Chebyshev` space has the property that its derivatives are given by ultraspherical spaces:
51
53
52
-
```@repl using-pkgs
54
+
```@repl
53
55
Derivative(Chebyshev())
54
56
```
55
57
@@ -59,7 +61,7 @@ A particularly useful class of operators are _functionals_, which map from funct
59
61
60
62
As an example, the evaluation functional `f(0)` on `CosSpace` has the form:
61
63
62
-
```@repl using-pkgs
64
+
```@repl
63
65
B = Evaluation(CosSpace(),0)
64
66
B*f ≈ f(0)
65
67
```
@@ -68,7 +70,7 @@ As can be seen from the output, `rangespace(B)` is a `ConstantSpace(Point(0))`,
68
70
69
71
Closely related to functionals are operators with finite-dimensional range. For example, the `Dirichlet` operator represents the restriction of a space to its boundary. In the case, of `Chebyshev()`, this amounts to evaluation at the endpoints `±1`:
A `Multiplication` operator sends a `Fun` to a `Fun` in the corresponding space by multiplying a given function. The `Multiplication` operators are presented in matrix form in `ApproxFun`.
It is possible for domain space and range space to be different under `Mulitplication`.
89
91
90
-
```@repl using-pkgs
92
+
```@repl
91
93
c = Fun(θ -> cos(θ), CosSpace());
92
94
Multiplication(c, SinSpace())
93
95
```
@@ -116,14 +118,14 @@ where ``f_0 = 0``.
116
118
Operators can be algebraically manipulated, provided that the domain and range spaces are compatible, or can be made compatible. As a simple example, we can add the second derivative of a Fourier space to the
117
119
identity operator:
118
120
119
-
```@repl using-pkgs
121
+
```@repl
120
122
D2 = Derivative(Fourier(),2)
121
123
D2 + I
122
124
```
123
125
124
126
When the domain and range space are not the same, the identity operator becomes a conversion operator. That is, to represent `D+I` acting on the Chebyshev space, we would do the following:
125
127
126
-
```@repl using-pkgs
128
+
```@repl
127
129
D = Derivative(Chebyshev())
128
130
C = Conversion(Chebyshev(),Ultraspherical(1))
129
131
D + C
@@ -139,7 +141,7 @@ Now consider the Fredholm integral operator of the second kind:
139
141
140
142
We can construct this using
141
143
142
-
```@repl using-pkgs
144
+
```@repl
143
145
x = Fun();
144
146
Σ = DefiniteIntegral(Chebyshev())
145
147
L = I + exp(x)*Σ
@@ -167,7 +169,7 @@ Note that `Σ*exp(x)` applies the operator to a function. To construct the oper
167
169
168
170
It is often more convenient to not specify a space explicitly, but rather infer it when the operator is used. For example, we can construct `Derivative()`, which has the alias `𝒟`, and represents the first derivative on any space:
Note that `rangespace(D) ≠Chebyshev()`, hence the operators are not compatible. Therefore, it has thrown away its domain space, and thus this is equivalent to `Derivative(rangespace(D))*D`.
199
+
Note that `rangespace(D) ≠Chebyshev()`, hence the operators are not compatible. Therefore, it has thrown away its domain space, and thus this is equivalent to `Derivative(rangespace(D))*D`.
0 commit comments