I

Numerical Methods for Ordinary Differential Equations

1 Introduction

Mathematica® uses, for the integration of systems of ordinary differen• tial equations, suitable internal routines which are not visible by the user. These ordinary solvers are like black boxes devised by specialists which are in charge of giving as output the evolution of the state variable, when the mathematical problem is given as input. Therefore, in principle, the user may even forget about the numerical scheme actually used and trust the internal library. However, we believe that, when handling computer libraries, it is always useful to know what are the methods used and their peculiarities. The technical details will be reserved to courses. This appendix will report the basic knowledge on some numerical meth• ods commonly used for the integration of initial and boundary-value prob• lems. Completeness is not, however, claimed. These methods also support the solution of initial-boundary value problems which have been briefly dealt with in Chapter 9. It is written in the form of a manual for the user and will try to sum• marize the essential features of some well-known methods, weighting their pros and cons and pointing out, for instance, their accuracy and stability properties.

341 342 Mechanics and Dynamic Systems

2 Numerical Methods for Initial-Value Problems

In order to understand the concepts of accuracy and stability, consider the simplest conceivable method for solving initial-value problems, the Euler method. If one knows the state variable at time ti and wants to compute its value at time ti+l = ti + h, the simplest idea consists in approximating the solution of du dt = f(t,u), (1.2.1) { U(ti) = Ui, with

(1.2.2) or (1.2.3)

Since

the above corresponds to a Taylor expansion of the solution u stopped at first order, which corresponds somewhat to following the di• rection of the to the solution in til as shown in Figure 1.1a.

u

ui m;; h t t (a) (b)

Figure I.1 - Differential representation of (a) Forward Euler method and (b) Crank-Nicholson method. Appendix I 343

The truncation error Terr is defined as the norm of the difference between the solution to the differential equation and the numerical solution divided by the time step used in the numerical scheme. It can be proved, under suitable regularity assumptions, that

(1.2.4)

Le., the error goes like h and one has a first order method. In general, if the truncation error goes like hP , the method is pth order, which means that halving the step halves the truncation error p times. This is what is generally meant by accuracy of the method. Another important requirement of a numerical scheme is that these errors should not be amplified without bound as time goes by, Le., the time step has to be chosen so that the scheme is stable. It can be proved that each scheme is characterized by a domain in the complex plane called the stability region, which can be used to determine a condition on the time step to be used in the integration. The following procedure should be used: • Starting from a nonlinear model, consider its linearized form

du dt = Au,

obtained for instance by linearization about the initial condition; • Compute the eigenvalues AI, ... , An of A, the so-called spectrum of the linearized model; • Choose, if possible, a not too restrictive time step h such that all hAi (i = 1, ... n) belong to the stability region. Then the numerical errors are not amplified during the integration and therefore the scheme can be considered for simulating the original nonlinear model. If, instead, there are some eigenvalues which remain outside the stability region, then one must be aware that the numerical errors grow exponentially in time. For instance, in the case of forward Euler method (1.2.2), the stability region A is the region in the complex plane inside the unit circle centered in -1. This means that An~ = [-2,0] and AnSS = {O}, where ~ and SS are, respectively, the real and imaginary axes. Hence the method can be used if the spectrum of the ordinary differential equation has a negative real eigenvalue A, since one can set h < 2/IAI to force that eigenvalue in the stability region. However it can not be used if the ordinary eigenvalue has a purely imaginary eigenvalue (corresponding to an undamped oscillation), because one is never able to force it inside the stability region, and it is 344 Mechanics and Dynamic Systems not convenient if the real part of an eigenvalue is much smaller than the imaginary part (small damping). Runge-Kutta methods Runge-Kutta methods are popillar for their adaptability and versatility and work quite well for all nonstiff problems. They are obtained by evaluating the function f at different values of t and u, and by suitably combining these values. In this way it is possible to obtain methods of any order of accuracy. For instance, one has

2nd order: UHl = Ui + ~ ( K 1 + K2), (1.2.5) where

~ 3rd order: UHl = Ui + (K 1 + 4K2 + K 3 ), (1.2.6) where

(1.2.7) where

K 1 = f(ti, Ui), ~,Ui ~Kl) K2 = f (t i + + , ~,Ui ~K2) K 3 = f (t i + + ,

K 4 = f(ti + h, Ui + hK3 ). Recalling that the initial-value problem with initial condition U(ti) = Ui can be written in integral form as

U(t) = Ui + lit f(8, U(8)) d8, (1.2.8) Appendix I 345 and, in particular,

(1.2.9) it can be observed that both the third- and the fourth-order methods are closely related to Simpson's rule applied to the integrals in (1.2.9). The stability regions of the second-order method has an ellipsoidal shape, while that of the third- and fourth-order methods are bean-shaped. More in detail

2nd order: An~= [-2,0] and An~={O}, 3rd order: An~= [-2.51,0] and A n ~ = [-v'3, v'3], (1.2.10) 4th order: A n ~ = [-2.79,0] and A n ~ = [-2V2,2V2].

Third and fourth-order Runge-Kutta methods are then recommended when dealing with problems for which the spectrum is not available since they include both a part of the imaginary axis and a part of the negative real axis. The disadvantage of these schemes is that several evaluations of f have to be performed per time step. Therefore, if the computation of f is very heavy, this method may demand an excessive amount of labor per step and become inconvenient. With respect to the multistep methods that will be dealt with later on, Runge-Kutta methods have the advantage of being self-starting and adaptive, in the sense that the time step can be changed at any moment according to an estimate of the local error. Unfortunately, it is not simple to get this estimate, as it is for the predictor-corrector methods (as we shall see). In this case, one can either integrate again using a method of the same order but halving the time step, or integrate again with a higher-order scheme. The time step has then to be decreased if the difference between the two values (over h) is larger than a specified maximum tolerance and can be increased if this difference is smaller than the minimum required tolerance. Of course, this checking is time consuming. Crank-Nicholson and Predictor-Corrector Methods All the previous methods get the approximation UiH at t = ti+l on the only basis of the solution Ui at the previous step t = ti. The Crank-Nicholson method, instead, averages the values of f in ti and tiH so that it can be written as h UiH = Ui + 2" [f(ti, Ui) + f(ti+l, UiH)J. (1.2.11) This corresponds to proceeding for half the time step along the value of the derivative at ti and for the remaining part along the derivative at tiH 346 Mechanics and Dynamic Systems

(see Figure I.1b), or to evaluating the integral in (1.2.9) by the trapezoidal rule (see Figure 1.2b), i.e., it approximates the integral under f(t, u) with the one under the polynomial of degree 1 (the linear interpolant) linking with a straight line the nodes

and

The method obtained in this way is second order. Its stability region is the whole negative half plane, and therefore

A n ~ = (-00,0] and An'S = (-00, +00). (1.2.12)

The magnitude of the stability region is one reason why this method is very popular, in spite of its not too high accuracy. To obtain the value UiH the Crank-Nicholson method then uses both the information at time ti and at time tHI and the linear interpolant to ap• proximate the integral in (1.2.9). One could generalize this same procedure by exploiting more information from the past. For instance, taking into account Pi- l = (ti-l, f(ti-l' ui-d) one can compute the parabola through Pi-I, Pi and PHI and approximate the same area considered before with the area under the parabola. Proceeding further, one can consider also Pi - 2 and compute the cubic interpolant. According to the number of nodes used, one has the following implicit multistep methods (or Adams-Moulton methods)

1st order: UiH =Ui + hf(ti+l' Ui+l), h 2nd order: Ui+l =Ui + 2" [f(tiH, uHd + f(ti, Ui)], h 3rd order: UiH =Ui + 12 [5f(tH1 , uHd + 8f(ti, Ui) - f(ti-l, ui-d), h 4th order: Ui+l =Ui + 24 [9f(tHI' uHd + 19f(ti, Ui)

- 5f(ti-l, ui-d + f(ti-2, Ui-2)]' (1.2.13) The first order scheme is called , while the sec• ond order scheme is the Crank-Nicholson method. These methods, how• ever, present on the right-hand side the evaluation of fin (tiH, UiH)' so that the value of U at the (i + 1)th step is not explicitly given in terms of known quantities. The methods are then called implicit. Then, one need either to use iterative methods or to find an approxi• mation of UiH to use on the right-hand side of (1.2.13). Of course, this predictive approximation has to have the same accuracy of the methods Appendix I 347

f

(a)

ti ti+I t

f

f(tH1) (b)

f(ti )

~ ti ti+I t

f

f(ti+V (c)

f(ti ) f(ti-J t i-I t·, ti+I t

f

f(ti+V (d) f(tt-2) f(ti ) f(ti-J t ti-2 t i-I t·, ti+I

Figure 1.2 - Integral representation: (a) Backward Euler method; (b) Crank-Nicholson method; (c) Third order implicit multistep method; and (d) Fourth order implicit multistep method. 348 Mechanics and Dynamic Systems

which has been chosen as corrector. The predictors can be found using a procedure similar to the one mentioned above, but that, for instance, computes the parabola through Pi- 2, Pi-I, and Pi, and extrapolates it to evaluate the integral in the interval [ti, ti+1]' One then obtains

1st order: ui+1 =Ui + hf(ti, Ui),

2nd order: ui+1 =Ui + ~ [3f(ti, Ui) - f(ti-l, Ui-l)],

3rd order: ui+1 =Ui + 1~ [23f(ti' Ui) - 16f(ti_l, ui-d + 5f(ti-2, Ui-2)]'

4th order: ui+1 =Ui + 2~ [55f(ti' Ui) - 59f(ti_l, ui-d

+ 37f(ti-2, Ui-2) - 9f(ti-3, Ui-3)]. (1.2.14)

So, for instance, the fourth-order predictor-corrector method can be written as

Ui+l = Ui + 2~ [55f(ti' Ui) - 59f(ti-l, ui-d + 37f(ti-2, Ui-2)

- 9f(ti-3, Ui-3)], (1.2.15) UHl = Ui + 2~ [9f(ti+1' ui+1) + 19f(ti' Ui) - 5f(ti-l, Ui-I)

+ f(ti-2, Ui-2)]' The stability regions of these methods include

1st order: An~= [-2,0] and An~ = {O}, 2nd order: An~= [-2,OJ and A n ~ = [-1.29,1.29]' 12 (1.2.16) 3rd order: An1R= [-5,0] and A n ~ = [-1.2,1.2], 24 4th order: An1R = [-9,0] and A n ~ = [-0.97,0.97].

With respect to Runge-Kutta methods, predictor-corrector schemes only need two new function evaluations per time step, as the evaluation at pre• vious time steps has been already computed at previous times and can be opportunely stored. Hence, if the evaluation of f is complicated a fourth order predictor scheme results convenient with respect to a fourth-order Runge-Kutta method, which needs four function evaluations per step. The disadvantage of predictor-corrector methods is that they need a starting procedure for the very first time steps, which must be of the same Appendix I 349 order in order to keep the truncation error always of the same size. For this purpose, Runge-Kutta methods are often used. As similar problems occur when adapting the time step, which is easy to do since the error committed during the integration between ti and ti+1 can be readily estimated as

~ (UH1 - ui+1)' 2nd order

UHl - u(tHd ~ 11 (Ui+1 - Ui+1) , 3rd order (1.2.17) 0

27019 (uHl - UHl'*) 4th order where u(t) is the solution of the system of ordinary differential equations with initial condition U(ti) = Ui, Ui+l is the predicted value, and uHl is the value after correction at t = tHI' However, since one uses information from several previous steps at given temporal distances, then by changing the time step one is required to use again the starting procedure already used at the beginning as computation were to start from scratch from that moment on.

3 Numerical Methods for Boundary-Value Problems

Some methods useful to solve boundary-value problems are sketched in this section: the shooting method, the collocation method, and the finite differ• ence method. For other methods or further details on the ones presented here, see for instance [KEa]. Shooting Method The basic idea of the shooting method is to transform a boundary-value problem into an initial-value problem. For instance, for a second order ordinary differential equation one can start the computation with assumed initial conditions

U(O) = UQ and (1.3.1 ) hoping that the solution satisfies, within a given tolerance, the other bound• ary condition, say u(T) = UT. It is like holding a bow having a target to hit at the other end point. One has only to decide the right inclination of the bow to aim with the arrow. If the target is missed, the amount and the direction of the deviation may suggest the appropriate correction to improve the result (see Figure 2.8). 350 Mechanics and Dynamic Systems

Denoting by u~) the value of u(T) obtained with initial condition

du(O) = (i) dt Vo , the next guess can be obtained by the secant method

(i-I) (HI) _ (i-I) (i) (i-I)) ur - ur Vo - Vo - Vo - Vo (i) (i-I) . (1.3.2) ur -ur The procedure is then iterated to convergence; however, there is no guarantee of convergence, as put in evidence in Section 2.6. The rapidity of convergence depends on how good the initial guess is, which can be obtained from physical considerations. If the simplest version of the shooting method just presented should fail to converge, one may try to use the point t = T as a starting point with initial conditions

u(T) = Ur, and (1.3.3) and solve backward in time. If the reverse shooting should also fail, the last choice is to use par• allel shooting [KEa]. In this technique, the interval is subdivided in a moderate number of subintervals

and in any subinterval the initial-value problem with initial conditions

and for i = 0, ... ,N -1, (1.3.4) has to be solved (of course to = 0). The quantities

i = 1, ... ,N, (1.3.5a) and

i=1, ... ,N-1, (1.3.5b) where UN = Ur measure the discontinuities in u and in its derivative. One has then to determine the 2N - 1 parameters V2, ... , VN-I and WI, ... , WN -1, so that the 2N - 1 residuals vanish. Appendix I 351

The easiest application of this technique is obtained when the interval is halved and the two problems respectively with initial conditions (1.3.1) and (1.3.3). are solved (one forward and the other backward in time) till, say, t = T/2, and then Vo and VT are arranged so that u and du/dt are continuous in the midpoint. Things get even more complicated for higher order problems, which involve a knowledge of some numerical methods that cannot be introduced here.

Collocation Methods Another general idea to be followed consists in introducing in the interval I a number N +1 of suitably located points Xi, called collocation points, and a set of N functions L i , called cardinal interpolants, characterized by the property Li(Xi) = 1, (1.3.6) For instance, Lagrange polynomials

N II(x - Xi) j=O j# L i (X) = ...:.N-:-:---- II (Xh - Xi) j=O j#h

Sine functions .( )_ sin 7l"(x - Xi) S,X - , 7l"(x - Xi) and fundamental splines are example of functions satisfying (1.3.6). If the values Uj of u(x) at the nodes Xj is known, then u(x) can be approximated with the linear combination of the cardinal interpolants

N u(x) ~ uN (X) = L ujLj(x). (1.3.7) j=O

The derivative of u(x) is then approximated by

du duN ~ dLj -(X) ~ -(X) = L.J u-(x). (1.3.8) dx dx Jdx j=1 352 Mechanics and Dynamic Systems

In particular, its value in the collocation point Xi is approximated by

(1.3.9) where

(1.3.10)

Therefore, one can write the vector of the value of the derivative in the collocation points as

(1.3.11 )

Consider, for instance, the linear boundary-value problem

d2u du dx2 + al(x) dx + ao(x)u = f(x),

u(O) = uo, (1.3.12)

T ~~(T) = v .

Collocating the differential equation in the collocation points and using approximations like (1.3.8) yields the algebraic problem

N L (Drj + al(xi)Dij) Uj + ao(xi)ui = Ii, j=l (1.3.13) N T LDNjuj = v , j=l for i = 2, ... , N - 1, and where fi = f(Xi) and Drj are the elements of the matrix D 2 = DD which computes the second derivative in the collocation points. Defining Appendix I 353

where Dij is the Kronecker delta, Eq. (1.3.13) can be written in the following matrix form

1 0 D21 D 22 D2,N VN~'" DN~l'No 1 ( D N - 1,2 DN-l,N-l D Nl DN2 DN,N-l DNN (1.3.14) The first and last rows in (1.3.14) refer to the boundary conditions, while the remaining rows refer to the differential equation in the internal collocation points. The generalization to an equation of order n is straightforward at this point, while the one to systems of differential equations might be technically, but not conceptually, more complicated. Sometimes the use of iterative schemes can be convenient and need be applied to use the same technique to solve nonlinear problems.

Finite Difference Methods The basis of the method consists in replacing every deriva• tive in the differential equation and in the boundary conditions with an appropriate approximation. Central differences

(1.3.15)

where Ui = U(ti), are usually preferred because they lead to better accuracy. Dividing the interval [0, T] in N equal parts of width h = T / N, and denoting ti = ih, the discretized version of the boundary-value problem

d2U du dx2 +a1(x)dx +ao(x)u=j(x), (1.3.16) u(O) = uo, T 1u(T) = u , 354 Mechanics and Dynamic Systems can be written as

(1.3.17)

where, for i = 2, ... , N - 2,

Equation (1.3.17) is a tridiagonal system of N - 1 equations

Au=f, (1.3.18) where /31 1'1 0 0 0 Ct2 /32 1'2 0 0 0 Ct3 133 1'3 0 A=

0 0 CtN-2 13N-2 1'N-2 0 0 0 CtN-l 13N-1

2 h !(h) - Ct1UO U1 2 U2 h !(t2 ) 2 U3 h !(t3) u= f=

2 UN-2 h !(tN-2) UN-1 2 h !(tN-d - 1'N-1UT which, under the assumption that

2 h< , max la1(x)1 tE[O,T] can be solved by a tridiagonal solver. Appendix I 355

One has to be aware that if ao(x) is positive, then the boundary-value problem may lack a unique solution or even have no solution at all (see Example 2.4). If, for instance, the boundary condition u(T) = UT is replaced with

(1.3.19)

then, one has to add the equation

(1.3.20) which is obtained by evaluating the ordinary differential equation in x N = T and replace the fictitious unknown UN+! = u(T+h) with the value obtained by approximating (1.3.19) with central differences, Le.,

UN+l = UN-l + 2hvT· II

Kinematics, Applied Forces, Momentum, and Mechanical Energy

1 Introduction

This appendix provides a technical support mainly (but not only) to Chap• ters 4 through 6 and deals with mechanical calculations related to kinemat• ics, force field analysis, mass distribution, momentum, and energy. The above mechanical quantities refer to a system of fixed orthogonal axes O(x, y, z) with unit vectors i, j, k. This frame does not need to be an inertial one. The analysis is developed both for material particles and rigid body models. In the latter case, a more elaborated analysis may be often needed. Let u and v be two vectors defined with respect to the above frame

u = U x i + uyj + U z k, (11.1.1 ) and

v = V x i + v y j + V z k, (11.1.2) we recall some simple vector algebraic . In particular, their vector sum is given as follows:

(II.1.3)

The internal product of the two vectors is a scalar defined as follows

u· v = lullvl cosa, (11.1.4)

357 358 Mechanics and Dynamic Systems where a is the angle between the two vectors, while the external product is a vector defined as

u x v = lullvl sinan, (II.1.5) where n is the unit vector orthogonal to the plane the two vectors directed in order to see a counterclockwise rotation from u to v. Detailed componentwise calculations of the above quantities yield, re• spectively (II. 1.6) and

2 Systems of Applied Forces

Given a discrete systems of N forces F j each applied in a point Xj, its resultant and moment with respect to 0 are, respectively, defined by

(II.2.1) and N

Mo = ~)Xj - xo) x F j . (11.2.2) j=l The definition can be generalized to distributed systems of forces F(x) acting on S. In this case one has

R= LF(x)dV (II.2.3) and Mo = L(x - xo) x F(x) dV. (11.2.4) It can be verified, by direct calculations, that the moment of a system of forces applied on the same point is equal to the moment of the resultant Appendix II 359 applied to the same point, and that by changing the pole 0 to 0', the moment changes according to the following rule

Mo' = Mo + R x (xo' - xo), (11.2.5) involving only the relative position of the two poles and the resultant and momentum of the system of forces with respect to O. One can then prove that for the system of forces there exists a line parallel to R through the point M given by

MoxR XM -Xo = - IRI2 (11.2.6) characterized by the fact that the moment computed with respect to its points are all parallel to the resultant and precisely given by the component of the moment in the direction u of the resultant, i.e.,

Mo·R MM = IRj2 R = (Mo· u)u. (11.2.7)

To realize that, it is sufficient to apply (11.2.6) to the points of the Mozzi's axis, defined by

MoxR Xo' = Xo - IRI2 + >.R, (11.2.8) where >. is a parameter. The moment of a system of forces with respect to any point 0 can then be decomposed as

(11.2.9) where the first term is parallel to R and is constant, and the second term is perpendicular to R and depends on O. The quantity Mo . R appearing in (11.2.7) is then called scalar invariant of a system of forces. We then define torque as the system composed by two forces F 1 and F 2 , such that F 1 + F 2 = o. The resultant of the system is then zero and the moment is orthogonal to the plane containing the forces and given in modulus by Mo = IFlb, where b is the distance between the two straight lines containing the forces, the so-called action line. An important aspect of mechanics consists in reducing systems of forces to other systems which are more convenient to handle. It is then fundamen• tal to understand how one can play with forces in order to obtain systems which are in all aspects perfectly equivalent to the original ones. 360 Mechanics and Dynamic Systems

First of all, we need to define Equivalent systems I Two systems of applied forces are equivalents if their resultant and moment with respect to a pole 0 are equal.

It can be verified, using the above relations, that if the resultant and the moment with respect to a pole 0 are equal, then the moment with respect to any pole will be equal. In detail, the following operations then are invariant: • Summing forces applied in the same point; • Decomposing a force F in more forces with resultant R = F, applied in the same point; • Transporting a force along its line of application.

Moreover, it can be technically verified that: • Any system of applied forces is equivalent to its resultant applied in 0 and a torque having moment M o ; • Any system of applied forces is equivalent to a force F having moment Mo with respect to 0 and a force R-F applied in 0; • If Mo . R = 0 (i.e., the scalar invariant vanishes), then the system is equivalent to one of the following systems: - a torque having moment Mo if R = 0, - the resultant applied to the Mozzi's axis if R =1= 0; • Any plane system of applied forces is equivalent to one of the following systems: - a torque having moment M o if R = 0, - the resultant applied to the Mozzi's axis if R =1= 0; • Any system of applied parallel forces is equivalent to one of the following systems: - a torque having moment Mo if R = 0, - the resultant applied to point C with

if R =1= o. (11.2.10)

It can be observed that in the last two cases the scalar invariant vanishes, because moment and resultant have orthogonal directions. The point C defined in (11.2.7) is called the center of the system of forces and is characterized by the fact that it is independent of the (common) direction of the system of parallel forces, i.e., if the forces are Appendix II 361 all rotated of the same angle about their point of application, Mozzi's axis will rotate of the same angle about C. The center of a system of applied forces remains unchanged if the sys• tem is partitioned in several subsystems with nonvanishing resultant and the subsystem is replaced by the resultant applied to the center of the subsystem of forces.

3 Fundamentals of Kinematics

If the position of a point is given in terms of n Lagrangian parameters q1,'" ,qn,

x = f(t,q) = fx(t,q) i + fy(t,q)j + fAt,q) k, (II.3.1 ) then its velocity is given by

. 8f ~8f. x = 8t + LJ a qh , (11.3.2) h=1 Qh or componentwise

._ (8fx ~ 8fx .)• (8fy ~ 8fy .)• x- - + LJ-qh 1+ - + LJ-qh J 8t h=1 8qh at h=1 8Qh

+ (8fz + ~ 8fz .) k 8t ~ 8qh qh . (II.3.3)

If the first term in (II.3.2) or, equivalently in each bracket of (11.3.3), does not appear, the constraints are time independent. Similar calculations can be developed for the acceleration. For instance, if a point moves on a helix

x = RcosOi + RsinOj + aOk. (11.3.4)

Hence x = (-RsinOi + RcosOj + ak)O, (II.3.5) or x = ROeo + aOk, (11.3.6) 362 Mechanics and Dynamic Systems where eo = -sinOi + cos OJ, (11.3.7) and

x= (-RsinO i + RcosO j + a k)O - (cosO i + sinO j)RlP, (11.3.8) or

x= -RiP er + ROeo + aOk, (11.3.9) where er=cosOi+sinOj. (11.3.10)

Consider two points, ~ and Pj , as belonging to the same rigid body, and let nij be the unit vector from Pj to Pi' It follows that

(11.3.11 ) where IXj - xii is the Euclidean constant distance between the two points. In Section 5.2, we have proved the fundamental formula

(11.3.12) where n is the rotation vector of the rigid body, which relates the velocity of any pair of points belonging to it. Similar calculations can be developed for the accelerations

(11.3.13)

If one considers a motion in the lab and in the body frame, one has ya = yr + y'T", where ya and yr are the velocities in the lab and in the body frame, and y'T" is the velocity of the point fixed with the body. In particular, if u = XB - XA, from (11.3.12) y'T" = n x u, and

dau _ dru n (11.3.14) dt - dt + H X U, where dau/dt and dru/dt are the derivative of u in the lab and in the body frame respectively. In addition, if u is fixed with the body, one has the Poisson's formula dn dt = n x n. (11.3.15) Appendix II 363

4 Center of Mass

In Chapter 4, we introduced the concept of material point as a model in which the dimensions of the single bodies are not considered important. The total mass of a system S of N material points of mass mj located in Xj is then given by N m = L mj' (II.4.l) j=l In Chapter 5, 6, and 9 we dealt with continuous bodies for which it is pos• sible to define a piecewise continuous function J.t(x), called mass density, such that the mass of each region V of the body has a mass

m(V) = fv J.t(x) dV. (IIA.2)

In this and the following sections we will introduce several definitions which differ only slightly when passing from a discrete to a continuous system. For this reason we will write in the same equation the discrete definition on the left and the continuous one on the right. For instance, aligning the above equations one can say that the mass of S is defined by N m= Lmj, (11.4.3) j=l In this way, as seen in Chapter 9, we also stress the relationship between continuous and discrete models. In mechanics a fundamental role is played by the center of mass, or centroid, which is defined by

1 N xG=-Lmjxj, XG =..!.- rxJ.t(x) dV. (IIAA) m j=l mJs

As seen in Section 2 of this appendix, gravitational forces represent a system of parallel forces; the center is then that point of Mozzi's axis which is common to all Mozzi's axes when the system rotates rigidly. Componentwise one then has

1 N XG = - Lmjxj, XG =..!.- r xJ.t(x) dV, (IIA.5a) m j=l mJs 364 Mechanics and Dynamic Systems

1 N YC = - I::mjYj, Yc = ~ ( yp,(x) dV, (11.4.5b) m j=l mls and ~ Zc = mls( zp,(x) dV. (11.4.5c) It can be proved that if the continuous body or if the set of material points is rigid, then Xc identifies a characteristic point of S. Moreover, one can define the mass mi and the center of mass Xc. of any part Si of a continuous body S, and that if we substitute to Si a material point of mass mi located in xc., the center of mass of the set of material points is again xc. This is known as the distributive property of the center of mass. Finally we want to recall the following properties which we formulate for systems of point masses but can be rewritten for continuous bodies: • The center of mass of a system of material points lies inside any convex closed surface containing all points. • The center of mass of a plane system of material points lies inside any convex closed curve of the plane containing all points. • The center of mass of a system of material points on a straight line is inside the segment identified by the most external points. • If there exists a plane 1r and a direction n (nonparallel to 1r) such that for any point of S there is another point having the same mass such that the segment connecting the two points is parallel to n and is bisected by 1r, then the center of mass belongs to 1r. • If the system of material points has a plane (axis) of symmetry, then the center of mass belongs to this plane (axis). • Ifthe system of material points has a point of symmetry, then this point is the center of mass. A useful final property is obtained by deriving the definition of center of mass. In this way one obtains also a relationship between the velocity of the center of mass of S and that of its parts

N mxc = I::mjxj, (11.4.6) j=l

In particular, if the motion is referred to a system having the origin in the center of mass (i.e., the centroidal frame), then

N I::mjxj =0, (11.4.7) j=l Appendix II 365

5 Tensor of Inertia

Another fundamental mechanical property of systems both of material points and of continuous bodies, which is strictly related to the mass distri• bution of the system under consideration, is the moment of inertia with respect to an axis r. This is defined as

N I r = Lmjp; , (11.5.1 ) j=l where Pj or P is the distance of the point from r. If the direction of r is identified by the unit vector n, then this distance can be written as

Pj = I(xj - xo) x nl, P = I(x - xo) x nl, (11.5.2) or

In particular, the moments of inertia with respect to the axes x, Y, and z are, respectively, given by

N 2 Ix = E mj(Y; + zj) , Ix = ~(y + Z2)p,(X) dV, (II.5.4a) j=l

N 2 I y = Lmj(x; +z;) , I y = ~(x + z2)Jl(x) dV, (11.5.4b) j=l and

N 2 2 I z = L mj(x; + Y]) , I z = Iv (x + y )Jl(x) dV. (11.5.4c) j=l

If one defines products of inertia as the quantities

N I xy = - L mjxjYj , I xy = - Iv xyp,(x) dV, (11.5.5a) j=l 366 Mechanics and Dynamic Systems

N I xz = - LmjXjZj, I xz = - fv XZJL(X) dV, (11.5.5b) j=l and N I yz = - L mjYjZj , I yz = - fv YZJL(X) dV. (11.5.5c) j=l and tensor of inertia as the matrix

IXX Ixy I = I xy I yy (11.5.6) ( I xz I yz

(where for uniformity one has introduced, for instance I xx = Ix), it can be proved that

I r = n·In. (11.5.7) As will be shown, tensors of inertia have a fundamental role in mechan• ics. They can be computed with respect to lab frames or to frames which move with the body. Therefore, their components generally depend on time. In the particular case of a rigid body, the tensor of inertia computed with respect to a body frame is time independent and will only depend on the geometry of S and on the mass distribution inside it. The name of tensor depends on the fact that if one chooses another frame O(x', y', z') centered in 0 but rotated, then the components of the tensor change according to the tensor rule

(11.5.8) where Q is the rotation matrix transporting O(x, Y, z) onto O(x', y', z') (see Section 5.2). The tensor of inertia is obviously symmetric and positive definite as, taking into account (11.5.1), Equation (11.5.7) always gives a positive num• ber. Hence it admits at least a set of orthogonal eigenvectors and three positive eigenvalues. In particular, in the frame defined by three eigenvec• tors, the tensor of inertia is diagonal with the eigenvalues on the principal diagonal. When referring to rigid bodies, any set of axes with the origin at 0 and axes along the three eigenvectors of I (which is then fixed with respect to the body) is called the principal frame of inertia relative to 0, and the relative eigenvalues are called the principal moments of inertia relative to O. In particular, if 0 coincides with the center of mass G of S, the adjective principal is substituted with central. Appendix II 367

In addition, as I is a symmetric and positive definite matrix, the surface

u·Iu= 1 (11.5.9)

identifies an ellipsoid £, called ellipsoid of inertia, with axes along the eigendirections of I. The planes of symmetry of the ellipsoid are then the principal planes of inertia. The ellipsoid ofinertia allows one to evaluate geometrically the moments of inertia of S about any axis r through O. In fact,

1 r (11.5.10) I = lul 2 ' where lui is the distance between 0 and the intersection of the axis r through 0 with the ellipsoid £ (see Figure 6.12). We have already remarked that when a tensor of inertia is known relative to a frame through 0, it is known relative to any frame through O. We want to show how tensors of inertia with respect to frame centered in different points are related. We will present the computation in tensor notation for a continuous body. The reader is encouraged to repeat the computation for discrete systems and componentwise. It is possible to write

Io = Iv [Ix - xol21 - (x - xo) 0 (x - xo)] p,(x) dV, (11.5.11)

where a 0 b is the matrix with components aibj , I is the identity matrix, and the subscript 0 indicates that the frame is centered in 0, Le., Xo appears in the definition. Then, writing x - Xo = (x - xa) + (xa - xo) yields

Iv Ix - xoI 2p,(x) dV = Iv Ix - xaI 2p,(x) dV

+ (xa - xo) . Iv (x - xa)p,(x) dV + Ixa - xol2 Iv p,(x) dV, (11.5.12) where the second integral vanishes from the definition of center of mass (11.4.4) and the last integral gives the mass m of the body, and

Iv (x - xo) 0 (x - xo)p,(x) dV = Iv (x - xa) 0 (x - xa)p,(x) dV

+ (xc - xo) 0 Iv (x - xc)p,(x) dV + Iv (x - xc)p,(x) dV 0 (xc - xo) 368 Mechanics and Dynamic Systems

+ (XG - xo) 0 (xG - xo) Iv ,Ax) dV, (11.5.13) where again the second and third integral vanish from the definition of center of mass (11.4.4) and the last integral gives the mass m of the body. Summing up one then has

Io = IG + m [lxG - xol2I- (xG - xo) 0 (xG - xo)] . (11.5.14) In particular, if the frames centered in G and 0 have parallel axes, one can state the following theorem, known as Huygens' theorem. Theorem 1 Huygens' Theorem The moments of inertia with respect to two parallel axes, one of which passing through the center ofmass, are related by

o - IG {j2 I r - r +mo,

where (jo is the distance between the two axes. In particular, refer• ring to two frames centered respectively in G and 0 having parallel axes, one for instance has

Moreover, the products ofinertia are related by the relations

I~y = ~y - m(xG - xO)(YG - YO) ,

and similar. We want to explicitly stress that Huygens' relation is only valid when one of the parallel axis runs through the center of mass. Passing from one axis to another axis parallel to it implies using twice Huygens' relation, Le.,

(11.5.15) where {jo and {jo' are the distances of the center of mass from the two axes through 0 and 0'. As a consequence of Huygens' theorem, one has that if the two frames are such that 0 belongs to an axis through G (or vice versa), the products of inertia are unchanged. In particular, Principal inertia frame I If the frame through G is central, then any frame with origin o belonging to one of the central axes and axes parallel to them is a principal frame of inertia. Appendix II 369

Determining the principal axes and the moments of inertia means com• puting the eigenvectors and the eigenvalues of I. Sometimes, we can avoid doing any computation as the eigendirections of I are related to the sym• metries of S. In fact, one can prove that: • If a rigid body S admits a symmetry plane 7r, then this is a principal plane of inertia for each point of it and a plane of symmetry for the ellipsoid of inertia. • If a rigid body S admits two symmetry planes 7r1 and 7rz, orthogonal to each other, their intersection r is a principal axis of inertia for all its points. Moreover, a principal frame of inertia relative to 0 E r can be obtained by intersecting 7r1 and 7rz with the third plane 7r3 containing 0 and orthogonal to 7r1 and 7rz. These three planes are planes of symmetry for the ellipsoid of inertia. • Ifa rigid body S admits strictly more than two symmetry planes through an axis r or two nonorthogonal symmetry planes, then r is a principal axis of inertia for all its points and the ellipsoid of inertia is rotationally symmetric about it. Hence a principal frame of inertia relative to 0 E r can be obtained by intersecting the plane 7r through 0 perpendicular to this axis with any two other perpendicular planes. In particular, if the rigid body is rotationally symmetric, then the ellipsoid of inertia will also have the same rotational symmetry. • If a rigid body S admits a symmetry axis r, then this axis is a principal axis. •A principal axis of a plane rigid body S is the direction orthogonal to the plane. Furthermore, calling z this axis it is I z = Ix + I y . The proof of all the properties given above is based on the computation of the products of inertia or on symmetry arguments.

6 Linear Momentum

The expression of linear momentum of a system of particles is given by

N Q= Lmp(j, (11.6.1 ) j=l while that of a continuous body by

Q = Iv x p,(x)dV (11.6.2) 370 Mechanics and Dynamic Systems

Deriving the definition of center of mass, one has that Linear momentum I The linear momentum ofS is equal to the product ofits total mass and the velocity of the center of mass

Q=mxG· (11.6.3)

Of course for a system of points, the relative location of the center of mass with respect to the points changes with time and therefore has to be identified at any time. On the other hand, if S is a rigid body, then this point is perfectly identified within the body.

7 Angular Momentum

The expression of angular momentum of a system of particles with re• spect to a point 0 is given by

N Ko = ~)Xj - xo) x mjxj, (11.7.1) j=l while that of a continuous body by

Ko = Iv (x - xo) x x jj(x) dV. (II.7.2)

It can be proved (see also systems of applied forces) that

Ko = KG + (xG - xo) x Q. (11.7.3)

If one now introduces a frame having the origin in the center of mass and axis parallel to the lab frame, then for any point of S

X=XG+X', (11.7.4) where x' is the velocity of the point about the center of mass, Le., with respect to the centroidal frame. Appendix II 371

Substituting (11.7.4) in the definition of angular momentum and recall• ing the definition of center of mass, gives Angular momentum I The angular momentum of S computed with respect to its center ofmass is always equal to the angular momentum ofS in its motion as seen from a ccntroidal frame.

Ifthe motion of the system is rigid, then one can specialize the definition as the velocity of any point is given by the fundamental relation

Xp = XO + 0 x (xp - xo). (II.7.5)

The angular momentum of a rigid body with respect to 0 can then be written as

Ko = i (x - xo) x [xo + 0 x (x - xO)]/-l(x) dV

= [i(X-XO)/-l(X)dV] x xo

+ i(x-xo) x [0 x (x-xo)]/-l(x)dV

= m(xG - xo) x Xo

+ i {lx- xoI 20- [0. (x-xo)](x-xO)}/-l(x)dV

= m(xG - xo) x Xo

+ {i [Ix - xol21 - (x - xo) 0 (x - xo)] /-l(x) dV} 0

= m(xG - xo) x Xo + IoO, (11.7.6) where Io is the tensor of inertia computed with respect to a frame centered in O. In particular, if 0 == G, then

KG =IGO. (II. 7. 7)

We have also the following particular cases: • In a motion about a fixed point 0

(II.7.8) 372 Mechanics and Dynamic Systems

where Ix" I y ., I z• are the moments of inertia with respect to the principal axis x*, y*, and z* through 0 and OX" Oy" and Oz, are the components of the angular velocity along these axes, e.g., Ox' = 0 . i*. • In a motion about a fixed axis z

(II.7.9)

In particular, if the rotation axis is a principal axis, then

(11.7.10)

and the angular velocity and momentum have coincident directions. • The angular momentum of a translatory motion vanishes. Recalling the definition of ellipsoid of inertia, we also have that

Ko = JI;loIIou, (11.7.11 ) where 0 is either fixed or coincident with the center of mass, o (11.7.12) u = -:-::10--'--1JI;----;:X=r defines the intersection point P of ellipsoid £0 with the axis r passing through 0 and parallel to O. On the other hand, as f(u) = u· Iou = 1 is the equation of £0, the normal to £0 in P is given by (gradJ)p = 2Iou, so that

Ko = ~JI;IOI(gradJ)p. (11.7.13) One can then say that the angular momentum Ko corresponding to 0 is directed along the normal to £0 at the point P in which the line through o and directed like 0 meets £0, as shown in Figure 6.12.

8 Kinetic Energy

The kinetic energy of a system of particles S is given by

(11.8.1 ) Appendix II 373

Introducing a centroidal frame, one has that Xj = Xc + xj, where xj is the velocity with respect to the centroidal frame. One can then write

N N 2 T = ~ L mj(v/ +V& + 2xc .xj) = T' + ~mv& +xc· L mjxj, (11.8.2) j=l j=l where T' is the kinetic energy of the motion about the center of mass and v,j = 1"1xj ' By (11.4.7), the last sum vanishes and we have proved Konig's theorem Theorem 2 Konig's Theorem The kinetic energy of a system S is equal to the sum of the kinetic energy ofS in its motion about its center ofmass and of the kinetic energy that S would have if all the mass were concentrated in the center of mass. The same thing can be proved for a continuous body whose energy is defined by

T=~v2JL(X)dV, where v=lxl. (11.8.3) If the motion of the system is rigid, then one can specialize the compu• tation of the kinetic energy in its motion about the center of mass using the fact that the velocity of any point is given by the fundamental relation (11.3.12), which can be rewritten in this case as

X' = 0 x (x' - xc). (11.8.4)

In particular,

(11.8.5) or

i V'2 = O· [Ix - xc!21 - (x' - xc) @ (x' - xc)] O. (11.8.6) Recalling (11.5.11), Eq.(11.8.6) shows that the computation ofthe kinetic energy of S in its motion about the center of mass then involves the tensor of inertia computed with respect to a frame centered in G

(11.8.7)

The kinetic energy of a rigid body is then given by

(11.8.8) 374 Mechanics and Dynamic Systems

This relation simplifies in the case of particular motions: • If the motion has a fixed point 0, one can repeat the same computation given above to show that

(11.8.9)

where Ix" I y ., I z• are the moments of inertia with respect to the principal axis x*, y*, and z* through 0 and Ox" Oy" and Oz, are the components of the angular velocity along these axes, e.g., Ox' = 0 . i*. • If the motion has a fixed axis z, then

where 0 = 101. (11.8.10)

• The kinetic energy of a translatory motion is given by

(11.8.11 )

where v is the modulus of the (common) velocity of all points. As shown in Chapter 6, the computation of the kinetic energy of a holonomic system plays a fundamental role in analytical mechanics. We will then consider it here in some detail. Assume that S is a holonomic system of point masses, whose positions are then identified by n Lagrangian parameters qj through

We recall that time explicitly appears in fj if the constraints are time dependent. The velocity of the point Xj is then related to the Lagrangian parameters by

(11.8.12)

In particular,

2 ~ j j j ~ j j v·=2 ~ -·-qhqk+2-·~-qh+-of of .. of of . 10f 1 (11.8.13) J h,k=l 0% oqk at h=l 0% at and therefore the kinetic energy can be written as

(11.8.14) Appendix II 375 where

1 N (ar.)2 To = 2Lmj at )=1

The terms To and T 1 only appear if the constraints are time dependent. The former is independent of q, while the latter is linear in q and can be written as

N ~ j T1 = b· q, with b = '"m . r.. ar . (II.8.l6) ~ ) q) at j=l

In the case of time independent constraints, the kinetic energy reduces to the quadratic form T2 :

(11.8.17) where the symmetric matrix A is defined in (II.8.l5). Observing that for any nonvanishing virtual displacement {)Xj,

(II.8.l8) one can deduce that A is also positive definite, which in particular implies that its eigenvalues are all real and positive and det A > O. III

Scientific Programs

1 Introduction to Programming

This appendix provides a technical introduction to the scientific program• ming based on Mathematica®, which solves the various examples and prob• lems proposed all along the book. Some of them are potential solvers of class of problems much greater than those identified by the specific prob• lems or examples. The aim is also to direct the reader toward a natural use of Mathematica® for the solution of problems in mechanics and applied sciences. Before describing the various programs, we will give some general technical aspects regarding their formal organization. Subsequently, the inner struc• ture of the commands related to two specific programs will be described in detail. Within the above framework, it is important to distinguish between two conceivable settings of programs. The first one, called Notebook, presents the lines of the program on the screen for the user to view. The second one, called Package, does not do this, which may be useful for very long programs. We assume that the reader has some knowledge, although not necessar• ily deep, of the main commands as they are presented in the Handbook of Mathematica. Therefore, the long list of them is not reported here also con• sidering that in compiling the program it is, however, necessary to consult the handbook. The Notebook is structured in the following way:

377 378 Mechanics and Dynamic Systems

Program Name [inputL, ... ,inputnJ := Module [{ letters (symbols) }, Command 1;

Command m; ] In detail, after the name of the program the line in square brackets reports all input data with the underscore. All commands used in the program have to be contained between two square brackets preceded by the word Module. The letters between the curly brackets identify the meaning of the letters used in the framework of the program. To run the program, type in the following line Program Name [inputi, ... ,inputn] where the underscore is not present any longer. We also remark that command lines end with a semicolon (;), while the command recalling the program does not have any punctuation. In writing examples all along the books using the correct punctuation has not been possible for typographic reasons. In the examples contained in this appendix we will instead report the exact line that needs to be typed in. The structure of the Package is as follows BeginPackage[IIProgram Name"] Program Name::usage:="description of target of the program" Begin [C C\ Private\ II] Name of the Program [inputL, ... ,inputn_] := Module [{ letters (symbols) }, Command 1;

Command m; ] End[] EndPackage [] Notebook programs are saved on the hard disk of the personal com• puter, as name. nb, while Package programs are saved as name. m. Saving is obtained using the command Save as Special, which is in the menu File. The above formal organization have to be followed carefully other• wise the program does not run. Appendix III 379

Two notebooks, Phase3D.nb and Motion12.nb, will now be explained in detail. We refer the subroutine Motion2 of the program Motion12.nb as the other subroutine can be seen as a special case.

The program Phase3D. nb integrates, for t E [T!, T2l, the initial value prob• lem for a system of three ordinary differential equations of the type

dx dt = X(x, y, z), dy dt = Y(x, y, z), dz dt = Z(x, y, z),

x(O) = Xo + ih, for i = -n, ,n, y(O) = Yo + jk, for j = -m, ,m, z(O) = Zo + rl, for r = -p, ,po

The program draws the referring to the time interval [T!, T2]. In using the program, it is convenient to define in advance the system as sys. The series of commands to do that are: eql=y[t] -x[t]*z[t]; eq2=x[t]-2*y[t]*z[t] ; eq3=x[t]+ z[t]; sys={eql,eq2, eq2,}; One then has to call the program. The general command is Phase3D[sys,{xO,h,n},{yO,k,m},{zO,1,p},{Tl,T2},{Tl,T2}, steps] which in the particular case becomes Phase3D[sys,{O,1,2},{O,1,1},{O,O,O},{O,2},{1,2},1000] where the last input refers to the number of time steps used for the numer• ical integration. The program writes Phase3D[sys_,{xO_,h_,n_},{yO_,k_,m_},{zO_,1_,p_}, {TL,T2_},{TL,T2_},stepsJ := Module[{a,b,c,s,orbits,u}, (*Initial data*) a=Table[xO+i h,{i,-n,n}]; b=Table[yO+j k,{j,-m,m}]; c=Table[zO+r l,{r,-p,p}]; 380 Mechanics and Dynamic Systems

(*Solution corresponding to the previous initial data*) s[L,j_,rJ := NDSolve[{x' [t]==sys[[l]] ,y'[t]==sys[[2]] ,z' [t]==sys[[3]], x [0] ==a[ [i)] ,y[O] ==b [[j]] ,z[0] ==c[ [r] l},{x,y,z}, {t,Tl,T2},MaxSteps->steps] ; (*Orbits*) orbits[L, j _, r J :=ParametricPlot3D[Evaluate[ {x[t] ,y[t],z[t]}/.s[i,j,r] ,{t,Tl,T2}, Compiled->False,AxesLabel->{x,y,z},PlotPoints->400, PlotRange->All,DisplayFunction->Identity]; u=Table[orbits[i,j,r] ,{i,l,2 n+l},{j,l,2 m+l}, {r,1,2 p+1}]; Show [u,Displayfunction->$DisplayFunction, AspectRatio->Automatic] ]

The sentences between the symbols (* ... *) are comments introduced to help the user understand the program better. The lines a, b, and c define three tables of numerical values for the coordi• nates x, y, and z of the initial points in a parallelepipedal neighborhood of the point (xO, yO, zO) having edges 2h, 2k,2l. s [i , j , r] denotes the numerical solution of the system x' [t] ==sys [ [1]] , y' [t] ==sys [[2]], z' [t] ==sys [ [3]], corresponding to the initial set of data a[[i)), b[[j]], c[[r]], obtained using the ODE solver NDSolve. {x, y ,z} denotes the state variable, while {t,T1 , T2} denotes the indepen• dent variable and its interval of variation. Finally MaxSteps sets the max• imum number of steps to be used as a criterium for the time step for the . orbits[i , j ,r] is the parametric plot of the solu• tion s [i , j ,r] in the time interval defined as {t,Tl,T2}. Various options have been chosen relative to the command Parametric• Plot3D. For instance, 400 points are used to draw the solution s [i,j ,r] and the option DisplayFunction->Identity is used because it does not permit the appearance of all single graphs on the screen. These are shown all together with the command Show. The notebook Motions12.nb contains two notebooks, here called subrou• tines, which are named Motionsl and Motions2. The first one analyzes the motion of a mechanical system with one degree of freedom, the second one analyzes the motions of a system referred to the cartesian coordinates x and y. The general command is

Motions2[m,F,data,T,step] Appendix III 381 where mis the mass, F is the force acting on it, data are the initial conditions {x [0] ,y[0] ,x' [0] ,y' [O]}, T is the final time of observation, and step is the number of time steps used for the numerical integration. As already mentioned, because Motionsl can be seen as a special case of Motions2, we focus on this last notebook which writes (*Planar motions. mass=m; force=F={Fx(x[t] ,yEt] ,x' [t] , ...) ,Fy(. ..)}; initial data={xO,yO,uO,vO}*) Motions2[m_,L,data_,T_,stepJ := Module[{eql,eq2,sol,pl,dx,dy,pldx,pap}, eql=m*x" [t]==F[[l]]; eq2=m*y"[t]==F[[2]] ; sol=NDSolve[{eql,eq2,x[0]==data[[1]],y[0]==data[[2]] , x' [0]==data[[3]] ,y' [0]==data[[4]]}, {x,y},{t,O,T},MaxSteps->step] ; Print["y[t] is continuous"]; Print ["x[t] is dashed"]; pll=Plot[Evaluate[x[t]/.sol] ,{t,O,T}, AxesLabel-> {"t", "x,y"} ,AxesOrigin-> {O,O}, DisplayFunction->Identity] ; pll=Plot[Evaluate[y[t]/.sol] ,{t,O,T},AxesOrigin->{O,O}, PlotStyle-> {Dashing[{O.015,O. 015}]}, DisplayFunction->Identity] ; Show[pll,pI2,DisplayFunction->$DisplayFunction] ; dx=D[Evaluate[x[t]/.sol] ,t]; dy=D[Evaluate[y[t]/.sol],t] ; pldx=Plot [dy, {t,O,T},AxesOrigin-> {O,O}, PlotStyle-> {Dashing[{O.015,0.015}]}, DisplayFunction->Identity] ; Print ["Trajectory"] ; papl=ParametricPlot[Evaluate[{x[t] ,y[t]}/.sol], {t,O,T},AspectRatio->Automatic, AxesLabel-> {"x", "y"},AxesOrigin-> {O,O}] ; ] where eql and eq2 are the two equation of motions. As before, NDSolve solves the system of ordinary differential equations from the given initial data for the state variables x, y in the interval [0, T] using the option of maximum number of time steps given in input as step. The following two commands print a legend. Then pll and pl2 refer to the plots of the solution, which are again done for t E [0, T]. AxesLabel defines the name to put on the axes. AxesOrigin defines the starting values of the 382 Mechanics and Dynamic Systems two axis. PlotStyle-> {Dashing[{O.015,O.015}] plots y(t) as a dashed line. The two numbers refer to the length of the dashes and the spacing between two of them. As before, DisplayFunction->Identity does not permit the appearance of all single graphs on the screen. These are shown by using the command Show. dx and dy evaluate the derivative ofx [t] and y [t] , which are ten plotted as pldx and pldy. Finally papl draws the trajectory, Le., {x[t] ,yet]} with t E [0, T] as parameter. The option AspectRatio normalizes the maximum value of x [t] and y [t] to be equal.

2 Scientific Programs

This section describes in some details the programs that can downloaded from the Birkhauser Web site: http://www.birkhauser.com/book/isbn/O-8176-4007-X The presentation focuses on their aims and shows how to use these pro• grams, but does not enter into the details of the meaning of the specific commands contained within the program. The most important ones are explained in the program itself. There a brief explanation of the aim of the program, followed by the general input command. All variables in this com• mand have to be substituted with numbers or symbolic expressions, either before the command calling the Notebook, followed by a semicolon (;), or within the calling itself. The meaning of all variables are then explained in a easy to consult scheme. Finally, an example of use is given which uses the same values of the variables given in the preceding scheme. Reference is sometimes made to the section giving the theoretical basis needed to under• stand the output of the program and to other applications of the program already dealt with in the book. Appendix III 383

Program Ball.nb Ball on a rough inclined plane The program deals, with reference to Section 5.6.5 for the mechanical and mathematical models, with the motion ofa ball S rolling on a rough inclined plane 7r without slipping. The coordinates of the contact point are denoted by (xc,Yc), the angular velocity by 0, and the spin friction by r. The frame is chosen in a way that the x-axis runs along the line of steepest descent of 7r, the z-axis is orthogonal to 7r and the y-axis is orthogonal to the previous ones. The general command is Ball[xO,vO,nzO,a,fs,hd,kd,m,r,TJ where xO: the initial position of the center of mass (xc(O), Yc(O)); xO={O,O} vO: value of the initial velocity; vO={l,O} nzo: initial angular velocity along the z-axis; nzO=3 a: inclination of the plane; a=7r/20 f s : static friction coefficient; fs=O.3 hd: dynamic rolling friction coefficient; hd=O.Ol kd: dynamic spin friction coefficient; kd=O.02 m: mass; m=O.l r: ball radius; r=O.2 T: final instant of integration. T=10 For instance, Ball[{O,O},{1,O},O,7r/20,O.3,O.Ol,O.02,O.1,O.2,10J

o 384 Mechanics and Dynamic Systems

Program Bif.nb Stability and bifurcation The notebook Bif1 analyzes the stability properties of models of the type

X' = F(X,A), for variable parameter A and where F(O, 0) = 0, The general command is Bifl[eq, unk, par] where eq: equation; eq=u'==U-3+A+AU unk : state variablej unk=u par: parameter. par=A For instance, Bifl[u'==u-3+A+AU,U,A] The notebook BifG displays the curve F(x, A) = °related to the equilibrium configurations versus Aand gives the region of the rectangle [-a, a] x [-b, b] in which F(x, A) < 0, so that stability properties can be studied. The general command is BifG[eq, unk, par, a, b, p] where, besides the already defined eq, unk and par, a: half side of the rectangle along Xj a=l b: half side of the rectangle along y; b=2 p: subdivision of the two sides of the rectangle. p=20 For instance, BifG[u'==u-3+A+AU,U,A,1,2,20] The use the programs needs, first of all to evaluate, just once, the cell «Graphics'ImplicitPlot'

o Appendix III 385

------Program Criticaleq.nb ------Poincare's method The program applies Poincare's method to the system

dx dt = -ly+X(x,y),

{ dy dt = -Lx + Y(x, y), where the terms X and Yare such that X(O,O) = Y(O,O) = O. The objective is to study the stability of the origin, which is a critical equilibrium point. The program evaluates the coefficients G(4), G(6), G(8), ... ,G(n) (with n 2 4 even positive integer) of a suitable power de• velopment. If the first nonvanishing coefficient is positive (negative), the origin is unstable (stable). The general command is Criticaeq[X,Y,l,n] with

X: nonlinear term X (x, y) in the second equation; X=O.5*x*y-2 Y: nonlinear term Y (x, y) in the second equation; Y=-y*x-2 1 : coefficient l in equations; 1=1 n: order of the power development. n=4 For instance,

o 386 Mecllanics and Dynamic Systems

Program Curvemot.nb Motion of a point on a planar curve The program describes the motion of a point P moving on a curve 'Y. The general command is Curvemot['Y,u,uO,vO,m,fd,Fin,Fex,tf,steps] where 'Y: the couple of parametric equations of the curvej 'Y={Sin[~],-Cos[~]} u: curve parameterj u=~ uo: initial value of u; uO=1l"/2 vO: initial value of u' (0); vO=O m: masSj m=l fd: friction coefficient of the curve 'Yj fd=O Fin: the applied force in the frame (e, n) of the tangent unit vector and the normal unit vector to 'Y; Fin={-0. hAbs [~' [t*~' [t] ,O} Fex: the applied force in the external frame O(x,y)j Fex={O,-9.8} tf : final time of observation and numerical integrationj tf=5 steps: number of steps of the numerical integration. steps=1000 To find the motion and the reactive force, the projections of the equation

rna = F- fdfP vers v + fPo , along the tangent and the normal to 'Y are used. For instance, 'Y={Sin[~],-Cos[~]}; Fin={-O.hAbs[~' [t]]*~' [t] ,o}; Curvemot['Y,~,1l"/2,O,1,0,Fin,{O,-9.8},5,1000]

lJ Appendix III 387

Program EMField.nb Charge in an electromagnetic field The program supplies the trajectory of a charge q in an electromagnetic field (E, B). The general command is EMField[m,q,E,B,rO,vO,tf,opts] where m: mass of the charge; m=1 q: charge; q=2 E: electric field; E={O,O,-1} B: magnetic field; B={-1,O,O} rO: initial position of the charge; rO={O,O,O} vO: initial velocity of the charge; vO={1,O,O} tf : final time of observation and numerical integration; tf=5 opts: chooses the ViewPoint->a,b,c by + Input + 3DViewPointSelector + paste. opts=ViewPoint->{1.300,-2.400,2.000} For instance, EMField[1,2,{O,O,-1},{-1,O,O},{O,O,O},{1,O,O},5, ViewPoint->{1.300,-2.400,2.000}]

o 388 Mechanics and Dynamic Systems

Program GiroPes.nb Motion of a Heavy Gyroscope GiroPes identifies the intersection point of the gyroscopic axis with the sphere having radius equal to 1 and with the center at the fixed point. The general command is

GiroPes[A,CO,z,P,pO,qO,r,¢O,~O,BO,T,steps] where

A: double eigenvalue of the tensor of inertia; A=1 CO: simple eigenvalue; CO=O.5 z: coordinate of the center of mass on the gyroscopic axis; z=O.7 P: weight; P=O.9 pO, qO, r: components of initial angular velocity in the body frame; pO,qO,r=O.2,O.1,9 ¢O , ~O , ()O : initial value of the Euler angles; ¢O,~O,()O=-~/2,O,~/4 T: final time of observation; T=10 steps: number of time steps for the numerical integration. steps=1000 For instance,

GiroPes[1,O.5,O.7,O.9,O.2,O.1,9,-~/2,O,~/4,10,1000]

CI Appendix III 389

------Program HopfBif.nb ------Hopf bifurcation The program deals with a system sys of two differential equations

dx dt = X(x, y, A) ,

dy { dt = Y(X,y,A), which depends on a parameter A, and for which the origin is an asymptoti• cally stable equilibrium point. It verifies the hypotheses of Hopf's theorem and draws the phase portrait for values of Abelonging to the interval (b 1 , b2 ) with b1 < 0 < h For each value of A, the phase portrait is formed by the orbits relative to the points (ih, j k), with i = -n, ... ,nand j = -m, ... ,m. The general command is HopfBif[{eql,eq2},unk,par,varpar,{h,n},{k,m},{Tl,T2}, steps] where eql: first equation of the system; eql=u'==c*u+v-u*(u~2+v~2) eq2: second equation of the system; eq2=v'==-u+c*v-v*(u~2+v~2) unk: unknowns; unk={u,v} par: parameter; par=c varpar: interval around the origin of the parameter; varpar={-l,l} {h,n}: defines the initial condition for unkl as recalled above; {h,n}={O.4,6} {k,m}: defines the initial condition for unk2 as recalled above; {k,m}={O,O} {Tl,T2}: extrema of the independent variable; {Tl,T2}={O,4} steps: number of steps of the numerical integration. steps=300 390 Mechanics and Dynamic Systems

For instance,

eql = u' == €*u + V- u*(u-2 + v-2); eq2 = v' == -u + €*v - v*(u-2 + v-2); HopfBif[{eql,eq2},{u,v},€,{-1,1},{0.4,6},{0,0},{0,4},300]

o

------Program LagrEq.nb ------Lagrange equation Consider S to be a system whose kinetic energy T and potential function U are given in a symbolic form. The program then gives the Lagrange equations, their normal form, the equilibrium equations, and the principal minors of the Hessian matrix of U. Moreover, if L = T +U is independent of time, then the energy integral is printed. Finally, if there are cyclic coordinates, the program prints the relative constant kinetic momenta. The command is LagrEq[T,U,var,igvar] where

T: kinetic energy; T=T=1/2*m*(r'-2+r-2*~'-2) U: potential function; U=U= k/r var: vector of Lagrangian coordinates; var={r,~} igvar: list of cyclic coordinates. igvar={~} For instance, for a point mass in a Newtonian field, one has to write

T=1/2*m*(r'-2+r-2*~'-2); U=k/r; LagrEq[T,U, {r ,~}, {~}] The time derivative of a variable f is denoted by f'. If there are no cyclic coordinates, one has to replace {~} in the last input of the example above with n. o Appendix III 391

Program LindPoinc.nb Lindstedt-Poincare's perturbation method The program deals with the periodic motions of models of the type

where c: is a small nondimensional parameter. The program provides the first approximation of the solution obtained by the perturbation method by Lindstedt and Poincare, as explained in Section 3.5, and compares the approximated expression (continuous line) with the numerical one (dashed line) for a fixed value r of c: and for the initial data: x(O) = xo, and X(O) = x~. The general command is LindPoinc [g] where the meaning of g has just been given. To visualize the solution, type in Phase[g,r,xO,T] where g: the term multiplied by c: on the right-hand side; g=x' * (1-x~2) r: value of c: used for plotting needs; r=O.08 xO: initial condition Xoi xO=2 T: final time of observation. T=7 For instance,

LindPoinc[x'*(1-x~2)] finds the approximated solution of

for any value of c: and for any initial condition. 392 Mechanics and Dynamic Systems

To visualize the solution for e = 0.08 starting from x(O) = 2 till T = 7, type in

Phase[x'*(1-x~2).O.08.2.7]

[J

Program LineSys.nb Linear systems with constant coefficients The program provides, with reference to Section 2.4, the general integral of a homogeneous system of n linear differential equations with constant coefficients dx dt = Ax, where the matrix of the numerical coefficients A has to be written as A={{AU •...•Ain}, ... , {Ani •...•Ann} } The general command is Linesys [A] For instance, A={{1.0.2},{O.-3.0},{-1.0.0}}; Linesys[A]

[J Appendix III 393

------Program Linstab.nb ------Linear stability This program deals with systems of ordinary differential equations

dx dt = X(x,y),

{ dy dt = Y(x,y), and plots the curves given by X(x, y) = 0 and by Y(x, y), so that the user can graphically identify the location of the equilibrium configurations X e = (xe,Ye) with Xe E [a, b] by looking at the intersections between the curves. It also analyzes their stability. The general commands are EqPoints[eql,eq2,unk,unkO] and Stability[eql,eq2,xO] where eql: first equation; eql=x'==2xy eq2: second equation; eq2=y'==1-2x~2-y~2 unk: unknown unk={x,y} unkO: set of points near one of the equilibrium position found before. unkO={{O,1},{O,-1},{-O.5,O},{O.5,O}} xO: output of the program EqPoints xO=O,l For instance, eql=x'==2*x*y; eq2=y'==1-3*x~2-y~2; EqPoints[eql,eq2,{x,y},{-1,1}] gives the x and y axes and an ellipse, so that one can identify two points on the y-axis which are right at Ye = ±1 and two points on the x-axis near x e:: ±O.5 (it would be X e = 1/V3). Stability properties can be analyzed by the subroutine Stability.nb as follows Stability[eql,eq2,{{O,1},{O,-1},{-O.5,O},{O.5,O}}]

o 394 Mechanics and Dynamic Systems

Program Motions12.nb One- and two-dimensional motions The program contain two subprograms: Motionsl and Motions2. Mo• tionsl integrates the initial value problem for equations

mx = F(x, x, t), with initial conditions: x(O) = Xo and X(O) = x~, plotting the evolution of x and x versus time and the phase diagram. The general command is Motionsl[m,F,data,T,step] where m: masSj m=l F: forcej F=-Sin[x[t]] data: initial data Xo and X~j data={2,1} T: final time of observation and numerical integrationj T=3 step: number of time steps for numerical integration. step=500 For instance, Motionsl[l,-Sin[x[t]] ,{2,1},3,500] The program Motions2 integrates the initial value problem for a system of the type mx = F(x, x, y, y, t) { my = F(x, x, y, y, t), with initial conditions: x(O) = Xo, y(O) = Yo, x(O) = x~, y(O) = y~. The meaning of symbols is similar, but the command is Motions2[l,{-O.2*x'[t] ,-9.8-0.2*y' [t]},{O,1,2,3},3,500] which solves the particular initial value problem

X = -0.2x, { y = -9.8 - 0.2y, with initial conditions x(O) = 0, y(O) = 1, X(O) = 2, y(O) = 3, until T = 3 using 500 time steps. The program plots the trajectory (x [t] ,y[t] ).

o Appendix III 395

Program MotiPoin.nb ------Poinsot's motions ------The program supplies the polhode and the herpolhode for Poinsot's mo• tions (see Sections 6.7.4 and 5.6.4). The z*-axis is chosen parallel to the angular momentum Ko where 0 is the fixed point. Moreover, p, q, rare the components of the angular velocity n in the body frame and ni, n2 , n3 are those in the lab frame. Finally, 1/J,

A, B, CO: moments of inertia with respect to the fixed point; A,B,CO=l,l.4,O.5 rO: component along z* of the initial angular velocity; rO=3 00: initial angle 0; 00=0.01 b: defines the observation time; b=1.5

0:: defines the angle on the ellipsoid where the polhode is located. o:=Pi/10 For instance, MotiPoin[l,l.4,O.5,3,O.01,l.5,Pi/10]

[] 396 Mechanics and Dynamic Systems

Program NBoundary.nb Nonlinear boundary value problem The program NBoundary computes the numerical solution of the following boundary value problem (see Section 2.6) for the equation

2 d y ( dY ) dx2 = F x, Y, dx ' with boundary conditions y(a) = Yin, y(b) = Yjin, by several methods. In particular, the subroutine NBoundary[eq.{a.b},{yin.yfin}.{dymin.dymax}.n,steps] uses a shooting method (see Section 3 of Appendix I), which transforms the boundary value problem into the set of Cauchy problems

with initial conditions y(a) = Yin, *(a) = y~, where the values y~ are given by i y~ = dymin + -(dymax - dymin). n If the choice of dymin and dymax is not right, then the program plots the values y(b) - Yjin versus y~ to suggest a better choice. As usual the re• maining parameter steps denotes the number of steps in the numerical integration. For instance, eq=O.Ol*y"[x]+(x-O.5)*y' [x] ; NBoundary[eq.{O.1},{O.9.-0.9},{-10.10}.5.1000] solves the particular problem

with boundary conditions y(O) = 0.9, y(l) = -0.9, using as initial values

~ 20 40 i -20 8i Yt = - + 5 = + .

The number of integration steps is 1000. Appendix III 397

The subroutine NBoundaryl uses a to solve linear boundary value problems for equations of the type

with boundary conditions y(a) = Yin, y(b) = Yfin' For instance, the example above is solved by eq=O.Ol*y"[x]+(x-0.5)*y' [x] ; NBoundaryl[eq,{0,1},{0.9,-0.9},100] The inputs have the same meaning, but for 100 which stands for the number of division of the interval fa, b]. In this case [0,1] is divided in 100 subinter• vals. In addition, of course, here the inputs dymin, dymax, n which were used before to define y~ are not used. If the problem is nonlinear, then the subroutine NBoundary2 can be used in place of Nboundary1. Since the finite difference system is nonlinear, by the command FindRoot the program solves a set of boundary problem whose boundary data are

b j - 1 b j-l Yin = --Yin, Yfin = --Yfin , j = 1, ... ,8 + 1, 8 8 relative to the equation

The general command is NBoundary2[eq,g,{a,b},{yin,yfin},n,s] or, more specifically, eq=y"[x]+x-2*(y' [x])-2-Sin[x] ; NBoundary2[eq,-Sin[x] ,{0,1.5},{1,0.1},20,30] solves the particular problem y d2y 2 (d )2 . dx2 + X dx = sm x { y(O) = 1, y(1.5) = 0.1.

The interval is divided into 20 parts, and 30 steps are used to reach the given problem from the one without g(x). o 398 Mechanics and Dynamic Systems

Program Perturb.nb Poincare's perturbation method Consider, with reference to Section 3.5, a weakly of ordi• nary differential equations

dx dt = Ax+cF(x,c), where A is a constant matrix and c a small parameter. The program sup• plies the solution for initial data x(O) = Xo up to a number m of equations and compares the components Xv and X w of the approximate solution (con• tinuous line) for c = r, with the numerical one (dashed line) in the time interval (0, T). The general command is Perturb[A,F,xO,m,r,T,{v,w}] where

A: matrix given as {{Ail,... ,Ain}, ... , {Ani , ... ,Ann}}; A={{O,l}{-l,O.l}} F: perturbation term on the right-hand side; F={O,-(x[l] [t]) -3} xO: set of initial data; xO={2,O} m: order of expansion; m=i r: value of c used for plots; r=O.2 T: final time of observation; T=10 {v,w} : pairs of components used for plots. {v,w}={1,2} For instance, Perturb[{{O,l},{-l,O.l}},{O,-(x[l] [t])-3},{2,O},1,O.2,10, {1,2}]

D Appendix III 399

Program Phase.nb Phase portrait of two-dimensional system The program supplies the phase portrait of the system

dx dt = X(x,y),

dy { dt = Y(x,y), with initial conditions: x(O) = Xo +ih for i = -n, .. . ,n, and y(O) = Yo +jk for j = -m, ... ,m. It is convenient to define in advance the system as sys. The general command is Phase[sys,{xO,h,n},{yO,k,m},{T1,T2},steps) where sys : system of equations; sys={y[t)*(1+y[t),-(x[t)/2)+(y[t)/5)-x[t)*y[t) +1. 2* (y[t)) ~2} {xO,h,n}: initial conditions x(O) = Xo + ih, i = -n, ... ,n; {xO,h,n}={O,O.5,4} {yO,k,m}: initial conditions y(O) = Yo + jk, j = -m, ... ,m; {yO,k,m}={O.1,O,O} {Ti ,T2} : integration interval; {Tl,T2}={O,20} steps: number integration time steps. steps=1000 For instance, eq1=y[t)*(1+y[t); eq2=-(x[t)/2)+(y[t)/5)-x[t)*y[t)+1.2*(y[t)~2; sys={eq1,eq2}; Phase[sys,{O,O.5,4},{O.1,O,O},{O,20},1000) Notice that the input {O.1,O,O} produces only one initial value for y. This program is very similar to Phase3D. nb. More examples of its application can be found in Section 2.5. a 400 Mechanics and Dynamic Systems

Program Phase3D.nb Phase portrait of three-dimensional system The program supplies the phase portrait of the solutions of the system

dx dt = X(x, yz), dy dt = Y(x,y,z), dz dt = Z(x, y, z) , with initial conditions: x(O) = Xo + ih for i = -n, . .. , n, y(O) = Yo + jk for j = -m, ... , m, and z(O) = Zo + rl for r = -p, . .. ,p. It is convenient to define in advance the system as sys. The general com• mand is Phase3D[sys,{xO,h,n},{yO,k,m},{zO,1,p},{Tl,T2},{Tl,T2}, steps] where sys: system of equations; sys={y[t]-z[t],x[t]+2*y[t] ,O.2+z[t]*(x[t]-3)} {xO,h,n}: initial conditions x(O) = Xo + ih, i = -n, ... ,ni {xO,h,n}={2,1,O.2} {yO, j ,m}: initial conditions y(O) = Yo + jk, j = -m, ... , m; {yO,j,m}={-1,2,O.1} {zO,r,p}: initial conditions z(O) = Zo + rl, r = -p, ... ,Pi {zO,r,p}={l,O,O} {Tl ,T2} : integration interval; {Tl,T2}={O,50} {Tl ,T2} : time interval for the graphic representation; {Tl,T2}={O,10} steps: number of time steps for numerical integration. steps=100 For instance, eql=y[t]-z[t] ; eq2=x[t]+2*y[t] ; eq3=O.2+z[t]*(x[t]-3); sys={eql,eq2,eq3}; Phase3D[sys,{2,1,O.2},{-1,2,O.1},{1,O,O},{O,50}, Appendix III 401

{O,10},100] Notice that the input {l,O,O} produces only one initial values for z. o

Program Plane.nb Velocity field in a planar motion The program evaluates the velocity field of a planar motion for which the trajectory of one point ro and the angular velocity cp are given. It also shows the trajectory of the instanteneous rotation center C in the time interval (0, T) and the velocity field at the instant Tt belonging to the time interval (Tt - ti.,Tt + ti.). The program needs the package Graphics'PlotField'. The general command is PlanarMotions[rO,cp,T,Tl,step] where

rO: motion of the point ro of the rigid body; rO={Cos[t] ,Sin[t],O} cp: angular velocity; cp=O.5*t T: observation time; T=4 T1 : time instant for velocity field plot; T1=1 step: time step used for plotting the velocity field. step=O.5 For instance, if ro moves on a unit circle and the angular velocity steadily increases with time, one has PlanarMotions[{Cos[t] ,Sin[t],O},O.5*t,4,1,O.5]

o 402 Mechanics and Dynamic Systems

Program SBoundary.nb Boundary value problems The program finds the symbolical solution (when it exists), of the following boundary value problem (see Section 2.6)

d2y ( dY ) dx2 = F x,y, dx { y(a) = Yin y(b) = Yfin

The general command is SBoundary[eq,a,b,yin,yfin] where eq: equation; eq=€*y"[x]+(x-l)*y'[x] a,b : extrema of the x interval; a,b=O,2 yin,yfin: boundary data. yin,yfin=l,-l For instance, SBoundary[€*y"[x]+(x-l)*y' [x]/2,O,2,l,-1] To plot the solution for € = 0.001 and x E [0,2], one can use Plot[Evaluate[s3/.{€->O.OOl}],{x,O,2}]

o Appendix III 403

Program Sersol.nb Power series solution Sersol supplies the solution of Cauchy problem

dx = F(x) dt { x(O) = Xo as a power series in t of order r and initial point O. The obtained solution is compared with the numerical one in the interval [0, b]. The general command is Sersol[F,r,xO,b] where

F: right-hand side; F={-Sin[x[2] [t]] ,x[1] [t]-3} r: order of expansion; r=6 xO: initial conditions; xO={1,2} b: time of observation used for plotting needs. b=1.5 For instance, Sersol[{-Sin[x[2] [t]], x[l] [tr3},6,{1,2},1.5] solves the system dXI . & = - SlnX2,

{ dX2 3 &=XI' with initial conditions Xl (0) = 1, X2(O) = 2.

[J 404 Mechanics and Dynamic Systems

Program SmallOsc.nb ------Small oscillations ------The program supplies the linearized Lagrange equations around a known stable equilibrium positions for a system S with kinetic energy T and po• tential function U given in a symbolic form (see Section 6.6). For given data the program also provides the normal modes of oscillation and the normal frequencies, the general solution and the one satisfying the given initial conditions. Finally, the numerical solution of the linearized problem is compared with the one of the Lagrange equations. The general command is SmallOsc[T.U.var.varO.ind.tfi] where

T: kinetic energy; T=1/2 cpt ~2 U: potential function; U=mgr Cos[cp] var : list of Lagrangian coordinates; var={cp} varO: list of Lagrangian coordinates of the stable equlibrium positions; varO={O} ind: set of initial data on Lagrangian coordinates and velocities; ind={O.1.0.5} tfi : final time of observation. tfi=2 For instance, the motion of a compound pendulum is studied by using the following commands T = I/2 cp' ~2; U = mgr Cos[cp]; 1=1; m=1; r=1; g=9.8; SmallOsc[T. U. {cp}.{O}.{O.1.0.5}.2]

o Appendix III 405

Program Stabn.nb ------Stability The program analyzes the stability properties, by means of the criterion of linear stability, of given equilibrium configurations X e of a system of n differential equations dx dt = F(x). The general command is Stabn[eq,unk,xe] where eq: right-hand side vector; eq={-y+z+x-2*y,x+y-x-2+y-2,x+z-z-2} unk: state variable vector; unk={x,y,z} xe: equilibrium point X e ; xe={O,O,O} For instance,

o 406 Mechanics and Dynamic Systems

Program Surfmot.nb Motion of a point on a surface The program constructs the equation of motion of a point P constrained on a smooth surface S, plots the trajectory on the surface, and determines the normal and tangential components of the reaction. The unit normal to S is denoted by n, while el and e2 are the tangent vectors to coordinate lines on S. The projections of the equation

along the axes of the surface frame (el,e2,n) are used to find the motion and the reactive force. The general command is Surfmot[surf,{u1,u2},uO,vO,c1,c2,m,fd,Fin,Fex,tf,steps] where surf: matrix of the parametric equations of S; surf={Cos[~] ,Sin[~] ,z} u1,u2: surface parameters; u1,u2={~,z} uO: pair of initial values of coordinates; uO={Pi,-1} vO : pair of components of initial velocity; vO={1,O.1} c1: interval of the first surface parameter; c1={O,2*Pi} c2: interval of the second surface parameter; c2={-2, 2} m: mass; m=1 f d: friction coefficient; fd=O.03 Fin: force components in the surface frame (l't, £2, n); Fin={O,O,O} Fex: force components in the lab frame O(x,y,z); Fex={O,y,O} Appendix III 407 tf : final time of observation and numerical integrationj tf=20 steps: number of time steps for numerical integration. steps=900 For instance, surf={Cos[~] ,Sin[~] ,z}; Surfmot[surf,{~,z},{Pi,-1},{1,O.1},{O,2*Pi},{-2,2},1, O.03,{O,O,O},{O,y,O},20,900]

o

Program Sysn.nb System of n differential equations The program computes the solution of a system of n differential equations

dx dt = F(x, t), and plots either the temporal diagram of all variables, or a generalized phase diagram in which a variable is plotted versus another. This option can be exploited to obtain the graph of the trajectory in a plane plotting one component versus the other, Le., thinking of time as the parameter of the curve. The general command is Sysn[eq,unk,inda,{TO,Tl},{r,s},steps] where eq: right-hand side vector; eq={xl' [t]==x2[t]+O.Ol*xl[t]-2, x2'[t]==-xl[t]} unk: state variable vectorj unk={xl[t],x2[t]} inda: set of initial data Xoj inda={{l,O},{O,l},{l,l}} {TO, Tl}: time interval of observation and numerical integrationj {TO, Tl}={O, 10} {r , s} : indices of state variables used for phase diagram; {r,s}={1,2} steps: number of time steps for numerical integration. steps=500 408 Mechanics and Dynamic Systems

For instance, eq={xl'[t]==x2[t]+0.01*xl[t]-2, x2'[t]==-xl[t]}; Sysn[eq,{xl[t],x2[t]},{{1,0},{O,l},{O,l}},{O,10},{l,2}, 500] For a single initial data, the input for inda is {{0,0 .5} }.

D

Program Vectsys.nb Equivalence of vector systems The program allows one to determine the simplest applied vector system which is equivalent to a given system. The general command is Vectsys[A,V,O] where

A: list of application points; A={{O,O.5,l},{l,2,O}} V: list of vector components; V={{O,O,l},{O,-l,l}} 0: point with respect to which the torques are evaluated. O={O,l,O} For instance, Vectsys[{{O,O.5,l},{l,2,O}},{{O,O,l},{O,-l,l}},{O,l,O}]

D References

[ADa] Adam J.A., Effects of vascularization on lymphocytes/tumor cell dynamics: Qualitative features, Math. Compo Modelling, 23(6) (1996),1-11. [ADb] Adam J.A., General aspects of modeling tumor growth and immune responses, in A survey of Models for Tumor Immune , Adam J.A. and Bellomo N. eds., Birkhiiuser (1996), 15-88. [ANa] an der Heiden D., Schwegler H., and Tretter F., Patterns of alco• holism -A mathematical model, Math. Models Meth. Appl. Sci., 8 (1998), 521-4l. [ATa] Antonelli P.L. and Kazarinoff N.D., Modelling density dependent aggregation and reproduction in certain terrestrial and marine eco• system, Ecol. Modelling, 41 (1988), 219-27. [ASa] Ash R. and Gardner M., Topics in Stochastic Processes, Aca• demic Press (1975). [BAa] Bailey P.B., Shampine L.F., and Waltman P.E., Nonlinear Two• Point Boundary Value Problems, Academic Press (1968). [BEa] Bellomo N., Brzezniak Z., and de Socio L.M., Nonlinear Stocha• stic Problems in Applied Sciences, Kluwer (1992). [BEb] Bellomo N. and Preziosi L., Modelling Mathematical Methods and Scientific Computations, CRC Press (1995). [BLa] Beltrami E., for Dynamic Modelling, Academic Press (1987). [BRa] Birkhoff G. and Rota G.C., Ordinary Differential Equations, Wiley (1989).

409 410 Mechanics and Dynamic Systems

[CHa] Chorin A. and Marsden J., Mathematical Introduction to Fluid Dynamics, Springer-Verlag (1979). [CSa] Carbonaro B. and Starita G., The principle of virtual velocities, in Classical Problems in Mechanics, Russo R. ed., Quaderni di Matematica II University of Napoli (1997), 1-96. [DAa] Dautray R. and Lions J.-L., Mathematical Analysis and Nu• merical Methods for Science and Technology, Springer-Ver- lag (1990). [GEa] Genta G., Motor Vehicle Dynamics, World Scientific (1997). [GRa] Greenspan D., Particle Modeling, Birkhauser (1997). [GUa] Gurtin M.E., An Introduction to , Academic Press (1981). [HAa] Hageman L.A. and Young D.M., Applied Iterative Methods, Academic Press (1981). [KEa] Keller H.B., Numerical Solution of Two Point Boundary Value Problems, SIAM Regional Conference Series in n. 24, (1976). [LEa] Leutzback W., Introduction to the Theory of Traffic Flow, Springer-Verlag (1988). [LIa] Lin C.C. and Segel L.A., Mathematics Applied to Determin• istic Problems in the Natural Sciences, SIAM Publ. (1988). [LOa] Logan J.D., Applied Mathematics, John Wiley & Sons (1987). [MIa] Mickens R. E., Oscillation in Planar Dynamic Systems. World Scientific (1986). [SOa] Soong T.T., Random Differential Equations in Science and , Academic Press (1973). [STa] Stevens B.L. and Lewis F.L., Aircraft Control and Simulation, Wiley-Interscience (1992). [WHa] Whitham G., Linear and Nonlinear Waves, John Wiley & Sons (1974). Subject Index

Accuracy of numerical methods for ODE, 343 Active forces, 113-19, 148-52 Adams-Moulton method for ODE, 346 Aircraft model, 146-7 Alcoholism model, 237-9 Angular momentum, 370-4 Angular momentum theorem, 103 Applied forces (system of), 358-60 Articulated systems, 162-5 Asymptotic stability, 64 Autonomous and nonautonomous models, 23

Backward Euler method for ODE, 346 Ball dynamics on a plane, 175-8 Basin of attraction, 64, 82-95 Bendixon's theorem, 284-7 Beta distribution function, 254 Bifurcation point, 270 Bifurcation to chaos, 307 Bifurcation to torus, 307 Binet's formula, 127 Binomial distribution function, 256 Boundary conditions for ODE, 26 Boundary value problems for ODE, 28,46-50 Branch points, 270 Buckling rod model, 48-9

Center of instantaneous rotation, 160 Center of mass (centroid), 363-5 Center point, 68 Central moments for random variables, 252 Centroidal frame, 364 Chaotic dynamics, 292-4 Charge in an electromagnetic field, 203-4

411 412 Mechanics and Dynamic Systems

Chetayev theorem, 75 Classification of stochastic models, 249-50 Classification of models, 20-3 Collocation methods for ODE, 351-3 Conditional stability, 64 Conservative fields, 118-20 Consistency of mathematical models, 22, 327 Constraint (bilateral), 107 Constraint (holonomic), 107 Constraint (ideal), 149 Constraint (mobility), 108 Constraint (positional), 107 Constraint (rough), 150 Constraint (unilateral), 107 Constrained rigid body models, 152-61 Continuous dependence on initial data for ODE, 31-2 Correlation coefficients for random variables, 253 Coulomb forces, 120-1 Coulomb friction, 150 Crank-Nicholson methods, 345-9

D'Alambert Lagrange principle, 190 Dependent variable (definition), 3 Degrees of freedom, 108 Determinism, 16-7 Determinism of Newtonian mechanics, 101 Dirichlet boundary conditions for PDE, 328 Dirichlet stability theorem, 209 Diffusion (heat) model, 23-4, 318-9 Discrete models of continuous systems, 329-36 Discretization methods of continuous models, 329-36 Duffing model, 214-7 Dynamic friction, 151 Dynamic response, 27, 40-7 Dynamic system (definition), 7

Ecosystems modeling, 241-2 Elastic forces, 116 Elastic wire-mass model, 9-12,81-2 Electric circuit modeling, 14-6 Elementary displacement, 185 Elementary work, 188 Ellipsoid of inertia, 367 Energy methods, 189-211 Subject Index 413

Energy (kinetic) theorem, 191 Equilibrium configurations, 63 Equivalence of systems of forces, 360 Euler angles, 143 Euler equations, 153-5 Euler methods, 39,346 Existence and uniqueness for b.v.p. for ODE, 48 Existence and uniqueness for i.v.p. for ODE, 31,35 Extension theorems, 32

Feichtinger model, 13 Finite difference methods for ODE, 353-5 First integrals, 191-201 First order statistics, 258 Flutter model, 311-3 Force fields, 115-21 Free rotations of a gyroscope, 171-2 Friction forces, 114, 148-52 Friction rolling, 149 Fundamental matrix for linear ODE, 39

Galilei's principle, 102 Generalized potential, 202-3 Global stability, 64 Gravitational forces, 115-6 Gyroscope effect, 224 Gyroscope models, 171-4, 220-4 Gyroscopic axis, 171

Heat diffusion model, 23-4,318-9, 335-6 Heavy gyroscope, 220-4 Herpolhode, 218 Hopf's bifurcation, 287-92 Hopf's theorem, 288 Huygens theorem, 368 Hydrodynamic models, 324-6 Hydroplane model, 270-2

Independent variables (definition), 3 Initial and boundary conditions for ODE, 26 Initial value problem for ODE, 6, 26

Kepler (first) law, 125 Kepler (second) law, 128 414 Mechanics and Dynamic Systems

Kepler (third) law, 129 Kinematic calculus, 361-2 Kinetic energy, 372-3 Kinetic energy theorem, 191 Kirkhoff and Mach's principle, 99 Konig theorem, 373

Lagrangian coordinates, 108-9 Lagrange equations for holonomic systems, 197-8 Lagrange equations for potential forces, 202-3 Lagrange equations (method), 194-6 Lagrange function, 202 Lagrange mechanics, 189-230 Lagrange multipliers, 198 Lagrange polynomials, 350 Liapunov function, 71 Liapunov stability, 71-2 Limit cycle (definition), 283 Limit cycles, 282-7 Lindstedt-Poincare's method, 86 Linear models and systems, 22 Linear momentum, 369-70 Linear momentum theorem, 104 Linear stability and linearization, 65-70 Linear systems of ODE, 22, 35-9 Linear systems of ODE with constant coefficients, 37-9 Line galloping model, 300-4 Liouville equation, 262 Lipschitz condition, 30, 35 Lipschitz constant, 30 Lorentz forces, 120-1 Lorentz model, 294 Lymphocyte-tumor dynamics, 242-3

Marginal densities of random variables, 253 Mass spring model, 201-2, 211 Master equation, 261 Material point, 95 Material system, 93 Mathematical model (definition), 3 Mean value, 252 Mechanical energy, 193 Mechanical model, 27, 79 Metallic meter model, 298-300 Subject Index 415

Moments of inertia, 363 Moment representation of random variables, 259-60 Moments of random variables, 252-3 Momentum theorem (angular), 105 Momentum theorem (linear), 104 Mozzi's axis, 145, 359

Neumann boundary conditions for PDE, 328 Newtonian dynamics, 95-137 Newton's law, 101 Nonlinear dynamics model, 33-4 Normal distribution function, 254 Normal form of ODE, 8, 21 Normal frequency and mode, 210 Numerical methods for b.v.p. for ODE, 349-54 Numerical methods for Lv.p. for ODE, 342-55 Nutations, 223

Orbit (definition), 7 Oscillation model, 25--6

Particle dynamics (point-mass), 4-6, 23, 80-1, 284-5 Particle (point-mass, falling in air) dynamics, 129-33 Particle dynamics (point-mass) in a central force field, 125-9 Particle dynamics (point-mass) on a moving guide, 186-7 Particle dynamics (point-mass) on a rotating guide, 204-6 Particle dynamics (point-mass) on a surface, 112-4 Pendulum model, 58-61, 123-4, 167-9 Period doubling (bifurcation), 307 Perturbation methods, 62, 76-86 Piston dynamics, 164-5 Pitchfork bifurcation, 280 Pitching motion of an airplane, 146 Poincare's theorem, 83-4 Poisson distribution function, 254 Poisson's formula, 362 Poinsot's motion, 217-9 Polhode, 218 Population dynamics, 238 Potential, 118-9 Power, 188 Predictor-corrector methods for ODE, 344-8 Principal inertia frame, 368 Principal moments of inertia, 367 416 Mechanics and Dynamic Systems

Principle (first) of inertia, 98 Principle of virtual work, 189, 208 Principle (second) of inertia, 99 Probability density, 257 Products of inertia, 365-7 Programming with Mathematica®, 377-82

Random initial data, 261-3 Random particle dynamics, 247-51 Random variables, 251-3 Rayleigh distribution function, 254 Reactive forces, 110-2, 148-52 Realization and path, 256 Rigid body dynamics, 139-78 Rigid body model, 140-8 Rigid body kinematics, 145 Rigid body with a fixed point, 153-5 Rigid body with a fixed axis, 155-8 Rigid body with a point on a surface, 158-9 Rigid body with plane motion, 159-61 Ring on a rotating wire, 295-7 Robin boundary conditions for PDE, 328 Rolling disk model, 198-200 Rolling motion of an airplane, 146 Rotor dynamics, 192-4, 196-7 Runge-Kutta methods, 344-5

Saddle point, 67 Scalar invariants of systems of forces, 359 Scientific programs, 377-408 Self-sustained oscillations, 283 Semiflow (definition), 7 Shooting method, 349-51 Sinc functions, 350 Spring model, 84-5 Soft loss of stability, 297 Stability by energy methods, 207-8 Stability definitions, 63-4 Stability diagrams, 268-83 Stability of numerical methods for ODE, 342 Stable and unstable focus, 68 Stable and unstable manifolds, 67 Stable and unstable node, 67 Standard deviation, 252 Subject Index 417

Statement of problems for ODE, 26-9 Statement of problems for PDE, 326-9 State variable (definition), 3 Static friction, 151 Steady precession, 172 Stochastic process, 256 Stochasticity, 16-7, 246-7 Strange attractors, 292-3 Stroboscopic maps, 300 Subcritical and supercritical bifurcation, 280

Tensor of inertia, 365-7 Three body dynamics, 211-14 Three mass-point dynamics, 106, 134-5 Traffic flow models, 321-3 Trajectory (definition), 7 Transcritical bifurcations, 281 Transition to chaos, 307-8 Truncation error, 343 Turning point, 273

Uniform rotations, 170-1

Validation of models, 16-7, 228-30 van der Pol model, 15, 69-70, 285-8, 290 Variance, 252 Vector calculus, 355-6 Vehicle dynamics, 166-7 Vibrating string model, 84-6,96-7,315-6,330-1 Virtual displacement, 185 Virtual work, 188

Weakly nonlinear models, 22 Well formulated problem for ODE, 29 Well formulated problem for PDE, 328-9 Well-posedness for ODE, 29 Well-posedness for PDE, 327

Yawing motion of an airplane, 146