Re: Problem with Patterns and Integrate

• To: mathgroup at smc.vnet.net
• Subject: [mg123244] Re: Problem with Patterns and Integrate
• From: A Retey <awnl at gmx-topmail.de>
• Date: Tue, 29 Nov 2011 07:03:14 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <javpbs\$jbk\$1@smc.vnet.net>

```Am 28.11.2011 11:55, schrieb Jack McInerney:
> There is something about using patterns that I don't understand, and
> am hoping someone can shed some light.  Here is an example of my
> problem.  Say I have a function f[x] and I take the derivative of it.
> I can then integrate it and get f[x] back:
>
>
> In[167]:= expr = D[ f[x], x ]
> Out[167]= f=E2=80=B2[x]
>
> In[168]:= Integrate[expr, x]
> Out[168]= f[x]
>
> If I use a ReplaceAll and a pattern to do the integration, the
> Integrate function treats f'[x] as a constant and returns the wrong
>
> In[169]:= expr /. func_ ->   Integrate[func,x]
> Out[169]= x f=E2=80=B2[x]
>
> Any thoughts as to what I am doing wrong?

that's a good example for why there is RuleDelayed (:>) and not only
Rule (->)

expr /. func_ :> Integrate[func, x]

does what you expect. With Rule the Integration is done before the match
is inserted, that is you are actually doing the replacement

func_ -> func x

hth,

albert

```

• Prev by Date: Re: Problem with Patterns and Integrate
• Next by Date: Re: Problem with Patterns and Integrate
• Previous by thread: Re: Problem with Patterns and Integrate
• Next by thread: Re: Problem with Patterns and Integrate