// 3元
// -y^2 * z^2 - y^2 + 24*y*z - z^2 -13 = 0
// -x^2 * z^2 - x^2 + 24*x*z - z^2 -13 = 0
// -x^2 * y^2 - x^2 + 24*x*y - y^2 -13 = 0
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
double f1( double x, double y, double z)
{
return - y* y * z* z - y* y + 24 * y* z - z* z - 13 ;
}
double f2( double x, double y, double z)
{
return - x* x * z* z - x* x + 24 * x* z - z* z - 13 ;
}
double f3( double x, double y, double z)
{
return - x* x * y* y - x* x + 24 * x* y - y* y - 13 ;
}
double J11( double x, double y, double z) // df1(x,y,z)/dx
{
return 0 ;
}
double J12( double x, double y, double z) // df1(x,y,z)/dy
{
return - 2 * z* z* y - 2 * y + 24 * z;
}
double J13( double x, double y, double z) // df1(x,y,z)/dz
{
return - 2 * y* y* z + 24 * y - 2 * z;
}
double J21( double x, double y, double z) // df2(x,y,z)/dx
{
return - 2 * z* z* x - 2 * x + 24 * z;
}
double J22( double x, double y, double z) // df2(x,y,z)/dy
{
return 0 ;
}
double J23( double x, double y, double z) // df2(x,y,z)/dz
{
return - 2 * x* x* z + 24 * x - 2 * z;
}
double J31( double x, double y, double z) // df3(x,y,z)/dx
{
return - 2 * y* y* x - 2 * x + 24 * y;
}
double J32( double x, double y, double z) // df3(x,y,z)/dy
{
return - 2 * x* x* y + 24 * x - 2 * y;
}
double J33( double x, double y, double z) // df3(x,y,z)/dz
{
return 0 ;
}
void ucalc( double x, double y, double z, double * ux, double * uy, double * uz)
{
double det;
det = J11( x, y, z) * J22( x, y, z) * J33( x, y, z)
+ J21( x, y, z) * J32( x, y, z) * J13( x, y, z)
+ J31( x, y, z) * J12( x, y, z) * J23( x, y, z)
- J11( x, y, z) * J32( x, y, z) * J23( x, y, z)
- J31( x, y, z) * J22( x, y, z) * J13( x, y, z)
- J21( x, y, z) * J12( x, y, z) * J33( x, y, z) ;
* ux = 1 / det * (
( J22( x, y, z) * J33( x, y, z) - J23( x, y, z) * J32( x, y, z) ) * f1( x, y, z) +
( J13( x, y, z) * J32( x, y, z) - J12( x, y, z) * J33( x, y, z) ) * f2( x, y, z) +
( J12( x, y, z) * J23( x, y, z) - J13( x, y, z) * J22( x, y, z) ) * f3( x, y, z) ) ;
* uy = 1 / det * (
( J23( x, y, z) * J31( x, y, z) - J21( x, y, z) * J33( x, y, z) ) * f1( x, y, z) +
( J11( x, y, z) * J33( x, y, z) - J13( x, y, z) * J31( x, y, z) ) * f2( x, y, z) +
( J13( x, y, z) * J21( x, y, z) - J11( x, y, z) * J23( x, y, z) ) * f3( x, y, z) ) ;
* uz = 1 / det * (
( J21( x, y, z) * J32( x, y, z) - J22( x, y, z) * J31( x, y, z) ) * f1( x, y, z) +
( J12( x, y, z) * J31( x, y, z) - J11( x, y, z) * J32( x, y, z) ) * f2( x, y, z) +
( J11( x, y, z) * J22( x, y, z) - J12( x, y, z) * J21( x, y, z) ) * f3( x, y, z) ) ;
}
int main( )
{
double x, y, z, ux, uy, uz;
int i;
while ( 1 ) {
printf ( "x y z を入力(0 0 0で終了)\n " ) ; scanf ( "%lf%lf%lf" , & x
, & y
, & z
) ; if ( x == 0 && y == 0 && z == 0 ) break ;
for ( i = 0 ; i < 10 ; i++ ) {
ucalc( x, y, z, & ux, & uy, & uz) ;
x -= ux;
y -= uy;
z -= uz;
// printf("%d %.20f %.20f %.20f\n", i, x, y, z);
}
printf ( "x=%.20f y=%.20f z=%.20f\n " , x
, y
, z
) ; printf ( "f1=%.20f\n " , f1
( x
, y
, z
) ) ; printf ( "f2=%.20f\n " , f2
( x
, y
, z
) ) ; printf ( "f3=%.20f\n " , f3
( x
, y
, z
) ) ; }
return 0 ;
}
Ly8gM+WFgwovLyAtee+8vjIgKiB677y+MiAtIHnvvL4yICsgMjQqeSp6IC0geu+8vjIgLTEzID0gMAovLyAteO+8vjIgKiB677y+MiAtIHjvvL4yICsgMjQqeCp6IC0geu+8vjIgLTEzID0gMAovLyAteO+8vjIgKiB577y+MiAtIHjvvL4yICsgMjQqe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CXJldHVybiAtMip4KngqeiArIDI0KnggLSAyKno7Cn0KZG91YmxlIEozMShkb3VibGUgeCwgZG91YmxlIHksIGRvdWJsZSB6KQkvLyBkZjMoeCx5LHopL2R4CnsKCXJldHVybiAtMip5KnkqeCAtIDIqeCArIDI0Knk7Cn0KZG91YmxlIEozMihkb3VibGUgeCwgZG91YmxlIHksIGRvdWJsZSB6KQkvLyBkZjMoeCx5LHopL2R5CnsKCXJldHVybiAtMip4KngqeSArIDI0KnggLSAyKnk7Cn0KZG91YmxlIEozMyhkb3VibGUgeCwgZG91YmxlIHksIGRvdWJsZSB6KQkvLyBkZjMoeCx5LHopL2R6CnsKCXJldHVybiAwOwp9Cgp2b2lkIHVjYWxjKGRvdWJsZSB4LCBkb3VibGUgeSwgZG91YmxlIHosIGRvdWJsZSAqdXgsIGRvdWJsZSAqdXksIGRvdWJsZSAqdXopCnsKCWRvdWJsZQlkZXQ7CgoJZGV0CT0gSjExKHgseSx6KSAqIEoyMih4LHkseikgKiBKMzMoeCx5LHopCgkJKyBKMjEoeCx5LHopICogSjMyKHgseSx6KSAqIEoxMyh4LHkseikKCQkrIEozMSh4LHkseikgKiBKMTIoeCx5LHopICogSjIzKHgseSx6KQoJCS0gSjExKHgseSx6KSAqIEozMih4LHkseikgKiBKMjMoeCx5LHopCgkJLSBKMzEoeCx5LHopICogSjIyKHgseSx6KSAqIEoxMyh4LHkseikKCQktIEoyMSh4LHkseikgKiBKMTIoeCx5LHopICogSjMzKHgseSx6KTsKCSp1eCA9IDEvZGV0ICogKAoJCShKMjIoeCx5LHopKkozMyh4LHkseiktSjIzKHgseSx6KSpKMzIoeCx5LHopKSpmMSh4LHkseikgKwoJCShKMTMoeCx5LHopKkozMih4LHkseiktSjEyKHgseSx6KSpKMzMoeCx5LHopKSpmMih4LHkseikgKwoJCShKMTIoeCx5LHopKkoyMyh4LHkseiktSjEzKHgseSx6KSpKMjIoeCx5LHopKSpmMyh4LHkseikpOwoJKnV5ID0gMS9kZXQgKiA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