13. Write a program to demonstrate Euler's Modified Method.


        /*Program to execute Euler's Modified method*/
	#include <stdio.h>
	#include <conio.h>
	#include <math.h>
	float dif(float x, float y)
	{
	    return 3 * x + (y / 2);
	}
	void main()
	{
	    float x, h, x0, x1, y0, y1, aerr, yc, yc1;
	    printf("Enter the values of x, h, x0, x0, y0, aerr: ");
	    scanf("%f%f%f%f%f", &x, &h, &x0, &y0, &aerr);
	    x1 = x0;
	    y1 = y0;
	    while (x1 < x)
	    {
	        yc = y1;
	        y1 += h * dif(x1, y1);
	        yc1 = yc + h * (dif(x1, yc) + dif(x1 + h, y1)) / 2;
	        while (fabs(yc1 - y1) > aerr)
	        {
	            y1 = yc1;
	            yc1 = yc + h * (dif(x1, yc) + dif(x1 + h, y1)) / 2;
	        }
	        x1 += h;
		printf("\n Values of y = %f, when x = %f", yc1, x1);
	    }
	    getch();
	}
            
        

Output

            
            Enter the values of x, h, x0, y0, aerr: 0.3 0.1 0 1 0.0001
	
	Values of y = 1.066666, when x = 0.100000
	Values of y = 1.167510, when x = 0.200000
	Values of y = 1.304294, when x = 0.300000