Dear all,

I want to multiply a function by the same constant at each node and then integrate. I tried to project a constant on a scalar functionspace and use this, but the error message I obtain is “ArityMismatch: Adding expressions with non-matching form arguments?”. A slightly different equation without the scalar functionspace is solved without a problem. Can you help me figure out how to solve the arity mismatch? Thank you so much in advance.

```
from dolfin import *
#Mesh and functionspaces
lambda0 = 5
mesh = IntervalMesh(10,0,1)
S = FunctionSpace(mesh, "Lagrange", 1)
Q = FiniteElement("Lagrange", mesh.ufl_cell(), 1)
MIXED = Q * Q
W = FunctionSpace(mesh, MIXED)
#Boundary conditions
x0 = CompiledSubDomain("near(x[0], side,1e-12) && on_boundary" , side = 0)
x1 = CompiledSubDomain("near(x[0], side,1e-12) && on_boundary" , side = 1)
bcbx1 = DirichletBC(W.sub(1), Expression(("mu0"),mu0=1e5, degree=1), x1)
bcbx = DirichletBC(W.sub(0), Expression(("0.0"), degree=2), x0)
bcs = [bcbx, bcbx1]
#Functions
(du, dmu) = TrialFunctions(W)
z = Function(W)
dz = TrialFunction(W)
u, mu = split(z)
(v, q) = TestFunctions(W)
#Definitions
I = Identity(1)
F = 1 + u.dx(0)
J = det(F)*lambda0**2
lambdaspace = project(lambda0, S) #This defines a constant on the whole mesh
#Equations
flux = (1-J)*F**(-1)*F**(-1)*mu.dx(0)
sigma = F-F**(-1)+((ln(1-1/J)+1/J+1/J**2)+1e5-mu)*J*F**(-1)
sigma23 = lambdaspace-1./lambdaspace+((ln(1-1/J)+1/J+1/J**2)+1e5-mu)*J*1./lambdaspace
#############################################Works##############################################
F = inner(sigma, v.dx(0))*dx+2*inner(v.dx(0),sigma23)*dx+q.dx(0)*flux*dx
#############################################Works##############################################
#############################################Does not work######################################
F = inner(sigma, v.dx(0))*dx+2*inner(lambdaspace,sigma23)*dx+q.dx(0)*flux*dx
#############################################Does not work######################################
#Solver
J = derivative(F, z, dz)
pde_system = NonlinearVariationalProblem(F, z, bcs, J=J)
solver = NonlinearVariationalSolver(pde_system)
solver.solve()
#Plot solution
F = 1 + u.dx(0)
J = det(F)*lambda0**2
plot(J)
```