In [1]:

from funciones_forma_lagrange import lagrangiana_1D, lagrangiana_2D, lagrangiana_3D
from funciones_forma_lagrange import recorrer_matriz_espiral, guardar_matriz_espiral
from funciones_forma_lagrange import recorrer_matriz_3d_espiral, guardar_matriz_3d_espiral
from funciones_forma_lagrange import hermitiana_1D
from sympy import Symbol, lambdify, latex
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
from mayavi import mlab

x = Symbol('x')
y = Symbol('y')
z = Symbol('z')




In [2]:

A1 = hermitiana_1D(x, 2)

for i in range(len(A1)):
print A1[i]

X1 = np.arange(-1, 1, 0.01)

for i in range(len(A1)):
Y1 = lambdify(x, A1[i])
plt.plot(X1, Y1(X1))
plt.title('Funcion de forma de ' + str(len(A1) / 2) + ' nodos')
plt.show()




0.125*x**3 + 0.125*x**2 - 0.625*x + 0.375
0.25*x**3 - 0.25*x**2 - 0.25*x + 0.25
-0.125*x**3 + 0.125*x**2 + 0.625*x + 0.375
0.25*x**3 + 0.25*x**2 - 0.25*x - 0.25



Las ecuaciones obtenidas son:

\begin{eqnarray} 0.125 x^{3} + 0.125 x^{2} - 0.625 x + 0.375 \\\ 0.25 x^{3} - 0.25 x^{2} - 0.25 x + 0.25 \\\ - 0.125 x^{3} + 0.125 x^{2} + 0.625 x + 0.375 \\\ 0.25 x^{3} + 0.25 x^{2} - 0.25 \end{eqnarray}


In [3]:

A2 = hermitiana_1D(x, 3)

for i in range(len(A2)):
print latex(A2[i])

X2 = np.arange(-1, 1, 0.01)

for i in range(len(A2)):
Y2 = lambdify(x, A2[i])
plt.plot(X2, Y2(X2))
plt.title('Funcion de forma de ' + str(len(A2) / 2) + ' nodos')
plt.show()




0.375 x^{5} - 0.125 x^{4} - 0.875 x^{3} + 0.625 x^{2}
0.25 x^{5} - 0.25 x^{4} - 0.25 x^{3} + 0.25 x^{2}
1.0 x^{4} - 2.0 x^{2} + 1.0
1.0 x^{5} - 2.0 x^{3} + 1.0 x
- 0.375 x^{5} - 0.125 x^{4} + 0.875 x^{3} + 0.625 x^{2}
0.25 x^{5} + 0.25 x^{4} - 0.25 x^{3} - 0.25 x^{2}



Las ecuaciones obtenidas son:

\begin{eqnarray} 0.375 x^{5} - 0.125 x^{4} - 0.875 x^{3} + 0.625 x^{2} \\\ 0.25 x^{5} - 0.25 x^{4} - 0.25 x^{3} + 0.25 x^{2} \\\ 1.0 x^{4} - 2.0 x^{2} + 1.0 \\\ 1.0 x^{5} - 2.0 x^{3} + 1.0 x \\\ - 0.375 x^{5} - 0.125 x^{4} + 0.875 x^{3} + 0.625 x^{2} \\\ 0.25 x^{5} + 0.25 x^{4} - 0.25 x^{3} - 0.25 x^{2} \end{eqnarray}