Vous êtes sur la page 1sur 168

ADVANCED PHYSICS

THROUGH MATHCAD
BY
Dr.S.PALANISWAMY
PROFESSOR OF PHYSICS
PSG COLLEGE OF ARTS AND SCIENCE
COIMBATORE-641014

POSTGRADUATE LEVEL

FOR II MSc., PHYSICS

35
UNIT-I
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
2. Working with MathCAD Regions
2.1 Introduction
2.2 Moving regions
3. Entering Math and Text
3.1 Entering math
3.2 Entering text
4. Working with MathCAD styles and templates
4.1 Introduction
4.2 Using a template
4.3 Using styles
4.4 Creating a template
5. Defining variables
6. Defining functions

35
6.1 Trig and log
6.2 Matrix functions
7. Building Mathematical Expressions
8. Editing Expressions
9. Defining Range Variables –
10. Defining Vectors and Matrices.
Questions

1.MathCAD Tool Bars and Palettes


1.1 Features of the Mathcad Window

Before you move on to learning more about Mathcad's features and especially about
building math and text in your own Mathcad worksheets, take a moment to look at the
Mathcad application window in front of you.

1.2 The Main Menu


Here is your gateway to math, graphics, and symbolic functions and provides commands
that handle the details of editing and managing your worksheets. Click on the Math and
the Symbolics menus to see the array of computational functionality available to you in

35
this product. Access to any Mathcad Electronic Books you may have installed is now
available through the Help menu.

1.3 The Math Palette


Below the main menu is a tear-away bar whose buttons bring up palettes of math
operators. If you let your mouse hover over each of the buttons on the bar in turn, you'll
see a tool tip telling you what palette each button brings up:

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.

35
1.4 The Tool Bar
is another tear-away button bar that provides shortcuts for many common tasks, from
worksheet opening and file saving to spell checking to bringing up lists of built-in
functions and units. Depending on what you're doing in your worksheet, one or more of
these buttons may appear grayed out. Tool tips will remind you of the functions of each
of the buttons. One
useful button is:

1.5 The Resource Center Navigational Controls

appear whenever you have a Mathcad Electronic Book open and give you ways to browse
among the sections of the Book and find topics of interest. This Tutorial you are reading
is in fact a Mathcad Electronic Book! Just let your mouse hover over each of the
navigational buttons at the top of this window to see a tool tip explaining what each one
does.
• Finally, the message line

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 --

35
"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.

2. Working with MathCAD Regions


2.1 Introduction
Every Mathcad equation, text paragraph, and plot in a worksheet is a separate object
called a region. You can select a single region by clicking in math or text in your
worksheet. The region then shows up with a thin rectangle around it. If you move your
cursor to one of the edges of the region, notice how your cursor changes to a small hand
-- which lets you move the region. Try dragging the regions below to your worksheet
window. Note that if you click in the math region, you will see blue selecting lines under
the material currently selected. If you click in a text region, you will see black boxes at
each corner and the middle of each line. These boxes allow you to resize text regions,
which you can do in your worksheet window, but not in the Resource Center.

2.2 Moving Regions

You can also drag-select multiple regions at one time to move them around on the screen
to your liking. To move regions in your worksheet:
• Click in an empty area to position the red crosshair cursor in your worksheet and then
drag-select regions so they appear in dashed selection boxes.

35
• Move your cursor inside one of the boxes. Notice that it becomes a small black hand.
• Hold down your mouse button and drag your mouse. All of the selected regions will
move with it.
Once you have the regions positioned the way you want them, release the mouse button
and click on an empty part of the screen to deselect the regions.
Hint: If you want to grab a group of regions, but want to deselect one of them, use shift
click on individual regions, to do so.
Another way to see the regions in your worksheet is to choose Regions from the View
menu. The region boundaries will be highlighted against a contrasting background. An
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.

3. Entering Math and Text


3.1 Entering Math
Click your mouse in the blank space below so you see a red crosshair cursor. Now type:
Type 1+ See on screen

35
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:

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.
3.2 Entering Text

