MathGroup Archive 2000

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

Search the Archive

Re: Assumptions i Mathematica...

  • To: mathgroup at
  • Subject: [mg25724] Re: Assumptions i Mathematica...
  • From: leko at (J. Leko)
  • Date: Thu, 19 Oct 2000 04:35:50 -0400 (EDT)
  • References: <8sjjc2$>
  • Sender: owner-wri-mathgroup at

In article <8sjjc2$fu3 at>, "Jes Hansen"
<Whammer.antispam at> wrote:

> Hi, I'm quite new at this, and I havn't been able to figure out how to tell
> Mathematica to assume that a variable, x, is positive. I have a function,
> f(x), where I only want to consider positive values of x. I'm using version
> 3.0.
> Regards
> Jes

If you have a function f with a dependent variable x which you want to
always be positive, then what you need to do is to conduct a pattern test.
Check section 2.3.5, "Putting Constraints on Patterns", in the Mathematica
book for more information.

Here's an example:

In[14]:= f[x_?Positive] := x + 1

In[21]:= f[1]

Out[21]= 2
Out[22]= f[0]
Out[23]= f[-1]

Notice that when x is positive, the function is evaluated, otherwise the
function expression is returned.

J. Leko

Please e-mail replies to leko*j at and remove the *

  • Prev by Date: Re: Assumptions i Mathematica...
  • Next by Date: Re: AxesLabel for ContourPlot
  • Previous by thread: Re: Assumptions i Mathematica...
  • Next by thread: AxesLabel for ContourPlot