# Error between numerical solution and exact solution

**URL:** <https://community.freefem.org/t/error-between-numerical-solution-and-exact-solution/1935>\
**Category:** General Discussion\
**Created:** [August 8, 2022, 7:28am UTC](https://community.freefem.org/t/error-between-numerical-solution-and-exact-solution/1935 "2022-08-08T07:28:24Z")\
**Posts on this page:** 3\
**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:** [August 8, 2022, 7:28am UTC](https://community.freefem.org/t/error-between-numerical-solution-and-exact-solution/1935/1 "2022-08-08T07:28:24Z")

</div>

I calculated a one-dimensional KdV equation. Through grid refinement, i.e. the interval [- 40,40] was divided into 80，160，320，400 parts. However, the L2 error between the four numerical solutions obtained after refinement and the exact solution remained unchanged.

> L2error0.0944101H1error0.102034  
> L2error0.0954364H1error0.103233  
> L2error0.0957789H1error0.103633  
> L2error0.0959502H1error0.103834  
> L2error0.0960529H1error0.103954  
> CL2-0.0155998CH1-0.0168526  
> CL2-0.00516732CH1-0.00558552  
> CL2-0.00257757CH1-0.00278902  
> CL2-0.00154459CH1-0.0016741

[KDV08.07\_Neumann boundary condition.edp](https://community.freefem.org/uploads/short-url/nQwvX2tB1Gk590Qak3dCN1btptJ.edp) (2.5 KB)

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [August 8, 2022, 4:03pm UTC](https://community.freefem.org/t/error-between-numerical-solution-and-exact-solution/1935/2 "2022-08-08T16:03:14Z")

</div>

I have 2 or 3 bug.

the array b is constant in time and the matrix A1 is also constant in time  
but the form a and rhs depend of u0 (previous value).

After that they are other error but where ?

---

<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:** [August 10, 2022, 3:32am UTC](https://community.freefem.org/t/error-between-numerical-solution-and-exact-solution/1935/3 "2022-08-10T03:32:49Z")

</div>

Hello, thank you for your answer. I did not use **varf** , but directly used **solve**.In fact, with the refinement of the spatial grid, the error between numerical solution and exact solution is increasing.

> L2error0.0477312H1error0.0647041  
> L2error0.0480366H1error0.065121  
> L2error0.0481375H1error0.0652612  
> L2error0.0478928H1error0.0649569  
> L2error0.0482175H1error0.0653916

[KDV(n=1)07.27.edp](https://community.freefem.org/uploads/short-url/1T9n5DBd7wTA8Q0HtGeXGwOYu6.edp) (1.9 KB)
