1
$\begingroup$

Given a list of numbers each containing 2 prime factors, I wish to make a list of the products of the logs of each factor. For example, given

L = {4,6,9}, I would like to form P = {Log[2]*Log[2],Log[2]*Log[3],Log[3]*Log[3]}.

FactorInteger seems like a questionable route since it would require some work to distinguish squares from numbers with two distinct prime factors.

Any suggestions? Thank you.

$\endgroup$
4
  • $\begingroup$ Warning: Trying to force Mma to display its results in the way you like them is usually difficult and doesn't pay off $\endgroup$ Commented Jun 13, 2013 at 16:47
  • $\begingroup$ @belisarius: If you are suggesting that the best way might be a short program then I can accept that. $\endgroup$ Commented Jun 13, 2013 at 16:56
  • $\begingroup$ I do not see how this can be done without, in effect, factoring the number. $\endgroup$ Commented Jun 13, 2013 at 18:24
  • $\begingroup$ @DanielLichtblau: No, that has to be done. $\endgroup$ Commented Jun 14, 2013 at 0:48

1 Answer 1

1
$\begingroup$

You could try a couple of rules, but the heads of the elements in the output list will mix Times and HoldForm...

Map[FactorInteger,{4,6,9,15,25,33,49,51}] /. {{{p_,2}}->HoldForm[Log[p]*Log[p]], {{p_,_},{q_,_}}->Log[p]*Log[q]} 
$\endgroup$
2
  • 1
    $\begingroup$ Alternatively: {4, 6, 9, 15, 25, 33, 49, 51} /. n_Integer /; PrimeOmega[n] == 2 :> Times @@ Log[Flatten[ConstantArray @@@ FactorInteger[n]]] $\endgroup$ Commented Jun 13, 2013 at 18:23
  • $\begingroup$ Actually this was better than what I had anticipated, thanks. $\endgroup$ Commented Jun 13, 2013 at 23:52

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.