 CoCalc Public FilesPM_2_5 / wave_equation / worksheets / volume_integral_test.sagews
Author: Balavarun P
var('x, y, xi')
import numpy as np
from scipy import special as sp
x_nodes = [-1, 1]

(x, y, xi)
def LGL_points(N):
'''
'''
xi                 = np.poly1d([1, 0])
legendre_N_minus_1 = N * (xi * sp.legendre(N - 1) - sp.legendre(N))
lgl_points         = legendre_N_minus_1.r
lgl_points.sort()

return lgl_points

def lagrange_polynomials(x):
'''
'''
X = np.array(x)
lagrange_basis_poly   = []
lagrange_basis_coeffs = np.zeros([X.shape, X.shape])

for j in np.arange(X.shape):
lagrange_basis_j = np.poly1d()

for m in np.arange(X.shape):
if m != j:
lagrange_basis_j *= np.poly1d([1, -X[m]]) \
/ (X[j] - X[m])
lagrange_basis_poly.append(lagrange_basis_j)

return lagrange_basis_poly

N_LGL = 16

N_LGL_lagrange_polynomials = lagrange_polynomials(LGL_points(N_LGL))

e = np.e

x_element = e ** (((-0.9 + 0.1 * xi) ** 2) / 0.4 ** 2)

var(x, xi, eta)

Error in lines 1-1 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 995, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> NameError: name 'xi' is not defined




def L_0():
'''
'''
for i in range(N_LGL):
for j in range(N_LGL):