Você está na página 1de 8

> restart;

interface rtablesize = infinity :


with LinearAlgebra :
with plots, display :
#X
#Y

Vector
Vector

1, 0, 1, 1, 0, 1, 1, 0, 1 ;
1, 1, 1, 0, 0, 0, 1, 1, 1 ;

#X Vector
#Y Vector

1, 0.5, 0, 0.5, 1, 1, 0.5, 0, 0.5, 1, 1, 0.5, 0, 0.5, 1 ;


1, 1, 1, 0.5, 0.5, 0.5, 0, 0, 0, 0.5, 0.5, 0.5, 1, 1, 1 ;

#X

Vector

1, 1 ;

Vector

1, 0, 1 ;

Dimension X ;

# n ns

# tipo=1 unidimensional
# tipo=2 bidimensional
# m=2 unidimensional linear
# m=3 unidimensional quadrtico
# m=3 bidimensional linear
# m=6 bidimensional quadratico
m
3;
tipo
1;
pp

# tipo e dimenso da base polinomial

2; # expoente da funo de correlao

beta

1;

# parmetro de correlao

corr
#corr

"G"; # tipo de correlao - Gauss


"S"; # Spline

1
X :=

0
1

n := 3
m := 3
tipo := 1
pp := 2
:= 1

corr := "G"

(1)

> if m = 2 and tipo = 1 then


p
Vector m, 1, x ;
# unidimensional linear
elif m = 3 and tipo = 1 then
p
Vector m, 1, x, x2 ; # unidimensional quadrtico
elif m = 3 and tipo = 2 then
p
Vector m, 1, x, y ;
# bilinear
elif m = 6 and tipo = 2 then
p
Vector m, 1, x, y, x2, y2, x y ; # biquadrtico
fi:
P

Matrix n, m, 0 :

for i1 from 1 to n do
for i2 from 1 to m do
P i1, i2

subs x = X i1 , y = Y i1 , p i2 ;

end;
end;
print P ;

> R

1 1

0 0

1 1

(2)

Matrix n, n, 0 :

Rauxil

Matrix n, n, 0 :

maior

0:

for i from 1 to n do
for j from 1 to n do
if tipo = 2 then
r i, j
evalf sqrt X i
elif tipo = 1 then
evalf sqrt X i
r i, j
fi:
if r i, j
maior then
maior
r i, j :
# print maior :
fi:
d

maior :

X j
X j

2
2

Y i
:

Y j

end:
end:
for i from 1 to n do
for j from 1 to n do
if corr = "G" then
R i, j

beta r i, j
d

evalf exp

elif corr = "S" then


beta r i, j
auxiliar
evalf
d

pp

if auxiliar 0 and auxiliar 1 then


R i, j
1 6 auxiliar2 8 auxiliar3
elif auxiliar 1 then
R i, j
0:
fi:

3 auxiliar4;

fi:
end:
end:
print evalf R ;
1.00000000 0.77880078 0.36787944
0.77880078 1.00000000 0.77880078
0.36787944 0.77880078 1.00000000
> # constituio da matriz G
G

Matrix n

G 1 ..n, 1 ..n

m, n

m, 0 :

R:

for i from 1 to n do
for j from 1 to m do
G i, j n
G j n, i
end:
end:
print G ;

subs x = X i , y = Y i , p j
G i, j n :

(3)

1.00000000 0.77880078 0.36787944 1


0.77880078 1.00000000 0.77880078 1

0.36787944 0.77880078 1.00000000 1

1
1
1
> g

Vector m

n :

# =================
x0
0 : # ponto de teste
y0
0:
# =================
for i1 from 1 to n do
if tipo = 2
xy0r i1
elif tipo = 1
xy0r i1
fi:

then
evalf x0
then
evalf sqrt

X i1
x0

X i1

y0
2

Y i1

if corr = "G" then


g i1

evalf exp

beta xy0r i1
d

pp

elif corr = "S" then


beta xy0r i1
auxiliar
:
d
print auxiliar ;
if auxiliar 0 and auxiliar 1 then
1 6 auxiliar2 8 auxiliar3 3 auxiliar4;
g i1
elif auxiliar 1 then
0:
g i1
fi:
fi:
end:
# faltam restantes termos de b
x

1 1

'x':

0:
conta
for i1 from n 1 to m do
conta 1 :
conta

(4)

g i1
end;

evalf subs x = x0, y = y0 , p conta

if tipo = 1 then
if m = 2 then
g n 1
subs
g n 2
subs
elif m = 3 then
g n 1
subs
g n 2
subs
g n 3
subs
fi:

x = x0, p 1
x = x0, p 2

:
:

x = x0, p 1
x = x0, p 2
x = x0, p 3

:
:
:

elif tipo = 2 then


if
g
g
g

m = 3 then
n 1
subs x = x0, y = y0 , p 1
n 2
subs x = x0, y = y0 , p 2
n 3
subs x = x0, y = y0 , p 3

elif m = 6 then
g n 1
subs
g n 2
subs
g n 3
subs
g n 4
subs
g n 5
subs
g n 6
subs

x = x0, y = y0
x = x0, y = y0
x = x0, y = y0
x = x0, y = y0
x = x0, y = y0
x = x0, y = y0

,p
,p
,p
,p
,p
,p

1
2
3
4
5
6

:
:
:
:
:
:
:
:
:

fi:
fi:
print G, g ;
pesos0
LinearSolve G, g ;
# com estes pesos poder-se- depois obter o valor estimado num outro ponto
1.00000000 0.77880078 0.36787944 1

1 1

0.77880078 1.00000000 0.77880078 1

0.36787944 0.77880078 1.00000000 1

1
1
1

0.77880078
1.00000000
,

0.77880078

1.00000000 10-16
1.00000000
1.00000000 10-16
peso0 :=

(5)

5.57601566 10-17
1.00000000 10-16
5.26124474 10-17

> # Pretendendo-se construir uma matriz de funes de forma


Ident

IdentityMatrix n ;

repete
MatrixInverse Multiply Transpose P , P
A
Multiply repete, Transpose P ;
B
phi

Ident

Multiply Multiply P, repete , Transpose P ;

Multiply Transpose p , A

Multiply R 1, , B ;
1 0 0
Ident :=

0 1 0
0 0 1

0
1
2

A :=

1
2

1
2

1
2

0 0 0
B :=

0 0 0
0 0 0

:=

1
x
2

1 2
x 1
2

x2

1
x
2

1 2
x
2

1
x
2

1 2
x
2

(6)

> for i from 1 to n do


print phi i ;
end:

1
1
x
2
> if tipo = 1 then
plot phi, x = 1 ..1 ;

x2
1 2
x
2

(7)

elif tipo = 2 then


plot3d phi 1 , x = 1 ..1, y = 1 ..1, axes = boxed ;
fi;
1

0.8

0.6

0.4

0.2

0.5

0.5
x

> soma
0:
pontox
1; pontoy
1;
for i from 1 to n do
soma
soma subs x = pontox, y = pontoy , phi i ;
end:
print soma ;
pontox := 1
pontoy := 1
1
> dphi
map diff, phi, x ;
for i from 1 to n do
print dphi i ;
end:
dphi :=

1
2

2x

1
2

(8)

1
2

x
2x

1
2
>

(9)

Você também pode gostar