33
Chapter 1 Math review Courtesy NASA 1.1 Why math is important Math is a foundation for science, medicine, engineering, construction, and business. Math provides con- cepts (pictures, words, and ideas), calculations (mathematical operations, symbols, equations, and def- initions), and context (situations in which the concepts and calculations are relevant and useful). More generally, math is a language and set of rules and conventions that allow humans to count, quantify, calculate, manipulate, relate, define, extrapolate, and abstract “stuff”. 1 Math is critical for precise understanding of many concepts. 2 Advances in math depend on pictures 3 words, symbols, equations, and definitions. For example, consider the following definition of π. Object Example Approximate age of human comprehension Picture Toddlers Spoken word “circle” Pre-school Written word “circle”, “diameter”, “circumference” Elementary school Symbol d for diameter, c for circumference Middle school Equation c = πd Middle school Definition π = c d College / graduate school 1.2 A brief history of mathematics Advances in mathematics and technology are usually made at a painstakingly slow pace, with small sparks of individual brilliance that are accompanied by good luck or divine inspiration. Over the past millennia, various cultures have produced groups of gifted individuals that have had a significant impact on modern mathematics, engineering, and technology, including: Egypt (3000 BC), Babylon (2000 BC), Greece and China (500 BC), India (500 AD), Africa (800 AD), Europe and Asia (1500 AD), United States and Soviet Union (1900 AD), and Worldwide Web (2000 + AD). 1.2.1 Real number systems Egyptians (3000 BC): Egyptians used hieroglyphics (picture writing) for numerals. The system was based on 10, but did not include a zero or the principle of place value. The (approximate) 1 For example, the “idea” of value (answering “how much something is worth”) is quantified through money. 2 Certain concepts are difficult to precisely define. For example, physicists call mass “fundamental” because it currently eludes mathematical definition and because humans have an inherent sense of mass. 3 Art is not reserved for the sophisticated and highly educated who have the knowledge and historical context to understand and appreciate it. Appreciation for shapes, colors, and emotional expression in art is available to humans on a basic (almost primitive and subconscious) level. 1

Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

Chapter 1

Math review

Courtesy NASA1.1 Why math is important

Math is a foundation for science, medicine, engineering, construction, and business. Math provides con-cepts (pictures, words, and ideas), calculations (mathematical operations, symbols, equations, and def-initions), and context (situations in which the concepts and calculations are relevant and useful). Moregenerally, math is a language and set of rules and conventions that allow humans to count, quantify,calculate, manipulate, relate, define, extrapolate, and abstract “stuff”.1

Math is critical for precise understanding of many concepts.2 Advances in math depend on pictures3

words, symbols, equations, and definitions. For example, consider the following definition of π.

Object Example Approximate age of human comprehension

Picture ToddlersSpoken word “circle” Pre-schoolWritten word “circle”, “diameter”, “circumference” Elementary schoolSymbol d for diameter, c for circumference Middle schoolEquation c = π d Middle school

Definition π∆= c

d College / graduate school

1.2 A brief history of mathematics

Advances in mathematics and technology are usually made at a painstakingly slow pace, with small sparksof individual brilliance that are accompanied by good luck or divine inspiration. Over the past millennia,various cultures have produced groups of gifted individuals that have had a significant impact on modernmathematics, engineering, and technology, including: Egypt (3000 BC), Babylon (2000 BC), Greece andChina (500 BC), India (500 AD), Africa (800 AD), Europe and Asia (1500 AD), United States and SovietUnion (1900 AD), and Worldwide Web (2000+ AD).

1.2.1 Real number systems

• Egyptians (3000 BC): Egyptians used hieroglyphics (picture writing) for numerals. The systemwas based on 10, but did not include a zero or the principle of place value. The (approximate)

1For example, the “idea” of value (answering “how much something is worth”) is quantified through money.2Certain concepts are difficult to precisely define. For example, physicists call mass “fundamental” because it currently

eludes mathematical definition and because humans have an inherent sense of mass.3Art is not reserved for the sophisticated and highly educated who have the knowledge and historical context to understand

and appreciate it. Appreciation for shapes, colors, and emotional expression in art is available to humans on a basic (almostprimitive and subconscious) level.

1

Page 2: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

hieroglyphic symbols shown below combine to depict the number 1,326 as | @@@ ^^ //////.1 / Stroke10 ^ Arch100 @ Coiled Rope1,000 | Lotus Flower10,000 > Finger100,000 ~ Tadpole

• Babylonians (2000 BC): Developed a number system based on 60. Their number system was moreconsistent and structured than the Egyptian system and was simpler for mathematical calculations.The number of seconds in a minute (60) and number of minutes in an hour (60) are a consequenceof the Babylonian number system.

• Hittites in Mesopotamia (2000-700 BC): Developed the precursor to the Roman numeral systeme.g., their first four numbers were I, II, III, and IIII (note how I looks like a finger or a stick).

• Romans (500 BC): The early Roman system was based on the Hittite system, e.g., its first fournumbers were I, II, III, and IIII. The Roman system had special symbols for 5 (V), 10 (X), 50 (L),100 (C), 500 (D), and 1000 (M). The early Roman system only used addition (not subtraction) thus 4was IIII (not IV), 6 was VI, 9 was VIIII (not IX), and 11 was XI. The late Roman numeral systemwas invented in France in 1500 AD by clock and watch makers to save space on clocks. The Romansystem was used throughout the Middle Ages and by law was the only acceptable system in Europeuntil 1300 AD.

• Greeks (500 BC): Developed a system based on 10. The first nine letters of their alphabet rep-resented the numbers 1-9. The next nine letters stood for tens, from 10 through 90. The last nineletters were for hundreds, 100 through 900. The Greeks combined their symbols like the Egyptians.

• Hindus (200 BC - 700 AD): Around 200-300 BC, the Hindus in India used a system based on10. They had symbols for each number from 1 to 9 and a symbol for each power of 10. Thus aHindu wrote “1 sata, 3 dasan, 5” to write the number 135. Around 600 AD the Hindus found a wayto eliminate place names. They invented the symbol “sunya” (meaning empty), which we call zero.With this symbol they could write “105” instead of “1 sata, 5”.

The use of negative numbers in solving problems can be traced as far back as the Indian Brah-magupta (7th century AD) who used zero and negative numbers in his algebraic work. He even gavethe rules for arithmetic, e.g., “a negative number divided by a negative number is a positive number.”This may be the earliest [known] systemization of negative numbers as entities in themselves.

The ancient Chinese calculated with red (positive) and black (negative) rods (opposite to today’saccounting practices), but, like other cultures, they did not accept a negative number as a solutionto a problem. Instead, the problem was stated so its result was a positive quantity.Note: A 4-year old child’s answer to the problem of 3 apples - 5 apples was a profoundly definite “you can not do that”.

Humans use negative numbers to convey opposites, e.g., negative/positive temperatures convey cold and hot, debt is

negative whereas assets are positive, electrons and protons have positive and negative charge, etc.

Nineteenth century Europeans were the first to broadly accept negative numbers. Before 1800 AD,negative numbers were treated with great suspicion. For example, Pascal regarded the subtractionof 4 from 0 as utter nonsense. Maseres and Frend wrote algebra texts renouncing both negative andimaginary numbers on the grounds that mathematicians were unable to explain their use except byanalogy.

• Mayans (700-800 AD): The Mayan civilization invented a highly sophisticated vertical numbersystem that used positional base notation as well as zero. Unfortunately, their knowledge and civ-ilization did not survive the centuries and Mayan mathematics has had little impact on modernmathematics or technology.

• Arabs (700-800 AD): Muhammad ibn Musa Al-Khwarizmi (780-850 AD) learned the Hindu num-ber system and extended it by using zero as a place holder in positional base notation. In 800 AD,

Copyright c© 1992-2009 by Paul Mitiguy 2 Chapter 1: Math review

Page 3: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

he wrote a book that was later translated into Latin around 1100 AD. Many mathematicians considerthe Hindu-Arabic number system the world’s greatest mathematical invention because it introducedthe idea of place value and zero.

• Europeans (1000-1200 AD): The Latin translation of the Hindu-Arabic number system, theencouragement of the astute mathematician Gerbert (who later was made Pope Sylvester II) in980 AD, and the notational work of Leonardo of Pisa (Fibonacci) in 1202 AD, resulted in the numbersystem being used worldwide today. Because of political and cultural conflicts, widespread use of theArabic number system was delayed until 1500 AD.4

• Europeans (1700 AD): Gottfried Wilhelm Leibniz (1646-1716) developed the binary numbersystem (now used by most computers) in which he interpreted 1 for God and 0 for “the void”.

• Fractions were used by the Egyptians (3000 BC), Babylonians (2000 BC), and Greeks (500 BC).Representing fractions with two stacked integers was essentially due to the Hindus (628 AD). Thehorizontal fraction bar (called the vinculum) was introduced by the Arabs around 1200 AD Soon-thereafter, the diagonal fraction bar (called a solidus or virgule) was used for print because oftypographical difficulties with the horizontal fraction bar.

• Percent symbols (denoting 1100

) were introduced in an anonymous Italian manuscript in 1425 AD.

• Decimal points were first written as a blank space by the Persian astronomer Al-Kashi (1426). In1530, Christoff Rudolff used a vertical bar exactly as we use a decimal point today. Before 1617 whenNapier used both a comma and period to separate units and tenths, several other notations werein use, e.g., Simon (1585), Viete (1600), and Kepler (1616). Modern monetary and measurementsystems (e.g, the SI system) take advantage of the conveniences afforded by the base-10 numbersystem and decimal point [denoted with either a period (.) or comma (,)].

1.2.2 Imaginary numbers, complex numbers, and quaternions

• Stereometria of Heron of Alexandria (circa 50 AD) first noticed imaginary numbers when he saw that√81−144 could not be computed, so he switched it to

√144−81.

• Arithmetica of Diophantus (c. 275 AD) noticed imaginary numbers when he attempted to computethe sides of a right triangle with a perimeter of 12 and an area of 7. He found it necessary to solvethe equation 24x2 − 172x + 336 = 0. He did not understand that the equation had complex roots(there are no real triangles with a perimeter of 12 and an area of 7).

• Mahavira (c. 850 AD) stated that a negative number is not a square and does not have a square root.

• Bhaskara (c. 1150 AD) described imaginary numbers using language similar to Mahavira.

• The Arabs and Persians paid no special attention to the subject.

• Pacioli (1494 AD) stated in his Summa that the quadratic equation x2 = c = bx cannot be solvedunless b2/4 is greater than or equal to c. He recognized the impossibility of finding

√-1.

• Cardan (1545 AD) was the first to use the square root of a negative number in a computation. Theproblem was to divide 10 into two parts whose product was 40. He determined the number to be5 +

√-15 and 5 −√

-15 and proved by multiplication that his results were correct.

• Stevin (1585 AD) spoke of the difficulty of working with imaginary numbers but only remarked thatthat the subject was not mastered.

• Wallis (1673 AD) was the first to give a graphical representation of imaginary numbers in a plane(similar to positive and negative numbers on a line). He stated that the square root of a negative numberwas thought to imply the impossible, but the same might be said of a negative number.

4Until Pope Sylvester’s Latin translation of the Arabic number system, the Europeans resisted the number 0 and usingthis great “unholy infidel” number system. The Europeans raised philosophical and religious objections to 0 (e.g., 0 cannotexist because there is always God). Adopting the Arabic number system was complicated because of deep animosity betweenMuslim Arabs and Christian Europeans fueled by the holy wars.

Copyright c© 1992-2009 by Paul Mitiguy 3 Chapter 1: Math review

Page 4: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

