Example #1
0
float gety(float x,float y){
	float y1,f1,f2;
	f1= x*x + x*y - 10 ;
	f2= y + 3*x*y*y - 57;
	y1=df2x(y)*f1-df1x(x,y)*f2;
	return(y1/detJ(x,y));
}
float gety(float x,float y) {
    float y1,f1,f2;
    f1=x*x+x*y;
    f2=y+3*x*y*y;
    y1=-df2x(x,y)*f1+df1x(x,y)*f2;
    return(y1/detJ(x,y));
}
int main(void){
	float x, y, error, max;
	float a, b, dx, dy, jac;
	printf("Enter initial approximation for x and y:\n");
	scanf("%f %f", &x, &y);
	do{
		printf("x: %f;\t dx: %f;\ny: %f;\t dy: %f\n\n", x, dx, y, dy);
		a = f1(x,y);
		b = f2(x,y);
		jac = jacobian(x,y);
		dx = (b*df1y(x,y) - a*df2y(x,y))/jac;
		dy = (a*df2x(x,y) - b*df1x(x,y))/jac;
		x = x + dx;
		y = y + dy;
		printf("x: %f;\t dx: %f;\ny: %f;\t dy: %f;\n\n", x, dx, y, dy);
		
		max = (fabs(dx) > fabs(dy))?fabs(dx):fabs(dy);
		
	}while(max > EPSILON);
	return 0;
}
Example #4
0
float detJ(float x,float y){
	float z;
	z=df1x(x,y)*df2y(y,x) - df2x(y)*df1y(x);;
	return(z);
}
float jacobian(float x, float y){
	return (df1x(x,y)*df2y(x,y) - df1y(x,y)*df2x(x,y));
}