To run the code, type 'start_2D' or 'start_3D' in the MATLAB window.
Mass and stiffness matrices are assembled for nested uniform meshes (triangles in 2D and tetrahedral in 3D) starting from a coarse mesh (level=1 mesh) with few elements and ending up with a finest mesh (level=levels, where levels is predefined) with up to a milion of elements, depending on the memory available.
The Friedrichs', the Poincare and the Maxwell constants are computed from corresponding generalized eigenvalue problems. Their computed values are compared with exact values if these are known (eg. for the unit square domain in 2D and the unit cube domain in 3D) and eigenfunctions are visualized. Domains geometry can be easily changed by modifying input matrices nodes2coords, elems2nodes, dirichlet.
This code generalizes the original computations of the Friedrichs constant explained in the section 3.1. of . The original code to  is saved in the 'original_code' folder and can be run as the file 'start_Friedrichs' in the MATLAB window. This code exploits vectorization concepts of FEM assemblies exaplained in  and  and runs therefore much faster. There will be a separate report explaining analysis and numeric behind a code (in preparation).
 Jan Valdman, Minimization of Functional Majorant in A Posteriori Error Analysis based on H(div) Multigrid-Preconditioned CG Method, Advances in Numerical Analysis, vol. 2009, Article ID 164519 (2009)
 Talal Rahman, Jan Valdman, Fast MATLAB assembly of FEM matrices in 2D and 3D: nodal elements. Applied Mathematics and Computation 219, 7151–7158 (2013)
 Immanuel Anjam, Jan Valdman, Fast MATLAB assembly of FEM matrices in 2D and 3D: Edge elements. Applied Mathematics and Computation 267, 252–263 (2015)
The paper can be downloaded from the author's web