* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download p - Chris Hecker
Classical central-force problem wikipedia , lookup
Probability amplitude wikipedia , lookup
Dynamical system wikipedia , lookup
Symmetry in quantum mechanics wikipedia , lookup
Analytical mechanics wikipedia , lookup
Rigid body dynamics wikipedia , lookup
Centripetal force wikipedia , lookup
Tensor operator wikipedia , lookup
Laplace–Runge–Lenz vector wikipedia , lookup
Bra–ket notation wikipedia , lookup
Neat Stuff from Vector Calculus & Related Subjects Chris Hecker [email protected] definition six, inc. & Maxis Related Subjects scalar calculus linear algebra optimization & constraints vector calculus classical mechanics, dynamics differential & integral calculus differential geometry Intro & Prerequisites • this is a total hodge-podge, not a gentle introduction – lack of rationale for caring about this stuff, trust me? :) • stuff that I found non-intuitive or hard to figure out • tour of fairly basic examples building on themselves to get firm grounding and intuition in calculus concepts for the kinds of math games do – touch on lots of different areas during tour, many sidestreets • comfortable with algebra, linear algebra • need to understand scalar calc, at least at the plug’n’chug level of differentiating functions – f(x) = ax2+bx+c f’(x) = 2ax + b What is a Function? • a function maps values from the domain to the range uniquely – can be multivalued in range, but not domain f : Rn Rm y f (x) x cos q f (q ) y sin q f ( x, y) x 2 y 2 1 0 q x f (u, v) y 8 6 2 4 2 y f (x) 1 0 -1 0 0 1 2 -1 z f ( x, y) x 2 y 2 1 What is a Derivative? • derivative is another function that maps changes in the domain to changes in the range, “normalized” y y f ( x x) y f ( x x) f ( x) x x y f (x) y x Derivatives are Linear • the key insight of calculus: the change is so small that you can ignore it anytime it’s multiplied by itself...so, you can treat any continuous function as linear if you’re zoomed in far enough (to 1st order) – “continuity” keeps us from dividing by zero – normalization makes the numbers finite f ( x0 x) f ( x0 ) f ( x0 )x 1 2 f ( x0 )x 2 f ( x0 x) f ( x0 ) f ( x0 ) x y f (x) y f (x) boom! x0 x0 Random but Nifty Example of Ignoring Infinitessimals (nothing up my sleeve!) • prove infinitessimal rotations in 3D are vectors (add, commute, etc.) – angular velocity is a vector, cross product differentiates rotating vectors finite rotation: r ' Rr RT R 1 infinitessimal rotation: r ' (1 )r r r infinitessimal rotations add and commute: (1 1 )(1 2 ) 1 1 2 1 2 1 1 2 infinitessimal rotations are vectors: (1 )(1 )T 1 T 1 3x3 skew symmetric matrices T are isomorphic to vectors angular velocity differentiates with cross product: dr r 'r r vec ( ) r dr 1 v dt r ~r r dt Scalar Derivatives: a line • how does y (or f(x)) change for a change in x? – for lines, the change (derivative) is constant everywhere – drawn as red vector, but actually a scalar, “slope” y f (x) a 1 f ( x) ax b f ' ( x) a df a dx df adx f :R R df : R R Scalar Derivatives: a curve • for curves, the derivative is position dependent – derivative is a function itself, mapping change in domain to change in range – both direction and magnitude, but still a scalar y f (x) f ( x) ax 2 bx c f ' ( x) 2ax b df (2ax b)dx f :R R df : R R The Shape of Matrix Operations • vectors are columns of numbers in this talk, not rows • we right-multiply matrices by column vectors: v’ = Mv • matrix & vector ops “fit together” nicely • keeping the shapes right is the key to sanity with vector calc • “m by n * n by p = m by p” b11 p b11 b12 b13 b14 b21 Ab=c b31 n b21 b22 b23 b24 AB=C n b31 b32 b33 b34 a11 a12 a13 c11 c12 c13 c14 m a21 a22 a23 c21 c22 c23 c24 a11 a21 a31 a12 a22 a32 a13 c11 a23 c21 a33 c31 a·b = c = aTb = c a11 a12 • this is why “v’=vM” makes no sense for column vectors – either you’re using row vectors, or you’re confused – either way, you’re in for some pain when trying to do real math • because all math books use columns for vectors and rows are special • early computer graphics books got this backwards, and hosed everybody a13 b11 b21 b31 c11 Shape of Derivatives df needs to accept a domain linearly (ie. right-multiplied vector or scalar) to produce a range • scalar valued function of scalar – y=f(x) dy =dfdx df d • vector valued function of scalar – v=f(t) dv = dfdt • scalar valued function of vector – z=f(x,y) d d • vector valued function of vector – p=f(u,v) d Shape of Derivatives (cont.) • scalar valued function of vector: expands to row vector – the resulting range value depends on all the domain values – the differential needs a slot for a delta/change in each domain dimension...so it must be a row vector, there’s no T or · – z=f(x,y) f f f f f dx dz dx dy d x – dz=dfdx x y x x y dy df = d dz = dfdx = d • vector valued function of vector: expands to matrix – p=f(u,v) df = d dp = dfdx = d Derivatives: a parametric function “a vector function of a scalar” • for a change in the parameter (domain), how does the function (range) change? – in this case, differential is a vector x cos q y sin q q dx sin qdq sin q dq dy cos qdq cos q f : R R2 df : R R 2 Derivatives: a scalar function of a vector “height field” • differential is not in range of function z f ( x, y) ax 2 bxy cy 2 d 2 1.5 dz df 1 f f dx dy x y 0.5 (2ax by )dx (bx 2cy )dy 0 0 0.5 1 1.5 2 2ax by 8 6 2 4 2 bx 2cy dx dy column vector 1 0 -1 0 0 1 2 -1 row vector f : R2 R df : R 2 R Derivatives: a scalar function of a vector • view “height field” as implicit surface in 3d g ( x , y , z ) z f ( x, y ) – write g(x,y,z) > 0 above surface – differential is surface normal (not unit) dg g g g dx dy dz x y z dx 8 6 2ax by 2 4 2 1 0 -1 bx 2cy 1 dy dz 0 0 1 2ax by g g bx 2cy x 1 T 2 -1 f : R3 R df : R 3 R Derivatives: a scalar function of a vector • example plane n p d 0 1 n 1, 1 x p y z x yzd 0 z f ( x, y ) x y d g ( x , y , z ) z f ( x, y ) g ( x, y , z ) z x y d 2 1 1 0 -1 0.5 -2 -1 0 -0.5 -0.5 0 0.5 1 -1 dg g g g dx dy dz x y z dx 1 1 1 dy dz f : R3 R df : R 3 R Derivatives: a scalar function of a vector • example sphere g ( x, y, z ) x 2 y 2 z 2 1 g g g dg dx dy dz x y z dx 2x 2y 2 z dy dz f : R3 R df : R 3 R A Surface Normal is Not a Vector! this is why you need to keep shapes distinct • vector is a difference between two points • normal is “really” a mapping from a vector to a scalar points &vectors transform like this: a' Ta b' Tb v ba v' Tv Tb Ta b'a' v' b'a' n normals transform like this: v n vT n 0 v'T n' 0 n' Sn, v' Tv (Tv)T Sn 0 vT T T Sn 0 TTS 1 v a b S T T Normals and Vectors Example • scaling an ellipse g ( x, y) ax 2 y 2 1 g 2ax x x values for y=0 1 0.5 0.5 -0.5 -1 2y 1 1.5 2 a 1 x 1 4 12 2 1 4 Derivative of Vector Mappings • barycentric coordinates in 2D triangle – vector function of a vector – if square, can invert Jacobian to find du,dv given dp – function is linear in this case, but works generally – determinant of Jacobian is how areas distort under function p2 e2 p f (u, v) p0 e1u e2v p p1 e1 p0 f x f dp du u f y u u f x v du e 1 f y dv v e2 du dv Jacobian matrix f : R2 R2 df : R 2 R 2 Barycentric Coordinates in 3D Triangle • now jacobian is 3x2 p f (u, v) p0 e1u e2v – can still find du,dv from dp with least squares f x u f y f dp du u u f z u p2 e2 du e2 dv Ax b AT Ax AT b e1T du T 2 e e1 e1T dp T 2 e dp p e1 p0 f x v f y du e1 v dv f z v p1 e2 dv e1T e1 e2T e1 e1T T 2 e dp e1T e2 du e2T e2 dv same as projecting dp down into triangle f : R2 R3 df : R 2 R 3 Implicit Functions • equalities (constraints) subtract off DOFs f(x,y) = 0 • explicit to implicit is easy: z = f(x,y) g(x,y,z) = z – f(x,y) =0 • implicit to explicit is hard: f(x,y) = 0 y = f(x) y 1 x 2 • solving nonlinear equations, sometimes multiple or no solutions • but, inverting it differentially is easy because of linearization: f f dx dy 0 x y dy f x f y dx f dx 0 x shape/rank of jacobian will tell you how constrained you are as well f ( x, y) x 2 y 2 1 0 dy 2 x 2 y dx dy dx g ( x, y , z ) 0 dy 0dx f ( x, y , z ) 0 Chain Rule for Vector Derivatives • for scalar multiplication: d (a b) da b a db • differential of a scalar function of a scalar is a scalar Chain Rule for Vector Derivatives • for scalar multiplication: d (a b) da b a db • differential of a scalar function of a scalar is a scalar • for dot product it’s a little wackier • if vectors in dot are functions of scalars, it’s the same d (a b) da b a db Chain Rule for Vector Derivatives • for scalar multiplication: d (a b) da b a db • differential of a scalar function of a scalar is a scalar • for dot product it’s a little wackier • if vectors in dot are functions of scalars, it’s the same d (a b) da b a db • if vectors in dot are functions of vectors, need to watch shape! d – we know result must be row: Chain Rule for Vector Derivatives • for scalar multiplication: d (a b) da b a db • differential of a scalar function of a scalar is a scalar • for dot product it’s a little wackier • if vectors in dot are functions of scalars, it’s the same d (a b) da b a db • if vectors in dot are functions of vectors, need to watch shape! d – we know result must be row: use transpose picture to reason about it: d d ??? d (aT b) daT b aT db Chain Rule for Vector Derivatives • for scalar multiplication: d (a b) da b a db • differential of a scalar function of a scalar is a scalar • for dot product it’s a little wackier • if vectors in dot are functions of scalars, it’s the same d (a b) da b a db • if vectors in dot are functions of vectors, need to watch shape! d – we know result must be row: use transpose picture to reason about it: d d d (aT b) daT b aT db ??? don’t want to use tensors, so we pull a fast one with the commutativity of dot (a·b=b·a) d (aT b) bT da aT db d d Dot Product Derivative Example • derivative of squared length of vector r pq r r r T r r 2 ( p q) 2 dr 2 d ( p q)T ( p q) d (aT b) bT da aT db dr 2 ( p q)T d ( p q) ( p q)T d ( p q) dr 2 2( p q)T dp 2r T dp q dp makes intuitive sense: if dp is orthogonal, length doesn’t change r p Cross Product Works the Same Way • if cross is a vector function of vectors... d (a b) da b a db • result must be a matrix • use the skew symmetric picture of cross product ~ ~b b ab a a d d ??? same problem with tensors, so we pull the same (skew-)commutativity trick ~ ~ ~db d ( a b) b da a Cross Product Derivative Example • differentiate a cross product of moving vector with constant vector c r n dc d (r n) d~ rn ~dr ~ ~dr d~ r n n r dn n ~ ~b) b ~db d (a da a dc n dr n dr r c dc again, makes intuitive sense: dc changes orthogonally to dr changes References • Advanced Calculus of Several Variables – Edwards, Dover • Calculus and Analytic Geometry – Thomas & Finney • Classical Mechanics – Goldstein