MathGroup Archive 1999

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

Search the Archive

Re: Newbie question about rules

  • To: mathgroup at
  • Subject: [mg21369] Re: Newbie question about rules
  • From: "Atul Sharma" <atulksharma at>
  • Date: Wed, 29 Dec 1999 23:18:43 -0500 (EST)
  • References: <84dn7q$>
  • Sender: owner-wri-mathgroup at

Plot has the Attribute HoldAll


{HoldAll, Protected}

This means that the arguement is not evaluated in advance, and your
transformation rule is not applied before the function is plotted. Wrap the
expression in Evaluate to force evaluation of the rule and you will get the
result you want:

 Plot[Evaluate[(Sin[x] /. Sin -> Cos)], {x, 0, 2 Pi}]

A. Sharma
Atul Sharma MD, FRCP(C)
Pediatric Nephrologist,
McGill University/Montreal Children's Hospital

Doug Nelson wrote in message <84dn7q$31a at>...
>Hello All,
>I just received my copy of Mathematica 4.0 and I've been reading Mastering
>I'm trying to apply a rule that changes "Sin" to "Cos" in an expression.
>seems to work fine with normal expressions, but not with a Plot function.
>This works:
>   exp2 := Abcfunc[Sin[x]]
>   exp2 /. Sin -> Cos
>out = Abcfunc[Cos[x]]
>However, the following gives me a sine wave plot in both cases:
>   exp := Plot[Sin[x], {x,0,2 Pi}]
>   exp
>out = < a sine wave plot >
>   exp /. Sin -> Cos
>out = < another sine wave plot ! >
>Why don't I get a cosine plot?
>Thanks in advance,

  • Prev by Date: Re: Number Format, Padded Form
  • Next by Date: FourierTransform[Sign[t], t, w, FourierParameters -> {1, -1}]
  • Previous by thread: Re: Newbie question about rules
  • Next by thread: Re: Newbie question about rules