JuliaApproximation / ApproxFun.jl

Julia package for function approximation
http://juliaapproximation.github.io/ApproxFun.jl/
Other
541 stars 70 forks source link

Volterra equation #570

Closed robocop closed 6 years ago

robocop commented 6 years ago

Hello!

I tried to solve a simple Volterra equation using ApproxFun.

Here is my code:

using ApproxFun

d = Interval(0.0, 2.0)
K = Fun((x,y) -> exp(-(x-y)), d^2)
V = DefiniteIntegral(Chebyshev(d))[LowRankFun((x,y)-> y <= x ? K(x,y) : 0.0,d^2)]
one = Fun(x->1.0, d)

u = (I - V)\one;

That is the equation is the following:

u(x) = int_0^x{K(x-y) u(y) dy} + 1; with K(x, y) = exp(-(x-y))

However I got the following error:

WARNING: Maximum number of coefficients 1048577 reached in constructing Fun. Julia has exited.

I suspect the operator V cannot be interpolated properly. What should I do in this case?

Note that this code is working for simpler K such as K(x, y) = x-y

Thanks for yor help

dlfivefifty commented 6 years ago

Use Volterra:

d = Interval(0.0, 2.0)
K = Fun((x,y) -> exp(-(x-y)), d^2)
V = Volterra(Legendre(d))[LowRankFun(K,d^2)]
one = Fun(x->1.0, d)

u = (I - V)\one;

# check result
x = Fun(d)
u(0.1)-cumsum(exp(-(0.1-x))*u)(0.1) ≈ 1

It's mathematically impossible to do a low rank approximation of a triangular function.

robocop commented 6 years ago

Thank you! It works perfectly