Click below to view this site using some new reading style

** Classic | Flipcard | Magazine | Mosaic | Sidebar | Snapshot | Timeslide **

Euler’s Method for Ordinary Differential Equation of First Order–Programming in Language C

6:50 PM Edit This 0 Comments »

#include<stdio.h>
#include<conio.h>
float f(float x,float y)
{
<YOUR FUNCTION HERE>
}
main(){
     float x0,y0,h,x,x1,y1;
     int n,i;
     printf("enter the values of x0 y0 h x\n");
     scanf("%f %f %f %f",&x0,&y0,&h,&x);
     printf("\n");
     x1=x0;
     y1=y0;
     n=(x-x0)/h;
     for(i=0;i<=n;i++){
              if(x1>x)return;
              y1+=h*f(x1,y1);
              x1+=h;
              printf("when x=%8.30f : y=%8.30f\n",x1,y1);
              }
     getch();
     }

By – Ramen Mukherjee

this program has some bug issues.anyone who can make this perfect please do that so and post here.lots of thanks in advance.

BUG

the PHANTOM bug is that whenever the value of x is given 0.2 ,0.3 ,1.3 the program either exits abnormally or increases or decreases the given x by 0.1 automatically.i have absolutely no clue why it happens.bug 2
the program is full proof and it gives accurate results UPTO 30 DECIMAL PLACES !!.i tested myself this program on all NORMAL problems given in the book.but surprisingly this program failed to run and exits whenever i tried to put the function & values given to me in my college laboratory by my teacher.
when the x is given 0.1 , 1.0 , 1.3 , 0.5 etc etc.and this problem varies between different given value and the functions.

KNOWN CAUSE

when i increased the decimal place upto 35 i saw that the value which we are thinking as 2.2 is not at all 2.2.see yourself…. bug 1
it is much more than that.maybe of a very very low amount but still powerful enough to make 2.3 to 2.4 or 2.5 to 2.4 which i already stated as the PHANTOM INCREMENT-DECREMENT.
but i still don't know why the program exits at some points like 1.2 or something.maybe the inbuilt buffer of my already ultra high laptop is overflown.or maybe a stronger programming ,more efficient language is needed.maybe i would try this program in JAVA someday.

WELL I THINK I M THE FIRST ONE TO DETECT IT AND FIND A KNOWN CAUSE FOR IT.IF U HAVE ANYTHING MORE TO SAY THEN PLEASE COMMENT.

0 comments: