# [✓] Provide a default value for x in f[x_?NumericQ]:=...?

GROUPS:
 Ulrich Mutze 1 Vote If the restriction for x is expressed by specifying the Head, there is no problem: e.g. f[x_Complex : 1+ I] := .... . If the restriction is expressed by a predicate I did not find a way to set a default value for the argument. Who can help?
12 days ago
5 Replies
 J. M. 6 Votes In this case, you will want the expanded form of Pattern[] to account for both PatternTest[] and Optional[]. Thus: f[x : (_?NumericQ) : Pi] := Sin[x] {f[], f[Pi/2], f[y]} {0, 1, f[y]} 
11 days ago
 Great help! Thanks a lot