Command for third order derivative

// Third derivative example in FreeFem++

load “msh3” // only if you want 3D later, otherwise optional

// Define mesh
mesh Th = square(10, 10);

// Define finite element space (need degree >= 3 for 3rd derivatives)
fespace Vh(Th, P3);

// Define a test function
Vh u = x^3 + 2x^2y + y^3;

// Compute third derivatives
Vh d3x = dx(dxx(u)); // ∂³u / ∂x³
Vh d3y = dy(dyy(u)); // ∂³u / ∂y³
Vh d2x1y = dy(dxx(u)); // ∂³u / ∂x²∂y
Vh d1x2y = dx(dyy(u)); // ∂³u / ∂x∂y²

// Print values at a point (0.5, 0.5)
real px = 0.5, py = 0.5;
cout << "u(x,y) = " << u(px,py) << endl;
cout << "d³u/dx³ = " << d3x(px,py) << endl;
cout << "d³u/dy³ = " << d3y(px,py) << endl;
cout << "d³u/dx²dy = " << d2x1y(px,py) << endl;
cout << "d³u/dxdy² = " << d1x2y(px,py) << endl;

// Plot results
plot(u, value=1, cmm=“u(x,y)”);
plot(d3x, value=1, cmm=“∂³u/∂x³”);
plot(d3y, value=1, cmm=“∂³u/∂y³”);
plot(d2x1y, value=1, cmm=“∂³u/∂x²∂y”);
plot(d1x2y, value=1, cmm=“∂³u/∂x∂y²”);

What is the command for third order derivative?

This is not working

A command for 3rd order derivative would be useless. Already, using second order derivatives commands leads to mistakes. This is because most of the time, functions in finite element spaces are continuous, but their derivatives are discontinuous. It follows that computing a second derivative inside the element misses the jump part of the first-order derivative.

Instead of that, if you want to compute second or third derivatives, you have to interpolate discontinuous functions into spaces of continuous functions before applying derivative operators dx(), dy(). This gives

der3.edp (1.5 KB)

Thank you!!, Will it work in the weak formulation?

Yes, in a weak formulation the interpolated derivatives in a continuous space have to be understood as independent variables.
For example if you want to solve
-\Delta u=f
you can write the system
\partial_x u=u_x,
\partial_y u=u_y,
-\partial_x u_x-\partial_y u_y=f
with unknowns u,u_x,u_y in P1. Then you write a variational formulation with 3 unknowns and 3 test functions.
This is the mixed finite element method.