fork download
  1. // 3元
  2. #include <stdio.h>
  3.  
  4. double f1(double x, double y, double z)
  5. {
  6. return -y*y * z*z - y*y + 24*y*z - z*z -13;
  7. }
  8. double f2(double x, double y, double z)
  9. {
  10. return -x*x * z*z - x*x + 24*x*z - z*z -13;
  11. }
  12. double f3(double x, double y, double z)
  13. {
  14. return -x*x * y*y - x*x + 24*x*y - y*y -13;
  15. }
  16. double J11(double x, double y, double z) // df1(x,y,z)/dx
  17. {
  18. return 0;
  19. }
  20. double J12(double x, double y, double z) // df1(x,y,z)/dz
  21. {
  22. return -2*z*z*y - 2*y + 24*z;
  23. }
  24. double J13(double x, double y, double z) // df1(x,y,z)/dz
  25. {
  26. return -2*y*y*z + 24*y - 2*z;
  27. }
  28. double J21(double x, double y, double z) // df2(x,y,z)/dx
  29. {
  30. return -2*z*z*x - 2*x + 24*z;
  31. }
  32. double J22(double x, double y, double z) // df2(x,y,z)/dy
  33. {
  34. return 0;
  35. }
  36. double J23(double x, double y, double z) // df2(x,y,z)/dz
  37. {
  38. return -2*x*x*z + 24*x - 2*z;
  39. }
  40. double J31(double x, double y, double z) // df3(x,y,z)/dx
  41. {
  42. return -2*x*y*y - 2*x + 24*y;
  43. }
  44. double J32(double x, double y, double z) // df3(x,y,z)/dy
  45. {
  46. return -2*x*x*y + 24*x - 2*y;
  47. }
  48. double J33(double x, double y, double z) // df3(x,y,z)/dz
  49. {
  50. return 0;
  51. }
  52.  
  53. void ucalc(double x, double y, double z, double *ux, double *uy, double *uz)
  54. {
  55. double det;
  56.  
  57. det = J11(x,y,z) * J22(x,y,z) * J33(x,y,z)
  58. + J21(x,y,z) * J32(x,y,z) * J13(x,y,z)
  59. + J31(x,y,z) * J12(x,y,z) * J13(x,y,z)
  60. - J11(x,y,z) * J32(x,y,z) * J23(x,y,z)
  61. - J31(x,y,z) * J22(x,y,z) * J13(x,y,z)
  62. - J21(x,y,z) * J12(x,y,z) * J33(x,y,z);
  63. *ux = 1/det * (
  64. (J22(x,y,z)*J33(x,y,z)-J23(x,y,z)*J32(x,y,z))*f1(x,y,z) +
  65. (J13(x,y,z)*J32(x,y,z)-J12(x,y,z)*J33(x,y,z))*f2(x,y,z) +
  66. (J12(x,y,z)*J23(x,y,z)-J13(x,y,z)*J22(x,y,z))*f3(x,y,z));
  67. *uy = 1/det * (
  68. (J23(x,y,z)*J31(x,y,z)-J21(x,y,z)*J33(x,y,z))*f1(x,y,z) +
  69. (J11(x,y,z)*J33(x,y,z)-J13(x,y,z)*J31(x,y,z))*f2(x,y,z) +
  70. (J13(x,y,z)*J21(x,y,z)-J11(x,y,z)*J23(x,y,z))*f3(x,y,z));
  71. *uz = 1/det * (
  72. (J21(x,y,z)*J32(x,y,z)-J22(x,y,z)*J31(x,y,z))*f1(x,y,z) +
  73. (J12(x,y,z)*J31(x,y,z)-J11(x,y,z)*J32(x,y,z))*f2(x,y,z) +
  74. (J11(x,y,z)*J22(x,y,z)-J12(x,y,z)*J21(x,y,z))*f3(x,y,z));
  75. }
  76.  
  77. int main()
  78. {
  79. double x, y, z, ux, uy, uz;
  80. int i;
  81.  
  82. x = 1;
  83. y = 1;
  84. z = 1;
  85. for (i = 0; i < 10; i++) {
  86. ucalc(x, y, z, &ux, &uy, &uz);
  87. x -= ux;
  88. y -= uy;
  89. z -= uz;
  90. printf("%d %.20f %.20f %.20f\n", i, x, y, z);
  91. }
  92. return 0;
  93. }
  94.  
Success #stdin #stdout 0.02s 1720KB
stdin
Standard input is empty
stdout
0 0.80000000000000004441 0.80000000000000004441 0.80000000000000004441
1 0.77977799227799216020 0.77977799227799227122 0.77977799227799227122
2 0.77954807501704381778 0.77954807501704381778 0.77954807501704381778
3 0.77954804507915809175 0.77954804507915809175 0.77954804507915809175
4 0.77954804507915764766 0.77954804507915753664 0.77954804507915753664
5 0.77954804507915742562 0.77954804507915753664 0.77954804507915753664
6 0.77954804507915753664 0.77954804507915753664 0.77954804507915753664
7 0.77954804507915753664 0.77954804507915753664 0.77954804507915753664
8 0.77954804507915753664 0.77954804507915753664 0.77954804507915753664
9 0.77954804507915753664 0.77954804507915753664 0.77954804507915753664