Should be an easy question. How can I define a function which gets only integers in a form that I can use to find max and min for instance?
Example:
Find the Max of the expression
(3 n + 4)/(2 n + 1)
where n ∈ Integers
Diophantine problems are tough and there is no silver bullet. In your example this works:
i = IntegerPart;
sol = NMaximize[{(3 i@ n + 4)/(2 i@n + 1), n > 1}, n];
i@n /. sol[[2]]
(* 1 *)
Bounding the range of n resolves the issue with Maximize
Maximize[{(3 n + 4)/(2 n + 1), Element[n, Integers], -100 <= n <= 100}, n]
{4, {n -> 0}}
Or,
Maximize[{(3 n + 4)/(2 n + 1), -100 <= n <= 100}, n, Integers]
{4, {n -> 0}}
Any large value for the range bound will work since
Limit[(3 n + 4)/(2 n + 1), n -> #] & /@ {Infinity, -Infinity}
{3/2, 3/2}
DiscretePlot[
(3 n + 4)/(2 n + 1),
{n, -10, 10},
PlotRange -> All]
f[x_Integer] := x
?f[1]
will work whilef[1.]
won't. $\endgroup$f[x_Integer]:=...
but that won't help you to solve diophantine eqs in the general case. Please show what kind of problems you need to solve $\endgroup$i = IntegerPart; sol = NMaximize[{(3 i@ n + 4)/(2 i@n + 1), n > 1}, n]; i@n /. sol[[2]]
$\endgroup$