# derivative of testfunction

Asked by Melanie Jahny on 2013-03-27

I try to compute the derivative of TestFunctions (second order Lagrange) in x-direction
on a 2D domain.
Is this possible in FEniCS?

As I learned I need to project the "dx(0)" formulation on a function space. I think the basis
functions are only defined locally on a reference element, so I'm not sure where to project
it.

I tried:

mesh = Rectangle(0,0,1,1,10,10)
V = FunctionSpace(mesh, "Lagrange", 2)
W = FunctionSpace(mesh, "DG", 0)

eta = TestFunction(V)

dx_eta = eta.dx(0) # that works
deriv_eta = project(dx_eta, W) # error...

Thanks for any help!

## Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Melanie Jahny
Solved:
2013-03-27
Last query:
2013-03-27
 Melanie Jahny (melanie-jahny) said on 2013-03-27: #1

Ok, I found the second order Lagrange Basis functions and can
compute the derivative myself. Then I can use this formulation in
FEniCS. That should work, I think.

 B. Emek Abali (bilenemek) said on 2013-04-05: #2

Hi, I assume the problem accurs at the moment when FEniCS tries to solve the system by multiplying with a test functions. Project() needs to solve the system, which is in your example the derivative of the test function. Therefore the problem is testfunction times derivative of testfunction and an error occurs.

 Melanie Jahny (melanie-jahny) said on 2013-04-05: #3

Hi! I didn't know that Project() needs to solve the system. Then it is clear that it cannot work.
Thank you for the information. It helps to understand how FEniCS works.

I recently found out that I also can use a Function in my equation formulation instead of a Testfunction
which makes the thing easier for me.
That means I can do

W = ...
c_func = Function(W)
V = FunctionSpace(mesh, "DG", 1)
deriv_cx = project(c_func.dx(0), V)
deriv_val = deriv_cx(1.0, 1.0)

and that works.

 Martin Sandve Alnæs (martinal) said on 2013-04-05: #4

Melanie, I suggest you take a look at the FEniCS tutorial in the book, you can download it as a pdf from the webpage somewhere. There you'll find step by step explanations for how to set up and solve problems in FEniCS.