• Newton’s work (1685 AD) with imaginary numbers was confined to the number of roots of an equation.

• Jean Bernoulli (1702 AD) related the atan function and the logarithm of an imaginary number.

• Cotes (1710 AD) stated that log[cos(x) + i sin(x)] = i x.

• Euler (1727 AD) invented the symbol e for the base of natural logs and the corollary of Cotes’ formulaei x = cos(x) + i sin(x). Euler also invented the notation i =

√-1.

• Casper Wessil (1797 AD), a Norwegian surveyor, presented the modern geometric theory of com-plex numbers and the complex plane before the Royal Academy of Denmark.

• Sir William Hamilton (1830 AD) developed a system of hypercomplex numbers called quaternionswhich have four elements (1, i, j, k). Quaternions proved adaptable for operations in three dimensionalspace but have mostly been superseded by vectors. A quaternion is usually written in the formq = a0 + a1∗i+ a2∗j + a3∗k. The coefficients a0, a1, a2, a3 are called Euler parameters and are stillused for 3D descriptions of orientation of rigid bodies (see Section 4.12). Note: A quaternion is similar to

a complex number in that a complex number may be written as a0 + a1∗i where a0 and a1 are real numbers.

1.2.3 Vectors and dyadics

J. Williard Gibbs (1900 AD) developed vectors (quantities having magnitude and direction) and dyads(quantities with magnitude and two directions). Vectors and dyadics are extensively used in geometry,statics, dynamics, and motion design and analysis and are discussed in Chapters 2, 3, and 5.

1.2.4 Matrices and determinants

Matrices are useful for organizing sets of linear equations. The Babylonians (300 BC) studied problemsthat lead to simultaneous linear equations and some of these are preserved in clay tablets. The practicaltheories of matrices and determinants did not develop until nearly 1800 AD. The idea of a determinantfirst appeared in Japan (Seki 1683) and Europe (Leibniz 1683) within a few months of each other. In1750, Cramer gave a general rule for finding a determinant of a n×n system of equations. In 1772,Laplace discovered a new formula for the expansion of a determinant. In 1773, Lagrange discovered thata 3×3 determinant could be interpreted as the volume of a tetrahedron. The great mathematician Gauss(1801) first used the term “determinant” calculated inverses, and did “Gaussian elimination”. In 1812-1826, Cauchy did a detailed study of determinants, minors, eigenvalues, and diagonalization of a matrix.D’Alembert, Jacques Sturm, Jacobi, and Eisenstein made contributions to determinants, and Cayley (1841)introduced the notation of two vertical lines that denotes determinants in modern work. In 1850, Sylvestertermed the word “matrix” and shared his work with Cayley who later (1858) defined the word matrixmore precisely. The Jordan canonical form appeared in 1870. Frobenius defined the rank of a matrix andorthogonal matrices in 1878.

1.3 Units

Units quantify the measurement of “stuff”. First adopted by France on December 10, 1799 and nowused in all countries other than the United States,5 Liberia, and Myanmar, the SI system (International

System of Units) is used to measure length (meters), mass (kilogram), force (Newton), temperature (Celsius), time(second), etc. Accurate conversions from one unit of measure to another (e.g., km

hour to msec) are important

as inaccuracies have lead to many engineering failures. NIST (National Institute of Standards & Technology)

defines and quantifies accurate conversion factors and physical constants.

5It is ironic that the United States has not standardized on the SI system as it was the first country (in 1792) to use amonetary system with decimals and a base-10 number system. A study in Australia found that switching from British unitsto metric units freed an extra 1

2-year in science education.

Copyright c© 1992-2009 by Paul Mitiguy 4 Chapter 1: Math review

Page 5: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

1.4 Geometry

Geometry is the study and measurement of lines, curves, edges, surfaces, solids, etc. Geometry plays acentral role in construction, farming, engineering, medicine, science, cooking, and in measuring distance,area, or volume.

In many K-12 educational systems, 2+ years are spent on 2D Euclidean geometry and trigonometry. Therelatively new invention of vectors (Gibbs ≈ 1900 AD) has significantly simplified 2D and 3D geometry.The concepts, calculations, and applications of vector addition, dot-products, and cross-products are easyto teach, learn, and apply. Unfortunately, relatively few instructors are fully aware of the significantadvantages of vectors in geometry.

1.5 Circles and their properties

The ratio of a circle’s circumference to its diameter is a number equal toa

π = 3.14159265358979323846264338327950288419716939937510582 . . .

πππππππππππππ is called an “irrational number” because its value is not a whole numberor fraction, nor does it terminate or repeat. It is chaotic, disorderly, and has nodiscernible pattern (π is as rational as the contests to memorize 67, 890+ digits of π).

aThe symbol πππππππππππππ was introduced by Euler circa 1750, but the value π ≈ 3.14 was known in Egypt around 3000 BC

θr

The arc-length of a portion of the circle’s periphery and the area of a wedge of the circle can becalculated in terms of the circle’s radius r and the angle θ as6

Arc-length = θr Area of wedge = θ2 r2

Circumference = 2πr Area of circle = πr2

1.6 Triangles and the ratios of their sides

Triangles have a simple geometric shape and have been widely used in construction, surveying, and as-tronomy. The definitions of sine, cosine, and tangent as ratios of various sides of a right triangle dateback to before 140 BC when the Greek Hipparchus made sine, cosine, and tangent tables. More precisecalculations of sine and cosine were made in 100 AD by the mathematician Ptolemy who calculated sinesand cosines to six decimal places. A helpful mnemonic for memorizing the definitions of Sine, Cosine,and Tangent is SohCahToa .

adjacentθ

sin(θ) ∆=opposite

hypotenuse

cos(θ) ∆=adjacent

hypotenuse

tan(θ) ∆=opposite

adjacent=

sin(θ)cos(θ)

The mathematician Pythagoras of Samos (580-500 BC) was the first to prove an important property of a

6An angle always involves two lines and is measured in radians or degrees. A radian is the ratio of the arc-length of acircle to the circle’s radius. A degree is an archaic unit of measurement for an angle. Since there are approximately 360 daysin a year, each degree represents one day of Earth’s travel about the sun. The degree symbol looks like a small circle as areminder that 360◦ measures the Earth’s circular travel around the sun. Historically, the early Babylonian number systemwas based on 60, and the numbers 360 (days in a year) and 30 (days in a month) were sacred numbers.

Copyright c© 1992-2009 by Paul Mitiguy 5 Chapter 1: Math review

Page 6: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

right triangle that had been widely used thousands of years earlier by the Babylonians. The Pythagoreantheorem relates the lengths of the sides of a right triangle, namely

hypotenuse2 = adjacent2 + opposite2 (1)

A second important relationship that follows directly from the Pythagorean Theorem and the definitionsof sin(θ) and cos(θ) is7

sin2(θ) + cos2(θ) =(1)

1 (2)

1.6.1 Properties of sine, cosine, and tangent

There are many useful trigonometric formulas, including the Law of Cosines (Euclid of Alexandria300 BC), the Law of Sines (Ptolemy of Alexandria Egypt 100 AD), and the addition formula forsine (Ptolemy 100 AD).8 9

a

bc

β

α

φ

c2 = a2 + b2 − 2 a b cos(φ) Law of cosines (3)

sin(α)a

=sin(β)

b=

sin(φ)c

Law of sines (4)

sin(-α) = -sin(α) (5)

cos(-α) = cos(α) (6)

sin(α + β) = sin(α) cos(β) + sin(β) cos(α) Addition formula for sine (7)

cos(α + β) =(7)

cos(α) cos(β) − sin(α) sin(β) Addition formula for cosine (8)

sin(x) =(7)

sin(x + 2π n) n = 1, 2, 3, . . . Sine is periodic (9)

cos(x) =(8)

cos(x + 2π n) n = 1, 2, 3, . . . Cosine is periodic (10)

sin(x) =(8)

cos(x − π

2) = cos(-x +

π

2) (11)

cos(x) =(7)

sin(x +π

2) = sin(-x +

π

2) (12)

-sin(x) =(7)

sin(x ± π n) n=1, 3, 5, . . . (13)

-cos(x) =(8)

cos(x ± π n) n=1, 3, 5, . . . (14)

sin(x) =(7)

2 sin(x

2) cos(

x

2) or sin(2x) = 2 sin(x) cos(x) (15)

sin(x)2 =(8)

1 − cos(2x)2

(16)

7Numbers under an equals sign refer to equations numbered correspondingly.8Vectors are very useful in geometry and are a simple way to prove the Law of Cosines (see Homework 1.23), Law

of Sines (see Homework 1.??), and Sine addition formula (see Homework 1.??), from which most other trigonometricformulas are derived (e.g., Cosine addition formula (see Homework 1.??) hw:ProofOfAdditionTheoremOfCosines , half-angle formulas, double-angle formulas, etc.).

9The trigonometric identities required to reverse-engineer equation (20) include sin(a+b) = sin(a) cos(b)+ cos(a) sin(b),

sin(x)2 + cos(x)2 = 1 , and cos(x2)2 = 1+ cos(x)

2.

Copyright c© 1992-2009 by Paul Mitiguy 6 Chapter 1: Math review

Page 7: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

cos(x)2 =(8)

1 + cos(2x)2

(17)

sin(x

2)2 =

(16)

1− cos(x)2

or cos(x) = 1 − 2 sin(x

2)2 (18)

cos(x

2)2 =

(17)

1+ cos(x)2

or cos(x) = 2 cos(x

2)2 − 1 (19)

cos(b) − cos(a) =(7)

2 sin(

a+b

2

)sin

(a−b

2

)Useful for beat phenomenon analysis (20)

cos(ω2 t + φ2) − cos(ω1 t + φ1) =(20)

2 sin[(ω1+ω2

2) t +

φ1+φ2

2

]sin

[(ω1−ω2

2) t +

φ1−φ2

2

](21)

1.6.2 Sine, cosine, and tangent as functions

The functional character of sine, cosine, and tangent was discovered by Euler circa 1730. Thinking of sin(θ)and cos(θ) as functions, not just as the ratio of sides of a triangle, was a major advance for trigonometry.

sin(θ) ∆= oppositehypotenuse

Figure 1.1: sin functionθπ/4 π/2 3π/4 5π/4 3π/2π 7π/4 2π

0.5

1

−0.5

−1

0

cos(θ) ∆= adjacenthypotenuse

Figure 1.2: cos functionθπ/4 π/2 3π/4 5π/4 3π/2π 7π/4 2π

0.5

1

−0.5

−1

0

Copyright c© 1992-2009 by Paul Mitiguy 7 Chapter 1: Math review

Page 8: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

tan(θ) ∆= oppositeadjacent

= sin(θ)cos(θ)

Figure 1.3: tan function

θπ/4 π/2 3π/4 5π/4 3π/2π 7π/4 2π

1

2

−1

−2

0

1.6.3 The amplitude-phase formulas for sine and cosine

Two trigonometric identities that are particularly helpful in dynamic systems are the amplitude-phaseformulas for sine and cosine.10

A sin(x) + B cos(x) = C sin(x + φ) where C = +√

A2 + B2 and φ = atan2( B,A) (22)

A sin(x) + B cos(x) = C cos(x + φ) where C = +√

A2 + B2 and φ = atan2(-A,B) (23)

1.6.4 The atan2 function

The atan2 function is named because of its similarity to the arc-tangent function atan and because ittakes two arguments. It differs from the atan function because the atan2 function returns a value φ inthe range -π < φ ≤ π whereas the atan function returns -π

2 < φ ≤ π2 . One way to determine the angle φ

returned by the function φ = atan2(y, x) is:

• Draw a horizontal and vertical as shown on the right.

• Mark the point located at the designated y and x values.For example, to calculate atan2(4, -3) mark the point located aty = 4 and x= -3.

• Draw a line L connecting that point to the point at (0, 0).

• Mark the angle φ between the positive x-axis and line L.

• Using trigonometry, calculate the value of φ, e.g., φ = 2.21 rads.

φ

(-3,4)

In computer programs such as Matlab, MotionGenesis, Java, C, and C++, the function atan2(y, x) returnsthe radian measure of an angle -π < φ ≤ π that satisfies both

sin(φ) = y+√

x2 + y2and cos(φ) = x

+√

x2 + y2⇒ φ = atan2(y, x) (24)

10The amplitude-phase formulas [equations (22) and (23)] are used extensively in vibration analysis. These general formulasrequire atan2 because A and B may be positive, negative, or zero.

Copyright c© 1992-2009 by Paul Mitiguy 8 Chapter 1: Math review

Page 9: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

1.7 Differentiation

1.7.1 Definition of a partial derivative of a scalar function

When a function f is regarded to depend on n independent scalar variables t1, . . . , tn, it is denoted11

f(t1, . . . , tn), and n quantities, called “first partial derivatives of f”, can be formed. These quantities are

denoted ∂f∂ti

and are defined as

∂f

∂ti

∆= limh→0

f(t1, . . . , ti + h, . . . , tn) − f(t1, . . . , ti, . . . , tn)h

(i = 1, ..., n) (25)

Because ∂f∂ti

is defined as a limit, it cannot be regarded as a ratio, meaning one cannot cancel the ∂ti inthe denominator by multiplying through by ∂ti. In other words ∂ti is not an entity in its own right.

1.7.2 Definition of an ordinary derivative of a scalar function

When a function f is regarded as a function of only one single scalar variable t, then the definition inequation (25) reduces to that of the “ordinary derivative of f with respect to t”.12 Frequently, other

symbols are used in place of ∂f∂t

to denote the ordinary derivative of f with respect to t. e.g.,13 14

f ′ = f ′(t) = f = f(t) =df

dt=

d[f(t)]dt

=∂f

∂t

∆= limh→0

f(t + h) − f(t)h

(26)

Geometrical interpretation of an ordinary derivative

When f is a function of a single independent variable t,the (first) derivative of f with respect to t is the slopea

of f(t). The derivative of f ′(t), also called the “secondderivative of f(t) with respect to t”, is denoted f ′′(t) andis the curvature of f(t).

aIt is easy to fit a curve that passes through a few points withspecific slopes, e.g., with tangents to the curve at t =0, t= 1, andt =2. This is the fundamental idea behind numerical integration. 0

0.5

1

1.5

2

2.5

3

3.5

4

0 0.5 1 1.5 2

f(t)

= t

3 - 2

*t2 +

2*t

t

11The notation f(t1, . . . , tn) was invented by Euler circa 1730.12Synonyms for ordinary are “plain” and “boring” because f is a function of a single variable, whereas a “hot and spicy”

partial derivative is usually a function of two or more variables.13History: The modern differential notion

dfdt

was introduced by Gottfried Liebniz in 1675. The dot-notation f was

introduced by Newton in his “method of fluxions” around 1675 and relates to idea of flux (time-rates of change) of “fluents”(now called variables). The prime notation was introduced by Lagrange in 1797 in his Theorie des fonctiones analytiques.Lagrange called f ′(t) the “derived function” of f(t), from which the modern term derivative comes [54, pgs. 95-97].

Although Newton and Leibniz shared the discovery of calculus, their initially cordial relationship turned contentious - withNewton and Leibniz and their respective supporters allegating plagiarism and undermining each other’s credibility. Ironically,the recluse Newton died at 80-years old a national hero of England with a state funeral of the highest honors. The moresociable Leibniz’s died at 70-years old, almost completely forgotten, with a funeral attended by only his secretary. Newton’sdaunting reputation intimidated British mathematicians. England did not produce a single first-rate mathematician for overa century - and England’s next contributors were in algebra (not analysis). Undaunted and unintimidated by their Englishneighbors, the rest of Europe, lead by the Bernoulli family, Leonard Euler, and many others, quickly expanded analyticalanalysis through differential equations, the calculus of variations, etc.

14The chronological development of mathematics can occur in an interesting order. For example, the derivative was firstused (Fermat and Descartes, 1637), then discovered (Newton and Leibniz, 1669-1684), then explored and developed (Taylor,Euler, Maclaurin, Lagrange, 1755-1797) and and finally defined (Cauchy and Wiestrass, 1823-1861) [32].

Copyright c© 1992-2009 by Paul Mitiguy 9 Chapter 1: Math review

Page 10: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

1.7.3 Definition of the differential of a scalar function

When f is regarded as a function of n independent scalar variables t1, . . . , tn, one may define a quantitydf called the differential of the function f in terms of dt1, . . . , dtn (differentials of the indepen-dent variables t1, . . . , tn). These “independent differentials” are defined to be arbitrary (usually small)quantities that have the same dimension of t1, . . . , tn. With dt1, . . . , dtn in hand, df is defined as

df∆=

∂f

∂t1∗ dt1 +

∂f

∂t2∗ dt2 + . . .

∂f

∂tn∗ dtn (27)

When f is regarded as a function of a single scalar variable t, equation (27) reduces to

df =(27)

∂f

∂t∗ dt (28)

One is free to divide both sides of equations (27) or (28) by any non-zero quantity, including a differential.Dividing both sides of equation (28) by dt gives rise to the ratio of df to dt, that is

df

dt=

(28)

∂f

∂t(29)

Hence, when f is a function of a single independent scalar variable, the symbol dfdt

can means both aratio of the differential df to the differential dt and as a limit (or ordinary derivative) in the sense ofequation (26). This “overloading” of the symbol df

dtcan be both useful and confusing.

1.7.4 Definition of the total derivative of a scalar function

At times, a function f can be regarded as either depending on a single scalar quantity t, or regarded as afunction of n + 1 independent scalar quantities x1, . . . , xn and t, where x1, . . . , xn are themselves functionsof t. When one regards f as a function of x1, . . . , xn and t, f is denoted f(x1(t), . . . , xn(t), t), and theordinary derivative of f with respect to t is called the total derivative of f with respect to t and can becalculated as

dfdt

= ∂f∂x1

∗ dx1dt

+ ∂f∂x2

∗ dx2dt

+ . . .∂f∂xn

∗ dxndt

+ ∂f∂t

(30)

1.7.5 Short table of derivatives frequently encountered in engineering

Function Derivative of F (t)

F (t) = tn ∂F∂t

= n ∗ tn−1 (n = constant)

F (t) = ln(t) ∂F∂t

= t-1 = 1

t

F (t) = et ∂F∂t

= et Very important for differential equations

F (t) = sin(t) ∂F∂t

= cos(t)

F (t) = cos(t) ∂F∂t = -sin(t)

F (t) = tan(t) ∂F∂t

= 1cos2(t)

F (t) =t∫

x=t0

f(x) dx ∂F∂t

= f(t) (Fundamental Theorem of Calculus)

F (t) =h(t)∫

s=g(t)

f(s, t) ds ∂F∂t

=h(t)∫

s=g(t)

∂f(s, t)∂t

ds − f [s=g(t), t] d [g(t)]dt

+ f [s=h(t), t] d [h(t)]dt

Copyright c© 1992-2009 by Paul Mitiguy 10 Chapter 1: Math review

Page 11: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

1.7.6 Example: Partial and ordinary differentiation

Consider a function f(x, y, t) that depends on the independent variable t (time) and dependent variablesx and y (which implicitly depend on the independent variable t) as

f(x, y, t) = sin(x) y2 + e3 t

Partial derivatives of f with respect to x or y or t and the ordinary derivative of f are

∂f

∂x= cos(x) y2 ∂f

∂y= 2 sin(x) y

∂f

∂t= 3 e3 t df

dt= cos(x) x y2 + 2 sin(x) y y + 3 e3 t

Alternately, shown below are partial and ordinary derivatives of a function g(x, x, t) that depends on theindependent variable t (time) and a dependent variable x and its ordinary time-derivative x.

g(x, x, t) = sin(x) x2 + e3 t

∂g

∂x= cos(x) x2 ∂g

∂x= 2 sin(x) x

∂g

∂t= 3 e3 t dg

dt= cos(x) x3 + 2 sin(x) x x + 3 e3 t

1.7.7 Product rule for derivatives

Many calculus books introduce the “bad” product rule for differentiation d (u ∗ v)dt

= u ∗ dvdt

+ v ∗ dudt

.This is unfortunate as this product rule does not work if u and v are matrices, vectors, dyadics, etc.Additionally, it is difficult to use this product rule to differentiate the product of three or more scalarquantities, e.g., u∗v∗w. A simple, efficient, and extensible “good” product rule for differentiation,that works for matrices, vectors, dyadics, etc., is

∂(u ∗ v ∗ w)∂t

= ∂u∂t

∗ v ∗ w + u ∗ ∂v∂t

∗ w + u ∗ v ∗ ∂w∂t

(31)

Product rule example:∂[t2∗sin(t)∗et

]∂t = 2 t sin(t) et + t2 cos(t) et + t2 sin(t) et

1.7.8 Quotient rule for derivatives using exponents and the product rule

Since the quotient uv is equivalent to u v-1, the partial derivative

of uv with respect to t is implemented with the product rule and

exponents (without memorizing special quotient-rule formulas) as

∂∂t

(uv)

= ∂u∂t

v-1 − u v-2 ∂v∂t

(32)

1.7.9 Chain rule for derivatives

When the variable x depends on the variable t, the partial deriva-tive of the function f(x) with respect to t can be written via thechain rule for differentiation as shown in equation (33).

∂ f(x)∂t

= ∂ f(x)∂x

∂x∂t

(33)

1.7.10 Implicit differentiation

Implicit differentiation can be a useful tool for efficiently calculating derivatives. For example, thefollowing nonlinear algebraic equation relates a dependent variable y to an independent variable t.

y2 + sin(y) = cos(t)

In general, it is difficult to solve a nonlinear equation to find y explicitly in terms of t. However, implicitdifferentiation calculates dy

dtwithout first solving for y, e.g., differentiating the previous equation gives

2 ydy

dt+ cos(y)

dy

dt= -sin(t) ⇒ dy

dt=

-sin(t)2 y + cos(y)

Copyright c© 1992-2009 by Paul Mitiguy 11 Chapter 1: Math review

Page 12: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

The use of implicit differentiation in conjunction with natural logarithms is useful for calculating theordinary time-derivative of y = ct (c is a constant and t is time), as shown below.15

y = ct ⇒ ln(y) = t ln(c) ⇒ d [ln(y)] = ln(c) dt ⇒ 1y

dy = ln(c) dt

Solving for the ratio of dy to dt (which is equal to the ordinary time-derivative of y), yields

dy

dt= ln(c) y = ln(c) ct

Note: When c = e = 2.718281828,dydt

= y, which plays a central role in ordinary differential equations.

1.7.11 Differentiation with the symbolic manipulator MotionGenesis

Symbolic manipulators are useful for calculating partial derivatives and ordinary time-derivatives.For example, typing the following input lines at the MotionGenesis prompt, produces the results below.Note: Output lines are marked with ->.

(1) Variable x, y(2) z = y*cos(x) + 2*x^2*sin(y)

-> (3) z = y*cos(x) + 2*x^2*sin(y)

(4) partialDerivativeOfZwithRespectToY = D( z, y )-> (5) partialDerivativeOfZwithRespectToY = cos(x) + 2*x^2*cos(y)

(6) partialDerivativeOfZWithRespectToX = D( z, x )-> (7) partialDerivativeOfZWithRespectToX = 4*x*sin(y) - y*sin(x)

