Hi Stèphane,
Nonlinear is not built in, but it’s easy enough to do by hand with
Newton iteration in function space. Let me know if there is any confusion with
the code below. I suppose I could just add a “nonlinsolve” routine that
bundles this up.
(I am on the latest branch so this may or may not work on the 0.0.1
tag.)
Cheers,
Sheehan
x=Fun(identity,[-1.,1.])
d=x.domain
B=dirichlet(d)
D=diff(d)
# Sets up L and g for equation in the form Lu + g(u)-1==0
L=D^2 + 2(1-x.^2)*D
g=u->u.^2;gp=u->2u
u=0.x # initial guess for the solution is zero
for k=1:5
u=u-[B,L+gp(u)]\[0.,0.,L*u+g(u)-1.];
end
norm(diff(u,2) + 2(1-x.^2).*diff(u) + g(u) -1) # This equals 0.0
On 12 Jun 2014, at 1:02 am, 'Stéphane Laurent' via julia-users
<[email protected]> wrote:
> Hello Sheehan,
>
> I have unsuccessfully tried to understand how works the differential
> equation solver (I do not understand the Airy example).
>
> It would be nice to have an example of code for a simple BVP such as :
>
> u" + 2(1-x^2)u + u^2 = 1 , u(-1) = u(1) = 0
>
> Regards,
> Stéphane
>
> Le lundi 24 mars 2014 02:04:25 UTC+1, Sheehan Olver a écrit :
>
> I tagged a new release for ApproxFun
> (https://github.com/dlfivefifty/ApproxFun) with major new features that might
> interest people. Below are ODE solving and random number sampling examples,
> find more in ApproxFun/examples. The code is meant as alpha quality, so
> don't expect too much beyond the examples. There is rudimentary support for
> PDE solving (e.g. Helmholtz in a square), but it's reliability is limited
> without a better Lyapanov solver
> (https://github.com/JuliaLang/julia/issues/5814).
>
> Cheers,
>
> Sheehan
>
>
>
>
> Pkg.add("ApproxFun")
> using ApproxFun
>
> ODE Solving: solve the Airy equation on [-1000,10]
>
> x=Fun(identity,[-2000.,10.])
> d=x.domain
> D=diff(d)
> ai=[dirichlet(d),D^2 - x]\[airyai(-2000.),0.]
> plot(ai)
>
>
>
>
> Random number sampling: Sample a 2D Cauchy distribution on (-∞,∞)^2
>
> f = Fun2D((x,y)->1./(2π.*(x.^2 .+ y.^2 .+ 1).^(3/2)),Line(),Line())
> r = sample(f,100)
>
>