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: README.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,11 @@ x = chebpoints(order, lb, ub) # an array of `SVector` from [StaticArrays.jl](htt
17
17
c =chebinterp(f.(x), lb, ub)
18
18
```
19
19
and then evaluate the interpolant for a point `y` (a vector)
20
-
via `c(y)`.
20
+
via `c(y)`. Alternatively, you can combine `chebpoints` and `chebinterp` into a single call:
21
+
```jl
22
+
c =chebinterp(f, order, lb, ub)
23
+
```
24
+
which evaluates the given function at Chebyshev points for you.
21
25
22
26
We also provide a function `chebgradient(c,y)` that returns a tuple `(c(y), ∇c(y))` of
23
27
the interpolant and its gradient at a point `y`. (You can also use automatic differentiation, e.g. via the [ForwardDiff.jl package](https://github.com/JuliaDiff/ForwardDiff.jl),
@@ -49,6 +53,7 @@ Here is an example interpolating the (highly oscillatory) 1d function `f(x) = si
49
53
f(x) =sin(2x +3cos(4x))
50
54
x =chebpoints(200, 0, 10)
51
55
c =chebinterp(f.(x), 0, 10)
56
+
# alternatively, c = chebinterp(f, 200, 0, 10)
52
57
```
53
58
We can then compare the exact function and its interpolant at a set of points:
54
59
```jl
@@ -90,6 +95,7 @@ g(x) = sin(x[1] + cos(x[2]))
90
95
lb, ub = [1,3], [2, 4] # lower and upper bounds of the domain, respectively
91
96
x =chebpoints((10,20), lb, ub)
92
97
c =chebinterp(g.(x), lb, ub)
98
+
# alternatively, c = chebinterp(g, (10,20), lb, ub)
93
99
```
94
100
Let's evaluate the interpolant at an arbitrary point `(1.2, 3.4)` and compare it to the exact value:
0 commit comments