MathGroup Archive 2008

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

Search the Archive

Re: Mathematica question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg85064] Re: [mg85056] Mathematica question
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 27 Jan 2008 05:39:28 -0500 (EST)
  • Reply-to: hanlonr at cox.net

expr = {m * Log[a] + m * Log[b], m * Log[a] - m * Log[b]};

Use Simplify

expr // Simplify

{m*(Log[a] + Log[b]), m*(Log[a] - Log[b])}

Alternatively, note that since

m * Log[a] - m * Log[b] // FullForm

Plus[Times[m,Log[a]],Times[-1,m,Log[b]]]

You should use either

expr /. {(m_)*Log[a_] + (m_)*Log[b_] -> m *(Log[a] + Log[b]), 
  Plus[Times[m_, Log[a_]], Times[-1, m_, Log[b_]]] -> 
       m*(Log[a] - Log[b])}

{m*(Log[a] + Log[b]), m*(Log[a] - Log[b])}

or

expr /. {m_ * Log[a_] + m_ * Log[b_] -> m *(Log[a] + Log[b]), 
  m_ * Log[a_] + Times[-1, m_, Log[b_]] -> 
       m*(Log[a] - Log[b])}

{m*(Log[a] + Log[b]), m*(Log[a] - Log[b])}


Bob Hanlon

---- None None <worm9056 at yahoo.com> wrote: 
> 
> Dear Sir
> 
> I have a problem in mathematica. Consider the following function
> definition.  EC1[expr_]:=expr//.{m_ Log[a_]+m_Log[ b_]=A6 m (Log[a]+Log[ b]),m_ Log[a_]-m_Log[ b_]=A6 m (Log[a]-Log[ b])}
> It works fine for "m Log[a]+mLog[b]", but it does not work for
> "m Log[a]-m Log[b]". 
> 
> Kindly guide me on resolving this issue.
> 
> Kind regards  
> 



  • Prev by Date: Re: Better way to write this
  • Next by Date: Re: Better way to write this
  • Previous by thread: Re: Mathematica question
  • Next by thread: Legend Style