(8) Variable s’ % Declares s as a variable and s’ as it’s ordinary time-derivative(9) funct = log(s) + s*exp(s)

-> (10) funct = log(s) + s*exp(s)

(11) ordinaryTimeDerivativeOfFunct = Dt( funct )-> (12) ordinaryTimeDerivativeOfFunct = (1/s+exp(s)+s*exp(s))*s’

1.8 Integration and a short table of integrals

An integral can be regarded as a sum or as an anti-derivative. A useful interpretation of an integral isthe area under a curve. The following table contains integrals commonly found in engineering analysis.16

Function Integral of F (t)

F (t) = tn∫

F (t) dt = tn+1

n+1 + C (n is a number other than -1)

F (t) = t-1 ∫

F (t) dt = ln(t) + C

F (t) = et∫

F (t) dt = et + C

F (t) = sin(t)∫

F (t) dt = -cos(t) + C

F (t) = cos(t)∫

F (t) dt = sin(t) + C

15Implicit differentiation can be done with derivatives (shown in the first example in Section 1.7.10) or differentials (shownin the second example in Section 1.7.10).

16The website www.Mathematica.com is a valuable resource for calculating integrals.

Copyright c© 1992-2009 by Paul Mitiguy 12 Chapter 1: Math review

Page 13: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

1.9 Solutions of linear algebraic equations

It is relatively easy to solve a single, uncoupled, linear algebraic equation, e.g., solving for x in

3x + 9 sin(t) − 12 = 0

Solving two coupled linear algebraic equations for y and z is a little more difficult, e.g.,

3 y + 2 z + 9 sin(t) − 12 = 02 y + 4 z + 5 cos(t) − 11 = 0

Solving four coupled linear algebraic equations for x1, x2, x3, x4 is more difficult, e.g.,

3x1 + 2x2 + 2x3 + 3x4 = 9 sin(t)2x1 + 4x2 + 2x3 + 3x4 = 5 cos(t)4x1 + 5x2 + 6x3 + 7x4 = 119x1 + 8x2 + 7x3 + 6x4 = 15

1.9.1 Solutions of coupled linear algebraic equations with MotionGenesis (symbolic)

MotionGenesis17 symbolically solves the linear algebraic equations in Section 1.9 with the commands:

%-------------------------------------------------------------Variable xEquation = 3*x + 9*sin(t) - 12Solve( Equation, x )%-------------------------------------------------------------Variable y, zZero[1] = 3*y + 2*z + 9*sin(t) - 12Zero[2] = 2*y + 4*z + 5*cos(t) - 11Solve( Zero, y, z )%-------------------------------------------------------------Variable x{1:4}Eqn[1] = 3*x1 + 2*x2 + 2*x3 + 3*x4 - 9*sin(t)Eqn[2] = 2*x1 + 4*x2 + 2*x3 + 3*x4 - 5*cos(t)Eqn[3] = 4*x1 + 5*x2 + 6*x3 + 7*x4 - 11Eqn[4] = 9*x1 + 8*x2 + 7*x3 + 6*x4 - 15Solve( Eqn, x1, x2, x3, x4 )%-------------------------------------------------------------Save SolveLinearEquations.allQuit

1.9.2 Solutions of coupled linear algebraic equations with Matlab (numeric)

Matlab numerically solves the linear algebraic equations in Section 1.9 by assigning a numerical value tot and typing the commands:

t = 0.2;%-------------------------------------------------------------Coef(1,1) = 3; Rhs(1,1) = -(9*sin(t) - 12);SolutionToAxEqualsB = Coef \ Rhs;x = SolutionToAxEqualsB(1)%-------------------------------------------------------------Coef(1,1) = 3; Coef(1,2) = 2; Rhs(1,1) = -(9*sin(t) - 12);Coef(2,1) = 2; Coef(2,2) = 4; Rhs(2,1) = -(5*cos(t) - 11);SolutionToAxEqualsB = Coef \ Rhs;

17MotionGenesis is a symbolic manipulator (like Mathematica and Maple) for engineers and is a popular tool for generatingand solving linear and nonlinear algebraic and differential equations and writing C, Matlab, and Fortran code.

Copyright c© 1992-2009 by Paul Mitiguy 13 Chapter 1: Math review

Page 14: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

y = SolutionToAxEqualsB(1)z = SolutionToAxEqualsB(2)%-------------------------------------------------------------Coef(1,1) = 3; Coef(1,2) = 2; Coef(1,3) = 2; Coef(1,4) = 3; Rhs(1,1) = 9*sin(t);Coef(2,1) = 2; Coef(2,2) = 4; Coef(2,3) = 2; Coef(2,4) = 3; Rhs(2,1) = 5*cos(t);Coef(3,1) = 4; Coef(3,2) = 5; Coef(3,3) = 6; Coef(3,4) = 7; Rhs(3,1) = 11;Coef(4,1) = 9; Coef(4,2) = 8; Coef(4,3) = 7; Coef(4,4) = 6; Rhs(4,1) = 15;SolutionToAxEqualsB = Coef \ Rhs;x1 = SolutionToAxEqualsB(1)x2 = SolutionToAxEqualsB(2)x3 = SolutionToAxEqualsB(3)x4 = SolutionToAxEqualsB(4)

1.10 Solutions of polynomial equations (roots)

Polynomial equations are a special class of nonlinear algebraic equations. A special polynomial equationis the quadratic equation, which is a polynomial equation of degree 2. Shown below is a quadraticequation in x and its 2 roots (solutions).

Quadratic equation

ax2 + b x + c = 0

Solution to quadratic equation

x = -b +√

b2 − 4 a c2 a and x = -b − √

b2 − 4 a c2 a

Two other polynomial equations with “closed-form solutions” are the cubic and quartic equations

x3 + c2 x2 + c1 x + c0 = 0 and x4 + c3 x3 + c2 x2 + c1 x + c0 = 0

In 1824, Abel proved that no general closed-form solution for 5th-order (or higher) polynomials exist. It isknown, through the fundamental theorem of algebra, that any polynomial of degree n with complexcoefficients has n complex roots.18

Roots of a quadratic equation with MotionGenesis (symbolic)

The following shows how MotionGenesis calculates the roots of ax2 + b x + c = 0.(1) %--------------------------------------------------------------------(2) % Example 1: GetQuadraticRoots (roots of quadratic equation)(3) %--------------------------------------------------------------------(4) Constant a, b, c(5) Variable x(6) rootsA = GetQuadraticRoots( a*x^2 + b*x + c, x )

-> (7) rootsA[1] = -0.5*(b-sqrt(b^2-4*a*c))/a-> (8) rootsA[2] = -0.5*(b+sqrt(b^2-4*a*c))/a

(9) %--------------------------------------------------------------------(10) % Example 2: GetQuadraticRoots (roots of quadratic equation)(11) %--------------------------------------------------------------------(12) rootsB = GetQuadraticRoots( [a; b; c] )

-> (13) rootsB[1] = -0.5*(b-sqrt(b^2-4*a*c))/a-> (14) rootsB[2] = -0.5*(b+sqrt(b^2-4*a*c))/a

Roots of a 5th-order polynomial with MotionGenesis and Matlab

The following codes shows how MotionGenesis and Matlab calculate roots of a 5th-order polynomial equation.

p5 + 2∗p4 + 3∗p3 + 5∗p2 + 9∗p + 17 = 018The proof of the fundamental theorem of algebra is difficult and was presented with various rigor between 1608 and

1981 by great mathematicians including, Rothe( 1608) Girard (1629), Leibniz (1702), Bernoulli (1742), d’Alembert (1746),Euler (1749), Lagrange (1772), Laplace (1795), Gauss (1799), Argand (1806), Gauss (again in 1816 and 1849), Cauchy (1821),Weierstrauss (1891), Hellmuth Kneser (1940), and his son Martin Kneser (1981).

Copyright c© 1992-2009 by Paul Mitiguy 14 Chapter 1: Math review

Page 15: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

Roots of a polynomial equation of degree 5 with MotionGenesis

(1) %--------------------------------------------------------------------(2) % Example 1: GetPolynomialRoots (roots of 5th-order polynomial)(3) %--------------------------------------------------------------------(4) ImaginaryNumber i(5) Variable p(6) rootsA = GetPolynomialRoots( p^5 + 2*p^4 + 3*p^3 + 5*p^2 + 9*p + 17, p, 5 )

-> (7) rootsA = [-1.857621; -0.9475112 - 1.507048*i; -0.9475112 + 1.507048*i;0.8763218 - 1.455989*i; 0.8763218 + 1.455989*i]

(8) %--------------------------------------------------------------------(9) % Example 2: GetPolynomialRoots (roots of 5th-order polynomial)(10) %--------------------------------------------------------------------(11) rootsB = GetPolynomialRoots( [1, 2, 3, 5, 9, 17] )

-> (12) rootsB = [-1.857621, -0.9475112 - 1.507048*i, -0.9475112 + 1.507048*i,0.8763218 - 1.455989*i, 0.8763218 + 1.455989*i]

Roots of a polynomial equation of degree 5 with Matlab

>> polynomial = [1, 2, 3, 5, 9, 17];

>> p = roots( polynomial )

p =

0.8763 + 1.4560i

0.8763 - 1.4560i

-1.8576

-0.9475 + 1.5070i

-0.9475 - 1.5070i

1.11 Solutions of nonlinear algebraic equations

One way to find the solution to the nonlinear algebraic equation

x2 − cos2(x) = 0

is to graph the function x2− cos2(x) vs. x and identity the values ofx that make the function equal to 0. The graph shows this functionis nonlinear (i.e., it is not a line) and has two solutions, namelyx= 0.7391 and x= -0.7391.

-1

-0.5

0

0.5

1

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1

x2 - c

os(x

)2

x

XX

Another way to solve a nonlinear equation is to use a computer program such as MotionGenesis or Matlab.Most algorithms start with a guess and iterate towards a solution (usually the solution closest to the guess).For example, the following MotionGenesis commands produce the solution x= 0.7391.

Variable xSolveNonlinear( x^2 - cos(x)^2, x=2 ) % x=2 is a guess to a solutionQuit

Copyright c© 1992-2009 by Paul Mitiguy 15 Chapter 1: Math review

Page 16: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

1.11.1 Solutions of coupled nonlinear algebraic equations with MotionGenesis

Shown to the right is a coupled set of algebraic equations that isnonlineara in x and y (the unit circle and sine curve are not lines).These two curves intersect at two locations (there are two solutionsto these equations), namely x= 0.7391, y = 0.6736 and x= -0.7391,y = -0.6736. In general, it is difficult to determine the number ofsolutions to nonlinear algebraic equations, and the solution processusually requires a numerical algorithm that starts with a guess andthen iterates towards a solution.

aCoupled nonlinear algebraic equations frequently arise in determining staticequilibrium configurations of mechanical systems. Nonlinear equations with oneor two unknowns can be solved by trial and error or graphing. In general,Newton-Rhapson techniques are used to solve sets of nonlinear equations.

x2 + y2 = 1y = sin(x)

-1

-0.5

0

0.5

1

-1.5 -1 -0.5 0 0.5 1 1.5

For example, the following MotionGenesis commands produce the solution x= -0.7391, y = -0.6736.

Variable x, y % UnknownsZero[1] = x^2 + y^2 - 1 % x^2 + y^2 = 1 (unit circle)Zero[2] = y - sin(x) % y = sin(x) (sine wave)SolveNonlinear( Zero, x=1.5, y=0 ) % x=1.5, y=0 is a guess to a solutionQuit

1.11.2 Creating nonlinear algebraic C, Fortran, and Matlab codes with MotionGenesis

MotionGenesis can also produce efficient distributable C, Fortran, or Matlab codes that solve couplednonlinear algebraic equations without special toolboxes (such as Matlab’s optimization toolbox). The followingMotionGenesis commands produce the Matlab file NonlinearSolve.m that solves coupled nonlinear alge-braic equations.

Variable x, y % UnknownsZero[1] = x^2 + y^2 - 1 % x^2 + y^2 = 1 (unit circle)Zero[2] = y - sin(x) % y = sin(x) (sine wave)Input x=1.5, y=0 % x=1.5, y=0 is guess for solutionCODE Nonlinear( Zero, x, y ) NonlinearSolve.mQuit

1.11.3 Solutions of coupled nonlinear algebraic equations with Matlab

Matlab is another popular tool for solving nonlinear equations. To produce a Matlab solution for findingthe intersection of a circle and a sine wave:

• Use a text editor to create the file NonlinearSolveCircleSine.m (as shown below)• Invoke Matlab and make sure NonlinearSolveCircleSine.m is in the current working directory• Type NonlinearSolveCircleSine at the Matlab prompt• Note: The Matlab nonlinear solver fsolve requires the optimization toolbox.

See Section 1.11.2 to generate a Matlab solution that does not depend on the optimization toolbox.

%--------------------------------------------------------------------% File: NonlinearSolveCircleSine.m% Purpose: Solving a set of nonlinear equations with Matlab% Note: Requires Matlab’s optimization toolbox%--------------------------------------------------------------------function solutionToNonlinearEquations = NonlinearSolveCircleSineinitialGuess = [ 2, 0 ];solveOptions = optimset(’fsolve’);solutionToNonlinearEquations = fsolve( @CalculateFunctionEvaluatedAtX, initialGuess, solveOptions );

%========================================================================function fx = CalculateFunctionEvaluatedAtX( X )

Copyright c© 1992-2009 by Paul Mitiguy 16 Chapter 1: Math review

Page 17: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

x = X(1); y = X(2);fx(1) = x^2 + y^2 - 1; % x^2 + y^2 = 1 (unit circle)fx(2) = y - sin(x); % y = sin(x) (sine wave)

1.12 Solution of nonlinear 2nd-order ODEs (numerical integration)

The figure to the right shows a 1 m long pendulum swinging on Earth’ssurface. The pendulum’s motion is governed by the 2nd-order ODE

θ = -9.8 sin(θ)

The MotionGenesis solution to this ODE is shown below.The output data file ClassicParticlePendulum.1 has two columns.The first column records time from 0 to 5 sec in increments of 0.02 sec.The second column records the associated value of θ, accurate to 1 x 10

-8.

Variable theta’’theta’’ = -9.8*sin(theta)%-------------------------------------------------------------Input tFinal=5, integStp=0.02, absError=1.0E-08, relError=1.0E-08Input theta=30 deg, theta’=0Output t, theta deg%-------------------------------------------------------------Code ODE() ClassicParticlePendulumQuit

θ

L

-30

-20

-10

0

10

20

30

0 1 2 3 4 5

Pend

ulum

ang

le (

degr

ees)

Time (seconds)

1.13 Solution of coupled nonlinear 2nd-order ODEs

Computers and software programs such as MotionGenesis, Matlab, Mathematica, andMaple have revolutionized the numerical solution of partial and ordinary differentialequations.a The following sections show how to use MotionGenesis and Matlab to solve theordinary differential equations governing the motion of the system shown to the right.

qA =2 [508.89 sin(qA) − sin(qB) cos(qB) qA qB]

-21.556 + sin(qB)2

qB = -sin(qB) cos(qB) q2A

aThere are important reasons to study analytical solutions of differential equations. For example,in control system design, the stability of a differential equation can be more important than its solution.

qA

qB

1.13.1 Solution of ordinary differential equations with MotionGenesis

MotionGenesis generates and solves linear and nonlinear differential equations and produces fast, efficient,distributable C, Fortran, and Matlab codes that can be used with Simulink.19 The following MotionGenesis

commands solve the differential equations in Section 1.13.20

19Compiled C and Fortran codes are much faster than interpreted codes such as Matlab. This difference is significant forembedded systems that require real-time operation or when compiled code requires more than a minute to execute (whichmeans the interpreted code requires several hours). MotionGenesis symbolically optimizes expressions and sophisticatedcompilers optimize code for a specific operating system and microprocessor. To create C, Matlab, or Fortran code, replace thelast line in BabybootODE.al with: Code ODE babyboot.c or Code ODE babyboot.m or Code ODE babyboot.f

20MotionGenesis commands can be typed at the MotionGenesis prompt or run from a file as follows.

• Use a text editor, e.g., NotePad (Windows), SimpleText (Macintosh), Pico, Emacs, or vi (Unix), to create the fileBabybootODE.al (as shown in Section 1.13.1)

• Copy the file to the MotionGenesis folder, invoke MotionGenesis, and type run BabybootODE.al at the MotionGenesis

prompt. Or, in Microsoft Windows, drag and drop the file onto the MotionGenesis icon

Copyright c© 1992-2009 by Paul Mitiguy 17 Chapter 1: Math review

Page 18: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

The output data file solveBabybootODE.1 has three columns.The first column records time from 0 to 10 sec in increments of 0.02 sec.The second and third columns record associated values of qA and qB (in degrees).

Variable qA’’, qB’’ % Angles and their first and second time-derivatives%--------------------------------------------------------------------qA’’ = 2*( 508.89*sin(qA) - sin(qB)*cos(qB)*qA’*qB’ ) / (-21.556 + sin(qB)^2)qB’’ = -sin(qB)*cos(qB)*qA’^2%--------------------------------------------------------------------Input tFinal=10 sec, integStp=0.02 sec, absError=1.0E-07, relError=1.0E-07Input qA=90 deg, qB=1.0 deg, qA’=0.0 rad/sec, qB’=0.0 rad/secOutput t sec, qA degrees, qB degrees%--------------------------------------------------------------------Code ODE() solveBabybootODEQuit

qA

qB

1.13.2 Solution of ordinary differential equations with Matlab

The Matlab solution for the differential equations in Section 1.13 has two functions. The first functionis the main routine that drives the numerical integrator. The second function contains the differentialequations in first-order form. Since the solution is sensitive to numerical inaccuracies, Matlab’s defaultintegration error parameters RelTol and Abstol were modified as shown. To use Matlab:

• Use a text editor to create the file BabybootODE.m• Invoke Matlab and make sure BabybootODE.m is in the current working directory• Type BabybootODE at the Matlab prompt

%--------------------------------------------------------------------% File: BabybootODE.m (solving differential equations with Matlab)%--------------------------------------------------------------------function BabybootODEdegreesToRadians = pi/180;initialState = [ 90*degreesToRadians 1.0*degreesToRadians 0 0 ];timeInterval = linspace( 0, 10, 1000 );odeOptions = odeset( ’RelTol’, 1.0e-7, ’Abstol’, [1.0E-8, 1.0E-8, 1.0E-8, 1.0E-8] );[time,stateMatrix] = ode45( @odefunction, timeInterval, initialState, odeOptions );qB = stateMatrix(:,2);plot( time, qB/degreesToRadians, ’r-’ )xlabel( ’ Time (seconds) ’ );ylabel( ’ Plate angle (degrees) ’ );

function timeDerivativeOfState = odefunction( t, state )qA = state(1); % Pendulum angleqB = state(2); % Plate angleqAp = state(3); % qA’, time derivative of the pendulum angleqBp = state(4); % qB’, time derivative of the plate angleqApp = 2*( 508.89*sin(qA) - sin(qB)*cos(qB)*qAp*qBp ) / (-21.556 + sin(qB)^2);qBpp = -sin(qB)*cos(qB)*qAp^2;timeDerivativeOfState = [qAp; qBp; qApp; qBpp];

Copyright c© 1992-2009 by Paul Mitiguy 18 Chapter 1: Math review

Page 19: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

Chapter 2

Vectors and dyadicsCourtesy NASA/JPL-Caltech

Summary

Circa 1900 A.D., J. Williard Gibbs created a useful encapsulation of magnitude and direction (genericallycalled tensors) and invented vectors and their higher-dimensional counterparts dyadics, triadics, andpolyadics. Vectors describe three-dimensional space and are an important geometrical tool e.g., forsurveying, motion analysis, lasers, optics, computer graphics, animation, and CAD/CAE (computer aideddrawing/engineering).

Vector and dyadic operations include:• Multiplication of a vector with a scalar (produces a vector)

• Multiplication of a vector with a vector (produces a dyadic)

• Vector addition and dyadic addition• Dot product or cross product of a vector with a vector• Dot product of a vector with a dyadic• Differentiation of a vector Courtesy NASA/JPL-Caltech

This chapter describes vectors and vector operations in a basis-independent way. Although it can be helpfulto use an “x, y, z” or “i, j, k” orthogonal basis to represent vectors, it is not always necessary or desir-able. Postponing the resolution of a vector into components is often computationally efficient, allowing formaximum use of basis-independent vector identities and avoids the necessity of simplifying trigonometricidentities such as sin2(θ) + cos2(θ) = 1 (see Homework 2.10).

2.1 Examples of scalars, vectors, and dyadics

• A scalar is a quantity (e.g., a real number) that does not have an associated direction.

Scalar examplestime density volume mass moment of inertia temperature

distance speed angle weight potential energy kinetic energy

• A vector is a quantity that has magnitude and one associated direction. For example, a velocityvector has speed (how fast something is moving) and direction (which way it is going). A force vectorhas magnitude (how hard something is pushed) and direction (which way it is shoved).

Vector examplesposition vector velocity acceleration linear momentum force

impulse angular velocity angular acceleration angular momentum torque

• A dyad is a quantity that has magnitude and two associated directions.For example, stress is associated with force and area (both regarded as vectors).

• A dyadic is the sum of dyads. For example, an inertia dyadic describes the mass distribution ofa body and is the sum of various dyads associated with products and moments of inertia.

19

Page 20: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

2.2 Definition of a vector

A vector is defined as a quantity having magnitude and direction.1 Vectors are represented graphicallywith straight or curved arrows. For example, the vectors depicted below are directed to the right, left, up,down, out from the page, into the page, and inclined at 45◦, respectively.

Right/left up/down out/in inclined at 45o

Certain vectors have special properties (in addition to magnitude and direction) and have special namesto reflect these additional properties. For example, a position vector is associated with two points andhas units of distance. A bound vector is associated with a point (or a line of action).

Example of a vector

Traffic reports include observations such as “the vehicle is heading East at 5 msec”. In engineering, it is

conventional to represent these two pieces of information, namely the vehicle’s speed (5 msec ) and its di-

rection (East) by putting them next to each other or multiplying them (5∗East). To clearly distinguishthe speed from the direction, it is common to put an arrow over the direction (�East), or to use bold-facefont (East), or to use a hat for a unit vector (East).2 The vehicle’s speed is always a non-negativenumber. Generically, this non-negative number is called the magnitude of the vector. The combinationof magnitude and direction is a vector.For example, the vector v describing a vehicle traveling with speed 5to the East is graphically depicted to the right, and is written

v = 5 ∗ East or v = 5 East

A vehicle traveling with speed 5 to the West is

5 West or -5 East

N

S

EW

msec5

Note: The negative sign in -5East is associated with the vector’s direction (the vector’s magnitude is inherently positive).

2.3 The zero vector 0

The zero vector 0 is defined as a vector whose magnitude is zero.The zero vector may have any direction3 and has the following properties.

Addition of a vector a with the zero vector: a + 0 = aDot product with the zero vector: a ············· 0 = 0Cross product with the zero vector: a × 0 = 0

