Basic Calculation and Graphing                     

                                  Mathematica


Dr. Andrzej Korzeniowski
Department of Mathematics, UTA

Lesson 1

Preliminaries

Mathematica operations are based on the concept of a list {a, b, ..., c} where a, b,...  are symbols or numbers.  Use built-in palettes : BasicInput (shown as default next to the notebook) found in Files->Palettes->BasicInput. To put an expression of choice in a given place click the cursor in that place and then click the desired item from palette. Use Format-> Show ToolBar to see in the left-upper corner the attribute of the cell containing the active cursor.  Input cells hold commands that execute mathematical operations while Output cells store the answer.  Other layout options are: Text, Title, Section, etc. (word processing only and not to be executed).  Expressions are stored in cells displayed  as blue brackets on the right-hand side.  Cells can be formatted  or operated on by being selected (clicking on cell bracket to highlight it in black) then going to Cell (main menu) and using pull-down menus. Most useful initially  are: Cell Grouping (first choose Manual Grouping ->Ungroup Cells) so each executable expression is entered in a separate single Input cell for easy corrections, Divide Cell (put cursor in a desired place in the cell), Merge Cell (highlight cells to be merged).  Use the online HELP in the main menu to familiarize yourself  with many  other features. To delete a cell highlight the cell and press Delete key. Use copy, cut, paste, undo, from Edit to avoid unnecessary typing.

[Graphics:Images/lesson1_gr_1.gif]

[Graphics:Images/lesson1_gr_2.gif]
[Graphics:Images/lesson1_gr_3.gif]

[Graphics:Images/lesson1_gr_4.gif]

[Graphics:Images/lesson1_gr_5.gif]
[Graphics:Images/lesson1_gr_6.gif]
[Graphics:Images/lesson1_gr_7.gif]
[Graphics:Images/lesson1_gr_8.gif]
[Graphics:Images/lesson1_gr_9.gif]
[Graphics:Images/lesson1_gr_10.gif]
[Graphics:Images/lesson1_gr_11.gif]
[Graphics:Images/lesson1_gr_12.gif]
[Graphics:Images/lesson1_gr_13.gif]
[Graphics:Images/lesson1_gr_14.gif]
[Graphics:Images/lesson1_gr_15.gif]
[Graphics:Images/lesson1_gr_16.gif]
[Graphics:Images/lesson1_gr_17.gif]
[Graphics:Images/lesson1_gr_18.gif]
[Graphics:Images/lesson1_gr_19.gif]
[Graphics:Images/lesson1_gr_20.gif]

TYPING TEXT.  To type a text highlight a cell and choose Text from the ToolBar.  

NUMERICAL EVALUATION. To evaluate an  expression Expr  numerically use N[Expr] or Expr//N. To evaluate with n digit of accuracy use N[Expr,n]

[Graphics:Images/lesson1_gr_21.gif]
[Graphics:Images/lesson1_gr_22.gif]
[Graphics:Images/lesson1_gr_23.gif]
[Graphics:Images/lesson1_gr_24.gif]

FUNCTIONS.  All  elementary functions  MUST begin with a CAPITAL LETTER
followed by BRACKET [x] in place of parenthesis (x). List of  basic functions:
Sin[x], Cos[x],Tan[x], Cot[x], ArcSin[x], ArcTan[x], Log[x](=ln x = natural logarithm), Log [b, x] = [Graphics:Images/lesson1_gr_25.gif]x),  [Graphics:Images/lesson1_gr_26.gif] (exponential function base natural number ⅇ = 2.71828182, where ⅇ must be taken from the BasicInput palette (do NOT use 'e' from the keyboard),
Abs[x] (= |x| = absolute value of x ).

BRACKETS [ . ]  Used exclusively for defining functions, i.e., f[x]  NOT  f(x).
Parentheses are used only for grouping symbols in algebraic/numerical expressions.  
In fact, never use   [.], {.} in algebraic/numerical expressions.

[Graphics:Images/lesson1_gr_27.gif]

[Graphics:Images/lesson1_gr_28.gif]

Warning: The graph above is NOT a true picture!!!
A true picture
, i.e., with the units of length on the x and y axes equal,  is rendered by the
graphics option shown below (the default is 1/Golden Ratio = [Graphics:Images/lesson1_gr_29.gif]=.618)

[Graphics:Images/lesson1_gr_30.gif]

[Graphics:Images/lesson1_gr_31.gif]

DEFINITIONS.  To define expressions use " = " while for defining functions the syntax is f [x_ ] = [Graphics:Images/lesson1_gr_32.gif]+[Graphics:Images/lesson1_gr_33.gif],  or  g [x_ , y_ ] = (x + y - 1) / 3,  i.e., x_ = x followed by the underline symbol _.  Semicolon ";" at the end of the expression prevents writing it back to the screen. ": = " instead of " = " causes the output (after its execution) not to be displayed on the screen .

[Graphics:Images/lesson1_gr_34.gif]

CONDITIONAL DEFINITION of f [x] .   Depending on what the x-values are:

[Graphics:Images/lesson1_gr_35.gif]
[Graphics:Images/lesson1_gr_36.gif]
[Graphics:Images/lesson1_gr_37.gif]
[Graphics:Images/lesson1_gr_38.gif]

[Graphics:Images/lesson1_gr_39.gif]

EXACT ALGEBRAIC SOLUTIONS.

[Graphics:Images/lesson1_gr_40.gif]
[Graphics:Images/lesson1_gr_41.gif]
[Graphics:Images/lesson1_gr_42.gif]
[Graphics:Images/lesson1_gr_43.gif]
[Graphics:Images/lesson1_gr_44.gif]
[Graphics:Images/lesson1_gr_45.gif]
[Graphics:Images/lesson1_gr_46.gif]
[Graphics:Images/lesson1_gr_47.gif]

NUMERICAL SOLUTIONS.
Most  equations (e.g., polynomials  of degree 5 or higher) cannot be solved symbolically.  
One uses in those cases the built-in functions to obtain approximate numerical solution.

[Graphics:Images/lesson1_gr_48.gif]
[Graphics:Images/lesson1_gr_49.gif]
[Graphics:Images/lesson1_gr_50.gif]
[Graphics:Images/lesson1_gr_51.gif]
[Graphics:Images/lesson1_gr_52.gif]
[Graphics:Images/lesson1_gr_53.gif]
[Graphics:Images/lesson1_gr_54.gif]
[Graphics:Images/lesson1_gr_55.gif]

GRAPH TRACING.  One can change the position and size of the graph by using the mouse: Click on the graph+hold+drag
(= moving), click+hold corners+drag (= sizing).  Also, by pressing the Ctrl key one can move the mouse cursor to trace the
points on the graph and read the coordinates in the left lower corner of the notebook in the {x,y} form.  The graph tracing feature allows one to find approximate solutions to f [x] = 0, by following the graph of f [x] in the vicinity of its x-axis crossing.  After initial location of  x = a  such that  f [a] ≈  0; then one replots f [x]  on the interval  [a - δ, a + δ ], where  δ  is a small number and traces the graph again.  One may repeat those steps several times (the effect is to "zoom in" and a graph will eventually look like a straight line after several zoom-ins) until a desired accuracy is achieved.

MULTIPLE PLOTS.  To plot  f(x), g(x), h(x)  together use  Plot[{f[x], g[x], h[x]}, {x, a, b}];

[Graphics:Images/lesson1_gr_56.gif]

[Graphics:Images/lesson1_gr_57.gif]


Clear[f]
[Graphics:Images/lesson1_gr_58.gif]
[Graphics:Images/lesson1_gr_59.gif]

[Graphics:Images/lesson1_gr_60.gif]

DISCONTINUITY.   To graph the actual discontinuity of  f(x)  at  x = 1  one must remove the vertical segment
at  x = 1  by building the graph of  f(x)  separately on  [0,1)  and  [1,2] and then combine them together.

[Graphics:Images/lesson1_gr_61.gif]
[Graphics:Images/lesson1_gr_62.gif]

[Graphics:Images/lesson1_gr_63.gif]

Usually one identifies the vertical line segment over the point  x = a  as a point of discontinuity of  the function and
therefore no need for DisplayTogether[ . ] arises.


Converted by Mathematica      March 27, 2001