Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Re: assuming certain properties about variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111498] Re: Re: assuming certain properties about variables
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Tue, 3 Aug 2010 06:39:58 -0400 (EDT)

t /: Positive[t] = True;

f[x_?Positive] = x;

f /@ {-2, 0, 2, t}

{f[-2], f[0], 2, t}


Bob Hanlon

---- Bill Rowe <readnews at sbcglobal.net> wrote: 

=============
On 7/31/10 at 2:40 AM, hell at exoneon.de (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?

Basically, you can't unless you assign a positive value to t.

The pattern _?PositiveQ only matches positive numbers. A
variable with no assigned values will not match this pattern. If
you want your function to evaluate to a symbolic expression
given variables with no assigned values as arguments, you cannot
use a pattern that places restrictions on the arguments those
variables are used for. Such restrictive patterns will always
fail to match a variable with no assigned values. Consequently,
Mathematica will always return the function unevaluated.



  • Prev by Date: StringForm v.s Row
  • Next by Date: Re: Surprising FullSimplify result
  • Previous by thread: Re: assuming certain properties about variables
  • Next by thread: Re: assuming certain properties about variables