1Note: Direction can be resolved into orientation and sense. For example, a highway has an orientation (e.g., east-west)and a vehicle traveling east has a sense. Knowing both the orientation of a line and the sense on the line gives direction.

2MotionGenesis uses > to denote a vector. For example, the vector v is v> and the zero vector is 0>.3Note: It is improper to say the zero vector has no direction as a vector is defined to have both a magnitude and a

direction. It is also improper to say the zero vector has all directions as a vector is defined to have a magnitude and adirection (as contrasted with a dyad which has two directions or triad which has three directions). Thus there are an infinitenumber of equal zero vectors, each having zero magnitude and any direction.

Copyright c© 1992-2009 by Paul Mitiguy 20 Chapter 2: Vectors and dyadics

Page 21: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

2.4 Unit vectors

A unit vector is defined as a vector whose magnitude is 1.Unit vectors are sometimes designated with a special vector hat, e.g., u.

Unit vectors are typically introduced as “sign posts”, e.g., the unit vectorsNorth, South, West, and East shown to the right. The direction ofunit vectors are chosen to simplify communication and to produce efficientequations. Other useful “sign posts” are

• unit vector directed from one point to another point• unit vector directed locally vertical• unit vector tangent to a curve• unit vector parallel to the edge of an object• unit vector perpendicular to a surface

Another way to introduce a unit vector unitVector is to define it so it hasthe same direction as an arbitrary non-zero vector v by first determining|v|, the magnitude of v, and then writinga

aTo avoid divide-by-zero problems during numerical computation, one may write theunit vector in terms of a “small” positive constant ε as unitVector = v

|v| + ε.

N

S

EW

unitVector = v|v| (1)

2.5 Equal vectors

Two vectors are said to be equal (or equivalent) when they have the same mag-nitude and same direction.a The figure to the right shows three equal vectors.Although each vector has a different location, the vectors are equal because theyhave the same magnitude and direction.b

aHomework 2.4 draws vectors of different magnitude, orientation, and sense.bCertain vectors have additional properties. For example, a position vector is associated

with two points. Two position vectors are equal position vectors when, in addition to havingthe same magnitude and direction, the vectors are associated with the same points. Two forcevectors are equal force vectors when the vectors have the same magnitude, direction, and pointof application.

2.6 Vector addition

As graphically shown to the right, adding two vectors a + b produces a vector.a

First, vector b is translatedb so its tail is at the tip of a. Next, the vector a + bis drawn from the tail of a to the tip of the translated b.c

Properties of vector additionCommutative law: a + b = b + aAssociative law: (a + b) + c = a + (b + c) = a + b + cAddition of zero vector: a + 0 = a

aIt does not make sense to add vectors with different units. For example, adding a velocityvector with units of m/sec with an angular velocity vector with units of rad/sec does not producea vector with sensible units.

bTranslating b does not change the magnitude or direction of b, and so produces an equal b.cHomework 2.7 draws b + a.

b

a

aa+b

b

Copyright c© 1992-2009 by Paul Mitiguy 21 Chapter 2: Vectors and dyadics

Page 22: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

2.7 Vector negation

A graphical representation of negating a vector a is shown to the right.a

Negating a vector (multiplying the vector by -1) changes the sense of a vectorwithout changing its magnitude or orientation. In other words, multiplying avector by -1 reverses the sense of the vector (it points in the opposite direction).

aHomework 2.5 draws a vector -b.

a

-a

2.8 Vector multiplied or divided by a scalar

To the right is a graphical representation of multiplying a vector a by a scalar.a

• Multiplying a vector by a positive number (other than 1)

changes the vector’s magnitude.• Multiplying a vector by a negative number

changes the vector’s magnitude andreverses the sense of the vector.

• Dividing a vector a by a scalar s1 is defined as as1

∆= 1s1

∗ a

Properties of multiplication of a vector by a scalarCommutative law: s1 a = a s1

Associative law: s1 (s2 a) = (s1 s2)a = s2 (s1 a) = s1 s2 aDistributive law: (s1 + s2)a = s1 a + s2 aDistributive law: s1 (a + b) = s1 a + s1 bMultiplication by one: 1 ∗ a = aMultiplication by zero: 0 ∗ a = 0

aHomework 2.6 multiplies a vector b by various scalars.

a2a

-2a

a

2.9 Vector subtraction

As graphically shown to the right, the process of subtracting a vector b from avector a is simply addition and negation,a i.e.,

a − b ∆= a + -b

After negating vector b, it is translated so the tail of -b is at the tip of a. Next,the vector a + -b is drawn from the tail of a to the tip of the translated -b.b

aIn most (or all) mathematical processes, subtraction is defined as negation and addition.bHomework 2.8 draws b − a

∆= b + -a.

b

a

a + -b a

-b

Copyright c© 1992-2009 by Paul Mitiguy 22 Chapter 2: Vectors and dyadics

Page 23: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

2.10 Vector dot product

The dot product of a vector a with a vector b is defined in equation (2)in terms of

• |a| and |b|, the magnitudes of a and b, respectively• θ, the smallest angle between a and b (0 ≤ θ ≤ π).

When b is a unit vector, |b|= 1 and a ·············b can be interpreted as theprojection of a on b. Similarly, when a is a unit vector, a ·············b can beinterpreted as the projection of b on a.

Rearranging equation (2) produces an expression which is useful forfinding the angle between two vectors, i.e., θ =

(2)acos

(a ············· b|a| |b|

)

b

a

θ|b|

a ·············b ∆= |a| |b| cos(θ) (2)

The dot product is useful for calculating the magnitude of a vector v. Inview of equation (2), v ·············v = |v|2. Hence, one way to determine |v| isthe important relationship in equation (3).

v2 ∆= |v|2 = v ·············v|v| = +

√v ·············v

(3)

2.10.1 Properties of the dot-productDot product with the zero vector a ············· 0 = 0Dot product of perpendicular vectors a ·············b = 0 if a ⊥ bDot product of vectors having the same direction a ·············b = |a| |b| if a ‖ b

Dot product with vectors scaled by s1 and s2 s1a ············· s2b = s1 s2 (a ·············b)Commutative law a ·············b = b ············· aDistributive law a ············· (b + c) = a ·············b + a ············· cDistributive law (a + b) ············· (c + d) = a ············· c + a ·············d + b ············· c + b ·············d

2.10.2 Uses for the dot-product

Several uses for the dot-product in geometry, statics, and motion analysis, include

• Calculating an angle between two vectors (very useful in geometry)

• Calculating a vector’s magnitude (e.g., distance is the magnitude of a position vector)

• Calculating a unit vector in the direction of a vector [as shown in equation (1)]

• Determining when two vectors are perpendicular

• Determining the component (or measure) of a vector in a certain direction

• Changing a vector equation into a scalar equation (see Homework 2.21)

• Vector exponentiation

The definition of vector exponentiation of vn for the vectorv raised to the scalar power n and the specific case of v2 areshown to the right. Note: vn produces a non-negative scalar.

vn ∆= |v|n =(3)

+(v ·············v)n2

v2 ∆= |v|2 =(3)

v ·············v(4)

2.10.3 Special case: Dot-products with orthogonal unit vectors

When nx, ny, nz are orthogonal unit vectors, it can be shown (see Homework 2.7)

nxnz

ny

(ax nx + ay ny + az nz) ············· (bx nx + by ny + bz nz) = ax bx + ay by + az bz

Copyright c© 1992-2009 by Paul Mitiguy 23 Chapter 2: Vectors and dyadics

Page 24: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

2.10.4 Example: Microphone cable lengths and angles (with orthogonal walls)

A microphone Q is attached to three pegs A, B, and C by three cables. Knowing the peg locations andmicrophone location from point No, determine LA (the length of the cable joining A and Q) and the angle φbetween line AQ and line AB.

AB

C

Q

nx

ny

nz

No

1520

8

5

7

8

Quantity ValueDistance from A to B 20 mDistance from B to C 15 mDistance from No to B 8 mQ’s measure from No along back-wall 7 mQ’s height above No 5 mQ’s measure from No along left-wall 8 m

rQ/No = 7nx + 5ny + 8nz

Step-by-step solution:

• Form A’s position vector from No (inspection): rA/No = 8ny + 20nz

• Form Q’s position vector from A (vector addition and rearrangement):rQ/A = rQ/No − rA/No = 7nx + -3ny + -12nz

• Calculate rQ/A ············· rQ/A: (7nx + -3ny + -12nz) ············· (7nx + -3ny + -12nz) = 202

• Form LA, the magnitude of Q’s position vector from A: LA =√

rQ/A ············· rQ/A =√

202 = 14.2

• The determination of the angle φ starts with the definition of the following dot-productrQ/A ············· rB/A ∆=

∣∣∣rQ/A∣∣∣ ∣∣∣rB/A

∣∣∣ cos(φ)

• Subsequent rearrangement and substitution of the known quantities gives

cos(φ) =rQ/A ············· rB/A∣∣rQ/A

∣∣ ∣∣rB/A∣∣ =

rQ/A ············· rB/A

20 LA=

(7nx + -3ny + -12nz) ············· (-20 nz)20 ∗ 14.2

=240284

• Solving for the angle gives φ = acos(

240284

)= 32.32◦.

MotionGenesis solution

AB

C

Q

nx

ny

nz

No

1520

8

5

7

8

% File: MicrophoneCableLengthsOrthogonalWalls.al%------------------------------------------------------------NewtonianFrame N % Back WallPoint A, B, C % Points attached to wallsParticle Q % Microphone attached to cables%------------------------------------------------------------% Given position vectorsB.SetPosition( No, 8*Ny> )C.SetPosition( B, 15*Nx> )A.SetPosition( B, 20*Nz> )Q.SetPosition( No, 7*Nx> + 5*Ny> + 8*Nz> )%------------------------------------------------------------LA = Q.GetDistance(A)%------------------------------------------------------------phiRadians = GetAngleBetweenVectors( Q.GetPosition(A), B.GetPosition(A) )phiDegrees = phiRadians * ConvertUnits(radian,degree)%------------------------------------------------------------% Save input together with program responsesSave MicrophoneCableLengthsOrthogonalWalls.allQuit

Copyright c© 1992-2009 by Paul Mitiguy 24 Chapter 2: Vectors and dyadics

Page 25: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

2.11 Vector cross product

The cross product of a vector a with a vector b is defined in equation (5)in terms of

• |a| and |b|, the magnitudes of a and b, respectively• θ, the smallest angle between a and b (0 ≤ θ ≤ π).• u, the unit vector perpendicular to both a and b whose direction is deter-

mined by the right-hand rule.a

Note: The coefficient of u in equation (5) is inherently a non-negative quantity

since sin(θ) ≥ 0 because 0 ≤ θ ≤ π. Hence, |a×b| = |a| |b| sin(θ).aThe right-hand rule is a recently accepted universal convention, much like driving

on the right-hand side of the road in North America. Until 1965, the Soviet Union usedthe left-hand rule, logically reasoning that the left-hand rule is more convenient becausea right-handed person can simultaneously write while performing cross products.

b

a

θ|b|

u

a×b ∆= |a| |b| sin(θ) u (5)

2.11.1 Properties of the cross-product

Cross product with the zero vector a×0 = 0

Cross product of a vector with itself a× a = 0

Cross product of parallel vectors a×b = 0 if a ‖ b

Cross product with vectors scaled by s1 and s2 s1a × s2b = s1 s2 (a×b)

Cross products are not commutative a×b = -b× a (6)

Distributive law a× (b + c) = a×b + a× c

Distributive law (a + b) × (c + d) = a× c + a×d + b× c + b×d

Cross products are not associative a× (b× c) �= (a×b) × c

