Message Boards Message Boards

0
|
273 Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Cannot simplify the sum of logarithms

Posted 4 days ago

From Mathematica 5.2 to Mathematica 14.1 and you cannot simplify the sum of logarithms

POSTED BY: Gennaro Flowers
4 Replies

There is no such command in the Mathematica 14.1 help documentation.

Where can I learn more about this type of command?

-FullSimplify [- #] &]

Thank you for your help...

POSTED BY: Gennaro Flowers

TVM Gianluca...

POSTED BY: Gennaro Flowers

Do you want to simplify or combine the log terms? Simplify is a discrete global minimization solver than searches for an expression that minimizes a complexity function. (1) Your desired output may not be less complex than the input, in which case the logs will not be combined. (2) The simplification algorithm may get stuck in a relative minimum and miss the desired output.

The original log terms have a complexity measure of 58:

Assuming[
 0 <= Subscript[x, 1] <= a && 0 <= Subscript[x, 2] <= a && 
  Subscript[x, 2] > Subscript[x, 1] && 0 <= Subscript[y, 1] <= b && 
  0 <= Subscript[y, 2] <= b && Subscript[y, 2] > Subscript[y, 1] && 
  a > 0 && b > 0 && a > b && 1 + a^2/b^2 > 0 && 1 + b^2/a^2 > 0 && 
  a^2 + b^2 > 0,
 FullSimplify[
  -((b^2 Log[1 + a^2/b^2])/(12 a^2)) + 1/2 Log[a^2 + b^2] - (
   a^2 Log[1 + b^2/a^2])/(12 b^2),
  TransformationFunctions -> {Automatic, 
    FullSimplify[# /. log_Log :> Together /@ log] &}]
 ]
(*  1/12 (-((b^2 Log[1 + a^2/b^2])/a^2) + 6 Log[a^2 + b^2] - (a^2 Log[1 + b^2/a^2])/b^2)  *)

% // Simplify`SimplifyCount
(*  58  *)

If we add a transformation that expands and simplifies in one step, it gets out of a local minimum to a slightly less complex expression:

Assuming[
 0 <= Subscript[x, 1] <= a && 0 <= Subscript[x, 2] <= a && 
  Subscript[x, 2] > Subscript[x, 1] && 0 <= Subscript[y, 1] <= b && 
  0 <= Subscript[y, 2] <= b && Subscript[y, 2] > Subscript[y, 1] && 
  a > 0 && b > 0 && a > b && 1 + a^2/b^2 > 0 && 1 + b^2/a^2 > 0 && 
  a^2 + b^2 > 0,
 FullSimplify[
  -((b^2 Log[1 + a^2/b^2])/(12 a^2)) + 1/2 Log[a^2 + b^2] - (
   a^2 Log[1 + b^2/a^2])/(12 b^2),
  TransformationFunctions -> {Automatic, 
    Simplify[# /. log_Log :> Echo@PowerExpand[Together /@ log]] &}]
 ]
(*  (2 a^4 Log[a] + 2 b^4 Log[b] - (a^4 - 6 a^2 b^2 + b^4) Log[a^2 + b^2])/(12 a^2 b^2)  *)

% // Simplify`SimplifyCount
(*  55  *)

Generally, one should be careful about using PowerExpand. It assumes everything is a positive real. It is not used by Simplify or FullSimplify, I think. Some of the transformations it makes may be carried out by them, if suitable assumptions are given (as they are in this case). However, expanding the expression makes it more complex. The step may be rejected if it does not combine with other terms to become simpler right away. Wrapping the replacement above with Simplify[] helps to get over this hump, since steps will be rejected only if they are more complex than the already expanded expression.

To combine logs, one can do manually the following (taking responsibility for the validity of the steps on oneself, namely that the arguments to Log[] are positive and have positive factors):

-((b^2 Log[1 + a^2/b^2])/(12 a^2)) + 1/2 Log[a^2 + b^2] - (a^2 Log[1 + b^2/a^2])/(12 b^2) /.
  k_*Log[u_] :> Log[u^k] /.
 HoldPattern[Plus[a__Log]] :> 
  Log[Times @@ (First /@ Hold[a]) /. t_Plus :> Together[t] // PowerExpand]
(*  Log[a^(a^2/(6 b^2)) b^(b^2/(6 a^2)) (a^2 + b^2)^(1/2 - a^2/(12 b^2) - b^2/(12 a^2))]  *)
POSTED BY: Michael Rogers

This does it:

Collect[NU, {a^4, b^4}, -FullSimplify[-#] &]

It is often difficult to bring a complicated expression into the exact form we wish.

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

Group Abstract Group Abstract