If we again consider the heat in a metal bar of length \(L\text{,}\) but this time consider the effect of radiation as well as conduction, then the steady state equation has the form
\begin{equation*}
u_{xx}- d (u^{4} - u_{b}^{4}) = - g(x)\text{,}
\end{equation*}
where \(u_{b}\) is the temperature of the background, \(d\) incorporates a coefficient of radiation and \(g(x)\) is the heat source.
This equation is nonlinear in the unknowns, thus we no longer have a system of linear equations to solve, but a system of nonlinear equations. One way to solve these equations would be by the multivariable Newton method in Section 2.6. Instead, we introduce another iterative method.
Now for the main idea, we will begin with an initial guess for the value of \(u_{i}\) for each \(i\text{,}\) which we can represent as a vector \(\ub^{0}\text{.}\) Then we will use the above equation to get better estimates, \(\ub^{1}\text{,}\)\(\ub^{2}\text{,}\) …, and hope that they converge to the correct answer.
Notice that \(g_{i}\) and \(u_{b}\) do not change. In the resulting equation, we have \(u_{i}\) at each successive step depending on its previous value and the equation itself.
In the following program we solve the finite difference equations ((4.5.1)) with the boundary conditions \(u(0) = 0\) and \(u(L) = 0\text{.}\) We let \(L = 4\text{,}\)\(n=4\text{,}\)\(d = 1\text{,}\) and \(g(x) = \sin(\pi x/4)\text{.}\) Notice that the vector u always contains the current estimate of the values of \(\ub\text{.}\)
We can plot the initial guess by adding the command plot(x,u) right before the for loop. We can also plot successive iterations by moving the last plot(x,u) before the end. Now we can experiment and see if the iteration is converging. Try various values of \(steps\) and \(n\) to produce a good plot. You will notice that this method converges quite slowly. In particular, as we increase \(n\text{,}\) we need to increase \(steps\) like \(n^{2}\text{,}\) i.e. if \(n\) is large then steps needs to be really large.
Modify the script program mynonlinheat (Program 4.5.1) to plot the initial guess and all intermediate approximations. Add complete comments to the program. Print the program and a plot using \(n = 12\) and steps large enough to see convergence.