1
$\begingroup$

I'm writing a function to produce a more readable version of output which consists mainly of Plus[seq__] where seq__ matches-for the most part, but not exclusively- stuff like Times[-1,Log[f_[t_]]] or Log[f_[t_]]. The desired function has attribute Listable, so far.

I am trying to make it distribute over addition. Is something like the following code a proper way to go about it?

Unprotect[Plus];

prettyfy[Plus[x_, y___]] ^:= Total[prettyfy[{x, y}]]

Protect[Plus];
$\endgroup$
  • 11
    $\begingroup$ It is very risky to modify the basic arithmetic operations. Consider associating the definitions with your prettyfy instead. $\endgroup$ – J. M.'s discontentment Oct 12 '16 at 15:49
  • 7
    $\begingroup$ Distribution can be done with prettyfy[p_Plus] := prettyfy /@ p $\endgroup$ – Marius Ladegård Meyer Oct 12 '16 at 15:55
-2
$\begingroup$

Warming up examples, just a guess about the intents of the question:

tt = Log[Log[Log[6^5^4^3^2^1]]] // HoldForm;
tt /. Log[a_^b_] -> b Log[a]
PowerExpand[Log[Log[Log[a^b^c^d^e^f]]]] /. {a -> 6, b -> 5, c -> 4, 
  d -> 3, e -> 2, f -> 1}
rules = {Log[x_ y_] :> Log[x] + Log[y], Log[x_^k_] :> k Log[x]};
Defer@Log[Log[Log[6^5^4^3^2^1]]] //. rules
Block[{Power, Log}, Log[Log[Log[6^5^4^3^2^1]]] // PowerExpand]
Log[Log[Log[6^5^4^3^2^1]]] // Hold // PowerExpand // ReleaseHold

enter image description here

and

Log[262144 Log[5] + Log[Log[2] + Log[3]]]

This are instable and may not always give good results or even results others than overflows. Conditon may protect from these.

Another nice problem in Mathematica is solves this way:

Simplify[Log[b, b^x], Positive[b] && Element[x, Reals]]
(*x*)

As far as I understand Your aims, Your heading towards representation changes for example with logarithms. Mathematica is not head in the table of CAS with prepresentations. But there are many people interested in Mathematica improving it in this perspectives of maths. The requirements are high and demanding. The major design dissision might have been for Wolfram Inc. to cut efforts in machine run time terms. Nethertheless the overall best address for experiments in representations is the AskConstants package. Because Your question is sparse on examples, I do not do some.

Mathematica stays a little back on Root object and representation of numbers in terms of trigonometrics for example. This question might help further in this and other problems transform root objects into trigonometric expressions. Especially the robust approach in the AskConstants package AskConstants download and AskConstants WTC presentation on Youtube.. This package is free and the user is professional Mathematica at the University of Hawaii.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.