# Variational form of mixed finite element

**URL:** <https://community.freefem.org/t/variational-form-of-mixed-finite-element/1860>\
**Category:** General Discussion\
**Created:** [June 30, 2022, 8:37am UTC](https://community.freefem.org/t/variational-form-of-mixed-finite-element/1860 "2022-06-30T08:37:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qianrui](https://avatars.discourse-cdn.com/v4/letter/q/9fc348/32.png) [@Qianrui](https://community.freefem.org/u/Qianrui)\
**Post date:** [June 30, 2022, 8:37am UTC](https://community.freefem.org/t/variational-form-of-mixed-finite-element/1860/1 "2022-06-30T08:37:08Z")

</div>

The mixed variational problem is as follows. There are two known quantities. I did the following variational, but they all reported errors. Why？

Utt + △U+L(p)=0;  
p=L(U);

((U\_n+1 - 2\*U\_n + U\_n-1)/dt^2 , v)+ (▽(U\_n+1 + U\_n-1)/2, ▽v)+ (L(p\_n), v)=0;  
(p\_n, u)= （L((U\_n+1 + U\_n-1)/2, u)=0;

the command

> fespace Vh(Th, [P2, P1]);  
> varf RKG([Un+1,p1],[u,v])=…  
> varf RHS([Un,Un-1],[u,v])=…  
> matrix A = RKG(Xh, Xh, solver=UMFPACK);  
> matrix B = RHS(Xh, Xh);  
> complex[int] sol(Xh.ndof), aux(Xh.ndof);  
> Xh [w0, w1] = [Un, Un-1]; // **An error is reported in this line at runtime**  
> sol = w0;  
> for(real t=0+dt_2;t\<=Tf;t+=dt)  
> {  
> aux = B_sol;  
> sol = A^-1 \* aux;  
> },
