# Defining a function in Mathematica without functional form [closed]

I am trying to define a function $$H(s)$$ in Mathematica, but the only restrictions/information on this function are that it is a concave and increasing in $$s$$, which is defined over the interval $$[0,S_{\text{max}}]$$. Further, $$H(s=0)=0$$ and $$H(s>0)=h>0$$. Since the exact form isn't specified, I'm not sure how to use the := command here.

• There isn't a way to do this without assuming some kind of form. I think it would help to know why you needed to define such an abstract function. Jun 12, 2021 at 10:30
• This looks like an XY problem to me. It is not answerable unless you explain what you are actually trying to do. Jun 12, 2021 at 12:06
• Mathematica is an expression rewriting system. := simply tells it to rewrite anything that matches the left hand side using the right hand side. Jun 12, 2021 at 13:22
• Is h a constant? If yes, H is a step function: H= Piecewise[{{h, # > 0}}, 0] & where h is the constant value. Jun 12, 2021 at 19:53

Perhaps something like this?

H = 0;
H[x_] := ConditionalExpression[h[x], h[x] > 0 && x > 0];
(* Alternatively, you can do *)
H[x_] := ConditionalExpression[#, # > 0 && x > 0] &@h[x];


Let's try this with:

h[x_] = (x + 5)(x - 5);


There are 5 possible cases to test:

$$H(s = 0)$$

H (* Outputs 0 *)


$$H(s < 0) = h > 0$$

H[-6] (* Outputs Undefined *)


$$H(s < 0) = h \leq 0$$

H[-1] (* Outputs Undefined *)
H[-5] (* Outputs Undefined *)


$$H(s > 0) = h \leq 0$$

H (* Outputs Undefined *)
H (* Outputs Undefined *)


$$H(s > 0) = h > 0$$

H (* Outputs 11 *)


#### Unknown $$h(x)$$

If you don't have a definition for $$h(x)$$, you could define an additional function which simplifies the conditional statement depending on the constraints on $$h(x)$$ by using Assumptions:

f[x_] := Simplify[H[x]];
f[x_, ineq_] := Simplify[H[x], Assumptions -> {ineq /. h -> h[x]}];


Test cases:

$$H(s = 0)$$

f (* Outputs 0 *)
f (* Outputs unsimplified conditional expression: ConditionalExpression[h, h > 0] *)


$$H(s < 0) = h > 0$$

f[-6, h > 0] (* Outputs Undefined *)
f[-6, h > 7] (* Outputs Undefined *)


$$H(s < 0) = h \leq 0$$

f[-1, h <= 0] (* Outputs Undefined *)
f[-5, h <= 0]  (* Outputs Undefined *)
f[-5, -3 < h < -1]  (* Outputs Undefined *)


$$H(s > 0) = h \leq 0$$

f[1, h <= 0]  (* Outputs Undefined *)
f[5, h <= 0] (* Outputs Undefined *)
f[5, -3 < h < -1] (* Outputs Undefined *)


$$H(s > 0) = h > 0$$

f[6, h > 0] (* Outputs h *)
f[6, h > 7] (* Outputs h *)