Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Problems with easy simplifications

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54175] Re: [mg54143] Problems with easy simplifications
  • From: Chris Chiasson <chris.chiasson at gmail.com>
  • Date: Sat, 12 Feb 2005 01:58:04 -0500 (EST)
  • References: <200502110834.DAA09274@smc.vnet.net>
  • Reply-to: Chris Chiasson <chris.chiasson at gmail.com>
  • Sender: owner-wri-mathgroup at wolfram.com

The problem is that there is a type of hold on the function that isn't
showing itself. I found it when I checked the attributes of the If
command.

The following commands do what you want globally, but I haven't been
able to selectively mute the HoldRest.

H[x_, a_, b_] = If[x < a, a + b, a - b]

If[x < a, a + b, a - b]

Attributes[If]

{HoldRest, Protected}

Unprotect[If]

{If}

ClearAttributes[If, HoldRest]



H[x, 0, 0]

If[x < 0, 0, 0]



On Fri, 11 Feb 2005 03:34:47 -0500 (EST), Antonio González
<gonferh2o at esi.us.es> wrote:
> I have found some weird behaviors of Mathematica (5.0) related to the
> simplifications of easy expressions.
> 
> Take, for instance the function
> 
>    H[x_, a_, b_] = If[x < a, a + b, a - b]
> 
> If I try now to evaluate
> 
>    H[x,0,0]
> 
> the result
> 
>   If[x < 0, 0 + 0, 0 - 0]
> 
> (the values of a and b are irrelevat, a similar result is obtained, for
> instance, with a=1, b= 2, or any integer, real or complex values). I
> cannot force (at least in a simple way) Mathematica to make the addition
> or the substraction. The action of Simplify or FullSimplify leaves the
> expression unchanged while a Map of Simplify
> 
>    MapAll[Simplify, H[x, 0, 0]]
> 
> produces
> 
>    If[x < 0,
>      Simplify[Simplify[0] + Simplify[0]], Simplify[Simplify[
>        0] + Simplify[Simplify[-1] Simplify[0]]]]
> 
> Something even worse happens if a use values already defined. For instance
> 
>    c = 0; d = 0; H[x_] = If[x < c, c + d, c - d]
> 
> produces
> 
>   If[x < 0, c + d, c - d]
> 
> In this case, the addition is not necessary.
> 
>    c = 0; d = 0; H[x_] = If[x < c, c, d]
> 
> leads to
> 
>   If[x < 0, c, d]
> 
> Similar problems arise using the function Which.
> 
> Any explanation or help with this malfunction would be welcome.
> 
> --
> 
>    Antonio
> 
> (Eliminar el agua para responder por e-mail - Remove water to reply by
> e-mail)
> 
> 


-- 
Chris Chiasson
Kettering University
Mechanical Engineering
Graduate Student
1 810 265 3161


  • Prev by Date: Re: Problems with easy simplifications
  • Next by Date: Re: Re: how to have a blind factorization of a polinomial?
  • Previous by thread: Problems with easy simplifications
  • Next by thread: Re: Problems with easy simplifications