mathematica - a fantastic playgrounda welcome screen appears, from which you can either create a new...

41
Mathematica - A Fantastic Playground Before we Begin You can open a section by either double clicking on the down arrow at the very right of the screen or by navigating to that section (using the arrow keys) and hitting Control + ‘ (apostrophe). To start, open up the section "Explore: Dynamic Functionality" below. The real talk begins below with the section "Basics". Explore: Dynamic Functionality Start exploring this notebook on your own. All you need is a mouse! Play around with the sliders and other controllers below and see what happens

Upload: others

Post on 12-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

Mathematica - A Fantastic Playground

Before we BeginYou can open a section by either double clicking on the down arrow at the very right of the screen or by navigating to that section (using the arrow keys) and hitting Control + ‘ (apostrophe).

To start, open up the section "Explore: Dynamic Functionality" below. The real talk begins below with the section "Basics".

Explore: Dynamic Functionality

Start exploring this notebook on your own. All you need is a mouse! Play around with the sliders and other controllers below and see what happens

Page 2: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

In[32]:= (* Pottery *)

DynamicModule

dd = 3 Pi 2, f, pts = {{0, 2}, {1, 2}, {3, 3}, {5, 2}, {6, 2}, {7, 3}, {9, 3}},

f = Interpolation[pts, InterpolationOrder → 2, Method → "Spline"];

Grid

LocatorPane

