Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Rule replacement doesn't work after NDSolve?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124004] Re: Rule replacement doesn't work after NDSolve?
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Thu, 5 Jan 2012 05:56:05 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

On 1/4/12 at 5:03 AM, g.crlsn at gmail.com (gac) wrote:

>Thanks very much for the reply.  Your suggestion works as you say,
>but I'm still confused.  I thought that the replacement is for the
>function, not the arguments.

Replacement rules are not limited to either functions or
arguments. For example, I can do:

In[3]:= Cos[y] /. Cos -> Sin

Out[3]= Sin[y]

replacing the Cos function with Sin or

In[4]:= Cos[y] /. y -> 2 x

Out[4]= Cos[2*x]

replacing the argument y with 2 x

The thing to keep in mind with replacement rules is a litteral
match is made between the FullForm of the expression you want to
operate on and the left hand side of the replacement rule. For
example, this does nothing:

In[5]:= -2 I /. I -> -I

Out[5]= -2*I

since

In[6]:= FullForm[-2 I]

Out[6]//FullForm= Complex[0,-2]

and there is nothing to match the left hand side of the
replacement rule




  • Prev by Date: Re: Rule replacement doesn't work after NDSolve?
  • Next by Date: How to plot divergence of gradient as contour plot
  • Previous by thread: Re: Rule replacement doesn't work after NDSolve?
  • Next by thread: Re: Rule replacement doesn't work after NDSolve?