       Re: assuming certain properties about variables

• To: mathgroup at smc.vnet.net
• Subject: [mg111465] Re: assuming certain properties about variables
• From: Christoph Lhotka <christoph.lhotka at univie.ac.at>
• Date: Mon, 2 Aug 2010 07:05:43 -0400 (EDT)

```On 01/08/2010 10:58, Bill Rowe 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

hello,

I do not agree on that point, saying that one has to assign a value to t
to make the function f work:

f[t_] := If[MemberQ[{\$Assumptions}, t > 0], t, -t]

Assuming[t > 0, f[t]]

which will return t, if t is assumed to be positive and -t otherwise.

best regards,

Christoph

```

• Prev by Date: Re: Cannot load example data
• Next by Date: Re: discretized Laplacian or linear inverse problem with extremely