#include<stdio.h>
#include<conio.h>
#include<math.h>
#define ESP 0.0001
// (x)*(x) + (x)*(y) = 6// (x)*(x) - (y)*(y) = 3#define X(x,y) (x)*(x) + (x)*(y) - 6
#define Y(x,y) (x)*(x) - (y)*(y) - 3
#define F1(x,y) 2*(x) + (y)
#define G1(x,y) 2*(x)
#define F2(x,y) (x)
#define G2(x,y) -(2*(y))
void main()
{
double x1,y1,y2,x2,x,y,f,g,f1,f2,g1,g2;
int i=1;
clrscr();
printf("\nEnter the value of x: ");
scanf("%lf",&x);
printf("\nEnter the value of y: ");
scanf("%lf",&y);
f=X(x,y);
g=Y(x,y);
printf("\n\nf = %lf",f);
printf("\n\ng = %lf",g);
getch();
f1=F1(x,y);
f2=F2(x,y);
g1=G1(x,y);
g2=G2(x,y);
printf("\n\nf1 = %lf",f1);
printf("\n\ng1 = %lf",g1);
printf("\n\nf2 = %lf",f2);
printf("\n\ng2 = %lf",g2);
getch();
x1= x-((f*g2-g*f2)/(f1*g2-f2*g1));
y1= y-((g*f1-f*g1)/(f1*g2-f2*g1));
printf("\n\nx = %lf",x1);
printf("\n\ny = %lf",y1);
getch();
printf("\n\n");
do
{
f=X(x1,y1);
g=Y(x1,y1);
printf("\n\nf = %lf",f);
printf("\n\ng = %lf",g);
f1=F1(x1,y1);
f2=F2(x1,y1);
g1=G1(x1,y1);
g2=G2(x1,y1);
printf("\n\nf1 = %lf",f1);
printf("\n\ng1 = %lf",g1);
printf("\n\nf2 = %lf",f2);
printf("\n\ng2 = %lf",g2);
x2= x1-((f*g2-g*f2)/(f1*g2-f2*g1));
y2= y1-((g*f1-f*g1)/(f1*g2-f2*g1));
printf("\n\n x = %lf ",x2);
printf("\n\n y = %lf ",y2);
printf("\n\n");
if(fabs(x1-x2)<ESP && fabs(y1-y2)<ESP)
{
printf("\n\nREAL ROOT1 = %.3lf",x1);
printf("\n\nREAL ROOT2 = %.3lf",y1);
i=0;
}
else
{
x1=x2;
y1=y2;
}
}while(i!=0);
getch();
}
/*
____________________________
OUT PUT
____________________________
Enter the value of x: 1
Enter the value of y: 1
f = -4.000000
g = -3.000000
f1 = 3.000000
g1 = 2.000000
f2 = 1.000000
g2 = -2.000000
x = 2.375000
y = 0.875000
f = 1.718750
g = 1.875000
f1 = 5.625000
g1 = 4.750000
f2 = 2.375000
g2 = -1.750000
x = 2.021820
y = 0.987796
f = 0.084899
g = 0.112014
f1 = 5.031435
g1 = 4.043639
f2 = 2.021820
g2 = -1.975592
x = 2.000059
y = 0.999956
f = 0.000209
g = 0.000326
f1 = 5.000075
g1 = 4.000119
f2 = 2.000059
g2 = -1.999912
x = 2.000000
y = 1.000000
REAL ROOT1 = 2.000
REAL ROOT2 = 1.000
/