JuliaApproximation / JuliaApproximation/ApproxFun.jl

Cannot use `Integral` in Newton solver

Open
#928 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
559
Forks
71
PR merge metrics
No merged PRs in 30d

Description

I want to solve a nonlinear PDE where I impose, instead of a boundary condition, that the integral over the domain is zero. I don't know how to express this – the way I tried leads to an error (see below).

Things work if I impose that the solution is zero at a particular point (that's the second term u(0)). When I replace this by sum(Integral()*u), I receive an error about an unimplemented function.

julia> using ApproxFun

julia> newton(u -> [u(-1)-u(1), u(0), u''-1], Fun(x->1))
Fun(Chebyshev(), [0.25, 2.77556e-17, 0.25])

julia> newton(u -> [u(-1)-u(1), sum(Integral()*u), u''-1], Fun(x->1))
ERROR: MethodError: no method matching space(::ApproxFun.DualFun{Fun{Chebyshev{…}, Float64, Vector{…}}, ConstantOperator{Float64, Chebyshev{…}}})

Closest candidates are:
  space(::Fun)
   @ ApproxFunBase ~/.julia/packages/ApproxFunBase/1mBis/src/Fun.jl:339
  space(::ProductFun)
   @ ApproxFunBase ~/.julia/packages/ApproxFunBase/1mBis/src/Multivariate/ProductFun.jl:293
  space(::LowRankFun, ::Integer)
   @ ApproxFunBase ~/.julia/packages/ApproxFunBase/1mBis/src/Multivariate/LowRankFun.jl:348

I'd be happy to implement something, but as I'm new to the code I would need some pointers. For example, which function with what signature should be implemented?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the shown newton calls, then trace the Integral() constraint and the failing space(::ApproxFun.DualFun...) dispatch. Check the newton, Integral, and space entry points; done means the integral-constrained example runs without the MethodError and preserves the existing point-constraint behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.