-
-
Save Observatorio-de-Matematica/c0b1629c2c97ecd30bddddfea3fb3473 to your computer and use it in GitHub Desktop.
Resolução do Problema XOR utilizando função de base radial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/ | |
/* [ Created with wxMaxima version 11.08.0 ] */ | |
/* [wxMaxima: comment start ] | |
Essa primeira parte calcula os multiplicadores de lagrange | |
[wxMaxima: comment end ] */ | |
/* [wxMaxima: input start ] */ | |
rbf(x,i,y) := (%e^(-((x[i]-y).(x[i]-y))/2)) $ | |
array(d,3) $ | |
fillarray(d,[-1,1,1,-1]) $ | |
array(x,3) $ | |
l:create_list([x1, x2], x1, [1,-1], x2, [1,-1]) $ | |
fillarray(x,l) $ | |
array(a,3) $ | |
q:sum(a[i],i,0,3)-(1/2)*sum(sum(a[i]*a[j]*d[i]*d[j]*rbf(x,i,x[j]),j,0,3),i,0,3); | |
r:sum(d[i]*a[i],i,0,3); | |
s:solve(r,a[0]); | |
e:q,s; | |
e1:diff(e,a[1]), expand; | |
e2:diff(e,a[2]), expand; | |
e3:diff(e,a[3]), expand; | |
e1:e1 = 0; | |
e2:e2 = 0; | |
e3:e3 = 0; | |
p: [e1, e2, e3]; | |
res: linsolve(p, [a[1],a[2],a[3]]); | |
resCompleta: s, res; | |
/* [wxMaxima: input end ] */ | |
/* [wxMaxima: comment start ] | |
Aqui os resultados calculados são usados para formar o vetor aCalc | |
[wxMaxima: comment end ] */ | |
/* [wxMaxima: input start ] */ | |
array(aCalc, 3) $ | |
fillarray(aCalc, [(%e^4/(%e^4-2*%e^2+1)), (%e^4/(%e^4-2*%e^2+1)), (%e^4/(%e^4-2*%e^2+1)), (%e^4/(%e^4-2*%e^2+1))]) $ | |
predParcial(xt) := sum(aCalc[i]*d[i]*rbf(x,i,xt),i,0,3); | |
fPlot(x,y) := predParcial([x,y])$ | |
plot3d(fPlot, [x,-1.5, 1.5], [y,-1.5,1.5], [mesh_lines_color, false], | |
[elevation, 0], [azimuth, 0], [colorbox, true], [grid, 50, 50]) $ | |
/* [wxMaxima: input end ] */ | |
/* Maxima can't load/batch files which end with a comment! */ | |
"Created with wxMaxima"$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment