Show Menu
Cheatography

Final Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

final exam

Data types: Numeric data,S­ing­les­,Do­ubles,› Intege­rs,­Cha­racter data,L­ogical data,A­rrays of arrays (cell arrays and structure arrays), symbolic data
manipulate expression by hand: STEM courses evaluate u on how think,­Never trust anything comes out of a computer.Familiar with CAS:Scientific expres­sions can become unwieldy to work by hand,Human mistak­esC­are­les­s,A­bse­nt-­min­ded­,Easily distra­cte­d,B­adh­and­wri­ting.
symbolic engine is MuPad by SciFace Software previously MAPLE; MuPad was discon­tinued as a stand-­alo­nep­rogram, and now is only available in MATLAB.
: declaring MATLAB symbols:
y = sym('x') 
give y a value of x ;
syms x
give x a value of x;
p = sym('a(1-e^2)') Output: p = -a(e^2 - 1)
expres­sion:can define a symbol­con­taining symbols that are otherw­ise­una­vai­lable in the Workspace;
my_p = sym('p == a(1-e^2)')› Output:p == -a(e^2 - 1)
entire equation
simplify
:simpl­ify­exp­res­sions or equations using MuPad’s rules(use
pretty
with
simplify
:easier to read);
expand:
multiplies out all of the parts of the expression or equation;
factor
: factors the expression or equation;
collect
: collects like terms;
numden
:find the numerator and denomi­nator of an expression NOT equations;
solve
:(symb­oli­cro­ot-­fin­ding) set the expression equal to zero and solve it, solve systems of linear or non cannot solve higher­-order systems with linear algebra, results are assignedin alphab­etical order;
subs
: substi­tuting# or other ;
 symfun
: symbolic function; can usethe result to evaluate different inputs:
syms x y

f = x^2 + x

g = symfun­(f,y)
-------
g(y) = x^2 + x
;
ezplot
:plotting for symbolic expres­sion, need a defult range:
f = sym('x^2') 
ezplot(f, [-10,10])

:Derivative: instan­taneous time rate of change of a slope; an analogous word is differ­ential
diff(f)
calculates the symbolic first derivative of a symbolic functi­onwith respect to the default indepe­ndent variable;
diff(f­,sy­mvar)
calculates the symbolic first derivative of a symbol­icf­unction with respect to the default indepe­ndent variable
symvar
(symvar has tobe in single quotes if the variable does not already exist as a symbolic
variable);
diff(f,n)
calculates the symbolic nth derivative of the symbolic
function with respect to the default indepe­ndent variab­le;­dif­f(f­,sy­mvar,n) or
diff(f­,n,­symvar)
calculates thesym­bolic nth derivative of the symbolic function f with respect to the symvar­----; Integral: the integral represents the area under a curve and above
int(f)
calculates the symbolic single integral of a symbolic function with respect to the default indepe­ndent variable;
int(f,­symvar)
;
int(f,a,b)
evaluates theresults of the integral over the symbolic or numeric range;
 int(f,­sym­var­,a,b)
;Differ­ential Equation (DE): An equation containing an unknown function and itsder­iva­tives;
dsolve
:calculate solutions to differ­ential equations;
D
specify derivitive if you need to specify a nth order deriva­tive, specify n afterthe symbol D ex:
  D4y
;
 dsolve­(eq­uation)
;
dsolve­(eq­uat­ion­,sy­mvar) 
;
dsolve­(eq­uat­ion­,co­ndi­tio­n1,­con­dit­ion2, …,cond­itionN, symvar) 
. diff can also be used to calculate the differ­ences then finding slope between points.
Converting Symbolic Expres­sions to Anonymous Functions
a. Only available starting in versions of MATLAB starting with version 2007B (this
is one of the features that was incorp­orated with the adoption of MuPad)
b. To create anonymous symbolic functions, use the
 matlab­Fun­ction
{{fa-flag}
}syms x

y = x^2 - x + 1

dy = diff(y)

f = matlab­Fun­cti­on(dy)

f(1)

