Advanced Physics Through Mathcad
Advanced Physics Through Mathcad
Advanced Physics Through Mathcad
THROUGH MATHCAD
POSTGRADUATE LEVEL
FOR II MSc., PHYSICS
BY
Dr.S.PALANISWAMY
PROFESSOR OF PHYSICS
PSG COLLEGE OF ARTS AND SCIENCE
COIMBATORE-641014
33
TABLE OF CONTENTS
CHAPTER-1- MathCAD - Tools
1. MathCAD Tool Bars and Palettes
1.1 Features of the MathCAD Window
1.2 Main menu
1.3 Math Palatte
1.4 The tool bar
1.5 The resource centre navigational control
33
CHAPTER-3-MathCAD -graphics
33
1. Creating Graphs
2. Two dimensional graph- three dimensional graphs
3. Formatting Math and Text
4. Formatting Results
5. Using Units
6. Creating Programs
7. Conditional statements
8. Program loops
9. Fourier series
10. Bohrs theory of atomic structure
11. Numerical solution of Schrdinger wave equation
12. Lorentz force
13. Van-der-Waals equation
14. Resistivity
CHAPTER-4-COMPUTER ORIENTED
NUMERICAL METHODS
1. Euler's method of solving ode
2. False-position method
3. Fixed point iteration procedure
4. Modified Euler predictor corrector method
5. Newton-Raphson method
6. Numerical Integration-3/8 Simpson Rule
7. Predictor - Corrector method
8. Range-Kutta method
33
CHAPTER-5-MATHCAD PROGRAMS TO
PHYSICS PROBLEMS
1. Numerical solution of Schrdinger wave equation
2. Harmonic oscillator
3. Learning molecular symmetry-H2O,NH4
4. Numerical solution of second order differential equation
5. Study material of hydrogen atom and molecule
6. Ground state of helium atom byVariation method
7. Electron motion through rectangular potential barrier
8. XY3- planar
33
PREFACE
Many software tools exist to analyze and report the results of technical
experiments and design work. One of these packages in called MathCAD. MathCAD is a
program that allows the user to enter variables, formula, and text into the computer in a
"notebook" style format. The formula is entered just as they appear in textbooks and other
technical references, and the program computes the resulting values given the previously
defined values of the variables and the formulas. The program also allows the user to
annotate the calculations with areas of text. The program can produce a number graph
types. This feature is useful in visualization of functions and in plotting the data collected
from experiments. This lab activity handout demonstrates the computational and
reporting features of MathCAD. It was created with MathCAD to demonstrate the
features of the program. Use this software to produce graphs and perform calculations
associated with the laboratory experiments for this course. This introduction is based on
the commands and features of MathCAD Version 2001 Professional. The commands and
features may differ in the newer version of the program, but the general operation of the
program is no different.
Preliminary Exercises
1. Begin your MATHCAD session by opening the MathSoft Apps Group in Windows
and double clicking on the MATHCAD icon. You may wish to work through the Mathcad
Tutorial before you start the set of exercises in this document. Exit the tutorial session
before doing this set of exercises.
2. Simple keyboard practice. Notice the structure of a Mathcad page. It is like a white
piece of paper. The vertical line marks the right edge of the current page. The area to the
right of that line is a separate page. Sample the various pull down menus. Notice how
groups of possible actions are grouped together. Entering simple equations onto the
MATHCAD page. (Use the space to the right of this text on the screen Enter 16-8/2=
Note how the division sign behaves. Pressing = produces the numerical result of the
operation. When entering expressions for calculation, do not put in spaces. Mathcad will
33
put them in for you, and if you put them in, Mathcad will think you are entering text, not
an expression to be evaluated.
To produce (16-8)/2, one should either type the entry with the
parentheses included, or type 16-8, highlight the entire operation using the space bar, and
then press the division button. What ever is highlighted, i.e. in the blue box, will appear
in the numerator. Try this step now. The hierarchy of operator evaluation follows the
commonly used standards for computer programming. Powers are followed by
multiplication and division, followed by addition and subtraction. Pressing the =
evaluates the mathematical sequence and returns the numerical value to the right of the
equal sign as you saw above. To take the power of a function use the carat symbol (Shift6). Evaluate 4 squared. Practice now with other squares. You can make your practice
exercises right here in this document using the pages on the right portion of the screen or
print this document and create your own collection of answers to the exercises. Save your
file periodically in case of a computer glitch.
You can also annotate your document with text regions. This
will give you a personalized tutorial document that you can refer to if you forget
something you learned here. You can also add sample exercises to your personal
document as the semester proceeds. This is important because you may need to refer to
techniques from one exercise to the next and you don't want to waste time recreating a
technique that was already constructed in your practice file. Most users of Mathcad have
a file of techniques that they can refer to for new work. Start you file of techniques today.
After getting used to MathCAD software, try simple problems in Physics.
The problems like ideal gas equation, the wave pattern in sound, mechanical problems
using Newtons laws and de Broglie matter wave problems can be solved.
In this book, the first chapter introduces the learners the MathCAD
Tool Bars and Palettes.
The second chapter deals with advantages of MathCAD in developing
solutions to problems.
33
33
CHAPTER-1
MathCAD - Tools
1. MathCAD Tool Bars and Palettes
1.1 Features of the MathCAD Window
1.2 Main menu
1.3 Math Palate
1.4 The tool bar
1.5 The resource centre navigational control
33
8. Editing Expressions
9. Defining Range Variables
10. Defining Vectors and Matrices.
Questions
33
Click on one of these buttons in the bar to bring up the associated operator palette. You
can then use the operator palettes to insert math symbols right into your Mathcad
worksheet.
33
at the bottom of the Mathcad window gives you status alerts, tips, keyboard shortcuts,
and other helpful information. It also lists the calculation status of your worksheet -"auto" here means that the worksheet is in automatic mode, which means Mathcad will
automatically recalculate any math expressions if you make edits to your worksheet. You
can tell when Mathcad is recalculating because "WAIT" appears on the message line and
the cursor changes to a flashing light bulb. Other information that appears on the message
line is whether you have the Caps Lock or Num Lock key depressed on your keyboard, as
well as the page number of the current worksheet.
33
33
important property of Mathcad is that it reads your document from left to right and top to
bottom, just as you read a book. For an example of what this means, select the y2 = 100
below and drag it above the definition of y (the definition of the variable is done in
Mathcad with the colon-equals symbol; more on that later). You will see that Mathcad is
no longer able to tell you what y 2 equals because it doesn't know what y equals yet.
Notice that if you drag the region below the original assignment, it computes!
You can also easily delete selected regions. Select the math regions above in dashed line
boxes and choose Cut from the Edit menu. (You may need to copy the regions to a
worksheet of your own to try this out.) Now click in the empty space above and choose
Paste from the Edit menu to reinstate the equations. You can see how this can be useful
if you delete something by accident. Using this technique, you can select many regions at
once and clear them away. And, if you make a mistake, you can easily bring the regions
back, provided you bring them back before you Cut something else.
After you type the + you see a little black box delimited by blue editing lines. In
Mathcad this black box is called a placeholder. If you continue typing, whatever you type
next will appear in the placeholder. For example, type 2 in the placeholder, then press
the equals key (=) to see the result.
If you click outside the region, or press [Enter], you should see:
33
The basic operators are listed below, along with their keystrokes and Arithmetic Palette
button equivalents. To see the Arithmetic Palette, click on the Math Palette button.
Notice that math in a Mathcad worksheet appears in familiar math notation -multiplication as a raised dot, division with a fraction bar, exponents in a raised position,
and so on.
33
done, click outside the text region to go back to inputting math. The black selection box
disappears when you're no longer working in the text region.
33
put page numbers, filenames, and the current date in headers or footers
set the formats for numbers
Then Save As and choose under File of Type, Template. Make sure to have the file
extension be .mct. Your settings, styles, and bitmaps will be available for the next file
you create, saving you the time of redoing that work for each file. This will also help
make your files more consistent.
5. Defining Variables
Often you will want to define a number as a name you can use in subsequent calculations.
For example, click to position the red crosshair in an empty space below and type:
Type age:23 See on screen
Notice that when you type the colon [:] key or, press the assignment operator key.
on the Arithmetic Palette, Mathcad displays :=. The assignment operator ("colon
equals") in Mathcad is used for definitions. To see what age equals, you just type the
name followed by the equals sign:
Type age=
If you wanted to assign a different value to age, just click to the right of the 23 on the
right-hand side of the definition of age above, backspace over it to delete it, and enter the
new value. Notice that as soon as you press [Enter], age= changes as well. Because of
this ability to vary the value of a name, this type of definition is called a variable in
Mathcad. You can now use a Mathcad variable in an equation:
33
Try defining some variables of your own (you can call your variables x or money_spent
or any other names you can think of) and use them in equations in your main worksheet.
Remember that you use the assignment operator [:] for definitions, and you type [= ] to
calculate an answer.
6. Defining Functions
The syntax used for defining a function in Mathcad is the same as you see in textbooks.
For example, position the red crosshair in a blank area and try typing:
Type f(x):x^2 See on screen
Notice that you use the assignment operator to define functions, just as you use the
assignment operator to define variables in Mathcad. Once you've defined a function like
f(x), you can use it in a number of ways:
Define a range variable (more on this later) and plug it in as the argument of f(x) to see a
table of values.
33
You can define a function using expressions you build up from the keyboard or from the
palettes of math operators, as described above, and you can also include any of Mathcad's
hundreds of built-in functions. To see a scrolling list of builtin functions along with brief
descriptions, select Function from the Insert menu, or click on the
button on the toolbar. The Insert Function dialog box, pictured below, lets you insert a
function name directly into a math placeholder in your worksheet.
33
You can also type the name of any built-in function directly from the keyboard. Here are
just a few examples that use some of Mathcad's built-in functions.
6.1 Trig and Logs
33
in blue editing lines. So, when you typed the multiplication sign, you were multiplying
this entire expression by the expression that followed. If you hadn't pressed [Spacebar]
the first time, you would have seen
which is a completely different expression. When you pressed [Spacebar] the second
time, x3 was selected in the blue editing lines. Therefore, when you typed -1, you were
performing subtraction on the entire expression x3 . Compare what you typed above to
what happens when you type f(x):x+6*(x^3-1) you probably get something that looks
like
The exponent operator is called a sticky operator because your keystrokes will "stick" to
the exponent until you specifically ask to get out by pressing [Spacebar]. This stickiness
applies to exponents, square roots, subscripts, and division. To create the expression type
below:
33
Type x^2[Spacebar]
Now x2
is selected in blue editing lines, then Type +3[Spacebar] so that the entire equation is in
the editing lines, then
Type /5[Enter] and done!
If you try entering the expression again without pressing [Spacebar] after typing +3 you
should get
You may need to create some of your own equations in your main worksheet window in
order to get a better feel for sticky operators.
8. Editing Expressions
Understanding the structure of expressions in Mathcad will help you edit them efficiently.
Looking at the highlighted equation below, do the following with the mouse:
Click on the square root symbol. Notice that the square root and everything under
it is selected in blue editing lines.
Click immediately to the right of the 5 under the radical, then start pressing
[Spacebar]. Notice how more and more of the expression is selected in blue editing lines.
33
Click immediately to the left of the 3 in the exponent of x3, then start pressing
[Spacebar]. Notice how more and more of the expression is selected in blue editing lines.
The blue editing lines define a subexpression that will be operated on by the next
operator or expression you type. If your editing lines are positioned to the left of an
expression, the next operator or expression you type will appear to the left of the vertical
line; if your editing lines are to the right of an expression, the next thing you type will
appear to the right of the vertical line.
Now notice what happens when you use other mouse selection methods on parts of the
highlighted equation below:
Double-click on the x in the expression f(x). Notice that double-clicking selects the
variable in reverse video.
Click to the left of the x2 under the radical, then start dragging your mouse to the right.
Notice how more and more of the expression is selected in reverse video.
When you select a part of a math expression in reverse video, the next operator or
expression you type will replace the selected expression. This is probably how you're
already used to editing text on the screen in most word processors.
Try It Out!
33
If you want to take the square root of the entire right side of the equation, click to the
left of the radical and press [Spacebar] until the entire right-hand side is selected in blue
editing lines. Then type a backslash [\]s.
If you want to subtract x instead of x3 on the right-hand side, drag-select the x 3 and
then type 1/2[Spacebar]*x.
If you are editing an expression and make a mistake, just select Undo from the Edit
menu to return to the original expression. Or, if you recently saved your worksheet, close
it without saving changes and reopen it.
Here is another example you can try to get the hang of editing math in Mathcad. Enter the
following lines in the MathCad editor
The variable x has been defined at the beginning so you can see the effects of your edits.
33
So, incorporating everything you've learned so far, try to reproduce the following
equations yourself:
Notice that when you type the semicolon character [;], it displays on the screen as two
dots (..) followed by a placeholder.
This is Mathcad's range variable operator. Another way to put the range variable operator
in your worksheet is with the
Range Variable button
33
If you want your range to be in increments other than 1 (the default), enter the next value
in the range after the first one.For example, to create a range variable x that goes from 1
to 10 in increments of 0.1, type:
33
Notice that you typed a comma before the second value in the range, and then you typed
the semicolon [;] after the second value. Here are some other examples, along with the
keystrokes used to create them:
Type x:1,1.1;1.8See on screen
x := 1 1.1 1.8
Type data:10,8;0See on screen
data := 10 8 0
Type n:202,192;102See on screen
n:= 202 192 102
Here the range goes down!
Type x=See on screen
33
Try defining your own range variable and using it in an expression below.
33
Fill in the appropriate number of rows and columns. For example, the vector below has
3 rows and 1 column.
Click on Insert.
Fill in the placeholders with the appropriate values. Use [Tab] to move from
placeholder to placeholder inside the vector, or click on the appropriate placeholder to
select it.
To access a particular element of a vector, you use the subscript operator, which you
create by typing a left square bracket ( [ ), or by using the
in the Arithmetic Palette. By default the first element has the index 0:
Type v[0= See on screen
v0 3.3
If z is a matix, then the 3rd element in the first column can be accessed by typing v[2,0
For convenience, you can define the index as a range variable to access all of the
elements at once:
Type i:0;2 See on screen
i:= 02
Then
Type v[i= See on screen
33
For your exercise, try defining a vector and its index. It's important to understand that an
index for a vector will always be a range of consecutive integers in Mathcad, starting
from 0. Any values not specifically defined by you will be defined to equal 0 by Mathcad.
For example, consider the followings:
Type i:2;5 See on screen
i :=25
Type wrong[i:1 See on screen
wrong i:= 1
Type wrong= See on screen
You might expect the vector wrong to have four elements (the 2nd, 3rd, 4th and 5th).
However, as you can see, it has six. This is because internally, Mathcad still keeps track
of the 0th and 1st elements. And because these were not specifically defined, Mathcad
made them equal to 0.
It is useful to use vector elements as arguments of functions. For example, we'll use the
constants and function defined
below:
b:= 9.7
a:= 1.1
33
Now define a vector and use its elements as an argument of the function:
Try defining a vector and using its elements in a function. You can also use vectors as
arguments of functions. For example:
Type f(x):[Ctrl]4x See on screen
Here we use the vector summation operator, which is also available via the
Most of the vector and matrix operators can be found in the Vector and Matrix Palette,
but here is a listing of a few basics:
33
Mathcad has a wide variety of built-in functions for manipulating vectors and matrices.
Here is a small sampling, using the matrix M defined below:
Eigenvalues of a matrix
33
QUESTIONS
1. Explain MathCAD Tool Bars and Palettes.
2. Discuss Working with MathCAD Regions.
3. Explain the method of entering math and text regions in mathCAD.
4. Discuss Working with MathCAD Styles and Templates.
5. Define the variables and functions.
6. Explain building mathematical expressions.
7. Define range variables, vectors and matrices.
8. Explain editing expressions.
9. Explain the method of working with matrices and vectors in mathCAD.
33
CHAPTER-2
The MathCAD Advantage
Introduction
33
Introduction
Mathcad is a unique, powerful way to work with equations, numbers, text, and graphs.
Unlike any other math software,Mathcad does math the same way you do. That's because
it looks and works like a scratchpad and pencil. Mathcad's onscreen interface is a blank
worksheet on which you can enter equations, graph data or functions, and annotate with
text --anywhere on the page. And instead of forcing you to use a programming-like
syntax, Mathcad lets you use the language of mathematics.In a programming language,
for example, equations look like this:
In a programming language, for example, equations look like this:
x=(-B+SQRT(B**2-4*A*C))/(2*A)
In a spreadsheet, equations go into cells looking something like this:
X = (-B1+SQRT(B1*B1-4*A1*C1))/(2*A1)
In Mathcad, the same equation looks the way you would see it in a text or a reference
book:
2
b b 4 a c
2 a
The only difference is that Mathcad's equations and graphs are live. Change any data,
variable, or equation, and Mathcad recalculates the math and redraws the graphs -instantly. With Mathcad, you can solve a wide range of technical problems -- from the
simple to the very complex -- numerically or symbolically. You can also visualize
equations and data with 2D and 3D graphing. With Mathcad Electronic Books you also
get a wealth of mathematical knowledge and reference material -- all live and ready to be
dragged and dropped into your worksheets. Most important, Mathcad gives you all the
power you need to get the job done -- from start to finish. With Mathcad you can truly do
it all explore problems, formulate ideas, analyze data, model and test scenarios, select
the best solution . . . then document, present, and communicate the results. Using
33
Mathcad's connections to the Worldwide Web, you can also share your Mathcad
worksheets with colleagues and other professionals. This means you can collaborate
easily during any phase of a project -and you can do it in the rich and powerful language of mathematics.
Here are a few examples. These calculations are computed internally to 15 places, but
you can show fewer places in the answer -- just click on an answer and choose Number
from the Format menu, then change the number in the Displayed Precision field in the
dialog box. Get the square root and the power from the Arithmetic Palette, and type =to
see the answer. For the four basic operations, use +,,*, and / right from the
keyboard.
33
When you change a definition, Mathcad immediately recalculates any new values that
depend on it.
33
Try it! Click just to the right of the 4 in the definition of a above so you see the blue
editing lines:
Now type 3. Click the mouse anywhere else on the screen and you'll see the answers
change.
33
33
33
33
33
10.
33
The above program implements Newton's method for finding nth roots of numbers within
a tolerance e which is then used in the following example.
33
This only scratches the surface of Mathcad's mathematical features, but we hope it whets
your appetite to explore the product further! In the next sections you'll learn how to create
the basic elements of Mathcad worksheets: equations, text,and graphics.
QUESTIONS
1. Describe the different MathCADs built-in functions and math operators define
your own variables and functions.
2. Evaluate functions and expressions over ranges and explain the method to plot the
functions.
3. Explain the method of visualizing the data in two and three dimensions.
4. Explain the matrix computations in detail.
5. Explain the computation of sums and integrals.
6. Explain the method of solving equations numerically and the method carrying out
symbolic operations.
7. How will you create multiline procedures using new programming operators?
8. Explain the method of creating animations to visualize results over time.
33
CHAPTER-3
MathCAD -graphics
1. Creating Graphs
2. Two dimensional graph- three dimensional graphs
3. Formatting Math and Text
4. Formatting Results
5. Using Units
6. Creating Programs
7. Conditional statements
8. Program loops
9. Fourier series
10. Bohrs theory of atomic structure
11. Numerical solution of Schrdinger wave equation
12. Lorentz force
13. Van-der-Waals equation
14. Resistivity
33
1. Creating Graphs
Mathcad makes it easy for you to create an x-y plot. Just click in a new file, type an
expression that depends on one variable, for example, sin(x), and then click on the X-Y
Plot button
in the Graph Palette, or choose X-Y Plot from the Insert/Graph menu. Then press
[Enter]. Voila, a plot! You should see a nicely formatted plot that looks like this:
Try It Out!
The expression you plot doesn't even have to be a function of x. Try typing
y^2[spacebar]-3*y, followed by the @ key (a shortcut for creating an x-y plot). Mathcad
will plot over a reasonable default range for the dependent variable in your expression.
Here are a couple of other expressions you can try plotting in this way:
33
Define an independent variable for the horizontal axis. For example: Type x:0;10 See
on screen
Create your plot by clicking in the worksheet window, then type @ to create the x-y
plot and type x in the middle placeholder on the horizontal axis and type f(x) in the
middle placeholder on the vertical axis. Then press [Enter].
Your plot should look like this:
33
Those of you familiar with the plot of f(x) will notice that the trace looks a little rough.
To smooth the trace out, try changing the definition of x highlighted above to x:=
00.110 . The smaller increment (or step) means more points calculated, which means
more plotted, which makes the trace smoother because Mathcad is simply connecting the
dots. To format an x-y plot, just double-click on it (or choose Graph from the Format
menu) to bring up a formatting dialog box. The tabbed dialog box lets you change options
for logarithmic axes, grid lines, legends, trace types, markers, colors,axis limits, and
more. Experiment with the x-y plot below. Double-clicking on any Mathcad plot -contour, surface, polar,vector, etc. -- brings up an appropriate formatting dialog box.
33
To plot these data points, the horizontal axis must be either (a) an index variable into the
variable money_spenor (b) another vector with the same number of elements. For case
(a), first define an index into the vector:
Type i:0;7See on screen
i:= 0..7
33
Notice here that box symbols have been used on a dashed blue line. To demonstrate case
(b), plotting two vectors of equal size against each other, we will define a second vector,
called day:
33
Now it's easy: Create the plot by typing @, as above, and type
Type money_spentSee on screen
money_spent
in the placeholder on the y axis, and
Type daySee on screen
day
in the placeholder on the x axis. The resulting plot should look similar to this:
Here the "points" trace type has been used with magenta O's. Notice that grid lines have
been turned off on both axes.
33
Here, the difference with plotting a function of a range variable is that the horizontal axis
does not have to be in even increments (such as 1, 2, 3, ..., 10). Rather, it can be any set of
numbers you may wish to plot.
33
In this example both expressions are plotted over the same default range of values, but
you could use two separate range variables if you wish. Try it out in your worksheet
window now.
Type f(x):sin(x) See on screen
f(x):= sin(x)
Type g(t):t^3 See on screen
g (t):=t3
Type x:-10,-9.9;10 See on screen
x:= 109.9 10
Type t:-2,-1.9;2 See on screen
t:= 21.9 2
Then,
Type @ in some blank space.
In the middle placeholder on the horizontal axis, type x,t.
In the middle placeholder on the vertical axis, type f(x),g(t).
33
Type [Enter].
Your result should look like this:
As you can see, plotting more than one function is simple --- just separate your arguments
with a comma (,). The same syntax holds for plotting multiple traces using vectors and
functions of vectors.
33
In the text region, make the word "Here" appear in Courier 12-point bold.
Change the math fonts to Times New Roman 12-point bold italic.
Here is a graph of f(x).
To practice, create some regions in your worksheet window by dragging them over. The
directions to make these changes follow.
33
4. Formatting Results
Now that you've learned how to get results, both numerical and graphical, there are a few
tips you should know for formatting your results in Mathcad. Suppose you define some
function using the following steps:
Define the variables as constants
Type P:500 See on screen
P:= 5000
Type r:.07 See on screen
r:= .07
Type n:365 See on screen
n:= 365
Define A as a function of t , i.e. A(t)
Type A(t):P*(1+r/n)^n*t See on screen
A(t):= P*(1+r/n)n.t
Get the results for different values of t
Type A(3)= See on screen
33
A( 3) = 6.168 10 3.
This is a compound-interest calculation. Notice that by default Mathcad displays the
result (highlighted above) in exponential form if it's larger in absolute value than 1000,
and the result is shown by default with three places after the decimal point. Suppose your
calculation involved currency and you wanted to see the result in nonexponential form
with two places after the decimal point. To change the format of the result:
Double-click on the result (A(3)=), or click on the result and choose Number from the Format
menu.
Notice that the Number Format dialog box pops up.
Change Exponential Threshold from 3 to 6 (or another value > 3).
Change Displayed Precision from 3 to 2.
Click on OK.
A(3) would now display as
A(3) 6168.27
This changes the exponential threshold locally -- i.e., only for a(3). If you want to change it for
the entire worksheet,
Click on a blank part of the worksheet.
Select Number from the Format menu.
Change Exponential Threshold to the desired number.
Change Displayed Precision to the desired number.
Click on OK.
Under Number Format, you can also control, among other characteristics:
Complex tolerance
Zero tolerance
The radix of the result (octal, hexadecimal, or decimal) for integer values.
Plots, too, are easy to format via a dialog box you can summon by double-clicking on a result
(plot), or by choosing Graph
from the Format menu.
Suppose you want to change the traces on the following plot:
33
33
main worksheet window by clicking on a plot and choosing Graph/X-Y Plot Format in
the Format menu.
Click on the Traces tab.
Click on trace 1, and change the Color to green (for example).
Click on trace 2 and change the Line to dadot (for example).
Click on OK.
Experiment with the different options to see how you can alter the trace types and other
graph characteristics. For example, you could end up with this plot . . .
. . . or with . . .
You can also make your plot log scaled (if appropriate), put in grid lines, set markers for
emphasizing certain areas of the graph, create legends and axis labels, even create a title
33
for the plot. Be sure also to try clicking once on a plot when you are in the main
worksheet window and then select Trace or Zoom from the Graph Palette. And, of
course, you can stretch the plot to make it wider or longer by dragging the sizing handles
you see at the right and bottom edges when you click on a plot in the main worksheet
window.
5. Using Units
One of the handy features of Mathcad is its ability to track standard units during
calculations and to convert the units of calculated quantities automatically. For example,
you can define a variable in terms of the built-in unit kilometers simply by multiplying a
number by km. Here we define the radius of the Earth and a surface area function:
Type r:6370*kmSee on screen
r:= 6370 km
Type A(r):4*p[Ctrl]g*r^2See on screen
A(r):= 4r2
(The symbol is also available on both the Arithmetic Palette and the Greek Symbols
Palette.) Then you can evaluate these expressions directly, or perform more extensive
calculations involving them:
Type A(r)=See on screen
A(r ) = 5.099. 1014
Notice that the result is automatically shown in terms of the base units of your default
unit system -- in this case SI. To see what the surface area of earth equals in hectares,
click once on any part of the equation below and notice the trailing black box on the
right-hand side. Double-click on this black box to bring up the Insert Unit dialog box.
Then double-click on
one of the displayed units to replace the units shown.
33
4 r2 5.099 .1014 m2
The result in hectares is
4r2 5.099 .1010 . hectare
This principle holds for all of the Mathcad built-in units, which is a very extensive list, as
well as for any units you may wish to define yourself. To see the list of built-in units in
Mathcad, choose Unit from the Insert menu.
w:= 100 joule
w 100 m. N
m:= 10-6. m
smoot:= 5.23 ft
smoot = 1.594 106 .m
m 6.273. 10-7 smoot
The units feature is also very convenient because it lets you know if you have made a
mistake in the units in your calculations. For example, the force calculation below should
end up in newtons (or an equivalent force unit) . . .
a:= 10.m/sec
mass:= 2 kg
F:= mass. a
F 20 s newton
but it appears to have an extraneous factor of seconds. Looking closely at the statements
in the calculation, you can see that the definition of the acceleration a is missing a term of
sec-1.
6. Creating Programs
6.1 What is a program?
33
Despite the underlying equivalence between programs and simple expressions, programs
offer two distinct advantages:
When you use control structures like loops and conditional branches, a program can
become far more flexible than a simple expression could ever be.
A program made of several simple steps is often much easier to create than an
equivalent, but far more complicated expression draped with parentheses.
Type the left side of a function definition followed by the assignment operator ":".
Click on the Math toolbar to open the Programming toolbar containing the
programming operators.
Click the "Add Line" button or press ]. This creates a vertical bar.
33
Click on the top placeholder, type "z" and click on the local assignment button.
(Be aware that the definition of z is local to the program. It is undefined outside the
program and has no effect anywhere but inside the program. You cannot use the
Mathcad's usual assignment operator ":=", inside a program. You must use the local
assignment operator represented by "<-".)
Complete the local assignment by typing "x/w" in the placeholder to the arrow's right.
The last placeholder should always contain the value returned by the program. Type
"log(z)" into this placeholder. You can now use this function just as you would any other
function or evaluate it symbolically.
7. Conditional statements
Use a conditional statement whenever you want a program statement to execute only
upon the occurrence of some condition as in the following program
type the value you want the program to return if the condition is false.
Note: To insert a conditional statement:
Click on the placeholder into which you want to place the conditional statement.
Click on the Math toolbar to open the Programming toolbar containing the
programming operators.
Click the "If" button or press Shift+]. Do not just type the word "if".
In the right placeholder, type a boolean expression.
Click the "Add Line" button to insert placeholders for additional statements if
necessary.
33
Click in the remaining placeholder and click the "otherwise" button. Do not just type
the word "otherwise".
In the remaining placeholder
If you use more than one "if" statement before an "otherwise" statement, the "otherwise"
statement is executed only when all the conditions are false.
8. Program loops
A loop is a program statement that causes one or more statements (the body of the loop)
to execute repeatedly until a particular condition occurs. There are two kinds of loops:
"For" loops are useful when you know exactly how many times the body of the loop
should execute.
"While" loops are useful when you want to stop execution upon the occurrence of a
condition but you don't know
exactly when that condition will occur.
When using loops, you may need to break out of them or control particular iterations.
33
Click on the "for" button or press Ctrl+". Do not just type the word "for".
In the placeholder to the left of the "e", enter the iteration variable.
In the placeholder to the right of the "e", enter the range of values to be taken by the
iteration variable (although you will most often use a range variable here, you can also
use a vector, a list of scalars, and vectors separated by commas).
Click the "Add Line" button to insert placeholders for additional statements if
necessary. If you want the body of the loop to execute until the occurrence of a condition
but you don't know exactly how many times this will take, use a "while" loop instead.
33
In the placeholder below the "while", enter the statement you want to execute
repeatedly. Use the "Add Line" button to insert placeholders for additional statements if
necessary.
"While" loops are useful when you want to stop execution upon occurrence of a condition
and you don't know exactly when that condition will occur. If you know exactly how
many iterations you want, use a "for" loop instead.
33
Click on a placeholder into which you want to place the "continue" statement.
Click on the Math toolbar to open the Programming toolbar containing the
programming operators.
Click on the "continue" button or press Ctrl+[. Do not just type the word "continue".
When the program encounters a continue, it halts the iteration, goes to the nearest
outer loop, and continues with the next iteration.
33
"Return" statements are useful when you want to return a value from a particular loop.
Trapping errors
Click on the placeholder into which you want to place the "on error" statement.
Click on the Math toolbar to open the Programming toolbar containing the
programming operators.
Click on the "on error" button or press Ctrl+'. Do not just type the words "on error".
In the placeholder to the right of the "on error", type whatever you would like to return,
assuming it can be evaluated successfully.
In the placeholder to the left of the "on error", type whatever you would like to return if
the default return expression cannot be evaluated. Use the "Add Line" button to insert
placeholders for additional statements if necessary.
The right-hand expression is evaluated and returned if no errors occur. If an error occurs,
the left-hand argument is returned.
8.7 Recursion
Recursion is a powerful programming language that involves defining a variable in terms
of itself as shown in this example: Recursive function definitions should always have at
least two parts:
33
9. FOURIER SERIES
In physical sciences we often express functions as series. Power series are
very common, for example the Taylor series. Another important series is the Fourier
series. The Fourier series is a trigonometric series, a sum of sine and cosine terms. The
Fourier series is important because certain functions that cannot be expanded as a Taylor
series can be expanded instead using a Fourier series. The Fourier series is also the
prefered series for representing periodic functions. Examples of periodic functions
include harmonic oscillators, rotors of various kinds, pendulums, etc. Since the Fourier
33
series is a sum of sine and cosine terms it is essentially a periodic series. More generally
we can say that the Fourier series is an expansion of a periodic function, f(x), with a
uniformly convergent series, i.e. a sum of sine and cosine terms, in a range from 'a' to 'b'
where x is greater than or equal to 'a' and less than or equal to 'b'. For a range [a,b] that is
symmetric about zero, if f(x) is an even function, f(-x) = f(x), then only cosine terms
contribute to the sum and if f(x) is an odd function, f(-x) = -f(x), then only sine terms
contribute to the sum. A series is uniformly convergent for a function f(x) if, in a given
interval, the series equals f(x) for every value of x in the interval.
Expansions of a function as an infinite series like this are only possible because the sine
and cosine functions form a complete orthonormal set of functions that fully span the
space of the periodic function that they are being used to approximate.
Mathematically the orthonormal property is expressed as:
b
sc i ( x ) sc j ( x ) dx ij
where sci is either the sine(ix) or cosine(ix) and scj is either sine(jx) or cosine(jx)
and i,j is the Kronecker delta.
i,j = 1 when i is equal to = j
= 0 when i is not equal to j
The following expressions are useful in derivations of the coefficients of the terms in a Fourier
series. These expressions are toggled off in this part of the document.
sin ( n x ) dx
=0
n = 0, 1, 2, 3,....
=0
n = 1, 2, 3, .....
cos ( n x ) dx
= 2
n=0
33
cos ( m x ) sin ( n x ) d x
cos ( m x ) cos ( n x ) dx
= 0 m not equal to n
= m = n not equal to 0
sin ( m x ) sin ( n x ) d x
=0
=
m not equal to n
m = n not equal to 0
The general equations for a fourier series are shown here. Notice the use of a and b for
the coefficients for the cos and sin terms respectively. Here F(x) is the function that is to
be fit by the Fourier series. In the sections that follow you will be lead through a series of
exercises that will put into practice the Fourier series method for both odd and even
functions.
1
a 0 a n cos n x b n sin n x
2
n1
n1
f (x)
an
bn
2
L
F(x) cos n x dx
F(x) sin n x dx
33
Let us start with a simple Fourier expansion for a periodic function, a simple step function.
2
an F (x)cos(n x)dx
0
bn 0
2
bn F (x)sin(n x)dx
0
an 0
When you work with this document do not repeat the exercises using the same
variable names. This will confuse Mathcad and give you a headache trying to debug
your Mathcad code.
Let us start with a simple Fourier expansion for a periodic function, a simple step
function. When you work with this document do not repeat the exercises using the
same variable names. This will confuse Mathcad and give you a headache trying to
debug your Mathcad code.
33
x 3.1
f ( x )
1
2 j 1
sin [ ( 2 j 1 ) x ]
33
x 3.0
2. Then we choose an upper limit for the number of terms in the expansion (the value for
M). Explorations on the effect of changing the upper limit are easily implemented by just
changing the value for M. M is a global variable and is placed below just above the
graph.
n 0 M
M 5
3. Next we have the integral for Bn. In this integral note the presence of the function F(x).
Any odd function can be used here. n is the index used to identify the integrals in the
expansion for the fitting process. Using M and n makes possible a more general
exploration of the series in the area below.
1
B n
F ( x ) sin ( n x ) dx
Ask Mathcad to show several of the Bn coefficients in the Fourier expansion for the
function given here. Comment on their magnitude and the significance of the magnitude
as n increases.
33
Write out the expression that would correspond to the coeficients for the cosine terms in a
Fourier series expansion of this function. Show that several of these An coefficient
values are in fact zero.
4. We wrote f(x) here instead of F(x) so as to prevent Mathcad from overwriting our
original function. We will compare the fourier series fit, f(x), of the function to the
function, F(x), itself as an exercise. Now write out by hand f(x) as the sum of several
terms.
f ( x )
B n sin ( n x )
n 1
Notice M is an upper limit in the sum. Varying M allows rapid and efficient exploration
of the variation of the number of terms in a Fourier expansion. Graphical presentation is a
real time saver in understanding the consequences of changing the number of terms in the
series.
33
me v n rn
n h
---------(1)
---------(2)
Ei Ef
where is the frequency of the energy emitted : Ei and Ef are the energies of initial and
final states. Applying the Coulomb's law of force between the electron and proton:
1
4 0
2
2
me v n .rn
rn
33
rn
----------(4)
1
4 0
2
2
rn
-------
31
me 9.1093897 10
kg
0 8.854187817 10
19
e 1.60217733 10
coul
n h
v ( n )
Kinetic energy of the electron is
sec
joule sec
1
4 0
2
me e
e
34
h 6.6260755 10
4 0
r( n ) 0
c 299792458
k
k
-------------(5)
------------(6)
0 2 n h
1 k e 1
KE( n )
2 r( n ) e
---------------(7)
k e
r( n )
1
e
----------------(8)
---------------------(9)
According to Bohr's second postulate, a hydrogen atom radiates energy when the
electron jumps from one orbit to another of lower energy. The energy radiated is given
by the condition:
Ei Ef
h
KE( n )
1 k e
2 r( n )
PE( n )
k e
r( n )
33
E( n ) KE( n ) PE( n )
E( 1)
2
ni h
E( 1)
2
E( 1)
nf h
ni
nf
( n )
( n )
( n)
10
n 2 3 20
( n )
E( 1)
h
c
( n)
n 3 4 20
33
n
7
10
( n )
E( 1)
h
c
(n)
10
n 4 5 20
( n )
E( 1)
h
c
( n)
n 5 6 20
33
2
n
7
10
( n )
E( 1)
h
c
( n)
10
n 6 7 20
33
2m
Zq 2
0
E
2
4 0 r
where m is the mass of the electron, h is Planck's constant divided by 2, Z is the atomic
number, q is the electronic charge, 0 is the permittivity of free space, and
2
1 2
1
1
2
r
sin
r 2 r
r
r 2 sin
r 2 sin 2 2
in spherical coordinates.
As shown in numerous textbooks, this equation can be separated by the trial solution
( r , , ) R ( r )( ) ( )
The functions () and () are solutions to the separated angular equations and their
products are the spherical harmonics. Solution of the equation gives rise to the
quantum number ml and solution of the equation involves the associated Legendre
equation, which gives rise to a second quantum number l. The integer l corresponds to the
degree of the associated Legendre function while the integer ml corresponds to its order.
A third quantum number n arises from the solution of the separated radial equation R,
which involves the associated Laguerre equation. Its solutions are the associated Laguerre
functions, and their properties require that
l n 1
33
Note for the case in which l = 0, m = 0, MathCad cannot symbolically solve the above
expression for the associated Legendre polynomial. The solution can be shown to be equal to 1.
To plot the resulting spherical harmonic simply type (x): = 1 below.
Substituting cos for x gives as a function of
2
( l m)
The spherical harmonic is given by the product of the and functions.
B
The indices and equations needed to transform the spherical harmonics into Cartesian coodinates
for plotting in Mathcad are contained in the hidden section below.
33
n 3
l 2
Atomic number
Z 1
The solution to the R equation (Laguerre polynomial of the first kind) is given by
where is given by
2 Z r
n
We'll express r in Bohr units (1 Bohr = 0.0529 nm) in this workbook.
( r)
33
The radial wavefunction Rln(r), radial density function Rln2(r), and radial distribution function
4r2Rnl2(r) are plotted below. Note that the scale may need to be modified depending on the
selection of the quantum numbers.
The normalized hydrogenic wavefunctions are the products of the normalized real spherical
harmonics and the normalized wavefunctions. These functions are summarized for the 1s, 2p,
and 3d orbitals.
33
xmax 1
Effective mass:
V( x) 1
Given
1 d 2
( x) V( x) ( x)
2 d x2
Odesolve x xmax
E ( x)
( 0)
' ( 0)
0.1
( x)
( x)
x
max
E 4
33
( x) d x
( p )
x
max
2 0
exp ( i p x) ( x) d x
33
27
q 1.6 10
m 1.67 10
E 0
0.0001
q B
n 0 5000
1000
t n t
n
v
0
10
r 0
0
We integrate numerically the equation of motion a = F/m by using a = dv/dt = (vn+1 vn)/t and v = (rn+1 - rn)/t. This implementation is called the Euler method and its
accuracy depends on the smallness of the time interval: t << T.
33
n 1
n 1
v t
n
q v B q E
m
m n
r t v
n
vy v
n
n
vz
n
y r
n
n
zn
33
or in an expanded form:
Higher degree equations are handled by Mathcad with the root function. The syntax is:
root(f(x),x).
It returns the value of x that makes the function f equal to zero.
defining the constants and parameters:
R 8.3136
a 3.56
b 1.979 10
p 150000
n 1400
T 560
degree equation there are three solutions and which root is found
depends on the initialization value. Of the three roots, only one will
have physical meaning. In other words a negative or a complex value
for the volume, although mathematically correct, has no physical
meaning.
guess value
V 10000
a n
V root p
( V nb) nRT V
2
V .1
33
Instead of making wild guesses, the function can be graphed, and the intercepts with
the apscissa easily recognized:
V 0 100
QUESTIONS
1. Explain the method of creating two and three dimensional graphs.
2. Discuss the following (a) Formatting math and text (b) formatting results.
3. Explain the following (a) using units (b) creating the programs.
4. Explain the theory of Fourier series and write a mathCAD program to find a Fourier Series for an
odd function.
5. Explain the Bohrs theory of atomic structure and write a mathCAD program for studying the
various Series of Hydrogen Spectrum.
6. Explain the MathCAD procedure to find the numerical solution of Schrdinger wave equation.
7. Discuss the MathCAD procedure to study the Lorentz force.
8. Discuss the MathCAD procedure to study the Van-der-Waals equation.
33
CHAPTER-4
COMPUTER ORIENTED NUMERICAL METHODS
1. Euler's method of solving ode
2. False-position method
3. Fixed point iteration procedure
8.
Range-Kutta method
33
y'
dx
( x y)
f ( x y)
x 1
Note that a derivative "function" can be denoted in the same way as the original function
from which it came.
f' ( x y)
( x y)
2
x 1
In order to obtain the required relationship between variables we need a starting point,
commonly called an initial condition: y ( 0)
1,
c 1
.5 .
g ( x ) c x 1
A very practical
way of proving this is the case is by simply substituting y' and y into the original ODE to
generate an identity
taking the derivative of g(x) we get:
y'
1.0 x
33
x2 1 1.5
Substitute y' and y into the original expression. If y is a root we will get an identity
1.0 x
x2 1 1.5
simplify :
.5
x c x 1
x 1
c
x2 1 1.5
x 2 1 1.5
We get an identity, thus proving g(x) is a solution of the original equation. Now we have
an analytical solution with which we can compare our numerical solution.
In calculus you learned that if you had a function you could differentiate it to get the
"derivative function". If you had the derivative function you could integrate it to get the
original function back again. Thus, one of the first ways you learn for solving simple
differential equations is to simply integrate the derivative function analytically. However,
this is not always easy, or even possible. In such cases we resort to "numerical methods".
One of the first numerical methods usually learned is Euler's explicit method. Euler's
method depends on writing the differential equation to be solved as a "finite difference
approximation".
y'
d
dx
f ( x y)
( x y)
2
x 1
( x y)
2
x 1
or y
( x y)
2
x 1
Now, if we let y
yi yi 1
yi
yi 1
x i 1 yi 1
x i x i 1
x i 1 2 1
a recursive relationship. If
we have an initial condition we can use this equation to compute a sequence of y values.
33
The values of y are values of the solution function you are trying to get. The derivative
function (which you have) allows you to compute the slope between the points. The
approximation in Euler's procedure arises as a result of our estimate of the slope. We have
evaluated the slope between
x i yi
and
x i 1 yi 1
yi+1 = yi + f`(x,y)*h
f'(x,y)
k1
h
xi
x
xi+1
These are the estimates of points on the solution of the differential equation
f'(x,y) is the slope of the tangent line to the solution function at x,y
We will use this function to rate the accuracy of our estimates. Each method will rely on
iteratively estimating values at N+1 evenly spaced points on [0,L]. Here, we take
33
N 250 number of intervals into which the domain is to divided, the dependent variabl
is then approximated at each point
1
h L N
Define
sequences recursively by
y0 1
x i i h
yi 1 yi h f' x i yi
Effectively, we are progressing along the tangent-line to each y value to estimate y at the
next point on the curve.
Introduction: The false position procedure is a method for locating the roots of equations
based on the fact that the equation changes sign as it crosses the x axis. The method
requires 2 initial guesses which result in functional values with different signs. The false
position procedure is generally considered an improvment over the bisection method in
that it takes into account the fact that one of the initial guesses may be located quite close
to the root. An estimate of the root is made using the equation below. This estimate then
replaces one of the original endpoints and the procedure is repeated.
xr
xu
f x l f x u
f xu x l x u
Use the false position method to solve the following family of equations
f ( x n)
x 1.
We will see that the number of iterations required to get an acceptable root is heavily
dependent on the value of n.
x .01 .015 1.5 plot the function for a range of values, hopefully bracketing a root
n
equation to be solved
f ( x n) x 1
x l .01
x u 2.5
when possible, plot equation(s) to locate roots check to see if xu and xl bracket a root. Guess
again if the product below is > 0
33
Observation : Note that the higher the values of n the sharper the degree of curvature of
the function and the flatter the curve is on either side of the turn. It is this degree of
curvature which makes the root of the equation difficult to locate.We now create an
algorithm for false position procedure which stores sequences of root estimates as well as
sequences of end points.
Mathcad programs are in the form of functions
false_position_root x u x l n
. The items in
the parentheses are the inputs to the function, in this case the upper and lower guesses
and the value of the exponent in the equation being solved.
33
false_position_root x u x l n
i0
store initial
guesses
in a vector
upi x u
downi x l
if f x u n f x l n
f x l n f x u n
break if f x u n f x l n 0
f x u n x l x u
xr xu
f x l n f x u n
xu
f xu n xl xu
if x u and x l don't
bracket a
root, stop
store initial and
subsequent root
estimates, x r , in
si x r
vector
x rr x l
while
x r x rr
.000005
x rr
x rr x r
x u x r if f x r n f x l n 0
upi 1 x u
x l x r if f x r n f x l n 0
downi 1 x l
xr xu
establish stopping
criteria based on
approximate relative
error. While loop is
executed as long
as condition is true
set current value
of guess to
old value, x rr
determine which
endpoint
current x rreplaces
f x l n f x u n
f xu n xl xu
compute next x r
and store it in s
vector
si 1 x r
ii1
increment counter
( s up down i )
create a matrix containing the estimates of the root together with the upper end points for
each iteration, lower end points for each iteration and the number of iterations completed
The outputs of the function are the values on the last line of the program:
n 0 10
soln0 n false_position_root x u x l n
run the program for each value of n, store the results in a vector called [soln]
each element in [soln] is itself a 1 row 4 column vector
33
soln0 4
row, 1 column vectors and a number. The number is the number of iterations it took to get
the solution for that value of n.
range of the value of the exponent :
n 0 10
The number of iterations to get to the root rises exponentially as the value of n.
Lets examine just how the algorithm approaches the root for a specific value of n. Plot
3
x r soln0 3
0 0
x 1
.....
i 0 soln0 3
03
x u soln0 3
0 1
x l soln0 3
0 2
33
Now do the same for n = 9. Note the increase in the number of iterations required.
i 0 soln0 9
03
x r soln0 9
0 0
x u soln0 9
0 1
x l soln0 9
0 2
33
Note that in this case each sequential root estimate is always extremely close to the last
lower limit used but it takes a very large number of iterations for the root estimate to
converge acceptably.
So
m g
k
m g
2
k
ft
g 32.17
k t
m
1 exp
acceleration of gravity
sec
k 0.1
lb
sec
coefficient
Suppose So = (see below) ft., m = 0.25 lb and k = 0.1 lb-sec/ft. Use the fixed point
iteration method to find, within 0.01 sec., the time it takes for this object to hit the
ground.
mass .25lb
S o 300 ft
S ( t) So
mass g
k
33
mass g
2
k t
mass
1 exp
S ( t ) So
f (t)
mass g
k
mass g
2
k t
mass
1 exp
According to plot below the mass strikes the ground after about 6 seconds
g (x) .
f (x)
and converting
g ( t ) . This
g (t)
is done by rearranging f ( t )
f (t)
shown below:
33
y
x = f(x) denoted by
g(x) = 0
y = x
y = f(x)
xi+1
root of g(x) = 0
x
xi
The fixed point iteration procedure converts g(x) = 0 to the form x = f(x)
The recursive version of the fixed point procedure is : x i+1 = g(xi)
mass g
S So
mass g
k t
mass
1 exp
mass g
k
mass g
t
k t S
o
mass
1 exp
mass g
k
g (t)
mass g
2
ti 1
k ti
So
mass
1 exp
mass g
k
N 15
i 1 N
iteration number
33
mass g
2
ti
k ti1
So
mass
1 exp
mass g
k
Discussion : The fixed point procedure is an "open method" meaning that initial guesses
bracketing the root are not required. The price to be paid for this is that the solution
sequence may diverge, or not converge to a solution. In addition, a number of equations
of the form f(t) = 0 can be put into the form t = g(t) in more than one way and the
behavior of the these variations may be different, that is they may not all converge or
converge to the same solution.
33
prediction. The procedures are numerically explicit and they generally have the accuracy
of the corrector (implicit method). They are only conditionally stable however and the
minimum necessary step size may not be much larger than that of the explicit predictor
method. However, they avoid the problem of repeated solution of nonlinear equations.
Solution of the equation governing the radiation of heat from a lumped mass (sphere) at
an initial temperature To to the environment temperature at Ta.
The governing differential equation is:
where:
radius of sphere
d
dt
T4 Ta4
f ( t T)
r 1.0 cm
8000
5.67 10
sec m K
kg
m
time step :
t .5 sec
initial temperature
T0 2500 K
ambient temperature
initial time
Ta 100 K
t0 0 sec
33
C 500
J
kg K
NOTE: By "playing around" with lumped mass properties students will (hopefully)
eventually realize there is a tradeoff between the value of and the required
computational step size. As gets larger the required t gets smaller. Also, the
computational interval affects how well the predicted and corrected temperatures agree.
d
dt
T4 Ta4
f ( t T)
equation to be solved
The mass temperature at any time is equal to the temperature at the end of the previous time
step plus the incremental change during the current interval.
Tn = Tn-1 + (dT/dt) (t)
fp
yp
yp t fp
n
fp
f tp yp
n 1
n 1
yC
n 1
n 1
yn
1
2
dt
T
explicit prediction
t fp fp
n
n 1
f ( t T)
implicit correction
N 10000
n 1 N
tn tn1 t
( T t) T Ta
4
Tp
Tn1 Tn1 tn 1 t
d
dt
Note that we insert the RHS rather than the variable T p in the
expression below. If we had inserted Tp the loop would have broken, as there is no way
to redefine Tp as Tn in the next time step.
33
Note that in order to implement the procedure using subscripts instead of actual
programming we write each expression such that the same variable name is used on each
side of the expression differing only in the time subscript. If we change the variable name
there is no way redefine the current value as the previous value in the next step. The
expression below is the entire predictor-corrector method written in terms of T n and Tn-1
where n and n-1 are real subscripts referring to the time step.
Since :
( T t)
d
dt
( T t) t
Tnew
1
2
Told ( T t) t
Tn 1 tn1 Tn 1 Tn1 tn 1 t tn t
Conclusion : It takes a while (> 81 minutes) for even a small sphere (r = 1 cm) at an
initial temperature of 2500 K to cool to an ambient temperature of 100 K via radiation
alone.
33
2 L
0.5 f V
where:
P= pressure drop
D = pipe diameter
= fluid density
V = fluid velocity
L = pipe length
Several empirical formulas exist for the friction coefficient as a function of the Reynolds
DV
turbulent regime between completely smooth pipe and wholly rough pipe surfaces
Colebrook developed an empirical equation for the friction factor
1
1
_D_ratio 2.51
2 log
3.7
Re f
Develop a procedure to determine f for specified values of /D and Re. Use the
approximation proposed by Genereaux (1939) ,
0.16 Re
.16
, to determine an initial
33
f(x)
xi+1 = xi -
f(xi)
f '(xi)
f '(x1)
recursive equation
f ' (x2)
f(x1)
f(x2)
root
x2
x1
SOLUTION - find the friction factor using the Newton Raphson procedure. Define
values for /D and the Reynolds Number
_D_ratio
_D_ratio .001
n 6
Re ( n) 10
_D_ratio
F ( f ) 2 log
3.7
2.51
Re ( n) f
F' ( f )
Re ( n) f
3
2
2.51
ln ( 10)
.270 _D_ratio
Re (n) f
33
2f
33
6. NUMERICAL INTEGRATION-3/8
SIMPSON RULE
Stream cross sectional areas (A) are required for a number of tasks in water resource
engineering, including flood forecasting and reservoir design. Unless electronic sounding
devices are available to obtain continuous profiles of the channel bottom, the engineer
must rely discrete depth measurements to compute A. An example of a typical stream
cross section is shown below. The data represents places where a boat was anchored and
depth measurements taken. Estimate the cross sectional area of the channel.
33
distance
depth
6.5
13.00
19.5
26
32.5
39
Data
46.5
5.5
52.5
59
65.5
72
ft
3.5
2.8
1.4
78.5
n 12
number of points
h 6.5 ft
disti Data i 1
depthi Data i 2
i 1 2 11
Area
or
i 1 2 n 1
j 2 3 12
depthi depth j
i
h ft
33
i 1 3 n 1
j 2 4 n
Area 2
k 3 5 n 1
( width) ( average_height)
2h
segments
Area 2
f ( 1) 4 f ( 2) f ( 3)
6
segments
depthi 4 depth j
Area 2 2 h
depthk
Area 3
( width) ( average_height)
segments
Area 3
segments
i 1 4 n 2
Area 3 ( 3 h)
3h
8
( f ( 1) 3 f ( 2) 3 f ( 3) f ( 4) )
j 2 5 n 1
depthi 3
k 3 6 n
depth j
l 4 7 n 2
depthk 3
depthl
If the average flow velocity in the stream is 6 fps what is the flow rate?
33
7. PREDICTOR - CORRECTOR
METHOD
Introduction: There are a number of Euler type solution techniques for first order
differential equations. The explicit Euler procedure is simple but only conditionally
stable. The implicit procedure can result in the need to solve nonlinear equations but it is
unconditionally stable. Pedictor corrector methods offer a compromise. An explicit
method is used to predict the solution and an implicit method is used to correct the
prediction. The procedures are numerically explicit and they generally have the accuracy
of the corrector (implicit method). They are only conditionally stable however and the
minimum necessary step size may not be much larger than that of the explicit predictor
method. However, they avoid the problem of repeated solution of nonlinear equations.
Solution of the equation governing the radiation of heat from a lumped mass at an initial
temperature Tinit to the environment temperature at Ta.
A
mass C
where:
A = surface area of mass
A
mass C
A = surface area of mass
8
.4
mA=mass
kg
100 of the body,
C 10
mass 4000
d
dt
T4 Ta4
33
f ( t T)
t .5
equation to be solved
The mass temperature at any time is equal to the temperature at the end of the previous
time step plus the incremental change during the current interval.
Tn = Tn-1 + (dT/dt) (t)
Modified Euler Predictor - Corrector solution algorithm:
Tn Ta
4
fn
yp
yn t fn
fp
f tp yp
n 1
n 1
n 1
yn
yC
n 1
1
2
f ( t T)
explicit prediction
t fn fp
n 1
implicit correction
Mathcad programs are in the form of functions. The items in the parentheses are the
inputs to the program.
fct Tinit Ta t
n0
initialize counter
T0 Tinit
initialize temperature
while Tn 500
4 Ta4
Tp
Tn t f n
n 1
fp
f n Tn
n 1
Tn
Tn 1 TC
n 1
Tn Tn 1
nn1
n 1
Tp
n 1
TC
TC
n f fp Tp
1
2
4 Ta4
t f n fp
n 1
set TC = Tn
output vector
33
TC soln0 0
i
i
Tp soln0 4
i
i
f ii soln0 2
ii
fp soln0 3
i
i
33
d
dx
f ( x y)
Here we are interested in finding a function, y = f(x,y), such that its derivative satisfies
the original differential equation. In general, a numerical procedure for solving such
equations involves rearrangement of the equation to a finite difference form:
y
f ( x y) x
yi f ( x y) x 2 x 1
yi 1
In words the above equation can be stated as: "new y value = old y value + (function
slope)(x)". The given equation therefore is the slope of the desired solution function at
any point.
Runge Kutta methods achieve the accuracy of a Taylor series approach without requiring
calculation of higher order derivatives. There are a variety of methods but all can be cast
in the generalized form:
x i yi h
yi x i yi h h
yi 1
interval, h
A Second Order Runge Kutta Method
The simplest method works for differential equations of the form y' = f(x,y):
Note: we are operating on a function which specifies the derivative of another function.
Our solution will be the functional relationship between x and y. We must also have an
intial condition, namely:
y' x 0
y0
f' ( x y)
O.K. we are looking for the numerical approximation of a function, f(x,y), whose
derivative at any point is equal to y
Select an increment h:
h .2
33
( x y h) f' x
x i x 0 i h
N 500 i 0 N
and 1.
3. Now use:
yi 1 yi h x i yi h
f' x
h
2
f' ( x y)
ydep x ind e
x ind
also written as x
ln ( y)
x ind 0 .2 100
x ind
returns
xind
solution to the given ODE, y' = y If we plot the analytical solution we see that it exhibits
pronounced curvature once x approaches 9 to 10. This type of behavior is difficult to
reproduce with a numerical approximation algorithm. We will verify this fact by
evaluating and plotting both the analytical solution and the numerical solution on the
same set of axes.
33
Now let's compare the analytical and numerical solution techniques. We plot them on the
same set of axes below. We have used a log scale for the y axis to better see the solutions
over a wider range of x. At first glance the two techniques appear to give essentially the
same result. However this misleading and occurs because the solution to each gets very
large very fast, thus masking the difference.
QUESTIONS
1. Explain Eulers method of solving Ordinary differential equation.
2. Explain the False-position method of solving ODE.
3. Explain the Fixed point iteration procedure for solving ODE.
4. Explain Modified Euler predictor corrector method.
5. Explain the Newton-Raphson method.
6. Explain Numerical Integration-3/8 Simpson Rule for integrating a function with
given conditions.
7. Explain the Predictor - Corrector method.
8. Explain the Range-Kutta method.
33
CHAPTER-5
MATHCAD PROGRAMS TO PHYSICS PROBLEMS
1. Numerical solution of Schrdinger wave equation
2. Harmonic oscillator
33
1. NUMERICAL SOLUTION OF
SCHRODINGER WAVE EQUATION
1.1 HYDROGEN ATOM
The hydrogenic atom wavefunctions will also be used as the basis functions in the Linear
Combination of Atomic Orbital (LCAO) method. The Schrodinger equation for the
hydrogenic atom used in the LCAO method is
2
2m
Zq 2
0
E
2
4 0 r
where m is the mass of the electron, h is Planck's constant divided by 2, Z is the atomic
number, q is the electronic charge, 0 is the permittivity of free space, and
2
1 2
1
1
2
r
sin
r 2 r
r
r 2 sin
r 2 sin 2 2
in spherical coordinates.
As shown in numerous textbooks, this equation can be separated by the trial solution
( r , , ) R ( r )( ) ( )
The functions () and () are solutions to the separated angular equations and their
products are the spherical harmonics. Solution of the equation gives rise to the
quantum number ml and solution of the equation involves the associated Legendre
equation, which gives rise to a second quantum number l. The integer l corresponds to the
33
degree of the associated Legendre function while the integer ml corresponds to its order.
A third quantum number n arises from the solution of the separated radial equation R,
which involves the associated Laguerre equation. Its solutions are the associated Laguerre
functions, and their properties require that
l n 1
The spherical harmonics give atomic orbitals their characteristic shapes. The effect of
changing the quantum numbers on the and equations can be explored below.
l 1
m 1
1
2
Letting x = cos , the solution to the equation (associated Legendre polynomial of the
first kind) is given by
Note for the case in which l = 0, m = 0, MathCad cannot symbolically solve the above
expression for the associated Legendre polynomial. The solution can be shown to be
equal to 1. To plot the resulting spherical harmonic simply type (x): = 1 below.
Substituting cos for x gives as a function of
33
2l 1 ( l m)
2
( l m)
The indices and equations needed to transform the spherical harmonics into Cartesian
coodinates for plotting in Mathcad are contained in the hidden section below.
33
n 3
l 2
Atomic number
Z 1
The solution to the R equation (Laguerre polynomial of the first kind) is given by
where is given by
( r)
2 Z r
n
The radial wavefunction Rln(r), radial density function Rln2(r), and radial distribution
function 4r2Rnl2(r) are plotted below. Note that the scale may need to be modified
depending on the selection of the quantum numbers.
33
The normalized hydrogenic wavefunctions are the products of the normalized real
spherical harmonics and the normalized wavefunctions. These functions are summarized
for the 1s, 2p, and 3d orbitals here.
33
xmax 1
Effective mass:
V( x) 1
Potential energy:
1 d2
( x) V ( x) ( x)
2 dx2
Odesolve x xmax
E ( x) ( 0)
' ( 0)
( x)
0.1
( x)
x
max
E4
33
( x)
dx
( p )
x
max
2 0
exp ( i p x) ( x) d x
33
2. Harmonic Oscillator
Goal: to provide students with a working document through which they can explore
some of the properties of the quantum mechanical harmonic oscillator
Objectives:
1. Students will be able to obtain any required Hermite polynomial from the
recursion formula.
2. Students will be able to prepare graphs of and * as a function of x for any
quantum
mechanical harmonic oscillator state.
Students will be able to discuss the shape of the curve and its significance.
The wave functions for the n non-degenerate harmonic oscillator states are given by:
n Nn Hn x e
x
2
(1)
Identify each part of this wave function being sure to specify how it is significant for
the solution to the Schroedinger equation for the harmonic oscillator.
In this section we will develop the first 7 wave functions.
The various components can be written as follows:
This identifies the set of vibration numbers to be used in this exercise.
n 1 2 7
k 4
h
let 1
N( n )
1
n
2 n
33
n 1
Given
H( x)
( 1) exp x
n
n
dx
(2)
exp x
(3)
Find ( H( x) )
2 exp x x exp x
(4)
This equation can be simplified by highlighting all of the right hand side of the
expression and then choosing Simplify from the Symbolic Menu. The result is
shown here:
H1
2 x
33
0( x) N( 0) H0 e
1( x) N( 1) H1( x) e
Compute the area under each curve. Two examples are given below.
Do two more and then predict what will be the value of the integral for the others.
Explain the significance of this result.
Note: normally integration would be done from - to +his causes an
overflowing MathCAD.
Large numerical limits are used as a substitute. In cases like this the value for the
limits can be determined from the behavior of the function when it is graphed.
33
3. LEARNING MOLECULAR
SYMMETRY-H2O, NH4
Symmetry operations
All symmetry operations in 3-dimensional space can be represented by 3x3 matrices. The
simplest, E operation, is represented by a 3x3 identity matrix created by the command
identity(3).A rotation of angle along z-axis is represented by: In the space to the right
type identity(3)= to see the 3x3 identity matrix..
In general, a rotation of angle about any unit vector, A, passing through the origin, is
represented by:
33
This is the matrix representing a rotation of 90 degree about the z-axis. We will then use
Eq.[2] throughout the discussions. A reflection by a plane that is perpendicular to the zaxis is represented by :
These few matrices will give us sufficient tools to conduct algebric operations on
molecules.
33
Exercise 1: Write an arbitrary unit vector and write a 90 degree rotation matrix, a
reflection matrix on a plane that is perpendicular to this unit vector. Find the
determinants of these two matrices. What do you discover ? These symmetry matrices are
often called unitary matrices. Do you know why?
First column represents the x-coordinate of three atoms; 2nd column, the y-coordinates;
3rd column, the z-coordinates. First row represents (x,y,z) for the oxygen atom; two
hydrogen atoms are represented by the second-row and third-row of the matrix.If we
want to graphically represent 2 OH bonds in the water molecule, we may want to express
water molecule matrix as follows:
33
Internal Coordinates
33
Fig 4 can be further simplified, if we use internal coordinates such that the
oxygen atom is set as the origin, and the principal axis of rotation is set as the zaxis.By substracting (x,y,z) coordinates of O from H1(and H2), we have r1 and r2
as coordinates of two hydrogen atoms.
We still need to define the principal axis of rotation, which is a unit vector between 2 OH bonds
33
Exercise 2: Write x, y, z, r1, r2, and OH1 OH2 above and beside the matrix in Eq [8]
similar to those written on Eq.[6] Align C2 axis with a unit vector along the z axis The
procedures to align principal axis of rotation with a unit vector along the z-axis involve
rotation operations through 3consecutive Euler angles.
To align A with the z axis, we first rotate A about z-axis with an angle of =(90-26.224)
degree. This essentially align A with the x-axis. A second rotation of 90 degree will align
A with z axis. We can experiment the rotation operation as follows
33
The Euler operator defined in Eq.[10] can be used to linearly transform both OH bonds as
follows:
33
Exercise 3 Write x, y, z, O, H1, H2 over or beside the matrix NewH2O (Eq.[12]) similar
to those shown in Eq [5b].
33
Reflection of OH1 vector with v1 returns OH2 and vice versa. Reflection of OH1 with
v2 returns to itself.
Exercise 5 Show these symmetry elements satisfy Group Property [1]: If A, and B are
elements of a group then AB is an element of a group.
Exercise 6 Demonstrate the associative property for these elements: If A, B, C are
elements of a group, then (AB)C=A(BC)
Exercise 7 What is the inverse of the element of C2 ? Is the inverse of C2 also a
33
You may also notice that the determinants for these matrices are either +1 or -1:
Exercise 8: Are these symmetry matrices Hermitian (the transpose of a conjugate equals
to itself) ? If they are, what are their eigenvalues?
Exercise 9: Are these symmetry matrices symmetric ( the transpose equals to itself) ?
Exercise 10: Are the eigenvectors of these matrices orthonormal ? An example of
orthonormal properties for C2 is shown here.
33
3.2
The HyperChem ammonia coordinate data (the unit is Angstrom) are shown as follows:
The matrix NH3 consists of coordinate data of NH3; N in the first column (x=(-0.6121),
y=(-0.3974), z=0.5807; H1 in the second column, H2, the third column, H3 in the 4th
column. Three vectors (r1, r2, r3) that connect the central N atom and each of the three
individualH atom can be created from the data in Eq[20]. Shown below are the Mathcad
commands to extract data and generate vectors. Remember, in Mathcad, we use [ for the
vector or matrix subscript to extract data.
33
The matrix r in Eq[21] is made of three N-H vectors. All three H-atoms have the same
z-coordinates implying that they are in the same plane. It indicates that the unit vector
along z-axis is a unit vector for C3 rotation. Z-axis is the principal axis of the rotation.
33
Exercise 13: Determine the angles between two arbitrary NH bonds. How close are these
angles to the tetrahedral angles ?
Exercise 14: What are the bond lengths for any of the NH bonds ? Are the bond lengths
reasonable?
C3 Rotation
The right-hand side matrix for C3*r is essentially the same as the left-hand side matrix in
33
Eq.[23] except the numerical value -2.642 x 10-4 for C3*r11 on the left is set to zero on
the right. The matrix is disabled by right-clicking on the box to disable the evaluation.
Exercise 15 Is C3 a Hermitian operator? Is C3 a symmetric operator? If not, find the
eigenvalues and eigenvectors for C3. Are the eigenvalues real numbers? Are the
eigenvectors orthonormal?
Reflection
These reflection planes are perpendicular to vectors: H1-H2, H2-H3, and H3-H1
Exercise 15: Write three vectors that are perpendicular to the reflection planes. One of
the
vectors is wriiten here as A1. Write the other two vectors.
Exercise 16 Demonstrate that the ammonia molecule has three such reflection planes of
symmetry. One demonstration is shown here. Complete the rest.
33
operations.
You need to write 4-CH vectors, and check whether they are tetrahedrally oriented . The
experience you have gained through the previous ammonia exercises will help you to
write such vectors.
Exercise 19 Find the bond angles between any of these 4 bonds. Find the bond lengths
for all these bonds. Do they agree with the definition of a tetrahedral molecule?
33
Exercise 20 Write x, y, z, C, H1, H2, H3,H4 over or beside the matrix CCH4 (Eq.
[28]) similar to those shown in Eq [5b].
33
Now, let us look at the C4 operation about A with each CH bond of the CH4
molecule. What do you discover?
You can see that none of the column vectors in r <0> is the same as C4*r. On the
other hand,
as for the rotation-reflection operator, S4*r=Refl(A)*C4*r
After the S4 operation, r<0> becomes r<1>. You can repeat the operaion for other column
vectors.
Exercise 22 Using other axes of rotation, construct new S4 matrices. Does S4 on these
new axes return the molecule to itself its original configuration?
S4 in methane is not Hermitian, it is unitary
33
This means that lengths of the transformed C-H bonds are conserved:
4. NUMERICAL SOLUTION OF
SECOND ORDER DIFFERENTIAL
EQUATION
4.1
Introduction
In this document we will explore the use of numerical methods for solving second order
differential equations. As an illustration of this technique we choose both the classical
and quantum mechanical harmonic oscillator problems. In the classical case the solutions
were written easily. For the quantum mechanical oscillator the solutions consisted of
polynomials that were obtained by requiring that these solutions were well behaved
functions.
So suppose you did not know the analytic solutions to the classical and quantum
mechanical oscillator differential equations. Is there a method that you could use to
understand the properties of the harmonic oscillator solutions without requiring explicit
solution of the differential equations? In other words is it possible to use a method that
would produce numerical answers for the differential equations? We would then plot
these answers and visualize the solutions. In the case of the harmonic oscillator we would
33
then also be able to compare our results with the known solutions and make a preliminary
assessment of the value of numerical methods.
In this Mathcad document we will explore a technique for finding graphical solutions to
differential equations. The method is numerical rather than analytical, i.e. the analytical
form found by direct solution of the differential equation is not used. The differential
equation is written and the graphical solution bracketed by successive approximations to
a fitting parameter. The choice of fitting parameter and variations in it are guided by
inspection of the graphical behavior of the function at the boundaries of the physical
model described by the differential equation. The function must satisfy these boundary
conditions. In the case of the classical harmonic oscillator described in the background
section of this document, at time zero the function X(t) equals the maximum extension of
the oscillation and at this point the first derivative of X(t) equals zero. Furthermore the
range of the numerical solution extends from time = 0 to time = the period of the
oscillation.
4.2 Goal
To provide an introduction to the use of numerical methods for solving quantum
mechanical problems.
4.3 Prerequisites
1. College calculus including differentials and integrals. You should know what a second
derivative is.
2. Basic skills with Mathcad.
4.4 Objectives
1. Explain the relationship between a physical model and the differential equation
representing that model.
33
2. Discuss the relationship between the shape of the curves that are solutions to
differential equations and the properties of the physical system described by the
differential equations.
3. Compare and contrast the analytic solutions of the harmonic oscillator classical model
and quantum mechanical oscillators to each other.
4. Compare and contrast the graphical solutions obtained by numerical methods for both
oscillators.
4.5 Background
First we can review some of the basic ideas about the classical harmonic oscillator model
and equation. The equations in this section of this document are not Mathcad active. They
are images inserted into the text by paste/special/picture from equations written in
MSWord6.0.
The differential equation for the classical harmonic oscillator is:
d 2 X (t )
k
X (t )or
2
dt
m
k X (t )
X
m
--------------(1)
A standard approach for finding the solution to a differential equation like this is to try a
guess for the solution to this differential equation. A good choice would be some
oscillatory function like a sine or cosine function. A better guess would be a sum of the
two possibilities as written next.
X (t ) A cos(bt ) B sin(bt ) --------------------(2)
Next use the boundary conditions to determine A and B. One boundary condition we will
impose is that at time zero the value of X(0) is the maximum extension of the spring. This
maximum value of X is the amplitude of the oscillation, namely AMP.
so AMP A cos(b0) A
---------------(3)
Now we must determine the value for B. For this we do the following:
33
------------------(5)
so X (t ) AMP cos(bt )
-------------------------------(6)
k
m
---------------------(7)
Question: Write the final solution to the classical harmonic oscillator differential
equation. Provide the units for k and the significance of k for the oscillator. Describe
how k can be used to model the strength of a chemical bond.
4.6. The Classical Harmonic Oscillator Using the Numerical Solution Algorithm
In this section we will examine the implementation of the algorithm step by step. After
analyzing the process you will be directed to apply it to the quantum mechanical
harmonic oscillator. Later you will also be able to use another Mathcad document 2, 3 to
explore the solutions to the radial function for a spherical potential problem. You will
then be better able to describe and interpret two of the classic quantum chemistry models
that lie at the core of the discipline. So now let's get started.
First write the differential equation with f(t) being a constant k/m:
dt
X( t )
X( t)
k
m
33
To use this numerical method make a grid that spans the range of the problem. Here we
set the grid for 300 computed points. This will adequately span the range for this and
most problems. We need a large number of points so that the distance between points
throughout the whole range is small.
n 300
Next choose values for any parameters that appear in the differential equation. In the
equation in this introductory example this is the constant k. For simplicity let k=1 and
m=1. You are free to change k later as it is defined as a global variable below. Changing
m would require adjusting the algorithm equation for Xi. Since initially we want to focus
on k we will not include m in the equations to follow.
k 1
m 1
Mathcad will plot the computed 300 points using the difference algorithm shown in
equation 8. The solutions appear as plots of X(t) versus t.Here we set the time scale range
for the problem. For the simple classical harmonic oscillator the range here is the period
of the oscillation. You may choose any values to start. These too can be changed later. In
differential equations for real physical situations the range will be determined by the
physical context of the problem. Experience will allow you to set good ranges.
tmin 0
tmax 5
Compute the parameter. is the spacing between the grid points. In effect tmax is the
period of the oscillation.
tmax tmin
n
i 0 n
t tmin i
i
Set the initial values for X(t). The algorithm depends on the difference between
successive estimates of X(t) as the calculation steps through all the i values of the grid.
The choice of the two initial values for the function X(t) is somewhat arbitrary but
33
depends on the system you are studying. For the simple function in this initial exercise
you can use other values for X 1 and the result will be the same. Other functions that you
may try in a Quantum Chemistry course are more sensitive and require that the two initial
values for the function be rather closely spaced. Only trial and error and experience will
tell you how to proceed. This is part of the process of becoming an expert problem solver.
X 4
X 4.001
0
1
Now step through the algorithm. That is:
Implement the algorithm by computing X(t) for all values of i > 1. (Remember i = 0 was
the first one. The default in Mathcad is zero as the start of all array subscripts.) X 0 and
X1 were assigned values in order to start the process. We can think of these as seed
values for the algorithm.
i 2 3 n
The big equation shown below is the differential equation
solution algorithm.
2
2 X
X
i1
i 2
12
k X
1 k
k 1.0
i2
10 k X
i 1
12
The parameter k is set as a global variable. Adjust the value of k here to the left and
determine the value of k for which the curve equals X0 at the two ends of the range.
A preliminary graphical solution is shown here to the left. This solution clearly does not
give the correct value for the amplitude at the two extremes of the period of oscillation
that we chose at the beginning of the exercise. Adjust k until the function equals 4.0 at
both ends of the range. Adjust the graph layout to show grid lines and the correct range
that matches your differential equation.
33
Questions:
What is the range for this differential equation?
Find values of k that give a graphical solution with zero, one, and two nodes. A
graphical solution occurs when Xi = 4 at t equals 0 and at t equals the period of the
oscillation.
How does the value of k seem to vary for solutions that have different numbers of
nodes?
33
In the sections below, wavefunctions for the ionized hydrogen molecule are first obtained
by using the linear combination of atomic orbitals (LCAO) method and then by solving
the exact Schodinger equation using the numerical technique known as the Shooting
Method. The solutions from the two different techniques are then compared. In both
cases, the protons are assumed to be fixed at a distance rAB apart using the BornOppenheimer approximation [5] since they are much more massive than the electron.
Lines of constant r are circles around the proton, while constant defines a line
extending from the proton. Rotation about an axis creates spheres for constant r and
cones for constant , which can be described in spherical coordinates, where is the
angle of rotation.
Linear combinations of the atomic hydrogen orbitals can be used to approximate the
orbitals of the ionized hydrogen molecule. Both the sums and the differences of these
atomic orbitals must be considered, which suggests the trial molecular orbitals
33
(4a)
and
(4b)
for orbitals centered on protons A and B, respectively. We'll assume the protons are two
Bohr apart.
rAB 2
Thus, substituting the expressions for rA and rB given above transforms them into the
following expressions in spheroidal coordinates:
1sa
rAB
2
e
1sb
33
rAB
2
e
To determine the coefficients with the variational principle, we need to calculate the
overlap integral, which in spheroidal coordinates is given by
1 0
1sa 1sb
rAB
8
d d d
1g cb 1sa cb 1sb
1u ca 1sa ca 1sb
Here is the plot of the LCAO approximation of the 1g orbital and its probability
distribution.
33
Here is the plot of the LCAO approximation of the 1u orbital and its probability
distribution.
Here is the plot of the LCAO approximation of the 1u orbital and its probability
distribution.
33
The terms contributing to the total electronic energy of the helium atom are the kinetic
energy of each electrons interaction with the nucleus, and the interaction of the electrons
with each other.
Calculate kinetic energy:
33
Write the equation for the total electronic energy in terms of the
variational parameter and minimize the energy with respect to :
Compare optimized trial wave function with the HartreeFock wave function (see
McQuarrie and Simon, page 283) by plotting the radial distribution functions.
33
33
MAS 5
E 0.008
EoverV 0.9
Set the ratio of the particles energy to the barrier height. This
value should be kept less than unity.
WID 5
E
Vo
EoverV
Here we calculate the wavefunctions, which are found by solving the Schrodinger
equation !You need not know the details of
this coding.
K2
2 MAS ( Vo E)
A1 1.
A3
Wid0 WID
z 1
z K1 K2
2 K1 K2
sinh(K2WID)
A1p
A2
K1 2 MAS E
factor
2 K1 K2
0.5
K2
z K2 K1
i 1 100
x 5 WID i
i
A2p A1 A1p A2
10 WID
100
i
i A1p cos K1 xi z sin K1xi
P2 A2 exp K2 x A2p exp K2 x
P3 A3 cos K1 x z sin K1 x
i
i
i
i
i
i
P1 A1 cos K1 x z sin K1 x
i
potr if x WID x 0
Rwf Re wf
i
2
EoverV
wf if x 0 P1 if x WID P3 P2
i
x1 x
i
Below we plot out the real part of the wavefunction as it approaches the barrier from the
left. The wavefunction is indicated in red, the potential barrier is the thick black line.
33
Now we will write this wavefunction into a new vector which will be the reference
wavefunction.
ref i Rwf
Now we will compute the wavefunction for the particle whose characteristics you should
change. You will compare this wavefunction with the reference wavefunction ref.
E 0.008
MAS 5
WID 23
EoverV 0.9
Vo
E
EoverV
33
K2
2 MAS ( Vo E)
A1 1.
A3
z K1 K2
2 K1 K2
sinh(K2WID)
A1p
A2
K1 2 MAS E
factor
z K2 K1
2 K1 K2
0.5
K2
A2p A1 A1p A2
P1 A1 cos K1 x z sin K1 x
i
pot0 if x WID x 0
Rwf Re wf
i
100
10 WIDL
x 5 WIDL i
2
EoverV
P3 A3 cos K1 x z sin K1 x
i
x1
wf if x 0 P1 if x WID P3 P2
i
xmax if x1
100
100
100 100
xp x
i
z 1
33
33
33
1
2
2
S2
S3
Sr
d
1 2
1
2
6
1
2
3
(redundant coordinate)
B1 species
1 r r
S4
1
2
2
S5
1
2
2
S6
B2 species
The general form of the G and F matrices for H2CO in internal coordinates are shown in
the table for the inplane modes.Since there is only one out of plane vibration and belongs
to a different symmetry species, it could conveniently be considered seperately.
A B
F
E1 F1
E1
r1
r2
D
A1 B1 D1 D2 C1
A1 D1 C1 D2
33
With the aid of Decius or Shimanouchi tables , the G matrix elements are written down.
In the following expression,r1=r2=r and 1=2= are used. The symbol denotes the
reciprocal of the mass of the atoms shown as a subscript.
C O
G11
G22
G33
G23
B1
C cos
2 C
G14
G15
G16
G24
G34
G25
G26
G35
2
G55
G66
G56
G45
G46
C cos
sin
r
D2
C1
C H
sin
d
sin
cos
C
r
d
2 C
cos
r
C H C H
E1
C O
d
F
G13
sin
r
F1
G12
sin
r
D1
G36
G44
C H
A1
cos
2 C
r d
cos
cos
2 C
C
2
r d
C H
r
cos
r
33
MO 16
MH 1.008
1
MO
MC 12
1
MH
1
MC
120
180
r 1.09
B1 C cos
A1 C H
120
180
d 1.216
A C O
C H
E 2
B C cos
C H
2 C
2 C
C O
C H
F1
cos
C H
E1
2 C
cos
r d
cos
cos
C
2
r d
r
cos
r
33
A1 B1
2 B
GA1
( C D)
6
D1 D2 C1
6
0.146
0.162
3.096
A1 B1 D2 C1
E1 F1
fr 4.35
fd 10.8
fd 0.291
f 0
f 0.83 f 0.46
fr 0 frr 0
f 0
fr 0
fdr 0.29
fd 0.173
tr 0
fr frr
fd
2 fd fd
2 f f f 4 f
FA1
2 fdr
( E 4 F) 2 E1 2 F1
3
For B1 species
GB1
2
E F E1 F1
3
Ga1
C 2 D
1
2 E E1 F1 4 F
3
2 D1 C1 D2
2 fr fr tr
33
fr frr fr tr
FB2
f f
33
QUESTIONS
1. Derive the numerical solution of Schrdinger wave equation.
2. Describe the motion of a harmonic oscillator in an electrostatic potential well.
3. Discuss the molecular symmetry in H2O molecule.
4. Discuss the molecular symmetry in NH4 molecule.
5. Explain the method of solving second order differential equation through
mathCAD.
6. Explain the study of Hydrogen molecule through mathCAD.
7. Discuss the Ground state of helium atom by Variation method.
8. Explain the Electron motion through rectangular potential barrier.
9. Discuss the Formaldehyde molecule as an example of XY3 molecule. Derive the
frequencies of six modes of vibrations.
33
***************
33