Mathematica Tutorial

8
1 Return to List of Lessons Introduction To start Wolfram Mathematica 7, you can either click “Start” and move down to “All Programs” to find Wolfram Mathematica 7. Or you can click the icon of Wolfram Mathematica 7 on your desktop if its shortcut has already been set up. When it is activated, a welcome screen opens in the middle of your window and a blank notepad named “Untitled 1” opens to the left-hand side. If the Welcome screen does not come up, it can be found on the “Help” dropdown menu.

Transcript of Mathematica Tutorial

Page 1: Mathematica Tutorial

1  

Return to List of Lessons

Introduction

To start Wolfram Mathematica 7, you can either click “Start” and move down to “All Programs” to find Wolfram Mathematica 7. Or you can click the icon of Wolfram Mathematica 7 on your desktop if its shortcut has already been set up.

When it is activated, a welcome screen opens in the middle of your window and a blank notepad named “Untitled 1” opens to the left-hand side. If the Welcome screen does not come up, it can be found on the “Help” dropdown menu.

Page 2: Mathematica Tutorial

2  

Looking into the welcome screen,

you will find the guidance provided by Wolfram Research INC. that can help you learn how to get started.

There are many guided examples and hands-on tutorials from these links that basically teach you how to use Mathematica in a short period of time by yourself. Also you can watch a short video tour to get a general view of what people are doing with Mathematica. We particularly recommend that you work your way through “Learn with guided examples” right away.

Page 3: Mathematica Tutorial

3  

Lesson 1. Plotting a Graph of a Function Over a Given Interval

In this lesson we will learn how to use Mathematica to plot a single graph over a given interval.

In the next lesson we will learn how to plot multiple graphs over a given interval in the same box because in many occasions you may want to make comparisons between two or more graphs in the same box.

To get ready for plotting a graph of a function, first minimize the welcome screen and then click Palettes from the tool bar located at the top of your window.

From the dropdown menu of Palettes, you will find the Classroom Assistant. It brings up the Calculator that can help you type mathematical terms and symbols very conveniently and quickly, especially when you are still a new user.

Next you will see how to use Mathematica to plot graphs.

Example 1. Plot the graph of xxf sin)( = over the interval ]2,2[ ππ−

Page 4: Mathematica Tutorial

4  

First click in the blank notepad to makes sure the cursor is flashing.

Type , , ,

[Note] The initial letter of any function or command must be typed in upper case and the variable must be enclosed by square brackest, such as: Plot[ …], ,][xSin ,][xCos ,][xAbs and ].[xTan The range of x-values must be defined and enclosed by curly brackets, such as: , 2 , 2 . You can insert the character π by clicking on it on the Classroom Assistant. Notice that when you point to a character such as π on the Classroom Assistant that it also shows you the keys to type to enter that character. In this case you could enter π by pressing the Esc key, p, and Esc. For those who are reasonably good typists it is worth memorizing these key strokes for the more commonly used characters.

To get the result, you either press Shift + Enter on your keyboard, or use your mouse to click Enter on the Classroom Assistant panel. The graph will be shown as below.

Example 2. Plot the graph of 32)( 2 −−= xxxf over the interval ]5,5[−

Press Enter on your keyboard to exit the previous work. Then you start to type when the cursor is flashing.

Type , , ,

[Note] To type in the term in the notebook, you either use your keyboard to enter keys “x, Ctrl 6, 2, right arrow”, or use your mouse to click the symbol of exponent on the Classroom Assistant panel.

To get the result, you do the same thing as you did in Example 1 --Using the mouse to click Enter on the Classroom Assistant panel. The graph will be shown as

-6 -4 -2 2 4 6

-1.0

-0.5

0.5

1.0

Page 5: Mathematica Tutorial

5  

Example 3. Plot the graph of 2

1)(−

=x

xf over the interval ]5,1[−

Click Enter to exit the previous work and make sure the cursor is flashing.

Type , , ,

[Note] In this example you learn how to enter fractions. To type in the term , you either use the symbol for fraction from the Classroom Assistant, or press Ctrl / from your keyboard. After completing the denominator press the right arrow key to get back to the base line of type.

The graph should look like

-4 -2 2 4

5

10

15

20

25

30

-1 1 2 3 4 5

-3

-2

-1

1

2

3

Page 6: Mathematica Tutorial

6  

Example 4. Plot the graph of 24)( xxf −= over the interval ]4,4[−

Type √ , , ,

[Note] In this example you learn how to type in square-root functions. To type in the term √ , you either use the symbol of square-root from the Classroom Assistant, or press Ctrl 2 from your keyboard. After you type 24 x− you need to press the right arrow twice, first to exit the exponent, then to exit the square-root symbol.

The graph will be shown as

Example 5. Plot the graph of |12|)( −= xxf over the interval ]3,2[−

Type , , ,

[Note] Mathematica uses its own function “Abs[ ]” for the absolute-value functions, instead of using double lines, so when entering |12|)( −= xxf you need to type in ]12[ −xAbs . The result should look like

-4 -2 2 4

0.5

1.0

1.5

2.0

-2 -1 1 2 3

1

2

3

4

5

Page 7: Mathematica Tutorial

7  

In the last part of this lesson you will learn how to type texts inside a graph box. Let’s revisit Example 2.

Example 2. Plot the graph of 32)( 2 −−= xxxf over the interval ]5,5[−

, , ,

To add texts to the graph box, you need to right-click on the graph and a short menu pops up. On the menu you scroll your mouse to “Drawing Tools” and click. A small panel “2D Drawing” will drop into your window

At the bottom of the “2D Drawing” panel, there are two symbols ≡Α and ≡Σ .

“ ≡Α ” will let you type in texts in a normal form and “ ≡Σ ” let you type in texts in mathematical form.

-4 -2 2 4

5

10

15

20

25

30

Page 8: Mathematica Tutorial

8  

First click on ≡Α . The cursor will change. You click it on the graph at an appropriate place you want to type in your texts. For instance you can type in “ It is a parabola !” For these words, you can also change their sizes and fonts using the “Format” command located at the top of your screen.

Clicking on “Format” opens a menu that allows you to change many aspects of the text including font size, face, color, etc.

Next let’s click on ≡Σ to add “ 2 3” to the graph. Remember to press Ctrl 6 when typing in the term of just like what we did before. The “Format” commands can also be used to change the characteristics of this text. At last, click on the arrow on the “2D Drawing” panel.

You can pull out an arrow pointing from the text “ 2 3” to the curve. The result looks like

Return to List of Lessons

y = x2 - 2 x - 3It is a parabola !

-4 -2 2 4

5

10

15

20

25

30