Re: Assumptions i Mathematica...
- To: mathgroup at smc.vnet.net
- Subject: [mg25700] Re: Assumptions i Mathematica...
- From: Brian Higgins <bghiggins at ucdavis.edu>
- Date: Thu, 19 Oct 2000 04:35:26 -0400 (EDT)
- References: <8sjjc2$fu3@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Jes, One way to do this is to use the Condition function in the definition of f(x): i.e. f[x_/;x>0]:=x The above function will only evaluate the RHS if x>0. In[80]:=f[.2] Out[80]=0.2 In[81]:=f[-2] Out[81]=f[-2] You can also add an additional definition for all other values f[x/;<0]:=0 The down side with using this approach is that you cannot do many symbolic operations on your function, e.g. differentiate etc. An alternative method that gives you more flexibilitry is to use the UnitStep function In[89]:=f[x_] := x^3UnitStep[x] In[91]:=D[f[x], x] Out[91]=\!\(x\^3\ DiracDelta[x] + 3\ x\^2\ UnitStep[x]\) Cheers, Brian 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 > > Sent via Deja.com http://www.deja.com/ Before you buy.