I want to realize the following idea in Mathematica.
I've got a matrix
{{a,b},{c,d}}
which is multiplied to a vector {h,k}
leading to
{{a h + b k}, {c h + d k}}.
Imagine now that a
is an operator and I want to apply it to h
, instead of multiplying.
Primitive substitution {a h -> a@h}
helps, but it is not quite a good approach while it's not working in more sophisticated cases.
Thank you!
EDIT1: The problem is solved partially, all comments are very useful. But still I am a little bit stacked, so I'm posting the update trying to explain my exact problem.
The problem is following. I want to construct the matrix
{{a[x], b},{c, d}}
where a[x]
is an operator (function) and b,c
and d
are arbitrary expressions (which are symbolic in general). After applying the operation
{{a[x], b},{c, d}}.{{h}, {k}}
I want to obtain
{{a[h] + b k}, {c h + d k}}
I want this operation to work not only for numbers and functions as it was proposed in answers below but with arbitrary symbolic expressions. I mean I want Mathematica to understand that if x
and p
are not functions but just variables, then x*p
means multiplication, otherwise it means x[p]
.
Moreover I want this operation to work in more general cases, e.g.
{{a[x], b},{c, d}}.M.Transpose[{{a[x], b},{c, d}}],
where M
is an arbitrary matrix.
I would be very grateful for any ideas.
Inner
, the generalization ofDot
? $\endgroup$a[x]
inTranspose[{{a[x], b},{c, d}}]
act to the left onM
(in which case an order of operations needs to be specified), or does it act to the right, leaving the expression as a function? $\endgroup$b
withb*# &
and leavea
asa
, and use theInner
answer below, but see my last comment: we need an answer to this before giving a complete answer. $\endgroup$M
$\endgroup$a c x
byc*a[x]
in[[1,2]]
anda c x
bya[c x]
in[[2, 1]]
. That is exactly what I mean by non-associative. I think this means that you have to do these calculations left to right. Let me see if I can come up with something. $\endgroup$