如何在Fortran中验证非线性系统的迭代公式是否收敛到(x,y)附近的根
对于支持符号计算的编程语言来说,这是很容易的。但是在Fortran怎么做呢?就像得到分量函数的偏导数,并检查它们是否在根附近有界。但我不能在fortran这样做,也不知道怎么做。如果有人现在给我一些关于以下非线性系统的想法,或者如果可能的话,对于一般情况,这将对我有很大的帮助。
我想在这种情况下使用不动点迭代法
主要系统:
x^2+y=7
x-y^2=4迭代形式(给定):
X(n+1)=\sqrt(7-Y(n)),
Y(n+1)=-\sqrt(X(n)-4),
(x0,y0)=(4.4,1.0)定理(我遵循的)

问题是,我需要检查\sqrt(7-Y)和-\sqrt(X-4)的偏导数在(x0,y0)=(4.4,1.0)附近某个区域的有界性。我可以用fortran编写偏导数函数,但是如何计算这么多的值并检查它是否在(4.4,1.0)上有界。
更新
一个可能正确的解决方案是,在(4.4,1.0) (如(4.4-h,1.0-h)*(4.4+h,1.0+h) )周围得到一系列值,并求出定义的偏导数函数并逼近它们的有界性。我在Fortran没有遇到过这样的问题,所以任何关于这个问题的建议都能帮到我很多。
发布于 2021-10-16 12:14:06
如果您只想检查一个函数在网格上的有界性,您可以这样做
program verify_convergence
implicit none
integer, parameter :: dp = selected_real_kind(15, 307)
real(dp) :: centre_point(2)
real(dp) :: step_size(2)
integer :: no_steps(2)
real(dp) :: point(2)
real(dp) :: derivative(2)
real(dp) :: threshold
integer :: i,j
real(dp) :: x,y
! Set fixed parameters
centre_point = [4.4_dp, 1.0_dp]
step_size = [0.1_dp, 0.1_dp]
no_steps = [10, 10]
threshold = 0.1_dp
! Loop over a 2-D grid of points around the centre point
do i=-no_steps(1),no_steps(1)
do j=-no_steps(2),no_steps(2)
! Generate the point, calculate the derivative at that point,
! and stop with a message if the derivative is not bounded.
point = centre_point + [i*step_size(1), j*step_size(2)]
derivative = calculate_derivative(point)
if (any(abs(derivative)>threshold)) then
write(*,*) 'Derivative not bounded'
stop
endif
enddo
enddo
write(*,*) 'Derivative bounded'
contains
! Takes a co-ordinate, and returns the derivative.
! Replace this with whatever function you actually need.
function calculate_derivative(point) result(output)
real(dp), intent(in) :: point(2)
real(dp) :: output(2)
output = [sqrt(7-point(2)), -sqrt(point(1)-4)]
end function
end program我知道函数calculate_derivative并没有做你想要的,但是我不知道你想从你的问题中得到什么功能。只需根据需要替换此功能即可。
发布于 2021-10-15 17:09:26
主要的问题是不同的:没有任何软件的帮助,你怎么能计算出数学问题的解决方案?如果你知道的话,我们可以用fortran或任何语言编程。
特别是假设n=0,1,2,3..。要解决您的问题,您需要知道X(0)和Y(0)。这样你就可以计算出
X(1)=\sqrt(7-Y(0)),Y(1)=-\sqrt(X(0)-4)
现在你知道了X(1)和Y(1),然后你就可以计算了
X(2)=\sqrt(7-Y(1)),Y(2)=-\sqrt(X(1)-4)
等。
如果您的方程组收敛到某一项,直到一些迭代(例如,n=10,20,100),您将进行检查。但是因为fortran的本质,它不会给你一个象征性的解决方案,它不是它的目标。
https://stackoverflow.com/questions/69584191
复制相似问题