Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: why Pi is not recognized as a positive number?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45369] Re: why Pi is not recognized as a positive number?
  • From: drbob at bigfoot.com (Bobby R. Treat)
  • Date: Sat, 3 Jan 2004 01:35:11 -0500 (EST)
  • References: <bt3e0s$plb$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

You left out the question mark:

f[x_?Positive] := x + 1

x_Positive matches expressions with Positive as Head, so for instance:

Clear@f
f[x_Positive]:=x+1 
f@Positive[x]

1+Positive[x]

Bobby

Pedro L <pedrito6 at softhome.net> wrote in message news:<bt3e0s$plb$1 at smc.vnet.net>...
> I wanted to define a function for the positive numbers. But I discovered
>   something "strange" with Mathematica.
> 
>   Could you help me with this?
> 
>   Thanks in advance.
> 
>   Peter L  (Spain)
> 
> 
> 
> {
> 
> Cell[CellGroupData[{
> Cell[BoxData["$Version"], "Input",
>   CellLabel->"In[1]:="],
> 
> Cell[BoxData["\<\"5.0 for Microsoft Windows (June 11, 2003)\"\>"], \
> "Output",
>   CellLabel->"Out[1]="]
> }, Open  ]],
> 
> Cell[BoxData[
>     RowBox[{
>       RowBox[{"f", "[", "x_Positive", "]"}], ":=",
>       RowBox[{"x", "+", "1", "  "}]}]], "Input",
>   CellLabel->"In[2]:="],
> 
> Cell[CellGroupData[{
> 
> Cell[BoxData[
>     RowBox[{"Positive", "[", "Pi", "]"}]], "Input",
>   CellLabel->"In[3]:="],
> 
> Cell[BoxData["True"], "Output",
>   CellLabel->"Out[3]="]
> }, Open  ]],
> 
> Cell[CellGroupData[{
> 
> Cell[BoxData[
>     RowBox[{"f", "[", "Pi", "]"}]], "Input",
>   CellLabel->"In[4]:="],
> 
> Cell[BoxData[
>     RowBox[{"f", "[", "\[Pi]", "]"}]], "Output",
>   CellLabel->"Out[4]="]
> }, Open  ]],
> 
> Cell[BoxData[
>     RowBox[{"Remove", "[", "f", "]"}]], "Input",
>   CellLabel->"In[5]:="],
> 
> Cell[BoxData[
>     RowBox[{
>       RowBox[{"f", "[",
>         RowBox[{"x_", " ", "/;", " ",
>           RowBox[{"x", ">", "0"}]}], "]"}], ":=",
>       RowBox[{"x", "+", "1"}]}]], "Input",
>   CellLabel->"In[6]:="],
> 
> Cell[CellGroupData[{
> 
> Cell[BoxData[
>     RowBox[{"f", "[", "Pi", "]"}]], "Input",
>   CellLabel->"In[7]:="],
> 
> Cell[BoxData[
>     RowBox[{"1", "+", "\[Pi]"}]], "Output",
> 
>   CellLabel->"Out[7]="]
> }, Open  ]],
> 
> Cell[BoxData[
>     RowBox[{"Remove", "[", "f", "]"}]], "Input",
>   CellLabel->"In[8]:="]
> }


  • Prev by Date: Re: why Pi is not recognized as a positive number?
  • Next by Date: Re: why Pi is not recognized as a positive number?
  • Previous by thread: RE: why Pi is not recognized as a positive number?
  • Next by thread: Re: why Pi is not recognized as a positive number?