Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
problem_3
program newtoniterative implicit none real::mat(2,3),x = 2.0,y = 2.0,m,n,tol = 0.001 integer::i call jacobianMatrixAtPoint(mat,x,y) Write(*,*)'Jacobian matrix' call printMatrix(mat) Write(*,*)'' call guasselimination(mat,m,n) do i = 1,100 call jacobianMatrixAtPoint(mat,x,y) call guasselimination(mat,m,n) x= x+m y = y+n write(*,*) x,y if (abs(m)<tol .or. abs(n)<tol)then exit end if end do end program Subroutine printMatrix(mat) Implicit none Real,intent (in)::mat(2,3) integer::i,j write(*,*) "" do i=1,2 write(*,*) mat(i,1),mat(i,2),mat(i,3) end do End Subroutine Subroutine jacobianMatrixAtPoint(mat,x0,y0) Implicit none Real,intent (in)::x0,y0 real::mat(2,3), dxf1, dyf1, f1, dxf2, dyf2, f2 integer::i mat(1,1) = dxf1(x0,y0) mat(1,2) = dyf1(x0,y0) mat(1,3) = -f1(x0,y0) mat(2,1) = dxf2(x0,y0) mat(2,2) = dyf2(x0,y0) mat(2,3) = -f2(x0,y0) End Subroutine function f1(x,y) implicit none real::f1,x,y f1 = log(abs(x - y**2.0)) - sin(x*y) - sin(3.141592) end function function dxf1(x,y) implicit none real::dxf1,x,y dxf1 = (1/(x - y**2.0)) - y * cos(x*y) end function function dyf1(x,y) implicit none real::dyf1,x,y dyf1 = -x * cos(x*y) - ((2.0 * y) / (x - y**2.0)) end function function f2(x,y) implicit none real::f2,x,y f2 = exp(x*y) + cos(x - y) - 2.0 end function function dxf2(x,y) implicit none real::dxf2,x,y dxf2 = y * exp(x * y) - sin(x-y) end function function dyf2(x,y) implicit none real::dyf2,x,y dyf2 = x * exp (x * y) - sin(x-y) end function subroutine guasselimination(matx,x1,y1) IMPLICIT NONE REAL,intent(in)::matx(2,3) real,intent(out)::x1,y1 real::temp,mat(2,3) INTEGER::i,j,k mat = matx do i =1,2 temp = mat(i,i) do j = 1,3 mat(i,j) = mat(i,j)/temp end do do k=1,2 if (i ==k)then cycle end if temp = mat(k,i) do j=1,3 mat(k,j) = mat(k,j) - mat(i,j)*temp end do end do end do x1 = mat(1,3) y1 = mat(2,3) end subroutine
run
|
edit
|
history
|
help
0
Practice
gghhhhh
euler-cromer
exercise
Rvc new
Y
my_second_code
A_02 questions 3
underoverflow
A_02 Newton's practice