A Mathematica Crib Sheet (But It's OK, You'll Need One)

Similar documents
User Guide.

Getting Started with MasteringPhysics

Getting Started with

ALGEBRA REVIEW LEARNING SKILLS CENTER. Exponents & Radicals

Review of Matlab for Differential Equations. Lia Vas

SIMPLIFYING ALGEBRAIC FRACTIONS

Chapter 7 - Roots, Radicals, and Complex Numbers

GRE Prep: Precalculus

The KmPlot Handbook. Klaus-Dieter Möller Philip Rodrigues David Saxton

0.8 Rational Expressions and Equations

Techniques of Integration

3.1. RATIONAL EXPRESSIONS

Final Exam Review: VBA

MBA Jump Start Program

Year 9 set 1 Mathematics notes, to accompany the 9H book.

Exponents and Radicals

Chapter 5 Functions. Introducing Functions

Differentiation and Integration

3 Some Integer Functions

Zero: If P is a polynomial and if c is a number such that P (c) = 0 then c is a zero of P.

0 Introduction to Data Analysis Using an Excel Spreadsheet

Summary of important mathematical operations and formulas (from first tutorial):

CAHSEE on Target UC Davis, School and University Partnerships

Math Review. for the Quantitative Reasoning Measure of the GRE revised General Test

SAT Math Facts & Formulas Review Quiz

Section 1.5 Exponents, Square Roots, and the Order of Operations

Homework # 3 Solutions

Microeconomic Theory: Basic Math Concepts

Week 13 Trigonometric Form of Complex Numbers

Excel Basics By Tom Peters & Laura Spielman

INVERSE TRIGONOMETRIC FUNCTIONS. Colin Cox

Section 4.4. Using the Fundamental Theorem. Difference Equations to Differential Equations

ab = c a If the coefficients a,b and c are real then either α and β are real or α and β are complex conjugates

Zeros of Polynomial Functions

Indices and Surds. The Laws on Indices. 1. Multiplication: Mgr. ubomíra Tomková

Maple for Math Majors. 8. Manipulating and Simplifying Expressions 8.1. Introduction

Solving Rational Equations

EXCEL SPREADSHEET MANUAL

Lesson 10: Polynomials

Irrational Numbers. A. Rational Numbers 1. Before we discuss irrational numbers, it would probably be a good idea to define rational numbers.

Vocabulary Words and Definitions for Algebra

Solving Equations and Inequalities

Engineering Problem Solving and Excel. EGN 1006 Introduction to Engineering

1 if 1 x 0 1 if 0 x 1

This is a square root. The number under the radical is 9. (An asterisk * means multiply.)

Lectures 5-6: Taylor Series

Math 120 Final Exam Practice Problems, Form: A

TI-Nspire CAS Graphing Calculator

2 Integrating Both Sides

2.5 Zeros of a Polynomial Functions

Integrals of Rational Functions

Inverse Functions and Logarithms

Partial Fractions. Combining fractions over a common denominator is a familiar operation from algebra:

5.1 Radical Notation and Rational Exponents

Operations with positive and negative numbers - see first chapter below. Rules related to working with fractions - see second chapter below

Session 7 Fractions and Decimals

Click on the links below to jump directly to the relevant section

CHAPTER 5 Round-off errors

36 CHAPTER 1. LIMITS AND CONTINUITY. Figure 1.17: At which points is f not continuous?

FINAL EXAM SECTIONS AND OBJECTIVES FOR COLLEGE ALGEBRA

Graphing Parabolas With Microsoft Excel

Find all of the real numbers x that satisfy the algebraic equation:

Review of Fundamental Mathematics

EXCEL Tutorial: How to use EXCEL for Graphs and Calculations.

Examples of Tasks from CCSS Edition Course 3, Unit 5

An important theme in this book is to give constructive definitions of mathematical objects. Thus, for instance, if you needed to evaluate.

Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any.

COLLEGE ALGEBRA. Paul Dawkins

