2
$\begingroup$

This question already has an answer here:

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$

marked as duplicate by m_goldberg, user9660, Öskå, MarcoB, Bob Hanlon Jan 8 '16 at 14:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ Have a look at Piecewise. $\endgroup$ – Sascha Jan 7 '16 at 13:25
  • 6
    $\begingroup$ Hm... I thought this seemed familiar. I should have searched first. Proposed duplicates: (30312), (72325) $\endgroup$ – Mr.Wizard Jan 7 '16 at 13:27
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.