# What are the best way to get error estimates from a PDE solver?

**URL:** <https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086>\
**Category:** General Discussion\
**Created:** [July 6, 2021, 6:03pm UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086 "2021-07-06T18:03:39Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![dajopez](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@dajopez](https://community.freefem.org/u/dajopez)\
**Post date:** [July 6, 2021, 6:03pm UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/1 "2021-07-06T18:03:39Z")

</div>

Hello,

I am solving eigenfunctions on a simple domain and I want to get some nice error and convergence data from it. What are the best ways to do this? Are there any quick commands in FreeFEM to get it done automatically?

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [July 7, 2021, 7:58am UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/2 "2021-07-07T07:58:58Z")

</div>

If you are solving the eigenproblem with PETSc, you can get nice error and residual estimates with `-eps_error_backward ::ascii_info_detail -eps_error_relative ::ascii_info_detail -eps_error_absolute ::ascii_info_detail`.

---

<div class="post-metadata">

**Author:** ![dajopez](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@dajopez](https://community.freefem.org/u/dajopez)\
**Post date:** [July 13, 2021, 3:56am UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/3 "2021-07-13T03:56:52Z")

</div>

> [@prj](#):
>
> PETSc

How would I actually implement this in code? Do you have a link to the documentation?

---

<div class="post-metadata">

**Author:** ![dajopez](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@dajopez](https://community.freefem.org/u/dajopez)\
**Post date:** [July 13, 2021, 4:15am UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/4 "2021-07-13T04:15:45Z")

</div>

also, I am using SlepC

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [July 13, 2021, 5:05am UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/5 "2021-07-13T05:05:18Z")

</div>

> **[slepc.pdf](https://slepc.upv.es/documentation/slepc.pdf)**
>
> 933.70 KB

---

<div class="post-metadata">

**Author:** ![dajopez](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@dajopez](https://community.freefem.org/u/dajopez)\
**Post date:** [July 14, 2021, 1:34am UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/6 "2021-07-14T01:34:15Z")

</div>

> relErrorApprox[i] = abs(absErrorBnd[i])/abs(int2d(Th)(partX^2 + partY^2));
> 
> solverError[i] = EPSComputeError(OP, B,i,EPS\_ERROR\_RELATIVE,&error);
> 
> xBot[i] = int1d(Th,a4)(x_partY^2)/ev[i] + int1d(Th,a5)(x_partY^2)/ev[i];

It continually tells me that EPSComputeError does not exits. DO you have any idea what the issue could be?

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [July 14, 2021, 11:04am UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/7 "2021-07-14T11:04:54Z")

</div>

There is not interface to `EPSComputeError` in the SLEPc plugin. You can use the options I gave in the earlier post in the `sparams` argument of your `EPSSolve`. If you want to store the errors in a file instead of being printed to screen, you should be able to do `-eps_error_relative your_filename::ascii_info_detail`.

---

<div class="post-metadata">

**Author:** ![dajopez](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@dajopez](https://community.freefem.org/u/dajopez)\
**Post date:** [July 15, 2021, 3:20am UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/8 "2021-07-15T03:20:39Z")

</div>

Does this look right?

> Blockquote  
> int k = EPSSolve(OP, B, values=ev, vectors=eV,sparams = “-st\_type sinvert -eps\_nev " + nev + " -eps\_target " + sigma + " -eps\_gen\_hermitian” + “-eps\_error\_relative reportedRelativeError::ascii\_info\_detail” + “-eps\_error\_absolute reportedAbsoluteError::ascii\_info\_detail” + “-eps\_error\_backward reportedBackwardError::ascii\_info\_detail”);

> Blockquote

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [July 15, 2021, 6:46pm UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/9 "2021-07-15T18:46:01Z")

</div>

No, sorry, it’s `ascii:your_filename:ascii_info_detail` each time.

---

<div class="post-metadata">

**Author:** ![dajopez](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@dajopez](https://community.freefem.org/u/dajopez)\
**Post date:** [July 21, 2021, 6:37am UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/10 "2021-07-21T06:37:00Z")

</div>

So do I leave it as

> - “-eps\_error\_absolute:reportedAbsoluteError”

in the sparams or do I have to put in more information?

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [July 21, 2021, 6:39am UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/11 "2021-07-21T06:39:07Z")

</div>

Use what I said [initially](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/7) but put `ascii:` before `your_filename`.

---

<div class="post-metadata">

**Author:** ![dajopez](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@dajopez](https://community.freefem.org/u/dajopez)\
**Post date:** [July 21, 2021, 7:06am UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/12 "2021-07-21T07:06:38Z")

</div>

> [@dajopez](#):
>
> int k = EPSSolve(OP, B, values=ev, vectors=eV,sparams = “-st\_type sinvert -eps\_nev " + nev + " -eps\_target " + sigma + " -eps\_gen\_hermitian” + “-eps\_error\_relative ascii:reportedRelativeError::ascii\_info\_detail” + “-eps\_error\_absolute ascii:reportedAbsoluteError::ascii\_info\_detail” + “-eps\_error\_backward ascii:reportedBackwardError::ascii\_info\_detail”);

So this is correct? Or should there be only one colon in the second division?

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [July 21, 2021, 7:15am UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/13 "2021-07-21T07:15:32Z")

</div>

It should be correct, just launch, see if it produces what you need, otherwise use the `-help` command. There are obviously a lot of spaces missing around your `" + "`…

---

<div class="post-metadata">

**Author:** ![dajopez](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@dajopez](https://community.freefem.org/u/dajopez)\
**Post date:** [July 21, 2021, 7:32am UTC](https://community.freefem.org/t/what-are-the-best-way-to-get-error-estimates-from-a-pde-solver/1086/14 "2021-07-21T07:32:16Z")

</div>

> [@dajopez](#):
>
> - “-eps\_error\_relative ascii:reportedRelativeError::ascii\_info\_detail” + “-eps\_error\_absolute ascii:reportedAbsoluteError::ascii\_info\_detail” + “-eps\_error\_backward ascii:reportedBackwardError::ascii\_info\_detail”

When I include this in the sparams, my solver gives different (and incorrect) solutions. Do you have any idea why?