Vector triple cross product a× (b× c) = b (a ············· c) − c (a ·············b) (7)

When b is a unit vector |a×b|2 = a ·············a − (a ·············b)2

A mnemonic for a× (b× c) = b (a ············· c) − c (a ·············b) is “back cab” - as in were you born in the back of a cab?Many proofs of this formula resolve a, b, and c into orthogonal unit vectors (e.g., nx, ny, nz) and equate components.

2.11.2 Uses for the cross-product

Several uses for the cross-product in geometry, statics, and motion analysis, include• Calculating perpendicular vectors, e.g., v = a×b is perpendicular to both a and b• Determining when two vectors are parallel, e.g., a×b = 0 when a is parallel to b• Calculating the moment of a force or linear momentum, e.g., M = r×F and H = r×mv• Calculating velocity/acceleration formulas, e.g., v = ωωωωωωωωωωωωω × r and a = ααααααααααααα × r + ωωωωωωωωωωωωω × (ωωωωωωωωωωωωω × r)• Calculating the area of a triangle whose sides have length |a| and |b|

b

a

θ

b

a|a|sin(θ)

|b|

The area of a triangle ∆ is half the area of a parallelogram.a Sinceone geometrical interpretation of |a×b| is the area of a parallel-ogram having sides of length |a| and |b|,

∆ = 12 |a×b| (8)

aHomework 2.14 shows the utility of equation (8) for surveying.

Copyright c© 1992-2009 by Paul Mitiguy 25 Chapter 2: Vectors and dyadics

Page 26: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

2.11.3 Special case: Cross-products with right-handed, orthogonal, unit vectors

Given right-handed orthogonal unit vectors nx, ny, nz and twoarbitrary vectors a and b that are expressed in terms of nx, ny, nz asshown to the right, calculating a×b with the distributive propertyof the cross product happens to be equal to the determinant ofthe matrix and the expression shown below.a

aThis is proved in Homework 2.12.

nxnz

ny

a = ax nx + ay ny + az nz

b = bx nx + by ny + bz nz

a×b = det

nx ny nz

ax ay az

bx by bz

= (ay bz − az by)nx + (az bx − ax bz)ny + (ax by − ay bx)nz

2.12 Scalar triple product and the volume of a tetrahedron

The scalar triple product of vectors a, b, and c is the scalar defined in the various ways shown inequation (9).4 Homework 2.16 shows how determinants can calculate certain scalar triple products.

ScalarTripleProduct ∆= a ············· b × c = a × b ············· c = b ············· c× a = b × c ············· a (9)

A geometrical interpretation of a ·············b× c is the volume of a parallelepiped havingsides of length |a|, |b|, and |c|. The formula for the volume of a tetrahedron whosesides are described by the vectors a, b, and c is

Tetrahedron Volume =16

a ············· b× c

This formula is useful for volume (surveying cut and fill) calculations as well as 3D(CAD) solid geometry mass property calculations.

a

b

c

2.13 Dyads and dyadics (vector multiplied by a vector)

The dyad D that results from multiplication of the vectors a and b is definedas D ∆= a ∗ b = ab. To clearly distinguish a dyad from a scalar or vector,

it is common to use two arrows or two underlines, i.e.,−→−→D or D, or to use a

single line under a bold-face symbol, i.e., D.a

The sum of two or more dyads is called a dyadic. For example, letting a,b, c, and d be vectors, the dyads ab and cd can be formed. Their sumab + cd is a dyadic.b

aMotionGenesis uses >> to denote dyadics. For example, the dyadic D is D>>, the unitdyadic is 1>>, and the zero dyadic is 0>>.

bIn general, the dyadic ab + cd is not a dyad because it cannot be written as a vectormultiplied by a vector. Dyadics differ from vectors in that the sum of two vectors is a vectorwhereas the sum of two dyads is not necessarily a dyad.

Courtesy NASA

2.13.1 The zero dyadic and the unit dyadic

The zero dyadic 0 is defined as the dyad with two zero vectors. 0 ∆= 0 ∗ 0 (10)

4Although parentheses make equation (9) clearer, i.e., ScalarTripleProduct∆= a ············· (b× c), the parentheses are unnecessary

because the cross product b× c must be performed before the dot product for a sensible result to be produced.

Copyright c© 1992-2009 by Paul Mitiguy 26 Chapter 2: Vectors and dyadics

Page 27: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

The unit dyadic is denoted 1 and is defined by its property inequation (11).a As shown in Section 2.14, the unit dyadic can bewritten in terms of the orthogonal unit vectors bx, by, bz as shownin equation (12).b

aThe unit dyadic is similar to the identity matrix I whose defining propertyis I ∗ x = x ∗ I = x where x is any matrix.

bThe orthogonal unit vectors bx, by, bz do not have to be right-handedfor the unit dyadic to be expressed as 1 = bx bx + by by + bz bz. Unless across-product is involved, the right-handed nature of the vectors is irrelevant.

1 ·············v = v ············· 1 = vwhere v is any vector.

(11)

1 = bx bx + by by + bz bz (12)

2.13.2 Properties of dyadics associated with the vectors a, b, c, d, and w

Dyads are not commutative: ab �= baDistributive law: a (b + c) = ab + acDistributive law: (a + b) (c + d) = ac + ad + bc + bdPre-dot product: w ············· (ab + cd) = (w ·············a)b + (w ············· c)dPost-dot product: (ab + cd) ·············w = a (b ·············w) + c (d ·············w)Pre-cross product: w × (ab + cd) = (w× a)b + (w× c)dPost-cross product: (ab + cd) ×w = a (b×w) + c (d×w)Vector multiplication: s1a ∗ s2b = s1 s2 ab (s1 and s2 are scalars)

Dot product with 0: D ·············0 = 0 (D is any dyadic and 0 is the zero vector)

2.13.3 Dyadic examples

The following calculations use the orthogonal unit vectors ax, ay, az.axaz

ay

0 ············· (ax + 5ay) = 0

1 ············· (ax + 5ay) = ax + 5ay

1 = ax∗ax + ay∗ay + az∗az

(ax + 2ay + 3az) ∗ (4ax + 5ay + 6az) = 4ax ax + 5ax ay + 6ax az

+ 8ay ax + 10ay ay + 12ay az

+ 12az ax + 15az ay + 18az az

(ay az + 4az ax + 5az ay) ············· (ax + 2ay + 3az) = 3ay + 14az

(ax + 2ay + 3az) ············· (ay az + 4az ax + 5az ay) = 2az + 12ax + 15ay

The next set of calculations also use the orthogonal unit vectors bx, by, bz.

bxbz

by

(ax + 2ay) ∗ (bx + 3bz) = ax bx + 3ax bz + 2ay bx + 6ay bz

(ax bx + 3ax bz + 2ay bx + 6ay bz) ·············bx = ax + 2ay

ay ············· (ax bx + 3ax bz + 2ay bx + 6ay bz) = 2bx + 6bz

2.14 Optional∗∗: Unit dyadic expressed with orthogonal unit vectors

To prove 1 = bx bx+by by+bz bz in equation (12), note that equations (3.1) and (3.4) allow an arbitraryvector v to be expressed in terms of any orthogonal unit vectors bx, by, bz as

v = (v·············bx)bx + (v·············by)by + (v·············bz)bz = v ············· (bx bx + by by + bz bz)

As described in Section 2.13, the unit dyadic is defined by its property v ·············1 = v, hence

v ············· 1 = v ············· (bx bx + by by + bz bz) or v ············· [1 − (bx bx + by by + bz bz)] = 0

The proof is completed by noting that v is an arbitrary vector (e.g., not-necessarily 0).

Copyright c© 1992-2009 by Paul Mitiguy 27 Chapter 2: Vectors and dyadics

Page 28: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

2.15 MotionGenesis vector commands

Command DescriptionCross( a>, b> ) Returns a × bDot( a>, b> ) Returns a ············· bGetMagnitude( v> ) Returns |v|GetMagnitudeSquared( v> ) Returns |v|2GetUnitVector( v> ) Returns v / |v|GetAngleBetweenVectors( a>, b> ) Returns the angle between vectors a and bGetAngleBetweenVectors( Ax>, By> ) Returns the angle between unit vectors ax and by

Vector( A, x, y, z ) Returns the vector xAx + y Ay + z Az

Vector( A, [x, y, z] ) Returns the vector xAx + y Ay + z Az

2.16 Example: MotionGenesis vector operations

Vector operations such as addition, scalar multiplication, dot-products, andcross-products can be performed with MotionGenesis as shown below. axaz

ay

(1) % File: VectorDemonstration.al(2) RigidFrame A % Create orthogonal unit vectors Ax>, Ay>, Az>(3) V> = Vector( A, 2, 3, 4 ) % Construct a vector V>

-> (4) V> = 2*Ax> + 3*Ay> + 4*Az>

(5) W> = Vector( A, 6, 7, 8 ) % Construct a vector W>-> (6) W> = 6*Ax> + 7*Ay> + 8*Az>

(7) V5> = 5 * V> % Multiply V> by 5-> (8) V5> = 10*Ax> + 15*Ay> + 20*Az>

(9) magV = GetMagnitude( V> ) % Magnitude of V>-> (10) magV = 5.385165

(11) unitV> = GetUnitVector( V> ) % Unit vector in the direction of V>-> (12) unitV> = 0.3713907*Ax> + 0.557086*Ay> + 0.7427814*Az>

(13) addVW> = V> + W> % Add vectors V> and W>-> (14) addVW> = 8*Ax> + 10*Ay> + 12*Az>

(15) dotVW = Dot( V>, W> ) % Dot product of V> and W>-> (16) dotVW = 65

(17) crossVW> = Cross( V>, W> ) % Cross product of V> and W>-> (18) crossVW> = -4*Ax> + 8*Ay> - 4*Az>

(19) crossWWV> = Cross( W>, Cross(W>,V>) ) % Vector triple cross product-> (20) crossWWV> = 92*Ax> + 8*Ay> - 76*Az>

(21) dotVWithZeroVector = Dot( V>, 0> ) % Dot product of V> with the zero vector-> (22) dotVWithZeroVector = 0

(23) dotVWithUnitDyadic> = Dot( V>, 1>> ) % Dot product of V> with the unit dyadic-> (24) dotVWithUnitDyadic> = 2*Ax> + 3*Ay> + 4*Az>

(25) multVW>> = V> * W> % Form a dyadic by multiplying V> and W>-> (26) multVW>> = 12*Ax>*Ax> + 14*Ax>*Ay> + 16*Ax>*Az> + 18*Ay>*Ax> + 21*Ay>*

Ay> + 24*Ay>*Az> + 24*Az>*Ax> + 28*Az>*Ay> + 32*Az>*Az>

Copyright c© 1992-2009 by Paul Mitiguy 28 Chapter 2: Vectors and dyadics

Page 29: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

Chapter 3

Vector basis

Why use a vector basis?

Unit vectors are sign-posts, e.g., up, down, left, right, etc. With three orthogonal unitvectors (i.e., a vector basis), one has a way to “give directions” in 3D space. Howunit vectors are introduced depends on the analyst and field of study, e.g., biomechanics,aeronautics, vehicle dynamics, statics, etc.a

aFor example, a vector basis for Earth’s surface is NED (locally North/East/Down). A basis thatorients Earth relative to other celestial objects is ECEF (Earth-Centered/Earth-Fixed) with a unit vectorpointing from Earth’s center to 0 longitude/0 latitude, a second unit vector pointing to geometric North,and a third unit vector perpendicular to the other two.

3.1 What is a vector basis

