|
[Date Index]
[Thread Index]
[Author Index]
Re: assuming certain properties about variables
- To: mathgroup at smc.vnet.net
- Subject: [mg111437] Re: assuming certain properties about variables
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Sun, 1 Aug 2010 04:57:43 -0400 (EDT)
But once you put the restriction on the argument of f, you've told
Mathematica not to carry out the evaluation of f unless the input
supplied is actually positive.
If now t is just a symbol, then it is not positive (and not negative,
either) -- it's just a symbol. So why would you expect to be able to
tell Mathematica that it's positive? In general, Mathematica variables
don't really have types.
If it's just the particular symbol t that you want to supply to f, then
you could do this (I'm changing your function definition for clarity) --
not that you probably want SetDelayed (:=) instead of Set (=):
f[x_?Positive] := x^2
f[t] = t^2;
f[3]
9
f[t]
t^2
t = -5;
f[t]
f[-5]
f
On 7/31/2010 2:40 AM, Benjamin Hell wrote:
>
> let's say I have defined the following function:
> f[x_?Positive] = x
> Now I want to evaluate f with a variable t:
> f[t]
> As mathematica knows nothing about t, the output is f[t] instead of t.
>
> How can I tell mathematica, that t should be a positive number so that
> Positive[t] evaluates true and then f[t] evaluates to t?
> Of course this is just an example, which should present what I would
> like to know.
--
Murray Eisenberg murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
Prev by Date:
A question about string patterns
Next by Date:
Re: AxesLabel parallel to 3D axes?
Previous by thread:
Re: assuming certain properties about variables
Next by thread:
Re: assuming certain properties about variables
|