35
To create a text region, click in a blank area of the screen to position the red crosshair
cursor and type a double-quote ["]. You can also just start typing, and as soon as you
type a space, Mathcad converts from a math region to a text region. Typing certain
characters used in math will not automatically convert to a text region, so it is always
safest to use the double-quotes.Now you can now type whatever you like, just as in a
word processor. Notice that as the text region grows,a black box appears around it, and
there are resizing "handles" on the right and bottom edges of the rectangle. Once you are
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.

4. Working with MathCAD Styles and Templates


4.1 Introduction
Two new features in Mathcad 7 are styles and templates, which work much like those in
word processors. We have provided several templates for your use or revision, each
containing a number of styles. You can also create your own styles and store them in a
template so they are available for other documents.
4.2 Using a Template
To use a built-in template, choose File/New, then choose a template from the templates
listed, or browse to your own template directory. Just substitute your own text or bitmaps
in any of the placeholders, or use or revise the built-in styles.
4.3 Using Styles
The styles in each template are visible from the first pull- down menu in the Format Bar.
If the Format Bar is not visible, choose View Format Bar. Styles save you work,
because you can quickly apply a style such as Heading One to specific text regions,
instead of having to redefine the font, size, and indents for each new heading. To create

35
or modify a style, choose Format Style. To save your styles for use in new files, you
must make a template file.
4.4 Creating a Template
Creating a new template or revising another template is very easy. You can
• create text styles and number formats
• set the fonts and sizes for constants and variables in math regions
• add any bitmaps that you want on every page such as a line across the top or bottom of
the file
• 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:

35
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:

Or, use the variable to define another variable:

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:

35
Plug in a numerical value as the argument of f(x).

Define a range variable (more on this later) and plug it in as the argument of f(x) to see a
table of values.

Even define another function in terms of f(x).

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.

35
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

6.2 Matrix Functions

7. Building Mathematical Expressions


Click to position the red crosshair in the empty space below and type the following. Pay
particular attention to what happens when you press the spacebar:

Type f(x):x+6[Spacebar]*(x^3[Spacebar]-1) See on screen

35
The first time you pressed [Spacebar], you selected

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:

follow the following steps:

35
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

And if try typing x^1/t^2[Spacebar][Spacebar][Spacebar]/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.

35
• 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.
• 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!

• If you want to replace the 5 with a 6 , double-click on the 5 so it appears in reverse


video, then type 6.
• If you want to replace the division with multiplication, click to the left of the 8 in the
denominator, press the [Backspace] key, and type [*].

35
• 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 x3 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

then edit the last expression so that it looks like

The variable x has been defined at the beginning so you can see the effects of your edits.

Here Are the Steps . . .


• First, change the x2 to(x- 5)2 . Double-click on the first x in the expression and then
type x-5.
• Now change the leading constant from 2 to -2. Click immediately to the left of the
leading 2 so you see blue editing lines, and then type -.
• Now edit the fraction 3/2. Double-click on the 3 in the fraction bar to select it and then
type 5.
• Finally, change the addition at the end to a subtraction. Click immediately to the left of
the final equals sign in the expression so you see blue editing lines. Press [Backspace] to
delete the plus sign. Now type [-].

35
So, incorporating everything you've learned so far, try to reproduce the following
equations yourself:

You should have typed


score:3[Enter]
result:score+6[Spacebar]\+1/2[Spacebar]
[Spacebar]/score^2[Spacebar]-3[Enter]
result=[Enter]
If you had trouble with this, try practicing with some more examples until you feel
comfortable editing Mathcad expressions.
9. Defining Range Variables
Assigning a range of values to a variable is straightforward in Mathcad. For example, to
create a variable x that runs from 0 to 10, just click to position the red crosshair in some
free space and type x:0;10
After clicking away, you should see .

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

35
on the Math Palette.

You can now use a range variable as you would any other variable. Notice that Mathcad
creates an output table – a vertical series of boxes that contain numbers -- when you type
[=] after an expression involving a range variable.

Type x= See on screen

Type f(x)= See on screen

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:

35
Type x:1,1.1;10 See on screen

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.8 See on screen
x := 1 ,1.1 .. 1.8
Type data:-10,-8;0 See on screen
data := 10 , 8 .. 0
Type n:202,192;102 See on screen
n:= 202 , 192 .. 102
Here the range goes down!
Type x= See on screen

Type data= See on screen

35
Type n= See on screen

Try defining your own range variable and using it in an expression below.

10. Defining Vectors and Matrices


The examples you've seen so far have involved single numbers or scalars. Mathcad has
many powerful features and functions, however, for dealing with arrays of numbers, such
as vectors and matrices. Creating a vector or matrix in Mathcad involves just choosing
the dimensions of the array and filling in the placeholders. For example, to create a vector
v like the one shown below, click to position the red crosshair in some free space and
• Type v:
• Choose Matrix from the Insert menu (or click on the matrix button inside the Vector
and Matrix Palette)

35
• 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
The next element has the index 1:

Type v[1= See on screen


v1 = 1.2
The last element has the index 2, and so on:
Type v[2= See on screen
v2 = 8
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:= 0.. 2
Then
Type v[i= See on screen

35
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 :=2.. 5
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

Now define a vector and use its elements as an argument of the function:

35
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

button on the Vector and Matrix Palette.

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:

35
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

35
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 working with matrices and vectors in mathCAD.

UNIT-II

The MathCAD Advantage

1. Introduction
Do arithmetic with MathCAD’s built-in functions and math operators –
Define your own variables and functions –
Evaluate functions and expressions over ranges –
Plot functions quickly –
Visualize data in two and three dimensions –

35
Compute sums and integrals –
Do matrix computations –
Solve equations numerically –
Carry out symbolic operations –
Create multiline procedures using new programming operators –
Create animations to visualize results over time.

1. 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
x :=
2⋅ a

35
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
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.

2. Do arithmetic with Mathcad's


built-in functions and math
operators
The operator palettes accessible from the palette strip at the top of the window give you
access to Mathcad's mathematical operators. First click in your worksheet to place a red
crosshair cursor, then click on a button in one of these palettes to insert a math operator
into your worksheet. To see a scrolling list of Mathcad's built-in functions, go to the
Insert menu and select Function, or click on the Insert Function button on the toolbar.

The red crosshair

35
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.

3. Define your own variables and


functions
The definition symbol := is in the Arithmetic Palette; you can also enter it by typing a
colon (:).

35
When you change a definition, Mathcad immediately recalculates any new values that
depend on it.

Try it! Click just to the right of the 4 in the definition of a above so you see the blue
editing lines:

Then type [Backspace] once to get a placeholder:

Now type 3. Click the mouse anywhere else on the screen and you'll see the answers
change.

4. Evaluate functions and expressions over


ranges
The .. range operator is in the Arithmetic Palette and can also be entered by typing a
semicolon [;] at the keyboard. Change the 2 in the definition of z to a 4 to see bigger
tables. To create these tables, just type z=, f(z)= and so on.

35
5. Plot functions quickly
Use the X-Y Plot button in the Graph Palette, or type [Ctrl]2 to get a plot operator; then
type expressions you want to plot in the middle placeholders on the x and y axes. You
can type expressions on the y axis only, and Mathcad will choose a default range for you
automatically on the x axis! You can enter several expressions separated by a comma (,)
in these axes placeholders to see multiple traces.

35
6. Visualize data in two and three
dimensions
The following plots show how Mathcad can automatically interpolate a 3D scatter plot to
create a surface plot. The same array of points is displayed in both plots. The first plot
was created using Graph/3D Scatter Plot from the Insert menu, and the second plot was
created using Graph/Surface Plot from the Insert menu. You can also use the
corresponding buttons from the Graph Palette.

35
7. Compute sums and integrals
The sum and integral operators are in the Calculus Palette. To build one of these
expressions, click in your worksheet to position the red crosshair, click on the appropriate
button in the palette, then fill in each placeholder.

8. Do matrix computations
To enter a matrix, click on the 3 by 3 matrix icon in the Vector and Matrix Palette (or
choose Matrix from the Insert menu), choose the number of rows and columns, then fill
in the placeholders.

35
9. Solve equations numerically
Start Mathcad's root finder off with a guess . . .
t:= 1
. . . andMathcad finds the closest root.

10. Carry out symbolic operations

35
You perform these symbolic operations by clicking on an expression and choosing
commands from the Symbolics menu.You'll find commands for simplifying, expanding,
factoring, differentiating, integrating, solving an equation, generating series expansions,
carrying out symbolic matrix operations, and more. Copy the expression below to your
main worksheet window, then click on it so you see it surrounded by blue editing lines (if
necessary press the spacebar to select more of the expression); then choose Simplify
from the Symbolics menu:

11. Create multiline procedures using


new programming operators
Use the operators on the Programming Palette in Mathcad Professional to build
multiline Mathcad procedures with standard control structures: for and while loops,
branching, recursion, and more. Programs are seamlessly integrated with Mathcad's live
worksheets and math notation and can operate on scalars, vectors, arrays, and even arrays
of arrays. Look at the following programming example.

35
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.

Create animations to visualize results


over time
Any part of a Mathcad worksheet can be animated. Try animating the graph below by
choosing Animate from the View menu, then entering values of FRAME from 0 to 20 in
the dialog. Next drag-select the regions below including the graph and equations to the
right, and finally press Animate. You will see the animation pre-process. Then you can
Mathcad lets you play back and save the animation as a standard video file or embed it in
your worksheet.

35
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 MathCAD’s 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.

35
UNIT-III
MathCAD -graphics

Creating Graphs –
two dimensional graph- three dimensional graphs-
Formatting Math and Text –

35
Formatting Results –
Using Units-Creating Programs –
Fourier series-
Bohr’s theory of atomic structure –
Numerical solution of Schrödinger wave equation-
Lorentz force –
Van-der-Waals equation-
Resistivity

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:

35
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:

Two dimensional graph-Three


dimensional graph
Graphing a Function Using Range Variables

35
When you graphed the above expressions, Mathcad was choosing a default range for the
dependent variable. You can have control over the range of values that are plotted. To
graph a simple function using a range variable, do the following:
• Define a function of one variable that you wish to plot. For example, graph the
following function: Type f(x):-x^2[Spacebar]+8*x-27 See on screen

• 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:

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:=
0,0.1.. 10 . 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

35
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.

Graphing Vector Elements


Here is a vector of data points called money_spent. We created the vector using the
Matrix command on the Insert menu; our vector below has 8 rows and 1 column.

35
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;7 See on screen
i:= 0..7
Create your plot by typing [@] and typing
Type money_spent[i See on screen
money_spent I in the placeholder on the y axis, and i in the placeholder on the x axis. You
should see a plot similar to this:

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:

35
Now it's easy: Create the plot by typing @, as above, and type
Type money_spent See on screen
money_spent
in the placeholder on the y axis, and
Type day See on screen
day
in the placeholder on the x axis. The resulting plot should look similar to this:

35
Here the "points" trace type has been used with magenta O's. Notice that grid lines have
been turned off on both axes.

Graphing a Function of Vector Elements


You can plot a function over a domain that doesn't contain evenly spaced points. For
example, your domain could consist of a vector of values. Plotting a function of vector
elements entails defining a function, defining a vector which will be the domain for the
function, and plotting. An example of this is:

Define a function of one variable.


Type f(x):x^2 See on screen
f (x):= x2
Define a vector of numbers to be the domain for the function. Type x: followed by
[Ctrl]M , and fill in the Matrices dialog box with the appropriate number of rows and
columns (here, 5 rows and 1 column), followed by OK. Then fill in the placeholders in
the vector.

Define an index variable. Type i:0;4 See on screen


i:= 0.. 4
Type @ and fill in the middle placeholders on the y and x axes with f (xi)
and xi. The result should look similar to this:

35
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.

Graphing Two or More Functions


Plotting multiple functions over a single domain on a single graph is straightforward. For
example, suppose you want to plot both 1/z and z 2 on one plot. It's easy! Just type the
two expressions separated by a comma and then type @:
Type 1/z [Spacebar] , z^2 @ [Enter] You'll see a graph similar to this:

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.

35
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:= 10, 9.9 .. 10
Type t:-2,-1.9;2 See on screen
t:= 2, 1.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).
• 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.

35
Formatting Math and Text
You can easily modify the way text and math appear in your worksheet. You can select
different default fonts, sizes, and styles using the controls on the Format Bar that
appears in the Mathcad window. (If the Format Bar is hidden, and you want to see it,
make sure Format Bar on the View menu is checked.) If you're used to working with a
word processor, this should be familiar.
Definitions for plot:
x:= 1,1.1 .. 10
For example, suppose you want to make the following style changes to the math and text
in your worksheet.
F(x) := -2*(x-5)2 + 5/2*x -2
• 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.
Formatting Text
Here are the steps for changing the font and size for selected text:
• Drag-select or double-click the word "Here" in the text region above when you are in
your worksheet window. The selected word will appear in reverse video.

35
• Now choose your fonts and point sizes from the drop-down lists in the Format Bar,
and click on the appropriate buttons for special effects like boldface, italic, etc.
Further text formatting options are available by choosing Text from the Format menu.
Text Styles and Templates
You can access current text styles from the first drop-down list in the Format Bar. To
make a new text style, choose Style from the Format menu. If you want to save your
styles to use in new documents, save this file as a template. You can then open the
template and all your styles will be available for new documents. You may want to
examine the built-in styles
and templates which you can see when you choose File New or in the Template
directory.
Formatting Math
To change the math fonts, first notice that Mathcad distinguishes between variables
(names of variables and functions in math regions) and constants (numbers), and it lets
you apply different font tags to each. Just click on a variable or constant in a math region
and use the Format Bar or choose Equation from the Format menu to make any
changes you want for variables and constants.
Mathcad also lets you highlight equations to emphasize them. Just click on an equation
and choose Properties/Highlight Region from the Format menu in the main worksheet
window. To select different default colors for the worksheet background and equation
highlighting, choose Color from the Format menu.

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

35
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
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.

35
• 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:
Type f(x):sin(x) See on screen
f(x):= sin(x)
Type g(y):cos(y) See on screen
g(y):= cos (y)
Type x:-10,-9.9;10 See on screen
x:= 10, 9.9 .. 10
Type y:-2,-1.9;2 See on screen
y:= 2, 1.9 .. 2

35
To create the plot above:
• Type @ in some blank space.
• In the placeholder on the horizontal axis, type x,y .
• In the placeholder on the vertical axis, type f(x),g(y).
• Type [Enter]. Notice that the traces are different colors. To reformat the plot,
• Double-click near the center of the plot to see the X-Y Plot Format box. You can also
access this dialog box in your
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 . . .

35
. . . 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
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.

Using Units

35
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*km See on screen
r:= 6370 .km
Type A(r):4*p[Ctrl]g*r^2 See on screen
A(r):= 4. π . r2
(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.
4 . π . r2 = 5.099 .1014 m2
The result in hectares is
4. π. r2 = 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 .

35
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.

Creating Programs
What is a program?
A program is simply an expression made up of more than one statement (available in
Mathad Professional only). If you click on the examples below, you'll see how they look
when written as a program rather than as a single expression.

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.

35
Defining a program (Mathcad Professional only)
To following steps illustrate how to define a the program

• 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.

• 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.

35
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.
• 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.

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:

35
• "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.

"FOR" LOOPS
Use a "for" loop when you know exactly how many times you want the body of the loop
to execute.

To insert a "for" loop


• Click in the placeholder into which you want to place the "for" loop.
• Click on the Math toolbar to open the Programming toolbar containing the
programming operators.
• 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.

"WHILE" LOOPS

35
Use a "while" loop whenever you want a set of statements to keep executing until a
condition is met. Make sure you have a statement somewhere that makes the condition
false. Otherwise the loop will execute indefinitely and you will need to stop it by pressing
Esc.

To insert a "while" loop:


• Click in the placeholder into which you want to place the "while" loop.
• Click on the Math toolbar to open the Programming toolbar containing the
programming operators.
• Click on the "while" button or press Ctrl+]. Do not just type the word "while".
• In the placeholder to the right of the "while", type a boolean expression. Click the "Add
Line" button on the Programming toolbar to insert placeholders for additional statements
if necessary.
• 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.

"BREAK" STATEMENT

Use a "break" statement in a loop whenever you want to halt execution in a loop.

35
To insert a "break" statement:
• Click in the placeholder in which you want to put the "break" statement.
• Click on the Math toolbar to open the Programming toolbar containing the
programming operators.
• Click on the "break" button or press Ctrl+{. Do not just type the word "break".
When Mathcad encounters a "break" statement in the body of a “for” or “while” loop:
1. The loop ceases execution and return the most recent value computed.
2. The program execution then continues with the next line of the program after the loop.
Controlling iterations in a loop

Controlling iterations in a loop


Program loops are designed to continue until a certain condition is met or after a certain
number of iterations. However, you may want to halt a loop during a certain iteration and
continue with the next iteration. To do so, use a “continue” statement.
To insert a "continue" statement:

• 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".

35
• When the program encounters a “continue,” it halts the iteration, goes to the nearest
outer loop, and continues with the next iteration.

Returning a value from a program


By default, a program returns whatever is on the last line. However, you can return a
value located elsewhere in the program by using a “return” statement.

To insert a "return" statement:


• Click on the placeholder into which you want to place the "return" statement.
• Click on the Math Toolbar to open the Programming Toolbar containing the
Programming Operator.
• Click on the "return" button or press Ctrl+|. Do not just type the word "return".
• In the placeholder to the right of the "return", type whatever you would like to return.
"Return" statements are useful when you want to return a value from a particular loop.
Trapping errors

Trapping errors in a program


To return an alternative value when an error is encountered in an expression, use the “on
error” programming operator:

35
• 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.

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:

1. An initial condition to prevent the recursion from going forever, and


2. A definition of the function in terms of a previous value of the function.
The idea is similar to that underlying mathematical induction: if you can get f(n+1) from
f(n), and you know f(0), then you know all there is to know about f. Keep in mind
however, that although recursive function definitions, despite their elegance and
conciseness, are not always the most computationally efficient definitions. You may find
that an equivalent definition using one o f the iterative loops will evaluate more quickly.
Evaluating a program symbolically

35
Once you’ve defined a program that you want to evaluate symbolically:
(1) Type the name of the function or variable name which is defined in terms of a
program.
(2) Press Ctrl +Period to insert the right arrow representing the symbolic equal sign.

1. 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
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.

35
Mathematically the orthonormal property is expressed as:
b

 s c i ( x ) ⋅ s c j ( x ) dx : = δ i j (note: this equation is toggled off)

a

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.

π

 s i n ( n ⋅ x ) dx =0 n = 0, 1, 2, 3,....

−π

π

 c o s ( n ⋅ x ) dx =0 n = 1, 2, 3, .....

−π

= 2π n=0
π

 c o s ( m ⋅ x ) s i n ( n ⋅ x ) dx
⌡ = 0 m = 0, 1, 2, 3,.... and n = 0, 1, 2, 3,.......
− π

π

 c o s ( m ⋅ x ) c o s ( n ⋅ x ) dx
⌡ = 0 m not equal to n
− π

=π m = n not equal to 0
π

 s i n ( m ⋅ x ) s i n ( n ⋅ x ) dx
⌡ =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.

35
F(x) = some function of x

∞ ∞
1
f (x) = a 0 + ∑ a n cos( n x) + ∑ bn sin( n x)
2 n=1 n=1

π
1
an =
π ∫ F(x) cos ( n x ) dx
−π

p
2
bn =
L ∫ F(x) sin ( n x ) dx
−p

35
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


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.

35
x : = − π , − 3 . 1. . π N can equal 0 up to any large integer.

Notice the relationship between N and i

j := 0 .. N Notice the way the range of x is defined.

Values of N are entered below just above the graph. The


entry point for this integer was placed there so as to
4  N 1  make exploration and graphical insights possible
f ( x ) : = ⋅
π  ∑ 2 ⋅j + 1
⋅s i n [ ( 2 ⋅j + 1 ) ⋅x ]
 without excessive scrolling of the screen view. N is a
j = 0  Mathcad Global variable in this document. Depending
on how you have your worksheet options set a change
in N will immediately result in a new figure or you may
need to press F9 to do do the calculations that will
show a new figure. This can also be accomplished by
pressing the = sign in the first tool bar of the window.

35
Sample Problem:
Expand the function F(x)=x in the interval -π to π by a Fourier series.

1. First we write the function and set the interval for the expansion.
F (x ) := x 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 ) ⋅ s i n ( 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.

35
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.
M
f(x ) :=
∑ B n ⋅s i n( 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.

35
2.BOHR’S THEORY OF ATOMIC
STRUCTURE
Postulates of Bohr:
1. An electron in atom can revolve in certain stable orbits without the emission of
radiant energy.The angular momentum of the electron should in the integral multiples of
(nh/2π)
2. An electron may make a transition from one of its specified non-radiating orbits
to another of lower energy equal to the energy difference between initial and final states.
In stationary states the energy of the atom is assumed to be constant. Thus the atom does
not radiate em waves while in any one of these stationary states.
By the first postulate the angular momentum of the electron is

n ⋅h
me⋅v n⋅rn ---------(1)
2⋅π
By the second postulate the emission of energy is:
h⋅ν Ei − Ef ---------(2)

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:
where ν is the frequency of the energy emitted : Ei and
states. Applying the Coulomb's law of force between th
2 2
e 1 e
F k⋅ ⋅ ------
Equating the RHS of the equation (3) to the cetripetal force 2 4⋅ π⋅ ε0 2
rn rn
2
1 e 2 ----------(4)
⋅ me⋅ v n .rn
4⋅ π⋅ ε0 2
rn
Solving (1) and (4) for rn and vn we get,

35
Solving (1) and (4) for r n and vn we get,
− 31 − 12 farad m
me := 9.109389710
⋅ ⋅ kg ε0 := 8.854187817
⋅ 10 ⋅ c := 299792458⋅
m sec
1
− 19 k := − 34
e := 1.60217733
⋅ 10 ⋅ coul 4⋅ π⋅ ε0 h := 6.626075510
⋅ ⋅ joule⋅ sec

1
k :=
4⋅π⋅ε0

k= 2 2
n ⋅h
r( n ) := ε0⋅ -------------(5)
2
π⋅me⋅e
2
e
v ( n ) := ------------(6)
ε0⋅2⋅n ⋅h
Kinetic energy of the electron is
2
1 k⋅ e 1 ---------------(7)
KE( n ) := ⋅ ⋅
2 r( n ) e

Potential Energy of the electron is:


Potential Energy of the electron is:
2
−k⋅e 1
PE( n ) := ⋅ ----------------(8
r( n ) e
Total Energy of the electron is
E( n ) := KE( n ) + PE( n ) ---------------------(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
Substituting the values
2 of Ei and Ef using equation(9)
2
1 k⋅e −k⋅e
KE( n ) := ⋅ PE( n ) := E( n ) := KE( n ) + PE( n )
2 r( n ) r( n )

35
−E( 1) −E( 1)
− 
⋅ 
ν E( 1) 1 1
 2  ν −
2
n i ⋅h  n f ⋅h  h  2 2
 ni nf 

LYMAN SERIES
⋅ 
E( 1) 1 1
ν( n ) := −
h  2 2
n 1 

c 7
λn
( ) :
= ⋅10
ν( n )

n :
= 2 ,3 .
. 20

BALMER SERIES

⋅ 
E( 1) 1 1
ν( n ) := −
h  2 2
n 2 

c 7
λ( n ) := ⋅10
ν( n )

n := 3 , 4 .. 20

35
PASCHEN SERIES
⋅ 
E( 1) 1 1
ν( n ) := −
h  2 2
n 3 

c 7
λ( n ) := ⋅10
ν( n )

n := 4 ,5 .. 20

BRACKET SERIES
⋅ 
E( 1) 1 1
ν( n ) := −
h  2 2
n 4 

c 7
λ( n ) := ⋅10
ν( n )

n := 5 , 6 .. 20

35
FUND SERIES
⋅ 
E( 1) 1 1
ν( n ) := −
h  2 2
n 5 

c 7
λ( n ) := ⋅10
ν( n )

n := 6 , 7 .. 20

35
3. NUMERICAL SOLUTION OF
SCHRODINGER WAVE EQUATION
HYDROGEN ATOM

The hydrogenic atom wavefunctions will also be used as the basis functions in the Linear
Combination of Atomic Orbitals (LCAO) method. The Schrodinger equation for the
hydrogenic atom used in the LCAO method is
2m  Zq 2 
∇2ψ +  E + ψ = 0
 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

1 ∂  2 ∂ 1 ∂  ∂  1 ∂2
∇2 = r + 2  sin θ + 2
r ∂r  ∂r  r sin θ ∂θ 
2
∂θ  r 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
l ≤n−
1
functions, and their properties require that . The spherical harmonics give atomic
orbitals in their characteristic shapes.

35
Spherical Harmonics

Select values for the quantum numbers l and |m|. Note that |m| must be less than or equal to
l.
Angular momentum quantum number l := 1

Magentic quantum number m := 1


The solution to the Φ equation is given by

The normalization factor for this function is


1
A :=

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 θ

The normalization factor for the Θ function is


2l + 1 ( l − m)!
B := ⋅
2 ( l + m)!
The spherical harmonic is given by the product of the Φ and Θ functions.

The indices and equations needed to transform the spherical harmonics into Cartesian coodinates
for plotting in Mathcad are contained in the hidden section below.

35
Radial Wavefunctions

Select values for the quantum numbers n and l. Note that l must be less than or equal to n -
1. The atomic number Z can also be varied, but the solutions are only valid for one-electron
atoms.
Principal quantum number n := 3

Angular momentum quantum number l := 2

Atomic number Z := 1

The solution to the equation


R Laguerre
( polynomial of the first kind) is given by

where ρ is given by
2 ⋅ Z⋅ r
ρ ( r) :=
n
We'll express r in Bohr units (1 Bohr = 0.0529 nm) in this workbook.
The normalization factor for the R function is

35
The radial wavefunction is

The radial wavefunction Rln(r), radial density function Rln2(r), and radial distribution function

4π r2Rnl2(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.

35
Numerical Solutions for Schrodinger's Equation
Integration limit: xmax:= 1 Effective mass: µ := 1

Potential energy: V( x) := −1

Numerical integration of Schrodinger's equation:

−1 d 2
Given ⋅ Ψ ( x) + V( x) ⋅ Ψ ( x) E⋅ Ψ ( x) Ψ ( 0) 0 Ψ' ( 0) 0.1
2⋅ µ dx2

Ψ ( x)
(
Ψ := Odesolve x, xmax ) Normalize wave function: Ψ ( x) :=
x
⌠ max 2
 Ψ ( x) dx

0
Enter energy guess: E≡ 4

35
Fourier transform coordinate wave function into momentum space.
x
1 ⌠ max
p := −20, −19.5.. 20 Φ ( p ) := ⋅ exp( −i⋅ p ⋅ x) ⋅ Ψ ( x) dx
2⋅ π ⌡0

35
4.LORENTZ FORCE
We study the motion of a particle of charge q and mass m in a magnetic field B
and in an electric field E. The force acting on the particle is given by the Lorentz
formula: F = qE + qvxB where v is the velocity vector. For small enough velocities, v <<
c, we can use Newtonian mechanics to describe the motion of the charged particle: ma =
F . Lorentz formula and Newton's second law give: dv/dt = (q/m)E + (q/m)vxB. First we
input the mass and charge of the particle, proton for example.
− 19 − 27
q := 1.6⋅ 10 m := 1.6710

Next we input the magnetic field B and the electric field E.


In this computation we will study the case of no electric field E = 0.
 0   0
B :=  0  E :=  0 
   
 0.0001  0

q⋅ B 2⋅ π
ω := T :=
m ω

We will compute the position and velocity


T of the particle 1000 times during a period.
∆t := n := 0 .. 5000 t := n ⋅ ∆t
1000 n

The initial velocity is v0 and the initial position is r0.


 10 
6
   0
v :=  0  r :=  0 
0 0  
 5  0
 10 

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.

35
:= v + ∆t ⋅ 
q q 
v
n+ 1 n  ⋅ vn × B + m ⋅ E
 m 
r := r + ∆t ⋅ v
n+ 1 n n
Δ
To graph the trajectory, use
 vxthe
 3d scatter plot .  xn 
 n  
 vy  := v  y  := r
 n n  n n
 vz   zn 
 n  

So when E = 0 the trajectory is a helix.

5.van der Waals Equation


For an industrial process, it is necessary to introduce 1400 mols of mesytylene (1,3,5-
trihydroxybenzene) at a temperature of 560 K and pressure of 150 kPa in a steel cylinder.
Calculate the volume of the cylinder using the van der Waals equation, if the a and b
constants are known.
The van der Waals formula is a third degree equation for the volume:

35
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:

−4
R := 8.3136 a := 3.56 b := 1.979⋅10 p := 150000 n := 1400 T := 560

Since an iterative algorithm is used for the calculation, an initial


guess value is necessary. It must be borne in mind that for a third
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 good guess value always speeds the calculation,
although in this case, even a bad estimate converges
fast.

or the equation can


 be written
2 in the recognizable form:
a ⋅n  
V := root p + ⋅( V − n⋅b) − n⋅R⋅T , V
 V 
2 
 
the answer is the same:
However, a guess value in the "wrong direction" gets the not converging message:
guess value
V := .1

35
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 Bohr’s 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
Schrödinger wave equation.
7. Discuss the MathCAD procedure to study the Lorentz force.

35
8. Discuss the MathCAD procedure to study the Van-der-Waals equation.

UNIT-IV
COMPUTER ORIENTED
NUMERICAL METHODS:
Euler's method of solving ode-
False-position method –
Fixed point iteration procedure –
Modified Euler predictor corrector method –
Newton-Raphson method –
Numerical Integration-3/8 Simpson Rule -
Predictor - Corrector method –
Range-Kutta method.

35
6.EULER’S METHOD OF SOLVING
ODE
It is often impossible to find elementary solutions to differential equations of the form y'
= f(x,y). In applications, though, it is usually sufficient to find a numerical approximation
to the function satisfying the governing differential equation. We will develop a simple
numerical technique for the estimation of such solutions.
Remember: The solution to a differential equation is an equation relating the variables in
the derivative. Thus, a numerical approximation would result in a plot of the relationship
between the variables in the derivative but would not provide the functional relationship.
d −( x ⋅ y)
Let: y' f ( x , y)
dx 2
x +1

Note that a derivative "function" can be denoted in the same way as the original function
from which it came.
−( x ⋅ y)
f'( x , y) :=
2
x +1

In order to obtain the required relationship between variables we need a starting point,
c :=1
commonly called an initial condition: y ( 0) c 1, . This is the initial condition for
the desired relationship between x and y.
For purposes of illustration, let the solution function be denoted by: y = g(x), g(0) = c

The initial-value problem y' = f(x,y) has solution:


( 2
g (x) : = c ⋅ x + 1 ) − .5 . 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
c
y' −1.0 ⋅ x ⋅
taking the derivative of g(x) we get:
( x2 + 1) 1.5

35
Substitute y' and y into the original expression. If y is a root we will get an identity

−1.0 ⋅ x ⋅
c
 
(
− x ⋅  c ⋅ x + 1
2 ) − .5 
( x2 + 1) 1.5 2
x +1

c c
−x ⋅ −x ⋅
simplify :
( x2 + 1) 1.5 ( x2 + 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".
d −( x ⋅ y) here is the original differential equation.
y' f ( x , y)
dx 2
x + 1

We will rewrite it in finite difference form as:

∆y −( x ⋅ y) −( x ⋅ y)
∆x 2 or ∆y 2
⋅ ∆x
x +1 x +1

Now, if we let ∆ y ( yi − yi − 1) and ∆ x ( x i − x i − 1) we can write :


−( x i − 1 ⋅ yi − 1)
yi − yi − 1 ⋅ ( x i − x i − 1) or:
( x i −1) 2 + 1
( x i −1 ⋅ yi −1)
yi yi − 1 − ⋅ ( x i − x i −1) a recursive relationship. If
( x i − 1) 2 + 1
we have an initial condition we can use this equation to compute a sequence of y values.

35
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
x i , yi x i − 1 , yi − 1
have evaluated the slope between and as the value obtained at point i-1.
The process is described graphically below.
COMPUTATION PROCEDURE

Euler's Method for solving Ordinary


Differential Equations of the form y' = f(x,y)
y

yi+1 = yi + f`(x,y)*h
k1 f'(x,y)
in words: "new y value = old y value
*slope*∆h"

h
x
xi 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

35
L := 10 domain over which the solution function is to be approximated
N := 250 number of intervals into which the domain is to divided, the dependent varia
is then approximated at each point
−1
h := L ⋅ N size of each interval

i := 0 .. N counter to keep track of interval values approximated

LINEAR APPROXIMATION (EULER'S METHOD) Define sequences recursively by


y0 : =
1
initial value for y when x = 0
xi : i= ⋅ h
= (counter)(interval size) = value of independent variable
yi+ 1 : ( )
y=i + h ⋅ f' x i , yi
in words new value = (old value)*(slope)*Δx
Effectively, we are progressing along the tangent-line to each y value to estimate y at the
next point on the curve.

7. FALSE POSITION METHOD


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

35
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.
( )(
f xu ⋅ x l − x u )
xr xu −
f ( x l) − f ( x u)

n
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 initial guesses for upper and lower values

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

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

35
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.
false_position_root ( x u , x l , n)
Mathcad programs are in the form of functions . 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.

35
( )
false_position_rootx u , x l , n := i←0
upi ← x u store initial
guesses
downi ← x l in a vector
( )(
f xu , n ⋅ xl − xu )
xu − if f ( x u , n) ⋅ f ( x l , n) <0
f ( x l , n ) − f ( x u , n)
if xu and xl don't
bracket a
break if f ( x u , n) ⋅ f ( x l , n) > 0 root, stop

f ( x u , n) ⋅ ( x l − x u)
xr ← xu − store initial and
f ( x l , n) − f ( x u , n ) subsequent root
estimates, xr , in
si ← x r
vector
x rr ← x l
establish stopping
x r − x rr criteria based on
while ≥ .000005 approximate relative
x rr
error. While loop is
x rr ← x r executed as long
as condition is true
( ) (
x u ← x r if f x r , n ⋅ f x l , n < 0 )
set current value
upi+ 1 ← x u
of guess to
( ) (
x l ← x r if f x r , n ⋅ f x l , n > 0 ) old value, xrr

downi+ 1 ← x l determine which


endpoint
( )(
f xu , n ⋅ xl − xu ) current xrreplaces
xr ← xu −
f ( x l , n) − f ( x u , n)
compute next xr
si+ 1 ← x r
and store it in s
i←i+1 vector
increment counter
( s up down i )
create output vector
where s, up,
and down are
vectors. i is the last
value of the counter

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_rootx 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

35
soln0 , 4
each element within each value of [soln] (for instance ) contains, in turn, three 70
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.
n:
= 0 .10
range of the value of the exponent :

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 − 1
sequence of root estimates for .....
( )
i := 0 .. soln0 , 3
0,3

( )
x r := soln0 , 3
0, 0
(
x u := soln0 , 3 )
0, 1
(
x l := soln0 , 3)0, 2

rename each column of solution vector and plot them.

35
Now do the same for n = 9. Note the increase in the number of iterations required.
( )
i := 0 .. soln0 , 9
0,3

( )
x r := soln0 , 9
0, 0
(
x u := soln0 , 9 )
0, 1
( )
x l := soln0 , 9
0, 2

rename each column of solution vector and plot them.

35
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.

8.THE FIXED POINT ITERATION


PROCEDURE
An object falling vertically through the air is subjected to viscous air resistance as well as to the
force of gravity. Assume that an object with mass "m" is dropped from a height, So and that the

height of the object after t seconds is given by:


2
m ⋅g m ⋅g   −k ⋅ t 
S ( t) So + ⋅t − ⋅  1 − exp  
k
k
2   m 
ft
where: g := −32.17⋅ acceleration of gravity
2
sec
lb
k : = 0.1 ⋅ coefficient of resistance, a.k.a drag
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

Solution: First lets plot the function as given:


t := 0 ⋅ sec, .1 ⋅ sec.. 10⋅ sec

2
mass⋅ g mass ⋅ g   −k ⋅ t  
S ( t) := So + ⋅t − ⋅  1 − exp  
k
k
2   mass 

2
mass⋅ g mass ⋅ g   −k ⋅ t 
S ( t ) − So − ⋅t + ⋅  1 − exp   0 This equation is of the form
k
k
2   mass 
f (t) 0

35
According to plot below the mass strikes the ground after about 6 seconds

The fixed point procedure involves taking a function in the form f ( x ) 0 and converting
it to the form x g (x) . For this problem we take the function above, in the form f (t) 0 ,
and convert it to the form: t g ( t ) . This is done by rearranging f ( t ) 0 into a form where t
g (t)
is on the left side and a function remains on the right. A graphical representation is
shown below:

35
Gra
phic
alIn
terp
reta
tio
nofth
eFix
edP
oin
tIte
ratio
nPr
oced
ure

y
x=f(x)denotedby

g(x)=0
y=x
y=f(x)

xi+1

rootofg(x)=0
x
xi

Thefixedpointiterationprocedureconvertsg(x)=0totheformx=f(x)

Therecursiveversionofthefixedpointprocedureis:x i+1 =g(x i)

2
mass⋅ g mass ⋅ g   −k ⋅ t  
S − So − ⋅t + ⋅  1 − exp   0
k
k
2   mass 
mass⋅ g
⋅t
Here we isolate the t in the second term of the equation, k , on the LHS of the

equation, everything else on the right.


2
mass ⋅ g   −k ⋅ t  − S
⋅  1 − exp    o
k
2   mass  
t This equation is of the form
mass ⋅ g
k

t g (t)

The recursive form of the equation is then:


2
mass ⋅ g   −k ⋅ ti  
⋅  1 − exp    − So
k
2   mass 
ti+ 1
mass ⋅ g
k
N:
=15
total number of iterations
i:
= 1 .N
iteration number

35
2
mass ⋅ g   −k ⋅ ti−1  
⋅  1 − exp    − So
k
2   mass  
ti :=
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.

9. Modified Euler 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

35
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.

d −α ⋅  T4 − Ta4 )
f (t , T
The governing differential equation is: T    
dt

where:
r:
= 1.0 ⋅
cm
radius of sphere

− 8 J
σ : = 5.67 ⋅ 10 ⋅
2 4
σ = Stephan Boltzman constant, sec ⋅ m ⋅ K

kg
ρ : = 8000 ⋅
material density 3
m

ε = emissivity of the body, dimensionless ε:=.5

J
C : = 500 ⋅
C = specific heat of the material, joule/kg - K kg ⋅ K


t:
= .5 ⋅
sec
time step :
T0 : =
2500⋅K
initial temperature
Ta : = ⋅K
100
ambient temperature
t0 : 0= ⋅ sec
initial time

35
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
T −α ⋅  T4 − Ta4 f ( t , T) equation to be solved
  
dt

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:


In the modified procedure the slope, dT/dt, is computed as an average using
the previous value of T a new T value computed using the standard Euler procedure.

−α ⋅  Tn − Ta
4 4 d
fp  f ( t , T) T
dt
yp yp + ∆t ⋅ fp explicit prediction
n+ 1 n

fp
n+ 1 (
f tp , yp
n+ 1 )
( )
1
yC yn + ⋅ ∆t ⋅ fp + fp implicit correction
n+ 1 2 n n+ 1

N:
= 10000
maximum number of time steps
n:
= 1 .N
counter for time steps
tn := tn−1 + ∆t

φ ( T , t) := −α ⋅  T − Ta
4 4 d
 keep in mind that φ ( T , t) T
dt

Tp (
Tn− 1 + φ Tn− 1 , tn− 1 ⋅ ∆ t ) Note that we insert the RHS rather than the variable Tp 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.

35
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 Tn and Tn-1
where n and n-1 are real subscripts referring to the time step.
Since :
d
φ ( T , t) T ∆T φ ( T , t) ⋅ ∆t Tnew Told + φ ( T , t) ⋅ ∆t
dt

We can write the entire predictor-corrector method as :


1
Tn := Tn− 1 +
2
( ( ) ( ( ) ))
⋅ φ Tn− 1 , tn−1 + φ Tn− 1 + φ Tn−1 , 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.

35
10. NEWTON – RAPHSON METHOD
When a fluid flows in a steady fashion through a round pipe, the pressure drop due to
wall friction is given by the empirical formula:
2 L
∆P −0.5⋅ f ⋅ ρ ⋅ V ⋅
D

w h e re:
∆ P= p re s s u re d ro p D = p ip e d ia m ete r
ρ = flu id d e n s ity
f = D a rc y fric tio n fac to r
V = flu id ve lo c ity
L = p ip e le n g th

Several empirical formulas exist for the friction coefficient as a function of the Reynolds
ρ ⋅ D⋅ V
number, Re, which is given by µ where μ is the fluid viscosity. For flow in the

turbulent regime between completely smooth pipe and wholly rough pipe surfaces
Colebrook developed an empirical equation for the friction factor
1  ε_D_ratio + 2.51 
−2 ⋅ log 
1  3.7 1
2  2
f  Re ⋅ f 

Develop a procedure to determine f for specified values of ε/D and Re. Use the
− .16
approximation proposed by Genereaux (1939) , f 0.16 ⋅Re , to determine an initial
approximation for f. The equation is transcendental in anture therefore an analytical
solution is not possible. Here we will use the Newton Raphson procedure. A graphical
description of the procedure is given below.

35
Geometric Interpretation of the Newton-Raphson
Procedure
function for which root is
desired

f(xi)
xi+1 = xi - recursive equation f '(x1)
f(x) f '(xi)
1. May not converge, root not
bracketed
If initial guess is not too far
off sequence of iterates 2. Quadratically convergent when
converges to root it does converge
f(x1)
3. Requires evaluation of
analytical derivative which may
not exist

f ' (x2) f(x2)


root

x2 x1 x

NOTE: Equation to be solved must be recast in the form f(x)=0

SOLUTION - find the friction factor using the Newton Raphson procedure. Define
values for ε /D and the Reynolds Number
ε
ε_D_ratio
D
n
ε_D_ratio := .001 n := 6 Re ( n) := 10

 ε_D_ratio + 2.51  − 1
F ( f ) := −2 ⋅ log
 3.7 1 1
 2 2
 Re ( n) ⋅ f  f

This is the Colebrook White equation


2.51 1
F'( f ) := +
   3     3  
   2   2.51  ⋅ ln ( 10)     2 
 Re ( n) ⋅  f ⋅  .270⋅ ε_D_ratio +   2⋅f 
   ( Re (n) ⋅ f)  

The derivative w.r.t. f of the Colebrook White equation

35
35
11. 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.

Data below scaled from drawing


In Mathcad origin default is 0, reset to 1 in the Math / built-in variables submenu
i := 1 .. 12

35
distance depth

 6.5 0 
 
 13.00 2 
 19.5 2 
 
 26 4 
 32.5 4 
 
Data :=
 39 7 
⋅ft
 46.5 5.5 
 
 52.5 4 
 59 3.5 
 
 65.5 2.8 
 72 1.4 
 
 78.5 0 

n := 12 number of points

h := 6.5⋅ ft distance between sequential data


points

disti := Datai , 1
label each column separately
depthi := Datai , 2

compute the flow area using Simpson's rule


i := 1 , 2 .. 11
Area ( width) ⋅ ( ave_height)
depthi + depthi+ 1
Area :=
∑ 2
⋅ ( h)
i

or

i := 1 , 2 .. n − 1 j := 2 , 3 .. 12

∑ depthi + ∑ depthj Simpson's rule with summations multiplied


i j 2
⋅ h = ft through
2

Simpson's 1/3 rule - each segment requires 3 points

35
i := 1 , 3 .. n − 1 j := 2 , 4 .. n k := 3 , 5 .. n − 1

Area 2
∑ ( width) ⋅ ( average_height)
segments

f ( 1) + 4 ⋅ f ( 2) + f ( 3)
Area 2
∑ 2⋅h ⋅
6
segments

 ∑ depthi + 4 ⋅ ∑ depthj +  ∑ depthk 


 i  j   k 
Area 2 := 2 ⋅ h ⋅  
 6 

Simpson's 3/8 rule - each segment requires 4 points


Area 3
∑ ( width) ⋅ ( average_height)
segments

3⋅h
Area 3
∑ 8
⋅ ( f ( 1) + 3 ⋅ f ( 2) + 3 ⋅ f ( 3) + f ( 4) )
segments

i := 1 , 4 .. n − 2 j := 2 , 5 .. n − 1 k := 3 , 6 .. n l := 4 , 7 .. n − 2
 
 ∑ depthi + 3 ⋅
 ∑ depthj + 
 ∑ depthk ⋅ 3 +
 ∑ depthl
  i  j  k  l 
Area 3 :=  ( 3 ⋅ h) ⋅ 
 8 

If the average flow velocity in the stream is 6 fps what is the flow rate?

35
12.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⋅ε ⋅σ
α where:
mass⋅ C
A = surface area of mass
A⋅ε ⋅σ
α
mass⋅ C
A = surface area of mass
−8
ε = Stephan Boltzman constant, ε := 5.67⋅ 10

σ = emissivity of the body, dimensionless


σ := .4 mA=:=mass
100 of the body, kg
C := 10 mass := 4000
C = specific heat of the material, joule/kg - K
A⋅ε ⋅σ
Tinit := 2500 Ta := 250 α := ∆t := .5
mass⋅ C

d
T −α ⋅  T4 − Ta4 f ( t , T) equation to be solved
  
dt

35
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 4
fn  f ( t , T)

yp yn + ∆t ⋅ fn explicit prediction
n+ 1

fp
n+ 1
(
f tp , yp
n+ 1
)

( )
1
yC yn + ⋅ ∆t ⋅ fn + fp implicit correction
n+ 1 2 n+ 1

Mathcad programs are in the form of functions. The items in the parentheses are the
inputs to the program.

( )
fct Tinit , Ta , α , ∆t :=  n ← 0  initialize counter
  initialize temperature
 T0 ← Tinit 
 while Tn > 500  calculate until temperature drops
  below 500 degrees. This value can
  f ← −α ⋅  T 4 − T 4  
( n)
be changed as desired.
  n a

  Tp ← ( Tn) + ∆t ⋅ f n
 
   predictor corrector algorithm
n+ 1

   
 4
  fpn+ 1 ← −α ⋅  Tpn+ 1 − Ta  ( 4
)  
   
  TC ← Tn + 1 ⋅ ∆t ⋅ f n + fp ( )  
  n+ 1 2 n+ 1  
  T ← TC
 
  n+ 1 n+ 1
 
  T ←T  set TC = T n

  n n+ 1  

  n←n+1  
 increment counter by 1 and return
 
 ( TC n f fp Tp )  output vector

35
( )
soln := fct Tinit , Ta , α , ∆t

n := soln0 , 1 define n based on solution, this way counter always set correctly

redefine solution vector elements with more recognizable names


i
(
TC := soln0 , 0)i
(
Tp := soln0 , 4
i i
) (
f ii := soln0 , 2)ii
(
fp := soln0 , 3
i
)i

13.RUNGE-KUTTA METHOD TO
SOLVE ODE
This document deals with using Runge Kutta methods to solve differential equations of
the form

35
d
y f ( x , y)
dx

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+ 1 (
yi + f ( x , y) ⋅ x 2 − x 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:
yi+ 1 (
yi + φ x i , yi , h ⋅ h )
φ ( x i , yi , h)
is called an increment function. It is essentially a representative slope over the
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

Here's how it works. Let's try an example in which . . .y' f' ( x , y) y

f'( x , y) := y initial condition x 0 := 0 and y0 := 1

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

In the general Runge-Kutta method, you must define a function φ as follows:

35
φ can be different in different variations on the method. Here we
 h 1 
φ( x , y , h) := f' x + ,y + ⋅ h ⋅ f'( x , y) evaluate the function at x+h/2 and y+(f'(x,y)*h/2). Since the
 2 2  function is the derivative, the number returned each time is a
slope.

This represents the slope evaluated at x+h/2 and y +


((∆ y/2)*h).
So we can find a set of points on the curve as follows:
N:
=500 i :
= 0 .N
1. Set a counter to determine the number of points to find
xi : = 0 + i⋅ h
x
2. Define the x values as : . Note that xo and yo are already defined as 0
and 1.
yi+ 1 : y=i + h ⋅ φ ( x i , yi , h)
3. Now use: to define the y values. Note that the relationship is

 h h 
recursive in that each new y value is then used in φ ( x , y , h) f' x + ,y+ ⋅ f'( x , y)
 2 2 
to compute the next y value.

In words : yi+1 = yi + (∆ x * (average between yi and yi+1))


x ind
d
y y has an analytical solution:
( )
ydep x ind : = e
also written as x ln ( y)
dx
x ind := 0 , .2 .. 100

xind
x ind e
Note that the derivative of y e returns demonstrating that it is in deed the
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.

35
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 Euler’s 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.

35
UNIT – V

MATHCAD PROGRAMS TO
PHYSICS PROBLEMS:
Numerical solution of Schrödinger wave equation-
Harmonic oscillator-

35
Learning molecular symmetry-H2O,NH4
-Numerical solution of second order differential
equation –
Study material of hydrogen atom and molecule -
Ground state of helium atom byVariation method
-Electron motion through rectangular potential
barrier –
XY3- planar
14.NUMERICAL SOLUTION OF
SCHRODINGER WAVE EQUATION
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
2m  Zq 2 
∇2ψ +  E + ψ = 0
 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

1 ∂  2 ∂ 1 ∂  ∂  1 ∂2
∇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

35
Ψ( 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
l ≤n−
1
functions, and their properties require that .
The spherical harmonics give atomic orbitals their characteristic shapes. The effect of
changing the quantum numbers on the Θ and Φ equations can be explored below.

Spherical Harmonics

Select values for the quantum numbers l and |m|. Note that |m| must be less than or
equal to l.
Angular momentum quantum number l := 1

Magentic quantum number m := 1


The solution to the Φ equation is given by

The normalization factor for this function is


1
A :=

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 θ

35
The normalization factor for the Θ function is
2l + 1 ( l − m)!
B := ⋅
2 ( l + m)!
The spherical harmonic is given by the product of the Φ and Θ functions.

The indices and equations needed to transform the spherical harmonics into Cartesian
coodinates for plotting in Mathcad are contained in the hidden section below.

Radial Wavefunctions

Select values for the quantum numbers n and l. Note that l must be less than or
equal to n - 1. The atomic number Z can also be varied, but the solutions are only valid
for one-electron atoms.

35
Principal quantum number n := 3

Angular momentum quantum number l := 2

Atomic number Z := 1

The solution to the equation


R Laguerre
( polynomial of the first kind) is given by

where ρ is given by
2 ⋅ Z⋅ r
ρ ( r) :=
n
We'll express r in Bohr units (1 Bohr = 0.0529 nm) in this workbook.
The normalization factor for the R function is

The radial wavefunction is

The radial wavefunction Rln(r), radial density function Rln2(r), and radial distribution

function 4π r2Rnl2(r) are plotted below. Note that the scale may need to be modified
depending on the selection of the quantum numbers.

35
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.

35
15. Numerical Solutions
for Schrodinger's Equation

Integration limit: xmax := 1 Effective mass


: µ := 1

Potential energ
y: V( x) := −1

Numerical integration of Schrodinger's equation:

−1 d2
Given ⋅ Ψ ( x) + V( x) ⋅Ψ ( x) E⋅Ψ ( x) Ψ ( 0) 0 Ψ' ( 0) 0.1
2 ⋅µ d x2

Ψ ( x)
(
Ψ := Odesolve x , xmax ) Normalize wave function:Ψ ( x) :=
x
⌠ max 2
 Ψ ( x) d x
⌡0
Enter energy guess: E≡4

35
Fourier transform coordinate wave function into momentum space.
x
1 ⌠ max
p := −20, −19.5.. 20 Φ ( p ) := ⋅ exp( −i⋅ p ⋅ x) ⋅ Ψ ( x) dx
2⋅ π ⌡0

35
16.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.
3. 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:
2
 1  − α ⋅x
 2  2
ψ n := Nn⋅ Hn α ⋅ x ⋅ e (1) Note: this is an inactive equation.

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:
n := 1 , 2 .. 7 This identifies the set of vibration numbers to be used in this exercise.

2 Identify all of the components of a.


k⋅ µ ⋅ ( 4⋅ π)
α :=
2
h

This is done to simplify the mathematical representation.


let α := 1

1
N( n ) := The normalization factor is a function of n,
n 4 the vibration quantum number
α ⋅ 2 ⋅ n!⋅ π

35
Beginning of Solve Block

Here a solve block is used to find the first Hermite polynomial


n := 1 for the n=1 harmonic oscillator wave function.

Given

H( x)
n ( 2)
( −1) ⋅ exp x ⋅
d
n
n
( 2)
exp −x
(2)
Note:[ctrl] and equal used simultaneously here.
dx

(3) Note: I used [ctrl] and period simultaneously to


Find( H( x) ) → create this expression.

End of Solve Block


Since the range of x has not been defined the [ctrl]= is used in equation (2) to
separate the right and left sides of the solve block.
The Hermite polynomial for n=1 is to the right of the arrow in equation (3) of the
solve block above. Highlighting the polynomial and using copy and paste permits
the creation of the first expression that you will need for the remainder of this
exploration of quantum mechanical harmonic oscillator functions. The subscript
in equation (4) was created with a period, i.e. you type a period followed by the
number or letter you wish to use. This is known as a literal subscript in MathCAD.
The results are:

H1 ( 2) ( 2)
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

By inspection write the polynomial that results when n=0.

Vary n above and determine the first seven Hermite polynomials.

Simplify each one and compare to those published in texts.

Make a table of these to use in the next part of this exploration.


(Hint: use separate regions or Insert lines from the Edit menu to give yourself
space
in this work sheet.)
Now prepare a table of the first seven wave functions for the harmonic oscillator.

35
Plot these and compare to the curves found in most texts.

The first two are shown here as examples. A range for x is set to permit plotting
of the functions.
x := −5 , −4.99.. 5
2 2
− α ⋅x − α ⋅x
2 2
ψ 0( x) := N( 0) ⋅ H0⋅ e ψ 1( x) := N( 1) ⋅ H1( x) ⋅ e

Now plot ψ ψ * as a function of x for each one wave function.

Compare your results to diagrams in your text.

The first two graphs are shown for illustration.

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.

35
2 3 2 4
H0 := 1 H1( x) := 2⋅ x H2( x) := −2 + 4⋅ x H3( x) := −12⋅ x + 8⋅ x H4( x) := 12 − 48⋅ x + 16⋅ x

3 5 2 4 6
H5( x) := 120⋅ x − 160⋅ x + 32⋅ x H6( x) := −120 + 720⋅ x − 480⋅ x + 64⋅ x

3 5 7
H7( x) := −1680⋅ x + 3360x
⋅ − 1344x
⋅ + 128⋅ x

17. 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:

35
It is to be understood that all symmetry matrices in this work will operate on a
displacement vector (x,y,z).To check if Eq [2] reduces to Eq[1], let's define

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 z-axis is
represented by σ:

In general, a reflection by a plane passing through the origin, that is perpendicular to a


unit
vector, A, is represented by a Refl(A) matrix:

Let us check this equation to see if the


matrix reduces to Eq.[3] when A is a unit vector along z-axis:

An inversion about the origin is represented by an Inv matrix:

35
These few matrices will give us sufficient tools to conduct algebric operations on
molecules.
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?

Water molecule

The coordinates of the water molecule can be obtained from quantum computations using
software such as HyperChem. In HyperChem, you need to align the molecule such that z-
axis
is the axis of the rotation. In setting up the molecule for quantum computation, you need
to
use "Align Viewer" with the z-axis (This assures you are looking down the z-axis.) Next,
align
the tertiary axis (axis of rotation in water) with the z-axis, using "Align Molecules" and
align the
tertiary axis with the z-axis.After the alignment, perform ab-initio calculations with 6-
31G**, Restricted Hartree-Fock with MP correlation. Go to the log to find your
coordinate data. The unit of length used in this matrix is the Angstrom.

35
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:

Graphical representation of water molecule:

35
Internal Coordinates

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 z-axis.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 O-
H bonds
C2 Rotation along a principal axis
Closely look at the water molecule shown in Fig.4, the principal axis of rotation is a unit
vector
between 2 O-H bonds. A 180 degree rotation along this unit vector, the molecule returns
to itself.
This axis of rotation is defined as the C2 rotation for the water molecule. To see this, we
shall
first define 2 r vectors,r1= r<0> and r2=r<1>, connecting O atom to 2 H atoms.

35
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.

35
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

35
The Euler operator defined in Eq.[10] can be used to linearly transform both OH bonds as
follows:

Plotting bond vectors


Define a new water molecule matrix:

C2 rotation on OH1 results in OH2. Similarly, C2 rotation on OH2 results in OH1.

35
Exercise 3 Write x, y, z, O, H1, H2 over or beside the matrix NewH2O (Eq.[12]) similar
to
those shown in Eq [5b].
Angle between the two O-H bonds
Exercise 4: If there are two vectors, a and b, that intersect with an angle θ, how would
you
express the relationship between θ, and the dot product of a and b?

Reflection by a plane containing a principal axis


There are two such planes. One such plane is such that its normal is a vector that connects
H1 to H2. The other plane is a plane conaining all three atoms.

35
Reflection of OH1 vector with σv1 returns OH2 and vice versa. Reflection of OH1 with
σv2
returns to itself.
Symmetry operators for water molecule form a group
We can show that these 4 symmetry operators, E, C2, σv1, and σv2 form a group,
according
to group theory. We need to demonstrate:
1) if A and B are symmetry operations of the group, then AB is also a symmetry
operation of
the group.
2) associative rule is obeyed: (AB)C= A(BC)
3) there is an identity symmetry operation, E, such that EA=AE=A
4) for every A, there is A-1 such that AA-1=A-1A=E
With Fig.5 of OH1 and OH2 of water molecules, we re-write these 4 operators.

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)

35
Exercise 7 What is the inverse of the element of C2 ? Is the inverse of C2 also a
member of the group? What is it ?
Unitary properties of symmetry operations
We can show these symmetry operations are unitary by showing that their transpose
matrices
are also their inverse matrices.

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.

Exercise 11 Demonstrate the unitary property of these symmetry matrices. An example of


conservation of length is demonstrated here. You will need to demonstrate length
conservations with other operators.

35
The Ammonia Molecule
Hyperchem data and three N-H vectors

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.

35
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.
Plotting ammonia molecules
To plot ammonia molecule with three NH bonds, we need to construct a matrix from Eq.
[21]

35
Angles between N-H bonds

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
Eq.[23] except the numerical value -2.642 x 10-4 for C3*r11 on the left is set to zero on
the

35
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.

Exercise 18 Construct coordinate matrices based on Eq[25] and plot them to


demonstrate that the molecule returns to an identical configuration after the reflection
operations.

35
Reflection-Rotation(Improper Rotation) of Methane Molecules
Hyperchem Quantum Computation to collect coordinate data. Your objective is to write
4
vectors from the central carbon atom to each individual H-atom. The goal of this hand s-
on
exercise is to learn about the improper rotation, S 4 , which is one of the symmetry
operations
for methane. You also need to show that there is no C4 symmetry operation for this
particular molecule.
The units used in the following table are Angstroms.

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

35
all these bonds. Do they agree with the definition of a tetrahedral molecule?

Plotting methane molecule

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].

The methane molecule has an reflection-rotation symmetry, S4, which consists of a


combination of first, a 90 degree of rotation followed by a reflection which is
perpendicular to

35
this axis of rotation. By looking at the plot shown above, is the axis of rotation the same
as
z-axis ? Obviously, it is not. Therefore, you need to identify the axis of rotation.
22 Franklin M.C. Chen
UW-Green Bay
The axis of rotation is half way between any of two C-H bonds.
Exercise 21: Find all the axes of rotation-reflection for methane. One of the axes is
shown
here. Find the other axes. How many of these axes are unique?

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

35
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

Two out of three eigenvalues for S4 are imaginary. But S4 is unitary.

This means that lengths of the transformed C-H bonds are conserved:

35
18.NUMERICAL SOLUTION OF
SECOND ORDER DIFFERENTIAL
EQUATION
I. 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
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

35
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.
II. Goal
To provide an introduction to the use of numerical methods for solving quantum
mechanical problems.

III. Prerequisites
1. College calculus including differentials and integrals. You should know what a second
derivative is.
2. Basic skills with Mathcad.

IV. Objectives
1. Explain the relationship between a physical model and the differential equation
representing that model.
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.
V. 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.

35
The differential equation for the classical harmonic oscillator is:
d2 X t  k
2
=−   X  t  or
d t m
--------------(1)
k
Ẍ =−  X  t 
m

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:
First write X (t ) =AMP cos (bt ) +B sin (bt ) ---------------(4)
Take the derivative with respect to t to get
 (t ) =−AM
X P b sin (bt ) +Bb cos (bt ) ------------------(5)
Then impose another boundary condition, namely that
 (0) =0
when t =0then X

∴B =0

so X (t ) = AMP cos( bt ) -------------------------------(6)


substitute equation 6 into equation 1 to find b
k
b2 =
m

k
b= =ω ---------------------(7)
m

35
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.
VI. 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:

2
X( t ) := − ⋅ X( t)
d k
2 
dt m
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
n := 300
throughout the whole range is small.

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.
m := 1 k := 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

35
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

Now step through the grid to generate the ti values


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
depends on the system you are studying. For the simple function in this initial exercise
you can use other values for X1 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.) X0 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.

35
2

2⋅ X
i−1
−X
i− 2
+
12
(
⋅ k⋅ X
i−2
+ 10 ⋅ k ⋅ X
i− 1)
X :=
i 2

1 − k⋅
12
k ≡ −1.0

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.

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?

35
19.STUDY MATERIAL OF HYDROGEN
ATOM AND MOLECULE
The Ionized Hydrogen Molecule
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 Born-
Oppenheimer approximation [5] since they are much more massive than the electron.
LCAO Solution
In the LCAO view, the effects of each proton on the motion of the electron are
considered separately. In other words, the electron is assumed to be completely governed
by proton A when it is closer to proton A and to be completely controlled by proton B
when it is closer to proton B. This results in an overlap region the area of which depends
on the distance between the two protons. In a planar view, the position of the electron can
be defined by its distance to the nearest proton, rA or rB, and its angle, θA or θB . This
geometry, illustrated below, is best described in polar coordinates.

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

35
(4a)

and

(4b)
The coefficients can be determined from the variational principle.
To compare the molecular orbitals from the LCAO method to those of the exact method,
the real hydrogenic orbitals must be converted from spherical to spheroidal coordinates.
The necessary relationships between the spherical coordinates r, θ, and φ and the prolate
spheroidal coordinates ξ , η , and φ are given below.

The 1s orbitals in spherical coordinates are given by

(5a)

and

(5b)

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:
rAB   rAB 
− ⋅( ε + η
 ) − ⋅( ε −η )
1 1
ψ ( ε , η ) := ⋅e   ψ ( ε , η ) := ⋅e  
2 2
1sa 1sb
π π
To determine the coefficients with the variational principle, we need to calculate the
overlap integral, which in spheroidal coordinates is given by

∞ 1 2⋅π
⌠ ⌠ ⌠ 3
 
S := 


 ψ 1sa( ε , η ) ⋅ ψ 1sb ( ε , η ) ⋅
rAB
( 2
⋅ ε −η
2
) dφ dη dε
  8
⌡ ⌡
1 −1

0

35
The coefficients can be calculated from the following expressions.

The LCAO 1σ g orbital is


Ψ 1σg ( ε , η ) := cb ⋅ ψ 1sa( ε , η ) + cb ⋅ ψ 1sb( ε , η )
and the LCAO 1σ u orbital is
Ψ 1σu ( ε , η ) := ca ⋅ ψ 1sa( ε , η ) − ca ⋅ ψ 1sb ( ε , η )
Here is the plot of the LCAO approximation of the 1σ g orbital and its probability
distribution.

35
Here is the plot of the LCAO approximation of the 1σ u orbital and its probability
distribution.

Here is the plot of the LCAO approximation of the 1σ u orbital and its probability
distribution.

35
20.GROUND STATE OF HELIUM
ATOM BY VARIATION METHOD
Gaussian Trial Wave Function:

Demonstrate the wave function is normalized.

The terms contributing to the total electronic energy of the helium atom are the kinetic
energy of each electronʹs interaction with the nucleus, and the interaction of the electrons
with each other.
Calculate kinetic energy:

Calculate electron‐nucleus potential energy:

Calculation of electron‐electron potential energy:


a. Calculate the electric potential of one of the electrons in the
presence of the other:

b. Calculate the electron‐electron potential energy using result of part


a:

35
Write the equation for the total electronic energy in terms of the
variational parameter β and minimize the energy with respect to β:

Compare the variational calculation to the Hartree‐Fock limit:

Compare the variational calculation to the Hartree‐Fock limit:

Compare optimized trial wave function with the Hartree‐Fock wave


function (see McQuarrie and Simon, page 283) by plotting the radial
distribution functions.

35
22.ELECTRON MOTION THROUGH
RECTANGULAR POTENTIAL
BARRIER
We will examine the problem of a particle incident on a 1-dimensional potential
barrier.The particle approaches the barrier from the left with an incident energy
E. The barrier has a height of Vo and a width L. We will look at the wavefunctions
for the case where the incoming energy is lower than the barrier height.

________________
| |
E Vo | | T
| |
--------------------------- | | -- - - - - - - - - - - - >
| |
___________________________|
___________________________ <------- L ------->
In the first section, the wavefunction for a particle colliding with a barrier is plotted
out.
Use this wavefunction to describe the reference particle. Later on you get to
change the characteristics of a second particle and compare it with this reference
particle.
First, let's define the characteristics of the reference particle
MAS := 5 Set the particle's mass.

E := 0.008 Set the particle's energy (kinetic energy in this case).

Set the ratio of the particles energy to the barrier height. This
EoverV:= 0.9 value should be kept less than unity.

WID := 5 Set the width of the barrier.

E
Vo := Compute the barrier height.
EoverV

35
Here we calculate the wavefunctions, which are found by solving the Schrodinger
equation !
You need not know the details of this coding.
π π Wid0 := WID
K2 :=  2⋅ MAS ⋅ ( Vo − E) ⋅ K1 := ( 2⋅ MAS ⋅ E) ⋅ z := −1
2 2

A1 := 1. factor := cosh ( K2⋅ WID) −


(
z⋅ K1 − K2
2 2 ) ⋅sinh (K2⋅WID)
2⋅ K1⋅ K2

A1⋅ ( cos ( K1⋅ WID) − z⋅ sin ( K1⋅ WID) )


A3 :=
factor

A1p :=
( 2
−z⋅ K2 + K1
2) ⋅sinh (K2⋅WID)⋅A3⋅(cos (K1⋅WID) + z⋅sin (K1⋅WID))
2⋅ K1⋅ K2

0.5
A2 := ⋅ [ A1⋅ ( K2 + z⋅ K1) + A1p⋅ ( K2 − z⋅ K1) ]
K2 A2p := A1 + A1p − A2

i := 1 .. 100
10⋅ WID
x := −5⋅ WID + i⋅
i 100

( ( i) ( i) ) + A1p⋅ ( cos ( K1⋅ xi) − z⋅ sin ( K1⋅xi) )


P1 := A1⋅ cos K1⋅ x + z⋅ sin K1⋅ x
i
P2 := A2⋅ exp( K2⋅ x ) + A2p⋅ exp( −K2⋅ x ) P3 := A3⋅ ( cos ( K1⋅ x ) + z⋅ sin ( K1⋅ x ) )
i i i i i i

potr := if x ≤ WID ⋅ x ≥ 0 ,


( )(i ) , 0 (i (i ))
2
wf := if x < 0 , P1 , if x > WID, P3 , P2
i  i EoverV  i i i i

Rwf := Re wf
i ( i) x1 := x
i 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.

35
Now we will write this wavefunction into a new vector which will be the reference
wavefunction.
ψref i := Rwf i

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 This parameter specifies the particles energy.

Change this parameter to modify the mass. For nice


MAS := 5 wavefunctions this mass should be greater than 1 !

WID := 23 Change this parameter to modify the width of the barrier !

EoverV:= 0.9 Change this parameter to vary the ratio of the incoming energy to
the barrier height.

E
Vo := Here we compute the barrier height.
EoverV
Here we calculate the wavefunction, which is found by solving the Schrodinger
equation !
You need not know πthe details of this coding.
π
K2 :=  2⋅ MAS ⋅ ( Vo − E) ⋅ K1 := ( 2⋅ MAS ⋅ E) ⋅
2 2

A1 := 1. factor := cosh ( K2⋅ WID) −


(
z⋅ K1 − K2
2 2 ) ⋅sinh (K2⋅WID)
2⋅ K1⋅ K2

A1⋅ ( cos ( K1⋅ WID) − z⋅ sin ( K1⋅ WID) )


A3 :=
factor

A1p :=
(
−z⋅ K2 + K1
2 2 ) ⋅sinh (K2⋅WID)⋅A3⋅(cos (K1⋅WID) + z⋅sin (K1⋅WID))
2⋅ K1⋅ K2

35
0.5
A2 := ⋅ [ A1⋅ ( K2 + z⋅ K1) + A1p⋅ ( K2 − z⋅ K1) ]
K2 A2p := A1 + A1p − A2

WIDL := if( WID ≤ Wid0, Wid0 , WID)


10⋅ WIDL
i := 1 .. 100 x := −5⋅ WIDL + i⋅
i 100

( ( )
P1 := A1⋅ cos K1⋅ x + z⋅ sin K1⋅ x
i i ( ) ) + A1p⋅ ( cos ( K1⋅ xi) − z⋅sin ( K1⋅ xi) )
i

( )
P2 := A2⋅ exp K2⋅ x + A2p⋅ exp −K2⋅ x
i i ( )
i ( ( )
P3 := A3⋅ cos K1⋅ x + z⋅ sin K1⋅ x
i i ( ))
i

pot0 := if x ≤ WID ⋅ x ≥ 0 ,


( )(i ) , 0 (i (i ))
2
wf := if x < 0 , P1 , if x > WID, P3 , P2
i  i EoverV  i i i i

Rwf := Re wf
i ( i) xmax:= if x1 ( 100
≥x
100
, x1
100 100
,x )
This is the wavefunction of the reference particle
xp := x
i i z := −1

This is the wavefunction of your particle.

35
22. PLANAR XY3 TYPE
MOLECULE-EXAMPLE HCHO-
FORMALDEHYDE.
As the figure below reminds you, formaldehyde is a four atom non-linear
molecule. The point group to which it belongs is C2v, and it is a nearly prolate top with
an asymmetry parameter near -1. The permanent dipole moment is directed along the a-
axis. Since it is non-linear, there are 3(4)-6 = 6 non-degenerate normal modes of
vibration. In the order derived by G. Herzberg, these six modes are:

35
The structure and vibrational normal modes of formaldehyde.

What are the symmetries of the normal modes? Clearly, the C2v symmetry of the
molecule is maintained in the ν1,ν2, and ν3 modes, and so they are all A1. The ν6,
or out-of-plane bending, mode, is B1, and the remaining ν4 and ν5 modes are B2. The
ν1, ν2, and ν3 modes have dipole derivatives that change along the a-axis,
The six normal modes of vibration of formaldehyde in the point group
C2v(3A1+2B1+B2)are all Raman and Infrared active. The internal coordinates of H2CO
are shown in the figure and the coordinate for the out of plane mode(∆ π ) are not
shown. The symmetry coordinates are easily constructed and are easily shown below.

35
The geometrical parameters are r(C=O)1.216 A,r (C-H)1.09A,α (HCH)and
α (OCH)each 120deg.are employed.
Symmetry coordinates :
A1 species :
 1
(
S1   ⋅ ∆r1 + ∆r2 )
 2

S2 ∆d
 1  ⋅ 2 ⋅∆ β− ∆ α − ∆ α
S3   ( 1 2 )
 6
 1  ⋅ ∆ β+ ∆ α + ∆ α
Sr   ( 1 2)
 3
(redundant coordinate)
B1 species
 1
(
S4   ⋅ ∆r1 − ∆r2 )
 2
 1 ⋅ ∆ α −∆ α
S5   ( 1 2)
 2
B2 species S6 ∆ π

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.
 ∆d   A B B C D D 
 
∆r
 1  A1 B1 D1 D2 C1 
   
 ∆r2
  A1 D1 C1 D2 
 ∆ β  
 E F F 
 

 1α  E1 F1 
 ∆ α  
 E1 
 2
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.

35
G11 A µC + µO

G22 G33 A1 µC + µH

G23 B1 µ C ⋅ cos ( β ) G12 G13 B µ C ⋅cos ( α )

sin ( α )
G14 C 2 ⋅µC ⋅
r
sin( α )
G15 G16 −µ C ⋅
r

sin( β )
G24 G34 D1 −µ C ⋅
r
sin( α )
G25 G36 D2 −µ C ⋅
d
sin ( β ) cos ( α )
G26 G35 C1 −µ C ⋅ + µC ⋅
r d
( µC + µH)  cos ( β ) 
G44 E 2⋅ − 2 ⋅ µ C ⋅ 
2 2
r  r 
( µC + µH) ( µC + µH)  cos ( α ) 
G55 G66 E1 + − 2 ⋅ µC ⋅ 
d
2
r
2  r ⋅d 

( µ C + µ O)   cos ( α )   cos ( β )


+ 2 ⋅ µ C ⋅  −  µC ⋅
2 
G56 F1
 
2 r ⋅d 
d  r 
( µC + µH) cos ( β )
G45 G46 F − + µC ⋅
2 2
r r

35
120⋅π
MO := 16 MH := 1.008 MC := 12 β :=
180
1 1 1
µ O := µ H := µ C :=
MO MH 120⋅ π
MC α :=
180
A1 := µ C + µ H B1 := µ C ⋅cos ( β ) r := 1.09
d := 1.216
A := µ C + µ O
B := µ C ⋅ cos ( α )

( µC + µH)  cos ( β ) 
E := 2 ⋅ − 2 ⋅ µC ⋅ 
2 2
r  r 
 ( µC + µ H) ( µC + µH)  cos ( α )  
E1 :=  + − 2 ⋅ µC ⋅ 
 d
2
r
2  r ⋅d 

 ( µC + µO)   cos ( α)   cos ( β )  
F1 :=  + 2 ⋅  µ C ⋅  −  µC ⋅ 
2 
 
2 r ⋅d 
 d  r  
 ( µ C + µH) cos ( β ) 
F := − + µC ⋅ 
2 2
 r r 

35
 ( D1 + D2 − C1) 
 A1 + B1 2 ⋅B 2 ⋅D1 − C1 − D2 2⋅ 
6
 
 ( C − D) C + 2 ⋅D 
 0 A 2⋅ 
6 6
GA1 :=  
 0 0
1
⋅ ( 2 ⋅ E + E1 + F1 − 4 ⋅F)
2
⋅ ( E + F − E1 − F1) 
 3 3 
 1

 0 0 0 ⋅ ( E + 4 ⋅ F) + 2 ⋅E1 + 2 ⋅ F1 
 3  

 1.034 −0.059 0.027


Ga1 :=  0 0.146 0.162
 
 0 0 3.096

For B1 species

 A1 − B1 D2 − C1 
GB1 :=  
 0 E1 − F 1

fr := 4.35 fd := 10.8 fα := 0.83 fβ := 0.46

fdα := 0.291 frβ := 0 frr := 0 frα := 0 fdβ := 0.173

fα α := 0 fβ α := 0 fdr := 0.29 trα := 0


 2 ⋅frβ − frα − trα 
fr + frr 2 ⋅ fdr
 3 
FA1 :=  0 fd 2 ⋅ ( fdβ − fdα ) 
 
  2 ⋅fβ + fα + fα α − 4 ⋅fβ α 
 0 0  
  3 

35
 fr − frr frα − trα 
FB2 :=  
 0 fα − fα α

35
QUESTIONS
1. Derive the numerical solution of Schrödinger 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.

35
***************

35

Vous aimerez peut-être aussi