practical06

# practical06 - COSC 1002/1902 Computational Science in C...

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: COSC 1002/1902 Computational Science in C Practical 6 This practical session involves numerically solving first-order ordinary differential equations in C using Euler’s method, and using the second order Runge-Kutta method, and emphasizes accuracy and stability. Science problems addressed include population growth including competition, and the dynamics of a rocket. Before you begin these exercises, you should review the material in lecture 6. After you do this you should be ready to begin the exercises. If necessary consult a tutor, who can provide assistance. The exercises are for students in both units except where indicated (‘1002’ means that the question is just for students in COSC 1002, and ‘1902’ means that the question is just for students in COSC 1902). Remember to have a tutor mark off checkpoints as you reach them. Exercises 1. Recall the non-dimensional version of the population growth model from lecture 5, dy dx = y, y (0) = 1 , (1) which has the solution y = e x . (a) In practical session 5 you wrote a code to solve this problem using Euler’s method, to estimate y (1) . [In case your code was in error, I have provided a correct working code ( ode_exp_euler.c ) on the ‘Codes’ page for the unit — please check that your code is equivalent to this code.] Modify your code so that the numerical integration of the ODE is performed using second order Runge-Kutta rather than Euler’s method (see § 6.3 of the lecture notes). Note that the rk2() function [to replace euler() ] is also available from the ‘Codes’ page accessible via WebCT or from the COSC server. Compile and run the resulting code to numerically integrate the ODE with NSTEP equal to 10 . What is your estimate for y (1) ? How accurate is it? How does this result (with 10 integration steps) compare with the results obtained using Euler’s method? In lecture 6 it was pointed out that this ODE can be classified as unstable. What do you conclude about the second order Runge-Kutta method?...
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

practical06 - COSC 1002/1902 Computational Science in C...

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

View Full Document
Ask a homework question - tutors are online