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: [mg45361] Re: [mg45360] why Pi is not recognized as a positive number?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sat, 3 Jan 2004 01:35:05 -0500 (EST)
  • References: <200401020923.EAA26179@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

The definition

f[x_Positive] := x + 1


means that is x is an expression with head Positive that f[x] should 
return x+1. So:


f[Positive[dog]]

1+Positive[dog]


The Head of Pi is not Positive, it is


Head[Pi]

Symbol

Presumably what you really intended was:


Clear[f]


f[x_?Positive]:=x+1


f[Pi]


1+Pi

Andrzej Kozlowski
Chiba, Japan
http://www.mimuw.edu.pl/~akoz/



On 2 Jan 2004, at 18:23, Pedro L wrote:

> {
>
> 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: why Pi is not recognized as a positive number?
  • Next by thread: Re: why Pi is not recognized as a positive number?