Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6811 > unrolled thread
| Started by | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| First post | 2011-11-29 12:10 +0000 |
| Last post | 2011-11-30 08:21 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Problem with Patterns and Integrate Bob Hanlon <hanlonr357@gmail.com> - 2011-11-29 12:10 +0000
Re: Problem with Patterns and Integrate Jack McInerney <ejmcinerney@gmail.com> - 2011-11-30 08:21 +0000
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Date | 2011-11-29 12:10 +0000 |
| Subject | Re: Problem with Patterns and Integrate |
| Message-ID | <jb2i4f$5ho$1@smc.vnet.net> |
Compare Rule with RuleDelayed func -> Integrate[func, x] func -> func*x func :> Integrate[func, x] func :> Integrate[func, x] expr = D[f[x], x]; expr /. func_ :> Integrate[func, x] f[x] Bob Hanlon On Mon, Nov 28, 2011 at 5:53 AM, Jack McInerney <ejmcinerney@gmail.com> 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? > > Jack >
[toc] | [next] | [standalone]
| From | Jack McInerney <ejmcinerney@gmail.com> |
|---|---|
| Date | 2011-11-30 08:21 +0000 |
| Message-ID | <jb4p2s$gov$1@smc.vnet.net> |
| In reply to | #6811 |
On Nov 29, 4:10 am, Bob Hanlon <hanlonr...@gmail.com> wrote: > Compare Rule with RuleDelayed > > func -> Integrate[func, x] > > func -> func*x > > func :> Integrate[func, x] > > func :> Integrate[func, x] > > expr = D[f[x], x]; > > expr /. func_ :> Integrate[func, x] > > f[x] > > Bob Hanlon > > > > > > > > On Mon, Nov 28, 2011 at 5:53 AM, Jack McInerney <ejmciner...@gmail.com> 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? > > > Jack Thanks everyone for the suggestions. I have never been that clear on when I should use RuleDelayed versus Rule. The distinction is much clearer now. Jack
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web