Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.3K Views
|
6 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Why "Collect" does not work?

Posted 10 years ago

Hey guys:

I am wondering why two Ln functions does not combine together in my case?

enter image description here

It also takes me quite a long time to run this program. Is there any way to improve this?

Attachments:
POSTED BY: Zhehao Zhang
6 Replies

Well, thanks...

POSTED BY: Gianluca Gorni

FullSimplify does not always recognize that two logs can be combined into one. You can write your own replacement rule, however:

combineLogs = ((a_*Log[b_] + c_*Log[d_]) /; a + c == 0) :> 
   a*Log[b/d];
With[{\[Lambda] = 1/100, \[Delta] = 1/100},
 result1 = 
  1 + (\[Lambda]*s)/2 (1 - s*Exp[-\[Delta]*t])^(\[Lambda]/\[Delta])
     Integrate[
     E^(-\[Delta]*
       v) *(1 - s*Exp[-\[Delta]*v])^(-(\[Lambda]/\[Delta])), {v, 0, 
      t}]; result2 = result1 /. combineLogs;
 Collect[result2, _Log, Simplify]]

Pay attention to the arguments of Log, which can become negative in Mathematica's integration results.

POSTED BY: Gianluca Gorni
Posted 10 years ago

I would like to say I would really like to be student in your Mathematica lecture. What a pleasure!

POSTED BY: Zhehao Zhang

Collect with a pattern _Log will only collect Logs that have the same argument. It will not collect together Log[1 - s] with Log[E^(t/100) - s]. One way to obtain that is forcing FullSimplify to combine the logs, by giving it the assumptions that the arguments are positive:

FullSimplify[
 1 + 1/200 (-1 + E^(-t/100) s) t + 
  1/2 (-1 + E^(-t/100) s) Log[1 - s] + 
  1/2 (1 - E^(-t/100) s) Log[E^(t/100) - s], 
 1 - s > 0 && E^(t/100) - s > 0]

and then collect the only remaining Log.

POSTED BY: Gianluca Gorni
Posted 10 years ago

Hi guys:

Sorry for that. I forgot to present here. There are two codes in the notebook and you can see "collect" function does work in the first case.The first coding is designed by Gianluca Gorni, and the second one is modified by me for another equation.

enter image description here

Code is in the attachment.

Attachments:
POSTED BY: Zhehao Zhang

Hi,

It would be very useful if you used the code window so that anyone who wants to help can just copy your code instead of having to type everything in again.

Also, I would expect this code to run a little while and it is not quite clear whether combining the Logs would actually make things simpler. It also depends on the definition of "simpler".

Could you copy the code into a code window and not use a screen shot for this, please?

Cheers,

Marco

@Moderation Team sorry your reply was somehow not appearing when I was typing mine. I did not mean to simply repeat what you wrote. Sorry.

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard