Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: HoldPattern question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70076] Re: HoldPattern question
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Mon, 2 Oct 2006 00:33:54 -0400 (EDT)
  • References: <eflejf$dh6$1@smc.vnet.net>

Hi,

look what happens when you enter

{Integrate[y_, x_] -> f, Log[x] -> Exp[x]}

and you see that Integrate[y_, x_] is not evaluated
Only
{Integrate[y, x] -> f, Log[x] -> Exp[x]}

will try to evaluate the integral, while

{Integrate[y_, x] -> f, Log[x] -> Exp[x]}
{Integrate[y, x_] -> f, Log[x] -> Exp[x]}
and
{Integrate[y_, x_] -> f, Log[x] -> Exp[x]}

stay unevaluated.

Regards
   Jens

dimmechan at yahoo.com wrote:
> Hello to all.
> 
> I copied from the Help Browser.
> 
> HoldPattern[expr] is equivalent to expr for pattern matching,
> but maintains expr in an unevaluated form.
> (...)
> Example: expr /. HoldPattern[Integrate[y_, x_]] -> rhs transforms
> any subexpression of the form Integrate[y_, x_] in expr. Without
> the HoldPattern, the Integrate[y_, x_] in the rule would immediately
> be evaluated to give x_ y_, and the replacement would not work."
> 
> So based on this notes the folowing rule seems normal and well
> justified.
> 
> Hold[Integrate[a, x]] + Log[x] /. {HoldPattern[Integrate[y_, x_]] -> f,
> Log[x] -> Exp[x]}
> E^x + Hold[f]
> 
> However why the following rule (that is without HoldPattern) gives the
> same output?
> 
> Hold[Integrate[a, x]] + Log[x] /. {Integrate[y_, x_] -> f, Log[x] ->
> Exp[x]}
> E^x + Hold[f]
> 
> Using Trace I notice that even without HoldPattern surrounded
> Integrate[y_,x_] the latter is not evaluated to x_y_.
> 
> Trace[Hold[Integrate[a, x]] + Log[x] /. {Integrate[y_, x_] -> f, Log[x]
> -> Exp[x]}]
> {{{HoldForm[Integrate[y_, x_] -> f], HoldForm[Integrate[y_, x_] -> f]},
>  {{HoldForm[E^x], HoldForm[E^x]},  HoldForm[Log[x] -> E^x],
> HoldForm[Log[x] -> E^x]},
> HoldForm[{Integrate[y_, x_] -> f, Log[x] -> E^x}]},
> HoldForm[Hold[Integrate[a, x]] + Log[x] /. {Integrate[y_, x_] -> f,
> Log[x] -> E^x}], HoldForm[Hold[f] + E^x], HoldForm[E^x + Hold[f]]}
> 
> Based on the Help Browser it is very curious that this worked.
> Otherwise something I am missing.
> 
> I really appreciate some guidance.
> 
> Thanks.
> 


  • Prev by Date: Re: Smarter way to calculate middle-right terms of continued fraction partial sums
  • Next by Date: oscillatory integrals
  • Previous by thread: Re: HoldPattern question
  • Next by thread: variance of product of random variables