I want to write a function like the following:
s[u_, v_, x_, val_] := u[val]/NIntegrate[u'[x] v[x] + u'[x] v'[x], {x, 0, 1}]
So I can evaluate something like
s[Cos[x], Sin[3 x], x, 5]
I have a strong feeling that my approach is incorrect, however, I couldn't find the right one.
Update:
Thanks to b.gatessucks, who wrote the correct version of what I was trying to achieve. However, after that I tried to use that approach on lists:
r = {1, 2, 3, 4, 5};
u[x_, i_] := Sin[r[[i]] x];
A = Table[s[u[#, i] &, u[#, j] &, 5], {i, 5}, {j, 5}]
After this, I get a matrix, but I also get a bunch of errors, so I don't know if I can trust the output. The errors are:
Part::pspec: Part specification #2 is neither an integer nor a list of integers.
Part::pspec: Part specification #2 is neither an integer nor a list of integers.
Part::pspec: Part specification #2 is neither an integer nor a list of integers.
General::stop: "Further output of Part::pspec: will be suppressed during this calculation."
_
in the right-hand side. Next, you can drop thex
argument and evaluate you function ass[Cos[#] &, Sin[3 #] &, 5]
. $\endgroup$