## Improved Euler’s Method

The Improved Euler’s method, also known as the Heun formula or the average slope method, gives a more accurate approximation than the Euler rule and gives an explicit formula for computing

Improved Euler formula or the average slope method is commonly referred to as the Heun method:

*y*_{n+1}. The basic idea is to correct some errors of the original Euler's method. The syntax of the Improved Euler’s method is similar to that of the trapezoid rule, but the*y*value of the function in terms of*y*_{n+1}consists of the sum of the*y*value and the product of*h*and the function in terms of*x*_{n}and*y*_{n}.Improved Euler formula or the average slope method is commonly referred to as the Heun method:

yn+1=y

_{}n
Since it is actually the simplest version of the predictor-corrector method, the recurrence can be written as

p

y_{}n+1_{}n+1=y

_{}n+hf

_{}(x

_{}n,y

_{}n),

y

=y_{}n+1_{}n+h/2[f(xn,yn)+f(x

_{}n+1,p

_{}n+1)],n=0,1,2,….

###

C program to find the value using Heun's method

#include<stdio.h> #include<math.h> #include<conio.h> #define f(x,y) 2*(x)+(y) int main(){ float x,xp,x0,y0,y,h,m1,m2; printf("\n Heuns Method\n"); printf("\nEnter initial values of x and y\n"); scanf("%f%f",&x0,&y0); printf("\nEnter x at which function to be evaluated\n"); scanf("%f",&xp); printf("\nEnter the step size \n"); scanf("%f",&h); y=y0; x=x0; for(x=x0;x<xp;x=x+h){ m1=f(x,y); printf("\nm1=%f",m1); m2=f(x+h,y+(h*m1)); printf("\nm2=%f",m2); y=y+h/2*(m1+m2); printf("\ny=%f",y); } printf("Function value at x=%f is %f\n",xp,y); getch(); return 0; }

##
Euler's Method

Euler's Method assumes our solution is written in the form of a Taylor’s Series.

That is, we'll have a function of the form:

*h*is reasonably small.

For

**Euler's Method**, we just take the first 2 terms only.
expression, so we can write Euler's Method as follows:

We start with some known value for

*y*, which we could call*y*0. It has this value when X0. (We make use of the initial value 0,Y0)).
The result of using this formula is the value for y, one

*h*step to the right of the current value. Let's call it 1So we have:1 is the next estimated solution value;

*Y*0 is the current value;

*h*is the interval between steps; and

(

*x*0,

*y*0) is the value of the derivative at the starting point,(

*x*0,

*y*0).

**Next value:**

To get the next value 2, we would use the value we just found for 1 as follows:

Y2 is the next estimated solution value;

*Y*1 is the current value;

is the interval between steps;

1=

*X*0+

*h*; and

(

*x*1,

*y*1) is the value of the derivative at the current (

*x*1,

*y*1) point.

We continue this process for as many steps as required.

### C Program for Euler's Method

#include<stdio.h> #include<math.h> #include<conio.h> #define f(x,y) 2*(x)+(y) //#define f(x,y) 3*(x)*(x)+1 int main(){ float x,xp,x0,y0,y,h,m1,m2,m3,m4; printf("\n Euler's method'\n"); printf("\nEnter initial values of x and y\n"); scanf("%f%f",&x0,&y0); printf("\nEnter x at which function to be evaluated\n"); scanf("%f",&xp); printf("\nEnter the step size \n"); scanf("%f",&h); y=y0; x=x0; for(x=x0;x<xp;x=x+h){ m1=f(x,y); printf("\nm1=%f",m1); y=y+h*(m1); printf("\ny=%f",y); } printf("Function value at x=%f is %f\n",xp,y); getch(); return 0; }

## 0 Comments

Subscribe Us and Thanks for visiting blog.