fork download
  1. program report
  2. implicit none
  3. real(8) :: x, y, x1, y1, x2, y2, HX, e
  4. integer :: i
  5. read *, x, y
  6. e = 0.0000001
  7.  
  8. do i = 1, 100000
  9. HX = fx(x)*gy(x,y) - fy(y)*gx(x,y)
  10. x1 = x - (f1(x,y)*gy(x,y) - fy(y)*g1(x,y))/HX
  11. y1 = y - (-f1(x,y)*gx(x,y) + fx(x)*g1(x,y))/HX
  12.  
  13. x2 = x1 - x
  14. x2 = abs(x2)
  15. y2 = y1 -y
  16. y2 = abs(y2)
  17.  
  18. if (x2 < e) then
  19. if (y2 < e) exit
  20. end if
  21.  
  22. x = x1
  23. y = y1
  24. end do
  25.  
  26. write(*,*) x, y, x2, y2
  27.  
  28. contains
  29.  
  30. !関数定義
  31. function f1(x, y)
  32. real(8) :: f1
  33. real(8), intent(in) :: x, y
  34. f1 = x**2 + y**2 - 1
  35. end function f1
  36.  
  37. function g1(x,y)
  38. real(8) :: g1
  39. real(8), intent(in) :: x, y
  40. g1 = (X**2)*(2 + x) - (y**2)*(2 - x)
  41. end function g1
  42.  
  43. function fx(x)
  44. real(8) :: fx
  45. real(8), intent(in) :: x
  46. fx = 2*x
  47. end function
  48.  
  49. function fy(y)
  50. real(8) :: fy
  51. real(8), intent(in) :: y
  52. fy = 2*y
  53. end function
  54.  
  55. function gx(x,y)
  56. real(8) :: gx
  57. real(8), intent(in) :: x, y
  58. gx = 3*(x**3) + 4*x + y**2
  59. end function
  60.  
  61. function gy(x,y)
  62. real(8) :: gy
  63. real(8), intent(in) :: x, y
  64. gy = -4 *y +(2*x)*y
  65. end function
  66.  
  67. end program report
  68.  
Success #stdin #stdout 0s 5292KB
stdin
0.5,0.5
stdout
  0.59307029570618985       0.80515068425190628        3.7947544551109047E-008   2.7952198444758380E-008