Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6806 > unrolled thread

Re: Problem with Patterns and Integrate

Started byBill Rowe <readnews@sbcglobal.net>
First post2011-11-29 12:08 +0000
Last post2011-11-29 12:08 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Problem with Patterns and Integrate Bill Rowe <readnews@sbcglobal.net> - 2011-11-29 12:08 +0000

#6806 — Re: Problem with Patterns and Integrate

FromBill Rowe <readnews@sbcglobal.net>
Date2011-11-29 12:08 +0000
SubjectRe: Problem with Patterns and Integrate
Message-ID<jb2hvk$5fc$1@smc.vnet.net>
On 11/28/11 at 5:53 AM, ejmcinerney@gmail.com (Jack McInerney) wrote:

>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
>answer:

>In[169]:= expr /. func_ ->  Integrate[func,x] Out[169]= x
>f=E2=80=B2[x]

>Any thoughts as to what I am doing wrong?

Yes, for this application you need to use RuleDelayed (:>)
instead of what you did. The key is when the rule is evaluated.
When you use -> the Integrate[func,x] is evaluated immediately
to func x and the replacement rule is equivalent to func_->func x.

Instead, if you use RuleDelayed (:>) evaluation of
Integrate[func,x] takes place after f'[x] is substituted for
func and you get the result you were looking for.

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web