سلام بافرترن برای اسپیلاین در فاصله (0و1) نوشتم جواب نمیده اگه می تونید کمک کنید. با تشکرF(x)=sin(mпx) m =108801133
program main
real, parameter :: a=0.0, b=1.00000 pi = 3.1415926
real, dimension(0:n):: t,z
real :: d,h
integer ::i,j,k,n
doubleprecision id,m,dx,xx,y(1000),x(1000)
interface
subroutine spline3_coef(n,t,y,z)
integer, intent(in)::n
real, dimension(0:n), intent(in):: t,y
real, dimension(0:n), intent(out):: z
end subroutine spline3_coef
function spline3_eval(n,t,y,z,x)
integer, intent(in)::n
real, dimension(0:n), intent(in)::t,y,z
real, intent(in):: x
end function spline3_eval
end interface
write(*,*)"please enter your id:"
read*,id
m=(id/(10**9))*2
write(*,*)"please enter maximum of point:"
read*,n
write(*,*)"please enter x requested:"
read*,xx
do j=2,n
dx=1.0000000000000000/(j-1)
do i=1,j
if (i==1) then
x(1)=0
else if (i==j) then
x(j)=1
else
x(i)=x(i-1)+dx
end if
y(i)=sin(m*pi*x(i))
!write(*,*)"x","(",i,")",x(i)
!write(*,*)"y","(",i,")",y(i)
end do
call spline3_coef(n,t,y,z)
do i = 0,4*n
x = a + real(i)*h*0.25
d = sin(x) - spline3_eval(n,t,y,z,x)
print* "(i5,f22.14,e15.3)", i,x,d
end do
pause
end program main
subroutine spline3_coef(n,t,y,z)
integer, intent(in)::n
real, dimension(0:n), intent(in):: t,y
real, dimension(0:n-1) :: h,b
real, dimension(n-1)::u,v
real, dimension(0:n), intent(out):: z
integer :: i
do i = 0,n-1
h(i) = t(i+1) - t(i)
b(i) = (y(i+1) -y(i))/h(i)
end do
u(1) = 2.0*(h(0) + h(1))
v(1) = 6.0*(b(1) - b(0))
do i = 2,n-1
u(i) = 2.0*(h(i) + h(i-1)) - h(i-1)**2/u(i-1)
v(i) = 6.0*(b(i) - b(i-1)) - h(i-1)*v(i-1)/u(i-1)
end do
z(n) = 0.0
do i = n-1,1,-1
z(i) = (v(i) - h(i)*z(i+1))/u(i)
end do
z(0) = 0.0
pause
end subroutine spline3_coef
function spline3_eval(n,t,y,z,x)
integer, intent(in):: n
real, dimension(0:n), intent(in):: t,y,z
real, intent(in):: x
real :: h, temp
integer :: i
do i = n-1,1,-1
if( x - t(i) >= 0.0) exit
end do
h = t(i+1) - t(i)
temp = 0.5*z(i) + (x - t(i))*(z(i+1) - z(i))/(6.0*h)
temp = (y(i+1) - y(i))/h - h*(z(i+1) + 2.0*z(i))/6.0 + (x- t(i))*temp
spline3_eval = y(i) + (x - t(i))*temp
pause
end function spline3_eval