EULER METHOD:Explanation,algorithm,flowchart

 EULER METHOD

Euler’s method is considered to be one of the oldest and simplest methods to find the numerical solution of ordinary differential equation or the initial value problems. Here, a short and simple algorithm and flowchart for Euler’s method has been presented, which can be used to write program for the method in any high level programming language.

Through Euler’s method, you can find a clear expression for y in terms of a finite number of elementary functions represented with x. The initial values of y and x are known, and for these an ordinary differential equation is considered.

Euler’s Method Algorithm:

  1. Start
  2. Define function
  3. Get the values of x0, y0, h and xn
    *Here x0 and y0 are the initial conditions
    h is the interval
    xn is the required value
  4. n = (xn – x0)/h + 1
  5. Start loop from i=1 to n
  6. y = y0 + h*f(x0,y0)
    x = x + h
  7. Print values of y0 and x0
  8. Check if x < xn
    If yes, assign x0 = x and y0 = y
    If no, goto 9.
  9. End loop i
  10. Stop
FLOWCHART OF EULER'S METHOD:


C PROGRAM FOR EULER'S METHOD:

#include<stdio.h>
float fun(float x,float y)
{
    float f;
    f=x+y;
    return f;
}
main()
{
    float a,b,x,y,h,t,k;
    printf("\nEnter x0,y0,h,xn: ");
    scanf("%f%f%f%f",&a,&b,&h,&t);
    x=a;
    y=b;
    printf("\n  x\t  y\n");
    while(x<=t)
    {
        k=h*fun(x,y);
        y=y+k;
        x=x+h;
        printf("%0.3f\t%0.3f\n",x,y);
    }
}

Comments

Popular posts from this blog

Newton Raphson Method:Explanation, algorithm and flowchart

GAUSS ELIMINATION METHOD:EXPLANATION,ALGORITHM AND FLOWCHART