# Nonlinear boundary conditions in ApproxFun

**URL:** https://discourse.julialang.org/t/nonlinear-boundary-conditions-in-approxfun/129504
**Category:** Numerics
**Tags:** question, nonlinear, approxfun
**Created:** [May 31, 2025, 3:43pm UTC](https://discourse.julialang.org/t/nonlinear-boundary-conditions-in-approxfun/129504 "2025-05-31T15:43:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![MingjiaYan](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@MingjiaYan](https://discourse.julialang.org/u/MingjiaYan)
#### Post date: [May 31, 2025, 3:43pm UTC](https://discourse.julialang.org/t/nonlinear-boundary-conditions-in-approxfun/129504/1 "2025-05-31T15:43:07Z")

</div>

Hi,

I’m trying to solve for the steady state solution of a one-dimensional heat equation describing a nonlinear heat conduction in a finite domain [0,1] using ApproxFun.jl:

T\_{xx} = 0

subject to a Dirichlet boundary conditions at the left end

T(0,t) = T\_0 \quad \text{at} \;\; x=0

and a nonlinear power law boundary condition at the right end

T\_x(1, t) = \beta(T^4 - T\_0^4) \qquad \text{at}\;\; x=1.

Here, T = T(x, t) is the temperature variable, \beta and T\_0 are some constant parameters.

I’m having trouble dealing with the nonlinearity in the right boundary condition. The numerical result I got from the plot does not agree with the analytical one, so I wonder how to fix this?  
Here’s my code:

```julia
using ApproxFun, Plots, LinearAlgebra

T₀ = 2.0
β = 2.0

d = Interval(0,1)
S = Chebyshev(d)
x = Fun(S)
D = Derivative(S)

BC1 = Evaluation(S, 0) # T(0) = T₀ at x=0
BC2 = Evaluation(S, 1, 1) - β*Evaluation(S, 1)^4 # T'(1) = β(T(1)^4 - T₀^4) at x=1
L = D^2 # differential operator: T'' = 0

sol = [BC1; BC2; L] \ [T₀; -β*T₀^4; 0*x]

# analytical solution: T(x) = Ax + B, where B = T₀ and A = β((A+T₀)^4 - T₀^4) -> A ≈ -3.93545
T_analytical = -3.93545*x

print(sol)
plot(sol, label="numerical")
plot!(T_analytical, label="analytical", lw=2, linestyle=:dash)

```

and the plot I got:

 ![Screenshot 2025-05-31 at 16.42.05](https://global.discourse-cdn.com/julialang/original/3X/5/c/5ceacf6d5a731ecd9e3179227af4ee7af39f2979.png)

Any help would be much appreciated! 🙂
