|
[Date Index]
[Thread Index]
[Author Index]
RE: why Pi is not recognized as a positive number?
- To: mathgroup at smc.vnet.net
- Subject: [mg45364] RE: [mg45360] why Pi is not recognized as a positive number?
- From: "David Park" <djmp at earthlink.net>
- Date: Sat, 3 Jan 2004 01:35:07 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Peter,
x_Positive is the pattern for an expression that has the Head Positive - not
what your want. You want...
f[x_?Positive] := x + 1
f[Pi]
1 + Pi
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
From: Pedro L [mailto:pedrito6 at softhome.net]
To: mathgroup 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: Function interpolation
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?
|