# -*- coding: utf-8 -*- """ Created on Tue Apr 27 16:15:13 2021 @author: neil """ #xi are the nodal locations, the A matrix contains the integrals of the 'phi' # functions (the lengths of the elements), while C is the forcing vector # the integral of f(x), the first line in A and C needs to set a0 to f(xi[0]) b = np.diff(xi)/2 # produce a list of element lengths/2 for i in range(1,len(xi)): # do each element in sequence # integral of 'f(x)' from x1 to x2, (integral done in class) x1 = xi[i-1] x2 = xi[i] If = -np.cos(x2)+np.cos(x1)+0.05*(x2*x2-x1*x1)+2*(x2-x1) A[i,i] = b[i-1] # the A matrix is integrals of phi A[i,i-1] = b[i-1] C[i] = If # the C matrix is integrals of f(x)