I need a function which could return a constant for all positive integers and another constant for rest of positive real numbers.

In piecewise function form, it is like this:-

$ f(n) = \begin{cases} constant1, & \text{if $n \in z^+$} \\ constant2, & \text{if $n \in R^+ \text{&} \notin z^+$ } \end{cases} $

This sine function returns $ \space {0} \space \forall{\space{x}} \in z^+ $

$\sin({{\pi}x})$, but it doesn't return another constant value for all positive non-integers.

Or say I need a sort function which can do implicit case handling, purely with operations and such things.

  • 1
    $\begingroup$ Why is piecewise form not satisfactory? It is a perfectly valid way to define a function. $\endgroup$
    – FXV
    Jul 6 '19 at 8:16
  • $\begingroup$ @FXV I know, but i am interested in finding such function. Also, there are some reasons for doing this(Like building more functions over that which doesn't require human to check again and again whether its integer or not.) $\endgroup$
    – Vicrobot
    Jul 6 '19 at 8:18
  • 3
    $\begingroup$ I think your formulation is not correct. "Find a function" means to exihbit a function, the way you express it is entirely up to you - so piecewise constant is perfectly valid. If what you want is to find an expression for this function using a set of standard functions, then you should define which set of standard functions to start with. $\endgroup$
    – FXV
    Jul 6 '19 at 8:29
  • $\begingroup$ How about $\operatorname{sgn} (|\sin (\pi x)|)$? $\endgroup$ Jul 6 '19 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.