Hi i how do i replace constant for k in this summation.
For following:
Here is the code
ue[x_, t_, k_, n_] :=
(1/2)*Sum[Subscript[k, j]*(Subscript[x, j - 1][t] - Subscript[x, j][t])^2,{j, 1, n + 1}];
Hi i how do i replace constant for k in this summation.
For following:
Here is the code
ue[x_, t_, k_, n_] :=
(1/2)*Sum[Subscript[k, j]*(Subscript[x, j - 1][t] - Subscript[x, j][t])^2,{j, 1, n + 1}];
Subscript[k, j_?EvenQ] = a;
Subscript[k, j_?OddQ] = b;
For extra conditions at $j=0$ and $j=n+1$ you can use a two-index form $k_{n,j}$:
Subscript[k, n_, 0] = 0;
Subscript[k, n_, j_] /; j == n + 1 = 0;
Subscript[k, n_, j_?EvenQ] = a;
Subscript[k, n_, j_?OddQ] = b;
Check:
With[{n = 10}, Table[Subscript[k, n, j], {j, 0, n + 1}]]
{0, b, a, b, a, b, a, b, a, b, a, 0}