# Processo de ortogonalização de Gram-Schmdit com espaço de reprodução

K<-function(s,t){exp(-(s^2+t^2)/4)} # Espaço de reprodução 

x=seq(-1,1,by=0.25); y=x  # Nós da malha

MK=matrix(0,length(x),length(y))

for (i in 1:length(x)){
 for (j in 1:length(y)){
    MK[i,j]=K(x[i],y[j])
 }
}

# MK

RK=diag(1,length(x),length(y))
for (i in 2:length(x)){
 for (j in 1:(i-1)){
   RK[i,j]=-K(x[i],y[j])/K(x[j],y[j])
 }
}

# RK

nRK=RK

d=0*x
d[1]=K(x[1],x[1])
for (i in 2:length(x)){
p=K(x[i],y[i])
q=0
for (j in 1:(i-1)){
for (l in 1:(i-1)){q=q+RK[j,l]*K(x[j],y[l])}
p=p-2*RK[i,j]*K(x[i],y[j])+RK[i,j]*q
}
d[i]=sqrt(p)
}

# d

for (i in 1:length(x)){nRK[i,]=RK[i,]/d[i]}

Beta=t(nRK)#; Beta

Alpha=solve(Beta)#; Alpha

print('Teste 1')
#-------Teste de ortogonalização

# Temo que 
n=length(x)#; n
# as funções 
Psi<-function(s,i){# Equivale a função psi_i(s), para -1<=s<=1.
p=0
for (j in 1:i){p=p+Beta[j,i]*K(x[j],s)}
return(p)
}

Phi<-function(s,i){# Equivale a função psi_i(s), para -1<=s<=1.
p=0
for (j in 1:i){p=p+Alpha[j,i]*Psi(s,j)}
return(p)
}

# g<-function(s){K(x[n-1],s)}; f<-function(s){Phi(s,n-1)}; curve(g,-1,1);curve(f,-1,1)

# h<-function(s){Psi(s,n-1)}; curve(h,-1,1)

# Erro4<-function(s){f(s)-g(s)}; curve(Erro4,-1,1)

print('Teste 2')
# Teste em resolução de sistema lienar infinito 

M<-function(s,t){1/(s+t)} # matriz do sistema

precisao=1000000

b<-function(s){
p=0 
for (i in 1:precisao){p=p+1/((i-1+s)*i) }
return(p) 
}

bap=c(b(1),b(2),b(3),b(4)); bap

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: