When I use the Mathematica to obtain the integral of the symbolic expression, the output result seems not to be applied for all the cases. For example I use the code
Integrate[Cos[m Pi x] Cos[n Pi x], {x, 0, 1}, Assumptions -> m \[Element] Integers && n \[Element] Integers]
to calculate the integral $ $ \int\cos (m\pi x)\cos (n \pi x)\,\mathrm{d}x$ $
The output is $ $ \frac{m \sin (\pi m) \cos (\pi n)-n \cos (\pi m) \sin (\pi n)}{\pi m^2-\pi n^2}$ $
I define a function with respect to the variables $ m$ and $ n$
f[m_, n_] := ( m Cos[n \[Pi]] Sin[m \[Pi]] - n Cos[m \[Pi]] Sin[n \[Pi]])/( m^2 \[Pi] - n^2 \[Pi]);
Obviously, the function $ f(m,n)$ is only applicable for the cases $ m\neq n$ . Some assumptions are made during the calculation by Mathematica. Now I want to obatin the unified expressions for the integral, for example, The result can be a conditional expression.