In [ ]:
using BasisFunctions
using FrameFun
using DomainSets
using Plots
gr()

One-Dimensional Adaptive Approximation

Intervals


In [ ]:
D = Interval(-0.5,0.5)

Spaces


In [ ]:
F = FourierSpace(-1,1)
C = ChebyshevSpace()
Dictionary(F,4)

Functions


In [ ]:
f0 = x->x
f1 =(x)->cos(3*x)
f2 =(x)->cos(80*x)
f3 =(x)->cos(10*x.^2)

FeFun

Default is a 1D Fourier approximation on [-1,1] with extended domain [-2,2]


In [ ]:
FF = FeFun(f0)

In [ ]:
plot(FF,plot_ext=true,layout=2)
plot!(f0,FF,plot_ext=true,subplot=2)

But you can add your own domains also


In [ ]:
FF = FeFun(f0,Omega=Interval(-1,.1),Gamma=Interval(-1.5,.1))

Constructors


In [ ]:
FC1 = FunConstructor(F, D)
F1 = FC1(f0)

In [ ]:
F1 = FC1(f0,afun=FrameFun.fun_simple)

In [ ]:
plot(abs.(coefficients(F1)),yscale=:log10)

In [ ]:
F1 = FC1(f0,afun=FrameFun.fun_greedy)

In [ ]:
plot(abs.(coefficients(F1)),yscale=:log10)

In [ ]:
plot(F1,f0)

In [ ]:
FC2 = FunConstructor(C, Interval(-.5,.5))
F2 = FC2(f2)

In [ ]:
plot(F2,f2)

In [ ]:
FC3 = FunConstructor(F, Interval(-1.0,-0.5)Interval(-0.2,0.5))
F3 = FC3(f3, max_logn_coefs=12, solver=AZSolver)
F3 = FC3(f3, max_logn_coefs=12, solver=DirectSolver)

In [ ]:
l = @layout [Plots.grid(1,1); Plots.grid(1,2)]
plot(F3, layout=l)
plot!(F3, subplot=2, plot_ext=true)
plot!(F3,f3, subplot=3)

Extra functionality


In [ ]:
x = FC1(identity)

In [ ]:
f4 = x->sin(cos(x))
F4 = sin(cos(x))

In [ ]:
plot(F4,f4;layout=2)
plot!(F4;subplot=2)

In [ ]:
f5 = x->exp(cos(100x))
F5 = exp(cos(100x); max_logn_coefs=10)

In [ ]:
plot(F5,f5)

2D approximations

FeFun


In [ ]:
FF = FeFun((x,y)->exp(x-y),2,Omega=disk(),adaptive_verbose=true,cutoff=1e-5)

In [ ]:
plot(FF)

In [ ]:
gr()

Constructors


In [ ]:
D = Interval(0.,.5)^2
FF = FourierSpace()FourierSpace()
f = (x,y) -> exp(y*2*x)
FC = FunConstructor(FF, D)

In [ ]:
F0 = FC(f,tol=1e-12, max_logn_coefs=12)
F1 = FC(f,tol=1e-12, max_logn_coefs=12, solver=AZSolver)
F2 = FC(f,tol=1e-12, max_logn_coefs=12, solver=DirectSolver)

In [ ]:
plot(F1,f)

In [ ]:


In [ ]: