HW #1 HEUN'S METHOD

_________________Problem Introduction Theory Code Results Discussion_______________

 

 

PROBLEM :

Solve the following ODE using the Heun's method for

Back


INTRODUCTION

In this study Heun's method is used for the existing initial value problem to solve numerically. Heun's methodis a multi-step 
numerical method with additonal predictor an corrector steps to euler solution. Heun's solution gives much better predictions than euler solutions as it is shown by
nature of this problem also.For numerical calculations fortram program is used.

Back


THEORY

The basic of the heun's method is that to prevent the main source of error in Euler's method which is the innitial slope is assumed

to apply accross the entire interval. Heuns method assumes the slope as the average of slopes at the beginning and the end of the interval. Improved Heun's

method is a more correct method which has predictor and corrector steps. Operational steps are as fallows:

 

 

After the the application of euler method,which is just calculation of slope at first point and predicting the y value at second x value.

As we calculated second y we can calculate slope also.After that taking averages of two slopes and with that calculating second poins y again is the basis of

heun.After this last step (corrector) we can return to predictor step and make calculations again. This will gives a better prediction which is close to higher order

predictions.

Back


CODE

Back


RESULTS

  1. Datas are taken both for heun's and euler's method with stepsizes of 0.3, 0.2 , 0,1 , 0.01 ,and 0,001. While taking the stepsize greater than 0,5 the solution goes to plus or minus infinity.With corresponding stepsizes v goes to zero near t=3. Considering this all graps are limited in t axis between 0-3.Following graph is the comparison of all heun's method solutions with different stepsizes.Step sizes 0.2 , 0.3 are slightly different than other soltions , caused by high corrector step cycle.

  1. In this graph relative errors of heun's solutions with different stepsizes are represented.As a comparison tool heun's solution with the sepsize 0.01 (corrector-predictor step= 15) is used because it is obvious that it is the best solution that the heun's method can present. As the stepsize decreases , error decreases:

  1. On this graph the comparison of Heun's method solutions with different stepszes are represented. Again as the comparison tool Heun's method solution corrector=15 stepsize=0.01 is used.It can be seen that greater stepsizes are lack of presition.Even with step 0.2 if we use many corrector cycles solution goes to exact.Solution s=0.2 c=15 can barely be identified with the best solution we assumed.

  1. This graph represents the relative error distribution of increasing corrector cycles with respect to Heun's method solution corrector=15 stepsize=0.01 As the corrector cycles increases, error decreases.

  1. Comparison of euler solution with Heun's method solution. Versions of Heun are close to eachother.For euler only stepsize 0.01 is close but others represent greater error:

  1. Relative error distrubution between heun's and euler solutions with corresponding stepsizes.In Heun's method corrector=15 is used.We know that heun represents always better estimations so we can say this is the error of euler solution in fact.As the stepsize decreases relative error decreases.These oscillations on 0.01 comparison may be caused by rapid intersections and small differances between heun' solution and euler's solution.

Back


DISCUSSION

In the beginning of this study it is seen that stepsizes greater than 0.5 do not provide the required solution .As t increases v goes to minus or plus infinity.This is caused by the nture of ode function. When a stepsize is great it is difficult to capture required slope, especially for functions which present a rapid exponential change in slope.

In Heuns method increasing corrector-predictor steps do a considerable change in the solution while incresing it further for example more than 12 cycles do not make any change after all and start to oscillate around the exact solution. This is caused by aproaching the real value very much. So in this small interval sthe slope intends to approach to the point but not with that of a precision. Therefore a point after or before the exact point is shooted an this continiues like this.For better error distributions Heun's Method with stepsize 0.01 and C=15 is used because even decreasing the stepsize or increasing corrector-predictor steps do not any change in the solution whose diffrantiation can be sensed even after 7th-8th decimal after the point.

Error distribution have sharp changes: To compare great stepsize solutions with small stepsize solutions there is nothing to do to take corresponding datas of smaller stepsizes.Which is exactly caused by few data points greater stepsize solutions have.But this is not a problem when comparing equal or near stepsizes.

Eulers method cannot match with heuns method. In big stepsizes the differnce can be seen. But in stepsize 0.01 it can be seen that solution approaches to the real. But what if the slope field changed drastically after around the exact solution represented by the route pointed with the innitial condition? These slope fields can be obtained easilly. Then the solution will not present the real. If some super-precision eq.(200-300 decimals after the point) computers are used and if it is fast enough too than there is no need to have other methods than the euler method because by means of very very small stepsizes the exact solution may be obtained. Otherwise we have to use more precise methods like Heun or rk4 because of the computers which have decimal limitation and calculation limitation.

Back