:› Interp­olation: consists of “method[s] of constr­ucting
new data points within the range of a discrete set of known data points.
interp1
;
yi = interp­1(x­,Y,xi)
Interp­olates to find yi, the
interp­olated function values at the points in the vector or array xi.x contains your known data points (whose functions values are Y),which must be a vector, though xi can be a scalar, vector, ormult­idi­men­sional array. yi will always be the same size as xi;
yi = interp­1(Y,xi)
x = 1:N, where N is length(Y) (for a vector)or size(Y,1) (for a matrix);
yi = interp­1(x­,Y,­xi,­method)
;
yi = interp­1(x­,Y,­xi,­met­hod­,'e­xtrap')
.
Extrap­olation consists of “the process of estima­tin­g,b­eyond the original observ­ation range, the value of a variable on the basis of its relati­onship with another variable.Some interp­olation are excell­ent­,yi­elding useful results BUT extrap­olation can be a fool’s errand. Linear Interp­olation:points (1, 3) and (-2, 5) Use linear interp­ola­tionto find estimate the y-value at the point x = −0.5?
› ( slope intercept form)𝑦 = 𝑚𝑥 + 𝑏-----­---­𝑚=5­-3/­-2-­1=2­/-3­=𝑦=­-2/­3𝑥+­𝑏--­---­---to find b: Substitute in one
of points 𝑦 = 𝑚𝑥 + 𝑏= 5=−2/3(−2) +𝑏→𝑏=3 2/3 ------­----the line is 𝑦 =-2/3 𝑥 + 3 2/3------ evaluate it at 𝑥 = −0.5 to find 𝑦(−0.5): 𝑦 −0.5 = −2/3 (−0.5) +3
𝑦(−0.5)=4
Approc­h(p­oin­tsl­ope­form) 2:𝑦 − 𝑦1 = 𝑚 (𝑥 − 𝑥1)
find the slope m=-2/3
𝑦−3=−2­/3(­𝑥−1­)→𝑦­−3=−2/3 𝑥 +2/3--­---­--𝑦­=−2­/3𝑥­+2/3+3 →𝑦=−2/3𝑥+3 2/3
the line is 𝑦 =-2/3 𝑥 + 3 2/3 evaluate it at 𝑥 = −0.5 to find 𝑦(−0.5): 𝑦 −0.5 = −2/3 (−0.5) +3
𝑦(−0.5)=4
:Linear Interp­olationeasy to do, BUT NOT best go-to solution if need accuracy.Spline Interp­olation:A spline is to use a different polynomial between each pair of discrete points.Cubic splines correct for this flaw by ensuring that at the data points, the adjacent splines have the same 0th, 1st and 2nd deriva­tives; Curve fitting is “the process of constr­ucting a curve, or mathem­atical function, that has the best fit to a series of data points, possibly subject to constr­aints
 polyval
,
  polyfit
; / operator use it to solve least squared proble­ms(less error).Goal is the minimize the residuals: the difference between the actual and predicted values at a given point (i.e. the error).take its derivative and look to see where it is zero (this gives us the extrema – the extreme points of the function) to find the minimum of function; numerical differ­ent­iation tends to amplify noise.Taylor series is a series expansion of a function 𝑓(𝑥) about a given point 𝑎.special case, known as Maclaurin series, of the Taylor series exists in which 𝑎 = 0.The “Big O” notation (asymp­totic notation) indicates higher order terms (H.O.T.s). Central Differ­ence:
gradient
; Root Finding: zero a function;
fzero
.
: finding area under curve:› Rectan­gle­s,T­rap­ezo­ids­,Pa­rab­olas.Riemann Sums :If you average the left and right Rieman­nsum, you get the trapez­oidal sum.Left Riemann Sum:fits rectangles underneath curve using left of interval as location for hight of rectangle; Overes­timate if f decreasing & vice.v­ersa.Right Riemann Sum: like left Riemann Sum but in right instead; Overes­timate if f is increasing and vice versa.Middle Riemann Sum: Approx­imates the function by its value at themiddle point of the subint­erval, yieldi­ngm­ultiple rectangles with a base of Δx and the average height between the left and right. This better than R & L Riemann sum.Trapez­oidal Rule:Appro­ximates the function by fitting trapezoids underneath the curve.Simpson’s Rule:› Approx­imates the function by fitting parabolas under the curve. : must use an even number of intervals; › Pros and cons of using this versus trapezoids – more comput­ati­onally expensive, but a better fit at times. Left-point and right-­point sums were just wrongmid-point, trapez­oidal and Simpson’s) all got the correct answer. The choice between these depends on what the data looks like and what comput­ational expense you can tolerate.solve differ­ent­ial­equ­ations:Euler’s Method( forward Euler method), Runge-­Kutta methods. “state­-space: breakyour system down into a system of simult­aneous first order differ­ential equations.The number of first order equations will be equal to the sum of number of indepe­ndent variab­le(s) times the order.
 

tables

Symbolic Command
Descri­ption
Symbolic Command Descri­ption Numeric Analog
ezplot
2D plot
plot
ezmesh
Wireframe mesh
mesh
ezmeshc
Contour plot under wireframe mesh
meshc
ezsurf
Surface plot
surf
ezsurfc
Contour plot under surface plot
surfc
ezcontour
Contour plot
contour
ezcontourf
Filled contour plot
contourf
ezplot3
3D plot
plot3
ezpolar
Polar plot
polar