Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Lab22
- use methods
- implicit none
- integer :: i, j, k, n, m, count
- real(8) :: a, b, eps
- real(8), allocatable :: grid(:,:), mapp(:,:), w(:), res(:)
- n = 1000
- m = 3
- k = 1
- count = 1000
- allocate(grid(n,4),mapp(count,3),w(n), res(m))
- !grid 1 - сетка 2 - значения функции 3 - значения с выбросами 4 - МНК значения
- !mapp 1 - аргумент 2 - значения функции
- a = -0.6d0
- b = 0.6d0
- w = 1d0
- call gengrid(grid,n,a,b)
- call MNK(grid,w,n,m,res)
- do i = 1,n
- grid(i,4) = pf(res,grid(i,1),m)
- end do
- !write(*,"(4f14.8)") (grid(i,:), i = 1,n)
- !Построение полинома и вычисление фактической ошибки
- do i = 1,count
- mapp(i,1) = a + (b-a)*real(i-1,8)/real(count,8)
- mapp(i,2) = pf(res,mapp(i,1),m)
- mapp(i,3) = dabs(mapp(i,2) - f(mapp(i,1)))
- end do
- open(1, file = "Result.csv")
- !open(2, file= "Err.csv")
- write(1,*) "x", ";", "y", ";", "py", ";", "error"
- do i = 1, count
- write(1, "(f16.12, a, f16.12, a, f16.12, a, f16.12)") mapp(i,1),";", f(mapp(i,1)),";",mapp(i,2), ";", mapp(i,3)
- end do
- !write(2,*) "n", ";", "maxerr"
- !do i = 3,k
- !allocate(grid(i,4),mapp(count,3),w(i), res(m))
- !call gengrid(grid,i,a,b)
- !call MNK(grid,w,i,m,res)
- !do j = 1,count
- !mapp(j,1) = a + (b-a)*real(j-1,8)/real(count,8)
- !mapp(j,2) = pf(res,mapp(j,1),m)
- !mapp(j,3) = dlog10(dabs(mapp(j,2) - f(mapp(j,1))))
- !end do
- !write(2,"(f16.12, a, f16.12)") real(i,8), ";", maxval(mapp(:,3))
- !deallocate(grid, mapp, w, res)
- !end do
- close(1)
- deallocate(grid, mapp, w, res)
- !close(2)
- pause
- end program Lab22
Add Comment
Please, Sign In to add comment