Hello, everyone.
Please, could somebody help-me with the code below? It is resulting in infinity value.
PROGRAM MR
!============================================================
!DECLARACAO DAS VARIAVEIS
!============================================================
IMPLICIT NONE
REAL, EXTERNAL::F
INTEGER, PARAMETER :: N=6, NPC=4
INTEGER I, J
REAL :: X(0:N),Y(0:N),A(0:N-1),B(0:N-1)
OPEN(UNIT=20, FILE="FUNCA.txt", STATUS="UNKNOWN")
!============================================================
!DADOS DA FUNCAO INTERPOLADA
!============================================================
PRINT*, "DADOS DA FUNCAO"
DO I=0, N
X=X(I)+1
Y(I)=F(X)
WRITE(20,*)X(I),Y(I)
WRITE(*,*)I,X(I),Y(I)
END DO
!============================================================
!COEFICIENTES DAS FUNCOES INTERPOLADAS
!============================================================
PRINT*, "COEFICIENTE DAS FUNCOES"
DO I=0, N-1
A(I)=(Y(I+1)-Y(I))/(X(I+1)-X(I))
B(I)=(Y(I)*X(I+1)-(I)*Y(I+1))/(X(I+1)-X(I))
WRITE (*,*)I,A(I),B(I)
END DO
END PROGRAM MR
!============================================================
!FUNCAO
!============================================================
REAL FUNCTION F(X)
IMPLICIT NONE
REAL::x
F = SIN(X/2)
END
The results is:
Blockquote
DADOS DA FUNCAO
0 1.00000000 0.479425550
1 2.00000000 0.841470957
2 3.00000000 0.997494996
3 4.00000000 0.909297407
4 5.00000000 0.598472118
5 6.00000000 0.141120002
6 7.00000000 -0.350783229
COEFICIENTE DAS FUNCOES
0 Infinity Infinity
1 Infinity Infinity
2 -Infinity Infinity
3 -Infinity Infinity
4 -Infinity Infinity
5 -Infinity Infinity
Process returned 0 (0x0) execution time : 0.035 s
Press any key to continue.
Thank you!!