Table of Contents - University of the West Indies
3 Pages
English

Table of Contents - University of the West Indies

Downloading requires you to have access to the YouScribe library
Learn all about the services we offer

Description

  • cours - matière potentielle : outlines
  • cours - matière potentielle : descriptions
  • online business development unit
  • bsc gen
  • franklyn bsc chem engineering
  • agricultural engineering ext
  • uwi
  • ext
  • phd
  • edu
  • 4 edu
  • bsc
  • agriculture

Subjects

Informations

Published by
Reads 23
Language English
AbbreviationsPatterns [DC, Tut] Mathematicacommands summary (cheat sheet) approx Approximation Blank: any expr arg Argument Hugo Touchette char Character Double blank: any seq of expr School of Mathematical Sciences, Queen Mary University of London cnt Counter Last updated: October 8, 2010cond ConditionTriple blank: zero or more args dist Distribution xAny expr namedx elem Element Equalities, assignments [DC] x hExpr namedxwith headh eqn Equation eval EvaluationxExact matchingx =Assign value expr Expression x+2/.x->2Output: 4 :=Also used for repeated evalDelayed eval fct Function x:pattNamed expr matchingpatt ==Equalitypatt Pattern f[aˆ b]/.f[x:ˆ ]->p[x]Output:p[aˆ b] rand Random =.Clear valueSame asClear str String x :vOptional arg with default valv ===Same asBoolean testSameQ val Value var Variablex h:vTyped arg with optional valv f[x ]:=f[x]=...Remember computed vals f[n ]fwith any named argn Rules and replacements [DC, Tut] f[n ,n ]fwith identical args xˆ nxto any named powern patt->exprTransformation ruleCan be assigned to names x ˆnAny expr to any power patt:->exprSame asDelayed rule:> a +bSum of two named exprs expr/.ruleReplacement SameasReplaceAll {a1 ,a2}List of two named exprs 1+2 x/.x->3Output: 7 patt/;condPattern with condRead:pattsuch thatcond expr/.{rule1,rule2}Multiple replacements (x /;NumberQ[x]&&Im[x]==0)Any real number expr//.ruleSame asReplace until no changesReplaceRepeated rule/;condRule with cond Applications, functions and maps [DC, Tut]patt?testPattern matching boolean test f[x ?NumberQ]:=x+2 f@exprPrefix formf[expr] (patt1|patt2|...) patt1orpatt2or ... expr//fPostfix formf[expr] {1,x,xˆ 2,yˆ 3})->q/.(x|xˆ nOutput:{1,q,q,yˆ 3} x˜f˜yInfix formf[x,y] expr/.ruleReplacement inexprwithrule f@@exprReplaces the head ofexprbyfSame asApply[f,expr] x+2/.x->2Output: 4 Plus@@{1,2}Output:1 + 2 = 3 f[a]+f[b]/.f[x ]->xˆ2Output:aˆ 2+bˆ 2 Similar to:f[x]/.f->gOutput:g[x] Position[f[a],g[b],f[b],f[x ]]Output:{{1},{2}} f/@listMapfonlistSame asMap[f,list] {1,x,xˆ 2,xˆ 3}->r[n]/.xˆ nOutput:{1,x,r[2],r[3]} f/@exprMapfon parts ofexpr Except[c]Anything exceptc Map[f,a+b]Output:f[a]+f[b] Except[c,patt]Patternpattexceptc Function[x,body]Function with argxSame as pure functions 2Cases[{1,0,2},Except[0]]Output:{1,2} Function[x,xˆ 2][n]Output:n 2 2Cases[{1,x,0},Except[0, Integer]]Output:{1} Map[Function[x,xˆ 2],a+b]Output:a+b Function[{vars},...]Many args Type specificationFiles [DC] body&Pure (anonymous) function IntegerNEsc-dsN-Esc Import["file"]Import file or url (#ˆ 2&)[5]Output: 25 RealREsc-dsR-Esc 2 2 Export["file",expr]Exportexprin file Map[#ˆ 2&,a+b]Output:a+b ComplexCEsc-dsC-Esc ImageResolution->ptsImage resolution in pts (1+g[#])&/@{1,2}Output:{1+g[1],1+g[2]} RationalZEsc-dsZ-Esc ReadList["file"]Returns list from file #nnth arg in pure function ListList type or head <<File‘Load content of file ##Seq of all args SymbolAny symbol StringString type of head Formatting [DC]Shortcuts [DC] HeadTypeHead Ctrl-@FullFormDisplay full head form MatchQ[xˆ 2,Power] Ctrl-/Fraction MatrixFormDisplay in matrix form CtrlSuperscript ColumnDisplay in column form Ctrl-Subscript TableFormDisplay in tabular form Ctrl-EnterNew row TreeFormDisplay in tree structure Ctrl-,New column
Lists [DC, Tut] {i,imax} {i,imin,imax,di} Table[expr,cnt] list[[i]] list[[i,j]] list[[i;;j]] Drop[list,n] Drop[list,{n}] Extract[expr,list] Array[f,n]
Range[n] Range[nmin,nmax,dn] Position[expr,patt] Count[list,patt] Min[list], Max[list] Append[expr,elem] AppendTo[expr,elem] Prepend[expr,elem] Insert[list,elem,n] Delete[expr,elem,n] ReplacePart[expr,i->new] ReplaceList[expr,rule] Flatten[list] Flatten[list,n] Take[list,n]
Cases[list,patt]
Cases[list,patt,n] Cases[list,rule] Select[list,boolean] Position[expr,patt] Join[l1,l2,...] Union[l1,l2,...] Riffle[{e1,e2,...},x] Intersection[l1,l2,...] Subsets[list] DeleteDuplicates Thread[f[{a,b,c}]] Sort[list] Reverse[list] PadLeft[list,n,x] PadRight[list,n,x] Partition[list,n] Split[list] Tuples[list,n] Permutations[list] Outer[f,l1,l2]
Boolean functions [DC]Programming [DC, Tut1, Tut2] Simple counter from 1 toimax SameQ[x,y]Same? (x===y) Do[expr,cnt]Do loop Counter with steplistdi OrderedQ[list]ordered? While[test,body]While loop Generate listMultiple counters possibleIntegerQ[x]xinteger? If[cond,t,f]If statement iSame asth elem (list or expr)Part[list,i]orlist[i]MemberQ[list,patt]Elems matchpatt? Return[expr]Outputexprand stop (i, j)elem Sameaslist[[i]][[j]] MatchQ[expr,patt]exprmatchespatt? Module[{x,...},expr]Proc with local vars RangeitojSame asPart[list,i;;j] ValueQ[expr]exprhas value? (vars localization) FirstnLast ifelems dropped-n AtomQ[expr]expris atomic? Block[{x,...},expr]Eval with global vars nth elem droppedFreeQ[expr,patt] exprfree ofpatt? With[{x=x0,...},expr]Local constants Extract inexprat poslist EvenQ[n]neven integer? Trace[expr]Trace eval ofexpr {f(1), f(2), . . . , f(n)}OddQ[n]nodd integer? Compile[{vars},expr]Compiled expr Array[1+#ˆ 2&,2]Output:{2,5}PrimeQ[n]nprime integer? i++Incrementation {1,2,3, . . . , n}Same asexprArray[#&,n] NumberQ[expr]a number? i--Decrementation Full syntaxNumericQ[expr] exprnumerical? i+=diIncrement bydi List matching positionsPolynomialQ[expr,var] expra polynomial? i-=diDecrement bydi Number of matchesVectorQ[expr] expr1D array (list)? i*=cMultiply bycand override val Min, max of listSame as:exprMin[i,j,...] MatrixQ[expr]2D array (list)? i/=cDivide bycand override val exprwithelemadded at endDigitQ[str]All digits instr? Append and updateexprSame asexpr=Append[expr,elem] LetterQ[str]All letters instr? Inset at beginningSee also:PrependTo Inserteleminlistat posn Strings [DC, Tut] Deleteeleminlistat posn "chars"String Replacesexpr[[i]]bynew ToString[expr]Transformsexprto string Replace according torule StringJoin[str1,str2,...]Join stringsSame as<> Flattens nested lists StringLength[str]Number of chars instr Flattens to leveln StringTake[str,n]nfirst chars ofstrLast if-n Take firstnelem StringDrop[str,n]Firstnchars droppedLast if-n Take[#,1]&/@{{1,2},{3,1}}Output:{{1},{3}} StringInsert[str1,str2,n]Insertstr2at posn Elems oflistmatchingpatt 2StringPosition[str,substr]Start and end ofsubstrinstr Cases[{2,xˆ 2},xˆ n]Output:x StringCount[str,substr]Number of occurrences ofsubstr Firstnmatchingpatt StringReplace[str,rule]Replace with rule Results for whichruleapplies StringMatchQ[str,patt] pattappears instr? Boolean selection inlist StringFreeQ[str,patt] strfree ofpatt? Pos wherepattappears StringSplit[str]Split where whitespace Join lists StringSplit[str,patt]Split according topatt Set unionSame asSortAlphabetical (canonical) sort {e1,x,e2,x,...} DateString["elem"]String version of date Set intersectionSame asCharacters[str]List of chars All subsets oflist ToUpperCase[str]Capitalize Delete duplicates from list ToLowerCase[str]Lower case {f[a],f[b],f[c]} CharacterRange["char1","char2"]List fromchar1tochar2 Sortslist patt.. pattfollowed by symbols listin reverse order WhitespaceWhite space Addxntimes left oflistPad with 0 if nox Addxntimes right oflist Dynamic objects [ DC, Tut2 ] Partitionlistinnsublists Dynamic[expr]Dynamically updated expr Splitslistin identical elems DynamicModule[{vars},...]Module with dynamical vars n-tuples oflist Manipulate[expr,{u,...}]Interactive widget Permutations Outer (cartesian) product
Useful functions Sum[f,{i,imin,imax,di}] Product[f,{i,imin,imax,di}] Mod[m,n] Solve[f[x]==0,x] Expand[p] Factor[p] Length[expr] Numerator[expr] Denominator[expr] Options[cmd] SetOptions[cmd] Evaluate[expr] Piecewise[{{val,test},...}] InverseFunction[f][x] Nest[f,x,n] NestList[f,x,n] FixedPoint[f,x] FixedPointList[f,x] NestWhile[f,x,test] NestWhileList LinearModelFit NonlinearModelFit GraphPlot[m] GraphData["name"] FinancialData["tag","date"] CountryData["tag","prop"] WeatherData["tag","prop"]
Sum Product Remainder ofm/n Solves polynomial eqn Expand polynomialp Factorizep Number of elems inexpr Numerator ofexpr Denominator ofexpr Display options forcmd Set options forcmd Explicit eval Piecewise definition Inverse fct n-fold fct composition List of compositions Iterate until fixed point Iteration list While iteration While iteration list Linear model Nonlinear model Graph (network) for adjacencym Graph withname Financial data fromdate Country data Weather data
Probability and statistics [DC] RandomReal[{a,b}]Uniform rand real in[a, b] RandomReal[dist]Rand real fromdist RandomInteger[{i,j}]Uniform integer in[i, j] RandomInteger[dist]Rand integer fromdist RandomSample[list,n]nsamples fromlist RandomSeed[]Reset seed PDF[dist,x]Density fct ofdist CDF[dist,x]Cumulant density fct ofdist Histogram[list,w]Histogram (bin widthw)
BinCounts[list,w]Counting dist oflist(bin widthw) Mean[list]AlsoMean[dist] Variance[list] StandardDeviation[list] ChiSquareDistribution[ν] ExponentialDistribution[λ] NormalDistribution[µ,σ] BinomialDIstribution[n,p] BernoulliDistribution[p]
From[0,1]if no arg
Uniform0or1if no arg
Option:"Probability" "ProbabilityDensity"
Linear algebra [DC] a.b Cross[a,b] Norm[a] IdentityMatrix[n] Diagonal[m] Diagonal[m,k] Dimensions[m] Inverse[m] Det[m] Tr[m] Transpose[l] Eigenvalues[m] Eigenvectors
Parallel computation [DC, Tut] Dot or matrix product Parallelize[expr]Direct parallelization Cross product ParallelEvaluate[expr]Eval on kernels Euclidean norm DistributeDefinitionsPut def on kernels n×nidentity matrix ParallelNeedsPackage on kernels Diagonal ofm ParallelMapParallelMap kth elem in diagonal ofm ParallelSumParallelSum Dimensions ofm ParallelProductParallelProduct Inverse square matrixm ParallelTableParallelTable Determinant square matrix ParallelDoParallelDo Trace matrix or tensorm ParallelSubmitSubmit to kernel Transpose first two levels Collect withWaitAll Eigenvals square matrix WaitAllResults from kernels Eigenvects square matrix
Numerical routines [DC, Tut] N[expr]Numerical eval ofexpr NSolve[eqn,var]Approx polynomial eqn FindRoot[eqn,{x,x0}]Approx eqn in varxwith seedx0 FindRoot[eqn,{x,x0,a,b}]Approxeqnin[a, b] NDSolve[eqn,y,{x,a,b}]Solve differentialeqn NIntegrate[f,{x,a,b}]Numerical integration. Methods: "SymbolicProcessing"->0 "GlobalAdaptive" "LocalAdaptive" "Oscillatory" "PrincipalValue" "MonteCarlo" "AdaptiveMonteCarlo" FindMinimum[f,x,x0]Find local min with seedx0 NMinimize[f,x]Find global min. Methods: "DifferentialEvolution" "NelderMead" "RandomSearch" "SimulatedAnnealing" NumericalCalculuspackage: NLimit[expr,x->x0]Numerical limit ND[expr,x,x0]NumericalDatx0 NSeries[f,{x,x0,n}]Numerical series Notes
Initial cond specified ineqn
Fully numerical eval Default
1D integrals; automatic detection Cauchy principal value Random sampling
Option:"SearchPoints"
Option: Option:
"SearchPoints" "SearchPoints"
CopyrightHugo Touchettec 2010 Available at:http://www.maths.qmul.ac.uk/˜ht Mathematica is a trademark of Wolfram Research