2nd Year Computational Physics Week 4 (standard): Ordinary differential equations

Size: px
Start display at page:

Download "2nd Year Computational Physics Week 4 (standard): Ordinary differential equations"

Transcription

1 2nd Year Computational Physics Week 4 (standard): Ordinary differential equations Last compiled September 28,

2 Contents 1 Introduction 4 2 Prelab Questions 4 3 Simple Differential Equations Background Ordinary Differential Equations Euler s Method Taylor Expansion Method Procedure Example Code Coupled and Higher-Order Differential Equations Background Coupled ODEs and Reduction of Order Runge-Kutta Method Applying the Runge-Kutta Method With Reduction of Order for Coupled ODEs Procedure Example Code Bonus Section: The Transition from Order to Chaos: Plotting the Motion of a Double Pendulum Background Chaotic Systems Describing Complex Systems: Lagrange s Equations and Generalised Coordinates

3 5.1.3 Double Pendulum Initial Conditions and Energy Domains Procedure (One Bonus Mark) Example Code

4 1 Introduction Differential equations are at the heart of physics. They are used in almost all areas of physics, from classical equations of motion to thermodynamics to quantum mechanics. It cannot be stressed enough how important they are, or how difficult they can be to solve. Even seemingly simple systems like the double pendulum we will cover in this lab can lead to equations that are challenging to find analytic solutions for. In this lab we will learn some important numerical techniques for solving such equations. We will begin with the simplest methods for solving ordinary differential equations, namely the Euler and Taylor methods, then move on to the more accurate Runge-Kutta method, which we will use to solve the motion of a single pendulum. The culmination of the lab will be to calculate the motion of a double pendulum, and show that it displays chaotic behaviour. 2 Prelab Questions 1. Draw a flowchart showing how you use the Euler Method to solve an ODE as in question one of procedure Draw a flowchart showing how you would use the Runge-Kutta method at 4th order, to find a solution to coupled ODEs with reduction of order, as in question 1 of procedure 4.2. You can do this generally (without specifying the code for exact form of z (t) or the defining explicit initial conditions) or for the specific case of the pendulum as in question 2 of

5 3 Simple Differential Equations 3.1 Background Ordinary Differential Equations The general form of an ordinary differential equation (ODE) is given by y N (t) = f(t, y(t), y (t),..., y (N 1) (t)). (1) In order to solve this ODE we need N initial conditions, i.e for N = 1 we need y(t 0 ) = y 0, for N = 2 we need y(t 0 ) = y 0 and y (t 1 ) = y 1, etc. The methods outlined in this section are applicable to 1st order (N = 1) ODEs of the form dy(t) = f(t, y(t)). (2) dt with the single initial condition y(t 0 ) = y 0. Note that these techniques are not restricted to linear ODEs, that is function f(t.y(t),..., y (N 1) (t)) does not need to be linear in t, y(t),..., y (N 1) (t) Euler s Method The Euler Method is a method for solving 1st order ODEs of the form Eq. 2. The basic premise is to decompose the solution y(t) into a series of equally spaced trapezoids of width h, in a similar fashion to the trapezoidal integration method in the last lab. Explicitly where n is an integer. t t n = nh (3) y(t) y n = y(t n ) (4) Making this approximation the gradient at t n becomes y n = (y n+1 y n )/h, which causes the Eq. 2 to simplify to y n+1 = y n + hf(t n, y n ). (5) An approximation of the solution y(t) can therefore be built up by iterating Eq. 5 for 1 n N, where Nh is the upper range of y(t). Note that that the first value in the iteration is defined by the provided initial condition, i.e. y 0 = y(t 0 ). 5

6 We can assess the local error of this method by calculating which for this method is of O(h 2 ). LT E(t) = y n+1 y n h f(t n, y n ), (6) Taylor Expansion Method Similarly to numerical differentiation techniques we can improve on the accuracy of the Euler method by taking a Taylor expansion of the solution y(t) about the discretization scale h, i.e. y(t + h) = y(t) + hy (t) h2 y (t) + 1 3! h3 y (t) +... (7) We can then use Eq. 2 to express this in terms of f(t, y(t)). Using the notation y(t + h) y n+1, y(t) y n and f n f(t n, y n ), y n+1 = y n + hf n h2 f n + 1 3! h3 f n +... (8) Truncating at O(h 3 ), we get the iterative solution y n+1 = y n + hf n, (9) where F n f n hf n + 1 3! h2 f n. (10) Applying Eq. 6 one can easily show that the Taylor Method has a local error or O(h 4 ). This is clearly more accurate then than the Euler Method. In fact one can consider the Euler Method to be the Taylor Method truncated at O(h). 3.2 Procedure 1. Write an algorithm for solving an ODE using the Euler Method. 2. Consider the ODE y (x) = xy with y(0) = 1, with exact solution y(x) = e x2 /2. Use both numerical techniques to find approximate solutions to this equation. You can copy the algorithm for the Taylor Method directly from the example code. 3. Construct a table of values and investigate accuracy of each method. 6

7 3.3 Example Code // Example Code for Ordinary Differential Equations // Author: Chia-Ling Hsu // Date: 14/03/2016 #include <stdio.h> #include <stdlib.h> #include <math.h> double dfun(double, double); // y'(x) double ddfun(double, double); // y''(x) double dddfun(double, double); // y'''(x) double sol(double); // Solution of y(x) double taylor(double, double, double); // Taylor's method int main() double x = 0.; double h = 0.01; // Step double x_f = 1.; // double exact = 1.; // Variable for exact solution double y_t = 1.; // solution for Taylor's method double err_t = 0; // error for Taylor's method // Open a file for saving results FILE *fp = fopen("ode.dat","w"); // Input steps and end point of x printf("\nenter h,x_f: "); scanf("%lf%lf",&h,&x_f); printf("x \t y_t \t y(x) - y_t \n"); printf("%lf %lf %E\n", x, y_t, err_t); // Loop Starts while (x<x_f) // Assign values to variables y_t = taylor(x,y_t,h); // Increase x by h x += h; exact = sol(x);

8 // Calculate the error for different methods // Here error is defined as the absolute value of the difference between exact and numerical solutions. err_t = fabs(exact - y_t); // Print out the results for each step printf("%lf %lf %E\n", x, y_t, err_t ); // End of while loop // Close the file fclose(fp); return 0; // Exact solution of the given question double sol(double x) return exp(x*x*0.5); // Define first order differential equation double dfun(double x, double y) // y' = x*y return x*y; // Define second order differential equation (Taylor's only) double ddfun(double x, double y) // y'' = y + x*y' return y+x*dfun(x, y); // Define third order differential equation (Taylor's only) double dddfun(double x, double y) // y''' = 2*y' + x*y'' return 2*dfun(x,y)+x*ddfun(x,y); // Taylor method starts double taylor(double x, double y, double h) // Calculate till 3rd order

9 y = y + h*(dfun(x, y) + h/2.*(ddfun(x,y) + (h/3.*dddfun(x,y)))); // Return result return y;

10 4 Coupled and Higher-Order Differential Equations 4.1 Background Coupled ODEs and Reduction of Order The methods above are useful for solving first order ODEs but how do we deal with higher orders? The solution is to reduce and Nth order ODE into a system of N coupled first order ODEs, which we can solve using 1st order methods. To explain further we will consider the example of a second order ODE, though of course the same rationale can be applied up to any order. Let us begin with y (t) = f(t, y(t), y (t)), (11) which has initial conditions y(t 0 ) = y 0 and y (t 1 ) = y 1. We can now define z(t) y (t). We now have 2 coupled first order ODEs y (t) = g(t, y(t), z(t)), (12) z (t) = f(t, y(t), z(t)), (13) where g(t, y(t), z(t)) z, and y(t 0 ) = y 0 and z(t 1 ) = y 1 z 1. We can now use our usual 1st order techniques to solve first for z(t) and then for y(t). For example, if we were to use Euler s Method, we would iterate over starting from initial conditions y 0 and z 0. z n+1 = z n + hf(t n, y n, z n ), (14) y n+1 = y n + hg(t n, y n, z n ), (15) Runge-Kutta Method The next step up in accuracy from the previous two methods discussed is the Runge-Kutta Method. Where the last two algorithms used 2 sample points per step in our iteration, namely y(t n ) and y(t n + h), the Runge-Kutta Method uses the average of 4 weighted points, specifically y n+1 = y n + h 6 (k 1 + 2k 2 + 2k 3 + k 4 ), (16) 10

11 where k 1 = f(t n, y n ), (17) k 2 = f(t n + h 2, y n + h 2 k 1), (18) k 3 = f(t n + h 2, y n + h 2 k 2), (19) k 4 = f(t n + h, y n + hk 3 ). (20) k 1 and k 4 are increments based on the slope at the beginning and endpoints of the slice, which k 2 and k 3 are increments based on the slope at the midpoint of the slice. The middle points are weighted more heavily than the endpoints in this algorithm. This method is more accurate than both the Euler and Taylor methods, having a local truncation error of O(h 5 ). This method is actually the 4th order of a class of methods collectively known as Runge-Kutta Methods, defined by where y n+1 = y n + h s b i k i, (21) i=1 k 1 = f(t n, y n ), (22) k 2 = f(t n + c 2 h, y n + (a 21 k 1 )), (23) k 3 = f(t n + c 3 h, y n + (a 31 k 1 + a 32 k 2 )), (24). k s = f(t n + c s h, y n + h(a s1 k 1 + a s2 k a s,s 1 k s 1 )). (25) The weighting coefficients a b and c are obtained from standard tables known as Butcher Tableau, usually represented like 0 c 2 a 21 c 3 a 21 a c s a s1 a s2... a s,s 1 b 1 b 2... b s 1 b s Table 1: General format of Butcher Tableau. 11

12 For example the Butcher Tableau for the 4th order Runge-Kutta Method is given by Table 2, and that of the less accurate 2nd order Runge-Kutta Method is given by Table /2 1/2 1/2 0 1/ /6 1/3 1/3 1/6 Table 2: RK4 Butcher Tableau. 0 1/2 1/2 0 1 Table 3: RK2 Butcher Tableau Applying the Runge-Kutta Method With Reduction of Order for Coupled ODEs When applying the Runge-Kutta method with coupled ODEs we have: z n+1 = z n + h 6 (j 1 + 2j 2 + 2j 3 + j 4 ), (26) y n+1 = y n + h 6 (k 1 + 2k 2 + 2k 3 + k 4 ). (27) 12

13 To get the k and j values we have to calculate the following (in order) like so: j 1 = f(t n, y n, z n ), (28) k 1 = g(t n, y n, z n ), (29) j 2 = f(t n + h 2, y n + h 2 k 1, z n + h 2 j 1), (30) k 2 = g(t n + h 2, y n + h 2 k 1, z n + h 2 j 1), (31) j 3 = f(t n + h 2, y n + h 2 k 2, z n + h 2 j 2), (32) k 3 = g(t n + h 2, y n + h 2 k 2, z n + h 2 j 2), (33) j 4 = f(t n + h, y n + hk 3, z n + hj 3 ), (34) k 4 = g(t n + h, y n + hk 3, z n + hj 3 ). (35) Where f and g are those from section Procedure 1. Write a routine for finding solutions to coupled ODEs using Runge-Kutta method at 4th order. Assume that you know the analytic form of z (t) = f(t, y(t), z(t)), and the initial conditions z 0 and y 0. We know that g(t n, y n, z n ) = z n so for example; g(t n + h 2, y n + h 2 k 1, z n + h 2 j 1) = z n + h 2 j Consider a swinging pendulum, whose angle to the horizontal is given by θ(t). The equation of motion for this system is given by 0 = θ (t) + g sin θ/l θ (t) + gθ/l if we make the small angle approximation. Express this system as a set of coupled ODEs and solve for θ(t) using a 4th order Runge-Kutta routine up to t = 1s (choose h 1s), using the initial conditions θ(0) = π/6 and θ (0) = 0. Plot the resulting angle as a function of time. (l = 0.35m, g = 10m/s 2 ) 3. Repeat the above procedure, varying the initial conditions, graphing the results. What do you notice as the initial angle decreases/increases. 4. Increase the maximum time to t = 60s. Is the solution stable? 5. Extension: Repeat the above without assuming the small angle approximation, i.e. using the equation of motion 0 = θ (t) + g sin θ/l θ (t) + gθ/l. Comment on any differences in the angular trajectory. 13

14 4.3 Example Code // Example Code for Coupled ODEs and Reduction of Order // Author: Julia McCoey // Date: 17/03/2016 // Example Code for Runge-Kutta method. // Author: Julia McCoey // Date: 16/03/2016 #include <stdio.h> #include <stdlib.h> #include <math.h> typedef float (function)(float,float); // Declare function signatures float differential(float, float); // y'(x). This is the differential equation. float exactsolution(float); // y(x). This is the equation we approximate with Runge Kutta float RungeKutta(function, float, float, float); // Runge-Kutta average of 4 points float k1(function, float, float); float k2(function, float, float, float); // equations for Runge-Kutta method float k3(function, float, float, float); float k4(function, float, float, float); int main() float h = 0.01; // Step size float x0 = 0; // This is the initial x value float xf = 1.; // This is the final x value to calculate the approximation up to float y0 = 0; // This is the initial condition, i.e., y(x0) // Input step size and initial conditions

15 printf("\nplease enter step size: "); scanf("%f",&h); printf("\nplease enter the first x value you would like to calculate from, i.e. x0: "); scanf("%f",&x0); printf("\nplease enter the last x value you would like to calculate up to: "); scanf("%f",&xf); printf("\nplease enter the initial condition for y, i.e. y(x0): "); scanf("%f",&y0); int arraysize=((xf-x0)/h)+2; // size of arrays for storing the x values and the y values float xvalues[arraysize]; // array for storing x values; pgplot can plot these. float yvaluesrk[arraysize]; // array for storing y values; pgplot can plot these. float yvaluesexact[arraysize]; // array for storing the exact values xvalues[0]=x0; //start the x array at the first x value yvaluesrk[0]=y0; //start the y array with the given initial condition yvaluesexact[0]=y0; //fill the first value of the exact y values // This loop fills the x array with values increasing by h, // and fills the Runge-Kutta y array with values approximated by the Runge-Kutta method. // It also fills yvaluesexact with y values calculated with an exact solution to // the differential equation. int i; for (i=1; i<arraysize ; i++) //Use the Runge Kutta method to approximate the next y value yvaluesrk[i]=rungekutta( differential,xvalues[i-1],yvaluesrk[i-1],h); //Increase x by h (make the next x value be the previous one plus h) xvalues[i]=xvalues[i-1]+h; //Fill in exact solutions (to compare to the approximation)

16 yvaluesexact[i] = exactsolution(xvalues[i]); //Print results. They are in arrays of floats, so you can plot them with PGPlot. printf("\n x Runge Kutta y exact y"); for (i=0; i<arraysize-1 ; i++) printf("\n%4f\t%4f\t%4f",xvalues[i],yvaluesrk[i],yvaluesexact[i]); printf("\n"); return 0; // The first order differential equation float differential(float x, float y) // y' = x*y return x*y; // Exact solution of the differential equation, i.e., the equation that // we try to approximate with Runge-Kutta method float exactsolution(float x) return exp(x*x*0.5); //The Runge Kutta method (technically the 4th order Runge Kutta method) float RungeKutta(function f, float t, float yn, float h) return yn + (h/6)*( k1(f,t,yn) + (2*k2(f,t,yn,h)) + (2*k3(f,t,yn,h)) + k4(f,t,yn,h) ); //Equations used in Runge Kutta float k1(function f, float t, float yn) return f(t,yn);

17 float k2(function f, float t, float yn, float h) return f(t,yn+((h/2)*k1(f,t,yn))); float k3(function f, float t, float yn, float h) return f(t,yn+((h/2)*k2(f,t,yn,h))); float k4(function f, float t, float yn, float h) return f(t,yn+(h*k3(f,t,yn,h)));

18 5 Bonus Section: The Transition from Order to Chaos: Plotting the Motion of a Double Pendulum 5.1 Background In this section we will look at a system with a set of equations of motion that are not analytically tractable, i.e. the motion of a double pendulum. This system is of particular interest because it can display chaotic behaviour, with the paths of the pendula tracing out unpredictable complex paths which belie the seemingly simple nature of the set up Chaotic Systems A system is said to behave chaotically if it is extremely sensitive to the initial conditions. It may be deterministic, i.e. it follows well defined classical equations of motion, but it can be unpredictable in its long term behaviour. If the initial conditions of a chaotic system are not known to infinite precision, then it is impossible to predict what will happen to the system in the long term. The transition from order to chaos in a given system can be as simple as choosing a set of initial conditions in a given range. Let us illustrate this with an example. Consider an object undergoing simple harmonic motion. We begin with some initial conditions, and the object will oscillate with a well defined frequency and period. If we were to perturb those initial conditions slightly, the resulting amplitude and period would be perturbed by a small predictable amount. In a chaotic system like the one covered in this section (a double pendulum), a small perturbation in the initial conditions, (say the initial angles of the pendula) can lead to paths which in no way resemble those traced out without the perturbation Describing Complex Systems: Lagrange s Equations and Generalised Coordinates While Newtons equations of motion (F x = mẍ and F y = mÿ) are very useful for describing the motion of an object with time given a force (for example gravity), they can become extremely messy in some situations. In particular, you may be looking at a system where a Cartesian coordinate system is not the best choice 18

19 (such as for a double pendulum), what then do you do? The answer lies in the Lagrangian formalism of classical mechanics. Instead of writing down Newtons equations, we postulate the existence of an object known as the Lagrangian of a system L = T V, where T and V are the kinetic and potential energies of the system respectively. The Lagrangian can then be used to calculate the equations of motion by using the Euler Lagrange equations d dt ( ) L q i L q i = 0. (36) q i are known as a generalised coordinates, they can be any set of independent coordinates, for example q 1 = x, q 2 = y in a Cartesian basis, or q 1 = r, q 2 = θ in a polar basis. This is quite powerful, as given a Lagrangian in any coordinate system we can determine the equations of motion without the necessity of using a Cartesian basis. As an example let us consider the Lagrangian for a point mass m confined to the x direction, which experience potential V (x), which is given by L = 1 2 mẋ2 V (x). V (x) V (x) Using this L, Eq. 36 becomes mẍ =. Recalling that F (x), we x x return Newtons equation of motion. You will learn more about the Lagrangian formulation of classical mechanics in your classical physics course Double Pendulum θ 1 l 1 m 1 θ 2 l 2 m 2 Figure 1: Function f(x) broken into equally spaced differentiation/integration regions of width h. 19

20 The setup of a double pendulum system can be seen in Fig. 1. For two pendulums of fixed length and mass, allowed to swing in a 2D plane, there are 2 independent degrees of freedom, θ 1 and θ 2, defined in Fig. 1. The Lagrangian of this system can be easily derived to be the following L = T V = 1 2 (m 1 + m 2 )l 2 1 θ m 2l 2 2 θ m 2 l 1 l 2 θ1 θ2 cos(θ 1 θ 2 ). (37) From this we can use the Euler-Lagrange equations in Eq. 36 to derive the equations of motion for θ 1 and θ 2, which turn out to be 0 = (m 1 + m 2 )l 1 θ1 + m 2 l 2 θ2 cos(θ 1 θ 2 ) + m 2 l 2 θ2 2 sin(θ 1 θ 2 ) + g(m 1 + m 2 ) sin θ 1 0 = m 2 l 2 θ2 + m 2 l 1 θ1 cos(θ 1 θ 2 ) m 2 l 1 θ2 1 sin(θ 1 θ 2 ) + m 2 g sin θ 2 (39) We are left with two second order ODEs, the two solutions to which are θ 1 (t) and θ 2 (t). To obtain these solutions we require 4 initial conditions, for example values for θ 1 (t 0 ), θ 2 (t 0 ), θ 1 (t 0 ), and θ 2 (t 0 ). We can then apply reduction of order to these equations to reduce these 2 second order equations to a set of 4 first order ODEs. We make the substitution ϕ 1 θ 1 and ϕ 2 θ 2, which leave us with the following 4 first order coupled ODEs θ 1 = a(θ 1, θ 2, ω 1, ω 2 ), (40) ω 1 = b(θ 1, θ 2, ω 1, ω 2 ), (41) θ 2 = c(θ 1, θ 2, ω 1, ω 2 ), (42) ω 2 = d(θ 1, θ 2, ω 1, ω 2 ), (43) where a(θ 1, θ 2, ω 1, ω 2 ) ω 1, b(θ 1, θ 2, ω 1, ω 2 ) ω 2, and b(θ 1, θ 2, ω 1, ω 2 ) and d(θ 1, θ 2, ω 1, ω 2 ) can be determined by solving Eqs. 38 and 39 for ω 1 and ω 2. They are messy so we will not provide them in the text, please refer to the example code for their explicit forms. We can now express these equations in Runge-Kutta form, such that we can find numerical solutions for θ 1 (t) and θ 2 (t). Extending the logic of Section we obtain the iterative equations: θ 1, n+1 = θ 1, n + h 6 (j 1 + 2j 2 + 2j 3 + j 4 ), (44) ω 1, n+1 = ω 1, n + h 6 (k 1 + 2k 2 + 2k 3 + k 4 ), (45) θ 2, n+1 = θ 2, n + h 6 (l 1 + 2l 2 + 2l 3 + l 4 ), (46) ω 2, n+1 = ω 2, n + h 6 (m 1 + 2m 2 + 2m 3 + m 4 ), (47) (38) 20

21 where analogously to before j 1 = a(t n, θ 1 n, θ 2 n, ω 1 n, ω 2 n ), (48) k 1 = b(t n, θ 1 n, θ 2 n, ω 1 n, ω 2 n ), l 1 = c(t n, θ 1 n, θ 2 n, ω 1 n, ω 2 n ), m 1 = d(t n, θ 1 n, θ 2 n, ω 1 n, ω 2 n ), j 2 = a(t n + h 2, θ 1 n + h 2 j 1, θ 2 n + h 2 l 1, ω 1 n + h 2 k 1, ω 2 n + h 2 m 1), (49) k 2 = b(t n + h 2, θ 1 n + h 2 j 1, θ 2 n + h 2 l 1, ω 1 n + h 2 k 1, ω 2 n + h 2 m 1), l 2 = c(t n + h 2, θ 1 n + h 2 j 1, θ 2 n + h 2 l 1, ω 1 n + h 2 k 1, ω 2 n + h 2 m 1), m 2 = d(t n + h 2, θ 1 n + h 2 j 1, θ 2 n + h 2 l 1, ω 1 n + h 2 k 1, ω 2 n + h 2 m 1), j 3 = a(t n + h 2, θ 1 n + h 2 j 2, θ 2 n + h 2 l 2, ω 1 n + h 2 k 2, ω 2 n + h 2 m 2), (50) l 3 = c(t n + h 2, θ 1 n + h 2 j 2, θ 2 n + h 2 l 2, ω 1 n + h 2 k 2, ω 2 n + h 2 m 2), k 3 = b(t n + h 2, θ 1 n + h 2 j 2, θ 2 n + h 2 l 2, ω 1 n + h 2 k 2, ω 2 n + h 2 m 2), m 3 = d(t n + h 2, θ 1 n + h 2 j 2, θ 2 n + h 2 l 2, ω 1 n + h 2 k 2, ω 2 n + h 2 m 2), j 4 = a(t n + h, θ 1 n + hj 3, θ 2 n + hl 3, ω 1 n + hk 3, ω 2 n + hm 3 ), (51) k 4 = b(t n + h, θ 1 n + hj 3, θ 2 n + hl 3, ω 1 n + hk 3, ω 2 n + hm 3 ), l 4 = c(t n + h, θ 1 n + hj 3, θ 2 n + hl 3, ω 1 n + hk 3, ω 2 n + hm 3 ), m 4 = d(t n + h, θ 1 n + hj 3, θ 2 n + hl 3, ω 1 n + hk 3, ω 2 n + hm 3 ). We can now start with 4 initial conditions θ 1 0, θ 2 0, ω 1 0, and ω 2 0, and iterate over n to determine solutions to θ 1 (t) and θ 2 (t). 21

22 5.1.4 Initial Conditions and Energy Domains The initial conditions of the system determine the amount of energy available to it. For example the initial angles and velocities θ 1 /2(0), θ1 /2(0) will determine how much potential and kinetic energy is available to the pendula from the beginning. Given that the the pendulum system is closed, this energy is conserved, implying that the initial the amount of energy injected has a great effect on extent of motion on the system. Specifically, one can determine a-priori whether or not it is possible for either pendulum to flip completely around, based on the amount of energy initially available. Though the derivation is beyond the scope of this course, it is possible to show that if the initial conditions satisfy θ 1 (0) = θ 2 (0) = 0, and 3 cos θ 1 + cos θ 2 > 2, (52) then it is impossible for either pendulum to flip completely, there is simply not enough energy available. We can use this information when choosing our initial conditions, to better understand the resulting angular paths. 5.2 Procedure (One Bonus Mark) 1. Write a routine which finds solutions for θ 1 (t) and θ 2 (t) using the Runge- Kutta technique. The example code does this using the Euler Method. You may use this as a guide, even copying the relevant pieces of code directly. Note that the number of steps is N = As a test of your routine, assume θ 1 = θ 2, and use the initial conditions in Section 4.2 (θ 1 (0) = θ 2 (0) = π/6 and ω 1 (0) = ω 2 (0) = 0) to find the solution for θ 1 (t). This should just be the same solution as for a single pendulum. Plot up until t = 10s. 3. Use these same initial conditions and plot angular trajectories up to t = 10s for general solution θ 1 θ 2 0. Compare this with the result for a single pendulum and discuss. 4. Choose the initial condition θ 1 (0) = θ 2 (0) = π/3 and ω 1 (0) = ω 2 (0) = 0 and plot angular trajectories up to t = 10s. Change the values of the initial angles slightly. How does the long term behaviour change? Are you seeing evidence of chaotic behaviour? 22

23 5. Extension: Vary your initial conditions θ 1 (0) and θ 2 (0), choosing a few values which satisfy Eq. 52, and a few which do not. Plot your trajectories up to t = 10s. Comment on any differences in the long term behaviour of the two classes of initial condition. Varying these slightly from their initial values, do you see evidence of more/less chaotic behaviour in the different energy domains? 5.3 Example Code // Example Code for The Transition from Order to Chaos // Author: Anton Hawthorne // Date: 16/03/2016 #include <stdlib.h> #include <stdio.h> #include <math.h> #include <cpgplot.h> //Define G as +9.81m/s, the differential equations assume g is a +ve value. #define G 9.81 #define PI //Throughout: the variables labelled 1 belong to the first pendulum, and those labelled 2 correspond to the pendulum that is attached to the first. //so total extended length is l1+l2. the angle theta 2 is the angle from vertical, does not depend on theta1 inherently (although its dynamics do) //The right hand side of the second order differential equation: returns d(omega1)/dt = d2(theta1)/dt2 given the input masses, lengths, angles and angular velocities double f1(double m1, double m2, double l1, double l2, double theta1, double theta2, double omega1, double omega2) double a = m2*l2*pow(omega2,2)*sin(theta2-theta1); double b = -(m1+m2)*g*sin(theta1); double c = m2*cos(theta2-theta1)*(l1*pow(omega1,2)*sin(theta2-theta1) -G*sin(theta2)); double d = m1 + m2*pow(sin(theta2-theta1),2); return (a + b + c) / d;

24 //returns d(omega2)/dt = d2(theta2)/dt2 given the input masses, lengths, angles and angular velocities double f2(double m1, double m2, double l1, double l2, double theta1, double theta2, double omega1, double omega2) double a = -(m1+m2)*(l1*pow(omega2,2)*sin(theta2-theta1) + G*sin(theta2)); double b = cos(theta2-theta1)*((m1+m2)*g*sin(theta1) - m2*l2*pow(omega2,2)*sin(theta2-theta1)); double c = l2*(m1+m2*pow(sin(theta2-theta1),2)); return (a + b) / c; //return the next omega (timestep h later) given the input masses, lengths, angles, angular velocities and the timestep: h double omega1iterate(double m1, double m2, double l1, double l2, double theta1, double theta2, double omega1, double omega2, double h) return omega1 + h*f1(m1,m2,l1,l2,theta1,theta2,omega1,omega2); //the next value is the input value, plus the gradient multiplied by the width //same again for the angular velocity of the second pendulum double omega2iterate(double m1, double m2, double l1, double l2, double theta1, double theta2, double omega1, double omega2, double h) return omega2 + h*f2(m1,m2,l1,l2,theta1,theta2,omega1,omega2); //find the next theta1 double theta1iterate(double theta1, double omega1, double h) return theta1 + h * omega1; //The next theta one is the input + the angular velocity * timestep double theta2iterate(double theta2, double omega2, double h) return theta2 + h * omega2; //Function to run the pendulums and plot the trajectories void runpendula(double m1, double m2, double l1, double l2, double theta1initial, double theta2initial, double omega1initial, double omega2initial, double time, int stepno)

25 double h = time/stepno; //timestep is the total run time/number of steps double theta1 = theta1initial; double theta2 = theta2initial; double omega1 = omega1initial; double omega2 = omega2initial; //store the x and y values of each pendulum for each time step float xvalues1[stepno]; float yvalues1[stepno]; float xvalues2[stepno]; float yvalues2[stepno]; double omega1new;//temporary placeholder for omega1 int i = 1; for (i = 1; i<=stepno; i++) //calculated the next iterations of the angular velocities with the previous omega values omega1new = omega1iterate(m1,m2,l1,l2,theta1,theta2,omega1,omega2,h); omega2 = omega2iterate(m1,m2,l1,l2,theta1,theta2,omega1,omega2,h); //after omegas have been calculated, set omega1 to be omega1new. This way is needed so that both input omegas are used in calculating omega1 and omega2 omega1 = omega1new; //now calculate the next theta values theta1 = theta1iterate(theta1,omega1,h); theta2 = theta2iterate(theta2,omega2,h); //angle check for the cases where the pendulum might flip, if either pendulum does a full rotation then reset the angles if (theta1 > 2*PI) theta1 = theta1-2*pi; if (theta1 < -2*PI) theta1 = theta1 + 2*PI; if (theta2 > 2*PI) theta2 = theta2-2*pi; if (theta2 < -2*PI) theta2 = theta2 + 2*PI; //add the x and y positions of pendulum 1 at this time

26 xvalues1[i-1] = l1*sin(theta1); yvalues1[i-1] = -l1*cos(theta1); //add the x and y positions of pendulum 2 xvalues2[i-1] = l1*sin(theta1)+l2*sin(theta2); yvalues2[i-1] = -l1*cos(theta1)-l2*cos(theta2); //plot the results! cpgbeg(0,"/xs",1,1); cpgsls(1); cpgsch(1.); cpgswin(-1,1,-1,1); cpgbox("bcnst", 0.0, 0, "BCNST", 0.0, 0); cpgmtxt("b",3.,.5,.5,"x axis"); cpgmtxt("l",3,.5,.5,"y axis"); cpgsch(2.); cpgmtxt("t",1,.5,.5,"title"); cpgsci(7); cpgsci(4);//set colour and print pendulum 1 trajectory cpgline(stepno,xvalues1,yvalues1); cpgsci(2);//set a different colour and print pendulum 2 trajectory cpgline(stepno,xvalues2,yvalues2); cpgend(); int main(void) //the initial masses, lengths, angles and angular velocities double m1 = 1;//in kg double m2 = 1; double l1 = 0.5;//in m double l2 = 0.5; double theta1initial = -PI/6;//in radians double theta2initial = PI/6; double omega1initial = 0;//in radians per sec double omega2initial = 0; double timeinterval = 2;//in seconds int stepno = 10000; runpendula(m1,m2,l1,l2,theta1initial,theta2initial,omega1initial, omega2initial,timeinterval,stepno);

27 return 1;

The Nonlinear Pendulum

The Nonlinear Pendulum The Nonlinear Pendulum - Pádraig Ó Conbhuí - 08531749 TP Monday 1. Abstract This experiment was performed to examine the effects that linearizing equations has on the accuracy of results and to find ways

More information

Physics 200 Lecture 4. Integration. Lecture 4. Physics 200 Laboratory

Physics 200 Lecture 4. Integration. Lecture 4. Physics 200 Laboratory Physics 2 Lecture 4 Integration Lecture 4 Physics 2 Laboratory Monday, February 21st, 211 Integration is the flip-side of differentiation in fact, it is often possible to write a differential equation

More information

Euler s Method, cont d

Euler s Method, cont d Jim Lambers MAT 461/561 Spring Semester 009-10 Lecture 3 Notes These notes correspond to Sections 5. and 5.4 in the text. Euler s Method, cont d We conclude our discussion of Euler s method with an example

More information

Consistency and Convergence

Consistency and Convergence Jim Lambers MAT 77 Fall Semester 010-11 Lecture 0 Notes These notes correspond to Sections 1.3, 1.4 and 1.5 in the text. Consistency and Convergence We have learned that the numerical solution obtained

More information

Numerical integration for solving differential equations

Numerical integration for solving differential equations Numerical integration for solving differential equations After integration, it is natural to consider how to find numerical solutions to differential equations on the computer. Simple equations of motion

More information

Lecture 19: Calculus of Variations II - Lagrangian

Lecture 19: Calculus of Variations II - Lagrangian Lecture 19: Calculus of Variations II - Lagrangian 1. Key points Lagrangian Euler-Lagrange equation Canonical momentum Variable transformation Maple VariationalCalculus package EulerLagrange 2. Newton's

More information

Computational Physics (6810): Session 8

Computational Physics (6810): Session 8 Computational Physics (6810): Session 8 Dick Furnstahl Nuclear Theory Group OSU Physics Department February 24, 2014 Differential equation solving Session 7 Preview Session 8 Stuff Solving differential

More information

Numerical Methods for Initial Value Problems; Harmonic Oscillators

Numerical Methods for Initial Value Problems; Harmonic Oscillators Lab 1 Numerical Methods for Initial Value Problems; Harmonic Oscillators Lab Objective: Implement several basic numerical methods for initial value problems (IVPs), and use them to study harmonic oscillators.

More information

the EL equation for the x coordinate is easily seen to be (exercise)

the EL equation for the x coordinate is easily seen to be (exercise) Physics 6010, Fall 2016 Relevant Sections in Text: 1.3 1.6 Examples After all this formalism it is a good idea to spend some time developing a number of illustrative examples. These examples represent

More information

Numerical Methods for Initial Value Problems; Harmonic Oscillators

Numerical Methods for Initial Value Problems; Harmonic Oscillators 1 Numerical Methods for Initial Value Problems; Harmonic Oscillators Lab Objective: Implement several basic numerical methods for initial value problems (IVPs), and use them to study harmonic oscillators.

More information

Fourth Order RK-Method

Fourth Order RK-Method Fourth Order RK-Method The most commonly used method is Runge-Kutta fourth order method. The fourth order RK-method is y i+1 = y i + 1 6 (k 1 + 2k 2 + 2k 3 + k 4 ), Ordinary Differential Equations (ODE)

More information

Physics 584 Computational Methods

Physics 584 Computational Methods Physics 584 Computational Methods Introduction to Matlab and Numerical Solutions to Ordinary Differential Equations Ryan Ogliore April 18 th, 2016 Lecture Outline Introduction to Matlab Numerical Solutions

More information

Updated 2013 (Mathematica Version) M1.1. Lab M1: The Simple Pendulum

Updated 2013 (Mathematica Version) M1.1. Lab M1: The Simple Pendulum Updated 2013 (Mathematica Version) M1.1 Introduction. Lab M1: The Simple Pendulum The simple pendulum is a favorite introductory exercise because Galileo's experiments on pendulums in the early 1600s are

More information

Ph 22.1 Return of the ODEs: higher-order methods

Ph 22.1 Return of the ODEs: higher-order methods Ph 22.1 Return of the ODEs: higher-order methods -v20130111- Introduction This week we are going to build on the experience that you gathered in the Ph20, and program more advanced (and accurate!) solvers

More information

You may not use your books, notes; calculators are highly recommended.

You may not use your books, notes; calculators are highly recommended. Math 301 Winter 2013-14 Midterm 1 02/06/2014 Time Limit: 60 Minutes Name (Print): Instructor This exam contains 8 pages (including this cover page) and 6 problems. Check to see if any pages are missing.

More information

Numerical Differential Equations: IVP

Numerical Differential Equations: IVP Chapter 11 Numerical Differential Equations: IVP **** 4/16/13 EC (Incomplete) 11.1 Initial Value Problem for Ordinary Differential Equations We consider the problem of numerically solving a differential

More information

Chaotic motion. Phys 420/580 Lecture 10

Chaotic motion. Phys 420/580 Lecture 10 Chaotic motion Phys 420/580 Lecture 10 Finite-difference equations Finite difference equation approximates a differential equation as an iterative map (x n+1,v n+1 )=M[(x n,v n )] Evolution from time t

More information

Chapter 6 - Ordinary Differential Equations

Chapter 6 - Ordinary Differential Equations Chapter 6 - Ordinary Differential Equations 7.1 Solving Initial-Value Problems In this chapter, we will be interested in the solution of ordinary differential equations. Ordinary differential equations

More information

INTRODUCTION TO COMPUTER METHODS FOR O.D.E.

INTRODUCTION TO COMPUTER METHODS FOR O.D.E. INTRODUCTION TO COMPUTER METHODS FOR O.D.E. 0. Introduction. The goal of this handout is to introduce some of the ideas behind the basic computer algorithms to approximate solutions to differential equations.

More information

Review Higher Order methods Multistep methods Summary HIGHER ORDER METHODS. P.V. Johnson. School of Mathematics. Semester

Review Higher Order methods Multistep methods Summary HIGHER ORDER METHODS. P.V. Johnson. School of Mathematics. Semester HIGHER ORDER METHODS School of Mathematics Semester 1 2008 OUTLINE 1 REVIEW 2 HIGHER ORDER METHODS 3 MULTISTEP METHODS 4 SUMMARY OUTLINE 1 REVIEW 2 HIGHER ORDER METHODS 3 MULTISTEP METHODS 4 SUMMARY OUTLINE

More information

The Nonlinear Pendulum

The Nonlinear Pendulum The Nonlinear Pendulum Evan Sheridan 11367741 Feburary 18th 013 Abstract Both the non-linear linear pendulum are investigated compared using the pendulum.c program that utilizes the trapezoid method for

More information

Physics 6010, Fall Relevant Sections in Text: Introduction

Physics 6010, Fall Relevant Sections in Text: Introduction Physics 6010, Fall 2016 Introduction. Configuration space. Equations of Motion. Velocity Phase Space. Relevant Sections in Text: 1.1 1.4 Introduction This course principally deals with the variational

More information

Project 3: Pendulum. Physics 2300 Spring 2018 Lab partner

Project 3: Pendulum. Physics 2300 Spring 2018 Lab partner Physics 2300 Spring 2018 Name Lab partner Project 3: Pendulum In this project you will explore the behavior of a pendulum. There is no better example of a system that seems simple at first but turns out

More information

Second quantization: where quantization and particles come from?

Second quantization: where quantization and particles come from? 110 Phys460.nb 7 Second quantization: where quantization and particles come from? 7.1. Lagrangian mechanics and canonical quantization Q: How do we quantize a general system? 7.1.1.Lagrangian Lagrangian

More information

P321(b), Assignement 1

P321(b), Assignement 1 P31(b), Assignement 1 1 Exercise 3.1 (Fetter and Walecka) a) The problem is that of a point mass rotating along a circle of radius a, rotating with a constant angular velocity Ω. Generally, 3 coordinates

More information

Initial value problems for ordinary differential equations

Initial value problems for ordinary differential equations Initial value problems for ordinary differential equations Xiaojing Ye, Math & Stat, Georgia State University Spring 2019 Numerical Analysis II Xiaojing Ye, Math & Stat, Georgia State University 1 IVP

More information

2tdt 1 y = t2 + C y = which implies C = 1 and the solution is y = 1

2tdt 1 y = t2 + C y = which implies C = 1 and the solution is y = 1 Lectures - Week 11 General First Order ODEs & Numerical Methods for IVPs In general, nonlinear problems are much more difficult to solve than linear ones. Unfortunately many phenomena exhibit nonlinear

More information

Oscillatory Motion. Simple pendulum: linear Hooke s Law restoring force for small angular deviations. small angle approximation. Oscillatory solution

Oscillatory Motion. Simple pendulum: linear Hooke s Law restoring force for small angular deviations. small angle approximation. Oscillatory solution Oscillatory Motion Simple pendulum: linear Hooke s Law restoring force for small angular deviations d 2 θ dt 2 = g l θ small angle approximation θ l Oscillatory solution θ(t) =θ 0 sin(ωt + φ) F with characteristic

More information

Theoretical physics. Deterministic chaos in classical physics. Martin Scholtz

Theoretical physics. Deterministic chaos in classical physics. Martin Scholtz Theoretical physics Deterministic chaos in classical physics Martin Scholtz scholtzzz@gmail.com Fundamental physical theories and role of classical mechanics. Intuitive characteristics of chaos. Newton

More information

Oscillatory Motion. Simple pendulum: linear Hooke s Law restoring force for small angular deviations. Oscillatory solution

Oscillatory Motion. Simple pendulum: linear Hooke s Law restoring force for small angular deviations. Oscillatory solution Oscillatory Motion Simple pendulum: linear Hooke s Law restoring force for small angular deviations d 2 θ dt 2 = g l θ θ l Oscillatory solution θ(t) =θ 0 sin(ωt + φ) F with characteristic angular frequency

More information

PH 120 Project # 2: Pendulum and chaos

PH 120 Project # 2: Pendulum and chaos PH 120 Project # 2: Pendulum and chaos Due: Friday, January 16, 2004 In PH109, you studied a simple pendulum, which is an effectively massless rod of length l that is fixed at one end with a small mass

More information

Numerical Methods for Differential Equations

Numerical Methods for Differential Equations Numerical Methods for Differential Equations Chapter 2: Runge Kutta and Linear Multistep methods Gustaf Söderlind and Carmen Arévalo Numerical Analysis, Lund University Textbooks: A First Course in the

More information

Lecture V : Oscillatory motion and spectral analysis

Lecture V : Oscillatory motion and spectral analysis Lecture V : Oscillatory motion and spectral analysis I. IDEAL PENDULUM AND STABILITY ANALYSIS Let us remind ourselves of the equation of motion for the pendulum. Remembering that the external torque applied

More information

Do not turn over until you are told to do so by the Invigilator.

Do not turn over until you are told to do so by the Invigilator. UNIVERSITY OF EAST ANGLIA School of Mathematics Main Series UG Examination 216 17 INTRODUCTION TO NUMERICAL ANALYSIS MTHE612B Time allowed: 3 Hours Attempt QUESTIONS 1 and 2, and THREE other questions.

More information

Numerical Methods - Initial Value Problems for ODEs

Numerical Methods - Initial Value Problems for ODEs Numerical Methods - Initial Value Problems for ODEs Y. K. Goh Universiti Tunku Abdul Rahman 2013 Y. K. Goh (UTAR) Numerical Methods - Initial Value Problems for ODEs 2013 1 / 43 Outline 1 Initial Value

More information

Applied Math for Engineers

Applied Math for Engineers Applied Math for Engineers Ming Zhong Lecture 15 March 28, 2018 Ming Zhong (JHU) AMS Spring 2018 1 / 28 Recap Table of Contents 1 Recap 2 Numerical ODEs: Single Step Methods 3 Multistep Methods 4 Method

More information

Simulation of Simple Pendulum

Simulation of Simple Pendulum International Journal of Engineering Science Invention ISSN (Online): 2319 6734, ISSN (Print): 2319 6726 Volume 6 Issue 4 April 2017 PP. 33-38 Abdalftah Elbori 1, Ltfei Abdalsmd 2 1 (MODES Department Atilim

More information

Computational project: Modelling a simple quadrupole mass spectrometer

Computational project: Modelling a simple quadrupole mass spectrometer Computational project: Modelling a simple quadrupole mass spectrometer Martin Duy Tat a, Anders Hagen Jarmund a a Norges Teknisk-Naturvitenskapelige Universitet, Trondheim, Norway. Abstract In this project

More information

Ordinary Differential Equations

Ordinary Differential Equations CHAPTER 8 Ordinary Differential Equations 8.1. Introduction My section 8.1 will cover the material in sections 8.1 and 8.2 in the book. Read the book sections on your own. I don t like the order of things

More information

2 Canonical quantization

2 Canonical quantization Phys540.nb 7 Canonical quantization.1. Lagrangian mechanics and canonical quantization Q: How do we quantize a general system?.1.1.lagrangian Lagrangian mechanics is a reformulation of classical mechanics.

More information

Chapter 11 ORDINARY DIFFERENTIAL EQUATIONS

Chapter 11 ORDINARY DIFFERENTIAL EQUATIONS Chapter 11 ORDINARY DIFFERENTIAL EQUATIONS The general form of a first order differential equations is = f(x, y) with initial condition y(a) = y a We seek the solution y = y(x) for x > a This is shown

More information

Modeling and Experimentation: Compound Pendulum

Modeling and Experimentation: Compound Pendulum Modeling and Experimentation: Compound Pendulum Prof. R.G. Longoria Department of Mechanical Engineering The University of Texas at Austin Fall 2014 Overview This lab focuses on developing a mathematical

More information

Numerical Analysis Exam with Solutions

Numerical Analysis Exam with Solutions Numerical Analysis Exam with Solutions Richard T. Bumby Fall 000 June 13, 001 You are expected to have books, notes and calculators available, but computers of telephones are not to be used during the

More information

Constrained motion and generalized coordinates

Constrained motion and generalized coordinates Constrained motion and generalized coordinates based on FW-13 Often, the motion of particles is restricted by constraints, and we want to: work only with independent degrees of freedom (coordinates) k

More information

Introduction. Pre-Lab Questions: Physics 1CL PERIODIC MOTION - PART II Fall 2009

Introduction. Pre-Lab Questions: Physics 1CL PERIODIC MOTION - PART II Fall 2009 Introduction This is the second of two labs on simple harmonic motion (SHM). In the first lab you studied elastic forces and elastic energy, and you measured the net force on a pendulum bob held at an

More information

Nonlinear Oscillators: Free Response

Nonlinear Oscillators: Free Response 20 Nonlinear Oscillators: Free Response Tools Used in Lab 20 Pendulums To the Instructor: This lab is just an introduction to the nonlinear phase portraits, but the connection between phase portraits and

More information

Ordinary Differential Equations (ODEs)

Ordinary Differential Equations (ODEs) Ordinary Differential Equations (ODEs) 1 Computer Simulations Why is computation becoming so important in physics? One reason is that most of our analytical tools such as differential calculus are best

More information

Chaotic motion. Phys 750 Lecture 9

Chaotic motion. Phys 750 Lecture 9 Chaotic motion Phys 750 Lecture 9 Finite-difference equations Finite difference equation approximates a differential equation as an iterative map (x n+1,v n+1 )=M[(x n,v n )] Evolution from time t =0to

More information

[ ] is a vector of size p.

[ ] is a vector of size p. Lecture 11 Copyright by Hongyun Wang, UCSC Recap: General form of explicit Runger-Kutta methods for solving y = F( y, t) k i = hfy n + i1 j =1 c ij k j, t n + d i h, i = 1,, p + p j =1 b j k j A Runge-Kutta

More information

Numerical solution of ODEs

Numerical solution of ODEs Numerical solution of ODEs Arne Morten Kvarving Department of Mathematical Sciences Norwegian University of Science and Technology November 5 2007 Problem and solution strategy We want to find an approximation

More information

Notes on numerical solution of differential equations

Notes on numerical solution of differential equations Notes on numerical solution of differential equations Some definitions, for those who don t know: A differential equation is any equation that relates a thing to its derivatives. For instance, Newton s

More information

Introduction. Pre-Lab Questions: Physics 1CL PERIODIC MOTION - PART II Spring 2009

Introduction. Pre-Lab Questions: Physics 1CL PERIODIC MOTION - PART II Spring 2009 Introduction This is the second of two labs on simple harmonic motion (SHM). In the first lab you studied elastic forces and elastic energy, and you measured the net force on a pendulum bob held at an

More information

FORTRAN 77 Lesson 7. Reese Haywood Ayan Paul

FORTRAN 77 Lesson 7. Reese Haywood Ayan Paul FORTRAN 77 Lesson 7 Reese Haywood Ayan Paul 1 Numerical Integration A general all purpose Numerical Integration technique is the Trapezoidal Method. For most functions, this method is fast and accurate.

More information

8 Numerical Integration of Ordinary Differential

8 Numerical Integration of Ordinary Differential 8 Numerical Integration of Ordinary Differential Equations 8.1 Introduction Most ordinary differential equations of mathematical physics are secondorder equations. Examples include the equation of motion

More information

Math 128A Spring 2003 Week 12 Solutions

Math 128A Spring 2003 Week 12 Solutions Math 128A Spring 2003 Week 12 Solutions Burden & Faires 5.9: 1b, 2b, 3, 5, 6, 7 Burden & Faires 5.10: 4, 5, 8 Burden & Faires 5.11: 1c, 2, 5, 6, 8 Burden & Faires 5.9. Higher-Order Equations and Systems

More information

Introduction to standard and non-standard Numerical Methods

Introduction to standard and non-standard Numerical Methods Introduction to standard and non-standard Numerical Methods Dr. Mountaga LAM AMS : African Mathematic School 2018 May 23, 2018 One-step methods Runge-Kutta Methods Nonstandard Finite Difference Scheme

More information

28. Pendulum phase portrait Draw the phase portrait for the pendulum (supported by an inextensible rod)

28. Pendulum phase portrait Draw the phase portrait for the pendulum (supported by an inextensible rod) 28. Pendulum phase portrait Draw the phase portrait for the pendulum (supported by an inextensible rod) θ + ω 2 sin θ = 0. Indicate the stable equilibrium points as well as the unstable equilibrium points.

More information

Lab M1: The Simple Pendulum

Lab M1: The Simple Pendulum Spring 2003 M1.1 Introduction. Lab M1: The Simple Pendulum The simple pendulum is a favorite introductory exercise because Galileo's experiments on pendulums in the early 1600s are usually regarded as

More information

Ordinary Differential Equations

Ordinary Differential Equations Chapter 7 Ordinary Differential Equations Differential equations are an extremely important tool in various science and engineering disciplines. Laws of nature are most often expressed as different equations.

More information

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University Part 6 Chapter 20 Initial-Value Problems PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright The McGraw-Hill Companies, Inc. Permission required for reproduction

More information

MAS212 Assignment #2: The damped driven pendulum

MAS212 Assignment #2: The damped driven pendulum MAS Assignment #: The damped driven pendulum Sam Dolan (January 8 Introduction In this assignment we study the motion of a rigid pendulum of length l and mass m, shown in Fig., using both analytical and

More information

AN OVERVIEW. Numerical Methods for ODE Initial Value Problems. 1. One-step methods (Taylor series, Runge-Kutta)

AN OVERVIEW. Numerical Methods for ODE Initial Value Problems. 1. One-step methods (Taylor series, Runge-Kutta) AN OVERVIEW Numerical Methods for ODE Initial Value Problems 1. One-step methods (Taylor series, Runge-Kutta) 2. Multistep methods (Predictor-Corrector, Adams methods) Both of these types of methods are

More information

Parametric Resonance and Elastic Pendulums

Parametric Resonance and Elastic Pendulums Parametric Resonance and Elastic Pendulums Ravitej Uppu Abstract In this I try to extend the theoretical conception of Elastic Pendulum that can be explained by the Driven Pendulums that I presented during

More information

M2A2 Problem Sheet 3 - Hamiltonian Mechanics

M2A2 Problem Sheet 3 - Hamiltonian Mechanics MA Problem Sheet 3 - Hamiltonian Mechanics. The particle in a cone. A particle slides under gravity, inside a smooth circular cone with a vertical axis, z = k x + y. Write down its Lagrangian in a) Cartesian,

More information

Lecture 13: Forces in the Lagrangian Approach

Lecture 13: Forces in the Lagrangian Approach Lecture 3: Forces in the Lagrangian Approach In regular Cartesian coordinates, the Lagrangian for a single particle is: 3 L = T U = m x ( ) l U xi l= Given this, we can readily interpret the physical significance

More information

Chapter 6. Second order differential equations

Chapter 6. Second order differential equations Chapter 6. Second order differential equations A second order differential equation is of the form y = f(t, y, y ) where y = y(t). We shall often think of t as parametrizing time, y position. In this case

More information

Systems of Linear ODEs

Systems of Linear ODEs P a g e 1 Systems of Linear ODEs Systems of ordinary differential equations can be solved in much the same way as discrete dynamical systems if the differential equations are linear. We will focus here

More information

Ordinary Differential Equations

Ordinary Differential Equations Ordinary Differential Equations We call Ordinary Differential Equation (ODE) of nth order in the variable x, a relation of the kind: where L is an operator. If it is a linear operator, we call the equation

More information

ODE Runge-Kutta methods

ODE Runge-Kutta methods ODE Runge-Kutta methods The theory (very short excerpts from lectures) First-order initial value problem We want to approximate the solution Y(x) of a system of first-order ordinary differential equations

More information

PHYSICS 210 SOLUTION OF THE NONLINEAR PENDULUM EQUATION USING FDAS

PHYSICS 210 SOLUTION OF THE NONLINEAR PENDULUM EQUATION USING FDAS PHYSICS 210 SOLUTION OF THE NONLINEAR PENDULUM EQUATION USING FDAS 1. PHYSICAL & MATHEMATICAL FORMULATION O θ L r T m W 1 1.1 Derivation of the equation of motion O Consider idealized pendulum: Mass of

More information

Initial Value Problems

Initial Value Problems Chapter 2 Initial Value Problems 21 Introduction The first part of this introduction is based on [5, Chap 6] The rest of the notes mostly follow [1, Chap 12] The growth of some tumours can be modelled

More information

Example 2.1. Draw the points with polar coordinates: (i) (3, π) (ii) (2, π/4) (iii) (6, 2π/4) We illustrate all on the following graph:

Example 2.1. Draw the points with polar coordinates: (i) (3, π) (ii) (2, π/4) (iii) (6, 2π/4) We illustrate all on the following graph: Section 10.3: Polar Coordinates The polar coordinate system is another way to coordinatize the Cartesian plane. It is particularly useful when examining regions which are circular. 1. Cartesian Coordinates

More information

Analytical Mechanics - Extra Problems

Analytical Mechanics - Extra Problems Analytical Mechanics - Extra Problems Physics 105, F17 (R) are review problems. Review problems are those that have already been covered in prior courses, mostly Intro to Physics I and II. Some are math

More information

Chap. 20: Initial-Value Problems

Chap. 20: Initial-Value Problems Chap. 20: Initial-Value Problems Ordinary Differential Equations Goal: to solve differential equations of the form: dy dt f t, y The methods in this chapter are all one-step methods and have the general

More information

for changing independent variables. Most simply for a function f(x) the Legendre transformation f(x) B(s) takes the form B(s) = xs f(x) with s = df

for changing independent variables. Most simply for a function f(x) the Legendre transformation f(x) B(s) takes the form B(s) = xs f(x) with s = df Physics 106a, Caltech 1 November, 2018 Lecture 10: Hamiltonian Mechanics I The Hamiltonian In the Hamiltonian formulation of dynamics each second order ODE given by the Euler- Lagrange equation in terms

More information

Basic Theory of Differential Equations

Basic Theory of Differential Equations page 104 104 CHAPTER 1 First-Order Differential Equations 16. The following initial-value problem arises in the analysis of a cable suspended between two fixed points y = 1 a 1 + (y ) 2, y(0) = a, y (0)

More information

NUMERICAL SOLUTION OF ODE IVPs. Overview

NUMERICAL SOLUTION OF ODE IVPs. Overview NUMERICAL SOLUTION OF ODE IVPs 1 Quick review of direction fields Overview 2 A reminder about and 3 Important test: Is the ODE initial value problem? 4 Fundamental concepts: Euler s Method 5 Fundamental

More information

Computer Problems for Taylor Series and Series Convergence

Computer Problems for Taylor Series and Series Convergence Computer Problems for Taylor Series and Series Convergence The two problems below are a set; the first should be done without a computer and the second is a computer-based follow up. 1. The drawing below

More information

Ordinary differential equation II

Ordinary differential equation II Ordinary Differential Equations ISC-5315 1 Ordinary differential equation II 1 Some Basic Methods 1.1 Backward Euler method (implicit method) The algorithm looks like this: y n = y n 1 + hf n (1) In contrast

More information

Lab 10: Harmonic Motion and the Pendulum

Lab 10: Harmonic Motion and the Pendulum Lab 10 Harmonic Motion and the Pendulum 119 Name Date Partners Lab 10: Harmonic Motion and the Pendulum OVERVIEW A body is said to be in a position of stable equilibrium if, after displacement in any direction,

More information

Coordinate Curves for Trajectories

Coordinate Curves for Trajectories 43 The material on linearizations and Jacobian matrices developed in the last chapter certainly expanded our ability to deal with nonlinear systems of differential equations Unfortunately, those tools

More information

In the presence of viscous damping, a more generalized form of the Lagrange s equation of motion can be written as

In the presence of viscous damping, a more generalized form of the Lagrange s equation of motion can be written as 2 MODELING Once the control target is identified, which includes the state variable to be controlled (ex. speed, position, temperature, flow rate, etc), and once the system drives are identified (ex. force,

More information

Second Order ODEs. CSCC51H- Numerical Approx, Int and ODEs p.130/177

Second Order ODEs. CSCC51H- Numerical Approx, Int and ODEs p.130/177 Second Order ODEs Often physical or biological systems are best described by second or higher-order ODEs. That is, second or higher order derivatives appear in the mathematical model of the system. For

More information

Figure 12.1: A simple pendulum

Figure 12.1: A simple pendulum Chapter 12 A Simple Pendulum by Brian Patterson In this module you will use DIYModeling to build a simulation of a simple pendulum. The basic ideas can be extended to other types of pendulums, such as

More information

A Brief Introduction to Numerical Methods for Differential Equations

A Brief Introduction to Numerical Methods for Differential Equations A Brief Introduction to Numerical Methods for Differential Equations January 10, 2011 This tutorial introduces some basic numerical computation techniques that are useful for the simulation and analysis

More information

Assignments VIII and IX, PHYS 301 (Classical Mechanics) Spring 2014 Due 3/21/14 at start of class

Assignments VIII and IX, PHYS 301 (Classical Mechanics) Spring 2014 Due 3/21/14 at start of class Assignments VIII and IX, PHYS 301 (Classical Mechanics) Spring 2014 Due 3/21/14 at start of class Homeworks VIII and IX both center on Lagrangian mechanics and involve many of the same skills. Therefore,

More information

Ordinary Differential equations

Ordinary Differential equations Chapter 1 Ordinary Differential equations 1.1 Introduction to Ordinary Differential equation In mathematics, an ordinary differential equation (ODE) is an equation which contains functions of only one

More information

Classical Mechanics Comprehensive Exam Solution

Classical Mechanics Comprehensive Exam Solution Classical Mechanics Comprehensive Exam Solution January 31, 011, 1:00 pm 5:pm Solve the following six problems. In the following problems, e x, e y, and e z are unit vectors in the x, y, and z directions,

More information

Multistep Methods for IVPs. t 0 < t < T

Multistep Methods for IVPs. t 0 < t < T Multistep Methods for IVPs We are still considering the IVP dy dt = f(t,y) t 0 < t < T y(t 0 ) = y 0 So far we have looked at Euler s method, which was a first order method and Runge Kutta (RK) methods

More information

Mon Jan Improved acceleration models: linear and quadratic drag forces. Announcements: Warm-up Exercise:

Mon Jan Improved acceleration models: linear and quadratic drag forces. Announcements: Warm-up Exercise: Math 2250-004 Week 4 notes We will not necessarily finish the material from a given day's notes on that day. We may also add or subtract some material as the week progresses, but these notes represent

More information

Higher Order Taylor Methods

Higher Order Taylor Methods Higher Order Taylor Methods Marcelo Julio Alvisio & Lisa Marie Danz May 6, 2007 Introduction Differential equations are one of the building blocks in science or engineering. Scientists aim to obtain numerical

More information

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0 Math 2250 Lab 4 Name/Unid: 1. (25 points) A man bails out of an airplane at the altitute of 12,000 ft, falls freely for 20 s, then opens his parachute. Assuming linear air resistance ρv ft/s 2, taking

More information

Euler s Method, Taylor Series Method, Runge Kutta Methods, Multi-Step Methods and Stability.

Euler s Method, Taylor Series Method, Runge Kutta Methods, Multi-Step Methods and Stability. Euler s Method, Taylor Series Method, Runge Kutta Methods, Multi-Step Methods and Stability. REVIEW: We start with the differential equation dy(t) dt = f (t, y(t)) (1.1) y(0) = y 0 This equation can be

More information

AIMS Exercise Set # 1

AIMS Exercise Set # 1 AIMS Exercise Set #. Determine the form of the single precision floating point arithmetic used in the computers at AIMS. What is the largest number that can be accurately represented? What is the smallest

More information

CS520: numerical ODEs (Ch.2)

CS520: numerical ODEs (Ch.2) .. CS520: numerical ODEs (Ch.2) Uri Ascher Department of Computer Science University of British Columbia ascher@cs.ubc.ca people.cs.ubc.ca/ ascher/520.html Uri Ascher (UBC) CPSC 520: ODEs (Ch. 2) Fall

More information

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0 Math 2250 Lab 4 Name/Unid: 1. (35 points) Leslie Leroy Irvin bails out of an airplane at the altitude of 16,000 ft, falls freely for 20 s, then opens his parachute. Assuming linear air resistance ρv ft/s

More information

PreLab 2 - Simple Harmonic Motion: Pendulum (adapted from PASCO- PS-2826 Manual)

PreLab 2 - Simple Harmonic Motion: Pendulum (adapted from PASCO- PS-2826 Manual) Musical Acoustics Lab, C. Bertulani, 2012 PreLab 2 - Simple Harmonic Motion: Pendulum (adapted from PASCO- PS-2826 Manual) A body is said to be in a position of stable equilibrium if, after displacement

More information

(f(x) P 3 (x)) dx. (a) The Lagrange formula for the error is given by

(f(x) P 3 (x)) dx. (a) The Lagrange formula for the error is given by 1. QUESTION (a) Given a nth degree Taylor polynomial P n (x) of a function f(x), expanded about x = x 0, write down the Lagrange formula for the truncation error, carefully defining all its elements. How

More information

EXAMPLE OF ONE-STEP METHOD

EXAMPLE OF ONE-STEP METHOD EXAMPLE OF ONE-STEP METHOD Consider solving y = y cos x, y(0) = 1 Imagine writing a Taylor series for the solution Y (x), say initially about x = 0. Then Y (h) = Y (0) + hy (0) + h2 2 Y (0) + h3 6 Y (0)

More information

Introductory Numerical Analysis

Introductory Numerical Analysis Introductory Numerical Analysis Lecture Notes December 16, 017 Contents 1 Introduction to 1 11 Floating Point Numbers 1 1 Computational Errors 13 Algorithm 3 14 Calculus Review 3 Root Finding 5 1 Bisection

More information