This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to solve system of equations involving functions

+1 vote

I have a bunch of functions f[], a bunch of constants c[] and an unknown function u. I know that assemble(f[i] * u * dx) == c[i] for all i. How do I find u?

My first attempt was to set up a matrix A = [ f_i.vector() for f_i in f ] and then solve A.x == c (so that x == u.vector()). That that does not work, I think because it assumes the wrong inner product: assemble(f[i] * u * dx) != np.dot(f[i].vector(), u.vector()).

Is there a way to obtain a matrix representation of the inner product, i.e. a matrix G such that assemble(f[i] * u * dx) == np.dot(np.dot(G, f[i].vector()), u.vector())? I believe in that case I could solve A.G.x == c and get the right result. Or is there a way to get right A matrix directly from assemble?

asked Jan 31, 2014 by Nikolaus Rath FEniCS User (2,100 points)

1 Answer

+2 votes
 
Best answer

I think, you first have to give consideration to what this u function should look like.

Probably, you want to have u as a linear combination of some basis functions bj. Then, you need setup the basis functions and test them against the functions f[]. This will give you a linear equation system for the coefficients uj in the linear combination:

u = u1*b1 + ... + um*bm

Specifically, the $a_{ij}$ entry of your matrix A will be

aij = assemble(f[i] * bj * dx).

If your bj make up a basis of a Fenics FEM space V, then you can compute a row of A via

v = TrialFunction(V)
Ai = assemble(f[i] * v * dx)
answered Feb 3, 2014 by Jan FEniCS User (8,290 points)
edited Feb 4, 2014 by Jan
...