I wanted to verify the derivative of the following equation:
$$ f(x) = \sum^{K_2}_{k_2=1} c_{k_2} \exp\left(- \big(a^{(2)} - t^{(2)}_{k_2}\big)^2\right)$$
for that I wanted to write a symbolic equation/representation of it so that I could manipulate it but I wasn't sure how to do that in mathematica. Ideally I'd like to get the following functionality:
$$ \frac{df(x)}{dt^{(2)}_{k_2}} = c_{k_2} \left(- \exp\big(z^{(2)}_{k_2}\big)\cdot2\big(a^{(2)}_{k_2} - t^{(2)}\big)\right)(-1)$$
so that it gave me the actual equation back symbolically (if that happens to be the correct one).
Ideally I'd like to extend it to accept vector inputs to as in:
$$ f(x) = \sum^{K_2}_{k_2=1} c_{k_2} \exp\left(- \big\| a^{(2)} - t^{(2)}_{k_2}\big\|^2\right)$$
but one thing at a time.
This is what I have tried so far. So before I try to me the upper limit of the sum symbolic, I am going to try to try it out a fixed $K_2$.
f[a_, t_, c_] = Sum[c[k2] * exp[a, t[k2]], {k2, 1, 3}]
which outputs:
which seems exactly correct. However, when I actually try to evaluate it and give it a vector it doesn't work as I expect:
instead of indexing at every location it just inserts the list for the variable, which isn't exactly what I had in mind. I was expecting something like:
$$ f = c_1 e^{-(a - t_1)^2} + c_2 e^{-(a - t_2)^2} + c_1 e^{-(a - t_1)^2} $$
$$ f = 5 e^{-(a - 1)^2} + 6 e^{-(a - 2)^2} + 7 e^{-(a - 3)^2} $$
I also tried a simple example with K2 fixed and it didn't quite work:
why does it return zero :/