julia (v1.2)> f = Fun(cos);
julia (v1.2)> f(.1)
0.9950041652780257
julia (v1.2)> f(.1 + .1im)
0.0
julia (v1.2)> f(.1 + .0im)
0.9950041652780257 + 0.0im
julia (v1.2)> g = Fun(Chebyshev(), randn(Complex{Float64}, 20));
julia (v1.2)> g(.1)
2.1013219596855888 - 0.11052912191219874im
julia (v1.2)> g(.1 + .1im)
0.0 + 0.0im
julia (v1.2)> cos(.1 + .1im)
0.9999833333373015 - 0.00999998888888977im
Circle
or Segment
extrapolate(f,x)
in ApproxFun if you wish
using ApproxFun, Plots, LinearAlgebra
const c₀ = 3.0*10^8
d = Circle(0.0, 1.0, true) # Defines a circle
Δ = Laplacian(d) # Represent the Laplacian
f = ones(∂(d)) # one at the boundary
ω = Interval(0.0..10.0^9)
k = ω/c₀
u = \([Dirichlet(d); Δ+k*I], [f;0.]; # Solve the PDE
tolerance=1E-5)
surface(u) # Surface plot
I get the error 'Implement Laplacian(Laurant(:clock:), 1)'
When looking in to the code for ApproxFun, i can find no reference to the laplacian, only a confusing macro for implementing general derivative operators.
Where would I go to work out how to implement new Operators?
I was also wondering if it was yet possible to build spaces of arbitrary dimension to solve 3D PDEs, possibly with extra non spatial dimensions to represent free parameters
Disk()
? That sort of existed at one point but the code is crusty. We do have a version in MultivariateOrthogonalPolynomials.jl which uses @MikaelSlevinsky’s awesome FastTransform to do function approximation on the disk, but there’s no build script for that
PeriodicInterval
was updated to PeriodicSegment
in the source tree, but the Latest version at github.io is that out of date.
H=Fun(x->(0<x))
, the package returns ┌ Warning: Maximum number of coefficients 1048577 reached in constructing Fun.
└ @ ApproxFunBase /Users/guardian/.julia/packages/ApproxFunBase/RLdLv/src/constructors.jl:138
MethodError: no method matching ^(::ApproxFun.DualFun{Fun{Chebyshev{Interval{:closed,:closed,Int64},Float64},Float64,Array{Float64,1}},ConstantOperator{Float64,Chebyshev{Interval{:closed,:closed,Int64},Float64}}}, ::Float64)
Closest candidates are:
^(!Matched::Missing, ::Number) at missing.jl:115
^(!Matched::Float64, ::Float64) at math.jl:870
^(!Matched::Irrational{:ℯ}, ::Number) at mathconstants.jl:91
...
Stacktrace:
[1] (::var"#65#66")(::ApproxFun.DualFun{Fun{Chebyshev{Interval{:closed,:closed,Int64},Float64},Float64,Array{Float64,1}},ConstantOperator{Float64,Chebyshev{Interval{:closed,:closed,Int64},Float64}}}) at ./In[49]:6
[2] newton(::var"#65#66", ::Fun{Chebyshev{Interval{:closed,:closed,Int64},Float64},Float64,Array{Float64,1}}; maxiterations::Int64, tolerance::Float64) at /projects/d1d068b5-3a9d-4e16-9252-52734dea2c8e/.julia/packages/ApproxFun/IC3js/src/Extras/autodifferentiation.jl:98
[3] newton(::Function, ::Fun{Chebyshev{Interval{:closed,:closed,Int64},Float64},Float64,Array{Float64,1}}) at /projects/d1d068b5-3a9d-4e16-9252-52734dea2c8e/.julia/packages/ApproxFun/IC3js/src/Extras/autodifferentiation.jl:95
[4] top-level scope at In[49]:7
x = Fun(identity, 0..10)
n = 2.3
u₀ = 0.0x # initial guess
N = u -> [u'(0), u(0)-1, x*u'' + 2*u' + x*u^n]
u = newton(N, u₀) # perform Newton iteration in function space
plot(u)
Hello ApproxFun devs; I am solving a nonlinear ODE problem over a domain that could include a singularity for the function. The goal is to stop the solution before it gets there, but its location is not known a priori. Just by extending the endpoint of the domain, I can go from getting a converged solution to the following error:
ERROR: MethodError: no method matching setdomain(::ApproxFunBase.PiecewiseSpace{Tuple{ApproxFunOrthogonalPolynomials.Chebyshev{DomainSets.ChebyshevInterval{Float64},Float64},ApproxFunSingularities.JacobiWeight{ApproxFunOrthogonalPolynomials.Chebyshev{IntervalSets.Interval{:closed,:closed,Float64},Float64},IntervalSets.Interval{:closed,:closed,Float64},Float64,Int64},ApproxFunSingularities.JacobiWeight{ApproxFunOrthogonalPolynomials.Chebyshev{IntervalSets.Interval{:closed,:closed,Float64},Float64},IntervalSets.Interval{:closed,:closed,Float64},Float64,Int64}},DomainSets.UnionDomain{Float64,Tuple{DomainSets.ChebyshevInterval{Float64},IntervalSets.Interval{:closed,:closed,Float64},IntervalSets.Interval{:closed,:closed,Float64}}},Float64}, ::IntervalSets.Interval{:closed,:closed,Float64}
and if I extend it further, it results in memory exhaustion. All three of the domain spans (working, MethodError, memory exhaustion) include the singularity. I have tried providing a coarse value to the tolerances
argument to newton()
and it doesn't change the outcomes. This is on ApproxFun 0.12.5. Ideally the whole thing would error out consistently and gracefully so it could be caught; certainly the MethodError
and memory exhaustion shouldn't be occurring.
I'd prefer not to post my code publicly, but would be happy to make available to any ApproxFun devs.