# ApproxFun: defining a nonlinear differential operator

**URL:** https://discourse.julialang.org/t/approxfun-defining-a-nonlinear-differential-operator/15296
**Category:** Modelling & Simulations
**Created:** [September 21, 2018, 4:29pm UTC](https://discourse.julialang.org/t/approxfun-defining-a-nonlinear-differential-operator/15296 "2018-09-21T16:29:15Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)
#### Post date: [September 21, 2018, 4:29pm UTC](https://discourse.julialang.org/t/approxfun-defining-a-nonlinear-differential-operator/15296/1 "2018-09-21T16:29:15Z")

</div>

Hello, I am struggling with the very basics of usage of ApproxFun package. I would like to define a nonlinear differential operator (the ultimate motivation is actually to define and solve a nonlinear ODE). The operator \mathcal{N} acts on u(t) as \mathcal{N}u = \ddot u + (1-u^2)\dot u + u.

How do I do it using ApproxFun? This is what I tried so far:

```julia
using ApproxFun, LinearAlgebra
t₀ = 0.0; t₁ = 1.0; t = Interval(t₀,t₁);
D = Derivative(t); D2 = Derivative(t,2);

```

```julia
N = D2 + (1-?)*D + I;

```

What do I put instead of the ? symbol on the last line? Or shall I do it in a completely different way? I feel my confusion might come from the interpretation of the \* symbol as both the multiplication and application of an operator.

---

<div class="post-metadata">

### Author: ![vtchen](https://avatars.discourse-cdn.com/v4/letter/v/b9bd4f/32.png) [@vtchen](https://discourse.julialang.org/u/vtchen)
#### Post date: [September 12, 2019, 10:57am UTC](https://discourse.julialang.org/t/approxfun-defining-a-nonlinear-differential-operator/15296/2 "2019-09-12T10:57:57Z")

</div>

I have the same doubts. Have you solved this problem?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [September 12, 2019, 11:04am UTC](https://discourse.julialang.org/t/approxfun-defining-a-nonlinear-differential-operator/15296/3 "2019-09-12T11:04:42Z")

</div>

You have to translate back to position space to do it.

---

<div class="post-metadata">

### Author: ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)
#### Post date: [September 12, 2019, 11:19am UTC](https://discourse.julialang.org/t/approxfun-defining-a-nonlinear-differential-operator/15296/4 "2019-09-12T11:19:47Z")

</div>

Unfortunately no. I gave up, at least temporarily…

---

<div class="post-metadata">

### Author: ![vtchen](https://avatars.discourse-cdn.com/v4/letter/v/b9bd4f/32.png) [@vtchen](https://discourse.julialang.org/u/vtchen)
#### Post date: [September 12, 2019, 11:54am UTC](https://discourse.julialang.org/t/approxfun-defining-a-nonlinear-differential-operator/15296/5 "2019-09-12T11:54:16Z")

</div>

Dr chris and Dr Olver know the solution, and I hope the ApproxFun package will provide a solution to this problem in the near future.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [September 12, 2019, 12:30pm UTC](https://discourse.julialang.org/t/approxfun-defining-a-nonlinear-differential-operator/15296/6 "2019-09-12T12:30:04Z")

</div>

Here’s a few examples with finite discretizations at least:

[https://github.com/JuliaDiffEq/DiffEqBenchmarks.jl/blob/master/benchmarks/MOLPDE/allen\_cahn\_spectral\_wpd.jmd](https://github.com/JuliaDiffEq/DiffEqBenchmarks.jl/blob/master/benchmarks/MOLPDE/allen_cahn_spectral_wpd.jmd)  
[https://github.com/JuliaDiffEq/DiffEqBenchmarks.jl/blob/master/benchmarks/MOLPDE/burgers\_spectral\_wpd.jmd](https://github.com/JuliaDiffEq/DiffEqBenchmarks.jl/blob/master/benchmarks/MOLPDE/burgers_spectral_wpd.jmd)  
[https://github.com/JuliaDiffEq/DiffEqBenchmarks.jl/blob/master/benchmarks/MOLPDE/kdv\_spectral\_wpd.jmd](https://github.com/JuliaDiffEq/DiffEqBenchmarks.jl/blob/master/benchmarks/MOLPDE/kdv_spectral_wpd.jmd)  
[https://github.com/JuliaDiffEq/DiffEqBenchmarks.jl/blob/master/benchmarks/MOLPDE/ks\_spectral\_wpd.jmd](https://github.com/JuliaDiffEq/DiffEqBenchmarks.jl/blob/master/benchmarks/MOLPDE/ks_spectral_wpd.jmd)

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [September 12, 2019, 12:44pm UTC](https://discourse.julialang.org/t/approxfun-defining-a-nonlinear-differential-operator/15296/7 "2019-09-12T12:44:11Z")

</div>

An example of using ApproxFun to solve a nonlinear boundary-value problem is given here: [https://github.com/JuliaApproximation/ApproxFun.jl#nonlinear-boundary-value-problems](https://github.com/JuliaApproximation/ApproxFun.jl#nonlinear-boundary-value-problems)

The basic issue is that it is nonlinear, so you don’t define an operator and use `\`. Instead you define a function `N(u)` and run a Newton iteration (which internally performs a sequence of linearized solves).