Dynamicpts, f = Interpolation[#, InterpolationOrder → 2, Method → "Spline"];

pts = # &, Dynamic[Plot[f[t], {t, 0, 9}, PlotRange → {{0, 9}, {0, 4}}]],

Slider[Dynamic[dd], {.1, 2 Pi}],

{Dynamic[RevolutionPlot3D[{f[t]}, {t, 0, 9}, {d, 0, dd},

Mesh → None, PlotStyle → Directive[Orange, Specularity[White, 10]],

RevolutionAxis → {1, 0, 0}, PlotRange → {All, {-4, 4}, {-4, 4}},

ImageSize → 500], TrackedSymbols ⧴ {f, dd}], SpanFromLeft}

Out[32]=

0 2 4 6 8

1

2

3

4

2 Beginner Session - 10-25-2014.nb

Page 3: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

In[33]:= (* Rotating about a point *)

Manipulate[Graphics[{Gray, Rectangle[], Black, Rotate[Rectangle[], θ, center],

Red, PointSize[0.03], Point[center]}, PlotRange → 2, Axes → True],

"The rotation variable runs from 0 to 2π:",

{θ, 0, 2 π, ControlType → Animator, ImageSize → Small},

Delimiter,

"Rotation happens around whatever center the user specifies",

{{center, {0, 0}}, {0, 0}, {1, 1}, ControlType → Slider2D},

ControlPlacement → Left

]

Out[33]=

The rotation variable runs from 0 to 2π:θ

Rotation happens around

whatever center the user specifies

center

-2 -1 1 2

-2

-1

1

2

In[34]:= (* Random music *)

Sound

TableSoundNoteNestList[# + 4 &, -24, n = 10] RandomChoice[{1 - #, #} -> {0, 1}] & /@

RealDigitsN1 7, n + 1[[1]] 50 /. x_ /; x == 0 → None, 0.25, {102}

Out[34]=

25.5 s

Beginner Session - 10-25-2014.nb 3

Page 4: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

In[35]:= (* Pretty graphic *)

Manipulate[

Graphics[Polygon[Table[r^n {-Sin[n * a], Cos[n * a]}, {n, 0, L}]], PlotRange → P],

{P, 1, 0}, {{r, .98}, 1, .95}, {{a, 2.6}, 0, 2 Pi}, {{L, 300}, 1, 1000, 1}]

Out[35]=

P

r

a

L

4 Beginner Session - 10-25-2014.nb

Page 5: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

In[36]:= (* Bouncing balls *)

Framed@DynamicModule{contents = {}}, EventHandler

GraphicsText[Style["Click on me!", 18], {0.5, 0.8}], PointSize[0.1], Point

Dynamiccontents = MapIf#[[1, 2]] ≥ 0, {#[[1]] - #[[2]], #[[2]] + {0, 0.001}},

{#[[1, 1]], 0}, 1, -0.8 + RandomReal[{0, 0.2}] #[[2]] &, contents;

Map[First, contents], PlotRange → {{0, 1}, {0, 1}},

"MouseDown" ⧴ AppendTo[contents, {MousePosition["Graphics"], {0, 0}}]

Out[36]=

Click on me!

How much code do you think each of these requires? To ungroup (or open) a cell, double mouse click on the down arrow at the very right of the screen.

Beginner Section: A Gentle IntroductionImportant sections are marked with (!!!)

Basics

Nomenclature

The interface within which we program in Mathematica is called a notebook.

To use Mathematica:

◼ Start the Mathematica application

◼ Alternatively, double clicking any Mathematica notebook file on your computer start Mathematica and open that file

◼ A Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent notebooks you have been working on)

Beginner Session - 10-25-2014.nb 5

Page 6: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

◼ There are various other links and resources for you to explore

◼ If you un-check "Show at startup" on the bottom left, a blank Mathematica notebook would appear instead of the Welcome Screen when you start Mathematica

◼ Select “New Document” and a blank notebook will appear within which you can begin programming. A world of possibilities is now at your command

A Fancy Calculator

One of the simplest and most intuitive ways Mathematica can be used is as a (super-awesome) calculator.

The journey of a thousand miles, starts with a single step. Let’s do some addition and multiplica-tion.Evaluate these commands using Shift+Enter (or NumPad Enter if you have one)

In[37]:= 1 + 1

Out[37]= 2

In[38]:= -2 * -2

Out[38]= 4

The In[n]:= and Out[n]= are generated by Mathematica, and not input by the user. For example, if you change the input above from (-2)*(-2) into (-2)*(-25) then before you evaluate you will see that the In[n]:= expression went away and the corresponding Out[n]= expression has become gray, indicating that the input no longer corresponds to the output. If you restore the expression to (-2)*(-2) or alternatively hit Undo (Ctrl+z), the output will return to its original black form.

A notebook consists of individual cells ranging from text cells (what you are reading now) to header cells (which make up the section titles “Introducing the Language” and “Basics” above) to code cells (like the 1 + 1 and -2 * -2 shown above). Only code cells can be evaluated. When your

cursor is between two cells and you begin typing, you automatically create a new code cell. Try creating the code cell 2^3 below the -2 * -2 cell above and evaluating it.

The Rules

The rules for the Mathematica language are:

◼ Most built-in commands begin with a capital letter and are non-abbreviated, standard English words. If a command consists of several words, the first letter of each word is capitalized. The complete word is written without spaces. Ex: Solve, Integrate, PlotRange...

◼ Exception class 1: Mathematical shorthand notations (E, I, Sin, LCM, D)

◼ Exception class 2: Numerical functions involving N (which stands for numerical) such as in NSolve or NIntegrate (which numerically solve a system of equations or numerically integrate)

◼ Exception class 3: Functions involving Q (which stands for question) such as in EvenQ or IntegerQ (which test if the input is an even number or an integer)

◼ Symbols defined by the user usually begin with lowercase letters. Variable names can be arbitrarily long and can include

6 Beginner Session - 10-25-2014.nb

Page 7: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

◼ Uppercase letters

◼ Lowercase letters

◼ Numbers (although numbers cannot be used as the first character)

◼ $ (but avoid introducing symbols of the form name$ or name$number because it may interfere with Mathematica’s functionality)

◼ Addition (+), subtraction (-), multiplication (*), and division (/) obey order of operations

◼ The * for multiplication can be omitted by using a blank space instead

◼ Many Mathematica functions have options which can be specified in the form optionName -> specialOptionSetting (Ex: PlotPoints → 25 and PlotLabel → "Awesome Plot")

Explore: Ridiculously Complex Arithmetic

Note: To create code, place the cursor between two cells and start typing. (If you place the cursor in a bullet cell and press Enter, you will get another bullet cell instead of a coding cell.)

◼ Evaluate 15 48 + 19 400 + 16 25

In[39]:= 15 48 + 19 400 + 16 25

Out[39]= 1

After evaluating this cell, we see that the answer is 1

In[40]:= 15 48 + 19 400 + 16 25

Out[40]= 1

◼ What is the last digit of 2^1000

After evaluating this cell, we see that the answer is 6

In[41]:= 2^1000

Out[41]= 10 715 086 071862 673 209 484 250490 600 018 105 614 048117 055 336 074 437 503883 703 510 511 249

361 224 931983 788 156 958 581 275946 729 175 531 468 251871 452 856 923 140 435984 577 574 698

574 803 934567 774 824 230 985 421074 605 062 371 141 877954 182 153 046 474 983581 941 267 398

767 559 165543 946 077 062 914 571196 477 686 542 167 660429 831 652 624 386 837205 668 069 376

Basic Keyboard Shortcuts

Mouse wheel - Scroll up and down in the notebook

←/→: Move left/right one character↑/↓: Move up/down in the notebook

Control + ←/→: Move left/right one word in the cellControl + ↑/↓: Look up/down in the notebook, keeping the cursor stationary

Enter - New line (inside of a cell, this stays within the cell)Shift + Enter: Evaluate cellNumPad Enter: Evaluate cell

Control + c: CopyControl + v: Paste

Beginner Session - 10-25-2014.nb 7

Page 8: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

Control + z: UndoControl + y: Redo (i.e. undo an undo)

Control + ‘ (or Double Mouse Click on cell bracket): Open or close a cell group

Intermediate Section: Multiple Forms of an Expression

There are many ways to compute the square root of x. You can raise x to the 12 power; you can using

the shortcut Control+2 to create a square root symbol ( ) and then put x underneath it; you can use the Sqrt command. All of these are equivalent, so choose whichever you like. If you want to find out how to create a symbol, such as the symbol you can always look at the documentation page of its corresponding command (it will be in the Details section of the Sqrt page).

In[42]:= 4^1 2

Sqrt[4]

4

Out[42]= 2

Out[43]= 2

Out[44]= 2

(!!!) Brackets

◼ Assign values to a variable using =

In[45]:= var = 5

Out[45]= 5

In[46]:= var - 3

2 * var

Out[46]= 2

Out[47]= 10

◼ The three types of parenthesis play different roles

◼ Braces {} are used to enclose components of vectors and elements of sets (any number of elements of arbitrary type are allowed, which can be nested to any level)

◼ Ex: Create a list with the elements 1, 5, 25, 125, 625, 3125, 15625, and 78125

In[48]:= {1, 5, 25, 125, 625, 3125, 15 625, 78 125}

Out[48]= {1, 5, 25, 125, 625, 3125, 15 625, 78 125}

◼ Brackets [] are used for enclosing arguments in functions

◼ Ex: Apply the function Exp (the exponential function) of the arguments 5, 0, and x. These yield the values ⅇ5, ⅇ0 = 1, and ⅇx, respectively

8 Beginner Session - 10-25-2014.nb

Page 9: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

In[49]:= Exp[5]

Exp[0]

Exp[x]

Out[49]= ⅇ5

Out[50]= 1

Out[51]= ⅇx

◼ Parentheses () are used exclusively for grouping

◼ Ex: Normal order of operations would evaluate 2 * 3 + 4 as 2 * 3 + 4 = 10. If we instead want to evaluate 2 * 3 + 4 = 14 we must add parentheses

In[52]:= 2 * 3 + 4

2 * 3 + 4

Out[52]= 10

Out[53]= 14

◼ Double brackets with an integer [[j]] applied to a list returns the jth element in that list (where j ranges from 1 to the length of the list)

◼ Ex: Take the second element of the list {10, 20, 30, 40}

In[54]:= {10, 20, 30, 40}[[2]]

Out[54]= 20

Explore: Total

◼ The function Total sums up the elements of a list. Define list as a list containing 2, 6, 12, 20, 30 and then use Total (with hard brackets) on this list. Compare the result to 2 + 6 + 12 + 20 + 30

In[55]:= list = {2, 6, 12, 20, 30}

Out[55]= {2, 6, 12, 20, 30}

In[56]:= Total[list]

2 + 6 + 12 + 20 + 30

Out[56]= 70

Out[57]= 70

As expected, these two values are the same. Alternatively, instead of defining list we could have just used Total directly

In[58]:= Total[{2, 6, 12, 20, 30}]

Out[58]= 70

Intermediate Section: Output of Set

When you give a variable a value, you always see the output of that variable’s value. For example, define list to be a list containing 1, 2, 3, 4, and 5

In[59]:= list = {1, 2, 3, 4, 5}

Out[59]= {1, 2, 3, 4, 5}

Beginner Session - 10-25-2014.nb 9

Page 10: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

The output is the expected list containing 1, 2, 3, 4, and 5. Suppose we instead defined list as

In[60]:= list = {1 * 2, 2 * 3, 3 * 4, 4 * 5, 5 * 6}

Out[60]= {2, 6, 12, 20, 30}

The computations have been evaluated prior to assigning these values to list. In other words, the first element in list equals 2 and not 1 * 2

In[61]:= list[[1]]

Out[61]= 2

Intermediate Section: More Syntax

More useful Mathematica syntax includes:

◼ Prevent the display of (long) results by using a semicolon at the end of input: expression;

◼ Independent inputs can either be placed on separate lines or they can be separated by semicolons: inputStatement1; inputStatement2; …; inputStatementn

◼ The last expression given by Mathematica: %

◼ The next-to-last (penultimate) expression given by Mathematica: %%

◼ The ith output of Mathematica: %i or Out[i]

◼ When an expression is too long to fit on one line, the symbol \ (or ) is displayed, indicating that the expression is continued on the next line (if an expression is incomplete when the end of the line is reached, the expression is automatically considered to be continued on the next line)

◼ Comments can be written in the form, (* material to be ignored when sent to the Mathematica kernel *) (comments can be inserted anywhere in Mathematica source code)

◼ Information on the command command: ?command

◼ "Ordinary", Greek, Gothic, Script, and double-struck letters represent different letters (B≠Β≠≠ℬ≠), and symbol names made from them are considered different. But plain, bold, italic, bold-italic, and underlined versions of a letter are considered equal (B=B=B=B=B)

(!!!) Documentation Center (F1)

Your best resource for:

◼ Learning the functionality of a function (i.e. what can Mod do?)

◼ All examples can be evaluated and changed (note that when you load the reference page the next time it will be reset to its default appearance)

◼ Copy code into your notebook and adapt it to your use (the best way to first learn how to use a function)

◼ Different sections provide different details about the function

◼ The See Also section at the bottom lists related functions - this is one of the best ways to discover new functions

◼ Searching for new functions (Ex: if you want the mean of a list of quantities, search for mean)

10 Beginner Session - 10-25-2014.nb

Page 11: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

◼ Tutorials on all aspects of Mathematica (Ex: basic syntax, general conventions, introduction to strings, evaluation theory, exploring manipulate, dynamic functionality...)

Shortcuts:

◼ F1 (Windows), Fnct + F1 (Mac): Open the Documentation Center

◼ Mouse click a link: Navigate to that link

◼ Shift+Click a link: Open up a new Documentation Center at that link

◼ Shift+F1: Open a new Documentation Center main page

Explore: Factorial, Table, Mean

◼ What is the first digit of 10000 factorial (i.e. 10 000*9999*9998* · · ·*1)

We can evaluate the following and look at the first digit (2)

In[62]:= 10 000!

Out[62]= 28 462 596 809170 545 189 064 132121 198 688 901 480 514017 027 992 307 941 799942 744 113 400 037

644 437 729907 867 577 847 758 158840 621 423 175 288 300423 399 401 535 187 390524 211 613 827

161 748 198241 998 275 924 182 892597 878 981 242 531 205946 599 625 986 706 560161 572 036 032

397 926 328736 717 055 741 975 962099 479 720 346 153 698119 897 092 611 277 500484 198 845 410

475 544 642442 136 573 303 076 703628 825 803 548 967 461117 097 369 578 603 670191 071 512 730

587 281 041158 640 561 281 165 385325 968 425 825 995 584688 146 430 425 589 836649 317 059 251

717 204 276597 407 446 133 400 054194 052 462 303 436 869154 059 404 066 227 828248 371 512 038

322 178 644627 183 822 923 899 638992 827 221 879 702 459387 693 803 094 627 332292 570 555 459

690 027 875282 242 544 348 021 127559 019 169 425 429 028916 907 219 097 083 690539 873 747 452

483 372 899521 802 363 282 741 217040 268 086 769 210 451555 840 567 172 555 372015 852 132 829

034 279 989818 449 313 610 640 381489 304 499 621 599 999359 670 892 980 190 336998 484 404 665

419 236 258424 947 163 178 961 192041 233 108 268 651 071354 516 845 540 936 033009 607 210 346

944 377 982349 430 780 626 069 422302 681 885 227 592 057029 230 843 126 188 497606 560 742 586

279 448 827155 956 831 533 440 534425 446 648 416 894 580425 709 461 673 613 187605 234 982 286

326 452 921529 423 479 870 603 344290 737 158 688 499 178932 580 691 483 168 854251 956 006 172

372 636 323974 420 786 924 642 956012 306 288 720 122 652952 964 091 508 301 336630 982 733 806

353 972 901506 581 822 574 295 475894 399 765 113 865 541208 125 788 683 704 239208 764 484 761

569 001 264889 271 590 706 306 409661 628 038 784 044 485191 643 790 807 186 112370 622 133 415

415 065 991843 875 961 023 926 713276 546 986 163 657 706626 438 638 029 848 051952 769 536 195

259 240 930908 614 471 907 390 768585 755 934 786 981 720734 372 093 104 825 475628 567 777 694

081 564 074962 275 254 993 384 112809 289 637 516 990 219870 492 405 617 531 786346 939 798 024

619 737 079041 868 329 931 016 554150 742 308 393 176 878366 923 694 849 025 999607 729 684 293

977 427 536263 119 825 416 681 531891 763 234 839 190 821000 147 178 932 184 227805 135 181 734

921 901 146246 875 769 835 373 441456 013 122 615 221 391178 759 688 367 364 087207 937 002 992

038 279 198038 702 372 078 039 140312 368 997 608 152 840306 051 116 709 484 722224 870 389 199

993 442 071395 836 983 063 962 232079 115 624 044 250 808919 914 319 837 120 445598 344 047 556

759 489 212101 498 152 454 543 594285 414 390 843 564 419984 224 855 478 532 163624 030 098 442

855 331 829253 154 206 551 237 079705 816 393 460 296 247697 010 388 742 206 441536 626 733 715

428 700 789122 749 340 684 336 442889 847 100 840 641 600093 623 935 261 248 037975 293 343 928

764 398 316390 312 776 450 722 479267 851 700 826 669 598389 526 150 759 007 349215 197 592 659

192 708 873202 594 066 382 118 801988 854 748 266 048 342256 457 705 743 973 122259 700 671 936

061 763 513579 529 821 794 290 797705 327 283 267 501 488024 443 528 681 645 026165 662 837 546

519 006 171873 442 260 438 919 298506 071 515 390 031 106684 727 360 135 816 706437 861 756 757

439 184 376479 658 136 100 599 638689 552 334 648 781 746143 243 573 224 864 326798 481 981 458

432 703 035895 508 420 534 788 493364 582 482 592 033 288089 025 782 388 233 265770 205 248 970

937 047 210214 248 413 342 465 268206 806 732 314 214 483854 074 182 139 621 846870 108 359 582

946 965 235632 764 870 475 718 351616 879 235 068 366 271743 711 915 723 361 143070 121 120 767

Beginner Session - 10-25-2014.nb 11

Page 12: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

608 697 851559 721 846 485 985 918643 641 716 850 899 625516 820 910 793 570 231118 518 174 775

010 804 622585 521 314 764 897 490660 752 877 082 897 667514 951 009 682 329 689732 000 622 392

888 056 658036 140 311 285 465 929084 078 033 974 900 664953 205 873 164 948 093883 816 198 658

850 827 382468 034 897 864 757 116679 890 423 568 018 303504 133 875 731 972 630897 909 435 710

687 797 301633 918 087 868 474 943633 533 893 373 586 906405 848 417 828 065 196275 826 434 429

258 058 422212 947 649 402 948 622670 761 832 988 229 004072 390 403 733 168 207417 413 251 656

688 443 079339 447 019 208 905 620788 387 585 342 512 820957 359 307 018 197 708340 163 817 638

278 562 539516 825 426 644 614 941044 711 579 533 262 372815 468 794 080 423 718587 423 026 200

264 221 822694 188 626 212 107 297776 657 401 018 376 182280 136 857 586 442 185863 011 539 843

712 299 107010 094 061 929 413 223202 773 193 959 467 006713 695 377 097 897 778118 288 242 442

920 864 816134 179 562 017 471 831609 687 661 043 140 497958 198 236 445 807 368209 404 022 211

181 530 051433 387 076 607 063 149616 107 771 117 448 059552 764 348 333 385 744040 212 757 031

851 527 298377 435 921 878 558 552795 591 028 664 457 917362 007 221 858 143 309977 294 778 923

720 717 942857 756 271 300 923 982397 921 957 581 197 264742 642 878 266 682 353915 687 857 271

620 146 192244 266 266 708 400 765665 625 807 109 474 398740 110 772 811 669 918806 268 726 626

565 583 345665 007 890 309 050 656074 633 078 027 158 530817 691 223 772 813 510584 527 326 591

626 219 647620 571 434 880 215 630815 259 005 343 721 141000 303 039 242 866 457207 328 473 481

712 034 168186 328 968 865 048 287367 933 398 443 971 236735 084 527 340 196 309427 697 652 684

170 174 990756 947 982 757 825 835229 994 315 633 322 107439 131 550 124 459 005324 702 680 312

912 392 297979 030 417 587 823 398622 373 535 054 642 646913 502 503 951 009 239286 585 108 682

088 070 662734 733 200 354 995 720397 086 488 066 040 929854 607 006 339 409 885836 349 865 466

136 727 880748 764 700 702 458 790118 046 518 296 111 277090 609 016 152 022 111461 543 158 317

669 957 060974 618 085 359 390 400067 892 878 548 827 850938 637 353 703 904 049412 684 618 991

272 871 562655 001 270 833 039 950257 879 931 705 431 882752 659 225 814 948 950746 639 976 007

316 927 310831 735 883 056 612 614782 997 663 188 070 063044 632 429 112 260 691931 278 881 566

221 591 523270 457 695 867 512 821990 938 942 686 601 963904 489 718 918 597 472925 310 322 480

210 543 841044 325 828 472 830 584297 804 162 405 108 110326 914 001 900 568 784396 341 502 696

521 048 920272 140 232 160 234 898588 827 371 428 695 339681 755 106 287 470 907473 718 188 014

223 487 248498 558 198 439 094 651708 364 368 994 306 189650 243 288 353 279 667190 184 527 620

551 085 707626 204 244 509 623 323204 744 707 831 190 434499 351 442 625 501 701771 017 379 551

124 746 159471 731 862 701 565 571266 295 855 125 077 711738 338 208 419 705 893367 323 724 453

280 456 537178 514 960 308 802 580284 067 847 809 414 641838 659 226 652 806 867978 843 250 660

537 943 046250 287 105 104 929 347267 471 267 499 892 634627 358 167 146 935 060495 110 340 755

404 658 170393 481 046 758 485 625967 767 959 768 299 409334 026 387 269 378 365320 912 287 718

077 451 152622 642 548 771 835 461108 886 360 843 272 806227 776 643 097 283 879056 728 618 036

048 633 464893 371 439 415 250 259459 652 501 520 959 536157 977 135 595 794 965729 775 650 902

694 428 088479 761 276 664 847 003619 648 906 043 761 934694 270 444 070 215 317943 583 831 051

404 915 462608 728 486 678 750 541674 146 731 648 999 356381 312 866 931 427 616863 537 305 634

586 626 957894 568 275 065 810 235950 814 888 778 955 073939 365 341 937 365 700848 318 504 475

682 215 444067 599 203 138 077 073539 978 036 339 267 334549 549 296 668 759 922530 893 898 086

430 606 532961 793 164 029 612 492673 080 638 031 873 912596 151 131 890 359 351266 480 818 568

366 770 286537 742 390 746 582 390910 955 517 179 770 580797 789 289 752 490 230737 801 753 142

680 363 914244 720 257 728 891 784950 078 117 889 336 629750 436 804 214 668 197824 272 980 697

579 391 742229 456 683 185 815 676816 288 797 870 624 531246 651 727 622 758 295493 421 483 658

868 919 299587 402 095 696 000 243560 305 289 829 866 386892 076 992 834 030 549710 266 514 322

306 125 231915 131 843 876 903 823706 205 399 206 933 943716 880 466 429 711 476743 564 486 375

026 847 698148 853 105 354 063 328845 062 012 173 302 630676 481 322 931 561 043551 941 761 050

712 449 024873 277 273 112 091 945865 137 493 190 965 162497 691 657 553 812 198566 432 207 978

666 300 398938 660 238 607 357 858114 394 715 872 800 893374 165 033 792 965 832618 436 073 133

327 526 023605 115 524 227 228 447251 463 863 269 369 763762 510 196 714 380 125691 227 784 428

426 999 440829 152 215 904 694 437282 498 658 085 205 186576 292 992 775 508 833128 672 638 418

713 277 780874 446 643 875 352 644733 562 441 139 447 628780 974 650 683 952 982108 174 967 958

836 452 273344 694 873 793 471 790710 064 978 236 466 016680 572 034 297 929 207446 822 322 848

665 839 522211 446 859 572 858 403863 377 278 030 227 591530 497 865 873 919 513650 246 274 195

899 088 374387 331 594 287 372 029770 620 207 120 213 038572 175 933 211 162 413330 422 773 742

12 Beginner Session - 10-25-2014.nb

Page 13: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

416 353 553587 977 065 309 647 685886 077 301 432 778 290328 894 795 818 404 378858 567 772 932

094 476 778669 357 537 460 048 142376 741 194 182 671 636870 481 056 911 156 215614 357 516 290

527 351 224350 080 604 653 668 917458 196 549 482 608 612260 750 293 062 761 478813 268 955 280

736 149 022525 819 682 815 051 033318 132 129 659 664 958159 030 421 238 775 645990 973 296 728

066 683 849166 257 949 747 922 905361 845 563 741 034 791430 771 561 168 650 484292 490 281 102

992 529 678735 298 767 829 269 040788 778 480 262 479 222750 735 948 405 817 439086 251 877 946

890 045 942060 168 605 142 772 244486 272 469 911 146 200149 880 662 723 538 837809 380 628 544

384 763 053235 070 132 028 029 488392 008 132 135 446 450056 134 987 017 834 271106 158 177 289

819 290 656498 688 081 045 562 233703 067 254 251 277 277330 283 498 433 595 772575 956 224 703

707 793 387146 593 033 088 629 699440 318 332 665 797 514676 502 717 346 298 883777 397 848 218

700 718 026741 265 997 158 728 035440 478 432 478 674 907127 921 672 898 523 588486 943 546 692

255 101 337606 377 915 164 597 254257 116 968 477 339 951158 998 349 081 888 281263 984 400 505

546 210 066988 792 614 558 214 565319 696 909 827 253 934515 760 408 613 476 258778 165 867 294

410 775 358824 162 315 779 082 538054 746 933 540 582 469717 674 324 523 451 498483 027 170 396

543 887 737637 358 191 736 582 454273 347 490 424 262 946011 299 881 916 563 713847 111 849 156

915 054 768140 411 749 801 454 265712 394 204 425 441 028075 806 001 388 198 650613 759 288 539

038 922 644322 947 990 286 482 840099 598 675 963 580 999112 695 367 601 527 173086 852 756 572

147 583 507122 298 296 529 564 917835 071 750 835 741 362282 545 055 620 270 969417 476 799 259

229 774 888627 411 314 587 676 147531 456 895 328 093 117052 696 486 410 187 407673 296 986 649

236 437 382565 475 022 816 471 926815 559 883 196 629 848307 776 666 840 622 314315 884 384 910

519 058 281816 740 764 463 033 300119 710 293 036 455 866594 651 869 074 475 250837 841 987 622

990 415 911793 682 799 760 654 186088 721 626 654 886 492344 391 030 923 256 910633 775 969 739

051 781 122764 668 486 791 736 049404 393 703 339 351 900609 387 268 397 299 246478 483 727 274

770 977 466693 599 784 857 120 156789 000 241 947 269 220974 984 127 323 147 401549 980 920 381

459 821 416481 176 357 147 801 554231 599 667 838 534 854486 406 936 410 556 913531 335 231 184

053 581 348940 938 191 821 898 694825 383 960 989 942 822027 599 339 635 206 217705 343 572 073

396 250 574216 769 465 101 608 495601 439 303 244 304 271576 099 527 308 684 609204 422 226 103

154 229 984444 802 110 098 161 333824 827 375 218 998 738205 315 164 927 134 498105 950 159 974

800 571 591912 202 154 487 748 750103 473 246 190 633 941303 030 892 399 411 985006 225 902 184

164 409 988173 214 324 422 108 554248 620 896 250 260 604398 180 189 026 317 781146 617 454 999

771 440 665232 863 846 363 847 001655 618 153 861 098 188111 181 734 191 305 505024 860 345 856

755 585 637511 729 774 299 329 074944 236 579 668 332 700918 367 338 977 347 901759 248 885 660

379 952 771540 569 083 017 311 723894 140 326 159 612 292912 225 191 095 948 743805 673 381 278

538 616 491842 786 938 417 556 898047 100 859 868 372 033615 175 158 097 022 566275 200 160 956

192 229 925401 759 878 522 038 545913 771 783 976 389 811198 485 803 291 048 751666 921 195 104

514 896 677761 598 249 468 727 420663 437 593 207 852 618922 687 285 527 671 324883 267 794 152

912 839 165407 968 344 190 239 094803 676 688 707 838 011367 042 753 971 396 201424 784 935 196

735 301 444404 037 823 526 674 437556 740 883 025 225 745273 806 209 980 451 233188 102 729 012

042 997 989005 423 126 217 968 135237 758 041 162 511 459175 993 279 134 176 507292 826 762 236

897 291 960528 289 675 223 521 425234 217 247 841 869 317397 460 411 877 634 604625 637 135 309

801 590 617736 758 715 336 803 958559 054 827 361 876 112151 384 673 432 884 325090 045 645 358

186 681 905108 731 791 346 215 730339 540 580 987 172 013844 377 099 279 532 797675 531 099 381

365 840 403556 795 731 894 141 976511 436 325 526 270 639743 146 526 348 120 032720 096 755 667

701 926 242585 057 770 617 893 798231 096 986 788 448 546659 527 327 061 670 308918 277 206 432

551 919 393673 591 346 037 757 083193 180 845 929 565 158875 244 597 601 729 455720 505 595 085

929 175 506510 115 665 075 521 635142 318 153 548 176 884196 032 085 050 871 496270 494 017 684

183 980 582594 038 182 593 986 461260 275 954 247 433 376226 256 287 153 916 069025 098 985 070

798 660 621732 200 163 593 938 611475 394 561 406 635 675718 526 617 031 471 453516 753 007 499

213 865 207768 523 824 884 600 623735 896 608 054 951 652406 480 547 295 869 918694 358 811 197

833 680 141488 078 321 213 457 152360 124 065 922 208 508912 956 907 835 370 576734 671 667 863

780 908 811283 450 395 784 812 212101 117 250 718 383 359083 886 187 574 661 201317 298 217 131

072 944 737656 265 172 310 694 884425 498 369 514 147 383892 477 742 320 940 207831 200 807 235

326 288 053906 266 018 186 050 424938 788 677 872 495 503255 424 284 226 596 271050 692 646 071

767 467 502337 805 671 893 450 110737 377 034 119 346 113374 033 865 364 675 136733 661 394 731

550 211 457104 671 161 445 253 324850 197 901 083 431 641989 998 414 045 044 901130 163 759 520

Beginner Session - 10-25-2014.nb 13

Page 14: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

675 715 567509 485 243 580 269 104077 637 210 998 671 624254 795 385 312 852 889930 956 570 729

218 673 523216 666 097 874 989 635362 610 529 821 472 569482 799 996 220 825 775840 988 458 484

250 391 189447 608 729 685 184 983976 367 918 242 266 571167 166 580 157 914 500811 657 192 200

233 759 765317 495 922 397 884 982814 705 506 190 689 275625 210 462 185 661 305800 255 607 974

609 726 715033 327 032 310 025 274640 428 755 556 546 883765 838 802 543 227 403507 431 684 278

620 637 697054 791 726 484 378 174446 361 520 570 933 228587 284 315 690 756 255569 305 558 818

822 603 590006 739 339 952 504 379887 470 935 079 276 181116 276 309 771 257 983975 996 526 612

120 317 495882 059 435 754 883 862282 508 401 408 885 720583 992 400 971 219 212548 074 097 752

974 278 775912 566 026 443 482 713647 231 849 125 180 866278 708 626 116 699 989634 812 405 803

684 794 587364 820 124 653 663 228889 011 636 572 270 887757 736 152 003 450 102268 890 189 101

673 572 058661 410 011 723 664 762657 835 396 364 297 819011 647 056 170 279 631922 332 294 228

739 309 233330 748 258 937 626 198997 596 530 084 135 383241 125 899 639 629 445129 082 802 023

225 498 936627 506 499 530 838 925632 246 794 695 960 669046 906 686 292 645 006219 740 121 782

899 872 979704 859 021 775 060 092893 328 957 272 392 019589 994 471 945 147 360850 770 400 725

717 439 318148 461 909 406 269 545285 030 526 341 000 565022 226 152 309 364 882887 122 046 454

267 700 577148 994 335 147 162 504252 365 173 710 266 068647 253 458 120 186 683273 953 682 547

456 536 553597 546 685 788 700 056988 360 286 686 450 740256 993 087 483 441 094086 086 303 707

908 295 240576 731 684 941 855 810482 475 304 758 923 392801 571 302 824 106 234999 945 932 390

521 409 856559 565 661 346 003 396150 515 164 758 852 742214 732 517 999 548 977992 849 522 746

029 855 666700 811 871 200 856 155016 457 400 484 170 210303 038 996 339 253 337466 556 817 824

410 737 409336 919 294 104 632 307731 994 759 826 307 383499 600 770 372 410 446285 414 648 704

116 273 895649 834 555 162 165 685114 551 383 822 047 005483 996 671 706 246 467566 101 291 382

048 909 121117 229 386 244 253 158913 066 987 462 045 587244 806 052 829 378 148302 622 164 542

280 421 757760 762 365 459 828 223070 815 503 469 404 938317 755 053 305 094 698999 476 119 419

231 280 721807 216 964 378 433 313606 760 676 965 187 138394 338 772 485 493 689061 845 700 572

043 696 666465 080 734 495 814 495966 306 246 698 679 832872 586 300 064 215 220210 171 813 917

325 275 173672 262 621 454 945 468506 006 334 692 713 838311 715 849 753 092 643252 486 960 220

059 099 802663 765 386 225 463 265168 414 963 306 369 548086 551 101 256 757 717890 616 694 758

344 043 486218 485 369 591 602 172030 456 183 497 524 162039 926 441 331 651 884768 606 830 642

004 858 557924 473 340 290 142 588876 403 712 518 642 229016 333 691 585 063 273727 199 596 362

912 783 344786 218 887 871 009 533753 551 054 688 980 236378 263 714 926 913 289564 339 440 899

470 121 452134 572 117 715 657 591451 734 895 195 016 800621 353 927 175 419 843876 163 543 479

806 920 886666 227 099 512 371 706241 924 914 282 576 453125 769 939 735 341 673046 864 585 181

979 668 232015 693 792 684 926 999983 992 413 571 941 496882 273 704 022 820 805171 808 003 400

480 615 261792 013 978 945 186 295290 558 440 703 738 300533 552 421 153 903 385185 829 366 779

190 610 116306 233 673 144 419 202893 857 201 855 569 596330 833 615 450 290 424822 309 297 087

124 788 002017 383 072 060 482 680156 675 397 593 789 931793 515 799 958 929 562156 307 338 416

294 599 900276 730 832 827 716 595064 217 966 523 190 439250 543 226 753 731 811755 315 476 780

739 470 338931 185 107 297 724 318378 972 674 957 455 778183 345 495 942 317 353558 291 046 967

315 391 275975 687 281 861 691 161083 156 337 232 639 968881 490 543 943 261 197182 274 996 791

176 628 553401 860 198 315 809 629981 791 107 208 804 992292 016 062 059 067 271273 599 461 871

634 945 774995 805 337 947 187 105456 452 579 396 024 210259 136 415 528 398 395201 773 012 712

514 892 051061 708 228 008 339 985665 786 646 920 737 114269 682 301 770 416 324829 479 409 558

694 699 089379 165 191 006 305 185352 102 345 189 798 127619 143 061 864 362 703081 977 124 992

751 056 732909 481 202 057 747 100687 703 379 708 934 229207 183 903 744 167 503493 818 836 342

229 284 946790 660 285 674 293 251642 569 044 363 473 087656 797 056 595 677 285291 081 242 733

154 406 580199 802 711 579 126 254172 797 452 862 574 865921 933 293 805 915 239524 735 518 887

119 860 391319 654 287 576 290 190503 964 083 560 246 277534 314 409 155 642 181729 459 941 596

061 979 622633 242 715 863 425 977947 348 682 074 802 021538 734 729 707 999 753332 987 785 531

053 820 162169 791 880 380 753 006334 350 766 147 737 135939 362 651 905 222 242528 141 084 747

045 295 688647 757 913 502 160 922040 348 449 149 950 778743 107 189 655 725 492651 282 693 489

515 795 075486 172 341 394 610 365176 616 750 329 948 642244 039 659 511 882 264981 315 925 080

185 126 386635 308 622 223 491 094629 059 317 829 408 195640 484 702 456 538 305432 056 506 924

422 671 863255 307 640 761 872 086780 391 711 356 363 501269 525 091 291 020 496042 823 232 628

996 502 758951 052 844 368 177 415730 941 874 894 428 065427 561 430 975 828 127698 124 936 993

14 Beginner Session - 10-25-2014.nb

Page 15: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

313 028 946670 560 414 084 308 942231 140 912 722 238 148470 364 341 019 630 413630 736 771 060

038 159 590829 746 410 114 421 358321 042 574 358 350 220737 173 219 745 089 035573 187 350 445

827 238 770728 271 406 162 997 919629 357 224 104 477 155051 652 535 867 544 109395 079 218 369

015 261 138440 382 680 054 150 924346 511 711 436 477 899444 553 993 653 667 727589 565 713 987

505 542 990824 585 609 510 036 934663 100 673 714 708 029927 656 933 435 500 927189 854 050 109

917 474 979991 554 392 031 908 961967 615 444 686 048 175400 695 689 471 463 928245 383 807 010

444 181 045506 171 305 160 584 355817 521 032 338 465 829201 071 030 061 124 283407 458 607 006

060 194 830551 364 867 021 020 364708 470 807 422 704 371893 706 965 688 795 617928 713 045 224

516 842 027402 021 966 415 605 280335 061 293 558 739 079393 524 404 092 584 248380 607 177 444

609 964 035221 891 022 961 909 032569 042 381 374 492 494906 892 314 330 884 224399 631 396 391

545 854 065286 326 468 807 581 148748 371 408 284 176 455226 386 313 520 264 894016 262 494 802

388 568 231599 102 952 620 337 126449 279 901 938 211 134518 446 387 544 516 391239 377 974 190

576 649 911764 237 637 722 282 802318 465 738 050 121 277809 680 315 691 477 264910 257 503 508

758 792 248110 223 544 524 410 872448 565 700 755 187 132146 592 093 548 504 552829 170 749 596

775 404 450779 494 836 371 756 062326 925 757 412 813 110241 910 373 338 080 434325 310 884 694

831 555 729402 265 394 972 913 817581 338 619 457 057 799561 808 755 951 413 644907 613 109 617

155 928 376585 840 036 489 374 076822 257 523 935 988 731081 689 667 688 287 403837 192 827 690

431 514 106997 678 303 819 085 690713 091 931 340 846 019511 147 482 766 350 724676 534 922 040

058 626 677632 935 516 631 939 622498 979 912 708 004 465982 264 899 125 226 813124 300 528 104

995 058 595676 527 123 591 494 442612 554 437 618 645 029202 881 358 582 871 789577 224 116 380

815 161 831603 129 728 796 987 480139 828 621 645 629 196153 096 358 337 313 619724 773 332 353

025 466 571196 902 611 237 380 629030 242 904 275 794 549030 022 660 847 446 513161 741 691 916

851 746 464945 459 696 005 330 885252 792 083 472 495 235473 110 674 109 099 223541 055 506 299

687 642 153951 249 355 986 311 346661 725 116 890 785 633328 935 569 150 449 485189 113 488 301

876 365 100638 502 565 916 433 021928 565 596 263 914 382895 068 324 838 727 165616 560 111 531

517 055 222955 765 944 972 454 788815 532 316 417 453 267167 978 861 141 165 355597 588 331 979

638 070 962998 880 767 303 616 940317 736 448 140 427 867784 251 232 449 974 693421 348 217 179

595 190 698204 602 997 172 001 174857 303 889 719 205 597414 742 453 011 135 869766 256 607 770

970 225 633261 701 108 463 784 795555 258 504 578 058 879440 756 064 974 127 974530 918 418 405

207 558 526462 208 821 483 646 754652 237 609 210 787 539190 454 684 852 349 759986 044 943 322

828 073 120679 922 402 477 507 514105 890 774 627 334 319091 255 451 352 225 329275 913 842 047

384 603 056163 154 236 552 935 312278 389 759 446 515 787337 343 463 172 280 001031 380 425 481

404 022 090580 405 056 003 860 937403 435 068 863 081 434683 848 900 708 938 565050 027 569 059

678 069 404698 435 184 535 134 141031 615 133 683 043 714786 642 925 389 717 165978 629 010 728

400 758 939700 388 317 742 648 163725 113 277 369 926 827709 465 342 583 596 111881 955 092 462

062 153 978121 197 244 762 623 771534 452 048 069 819 082524 943 963 962 251 113831 177 428 978

535 825 590832 490 480 497 516 047104 257 569 753 442 551515 779 815 600 370 847230 603 484 753

977 513 688390 404 316 017 486 248871 339 311 818 523 029425 425 676 202 485 688393 970 836 748

788 453 789172 574 145 155 917 919035 398 535 077 200 900594 979 352 939 459 631213 445 503 368

260 690 059828 717 723 533 375 221941 915 547 303 742 062343 262 892 968 397 015058 892 191 112

049 249 864792 053 410 872 349 115430 987 182 160 055 762209 075 732 304 626 106597 744 947 658

346 313 025598 636 315 029 959 672352 476 943 975 462 530206 788 193 304 372 284800 209 305 354

155 640 664838 569 378 144 603 138697 563 459 200 233 462606 995 955 513 484 754147 891 180 830

329 816 421587 452 922 952 678 937925 647 752 029 052 675349 356 673 744 293 182673 374 571 642

465 407 748267 901 046 778 759 085408 130 531 447 176 455869 894 169 668 940 436489 952 465 247

443 988 349583 871 206 296 485 413357 553 813 419 500 498743 813 369 062 703 973874 586 604 296

871 595 820715 766 599 826 607 317005 624 465 541 763 024501 349 159 567 288 942619 746 144 496

908 671 655859 782 729 228 702 723774 835 097 362 901 019130 417 812 735 773 037781 804 081 589

136 005 207315 806 941 034 305 003184 349 342 360 269 244733 060 013 861 119 781774 472 669 608

928 321 052543 116 496 033 420 102032 603 863 672 532 889648 333 405 862 204 843616 575 362 001

468 405 476649 666 473 566 979 572953 394 809 138 263 703324 220 930 839 366 954980 688 240 491

622 063 147911 494 642 042 500 022450 413 425 558 561 937442 905 257 252 436 320054 487 441 524

307 305 215070 491 020 434 076 572476 865 095 751 174 125413 729 531 644 521 765577 235 348 601

821 566 833352 520 532 830 000 108344 008 762 266 843 817023 235 605 645 158 256954 177 359 197

813 649 975559 601 912 567 744 942717 986 360 045 847 405209 290 089 397 315 276024 304 951 653

Beginner Session - 10-25-2014.nb 15

Page 16: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

864 431 388147 876 977 541 478 757432 610 159 879 709 758855 625 806 766 197 973098 472 460 769

484 821 127948 427 976 536 607 055051 639 104 415 022 554420 329 721 292 033 009353 356 687 294

595 912 327965 886 376 486 894 188433 640 548 494 009 574965 791 657 687 213 927330 153 555 097

865 114 767947 399 690 623 184 878377 515 462 613 823 651665 956 337 209 345 708208 301 840 482

797 005 728071 432 925 727 577 436229 587 047 361 641 609731 817 241 594 204 270366 066 404 089

740 245 521530 725 227 388 637 241859 646 455 223 673 260411 164 598 464 020 010216 920 823 315

155 388 821071 527 191 267 876 531795 071 908 204 525 100447 821 291 318 544 054814 494 151 867

114 207 103693 891 129 125 012 750853 466 337 717 749 376016 543 454 696 390 042711 129 829 255

096 830 420665 725 364 279 472 200020 835 313 883 708 781649 957 189 717 629 338794 854 271 276

882 652 003766 325 924 561 614 868744 897 471 519 366 219275 665 852 462 114 457407 010 675 380

427 564 184440 834 805 203 838 265052 601 698 584 060 084788 422 421 887 856 927897 751 810 442

805 474 427229 455 167 420 335 686460 609 977 973 124 950433 321 425 205 053 675790 499 520 783

597 650 415379 001 132 579 536 040655 172 654 879 022 173595 444 151 139 429 231648 950 663 177

813 039 057462 082 449 171 921 311864 129 633 704 661 406456 900 178 942 356 738775 523 130 952

785 912 774533 241 855 442 484 484493 664 210 731 348 819180 640 189 222 317 302156 645 813 473

186 449 997905 781 662 091 469 870718 039 388 885 781 280740 226 363 602 294 114354 869 871 402

143 572 055947 730 892 808 653 678920 201 935 102 605 361567 924 483 276 749 476117 858 316 071

865 710 310842 200 560 259 545 115191 391 309 119 544 447844 361 032 741 876 102338 843 391 687

589 233 423790 859 841 968 266 525610 628 751 237 572 318491 474 951 945 985 728897 934 981 791

761 822 652480 408 237 128 109 790772 638 864 286 067 917082 288 575 852 703 470839 714 561 619

926 247 844794 692 794 996 845 945632 382 702 297 364 173503 430 783 194 115 698247 820 013 290

851 202 878474 805 860 188 960 045901 745 974 055 630 732714 487 679 085 288 867978 809 970 695

240 681 006625 611 440 014 983 413580 889 737 246 844 064948 857 074 167 687 916413 224 205 373

654 067 330186 392 497 910 915 474785 959 163 865 597 507090 581 175 924 899 502214 799 250 945

635 582 514315 814 464 060 134 283490 422 798 357 939 659258 985 200 763 845 646681 640 732 681

928 346 007767 285 876 284 900 068874 564 639 274 964 415904 034 033 672 337 814491 597 032 941

787 294 155061 054 129 515 400 159393 851 663 929 325 677429 557 549 480 046 658273 579 653 990

940 233 543644 649 376 827 272 541873 627 547 532 976 808190 325 336 141 086 433084 237 771 738

995 221 536763 095 302 045 902 438694 632 702 895 293 994483 013 577 589 081 214884 558 493 819

874 505 920914 067 209 522 469 096263 076 941 753 340 983698 859 363 700 314 973728 977 996 360

018 626 500174 929 290 087 931 189997 822 963 712 306 642297 996 163 582 572 600112 288 983 647

651 418 045975 770 042 120 833 949364 659 647 336 464 289044 499 325 396 227 091907 373 705 772

051 322 815957 863 227 591 912 786054 297 862 953 188 615559 804 728 160 710 864132 803 585 400

160 055 575686 855 791 785 977 899197 902 656 592 621 283007 225 351 401 525 973569 300 729 015

392 211 116868 504 740 402 172 174442 051 738 000 251 361000 494 534 119 324 331668 344 243 125

963 098 812396 962 202 358 858 395587 831 685 194 833 126653 577 353 244 379 935683 215 269 177

042 249 034574 534 858 913 812 582681 366 908 929 476 809052 635 560 638 119 661306 063 936 938

411 817 713545 929 884 317 232 912236 262 458 868 394 202889 981 693 561 169 865429 884 776 513

118 227 662526 739 978 808 816 010470 651 542 335 015 671353 744 817 086 234 314662 531 190 291

040 152 262927 104 099 285 072 418843 329 007 277 794 754111 637 552 176 563 589316 326 636 049

381 218 401837 512 818 884 771 168975 479 483 767 664 084842 753 623 074 019 542183 217 985 496

260 666 590347 925 816 342 392 670947 839 907 062 923 166535 037 285 019 751 324813 803 837 070

894 638 925470 887 039 085 723 581006 130 628 646 664 710006 104 352 115 778 926613 432 214 655

311 411 882596 942 926 284 522 109026 688 414 975 763 341554 921 135 581 254 616558 078 273 470

115 814 006008 345 762 133 130 389987 843 270 653 719 956709 570 847 385 786 092649 188 858 378

739 239 165554 263 577 301 292 243641 604 062 551 736 892335 636 568 854 365 851646 207 821 875

741 724 364525 814 143 487 632 761341 752 707 376 754 922276 287 782 264 765 154315 341 585 713

773 522 730335 403 376 364 204 258034 257 264 749 686 217823 666 951 353 410 677378 421 131 371

131 987 373222 891 805 275 062 812277 716 412 494 412 401207 125 954 319 991 746574 745 892 582

613 712 825555 535 080 404 143 944557 295 994 554 635 608487 251 339 462 936 358940 832 098 964

801 619 583130 429 720 964 794 128539 388 996 265 368 928263 807 677 168 759 588502 216 464 582

430 940 165009 688 797 366 157 733560 316 836 710 386 895228 270 941 509 545 222744 002 735 499

253 670 214715 994 056 544 813 842186 380 128 799 900 820933 576 320 736 369 405991 424 263 718

294 000 613741 900 579 513 096 298545 330 748 197 802 568301 089 672 873 802 234820 488 862 973

130 369 689882 640 657 904 781 562389 778 485 365 025 691064 231 795 736 025 330908 763 271 784

16 Beginner Session - 10-25-2014.nb

Page 17: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

911 189 748432 246 868 086 340 383964 176 127 605 788 646574 472 284 824 932 687443 062 551 220

506 955 168464 669 477 183 681 911432 873 544 815 836 350548 146 411 099 960 143390 595 799 766

290 646 881295 025 039 150 923 633011 076 070 632 863 317393 378 149 693 380 247580 035 052 789

782 755 750928 604 039 420 506 342939 327 064 636 161 031822 879 248 152 679 306862 749 237 275

631 852 225654 266 008 556 849 497720 285 909 150 930 495425 967 473 648 331 437236 349 555 448

901 598 668408 362 176 913 559 656039 519 670 425 368 863482 369 587 129 462 524759 031 776 813

184 977 588276 576 740 482 558 136502 103 649 585 505 703259 219 957 675 334 264223 783 723 586

058 509 403583 977 103 476 670 644788 640 831 109 650 302565 215 607 464 019 652716 999 732 373

465 237 173456 595 514 559 493 098166 644 006 211 599 349133 180 135 150 528 651842 178 828 026

343 325 934755 850 761 168 697 709125 580 056 185 683 710540 856 081 249 519 403148 064 618 719

402 577 663285 267 019 698 387 567561 524 696 759 028 106864 896 869 293 315 954352 097 687 527

137 201 616160 931 174 250 199 709289 684 940 034 696 242325 688 410 665 113 304377 412 256 176

258 658 941236 728 171 145 526 423894 512 631 717 834 790276 921 171 452 887 352955 019 336 759

218 908 006048 633 737 786 728 180610 254 782 570 436 788449 503 518 925 787 499836 694 785 908

612 975 543084 122 677 060 954 347612 133 717 433 156 783790 162 012 337 237 023338 316 414 706

428 592 185977 610 158 232 721 997915 062 871 868 186 750981 665 537 745 013 020880 333 904 353

639 770 263363 809 098 526 494 532628 146 558 065 546 504823 486 429 495 390 613257 400 496 912

888 340 518222 933 644 476 683 855037 967 975 809 619 983575 807 027 759 535 968788 226 194 659

612 223 044549 275 600 274 955 168583 542 582 295 336 042834 426 318 478 068 825395 450 746 691

877 897 765406 038 432 512 843 812811 316 856 204 608 617289 408 229 658 626 174420 766 920 297

427 930 088129 519 854 678 713 548623 236 610 413 216 581279 267 151 545 961 594352 593 456 757

445 992 307889 205 519 540 082 316409 719 591 250 025 455237 503 106 735 639 748835 542 480 449

681 383 030671 851 931 491 335 789202 123 605 308 199 952020 584 503 423 499 932150 962 634 977

812 456 658304 680 581 824 563 524814 625 849 331 926 195406 884 818 446 445 248429 486 063 016

169 476 663242 625 231 476 322 371109 695 369 483 824 482316 410 396 224 507 675405 614 287 468

267 835 723704 895 606 990 652 792688 455 844 512 046 654853 378 534 026 646 645042 339 638 488

257 719 874953 611 300 494 215 593735 545 211 926 186 721478 265 416 885 604 094928 290 056 616

883 807 637656 690 510 740 892 510549 165 222 968 878 676968 631 652 514 917 701499 900 066 637

344 546 120262 780 701 925 698 706225 540 928 945 194 718778 004 306 130 021 828287 425 867 048

748 480 826948 573 444 778 244 078734 102 710 824 870 269523 830 804 910 960 482013 901 294 024

631 244 800159 336 670 212 658 317677 879 752 965 963 472576 894 326 540 435 889267 293 950 687

860 830 626266 263 287 392 087 327302 547 910 099 932 113388 977 807 814 336 728791 448 768 373

686 467 748528 777 737 403 547 472871 644 217 767 820 712964 506 270 880 978 637928 144 071 192

505 141 148004 907 055 608 097 229299 792 441 471 062 852247 029 870 699 869 227676 341 773 513

258 602 908903 875 707 454 368 077876 422 385 333 700 692089 616 351 009 233 587303 986 543 906

071 880 952557 553 380 364 725 895007 306 772 122 528 078179 471 056 481 171 378557 451 057 691

044 322 925429 024 149 433 588 396093 679 321 361 696 954251 299 731 031 032 804436 954 501 929

843 820 842383 121 265 825 740 594509 426 942 777 307 124802 176 915 781 835 720087 170 538 773

256 017 987133 005 505 911 377 823841 791 640 280 841 409623 820 847 637 393 013930 778 428 554

545 222 367559 824 666 250 608 754284 876 104 145 661 362227 642 405 914 304 455580 856 318 180

935 230 407793 891 614 902 116 292400 515 074 914 068 443203 230 365 609 954 878620 999 194 306

564 455 332547 135 557 365 318 516011 700 321 550 690 787716 752 062 881 527 885897 149 410 320

986 984 083048 966 524 351 030 502444 679 931 779 147 659103 428 949 129 054 120361 601 695 671

222 140 806369 405 940 304 552 186212 879 933 092 856 231022 418 446 365 289 097444 640 151 986

623 183 881962 444 822 590 783 585914 043 686 193 019 041458 962 693 878 907 034982 169 868 696

934 448 086213 990 534 591 792 826654 304 798 207 219 634134 755 646 525 483 143771 156 678 459

077 797 196510 772 468 000 293 581546 267 646 310 224 279007 313 631 352 522 067062 951 125 935

874 473 134186 492 497 282 784 796644 585 448 962 932 905262 058 065 248 588 707020 879 389 134

476 083 344653 170 939 242 408 249328 008 915 731 319 541348 311 820 927 752 486880 548 733 943

315 867 562666 122 179 355 051 190609 992 911 379 445 634995 627 391 898 459 029021 713 155 706

096 267 881673 302 940 198 464 237390 445 098 028 030 948975 981 259 252 055 850973 537 436 556

825 780 313681 902 007 151 675 693827 281 818 824 587 541710 721 180 806 556 448039 122 504 537

089 422 695358 382 192 535 075 692834 095 639 859 265 599740 391 316 709 290 043996 275 976 830

375 217 503360 879 028 295 673 068862 263 077 729 733 533853 682 668 734 519 035709 709 687 322

323 738 300494 090 123 239 274 318759 046 526 327 095 178406 267 264 828 893 646896 593 219 169

Beginner Session - 10-25-2014.nb 17

Page 18: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

521 106 361729 757 074 376 148 061601 331 104 911 692 271318 609 404 145 014 842866 423 634 716

982 892 418180 484 365 230 538 864559 809 839 273 836 490685 480 823 014 267 803143 937 440 431

807 822 678779 494 006 206 489 151248 952 516 543 005 634448 375 046 751 754 207043 313 372 486

870 633 237561 645 232 360 481 932024 377 596 890 914 783372 179 553 676 992 603235 715 185 513

391 098 402739 063 753 280 702 313301 755 754 269 396 202629 423 910 945 323 537910 125 948 964

941 812 563672 992 967 084 250 667599 803 456 273 455 598559 628 512 281 414 582556 024 841 783

305 645 240508 450 065 988 755 987518 601 335 860 624 932784 487 772 006 842 296591 945 516 539

562 982 960591 610 046 578 907 214842 054 861 830 418 175604 559 815 168 088 031783 080 261 445

994 444 677918 012 432 146 400 983610 678 683 412 974 872596 729 258 786 806 223080 115 822 026

289 014 364459 002 301 645 823 666709 265 571 264 559 925790 622 304 745 235 625575 111 770 791

512 002 789380 975 775 468 546 121017 307 522 799 241 407026 308 137 792 971 909461 413 145 802

081 087 738121 624 539 858 769 697371 425 881 836 152 605069 380 926 917 712 087321 915 005 831

977 113 322793 572 385 071 940 612761 291 872 572 099 404930 250 277 748 156 614021 327 434 743

881 966 413330 052 634 229 082 906400 927 944 924 808 556131 183 440 161 804 801357 032 507 836

323 938 921567 643 159 620 442 612809 700 944 107 776 130638 909 071 294 456 394056 601 559 246

025 454 204771 186 140 420 155 233371 270 501 377 121 034570 009 578 009 389 265329 385 720 478

576 508 777149 663 403 003 562 380595 757 191 609 382 171312 222 810 465 858 388943 507 176 431

939 973 012661 591 423 837 170 284400 120 399 485 880 996231 859 472 474 858 776584 355 077 006

934 099 220340 378 772 192 728 370301 380 838 144 394 114984 971 730 766 162 961342 059 105 014

814 283 949700 695 951 676 939 041557 902 856 356 911 055547 312 684 571 497 449635 320 554 677

940 775 184056 667 637 222 969 090346 128 706 829 887 104278 761 090 090 999 160443 821 794 511

763 620 835379 716 161 833 124 364431 267 855 435 550 800507 986 124 664 397 724135 502 128 238

026 726 719914 989 727 248 512 981287 283 697 489 276 420792 868 666 970 177 259794 407 858 155

909 332 508554 131 299 946 581 118527 691 652 464 790 819119 384 233 275 897 699573 012 098 103

009 171 001695 718 791 616 942 270079 528 915 191 912 521053 891 838 538 959 315167 400 505 723

817 401 030621 004 380 243 011 187977 704 252 328 073 236575 129 609 372 456 053680 037 516 596

164 236 147709 330 391 224 409 752871 732 067 976 128 120428 026 739 256 557 305675 931 512 645

750 047 875756 531 854 825 821 411574 030 473 147 492 511910 835 615 765 732 002546 109 686 701

890 307 648531 373 832 912 682 481741 181 359 032 826 625082 549 313 211 431 478953 352 317 043

989 053 928534 946 642 886 074 268371 824 902 498 092 479487 226 633 686 823 799580 875 637 040

808 655 649321 905 489 637 785 549531 167 397 935 270 799470 452 399 153 297 534358 690 514 105

864 096 534514 182 896 474 439 367182 852 711 843 560 799285 895 978 176 543 950113 088 848 419

163 516 673213 692 860 830 956 744502 801 800 373 716 458009 168 082 972 708 715609 185 038 654

053 436 660045 504 985 624 687 376022 557 041 595 800 250174 095 361 839 287 643458 003 670 864

954 057 941720 085 136 357 127 163768 323 493 134 230 703821 274 484 501 440 529541 695 374 381

945 459 456533 165 140 990 993 722722 801 019 654 652 726227 831 512 103 467 686166 826 131 471

843 610 025517 863 247 950 150 022953 695 466 317 739 589344 131 481 485 834 694374 523 981 159

954 666 071205 997 794 363 440 185078 360 899 108 948 073419 633 939 259 318 973940 943 110 042

116 729 120199 722 626 609 871 927014 024 105 805 515 315100 109 804 996 044 147291 039 451 030

312 664 114726 736 839 973 315 035036 742 741 546 992 633165 270 432 940 675 237449 075 056 739

508 929 674779 115 800 864 399 992564 817 208 847 429 250821 546 279 856 079 127768 611 946 086

210 349 405535 850 134 472 190 244543 824 521 089 284 409498 132 717 010 673 966471 114 931 896

789 977 661595 488 186 193 176 900175 027 901 783 824 624387 873 831 483 279 500879 026 433 992

577 026 588005 849 778 984 624 295660 321 276 945 810 824348 129 690 840 972 550671 054 732 471

317 254 997191 901 039 553 305 847040 728 081 693 158 626093 886 019 147 689 944137 673 621 432

083 607 375131 574 376 316 754 666479 186 753 896 571 555100 850 626 810 005 119827 486 807 780

592 667 765654 100 834 778 571 024250 133 253 391 587 384761 024 129 794 736 751001 163 498 977

803 745 930025 457 609 870 671 092153 597 115 178 252 014281 216 647 543 034 075128 600 240 297

038 428 615984 289 816 602 143 429849 088 917 359 682 192284 469 123 035 904 329877 231 843 309

914 187 264674 607 558 318 725 713138 832 356 015 809 009594 182 530 207 799 397648 462 597 901

883 341 793830 920 965 841 463 574411 985 878 296 475 850943 053 008 148 341 821747 826 603 773

762 252 997703 468 752 903 517 310792 083 220 038 080 809212 164 346 586 817 989810 504 274 375

385 786 789186 350 517 717 501 606531 826 406 928 883 250135 919 517 178 537 687865 881 752 366

421 534 010961 295 763 074 762 648070 312 757 365 787 762352 859 057 153 932 484576 503 944 390

496 668 087711 899 192 498 933 896524 852 395 536 795 827530 614 167 131 757 915756 386 606 004

18 Beginner Session - 10-25-2014.nb

Page 19: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

839 994 179548 705 868 209 201 195154 952 031 294 562 451315 422 506 574 858 629161 606 523 796

643 010 172693 950 282 294 667 489681 746 821 163 996 794950 294 284 013 099 235901 278 250 437

428 192 557634 533 217 576 162 292751 110 598 368 271 567229 778 620 053 722 932314 082 887 058

749 444 060116 236 521 627 717 558503 013 451 471 452 765841 864 277 071 769 968435 499 620 257

547 431 811994 883 385 806 759 692359 580 622 165 832 464092 095 350 648 357 935817 742 903 018

315 351 290014 321 495 518 177 456908 388 719 320 697 769695 657 771 754 499 149911 431 368 950

836 160 692539 606 469 893 374 870942 933 219 185 601 299108 564 470 256 257 163505 508 620 689

240 297 589684 714 283 678 684 735455 533 583 477 652 536156 578 189 996 983 068654 671 736 445

996 343 136468 195 427 420 490 472433 064 675 001 442 697508 322 369 013 083 895492 637 066 778

406 531 328664 886 080 129 513 771720 847 581 157 719 491012 345 141 774 941 482773 580 041 432

667 332 379617 716 965 698 582 785832 300 505 265 883 502247 868 050 648 201 444570 593 197 343

382 923 860072 601 696 510 903 258980 909 912 837 652 275381 493 529 845 099 414966 933 862 815

568 031 306981 064 525 192 703 818515 872 648 691 762 563239 441 425 216 118 427769 145 067 718

411 735 714396 681 005 615 483 952443 154 944 864 238 384298 900 399 826 113 322468 963 346 522

104 692 545137 969 276 009 719 645338 955 332 105 584 245640 187 448 611 050 959111 766 828 942

711 640 054010 503 770 420 346 052521 318 228 045 892 998637 903 572 350 665 108782 350 043 349

942 391 285236 308 896 510 989 246641 056 331 584 171 142885 304 143 772 286 629832 318 970 869

030 400 301325 951 476 774 237 516158 840 915 838 059 151673 504 519 131 178 193943 428 482 922

272 304 061422 582 078 027 829 148070 426 761 629 302 539228 321 084 917 759 984200 595 105 312

164 731 818409 493 139 800 444 072847 325 902 609 169 730998 153 853 939 031 280878 823 902 948

001 579 008000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000 000 000000 000 000 000

000 000 000000 000 000 000 000 000000 000

Beginner Session - 10-25-2014.nb 19

Page 20: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

Alternatively, we can use IntegerDigits to break up the number into a list of its digits, and then take the first element in this list (i.e. the first digit)

In[63]:= IntegerDigits[10000!][[1]]

Out[63]= 2

◼ The Table function is useful for constructing lists. Create a list of the first 100 prime numbers (Hint: Use the function Prime inside of Table)

Here is a quick sweep of how the Table function works, following the different forms listed in the Documentation Center

In[64]:= Table[5, {10}]

Table[5 * i, {i, 10}]

Table[5 * i, {i, 0, 10}]

Table[5 * i, {i, 0, 10, 2}]

Out[64]= {5, 5, 5, 5, 5, 5, 5, 5, 5, 5}

Out[65]= {5, 10, 15, 20, 25, 30, 35, 40, 45, 50}

Out[66]= {0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50}

Out[67]= {0, 10, 20, 30, 40, 50}

With this, we can compute the first 100 primes using

In[68]:= Table[Prime[j], {j, 1, 100}]

Out[68]= {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,

73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157,

163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241,

251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347,

349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439,

443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541}

◼ What is the mean of the first 100 prime numbers?

In[69]:= Mean[Table[Prime[j], {j, 1, 100}]]

Out[69]=24 133

100

Symbolics

Tutorial: Symbolic Computation

Mathematica handles symbolic as well as numerical calculations. Everything that we have done above (and indeed, nearly everything in Mathematica) supports symbols. For example, here is basic arithmetic

In[70]:= a + b

a * b

a^b

Out[70]= a + b

Out[71]= a b

Out[72]= ab

20 Beginner Session - 10-25-2014.nb

Page 21: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

Here is a polynomial in the symbol x which we can Expand or Factor

In[73]:= poly = -2 + x -2 - x - 3 x2 + 2 x3

Out[73]= -2 + x -2 - x - 3 x2 + 2 x3

In[74]:= Expand[poly]

Factor[poly]

Out[74]= 4 + 5 x2 - 7 x3 + 2 x4

Out[75]= -2 + x2 1 + x + 2 x2

Note that when a symbol has not been given a value (such as x above), it shows up as blue. When a symbol has been given a value (such as poly above) it shows up as black. This is important as it helps distinguish between these two cases which yield very difference values

In[76]:= z + 12

Out[76]= 1 + z2

In[77]:= y = 1;

y + 12

Out[78]= 4

Clearing Values

Suppose we set a particular value for x that we needed for some previous calculation

In[79]:= x = 1;

x2 + 1

Out[80]= 2

If we now want to once again use x symbolically, we first need to Clear its definition.

In[81]:= Clear[x]

Note that x will now once again appear as blue everywhere in the notebook, indicating that it does not currently have a value assigned to it. Hence x is now treated as a symbol.

In[82]:= x2 + 1

Out[82]= 1 + x2

You can clear multiple variables at the same time

In[83]:= Clear[x, y, z]

Intermediate Section: Dive Deeper

Polynomial Ordering

Polynomial ordering(In case you are curious about the ordering Mathematica uses to display polynomials)

Beginner Session - 10-25-2014.nb 21

Page 22: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

Giving Symbols Values

Suppose you are given a polynomial poly that you want to evaluate at various values of x.

In[84]:= poly = 4 + 5 x2 - 7 x3 + 2 x4

Out[84]= 4 + 5 x2 - 7 x3 + 2 x4

For example, you want to know what poly equals at x = 2 and x = 5. You can do so by using ReplaceAll which has a convenient shorthand notation (/.)

In[85]:= poly /. x → 2

poly /. x → 5

(* Equivalent form *)

ReplaceAll[poly, x → 2]

ReplaceAll[poly, x → 5]

Out[85]= 0

Out[86]= 504

Out[87]= 0

Out[88]= 504

ReplaceAll applies to every instance of the replacement expression. For example,

In[89]:= {{x, y, {x, x}, z, {{{x}}}}} /. x → 1

Out[89]= {{1, y, {1, 1}, z, {{{1}}}}}

As an advanced example, you can take the underlying structure of an object such as a graph

22 Beginner Session - 10-25-2014.nb

Page 23: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

In[90]:= ParametricPlot3D[{Sin[u], Cos[u], u / 5}, {u, 0, 4 π}]

Out[90]=

and alter the way that it appears. As two examples, we change the underlying mechanism used in the plot from Line into Tube, giving the plot a more 3D appearance.

Beginner Session - 10-25-2014.nb 23

Page 24: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

In[91]:= ParametricPlot3D[{Sin[u], Cos[u], u / 5}, {u, 0, 4 π}] /. Line -> Tube

Out[91]=

Vectors, Matrices, Tensors

Tutorial: Vector Operations

Lists are very generic objects. We can represent vectors (Ex: {a, b, c}), matrices (Ex: {{a, b}, {c, d}}), or arbitrary tensors. These have the usual vector and matrix operations such as matrix multiplication, cross products, etc.

In[92]:= (* Matrix multiplication *)

{{a, b}, {c, d}}.{{e, f}, {g, h}}

(* Cross products *)

Cross[{a, b, c}, {d, e, f}]

Out[92]= {{a e + b g, a f + b h}, {c e + d g, c f + d h}}

Out[93]= {-c e + b f, c d - a f, -b d + a e}

Lists can also be ragged, meaning that they do not need to have the same number of elements at each level (Ex: {{a, b, c, d, e}, {f}}). This generality makes them extremely powerful.

◼ Ex: Construct a list of the first 10 integers in the form { j, divisors of j}.

In[94]:= Table[{j, Divisors[j]}, {j, 1, 10}]

Out[94]= {{1, {1}}, {2, {1, 2}}, {3, {1, 3}}, {4, {1, 2, 4}}, {5, {1, 5}}, {6, {1, 2, 3, 6}},

{7, {1, 7}}, {8, {1, 2, 4, 8}}, {9, {1, 3, 9}}, {10, {1, 2, 5, 10}}}

24 Beginner Session - 10-25-2014.nb

Page 25: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

(!!!) Numerics

Overview

◼ Exact input will yield exact output

In[95]:= Sin[Pi/3]

Out[95]=3

2

◼ Entering non-exact (i.e. numerical) input yields numerical output

◼ Ordinarily, this means 16 decimal points, with only 6 digits shown

◼ Numerical output can also be given for exact input by using the function N upon the exact value

In[96]:= (* Entering non-exact input *)

SinPi 3.

1. * SinPi 3

(* Using N on an exact number *)

NSinPi 3

Out[96]= 0.866025

Out[97]= 0.866025

Out[98]= 0.866025

◼ Arbitrary precision is supported on exact values. For example, we can ask for SinPi 3 to 100 decimal points using N with a second argument

In[99]:= NSinPi 3, 100

Out[99]= 0.86602540378443864676372317075293618347140262690519031402790348972596650845440001854

05730933786242878

Explore: Powers of 5

◼ Consider 15k where k is a positive integer. What is the smallest value of k such that 1

5k < 10-7?

We make a Table of the first several powers of 1.5k , forcing this table to be numeric by using 1. in the

numerator instead of the exact value 1(For ease of finding the answer we let each element take the form k, 1.

5k)

In[100]:= Tablek,1.

5k, {k, 1, 20}

Out[100]= {1, 0.2}, {2, 0.04}, {3, 0.008}, {4, 0.0016}, {5, 0.00032}, {6, 0.000064},

{7, 0.0000128}, 8, 2.56 × 10-6, 9, 5.12 × 10-7, 10, 1.024 × 10-7,

11, 2.048 × 10-8, 12, 4.096 × 10-9, 13, 8.192 × 10-10, 14, 1.6384 × 10-10,

15, 3.2768 × 10-11, 16, 6.5536 × 10-12, 17, 1.31072 × 10-12,

18, 2.62144 × 10-13, 19, 5.24288 × 10-14, 20, 1.04858 × 10-14

We see that k = 11 is the first case where 15k < 10-7

Alternatively, Mathematica will automatically simplify numerical inequalities to True or False,

Beginner Session - 10-25-2014.nb 25

Page 26: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

allowing us to use

In[101]:= Tablek,1.

5k< 10-7, {k, 1, 20}

Out[101]= {{1, False}, {2, False}, {3, False}, {4, False}, {5, False}, {6, False}, {7, False},

{8, False}, {9, False}, {10, False}, {11, True}, {12, True}, {13, True},

{14, True}, {15, True}, {16, True}, {17, True}, {18, True}, {19, True}, {20, True}}

(Once we learn how to use Solve, the best solution would be)

In[102]:= Ceilingk /. Solve1

5k== 10-7, k, Reals[[1]]

Out[102]= 11

Visualization

Plotting a function of one variable is done using Plot

In[103]:= Plot[Sin[x], {x, 0, 6 Pi}]

Out[103]=5 10 15

-1.0

-0.5

0.5

1.0

Plot has lots of options, enabling you to customize nearly the axes, ticks, legend, color... You can also plot multiple functions very easily.

In[104]:= Plot[{Sin[x], Sin[2 x], Sin[3 x]}, {x, 0, 2 Pi},

AxesLabel → {"x"}, PlotLabel → "Really Cool Plot"]

Out[104]=

1 2 3 4 5 6x

-1.0

-0.5

0.5

1.0

Really Cool Plot

Here is a brief look at some of the options of Plot

26 Beginner Session - 10-25-2014.nb

Page 27: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

In[105]:= Manipulate[Plot[amp f[freq x], {x, 0, 6},

PlotStyle → {color, Dashing[dashing], Thickness[thickness]},

Axes → axes, Frame → frame, AxesOrigin → axesorigin, PlotLabel → f],

{f, {Sin, Cos, Tan}},

TabView[{

"Function Variations" → Column[{Control[{freq, 1, 5}], Control[{amp, 1, 5}]}],

"Axes and Frames" → Column[{Control[{axes, {True, False}}],

Control[{frame, {False, True}}], Control[{axesorigin, {0, 0}, {6, 1}}]}],

"Plot Style" → Column[{Control[{color, Blue}], Control[{dashing, 0, 0.1}],

Control[{thickness, 0.001, 0.1}]}]}, ImageSize → {All, Automatic}]]

Out[105]=

f Sin Cos Tan

freq

amp

Function Variations Axes and Frames Plot Style

1 2 3 4 5 6

-1.0

-0.5

0.5

1.0

Sin

There are lots of different types of plotting functions, depending on what you need. Ex: ListPlot, ParametricPlot , ContourPlot... as well as their 3D versions (Plot3D, ListPlot3D, ParametricPlot3D, ContourPlot3D ...)

I provide a little peak at the capabilities of all the plotting functions in the Advanced Section.

(!!!) Application: Simplifying Expressions

Simplify

Simplify is one of the most incredible functions that Mathematica has to offer. Simplify will accomplish in a split second what can take you hours to do by hand.

Beginner Session - 10-25-2014.nb 27

Page 28: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

In[106]:= Simplify

-1024 + 5120 x - 11520 x2 + 15 360 x3 - 12 416 x4 + 2944 x5 + 8160 x6 - 14 400 x7 + 13 260 x8 -

8044 x9 + 3359 x10 - 960 x11 + 180 x12 - 20 x13 + x14 -2 + x - 2 x2 + x3

Out[106]= -2 + x9 -1 + x2

Most expressions are not simplified automatically, but Simplify does the trick

In[107]:= (* We know that this answer must be 1

x3+1*)

result = DIntegrate1 x^3 + 1, x, x

Out[107]=1

3 1 + x-

-1 + 2 x

6 1 - x + x2+

2

3 1 +1

3-1 + 2 x2

In[108]:= (* Mathematica can simplify the above result to find this simpler form *)

Simplify[result]

Out[108]=1

1 + x3

Radicals

Mathematica ordinarily does not make any assumptions about variables. However, this extra information can easily be specified (either in each Simplify command or globally using $Assumptions)

In[109]:= Simplify[Sqrt[x^2]]

Out[109]= x2

In[110]:= Simplify[Sqrt[x^2], Element[x, Reals]]

Out[110]= Abs[x]

In[111]:= Simplify[Sqrt[x^2], x > 0]

Out[111]= x

Simplifying equations is an extremely challenging problem, and there are very good mathematical reasons why a language like Mathematica which allows arithmetic with complex numbers cannot always simplify expressions for positive real numbers (even when those expressions are “obviously simplifyable”).

Whenever an expression does not seem to simplify fully, always try to give it extra Assumptions in the second argument. If this still does not work, I try FullSimplify with Assumptions.

Applications

Suppose you see a solution to an equation in a textbook. Simplify can verify whether this solution satisfies the equations

In[112]:= sol = Solve[x^2 + x + 1 ⩵ 0, x]

x^2 + x + 1 ⩵ 0 /. sol // Simplify

Out[112]= x → --11/3, x → -12/3

Out[113]= {True, True}

28 Beginner Session - 10-25-2014.nb

Page 29: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

Simplify has a lot of algorithms at its disposal, and it is able to prove some theorems. For example, this proves that the arithmetic mean is larger of two numbers is larger than their geometric mean

In[114]:= Simplify(x + y) 2 ≥ Sqrt[x y], x ≥ 0 && y ≥ 0

Out[114]= True

FullSimplify

FullSimplify is Simplify ’s big brother.

While Simplify tries very hard to return an answer quickly, FullSimplify will take up more time and use a wider array of algorithms on your expression. FullSimplify will always yield at least as simple a form as Simplify .

For example, FullSimplify can prove a relation about the Gamma function that Simplify cannot

In[115]:= Simplify[Gamma[x] Gamma[1 - x]]

FullSimplify[Gamma[x] Gamma[1 - x]]

Out[115]= Gamma[1 - x] Gamma[x]

Out[116]= π Csc[π x]

Explore: Binomial (Coefficients)

Use FullSimplify to prove get nice formula for Binomial[n+1,k+1]Binomial[n,k] =

n + 1k + 1

n

k

In[117]:= FullSimplifyBinomial[n + 1, k + 1] Binomial[n, k]

Out[117]=11

1 + k

(!!!) Application: Solving Equations

Exact Solving

The Power of Solve

Solve allows you to solve a system of equations. Solve allows you to use multiple equations, equalities or inequalities, restrict variables to domains (Integers, Reals, Complexes...), use geomet-ric regions...

◼ When entering equations in the form lhs == rhs you must use == (which indicates equality) instead of = (which indicates defining the variable lhs to have the value rhs)

In[118]:= (* Solve a linear equation *)

Solve5 x + 2 ⩵ 7 2, x

Out[118]= x →3

10

In[119]:= (* Solve finds all solutions, real or complex *)

Solve[x^4 ⩵ 1, x]

Out[119]= {{x → -1}, {x → -ⅈ}, {x → ⅈ}, {x → 1}}

Beginner Session - 10-25-2014.nb 29

Page 30: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

In[120]:= (* Solve for multiple variables *)

Solve[{x * y ⩵ 35, x + y ⩵ 12}, {x, y}]

Out[120]= {{x → 5, y → 7}, {x → 7, y → 5}}

In[121]:= (* Solve where the unit circle intersects

the line passing through -2,1 and 1,-2 *)

ℛ1 = Circle[];

ℛ2 = Line[{{-2, 1}, {1, -2}}];

solve = Solve[{x, y} ∈ ℛ1 && {x, y} ∈ ℛ2, {x, y}];

Graphics[{{ℛ1, Purple, ℛ2}, {Red, PointSize[0.015], Point[{x, y}] /. solve}}]

Out[124]=

Numerical Solving

NSolve is a version of Solve specializing in finding numerical values. If you don’t care about exact solutions, NSolve will usually be much faster.

In[125]:= (* Find exact solutions to a system of equations *)

Solve[{x^2 + y^2 ⩵ 1, x + y^2 ⩵ 2}, {x, y}]

(* Find approximate solutions to a system of equations *)

NSolve[{x^2 + y^2 ⩵ 1, x + y^2 ⩵ 2}, {x, y}]

Out[125]= x →1

2+ⅈ 3

2, y → -

3

2-ⅈ 3

2, x →

1

2+ⅈ 3

2, y →

3

2-ⅈ 3

2,

x →1

2-ⅈ 3

2, y → -

3

2+ⅈ 3

2, x →

1

2-ⅈ 3

2, y →

3

2+ⅈ 3

2

Out[126]= {{x → 0.5 - 0.866025 ⅈ, y → 1.27123 + 0.340625 ⅈ},

{x → 0.5 + 0.866025 ⅈ, y → 1.27123 - 0.340625 ⅈ},

{x → 0.5 - 0.866025 ⅈ, y → -1.27123 - 0.340625 ⅈ},

{x → 0.5 + 0.866025 ⅈ, y → -1.27123 + 0.340625 ⅈ}}

30 Beginner Session - 10-25-2014.nb

Page 31: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

Explore: Solving the Mysteries of Life

◼ Solve for the roots of the quadratic equation a x2 + b x + c = 0

In[127]:= Solve[a x^2 + b x + c == 0, x]

Out[127]= x →-b - b2 - 4 a c

2 a, x →

-b + b2 - 4 a c

2 a

◼ Find n such that nn = 3456?

First, let’s take a second to appreciate just how massive these numbers are

In[128]:= 3456

Out[128]= 57 918 773 205287 127 842 044 254126 179 599 852 840 968492 056 164 062 843 692360 166 371 779 746

690 236 416

That is pretty huge! But NSolve has no problem finding where nn = 3456, from which we can take the Ceiling to find the smallest integer satisfying nn > 3456

In[129]:= int = Ceilingn /. NSolvenn ⩵ 3456, n > 0, n[[1]]

Part : Part 1 of {} does not exist.

ReplaceAll : {{}〚1〛} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.

Out[129]= Ceiling[10 /. {}〚1〛]

We can verify that this is the smallest integer using ReplaceAll (which is explained in the next section)

In[130]:= nn > 3456 /. n → int - 1

nn > 3456 /. n → int

Out[130]= False

Out[131]= False

ReplaceAll (/.)

Replacing Tutorial

Replacing symbols with other symbols is incredibly useful. For example, suppose you want to change the function Cos[x a] + 1

x aSin[x a] into a function in y = x a. One way to do this is to use

ReplaceAll, which you will almost always see in its shorthand form (/.)

Beginner Session - 10-25-2014.nb 31

Page 32: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

In[132]:= (* This function can be plotted once x a is replaced with y *)

PlotCos[a x] +Sin[a x]

a x/. x →

y

a, {y, 0, 6 π}

Out[132]=

5 10 15

-1.0

-0.5

0.5

1.0

1.5

2.0

ReplaceAll is also a convenient way to plug in a specific value for an expression. For example suppose you want to figure the numerical value of Cos[E^x] equals when x = 1, then you can use

In[133]:= Cos[E^x] /. x → 1.

Out[133]= -0.911734

Replacing is incredibly useful when using Solve or NSolve, since the output of these functions is a replacement rule. For example, here we extract the solutions for a linear equation

In[134]:= Solve[{x + 5 ⩵ 7}, {x}]

solutions = x /. Solve[{x + 5 ⩵ 7}, {x}]

Out[134]= {{x → 2}}

Out[135]= {2}

Explore: Maximizing/Minimizing Functions

◼ Find the local minima and maxima of the function x^3 - 2 x^2 - 3 x + 5. (Hint: Solve for when the derivative D[x^3 - 2 x^2 - 3 x + 5, x] equals zero)

In[136]:= f = x^3 - 2 x^2 - 3 x + 5

solutions = Solve[D[f, x] ⩵ 0, x]

Out[136]= 5 - 3 x - 2 x2 + x3

Out[137]= x →1

32 - 13 , x →

1

32 + 13

In[138]:= points = N[f] /. solutions

Out[138]= {5.87942, -1.0646}

32 Beginner Session - 10-25-2014.nb

Page 33: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

In[139]:= Plot[f, {x, -5, 5},

Epilog → {PointSize[0.02], Red, Point[Transpose[{x /. solutions, points}]]}]

Out[139]=

-4 -2 2 4

-100

-50

50

Application: Differential Equations

Derivatives and Integrals

Mathematica knows all about Calculus with the function D denoting the partial derivative

In[140]:= (* Simple derivatives *)

Dxn, x

D[Sin[b * x], x]

D[Cos[b * x], x]

DEb x, x

D[Log[x], x]

(* Higher order derivatives *)

Dxn, {x, 2}

Dxn, {x, 3}

Out[140]= 10 x9

Out[141]= b Cos[b x]

Out[142]= -b Sin[b x]

Out[143]= b ⅇb x

Out[144]=1

x

Out[145]= 90 x8

Out[146]= 720 x7

To tell D that a function y depends on x, we use the form y[x]

Beginner Session - 10-25-2014.nb 33

Page 34: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

In[147]:= (* Sum Rule *)

D[y[x] + z[x], x]

(* Product Rule *)

D[y[x] z[x], x]

(* Chain Rule *)

D[y[x[t]], t]

Out[147]= y′[x] + z′[x]

Out[148]= z[x] y′[x] + y[x] z′[x]

Out[149]= x′[t] y′[x[t]]

When functions have more than one argument, D will explicitly state which variable it is differentiat-ing with respect to

In[150]:= D[x[y[t], z[t]], t]

Out[150]= z′[t] x(0,1)[y[t], z[t]] + y′[t] x(1,0)[y[t], z[t]]

Intuitively enough, the function Integrate is used to integrate

In[151]:= (* Simple integrals *)

Integratexn, x

Integrate[Sin[b * x], x]

Integrate[Cos[b * x], x]

IntegrateEb x, x

Integrate1 x, x

Out[151]=x11

11

Out[152]= -Cos[b x]

b

Out[153]=Sin[b x]

b

Out[154]=ⅇb x

b

Out[155]= Log[x]

Definite integration is done by using a List in the second argument

In[156]:= Integrate[x, {x, 0, 4}]

IntegrateEb x, {x, y, z}

Out[156]= 8

Out[157]=-ⅇb y + ⅇb z

b

Differential Equation Solver

DSolve allows you to solve differential equations

In[158]:= DSolve[y'[x] == y[x], y[x], x]

Out[158]= y[x] → ⅇx C[1]

34 Beginner Session - 10-25-2014.nb

Page 35: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

You can specify initial conditions

In[159]:= DSolve[{y''[x] ⩵ -y[x], y[0] ⩵ 0, y'[0] ⩵ 5}, y[x], x]

Out[159]= {{y[x] → 5 Sin[x]}}

You can solve a list of differential equations

In[160]:= sol = DSolvey'[x] - 3 z[x] ⩵ Sin[x], y[x] + z[x] ⩵ 1 5, yPi 2 == 1 2, {y, z}, x;

Plot[Evaluate[{y[x], z[x], y[x] + z[x]} /. sol],

{x, 2, 16}, PlotLegends → {y[x], z[x], y[x] + z[x]}]

Out[161]=

4 6 8 10 12 14 16

-0.2

0.2

0.4

y(x)

z(x)

y(x) + z(x)

Model a ball bouncing down steps

In[162]:= c = .75;

sol = DSolve[{y''[t] ⩵ -9.8, y[0] ⩵ 13.5,

y'[0] ⩵ 5, a[0] ⩵ 13, WhenEvent[y[t] - a[t] ⩵ 0, y'[t] -> -c y'[t]],

WhenEvent[Mod[t, 1], a[t] -> a[t] - 1]}, {y, a}, {t, 0, 8}, DiscreteVariables → {a}] ;

Plot[Evaluate[{y[t], a[t]} /. sol], {t, 0, 8}, Filling → {2 → 0}, Exclusions → None]

Out[164]=

2 4 6 8

8

10

12

14

Application: Fitting Data

There are lots of functions to fit data. The simplest one is Fit which fits data to polynomials.

Beginner Session - 10-25-2014.nb 35

Page 36: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

In[165]:= data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}};

(* Fit data to a linear curve *)

line = Fit[data, {1, x}, x];

(* Fit data to a parabola *)

parabola = Fit[data, {1, x, x^2}, x];

(* Show the data along with the fitted curves *)

Show[ListPlot[data, PlotStyle → Red], Plot[{line, parabola}, {x, 0, 5}]]

Out[168]=

1 2 3 4 5

1

2

3

4

You can also fit data to general functions using FindFit . Here we fit the first 20 primes to a function of the form a x Log[b + c x],

In[169]:= data = Table[Prime[x], {x, 20}];

parameters = FindFit[data, a x Log[b + c x], {a, b, c}, x];

fit = Table[a x Log[b + c x] /. parameters, {x, 20}];

Show[ListPlot[data, PlotStyle → Red],

ListPlot[fit, Joined → True, Mesh → All, MeshStyle → Thin]]

FindFit : 0.75` is not a valid variable.

FindFit : 0.75` is not a valid variable.

ReplaceAll : {FindFit[{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71}, a Log[0.75 + b], {a, b, 0.75}, 1]} is

neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.

FindFit : 0.75` is not a valid variable.

ReplaceAll : {FindFit[{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71}, 2 a Log[1.5 + b], {a, b, 0.75}, 2]} is

neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.

FindFit : 0.75` is not a valid variable.

General : Further output of FindFit::ivar will be suppressed during this calculation.

ReplaceAll : {FindFit[{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71}, 3 a Log[2.25 + b], {a, b, 0.75}, 3]} is

neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.

General : Further output of ReplaceAll::reps will be suppressed during this calculation.

FindFit : 0.75` is not a valid variable.

ReplaceAll :

{FindFit[{2.000000000000000, 3.000000000000000, 5.000000000000000, 7.000000000000000, 11.00000000000000,

13.00000000000000, 17.00000000000000, 19.00000000000000, 23.00000000000000, 29.00000000000000,7,

37.00000000000000, 41.00000000000000, 43.00000000000000, 47.00000000000000, 53.00000000000000,

59.00000000000000, 61.00000000000000, 67.00000000000000, 71.00000000000000},2,6]}

is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.

FindFit : 0.75` is not a valid variable.

36 Beginner Session - 10-25-2014.nb

Page 37: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

ReplaceAll :

{FindFit[{2.000000000000000, 3.000000000000000, 5.000000000000000, 7.000000000000000, 11.00000000000000,

13.00000000000000, 17.00000000000000, 19.00000000000000, 23.00000000000000, 29.00000000000000,7,

37.00000000000000, 41.00000000000000, 43.00000000000000, 47.00000000000000, 53.00000000000000,

59.00000000000000, 61.00000000000000, 67.00000000000000, 71.00000000000000},2,6]}

is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.

FindFit : 0.75` is not a valid variable.

General : Further output of FindFit::ivar will be suppressed during this calculation.

ReplaceAll :

{FindFit[{2.000000000000000, 3.000000000000000, 5.000000000000000, 7.000000000000000, 11.00000000000000,

13.00000000000000, 17.00000000000000, 19.00000000000000, 23.00000000000000, 29.00000000000000,7,

37.00000000000000, 41.00000000000000, 43.00000000000000, 47.00000000000000, 53.00000000000000,

59.00000000000000, 61.00000000000000, 67.00000000000000, 71.00000000000000},2,6]}

is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.

General : Further output of ReplaceAll::reps will be suppressed during this calculation.

Out[172]=

5 10 15 20

10

20

30

40

50

60

70

Here is a simple interface that lets you dynamically alter 10 points to which a quintic polynomial is fit.

In[173]:= ManipulatePlotEvaluateFitpoints, Tableζi, {i, 0, 5}, ζ, {ζ, -2, 2},

PlotRange → 5, ImageSize → 240, {{points, RandomReal[{-2, 2}, {10, 2}]}, Locator}

Out[173]=

-2 -1 1 2

-4

-2

2

4

(!!!) Manipulate

Introduction to Manipulate

Beginner Session - 10-25-2014.nb 37

Page 38: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

Manipulate is by far one of the most useful and unique features of Mathematica, allowing you to interact with any parameter in an expression and immediately see how it effects the expression.

(Electrodynamics) Point charges - Electrostatic potential

In[174]:= ManipulateContourPlotq1 Norm[{x, y} - p[[1]]] + q2 Norm[{x, y} - p[[2]]],

{x, -2, 2}, {y, -2, 2}, Contours → 10, {{q1, -1}, -3, 3}, {{q2, 1}, -3, 3},

{{p, {{-1, 0}, {1, 0}}}, {-1, -1}, {1, 1}, Locator}, Deployed → True

Out[174]=

q1

q2

-2 -1 0 1 2

-2

-1

0

1

2

38 Beginner Session - 10-25-2014.nb

Page 39: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

(Quantum Mechanics) Spherical harmonics

In[175]:= Manipulate[ParametricPlot3D[

Evaluate[{Cos[p] Sin[t], Sin[p] Sin[t], Cos[t]} Abs[SphericalHarmonicY[l, m, t, p]]],

{p, -Pi, Pi}, {t, 0, Pi}, PlotRange → {{-.5, .5}, {-.5, .5}, {-1.1, 1.1}},

Mesh → False, PlotPoints → {36, 18}, MaxRecursion → ControlActive[0, 2],

ViewAngle → .246, ImageSize → {500, 377}, Axes → False,

SphericalRegion → True, Boxed → False, PlotLabel → Style[With[{l = l, m = Round@m},

TraditionalForm[HoldForm[r == SphericalHarmonicY[l, m, θ, ϕ]]]], 14]],

{{l, 2, "degree l"}, 0, 7, 1, Appearance → "Labeled"},

{{m, 0, "order m"}, -l, l, 1, Appearance → "Labeled"}]

Out[175]=

degree l 2

order m 0

Beginner Session - 10-25-2014.nb 39

Page 40: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

(Math) Differential equation - Set boundary values

In[176]:= Manipulate[Plot[Evaluate[

y[t] /. First[NDSolve[ {y''[x] ⩵ -x y[x], y[0] ⩵ a, y'[0] ⩵ b}, y, {x, 0, 4}]]],

{t, 0, 4}, Epilog → {Green, Arrow[{{0, a}, {1, b + a}}], Red, Point[{0, a}]},

ImagePadding → 25, PlotRange → 3],

{{a, 1, TraditionalForm[y[0]]}, -3, 3},

{{b, 0, TraditionalForm[y'[0]]}, -3, 3}]

Out[176]=

y(0)

y′(0)

1 2 3 4

-3

-2

-1

1

2

3

Intermediate Section: Learn More

Manipulate gives you an unprecedented perspective into problems, truly allowing you to visualize how every variable acts. If the above examples seem impressive, learn about Manipulate’s com-plete capabilities.

Advanced Manipulate

Mathematica has lots of additional Dynamic capabilities outside of Manipulate which can help you design interfaces, understanding how Mathematica evaluates, and truly take your coding capabili-ties up to the next level!

Localizing Variables

Conclusions

Useful Resources

Great resources (beginner to advanced level):

◼ Wolfram training videos - Cover various aspects of Mathematica (stick to the free options)

40 Beginner Session - 10-25-2014.nb

Page 41: Mathematica - A Fantastic PlaygroundA Welcome Screen appears, from which you can either Create a New Document (i.e. a blank notebook) or Open a Recent Document (i.e. one of recent

◼ Mathematica Guidebooks - Caltech library has a copy with a CD, so you can read the electronic or physical version

◼ Got Questions? Just Google It! - Tons of sites (StackExchange, Wolfram Community, Wolfram Blogs) answer user questions; Mathematica developers often post answers as well

If you find yourself seriously using Mathematica, get to know what the language can do. A bit of

reading will reduce your programming creation time and programming run time by 100x.

Why Mathematica?

◼ Comprehensive functionality - Practically any math function you can think of is built in: symbolics, numerics, plotting, image analysis, machine learning...

◼ Don’t re-invent the wheel - Mathematicians have spent years optimizing Mathematica’s functionality, creating robust code that will run much faster than your own version. Stand on the shoulder of giants and you will see far.

◼ The code makes sense - Function names are nearly always complete English words, fully spelled out. If you know the mathematical name for something, you can probably guess the Mathematica form.

In[177]:= PlotE-1/x, {x, 0, 5}, AxesLabel → {"time", "knowledge"},

PlotLabel → "Mathematica Learning Curve", Ticks → None,

Epilog → PointSize[Medium], Point0.35, E-1/0.35

General : Exp[-9790.21] is too small to represent as a normalized machine number; precision may be lost.

Out[177]=

time

knowledgeMathematica Learning Curve

Beginner Session - 10-25-2014.nb 41