大家好,我用hybrd算法求解非线性方程组,出现问题,这个应该如何解决呢?
算法代码
hybrd.f
(14.54 KB, 下载次数: 25)
hybrd1.f
(3.83 KB, 下载次数: 24)
程序代码:
[Fortran] 纯文本查看 复制代码 subroutine function_equations(n,x,fvec,iflag)
implicit none
integer n,iflag
double precision x(n),fvec(n)
! ------------------------------------------------
fvec(1) = 3d0*x(1)-cos(x(2)*x(3))-0.5d0
fvec(2) = x(1)**2-81d0*(x(2)+0.1d0)**2+sin(x(3))+1.06d0
fvec(3) = dexp(-x(1)*x(2))+20d0*x(3)+(10d0*3.1415926d0-3d0)/3d0
return
end
program main_test
implicit none
external function_equations
integer,parameter :: n=3 ,lwa=(n*(3*n+13))/2
double precision x(n),fvec(n)
double precision,parameter :: tol = 1d-8
double precision wa(lwa)
integer info
wa(lwa) = 1d0
! hybrd1(fcn,n,x,fvec,tol,info,wa,lwa)
call hybrd1(function_equations,n,x,fvec,tol,info,wa,lwa)
end
|