Library
Domains
ApproxFunOrthogonalPolynomials.Arc — TypeArc(c,r,(θ₁,θ₂))represents the arc centred at c with radius r from angle θ₁ to θ₂.
ApproxFunFourier.Circle — TypeCircle(c,r,o)represents the circle centred at c with radius r which is positively (o=true) or negatively (o=false) oriented.
ApproxFun.Curve — TypeCurve Represents a domain defined by the image of a Fun. Example usage would be
x=Fun(1..2)
Curve(exp(im*x)) # represents an arcApproxFunFourier.Disk — TypeDisk(c,r)represents the disk centred at c with radius r.
ApproxFunBase.Segment — TypeSegment(a,b)represents a line segment from a to b. In the case where a and b are real and a < b, then this is is equivalent to an Interval(a,b).
IntervalSets.Interval — TypeAn Interval{L,R}(left, right) where L,R are :open or :closed is an interval set containg x such that
left ≤ x ≤ rightifL == R == :closedleft < x ≤ rightifL == :openandR == :closedleft ≤ x < rightifL == :closedandR == :open, orleft < x < rightifL == R == :open
ApproxFunOrthogonalPolynomials.Line — TypeLine{a}(c)represents the line at angle a in the complex plane, centred at c.
ApproxFunFourier.PeriodicSegment — TypePeriodicSegment(a,b)represents a periodic interval from a to b, that is, the point b is identified with a.
DomainSets.Point — TypePoint(x)represents a single point at x.
DomainSets.ProductDomain — TypeA ProductDomain represents the cartesian product of other domains.
ApproxFunOrthogonalPolynomials.Ray — TypeRay{a}(c,L,o)represents a scaled ray (with scale factor L) at angle a starting at c, with orientation out to infinity (o = true) or back from infinity (o = false).
DomainSets.UnionDomain — Typeusing DomainSets
A UnionDomain represents the union of a set of domains.
DomainSets.∂ — FunctionReturn the boundary of the given domain as a domain.
Accessing information about a spaces
ApproxFunBase.canonicalspace — Functioncanonicalspace(s::Space)Return a space that is used as a default to implement missing functionality, e.g., evaluation. Implement a Conversion operator or override coefficients to support this.
Examples
julia> f = Fun(x->x^2, NormalizedLegendre());
julia> ApproxFunBase.canonicalspace(f)
Legendre()ApproxFunBase.itransform — Functionitransform(s::Space,coefficients::AbstractVector)Transform coefficients back to values. Defaults to using canonicalspace as in transform.
Examples
julia> F = Fun(x->x^2, Chebyshev())
Fun(Chebyshev(), [0.5, 0.0, 0.5])
julia> itransform(Chebyshev(), coefficients(F)) ≈ values(F)
true
julia> itransform(Chebyshev(), [0.5, 0, 0.5])
3-element Vector{Float64}:
0.75
0.0
0.75ApproxFunBase.transform — Functiontransform(s::Space, vals::Vector)Transform values on the grid specified by points(s,length(vals)) to coefficients in the space s. Defaults to coefficients(transform(canonicalspace(space),values),canonicalspace(space),space)
Examples
julia> F = Fun(x -> x^2, Chebyshev());
julia> coefficients(F)
3-element Vector{Float64}:
0.5
0.0
0.5
julia> transform(Chebyshev(), values(F)) ≈ coefficients(F)
true
julia> v = map(F, points(Chebyshev(), 4)); # custom grid
julia> transform(Chebyshev(), v)
4-element Vector{Float64}:
0.5
0.0
0.5
0.0ApproxFunBase.evaluate — Functionevaluate(coefficients::AbstractVector, sp::Space, x)Evaluates the expansion at a point x that lies in domain(sp). If x is not in the domain, the returned value will depend on the space, and should not be relied upon. See extrapolate to evaluate a function at a value outside the domain.
DomainSets.dimension — Methoddimension(s::Space)Return the dimension of s, which is the maximum number of coefficients.
Inbuilt spaces
ApproxFunBase.SequenceSpace — TypeSequenceSpace is the space of all sequences, i.e., infinite vectors. Also denoted ℓ⁰.
ApproxFunBase.ConstantSpace — TypeConstantSpace is the 1-dimensional scalar space.
ApproxFunOrthogonalPolynomials.Chebyshev — TypeChebyshev() is the space spanned by the Chebyshev polynomials
T_0(x),T_1(x),T_2(x),…where T_k(x) = cos(k*acos(x)). This is the default space as there exists a fast transform and general smooth functions on [-1,1] can be easily resolved.
ApproxFunOrthogonalPolynomials.Hermite — TypeHemite(L) represents H_k(sqrt(L) * x) where H_k are Hermite polynomials. Hermite() is equivalent to Hermite(1.0).
ApproxFunOrthogonalPolynomials.Jacobi — TypeJacobi(b,a) represents the space spanned by Jacobi polynomials P_k^{(a,b)}, which are orthogonal with respect to the weight (1+x)^β*(1-x)^α
ApproxFunOrthogonalPolynomials.Laguerre — TypeLaguerre(α) is a space spanned by generalized Laguerre polynomials Lₙᵅ(x) 's on (0, Inf), which satisfy the differential equations
xy'' + (α + 1 - x)y' + ny = 0Laguerre() is equivalent to Laguerre(0) by default.
ApproxFunOrthogonalPolynomials.Ultraspherical — TypeUltraspherical(λ) is the space spanned by the ultraspherical polynomials
C_0^{(λ)}(x),C_1^{(λ)}(x),C_2^{(λ)}(x),…Note that λ=1 this reduces to Chebyshev polynomials of the second kind: C_k^{(1)}(x) = U_k(x). For λ=1/2 this also reduces to Legendre polynomials: C_k^{(1/2)}(x) = P_k(x).
ApproxFunFourier.Taylor — TypeTaylor() is the space spanned by [1,z,z^2,...]. This is a type alias for Hardy{true}.
ApproxFunFourier.Hardy — TypeHardy{false}() is the space spanned by [1/z,1/z^2,...]. Hardy{true}() is the space spanned by [1,z,z^2,...].
ApproxFunFourier.Fourier — TypeFourier()The space spanned by the trigonemtric polynomials
1, sin(θ), cos(θ), sin(2θ), cos(2θ), …See also Laurent.
Fourier(d::Domain)The space spanned by the trigonemtric polynomials
1, sin(2pi/L*θ), cos(2pi/L*θ), sin(2pi/L*2θ), cos(2pi/L*2θ), …for a domain with a period L.
ApproxFunFourier.Laurent — TypeLaurent()The space spanned by the complex exponentials
1,exp(-im*θ),exp(im*θ),exp(-2im*θ),…See also Fourier.
Laurent(d::Domain)The space spanned by the complex exponentials
1, exp(-im * (2pi/L*θ)), exp(im * (2pi/L*θ)), exp(-2im * (2pi/L*θ)), …for a domain with a period L.
ApproxFunFourier.CosSpace — TypeCosSpace()The space spanned by [1, cos θ, cos 2θ, ...]
CosSpace(d::Domain)The space spanned by [1,cos(2pi/L*θ), cos(2pi/L*2θ), ...] for a domain with a period L
ApproxFunFourier.SinSpace — TypeSinSpace()The space spanned by [sin θ, sin 2θ, ...]
SinSpace(d::Domain)The space spanned by [1, sin(2pi/L*θ), sin(2pi/L*2θ), ...] for a domain with a period L
ApproxFunSingularities.JacobiWeight — TypeJacobiWeight(β,α,s::Space)weights a space s by a Jacobi weight, which on -1..1 is (1+x)^β*(1-x)^α. For other domains, the weight is inferred by mapping to -1..1.
ApproxFunSingularities.LogWeight — TypeLogWeight(β,α,s::Space)represents a function on -1..1 weighted by log((1+x)^β*(1-x)^α). For other domains, the weight is inferred by mapping to -1..1.
ApproxFunBase.ArraySpace — TypeArraySpace(s::Space,dims...)is used to represent array-valued expansions in a space s. The coefficients are of each entry are interlaced.
For example,
f = Fun(x->[exp(x),sin(x)],-1..1)
space(f) == ArraySpace(Chebyshev(),2)ApproxFunBase.TensorSpace — TypeTensorSpace(a::Space,b::Space)represents a tensor product of two 1D spaces a and b. The coefficients are interlaced in lexigraphical order.
For example, consider
Fourier()*Chebyshev() # returns TensorSpace(Fourier(),Chebyshev())This represents functions on [-π,π) x [-1,1], using the Fourier basis for the first argument and Chebyshev basis for the second argument, that is, φ_k(x)T_j(y), where
φ_0(x) = 1,
φ_1(x) = sin x,
φ_2(x) = cos x,
φ_3(x) = sin 2x,
φ_4(x) = cos 2x
…By Choosing (k,j) appropriately, we obtain a single basis:
φ_0(x)T_0(y) (= 1),
φ_0(x)T_1(y) (= y),
φ_1(x)T_0(y) (= sin x),
φ_0(x)T_2(y), …Constructing a Fun
ApproxFunBase.Fun — TypeFun(s::Space, coefficients::AbstractVector)Return a Fun with the specified coefficients in the space s
Examples
julia> f = Fun(Fourier(), [1,1]);
julia> f(0.1) == 1 + sin(0.1)
true
julia> f = Fun(Chebyshev(), [1,1]);
julia> f(0.1) == 1 + 0.1
trueFun(f, s::Space)Return a Fun representing the function, number, or vector f in the space s. If f is vector-valued, it Return a vector-valued analogue of s.
Examples
julia> f = Fun(x->x^2, Chebyshev())
Fun(Chebyshev(), [0.5, 0.0, 0.5])
julia> f(0.1) == (0.1)^2
trueFun(f, d::Domain)Return Fun(f, Space(d)), that is, it uses the default space for the specified domain.
Examples
julia> f = Fun(x->x^2, 0..1);
julia> f(0.1) ≈ (0.1)^2
trueFun(s::Space)Return Fun(identity,s)
Examples
julia> x = Fun(Chebyshev())
Fun(Chebyshev(), [0.0, 1.0])
julia> x(0.1)
0.1Fun(f)Return Fun(f, Chebyshev())
Examples
julia> f = Fun(x->x^2)
Fun(Chebyshev(), [0.5, 0.0, 0.5])
julia> f(0.1) == (0.1)^2
trueFun()Return Fun(identity, Chebyshev()), which represents the identity function in -1..1.
Examples
julia> f = Fun(Chebyshev())
Fun(Chebyshev(), [0.0, 1.0])
julia> f(0.1)
0.1Base.ones — Methodones(d::Space)Return the Fun that represents the function one on the specified space.
Examples
julia> ones(Chebyshev())
Fun(Chebyshev(), [1.0])Base.zeros — Methodzeros(d::Space)Return the Fun that represents the function one on the specified space.
Examples
julia> zeros(Chebyshev())
Fun(Chebyshev(), [0.0])Accessing information about a Fun
ApproxFunBase.domain — Functiondomain(f::Fun)Return the domain that f is defined on.
Examples
julia> f = Fun(x->x^2);
julia> domain(f)
-1.0..1.0 (Chebyshev)
julia> f = Fun(x->x^2, 0..1);
julia> domain(f)
0..1ApproxFunBase.coefficients — Functioncoefficients(f::Fun) -> VectorReturn the coefficients of f, corresponding to the space space(f).
Examples
julia> f = Fun(x->x^2)
Fun(Chebyshev(), [0.5, 0.0, 0.5])
julia> coefficients(f)
3-element Vector{Float64}:
0.5
0.0
0.5coefficients(f::Fun, s::Space) -> VectorReturn the coefficients of f in the space s, which may not be the same as space(f).
Examples
julia> f = Fun(x->(3x^2-1)/2);
julia> coefficients(f, Legendre()) ≈ [0, 0, 1]
truecoefficients(cfs::AbstractVector, fromspace::Space, tospace::Space) -> VectorConvert coefficients in fromspace to coefficients in tospace
Examples
julia> f = Fun(x->(3x^2-1)/2);
julia> coefficients(f, Chebyshev(), Legendre()) ≈ [0,0,1]
true
julia> g = Fun(x->(3x^2-1)/2, Legendre());
julia> coefficients(f, Chebyshev(), Legendre()) ≈ coefficients(g)
trueApproxFunBase.extrapolate — Functionextrapolate(f::Fun,x)Return an extrapolation of f from its domain to x.
Examples
julia> f = Fun(x->x^2)
Fun(Chebyshev(), [0.5, 0.0, 0.5])
julia> domain(f)
-1.0..1.0 (Chebyshev)
julia> extrapolate(f, 2)
4.0ApproxFunBase.ncoefficients — Functionncoefficients(f::Fun) -> IntegerReturn the number of coefficients of a fun
Examples
julia> f = Fun(x->x^2)
Fun(Chebyshev(), [0.5, 0.0, 0.5])
julia> ncoefficients(f)
3ApproxFunBase.points — Functionpoints(f::Fun)Return a grid of points that f can be transformed into values and back.
Examples
julia> f = Fun(x->x^2);
julia> chebypts(n) = [cos((2i+1)pi/2n) for i in 0:n-1];
julia> points(f) ≈ chebypts(ncoefficients(f))
truepoints(s::Space,n::Integer)Return a grid of approximately n points, for which a transform exists from values at the grid to coefficients in the space s.
Examples
julia> chebypts(n) = [cos((2i+1)pi/2n) for i in 0:n-1];
julia> points(Chebyshev(), 4) ≈ chebypts(4)
trueApproxFunBase.space — Functionspace(f::Fun)Return the space of f.
Examples
julia> f = Fun(x->x^2)
Fun(Chebyshev(), [0.5, 0.0, 0.5])
julia> space(f)
Chebyshev()Base.values — Methodvalues(f::Fun)Return f evaluated at points(f).
Examples
julia> f = Fun(x->x^2)
Fun(Chebyshev(), [0.5, 0.0, 0.5])
julia> values(f)
3-element Vector{Float64}:
0.75
0.0
0.75
julia> map(x->x^2, points(f)) ≈ values(f)
trueBase.stride — Methodstride(f::Fun)Return the stride of the coefficients, checked numerically
Modify a Fun
ApproxFunBase.reverseorientation — Functionreverseorientation(f::Fun)Return f on a reversed orientated contour.
ApproxFunBase.setdomain — Functionsetdomain(f::Fun, d::Domain)Return f projected onto domain.
The new function may differ from the original one, as the coefficients are left unchanged.
Examples
julia> f = Fun(x->x^2)
Fun(Chebyshev(), [0.5, 0.0, 0.5])
julia> setdomain(f, 0..1)
Fun(Chebyshev(0..1), [0.5, 0.0, 0.5])Base.chop — Methodchop(f::Fun, tol) -> FunReduce the number of coefficients by dropping the tail that is below the specified tolerance.
Examples
julia> f = Fun(Chebyshev(), [1,2,3,0,0,0])
Fun(Chebyshev(), [1, 2, 3, 0, 0, 0])
julia> chop(f)
Fun(Chebyshev(), [1, 2, 3])Bivariate Fun
ApproxFunBase.LowRankFun — TypeLowRankFun gives an approximation to a bivariate function in low rank form.
Operators
ApproxFunBase.Operator — TypeOperator{T}is an abstract type to represent linear operators between spaces.
BandedMatrices.bandwidths — Methodbandwidths(op::Operator)Return the bandwidth of op in the form (l,u), where l ≥ 0 represents the number of subdiagonals and u ≥ 0 represents the number of superdiagonals.
ApproxFunBase.domainspace — Functiondomainspace(op::Operator)gives the domain space of op. That is, op*f will first convert f to a Fun in the space domainspace(op) before applying the operator.
ApproxFunBase.rangespace — Functionrangespace(op::Operator)gives the range space of op. That is, op*f will return a Fun in the space rangespace(op), provided f can be converted to a Fun in domainspace(op).
Base.getindex — Methodop[k,j]Return the kth coefficient of op*Fun([zeros(j-1);1],domainspace(op)).
Base.getindex — Methodop[f::Fun]constructs the operator op * Multiplication(f), that is, it multiplies on the right by f first. Note that op * f is different: it applies op to f.
Examples
julia> x = Fun()
Fun(Chebyshev(), [0.0, 1.0])
julia> D = Derivative()
ConcreteDerivative : ApproxFunBase.UnsetSpace() → ApproxFunBase.UnsetSpace()
julia> D2 = D[x]
TimesOperator : ApproxFunBase.UnsetSpace() → ApproxFunBase.UnsetSpace()
julia> twox = D2 * x
Fun(Ultraspherical(1), [0.0, 1.0])
julia> twox(0.1) ≈ 2 * 0.1
trueBase.:\ — Method\(A::Operator,b;tolerance=tol,maxlength=n)solves a linear equation, usually differential equation, where A is an operator or array of operators and b is a Fun or array of funs. The result u will approximately satisfy A*u = b.
LinearAlgebra.qr — Methodqr(A::Operator)returns a cached QR factorization of the Operator A. The result QR enables solving of linear equations: if u=QR, then u approximately satisfies A*u = b.
LazyArrays.cache — Methodcache(op::Operator)Caches the entries of an operator, to speed up multiplying a Fun by the operator.
Inbuilt operators
ApproxFunBase.Conversion — TypeConversion(fromspace::Space,tospace::Space)Represent a conversion operator between fromspace and tospace, when available.
ApproxFunBase.Derivative — TypeDerivative(sp::Space,k::Int) represents the k-th derivative on sp.
Derivative(sp::Space,k::Vector{Int}) represents a partial derivative on a multivariate space. For example,
Dx = Derivative(Chebyshev()^2,[1,0]) # ∂/∂x
Dy = Derivative(Chebyshev()^2,[0,1]) # ∂/∂yDerivative(sp::Space) represents the first derivative Derivative(sp,1).
Derivative(k) represents the k-th derivative, acting on an unset space. Spaces will be inferred when applying or manipulating the operator.
Derivative() represents the first derivative on an unset space. Spaces will be inferred when applying or manipulating the operator.
ApproxFunBase.Dirichlet — TypeDirichlet(sp,k) is the operator associated with restricting the k-th derivative on the boundary for the space sp.
Dirichlet(sp) is the operator associated with restricting the the boundary for the space sp.
Dirichlet() is the operator associated with restricting on the the boundary.
ApproxFunBase.Evaluation — TypeEvaluation(sp,x,k) is the functional associated with evaluating the k-th derivative at a point x for the space sp.
Evaluation(sp,x) is the functional associated with evaluating at a point x for the space sp.
Evaluation(x) is the functional associated with evaluating at a point x.
ApproxFunBase.Integral — TypeIntegral(sp::Space,k::Int) represents a k-th integral on sp. There is no guarantee on normalization.
Integral(sp::Space) represents the first integral Integral(sp,1).
Integral(k) represents the k-th integral, acting on an unset space. Spaces will be inferred when applying or manipulating the operator.
Intergral() represents the first integral on an unset space. Spaces will be inferred when applying or manipulating the operator.
ApproxFunBase.Laplacian — TypeLaplacian(sp::Space) represents the laplacian on space sp.
Laplacian() represents the laplacian on an unset space. Spaces will be inferred when applying or manipulating the operator.
ApproxFunBase.Multiplication — TypeMultiplication(f::Fun,sp::Space) is the operator representing multiplication by f on functions in the space sp.
Multiplication(f::Fun) is the operator representing multiplication by f on an unset space of functions. Spaces will be inferred when applying or manipulating the operator.
ApproxFunBase.Neumann — FunctionNeumann(sp) is the operator associated with restricting the normal derivative on the boundary for the space sp. At the moment it is implemented as Dirichlet(sp,1).
Neumann() is the operator associated with restricting the normal derivative on the boundary.