# Resolve an equation

**URL:** <https://community.freefem.org/t/resolve-an-equation/1134>\
**Category:** General Discussion\
**Created:** [August 3, 2021, 9:58am UTC](https://community.freefem.org/t/resolve-an-equation/1134 "2021-08-03T09:58:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aicha](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Aicha](https://community.freefem.org/u/Aicha)\
**Post date:** [August 3, 2021, 9:58am UTC](https://community.freefem.org/t/resolve-an-equation/1134/1 "2021-08-03T09:58:06Z")

</div>

Hi,

i hope that you can help me to solve my problem please.

I(x,t) is solution of a variational formulation: system.

To find I, we write

load “iovtk”

verbosity=1;

int Nbx=10000;

real L=2.;

real t=0.0;

real dt=0.1;

real T=50.0;

real beta=5.;

real a=10.;

real Dx=L/Nbx;

load “msh3”

meshL Thl=segment(Nbx,[x\*L,0.]);

fespace Vh2(Thl,P1);

Vh2 I, IH;

Vh2 oldI=10;

problem system(I,IH,solver=UMFPACK)=

int1d(Thl)(I_IH/dt + beta_I\*IH)

- int1d(Thl)(oldI_IH/dt + a_IH);

for (real t=0;t\<T;t+=dt) {

system,

}

My question is: how we can resolve the equation I(x,t)=0.5 for all t: find x=x(t) such that I(x,t)=0.5 for all t and after this, calculate c(t)=x’(t).

To find the solution of the equation I(x,t)=0.5 i try to write the following algotirhme

but the problem it that FF++ don’t understand the expression I(x0,t) or I(x1,t)

there is a solution to adapte this algorithm to FreeFrem++ and find the solution x=x(t)? Please.

real x0, x1, y0, V0, V1;

x0=0.0;

verbosity=1;  
int Nbx=10000;  
real L=2.;  
real t=0.0;  
real dt=0.1;  
real T=50.0;  
real beta=5.;  
real a=10.;  
real Dx=L/Nbx;  
load “msh3”  
meshL Thl=segment(Nbx,[x_L,0.]);  
fespace Vh2(Thl,P1);  
Vh2 I, IH;  
Vh2 oldI=10;  
problem system(I,IH,solver=UMFPACK)=  
int1d(Thl)(I_IH/dt + beta_I_IH)  
- int1d(Thl)(oldI_IH/dt + a_IH);

for (real t=0;t\<T;t+=dt) {  
system,

I0=I(x0,t)-0.5;

real signe;  
if (I0\>0.0) { signe=1.0; }  
else {signe=-1.0;}  
for (int i = 1; i \< N; i++)  
{  
x1=L_real(i)/real(N-1);  
I1=I(x1,t)-0.5;  
if (I1_signe\<0.0)  
{  
xt = (I1_x0 - I0_x1) / (I1 - I0)  
}  
x0=x1;  
I0=I1;  
}

}

Thank you in advance for the help

Best regards,
