(***********************************************************************
Mathematica-Compatible Notebook
This notebook can be used on any computer system with Mathematica 4.0,
MathReader 4.0, or any compatible application. The data for the notebook
starts with the line containing stars above.
To get the notebook into a Mathematica-compatible application, do one of
the following:
* Save the data starting with the line of stars above into a file
with a name ending in .nb, then open the file inside the application;
* Copy the data starting with the line of stars above to the
clipboard, then use the Paste menu command inside the application.
Data for notebooks contains only printable 7-bit ASCII and can be
sent directly in email or through ftp in text mode. Newlines can be
CR, LF or CRLF (Unix, Macintosh or MS-DOS style).
NOTE: If you modify the data for this notebook not in a Mathematica-
compatible application, you must delete the line below containing the
word CacheID, otherwise Mathematica-compatible applications may try to
use invalid cache data.
For more information on notebooks and Mathematica-compatible
applications, contact Wolfram Research:
web: http://www.wolfram.com
email: info@wolfram.com
phone: +1-217-398-0700 (U.S.)
Notebook reader applications are available free of charge from
Wolfram Research.
***********************************************************************)
(*CacheID: 232*)
(*NotebookFileLineBreakTest
NotebookFileLineBreakTest*)
(*NotebookOptionsPosition[ 6715, 184]*)
(*NotebookOutlinePosition[ 7569, 214]*)
(* CellTagsIndexPosition[ 7525, 210]*)
(*WindowFrame->Normal*)
Notebook[{
Cell[CellGroupData[{
Cell["A Heat Flow Problem", "Title",
ImageRegion->{{-0, 1}, {0, 1}}],
Cell[BoxData[{
\(Author : \ Thomas\ Shores\), "\[IndentingNewLine]",
\(University\ of\ Nebraska\), "\[IndentingNewLine]",
\(Send\ comments\ \(to : \ tshores@math . unl . edu\)\)}], "Input",
FontFamily->"Helvetica",
FontWeight->"Plain",
FontVariations->{"CompatibilityType"->0}],
Cell[CellGroupData[{
Cell["Discussion of the Problem", "Subsection",
ImageRegion->{{0, 1}, {0, 1}}],
Cell["\<\
Our second example has its origins in a physical problem of heat \
flow.
Suppose we have a rod of material of unit length, say, situated on the
x-axis, for 0 <= x <= 1$. Suppose further that the rod is laterally
insulated, but has a known internal heat source. Also suppose that
both the left and right ends of the rod are held at 0 degrees Celcius.
When sufficient time passes, the temperature of the rod at each point
will settle down to ``steady state'' values, dependent only on position
x. It can be shown from physical principles that if u is the
temperature function of the rod, i.e., u(x) is the temperature of the
rod at x , then u(x) and f(x) are related by the following \
equations:
\t-u''(x) = f(x),
\t u(0) = 0,
u(1) = 0.
\t
Here ' denotes derivatives with respect to x and f(x) is a known
function which depends on the material and the internal heat
distribution of the rod. The type of problem just described is called
a boundary value problem and abbreviated to BVP. Note that if we
knew how to integrate f(x) twice, it would be easy to determine
u(x) : simply use the boundary conditions at 0 and 1 to determine the
two constants of integration. The interesting case is when f(x) is
not easily integrated. In fact, a closed formula for f(x) may not
even be given. How do we solve the problem then?
We can formulate a discrete approximation to the BVP above as follows.
Choose an integer n and divide the interval [0, 1] into n+1 equal
subintervals with endpoints 0 = x_0, x_1, ... ,x_{n+1} = 1 (these
points are called nodes ). Then the width of each subinterval is
h = 1/(n+1) . Next let u_i be our approximation to u(x_i) .
Observe that we can approximate the first derivative by the forward \
difference formula
\t
(1) \tu'(x) ~(u(x+h) - u(x)) / h .
Likewise, we can approximate the second derivative by the
backward difference formula
(2) \tu''(x) ~ (u'(x-h) -u'(x)) / (-h)
Now use the formula (1) with x and x-h replacing x and substitute \
into Formula (2) to obtain the second derivative formula
(3) \tu''(x) ~ (u(x+h) - 2u(x) + u(x-h)) / (h^2)
At each unknown node x_i replace the second derivative
in the equation -u''(x_i) = f(x_i) , i = 1,...,n by the approximation
given by Formula (3) ; then multiply the equation by h^2.
Observe that u(x_i + h) = u_{i + 1} and one obtains a system of
n equations in the n unknowns u_1, u_2,...,u_n, where the ith
equation takes the form
\t
\t -u_{i-1} + 2u_i - u_{i+1} = h^2f(i h)
\t
Remember that u_0 and u_{n+1} are known to be 0, so the terms u_0 \
and u_{n+1} disappear.
It is reasonable to expect that the smaller h is, the more accurately
u_i will approximate u(x_i) . This is indeed the case. But consider \
what we are confronted with when we take n = 5 , i.e., h = 1/6 ,
which is hardly a small value of $h$. The system of five equations in
five unknowns becomes
2x_1 - x_2 = f(1/6)
-x_1 + 2x_2 - x_3 = f(2/6)
-x_2 + 2x_3 - x_4 = f(3/6)
-x_3 + 2x_4 - x_5 = f(4/6)
-x_4 + 2x_5 = f(5/6)
This problem is already about as large as we would want to work by hand.
Now let's try a specific example. Use N[Sin[Pi*x]] for f[x]. Define the \
required equations yourself and use Mathematica to compute the approximate \
solution by filling in the following cells with your equations. Use x1, x2, \
x3, x4, and x5 for your variables. BE SURE TO USE DECIMALS SOMEWHERE IN YOUR \
EQUATIONS TO FORCE MATHEMATICA TO VIEW EVERYTHING AS NUMBERS. The last cell \
will show you a graph of your approximate heat function u(x).
\
\>", "Text",
ImageRegion->{{-0, 1}, {0, 1}}],
Cell["vars = {x1, x2, x3, x4, x5}", "Input",
ImageRegion->{{-0, 1}, {0, 1}}],
Cell["\<\
equations = { ,
,
,
,
}\
\>", "Input",
ImageRegion->{{-0, 1}, {0, 1}}],
Cell["rules = Solve[equations,vars]", "Input",
ImageRegion->{{-0, 1}, {0, 1}}],
Cell["\<\
ListPlot[{{0.,0},{N[1/6],x1},{N[2/6],x2},{N[3/6],x3},
{N[4/6],x4},{N[5/6],x5},{1.,0.}}/.rules [[1]], PlotJoined->True]\
\>", "Input",\
ImageRegion->{{-0, 1}, {0, 1}}]
}, Closed]],
Cell["Exercises", "Subsection",
ImageRegion->{{-0, 1}, {0, 1}}]
}, Closed]]
},
FrontEndVersion->"4.0 for X",
ScreenRectangle->{{0, 1152}, {0, 864}},
WindowToolbars->{},
CellGrouping->Manual,
WindowSize->{520, 600},
WindowMargins->{{Automatic, 308}, {104, Automatic}},
PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}},
ShowCellLabel->True,
ShowCellTags->False,
RenderingOptions->{"ObjectDithering"->True,
"RasterDithering"->False}
]
(***********************************************************************
Cached data follows. If you edit this Notebook file directly, not using
Mathematica, you must remove the line containing CacheID at the top of
the file. The cache data will then be recreated when you save this file
from within Mathematica.
***********************************************************************)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[1739, 51, 70, 1, 107, "Title"],
Cell[1812, 54, 297, 6, 64, "Input"],
Cell[CellGroupData[{
Cell[2134, 64, 80, 1, 45, "Subsection"],
Cell[2217, 67, 3945, 88, 1472, "Text"],
Cell[6165, 157, 78, 1, 27, "Input"],
Cell[6246, 160, 108, 7, 87, "Input"],
Cell[6357, 169, 80, 1, 27, "Input"],
Cell[6440, 172, 179, 5, 57, "Input"]
}, Closed]],
Cell[6634, 180, 65, 1, 29, "Subsection"]
}, Closed]]
}
]
*)
(***********************************************************************
End of Mathematica Notebook file.
***********************************************************************)