# Inconsistent rates of convergence

**URL:** <https://community.freefem.org/t/inconsistent-rates-of-convergence/3947>\
**Category:** General Discussion\
**Created:** [May 28, 2025, 9:17am UTC](https://community.freefem.org/t/inconsistent-rates-of-convergence/3947 "2025-05-28T09:17:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![xavier1](https://avatars.discourse-cdn.com/v4/letter/x/f04885/32.png) [@xavier1](https://community.freefem.org/u/xavier1)\
**Post date:** [May 28, 2025, 9:17am UTC](https://community.freefem.org/t/inconsistent-rates-of-convergence/3947/1 "2025-05-28T09:17:13Z")

</div>

Hi everyone,  
I’m trying to compute the order of convergence for a nonlinear PDE solver using a three-level time-stepping scheme in FreeFEM++, but I’m not getting the expected results. I’m computing L2 and H1 errors against an exact solution, but the convergence rates seem inconsistent.

 ![scheme](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/c/c07341945ea5624e882a3a78c5c4baddf7c86a21.jpeg)  
[kg\_order.edp](https://community.freefem.org/uploads/short-url/2YVPqvk9gwlJsM4jizaYWp2evO5.edp) (4.9 KB)

---

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [May 30, 2025, 10:13am UTC](https://community.freefem.org/t/inconsistent-rates-of-convergence/3947/2 "2025-05-30T10:13:01Z")

</div>

Dear Xavier,  
I have corrected your code  
[kg\_order.edp](https://community.freefem.org/uploads/short-url/eUa7LXs7jcV3B5IEnbsRymP63qP.edp) (4.9 KB)  
There were several problems:

1. Dirichlet boundary conditions wrongly set in Newton method
2. Error in duexdq
3. Not good management of time
4. Missing right-hand side g in the definition of U1

Indeed for U1 it is not mandatory to do the complicate definition,  
it is more simple to set U1=U0+dt\*(du/dt)\_in  
For your test case (du/dt)\_in=-U0, thus it leads to  
U1=U0-dt\*U0;

---

<div class="post-metadata">

**Author:** ![xavier1](https://avatars.discourse-cdn.com/v4/letter/x/f04885/32.png) [@xavier1](https://community.freefem.org/u/xavier1)\
**Post date:** [May 31, 2025, 5:29am UTC](https://community.freefem.org/t/inconsistent-rates-of-convergence/3947/3 "2025-05-31T05:29:21Z")

</div>

Dear François Bouchut,  
Thank you very much for your corrections and insightful remarks regarding the code.  
I have implemented the suggested changes, like the simplified initialization of U1 = U0 - dt\*U0 . However, I am still observing a large increase in the order of convergence in the  
𝐻1 norm.  
Please let me know if you have any further thoughts on this observation.

---

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [May 31, 2025, 11:49am UTC](https://community.freefem.org/t/inconsistent-rates-of-convergence/3947/4 "2025-05-31T11:49:35Z")

</div>

Dear Xavier,  
The definition of U1 by the variational problem gives better results than the U1 = U0 - dt\*U0 (but is more complicate).  
Thus when debuging such a code, it is better to treat first the simplificed case.  
I did not observe a particular problem on the H1 norm with the version I posted. For which data do you see it?

---

<div class="post-metadata">

**Author:** ![xavier1](https://avatars.discourse-cdn.com/v4/letter/x/f04885/32.png) [@xavier1](https://community.freefem.org/u/xavier1)\
**Post date:** [May 31, 2025, 6:56pm UTC](https://community.freefem.org/t/inconsistent-rates-of-convergence/3947/5 "2025-05-31T18:56:00Z")

</div>

Hi François Bouchut,  
Thanks for the explanation! I’m comparing the results using the table below, along with the initial condition and exact solution mentioned in the example above (here k is dt)

 ![1](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/1/1353a7844494372d2f7f2095c04bd579c9c252c5.png)

---

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [May 31, 2025, 7:23pm UTC](https://community.freefem.org/t/inconsistent-rates-of-convergence/3947/6 "2025-05-31T19:23:54Z")

</div>

Is it for T=10? For this time the code gives better results (case P2):  
level 0 L2 error = 0.0070826 H1 error = 0.206281  
level 1 L2 error = 0.000854992 H1 error = 0.0486429  
level 2 L2 error = 2.59358e-05 H1 error = 0.00300922  
level 3 L2 error = 3.29636e-06 H1 error = 0.000805949  
Order of convergence in L2 norm between dt=0.25 and dt=0.125 = 3.0503  
Order of convergence in H1 norm between dt=0.25 and dt=0.125 = 2.08431  
Order of convergence in L2 norm between dt=0.125 and dt=0.0625 = 5.04289  
Order of convergence in H1 norm between dt=0.125 and dt=0.0625 = 4.01477  
Order of convergence in L2 norm between dt=0.0625 and dt=0.03125 = 2.976  
Order of convergence in H1 norm between dt=0.0625 and dt=0.03125 = 1.90063

---

<div class="post-metadata">

**Author:** ![xavier1](https://avatars.discourse-cdn.com/v4/letter/x/f04885/32.png) [@xavier1](https://community.freefem.org/u/xavier1)\
**Post date:** [June 1, 2025, 4:06am UTC](https://community.freefem.org/t/inconsistent-rates-of-convergence/3947/7 "2025-06-01T04:06:31Z")

</div>

No, here time is T = 5.

---

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [June 1, 2025, 10:05am UTC](https://community.freefem.org/t/inconsistent-rates-of-convergence/3947/8 "2025-06-01T10:05:59Z")

</div>

For T=5 still it is much better than in your table  
level 0 L2 error = 0.0128677 H1 error = 0.323882  
level 1 L2 error = 0.000713262 H1 error = 0.0434486  
level 2 L2 error = 4.37852e-05 H1 error = 0.00570313  
level 3 L2 error = 1.31308e-06 H1 error = 0.000315001  
Order of convergence in L2 norm between dt=0.25 and dt=0.125 = 4.17318  
Order of convergence in H1 norm between dt=0.25 and dt=0.125 = 2.89809  
Order of convergence in L2 norm between dt=0.125 and dt=0.0625 = 4.02591  
Order of convergence in H1 norm between dt=0.125 and dt=0.0625 = 2.92948  
Order of convergence in L2 norm between dt=0.0625 and dt=0.03125 = 5.05942  
Order of convergence in H1 norm between dt=0.0625 and dt=0.03125 = 4.17833

I don’t see how theoretically the order of accuracy could be higher than 2 (but maybe you have a good reason, with your special formula \mathcal{G}(v,w)=\frac{1}{4}(v^3+v^2w+vw^2+w^3))

The fact is that the solution is proportional to exp(-t), hence becomes rapidly small. Then we measure essentially the ability of the scheme to decay rapidly.  
If we take T=1, the order of accuracy becomes 2 for H1:  
level 0 L2 error = 0.0173478 H1 error = 0.506981  
level 1 L2 error = 0.00209946 H1 error = 0.113722  
level 2 L2 error = 0.00021149 H1 error = 0.0262025  
level 3 L2 error = 2.27056e-05 H1 error = 0.00630379  
Order of convergence in L2 norm between dt=0.25 and dt=0.125 = 3.04666  
Order of convergence in H1 norm between dt=0.25 and dt=0.125 = 2.15642  
Order of convergence in L2 norm between dt=0.125 and dt=0.0625 = 3.31136  
Order of convergence in H1 norm between dt=0.125 and dt=0.0625 = 2.11774  
Order of convergence in L2 norm between dt=0.0625 and dt=0.03125 = 3.21947  
Order of convergence in H1 norm between dt=0.0625 and dt=0.03125 = 2.05541

Indeed this is obtained by replacing `-int2d(Th)(g(t)*phi)` by  
`-int2d(Th)(.5*(g(t-dt)+g(t+dt))*phi)` in the update variational formulation `varf Fv`,  
so that the source term is discretized similarly as the Laplace term (this gives better results).

---

<div class="post-metadata">

**Author:** ![xavier1](https://avatars.discourse-cdn.com/v4/letter/x/f04885/32.png) [@xavier1](https://community.freefem.org/u/xavier1)\
**Post date:** [June 23, 2025, 11:16am UTC](https://community.freefem.org/t/inconsistent-rates-of-convergence/3947/9 "2025-06-23T11:16:55Z")

</div>

Thanks a lot for your thoughtful remarks!
