# How do I introduce an assumption when defining a piecewise function?

Define m as an integer. I want to specify a Piecewise function f[x,n] that takes value n^3 x^2 except when x divides m(n+1). At these values, I want f[x,n]=1.

I can't figure out how to do this because I can't work out how to include the assumption that m is an integer. I have

f[x_, n_] :=
Piecewise[{
{1, x ∈ Divisors[m (n + 1)]},
{x^2  n^(1/2), x ∉ Divisors[m (n + 1)]}
},
Assumptions -> m ∈ Integers];
table =Table[f[x, n], {x, 1, 5}, {n, 0, 5}]


This doesn't work. How do I do it?

• It's not clear what you're trying to do with m and the assumptions. Is m symbolic or numerical? If numerical, this is very simple: f[x_, n_] := Piecewise[{{n^3 *x^2, Mod[x, m (m + 1)] != 0}, {1, Mod[x, m (m + 1)] == 0}}] - but if m is symbolic, then this doesn't make any sense. Jul 13, 2020 at 16:22
• Hi @flinty. The Mod trick works if I eliminate the use of m entirely - it was just a dummy variable to stand for "integer multiples of n+1". Thank you. If you could tweak and post it as an answer, I'll tick it. Jul 13, 2020 at 18:08
• Maybe ConditionalExpression is what you need? Jul 13, 2020 at 18:43

As m is just an integer multiple of n+1, you can do this with Mod:
f[x_, n_] := Piecewise[{{1, Mod[x, n+1] == 0}}, n^3 *x^2]