DOC PREVIEW
CSBSJU PHYS 370 - Introduction to Mathematica Commands

This preview shows page 1-2-3-21-22-23-43-44-45 out of 45 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 45 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Appendix AIntroduction toMathematicaCommandsc Copyright 2004 by Jenny A. Baglivo. All Rights Reserved.Mathematica (Wolfram Research, Inc.) is a system for doing mathematics onthe computer and for reporting the results. Mathematica has numerical, graphical,and symbolic capabilities. Its basic features include arbitrary precision arithmetic;differential and integral calculus (routines for both symbolic and numerical eval-uation); infinite and finite series, limits and products; expansion and factoring ofalgebraic expressions; linear algebra; solving systems of equations; and two- andthree-dimensional graphics. Mathematica packages and custom tools include pro-cedures for probability and statistics.This chapter briefly describes the Mathematica commands used in the labo-ratory problems. The first section covers commands provided by the system, andcommands loaded from Mathematica packages. The second section covers the cus-tomized tools provided with this book. An index to the commands appears at theend of the chapter.A.1 Standard commandsThis section introduces the standard Mathematica commands used in the laboratoryproblems. Standard commands include commands provided by the system and com-mands loaded from add-on packages when the StatTools packages are initialized.Note that commands from theGraphics‘FilledPlot‘,Statistics‘DataManipulation‘,Statistics‘DescriptiveStatistics‘,Statistics‘DiscreteDistributions‘, andStatistics‘ContinuousDistributions‘packages are loaded when StatTools‘Group1‘ and StatTools‘Group2‘ are initial-ized, commands fromStatistics‘ConfidenceIntervals‘ and12 Appendix A. Introduction to Mathematica CommandsStatistics‘HypothesisTests‘are loaded when StatTools‘Group3‘ is initialized, and commands fromStatistics‘LinearRegression‘are loaded when StatTools‘Group4‘ is initialized.Online help for each Symbol discussed in this section is available by evaluating?Symbol. Additional help and examples are available in the Help Browser.A.1.1 Built-in constants and functionsFrequently used constants and arithmetic functions, functions for sums and prod-ucts, functions from calculus, functions used in counting problems, the numericalapproximation function (N), boolean functions, logical operators and connectors,and a function for producing random integer and random real numbers are summa-rized below.Constants and arithmetic functionsSymbol Value Symbol FunctionPi π = 3.14159 . . . +, − add, subtractE e = 2.71828 . . . ∗, / multiply, divideI i =√−1 ∧ exponentiationInfinity ∞True, False true, falseArithmetic expressions are evaluated from left to right with the following hierarchy:exponentiation is done first, followed by multiplication and division, followed byaddition and subtraction. Parentheses can be used to enclose subexpressions. Forexample, 3 + 8 ∗ 4 returns 35 and (3 + 8) ∗4 returns 44.In addition, a space can be used instead of the multiply symbol (although thisis not recommended). For example, 3 ∗ 4 ∗5 and 3 4 5 each return 60.Sum, Product functionsThe functions Sum and Product can be used to compute sums (respectively, prod-ucts) of one or more terms. For example,1. Sum[x ∧ 2, {x, 1, 10}] returns 385 = 1 + 4 + 9 + ··· + 100.2. Product[x, {x, 4, 12}] returns 79833600 = 4 ∗ 5 ∗ 6 ∗ ··· ∗ 12.In each case, the variable x is known as an iterator. More generally, Sum and Productcan be used to compute multiple sums (respectively, products). For example,Sum[i + j, {i, 1, 4}, {j, 1, i}] returns 50 = 2 + 3 + 4 + 4 + 5 + 6 + 5 + 6 + 7 + 8.A.1. Standard commands 3Functions from calculusMathematica Name FunctionLog[x] natural logarithm, ln(x) or log(x)Log[10,x] common logarithm, log10(x)Exp[x] exponential function, exPower[x,y] or x∧y power function, xySqrt[x] square root function,√xAbs[x] absolute value function, |x|Sign[x] sign function (+1 when x > 0,−1 when x < 0, 0 when x = 0)Round[x] round x to the nearest integerFloor[x] return the greatest integerless than or equal to xSin[x], Cos[x], Tan[x], . . . sin(x), cos(x), tan(x), . . .ArcSin[x], ArcCos[x], ArcTan[x], . . . arcsin(x), arccos(x), arctan(x), . . .Notice in particular that Mathematica uses the general function name Log for bothnatural and common logarithms.Functions for counting problemsMathematica Name FunctionFactorial[x] or x! factorial, x! = x ∗ (x − 1) ∗ ··· ∗ 1when x is a non-negative integerBinomial[n,r] binomial coefficient,nrMultinomial[r1,r2,. . .,rk] multinomial coefficient,nr1,r2,...,rkwhere n = r1+ r2+ ··· + rkFor example, Binomial[10,3] returns 120 (the total number of subsets of size 3from a set of size 10), and Multinomial[5,2,3] returns 2520 (the total number ofpartitions of a set of size 10 into distinguishable subsets of sizes 5, 2, 3).Random numbersMathematica uses the general function name Random to return random numbers inmany different situations. For example,1. Random[] returns a real number chosen uniformly from the interval (0, 1).2. Random[Real,{0, 500}] returns a real number chosen uniformly from the in-terval (0, 500).3. Random[Integer,{10, 200}] returns an integer chosen uniformly from therange of integers 10, 11, 12, . . ., 200.In each case, an algorithm called a pseudo-random number generator is used toproduce the output.4 Appendix A. Introduction to Mathematica CommandsNumerical approximationMathematica returns exact answers whenever possible. The N function can beused to compute approximate (decimal) values instead. For example, N[E] returns2.71828 and N[40!] returns 8.15915 1047.Logical symbolsLogical operators and connectors are summarized below:Symbol Meaning Symbol Meaning< less than == equal to<= less than or equal to ! = not equal to> greater than && logical and>= greater than or equal to || logical orThere are often several ways to ask the same question. For example, if a, x, and b arespecific real numbers, then the expression Not[a <= x <= b] and the expression(x < a)||(x > b) each return True when the number x is not in the interval [a, b],and False otherwise.Note that, in many systems, if you type “<=”, the symbol “≤” appears onthe screen. Similarly, if you type “>=”, the symbol “≥” appears on the screen.Boolean functionsFunctions returning True or False are summarized below:Mathematica Name Returns True when Returns False whenPositive[x] x is positive x is 0 or negativeNegative[x] x is negative x is 0 or positiveEvenQ[x] x is an even


View Full Document

CSBSJU PHYS 370 - Introduction to Mathematica Commands

Download Introduction to Mathematica Commands
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Introduction to Mathematica Commands and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Introduction to Mathematica Commands 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?