practical07_sol

# practical07_sol - Practical Session 7 — Solutions...

This preview shows pages 1–2. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Practical Session 7 — Solutions Exercises 1. (a) The ODE to be solved is dy/dx = 4 / (1 + x 2 ) , integrated from x = 0 to x = 1 with the initial condition y (0) = 0 . The numerical value of y (1) is then the estimate of the integral. (b) The modifications are to change the upper limit of integration to 1.0 and the RHS of the ODE in derivs() to dydx[0] = 4.0/(1.0 + xin*xin); . The result is in error by about 0.03%. 2. (a) This only requires replacing rk2() by euler() . The result is shown in Figure 1 — the amplitudes of the numerical solutions increase with x , rather than remaining constant.-2-1.5-1-0.5 0.5 1 1.5 2 2.5 2 4 6 8 10 12 14 y, z x "harmonic_e_100.txt" using 1:2 "harmonic_e_100.txt" using 1:3 sin(x) cos(x) Figure 1: Result for 2. (a). (b) The phase space diagram is shown in Figure 2. The solution spirals out rather than de- scribing a circle with unit radius. (c) The results are shown in Figure 3. For increased numbers of steps the solution is more accurate, but still exhibits a growing amplitude of oscillations with increasing x . For 1000 steps the result is becoming accurate, but the problem is still there. (d) Figure 4 shows the results. The amplitudes increase linearly on a log-linear plot, indicating that the amplitudes grow exponentially, which is characteristic of instability. (e) Euler’s method is unstable when applied to this problem. By comparison, Runge-Kutta is quite stable. 3. (1002) (a) The ODE is dy dx = 2 π h 1- sin 2 π 4 sin 2 x i- 1 / 2 , and this needs to be integrated from x = 0 to x = π 2 with the initial condition y (0) = 0 , in which case y ( π/ 2) is the estimate of the integral....
View Full Document

## This note was uploaded on 09/29/2009 for the course COSC 1002 taught by Professor Wheatland during the Three '09 term at University of Sydney.

### Page1 / 7

practical07_sol - Practical Session 7 — Solutions...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online