# When can you multiply two fespaces?

**URL:** <https://community.freefem.org/t/when-can-you-multiply-two-fespaces/1579>\
**Category:** General Discussion\
**Created:** [March 6, 2022, 12:45pm UTC](https://community.freefem.org/t/when-can-you-multiply-two-fespaces/1579 "2022-03-06T12:45:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SamuelJosephs](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/samueljosephs/32/1046_2.png) [@SamuelJosephs](https://community.freefem.org/u/SamuelJosephs)\
**Post date:** [March 6, 2022, 12:45pm UTC](https://community.freefem.org/t/when-can-you-multiply-two-fespaces/1579/1 "2022-03-06T12:45:33Z")

</div>

I’m new to FreeFEM and have the following error for the following code snippet:

```auto
fespace Uh(Th,P1);
Uh Ex, Ext;
Uh Exold;
Uh Extold;
Uh Ey,Eytold, Eyt;
Uh fx, fy;

problem Maxwell([Ex,Ey],[fx,fy]) = int2d(Th)(
	(dx(Ex)+dy(Ey))*(dx(fx)+dy(fy))
) - int2d(Th)(
	(dx(Ey) - dy(Ex))*(dx(fy) - dx(fy))
) - int2d(Th)(
	// mu0*epsilon0*(10*exp(-30*y))*(Ex*fx + Ey * fy)
	// mu0*epsilon0*(Ex*fx + Ey * fy)
	mu0*epsilon0*(10*exp(-30*y))*(
		 (Ex*fx + Ey*fy)-(Extold*fx - Eytold*fy)
	
)) + on(source,Ex = sin(8*x),Ey = 0);

```

I get an error when I multiply two FE spaces:

```auto
error operator * <10LinearCombI7MGauche4C_F0E>, <10LinearCombI7MGauche4C_F0E> 

```

Despite it working in examples : [Evolution problems](https://doc.freefem.org/models/evolution-problems.html)

So when is it okay to multiply these together?

---

<div class="post-metadata">

**Author:** ![fivanci](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@fivanci](https://community.freefem.org/u/fivanci)\
**Post date:** [March 7, 2022, 2:03am UTC](https://community.freefem.org/t/when-can-you-multiply-two-fespaces/1579/2 "2022-03-07T02:03:23Z")

</div>

> [@SamuelJosephs](#):
>
> I’m new to FreeFEM

Better start by going through the basic documentation first [Finite element](https://doc.freefem.org/documentation/finite-element.html#problem-definition). There are lots of examples and guidelines in the online documentation.

> [@SamuelJosephs](#):
>
> I multiply two FE spaces

1. From the code posted above, you only have **one** finite element space, namely, `fespace Uh(Th,P1)`. Mixing `fespace`s becomes important when you deal with mixed _finite element method_, so it is important to be consistent with terminology.

> [@SamuelJosephs](#):
>
> I get an error

1. Your error most likely comes because you have part of the _left hand side_ and the _right hand side_ under the same integral (the last integral in your `problem Maxwell([...],[...])`). These two have to be separated (see warning here [Finite element](https://doc.freefem.org/documentation/finite-element.html#problem-definition)).

if

---

<div class="post-metadata">

**Author:** ![SamuelJosephs](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/samueljosephs/32/1046_2.png) [@SamuelJosephs](https://community.freefem.org/u/SamuelJosephs)\
**Post date:** [March 7, 2022, 10:32am UTC](https://community.freefem.org/t/when-can-you-multiply-two-fespaces/1579/3 "2022-03-07T10:32:18Z")

</div>

Thank you! I have since gone through all the examples and a lot of documentation and think I know what I need to do now, would you say the following form would work?

A[Ex,Ey] = B[Exold,Eyold] + C[Exoldold,Eyoldold] +bc  
Where A,B,C, and bc are matrices of varf’s, which I can then solve for A repeatedly in a for loop to loop through time?

The aim of this is to be in much the same spirit of this:  
[https://doc.freefem.org/tutorials/timeDependentStokes.html](https://doc.freefem.org/tutorials/timeDependentStokes.html)
