Skip to content

Commit

Permalink
Don't display intervals (#898)
Browse files Browse the repository at this point in the history
* don't display intervals

* skip manuals in doctest
  • Loading branch information
jishnub authored Jul 29, 2023
1 parent b26907b commit 1b8473f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
24 changes: 13 additions & 11 deletions docs/src/usage/constructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,32 @@ end

`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:

```jldoctest
```jldoctest Fun
julia> x = Fun(identity,-1..1);
julia> f = exp(x);
julia> g = f/sqrt(1-x^2);
julia> space(f) == Chebyshev(-1..1)
true
```
In this example, `f` is a `Fun` that corresponds to a Chebyshev interpolant to `exp(x)`, and evaluating `f(x)` will generate a close approximation to `exp(x)`. In this case, the space is automatically inferred from the domain.

julia> space(f) # Output is pretty version of Chebyshev(Interval(-1.0,1.0))
Chebyshev(-1 .. 1)
`Fun`s may also incorporate singularities at the edges of the domain. In such cases, if the variable is in a polynomial space, the resulting space is a [`JacobiWeight`](@ref), which factors out the singularity and interpolates the residual analytical component. Perhaps this is best illustrated through an example:
```jldoctest Fun
julia> g = f/sqrt(1-x^2);
julia> space(g) # Output is pretty version of JacobiWeight(-0.5, -0.5, -1..1)
(1-x^2)^-0.5[Chebyshev(-1 .. 1)]
julia> space(g) == JacobiWeight(-0.5, -0.5, Chebyshev(-1..1))
true
```
The function `g` in this case is expanded the basis ``(1-x^2)^{1/2}\;T_n(x)``, where ``T_n(x)`` are Chebyshev polynomials. This is equivalent to expanding the function `f` in a Chebyshev basis.

The absolute value is another case where the space of the output is inferred from the operation:

```jldoctest abs_space
julia> f = Fun(x->cospi(5x),-1..1);
julia> f = Fun(x->cospi(5x), -1..1);
julia> g = abs(f);
julia> space(f)
Chebyshev(-1 .. 1)
julia> space(g) isa ContinuousSpace # Piecewise continous functions
true
Expand All @@ -43,7 +45,7 @@ that of continuous functions over the piecewise domain:
```jldoctest abs_space
julia> p = [-1; roots(f); 1];
julia> segments = @views [Segment(x,y) for (x,y) in zip(p[1:end-1], p[2:end])];
julia> segments = [Segment(x,y) for (x,y) in zip(p[1:end-1], p[2:end])];
julia> components(domain(g)) == segments
true
Expand Down
6 changes: 3 additions & 3 deletions docs/src/usage/spaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ and the basis becomes

`SumSpace((space_1,space_2,…,space_n))` represents the direct sum of the spaces, where evaluation is defined by adding up each component. A simple example is the following, showing that the coefficients are stored by interlacing:

```jldoctest
```jldoctest sumspace
julia> x = Fun(identity, -1..1);
julia> f = cos(x-0.1)*sqrt(1-x^2) + exp(x);
julia> space(f) # isa SumSpace
(1-x^2)^0.5[Chebyshev(-1 .. 1)] ⊕ Chebyshev(-1 .. 1)
julia> space(f) == JacobiWeight(0.5, 0.5, Chebyshev(-1..1)) + Chebyshev(-1..1)
true
julia> a, b = components(f);
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ DocMeta.setdocmeta!(ApproxFunBase, :DocTestSetup, :(using ApproxFun); recursive=
DocMeta.setdocmeta!(ApproxFun, :DocTestSetup, :(using ApproxFun); recursive=true)

@testset "doctests" begin
doctest(ApproxFun)
doctest(ApproxFun, manual=false)
doctest(ApproxFunBase, manual=false)
end

Expand Down

0 comments on commit 1b8473f

Please sign in to comment.