# FEM1D_BVP_QUADRATIC Finite Element Method, 1D, Boundary Value Problem, Piecewise Quadratic Elements

FEM1D_BVP_QUADRATIC is a Python program which applies the finite element method, with piecewise quadratic elements, to a two point boundary value problem in one spatial dimension.

The BVP to be solved is:

```        -u'' = x * ( x + 3 ) * exp ( x )  over the interval 0 < x < 1
u(0) = 0.0
u(1) = 0.0
```

The exact solution is:

```        u(x) = x * ( 1 - x ) * exp ( x )
```

To compute a finite element approximation, a set of n equally spaced nodes is defined from 0.0 to 1.0, a set of piecewise quadratic basis functions is set up, with one basis function associated with each node, and then an integral form of the BVP is used, in which the differential equation is multiplied by each basis function, and integration by parts is used to simplify the integrand.

A simple three point Gauss quadrature formula is used to estimate the resulting integrals over each interval.

### Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

### Languages:

FEM1D_BVP_QUADRATIC is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version..

### Related Data and Programs:

FEM1D_BVP_LINEAR, a Python program which applies the finite element method (FEM), with piecewise linear elements, to a two point boundary value problem (BVP) in one spatial dimension, and compares the computed and exact solutions with the L2 and seminorm errors.

FEM1D, a Python program which applies the finite element method (FEM) to a 1D linear two point boundary value problem (BVP) using piecewise linear basis functions.

FEM1D_CLASSES, a Python library which defines classes useful for solving a boundary value problem (BVP) of the form u''+2u'+u=f in 1 spatial dimension, using the finite element method (FEM), by Mike Sussman.

### Reference:

1. Gilbert Strang, George Fix,
An Analysis of the Finite Element Method,
Cambridge, 1973,
ISBN: 096140888X,
LC: TA335.S77.

### Source Code:

• fem1d_bvp_quadratic.py, the source code.
• h1s_error_quadratic.py, estimates the seminorm of the error, given the piecewise quadratic solution of the finite element problem, and a function that evaluates the derivative of the exact solution.
• l1_error.py, estimates the little l1 norm of the error, given the solution of the finite element problem, and a function that evaluates the exact solution.
• l2_error_quadratic.py, estimates the L2 norm of the error, given the piecewise quadratic solution of the finite element problem, and a function that evaluates the exact solution.
• max_error_quadratic.py, estimates the max norm of the error, given the piecewise quadratic solution of the finite element problem, and a function that evaluates the exact solution.
• timestamp.py, prints the YMDHMS date as a timestamp.

### Examples and Tests:

You can go up one level to the Python source codes.

Last revised on 12 July 2015.