MathGroup Archive 2000

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

Search the Archive

Re: Assumptions i Mathematica...


In article <8sjjc2$fu3 at smc.vnet.net>, "Jes Hansen"
<Whammer.antispam at post9.tele.dk> 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]
f[0]
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 cspar.uah.edu 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