I am trying to integrate a hat function for a project that I am doing and have found a method to do so but I find it sloppy. Currently I have the basis function
\[Psi][z_] := z - Subscript[Z, i]/ \[CapitalDelta]z + 1;
which I am trying to integrate from $z_{i-1}$ to $z_{i+1}$. I break the basis function up into two pieces and integrate the left side from $z_{i-1}$ to $z_{i}$ and then the right side from $z_i$ to $z_{i+1}$. My first question is, is there a way to integrate piecewise functions? The second question I have is, is there a way to set global assumptions like $z_{i-1} < z_i < z_{i+1}$, $z_i - z_{i-1} = \Delta z$ , etc?
Edit: This is the piece wise function taken directly from my code I am trying to integrate
\[Psi][z_, c_] := Piecewise[{{(z - c)/\[CapitalDelta]z + 1,
z <= c}, {-(z - c)/\[CapitalDelta]z + 1, z > c}}];
where $c$ is the center of the hat function. Here is my attempt to integrate the piece wise function
FullSimplify[
Integrate[\[Psi][z, Subscript[Z, i]], {z, Subscript[Z, i - 1],
Subscript[Z, i + 1]}],
Assumptions -> {-(Subscript[Z, i + 1] - Subscript[Z,
i ]) == -\[CapitalDelta]z,
Subscript[Z, i + 1] - Subscript[Z,
i ] == \[CapitalDelta]z, -(Subscript[Z, i] - Subscript[Z,
i - 1 ]) == -\[CapitalDelta]z,
Subscript[Z, i] - Subscript[Z, i - 1 ] == \[CapitalDelta]z}]
I do not get a usable answer. Am I doing something wrong (ie can one integrate a piece wise function)?


hator shape function is not a function. A function is supposed to take all its input from the arguments being passed to it (at least if done right). So, in yourfunctionabove, you are passing $z$ as argument, yet I see no $Z_i$ being passed in, and no $\Delta z$. So these must be global. Using global variables is not good. – Nasser Feb 13 at 4:54Piecewise? Did you know thatIntegratecan take symbolic values (such asSubscript[z,i-1]) in its integration limits? – Xerxes Feb 13 at 5:46