MathGroup Archive 2002

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

Search the Archive

Re: Change of Variables


Hi,

what is the difference between Replace[] and ReplaceAll[] ?

??ReplaceAll

"expr /. rules applies a rule or list of rules in an attempt to
transform \
each subpart of an expression expr"

While 

??Replace

"Replace[expr, rules] applies a rule or list of rules in an attempt to \
transform the entire expression expr. Replace[expr, rules, levelspec]
applies \
rules to parts of expr specified by levelspec."

And

test^2 /. v -> c*beta

gives 

beta^2

and 

2*Pi*c^2*h/lambda^5*(E^(h*c/(lambda*k*T)) - 1)^(-1) /. 
  T -> h*c/(lambda*k x)

gives

(2*c^2*h*Pi)/((-1 + E^x)*lambda^5)

Regards
  Jens

John S wrote:
> 
> Hello,
> 
> I would greatly appreciate any help with the following problem.  I am trying
> to perform a change of variable in a function/definition so that I can
> integrate it.  In particular, I want to take Planck's Radiation Law:
> 
> planck=2*Pi*c^2*h/lambda^5*(E^(h*c/(lambda*k*T))-1)^(-1)
> 
> and substitute x=h*c/(lambda*k*T) and integrate wrt lambda from 0 to
> infinity.  I tried using replace, but that does not seem to try to
> manipulate the function in terms of x, but simply seek out the replacement,
> and if it exists, perform it.
> 
> An even simpler example is the following:
> 
> test=v/c
> Replace[test^2,v/c -> beta]
> 
> does not yield beta^2, but rather v^2/c^2.
> 
> Again, any and all help would be greatly appreciated.


  • Prev by Date: Re: memoizing function again
  • Next by Date: Re: Change of Variables
  • Previous by thread: Re: Change of Variables
  • Next by thread: NestWhile