# Evaluating Solution at Arbitrary Points

**URL:** <https://community.freefem.org/t/evaluating-solution-at-arbitrary-points/4028>\
**Category:** General Discussion\
**Created:** [July 28, 2025, 6:53am UTC](https://community.freefem.org/t/evaluating-solution-at-arbitrary-points/4028 "2025-07-28T06:53:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wdachub](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/wdachub/32/1589_2.png) [@wdachub](https://community.freefem.org/u/wdachub)\
**Post date:** [July 28, 2025, 6:53am UTC](https://community.freefem.org/t/evaluating-solution-at-arbitrary-points/4028/1 "2025-07-28T06:53:25Z")

</div>

Dear FreeFEM users and developers,

I am trying to evaluate the value of a solution at a specific point in order to compare it with a theoretical value. If the point lies exactly on a mesh node, the method described in [this post](https://community.freefem.org/t/how-to-get-values-of-a-pde-at-every-position-in-the-space/278) works well.

However, if the point does not coincide with a mesh node, interpolation is necessary. I would like to ask whether FreeFEM provides any built-in functionality to perform this kind of interpolated evaluation at arbitrary spatial points.

Thank you in advance 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 28, 2025, 9:19am UTC](https://community.freefem.org/t/evaluating-solution-at-arbitrary-points/4028/2 "2025-07-28T09:19:22Z")

</div>

Yes, it does, it’s explained in the manual.

---

<div class="post-metadata">

**Author:** ![wdachub](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/wdachub/32/1589_2.png) [@wdachub](https://community.freefem.org/u/wdachub)\
**Post date:** [August 1, 2025, 12:39am UTC](https://community.freefem.org/t/evaluating-solution-at-arbitrary-points/4028/3 "2025-08-01T00:39:29Z")

</div>

Thanks. I also got it from AI. I was just surprised since AI couldn’t give a correct answer about FreeFem++ a few months ago.

real value;  
value = uh(x\_coord, y\_coord);

---

<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:** [August 1, 2025, 4:23am UTC](https://community.freefem.org/t/evaluating-solution-at-arbitrary-points/4028/4 "2025-08-01T04:23:14Z")

</div>

That code is wrong, yet another example of wrongful use of AI.

---

<div class="post-metadata">

**Author:** ![wdachub](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/wdachub/32/1589_2.png) [@wdachub](https://community.freefem.org/u/wdachub)\
**Post date:** [October 7, 2025, 12:02am UTC](https://community.freefem.org/t/evaluating-solution-at-arbitrary-points/4028/5 "2025-10-07T00:02:26Z")

</div>

Thanks for the comment. I think you mean that the underscore causes the problem. However, `u(x, y)` should be the correct syntax to obtain the solution value at the point (x, y), right?

The following example solves the equation \\Delta u = 1 on a unit circle with zero boundary conditions. The exact solution is u(x, y) = 0.25, (1 - (x^2 + y^2)). I tested several points, and the numerical results are close to the exact solution.

By the way, I still have trouble finding an explanation of this syntax in the FreeFem++ documentation. I would appreciate it if you could point me to the relevant section or page.

```auto
// Define mesh boundary
border C(t=0, 2*pi){x=cos(t); y=sin(t);}
// The triangulated domain Th is on the left side of its boundary
mesh Th = buildmesh(C(50));

// The finite element space defined over Th is called here Vh
fespace Vh(Th, P2);
Vh u, v;// Define u and v as piecewise-P1 continuous functions

// Define a function f
func f= 1;

// Get the clock in second
real cpu=clock();

// Define the PDE
solve Poisson(u, v, solver=LU)
    = int2d(Th)( // The bilinear part
          dx(u)*dx(v)
        + dy(u)*dy(v)
    )
    - int2d(Th)( // The right hand side
          f*v
    )
    + on(C, u=0); // The Dirichlet boundary condition

// Plot the result
// plot(u);
// Display the total computational time
cout << "CPU time = " << (clock()-cpu) << endl;

real xcoord, ycoord, value;
xcoord=0.5;
ycoord=0.5;
value = u(xcoord, ycoord);
func fun=0.25*(1-(x^2+y^2));
cout<<"solution value="<<u(xcoord, ycoord)<<endl;
cout<<"exact value="<<fun(xcoord, ycoord)<<endl;

```