A vector basis (often abbreviated basis) is a set of linearly independent vectors which span aspace. Each linearly independent vector is called a basis vector for the space. For example,the figure to the right shows vectors a1, a2, and a3 which form a three-dimensional vectorbasis. Notice that the basis is not an orthogonal basisa or unitary basisb

aAn orthogonal basis has mutually perpendicular basis vectors.bA unitary basis has unit basis vectors.

a1

a2

a3

A

One way to construct a three-dimensional basis with two non-parallel vectors a1 and a2

is with a1, a2, and a3∆= a1× a2. Alternately, a right-handed orthogonal basis can be

constructed with a1, a3 × a1, and a3.

It is very common to use three orthogonal unit vectors to form an orthogonal unitarybasis. A right-handed orthogonal unitary basis has various visual representations (shownto the right). Note: When a3 is absent, it is implied by the right-hand rule.

A set of three vectors that has an intrinsic order, e.g., a1, a2, a3, is called right-handed(or dextral) when a1 × a2 ············· a3 > 0. Alternately, the set is left-handed if a1 × a2 ············· a3 < 0.It is conventional to use a right-handed basis.a

aTo physically demonstrate a basis, hold your right hand with the thumb, forefinger, and middle fingerpointing in orthogonal directions. Chapter 4 is summarized with two hands (each with a basis) and thequestion “how do I relate two bases” .

a1a3

a2

a1a3

a2

a1

a2

29

Page 30: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

k i

j

Left/ Right -handed basis

ay

ax

az

Left/ Right -handed basis

ayax

az

Left /Right -handed basis

3.2 Extracting scalar equations from the vector equation v = 0

A first method for forming up to three linearly independent scalar equations from the vector equationv = 0 is by dot-multiplying v = 0 with three non-parallel, non-coplanar (but not necessarily orthogonalor unit) vectors a1, a2, a3.A second method expresses v as in equation (1), i.e., v = v1 a1 + v2 a2 + v3 a3, and writes an equallyvalid (but generally different) set of linearly independent scalar equations (shown below).Note: The proof that vi = 0 (i= 1, 2, 3) follows directly by substituting v = 0 into equation (2).

Method 1: v ············· a1 = 0 v ············· a2 = 0 v ············· a3 = 0Method 2: v1 = 0 v2 = 0 v3 = 0

3.3 Rigid basis

When the magnitude of each basis vector in a vector basis is constant and the anglesbetween bases vector are constant, the basis is called a “rigid basis” and one can attacha unique reference framea to that basis.b

aA reference frame is a rigid object that can be constructed by as few as three non-collinear pointswhose distance from each other are constant. Reference frames are discussed in Chapter 6.

bEven though a rigid basis implies a unique reference frame, each reference frame contains an infinitenumber of bases. For example, a rigid basis consisting of a1, a2, a3 implies a reference frame A in whicha1, a2, a3 are fixed. However, one is free to fix other rigid bases (e.g., ax, ay, az) in A.

a1

a2

a3

A

3.4 Non-orthogonal basis

There are situations in which it is sensible to use a non-orthogonal basis. For example, a non-orthogonalbasis plays an important role is in determining the volume, centroid, and inertia properties of a tetrahedron.Non-orthogonal bases are also useful in motion studies (e.g., gait studies) involving irregularly-shapedobjects (e.g., human bones) that require markers (devices which track the location of a single point) oneasily-identifiable, physically-meaningful locations (e.g., anatomic landmarks). It is easier (and morephysically meaningful) to construct a non-orthogonal basis out of basis vectors which are aligned withmarkers of interest (e.g., pointing from one marker to another marker).

3.5 Optional∗∗: The language, history, and culture of “left” and “right”Language Word Translation Meaning More infoEnglish right right correct, “you are right” Engineers like being “right”English left left “left out”Latin right dexter nimble (dextereous)Latin left sinistre dark and mysteriousFrench right droit adroit means to the right or skillfulFrench left gauche socially clumsy http://www.gauche.comGreek right orthos , dexion Root of the word orthogonal

Copyright c© 1992-2009 by Paul Mitiguy 30 Chapter 3: Vector basis

Page 31: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

3.6 Concept: What is the vector vs. how is it expressed

The figure to the right shows a particle Q that slides along a straighttrack B which spins in a reference frame N . A spring connects Q topoint No (No is fixed in both B and N).

Right-handed, orthogonal, unit vectors nx, ny, nz are fixed in Nwith nx directed horizontally right and nz parallel to the axis of B’srotation in N .

A second set of right-handed, orthogonal, unit vectors bx, by, bz arefixed in B, with bx directed along the track from No to Q and bz = nz.

B

bxby

bz

N

No

Qx

nznx

ny

=

θ

The point of this example is to clarify two distinct concepts:• What is the vector (the name on the left-hand side of the equal sign)

• How is the vector expressed (the expression on the right-hand side of the equal sign)

rQ/No (Q’s position vector from No) can be expressed in various bases.Expressed in terms of bx, by, bz.rQ/No = xbx

Expressed in terms of nx, ny, nz.rQ/No = x [cos(θ)nx + sin(θ)ny]

FQ (the linear spring force on Q) can be expressed in various bases.Expressed in terms of bx, by, bz.FQ = -k xbx

Expressed in terms of nx, ny, nz.FQ = -k x [cos(θ)nx + sin(θ)ny]

BvQ (Q’s velocity in B) can be expressed in various bases.Expressed in terms of bx, by, bz.BvQ = xbx

Expressed in terms of nx, ny, nz.BvQ = x [cos(θ)nx + sin(θ)ny]

NvQ (Q’s velocity in N) can be expressed in various bases.NvQ is not the same as BvQ. These are different vectors.

Expressed in terms of bx, by, bz.NvQ = xbx + x θ by

Expressed in terms of nx, ny, nz.NvQ = [x cos(θ) − x θ sin(θ)]nx + [x sin(θ) + x θ cos(θ)]ny

The important point to remember is:A vector can be expressed in various bases without changing the vector.A vector’s magnitude and direction are not changed by expressing it in a different basis.

Copyright c© 1992-2009 by Paul Mitiguy 31 Chapter 3: Vector basis

Page 32: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

3.7 Expressing a vector

Given an arbitrary vector v and a set of three non-parallel, non-coplanar (but not necessarilyorthogonal or unit) vectors a1, a2, a3, one can express v in terms of a1, a2, a3 as

a1

a2

a3

A

v = v1 a1 + v2 a2 + v3 a3 (1)

where v1, v2, and v3 are scalar functions equal to1

v1 =v ············· (a2 × a3)a1 ············· (a2 × a3)

v2 =v ············· (a3 × a1)a2 ············· (a3 × a1)

v3 =v ············· (a1 × a2)a3 ············· (a1 × a2)

(2)

When a1 and a2 are nonparallel and a3∆= a1× a2, equation (2) simplifies to

v1 =v ············· [(a2)2 a1 − (a1·············a2) a2]

(a1 × a2 )2v2 =

v ············· [(a1)2 a2 − (a1·············a2) a1](a1 × a2 )2

v3 =v ············· [a1 × a2](a1 × a2 )2

(3)

When a1, a2, a3 are right-handed orthogonal unit vectors, equation (2) reduces to

a1a3

a2

v1 = v ············· a1 v2 = v ············· a2 v3 = v ············· a3 (4)

3.8 Expressing a vector basis in terms of another vector basis

One set of basis vectors (e.g., b1, b2, b3) can be expressed in terms of another set of basis vectors (e.g.,a1, a2, a3) with the scalar functions Rij (i, j =1, 2, 3) as either

b1 = R11 a1 + R12 a2 + R13 a3

b2 = R21 a1 + R22 a2 + R23 a3

b3 = R31 a1 + R32 a2 + R33 a3

or b1

b1

b1

=

R11 R12 R13

R21 R22 R23

R31 R32 R33

a1

a1

a1

When ai and bi (i = 1, 2, 3) are both right-handed, orthogonal, unitary bases, the matrix relating bi to ai iscalled the bRa rotation matrix and has many special properties as described in Chapter 4.

1To prove equation (2), dot multiply both sides of equation (1) with a2 × a3 to get v ············· ( a2 × a3) =(1)

v1 a1 ············· (a2 × a3).

Isolate v1 to arrive at the first expression in equation (2). Proceed similarly to find v2 and v3.Note: Since a1, a2, a3 are non-parallel, non-coplanar vectors a1 ············· (a2 × a3) �= 0.

Copyright c© 1992-2009 by Paul Mitiguy 32 Chapter 3: Vector basis

Page 33: Math review - Stanford Universityweb.stanford.edu/class/me331b/documents/MitiguyGradDynamicsA… · Chapter 1 Math review 1.1 Why math is important Courtesy NASA Math is a foundation

3.9 Optional∗∗: Coordinate system

A coordinate system is a set of scalar quantities, typically angles or distances, used in specifying thelocation of points, curves, surfaces, and solids. A coordinate is a single scalar in the set. A generalizedcoordinate is a scalar quantity that is useful in locating points, curves, surfaces, and solids but is notnecessarily associated with a coordinate system.2 In other words a generalized coordinate is a moregeneral type of coordinate. Historically, coordinate systems played a major role in dynamics and thefamiliar coordinates in Cartesian, cylindrical, and spherical coordinate systems are listed below.3 In thepast hundred years, it has become increasingly apparent that generalized coordinates are the moreuseful description of position and orientation.4

Coordinate system Method for locating pointsCartesian coordinate system Three distances measures, e.g., (x, y, z)Cylindrical coordinate system Two distances and an angle, e.g., (r, θ, z)Spherical coordinate system one distance and two angles, e.g., (ρ, θ, φ)

The most famous coordinate system is a rectangular Cartesian coordinate system which consists ofthree mutually-perpendicular lines, called coordinate axes, along which measurements are done andwhich all intersect at one point called the origin. The differences between a Cartesian coordinate systemand a basis are highlighted below.5

• A Cartesian coordinate system has an origin and a set of coordinates. A basis does not.• A Cartesian coordinate system has coordinate axes along which measurements are done. A basis

does not.• A Cartesian coordinate system does not intrinsically have a basis - although one can easily be con-

structed by introducing unit vectors that are oriented parallel to the coordinate axes and whose senseis determined by the positive direction along the coordinate axes.

XY

Zo

Cartesian coordinate system

axaz

ay

Basis

3.10 Optional∗∗: Rigid frame

A rigid frame is the combination of a rigid vector basis and a point (called itsorigin). A rigid frame is a useful measuring device in multibody dynamics, robotics,aeronautics, vehicle dynamics, biomechanics, etc. For example, the figure to the rightshows a generic rigid frame B.

Bo

By

Bx

BzRigid frame

2A generalized coordinate may be a variable, constant, or specified function of time.3A spherical coordinate system is useful for describing the location of a point on a sphere. When studying the motion of

particles moving on the Earth, e.g., the geology of a particle in a river, it is helpful to use a spherical coordinate system becauseρ is a constant and the number of variables in the analysis is decreased from three to two. Using a Cartesian coordinate systemto study a particle moving on a sphere introduces an inherent relationship between x, y, and z, i.e., x2 + y2 + z2 = constant.Similarly, using a polar coordinate system necessitates an inherent relationship between r, θ, and z, i.e., r2 + z2 = constant.However, Homework 4.13 shows that spherical coordinates have an inherent singularity at the “North” and “South” pole.

4Other related coordinates include curvilinear, Plucker, canonical, intrinsic, parallel, elliptic, ellipsoidal, prolate spheroidal,oblate spheroidal, conical, parabolic, paraboloidal, toroidal, bispherical, biangular, etc.

5It is usually more efficient to use generalized coordinates and bases than coordinate systems.

Copyright c© 1992-2009 by Paul Mitiguy 33 Chapter 3: Vector basis