6.1. The Exponential Function. Introduction. Prerequisites. Learning Outcomes. Learning Style

xn. x must be written as x^(2n) and NOT as x^2n. Writing x^2n means 4x y would be written as 4 x^2 y^3 or with the multiplication mark as 4*x^2*y^3.

Course outline, MA 113, Spring 2014 Part A, Functions and limits Functions, domain and ranges, A Review (9 problems)

The Deadly Sins of Algebra

Section 4.1 Rules of Exponents

SAT Subject Math Level 2 Facts & Formulas

Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language

Unit 1 Equations, Inequalities, Functions

Lecture 3 : The Natural Exponential Function: f(x) = exp(x) = e x. y = exp(x) if and only if x = ln(y)

The Method of Partial Fractions Math 121 Calculus II Spring 2015

Lies My Calculator and Computer Told Me

Maths Workshop for Parents 2. Fractions and Algebra

Microeconomics Sept. 16, 2010 NOTES ON CALCULUS AND UTILITY FUNCTIONS

Factoring and Applications

POLYNOMIAL FUNCTIONS

Mathematica Tutorial

Quick Tricks for Multiplication

Lecture 13 - Basic Number Theory.

Calibration and Linear Regression Analysis: A Self-Guided Tutorial

Polynomial Expression

MATH Fundamental Mathematics IV

1 Lecture: Integration of rational functions by decomposition

2.2 Separable Equations

UNIT 5 VOCABULARY: POLYNOMIALS

Algebra 2 Chapter 1 Vocabulary. identity - A statement that equates two equivalent expressions.

A Second Course in Mathematics Concepts for Elementary Teachers: Theory, Problems, and Solutions

Algebra. Exponents. Absolute Value. Simplify each of the following as much as possible. 2x y x + y y. xxx 3. x x x xx x. 1. Evaluate 5 and 123

Preface of Excel Guide

Probability and Statistics Prof. Dr. Somesh Kumar Department of Mathematics Indian Institute of Technology, Kharagpur

This unit will lay the groundwork for later units where the students will extend this knowledge to quadratic and exponential functions.

1.3 Algebraic Expressions

ALGEBRA. sequence, term, nth term, consecutive, rule, relationship, generate, predict, continue increase, decrease finite, infinite

Transcription:

A Mathematica Crib Sheet (But It's OK, You'll Need One) Mathematica is a full-featured programming language, with over 1500 commands built-in or in standard "packages". But it's like speaking English: an educated person probably knows a quarter of a million words, but only about a hundred and fifty different words are really needed to get through a whole week. Similarly, there are only a few commands that you'll need to run Mathematica well enough to learn calculus. Think of this sheet as an emergency road-side manual, dedicated to getting you "up and running." Instead of asking, "What happens if I...", do it! The Golden Rule: Try It! Experiment! Try commands out to see what they do. Try commands we haven't talked about. We promise: the computer won't catch fire, no matter how bad a mistake you make. (As long as it doesn't involve matches...) Four Mistakes You'll Make Over and Over! 1. To end input you must hit "Enter" or "Shift-Return," not just "Return." Commands to Mathematica can span multiple lines, so if you just hit "Return" Mathematica thinks you haven't finished typing the command for that input cell, and waits for you to continue. 2. Mathematica functions and procedures use square brackets around their arguments, not parentheses! 3. Mathematica is very sensitive to the case a word is typed in. All Mathematica functions and procedures start with capital letters, but the rest of the letters must be lower-case, unless they effectively start a new word for example, FactorInteger. 4. Ending an expression with a semicolon tells Mathematica to suppress that output. If you're not getting any answers at all, check for semicolons. There are two important tricks to keep in mind: Getting Help from the Computer 1. If you want to know something about a Mathematica function or procedure, just type a question mark followed by the name of the procedure. Example:?FactorInteger After you press Enter Mathematica responds:

x^y FactorInteger[n] gives a list of the prime factors of the integer n, together with their exponents. To get still more help, type two question marks in front of the name. 2. If you can't remember the full name of a Mathematica function or procedure, but can remember a few letters at the start, there is a "fill-in" capacity: after typing a few letters, type command-k (simultaneously press down the "open apple" key, located next to the space bar, with the letter "K"). Mathematica will either finish typing the name for you if there is only one command which starts with those letters or will present you with a "pop-up menu," a list of possible matching commnads. By clicking on one of these you select the complete command. Some Common Mathematica Functions x to the y-th power (exponentiation). Try 0^0, 0^-1. x*y x times y. x y x times y (one or more spaces separate the variables). 2 x 2 times x. Any numerical constant can replace 2. But note that x2 doesn't mean x times 2, it's the name of a new variable. Sqrt[x] Square root of x. Exp[x] E^x. NOTE: the base of the natural logs is denoted by E, not e. Start with a capital letter! Log[x] Natural logarithm of x. Try Ln[x] just to see what happens. Log[b,x] Logarithm of x to the base b. Try Log[-1,2]. Can you figure this out? Sin[x], Cos[x], Tan[x], Csc[x], Sec[x], Cot[x] ArcSin[x], ArcCos[x], ArcTan[x], ArcCsc[x], ArcSec[x], ArcCot[x] Trigonometric functions. NOT Ctn[x]. Inverse trig functions. Remember to capitalize not only the first letter A, but also the first letter of the trig function you're inverting. n! Factorial of n. Factorial[n] also works. Abs[x] Absolute value of x (even if x is complex). Note that x doesn't work. Round[x] Closest integer to x. Floor[x] Largest integer <= x. Floor[2.1] = 2, but Floor[-2.1] = -3. Ceil[x] Smallest integer >= x. Mod[n,m] Remainder on division of n by m (for integers only; use PolynomialRemainder[p,q,x] if p and q are polynomials in x). Random[] Random number between 0 and 1. Max[x,y,...] Largest of x, y,... If x and y are unassigned variables,

Min[x,y,...] Mathematica won't have any idea which is largest, and will return Max unevaluated. Smallest of x, y,... (duhhhh) E Pi I Some Mathematica Constants Base of the natural logs, about 2.71828. Ask for N[E,50]. About 3.14159... You'll forget at least once and write pi, which Mathematica will treat as a new variable, leading you to bewilderment. The square root of -1. NOT i; remember, CAPITALIZE THE FIRST LETTER. You saw this guy when you asked for Log[-1,2]. Infinity Try Infinity+Infinity, Infinity/Infinity, then ask Mathematica what the devil ComplexInfinity is. % The result just generated. %% The result just before that. %%% The one just before that; and so on... %n The result generated on output line Out[n]. x = value Assign a value to the variable x. x = y = value Using Previous Results (These save a lot of typing!) Assigning Values Assign a value (the same value) to BOTH x and y. Clear[x] Clear the value previously assigned to x (if any). x := value Assign the value to x, but don't do it right away; wait until x is actually used. x == y Tests whether x is equal to y. You may think it a perversion to take the innocent = sign, which is used in mathematics to denote a statement of fact ("x is equal to y"), and turn it into a verb ("x = y" becomes "set x equal to y"), after which you must invent a monster == to regain your statement of fact ("x is equal to y"), but there you have it computer science majors will recognize "C". Values you assign remain assigned until you change them!! If you set x = 5 and then type Solve[x^2-2x + 1 == 0, x]

(asking Mathematica to solve the quadratic equation for x), Mathematica returns an empty solution set! You have asked it to solve the equation 5^2 + 2*5 + 1 == 0, and Mathematica realizes this has no solution. Moral: to be safe, before using a variable such as x you should always type Clear[x]. Replacements expr /. x->value expr /. {x- >xval,y->yval} Replace every occurrence of x in the expression expr with value. (Read: "expr, given that x is changed to value.") Perform several replacements simultaneously. For example, suppose we want to check that Mathematica got the correct roots of the quadratic equation x^2-7x - 3 == 0. Remembering the fiasco where we had set x = 5, we begin with Clear[x]; Solve[x^2-7x-3==0,x] Mathematica replies Out[5]= 7 - Sqrt[61] 7 + Sqrt[61] {{x -> ------------}, {x -> ------------}} 2 2 The result is a list of transformation rules. Now we type x^2-7x-3/.%5[[1]] that is, we ask for the value of x^2-7x - 3, given that the first transformation rule in %5 is applied. To understand the [[1]], read the next section on Lists and Iterators. Lists and Iterators {a,b,c} A list (in this case, of the three objects called a, b and c). {} A list (of no objects!). a[[n]] The n-th item in the list a. Note the double brackets!! Sum[a[[n]],{n,3,7}] The sum a[[3]] + a[[4]] + a[[5]] + a[[6]]. Here {n,3,7} is what is called an iterator, that is, a statement which says to repeat something; in this case, it means the sum of a[[n]] for n = 3 to 7, inclusive. Sum[a[[n]],{n,1,7,2}] The sum a[[1]] + a[[3]] + a[[5]] + a[[7]]. This form of the iterator says to let n run from 3 to 7, inclusive, incrementing n by 2 at each step. (That's an easy way to get the sum of all the odd terms, or all the even terms.) Plot[f[x],{x,a,b}] Plot the graph of the expression f[x], from x = a to x = b, inclusive. {x,a,b} is still called an iterator, because x takes on values between a and b, although of course not all real values between a and b.

Transforming Algebraic Expressions Expand[expr] Multiples out products and powers. ExpandAll[expr] Apply "Expand" everywhere throughout in expr. Factor[poly] Factors a polynomial over the integers. FactorTerms[poly] Pull out common factors that appear in each term of a polynomial. Together[expr] Put all terms over a common denominator. Apart[expr] Separate into terms with simpler denominators. Cancel[expr] Cancel common terms between numerators and denominators. Collect[expr,x] Group together powers of x. Simplify[expr] Try a sequence of algebraic transformations and give the simplest form of expr found. Numerator[expr] The numerator of expr. Denominator[expr] The denominator of expr. f[x_] := x^3- x Defining a Function Define a new function f. Note the underscore on the x on the left side of the statement! It must be there; it tells Mathematica to treat x as a pattern; thereafter, when you type something like f[a+b], Mathematica will then immediately consider that to be the same as (a+b)^3-(a+b). Derivatives and Integrals D[y,x] The derivative of the expression y with respect to x. f'[x] The derivative of f[x] with respect to x (if f has previously been defined as a function). D[y,x,x], f''[x] Second derivative with respect to x. Integrate[f[x],x] The indefinite integral of f[x] with respect to x. Mathematica will try to evaluate the integral; if it cannot, it will return your expression unchanged. Integrate[f[x],{x,a,b}] The definite integral of f[x] with respect to x on the interval [a,b]. If Mathematica cannot evaluate the integral, it will return your expression unchanged. Miscellaneous Useful Procedures Solve[x^2+x==1,x] Solve the given equation x^2 + x = 1 for x. Note that we must use the double-equals sign. Also, only an exact solution will satisfy Mathematica. You can also solve systems of equations, e.g. Solve[{x+y==1,x^2+y^2==1/2},{x,y}] solves those two

Roots[f[x]==0,x] NRoots[f[x]==0,x] equations for x and y. (Can you do this by hand?) Finds the roots of a polynomial equation. Only exact solutions will be reported. Finds the roots of a polynomial equation, but numerically, i.e. approximately. FindRoot[f[x]==0,{x,a}] Find roots of f[x] = 0 numerically, starting at x = a. Works for non-polynomials, but may fail to find the roots, or all of the roots, even when they exist. Yes, Virginia, There Is a Limit Limit[f[x],x- >a] The limit of f[x] as x approaches a. a can be Infinity or -Infinity. You won't be asked to use this very much, for fear of corrupting your morals.