2
$\begingroup$

Let's say you have a function

$ f(t) = t, \text{ for } t > 0,$

declared in Mathematica as

f[t_?(# > 0 &)] := t;

How do you print that function?

I have tried multiple options like

f[t]
FunctionExpand[f[t], t > 0]
f[t] /; t > 0

These return

f[t]
f[t]
f[t] /; t > 0

and not

t

or

t /; t > 0

Which is what I want.

$\endgroup$
2
  • 1
    $\begingroup$ Have a look at Piecewise. $\endgroup$
    – Sascha
    Commented Jan 7, 2016 at 13:25
  • 6
    $\begingroup$ Hm... I thought this seemed familiar. I should have searched first. Proposed duplicates: (30312), (72325) $\endgroup$
    – Mr.Wizard
    Commented Jan 7, 2016 at 13:27

1 Answer 1

4
$\begingroup$

If possible I would define the function using Simplify or Refine, then use Assuming:

f[t_] /; Refine[t > 0] := t;

Assuming[t > 0, f[t]]
t
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.