Hey guys:
I am wondering why two Ln functions does not combine together in my case?
It also takes me quite a long time to run this program. Is there any way to improve this?
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.
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.
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.
I would like to say I would really like to be student in your Mathematica lecture. What a pleasure!
Well, thanks…