19 January 2020 11:30:35 AM
FEM1D_PMETHOD
C version
Solve the two-point boundary value problem
- d/dX (P dU/dX) + Q U = F
on the interval [-1,1], with
U(-1) = U(1) = 0.
The P method is used, which represents U as
a weighted sum of orthogonal polynomials.
Highest degree polynomial to use is 2
Number of points to be used for output = 10
Problem #2:
U=cos(0.5*pi*x),
P=1,
Q=0,
F=0.25*pi*pi*cos(0.5*pi*x)
Basis function orthogonality test:
i j b(i,j)/a(i)
0 0 1
0 1 2.08167e-17
0 2 -8.32667e-17
1 0 3.46945e-17
1 1 1
1 2 1.73472e-17
2 0 -3.90313e-16
2 1 4.87891e-17
2 2 1.28571
Representation of solution:
Basis function coefficients:
0 0.95493
1 -1.25361e-18
2 -0.283868
X Approximate Solution
-1 0
-0.8 0.29881
-0.6 0.582087
-0.4 0.811679
-0.2 0.960335
0 1.0117
0.2 0.960335
0.4 0.811679
0.6 0.582087
0.8 0.29881
1 0
Comparison of computed and exact solutions:
X U computed U exact Difference
-1 0 6.12323e-17 6.12323e-17
-0.8 0.29881 0.309017 0.0102071
-0.6 0.582087 0.587785 0.0056984
-0.4 0.811679 0.809017 -0.0026619
-0.2 0.960335 0.951057 -0.00927815
0 1.0117 1 -0.0117033
0.2 0.960335 0.951057 -0.00927815
0.4 0.811679 0.809017 -0.0026619
0.6 0.582087 0.587785 0.0056984
0.8 0.29881 0.309017 0.0102071
1 0 6.12323e-17 6.12323e-17
Big L2 error = 0.00779738
FEM1D_PMETHOD
Normal end of execution.
19 January 2020 11:30:35 AM