3
$\begingroup$

I have a function works like this:

f[{m_, n_}] := Assuming[m > 0 && n > 0, Simplify[{n, Sqrt[n m]}]]
finalT = NestList[f, {T3, (T1 T2)^(1/2)}, 25]

Which will return result like this:

finalT[[All, 2]]

result

I wonder how to capture those exponent degrees in finalT[[All, 2]], like $(T_1 T_2)^\frac{1}{2} \rightarrow \frac{1}{2}$. I have tried

Exponent[finalT[[All, 2]], (T1 T2)]
Cases[finalT[[All, 2]], (T1 T2)^n]

both of them did not work. The first return a list of $0$s and the second returns an empty list. How can I achieve my goal? I am using Mathematica 11.

$\endgroup$
  • 1
    $\begingroup$ If you want to include the case n==1 then use Cases[finalT, (T1 T2)^n_. :> n, Infinity]; if not, then Cases[finalT, (T1 T2)^n_ :> n, Infinity] $\endgroup$ – Bob Hanlon Feb 12 '17 at 13:56
  • 1
    $\begingroup$ @BobHanlon use -1 instead of Infinity, shorter to write, same effect. :) $\endgroup$ – rcollyer Feb 12 '17 at 16:13
  • $\begingroup$ @rcollyer - Thanks $\endgroup$ – Bob Hanlon Feb 12 '17 at 16:18
4
$\begingroup$

You have to use finalT[[All, 2]] // FullForm to find the correct pattern:

Cases[
  Simplify[finalT[[All, 2]], Assumptions -> {T1 > 0, T2 > 0, T3 > 0}], 
  Power[Times[T1, T2], Rational[x_, y_]] -> {x/y}, {0, Infinity}]

(* 
    {{1/2}, {1/4}, {3/8}, {5/16}, {11/32}, {21/64}, {43/128}, {85/256}, {171/512}, 
    {341/1024}, {683/2048}, {1365/4096}, {2731/8192}, {5461/16384}, {10923/32768}, 
    {21845/65536}, {43691/131072}, {87381/262144}, {174763/524288}, {349525/1048576}, 
    {699051/2097152}, {1398101/4194304}, {2796203/8388608}, {5592405/16777216}, 
    {11184811/33554432}, {22369621/67108864}} 
*)
$\endgroup$
2
$\begingroup$
f[{m_, n_}] := Assuming[m > 0 && n > 0, Simplify[{n, Sqrt[n m]}]]

finalT = NestList[f, {T3, (T1 T2)^(1/2)}, 25]

Below is a look at the FullForm for a subset of FinalT

Map[{FullForm[#[[1]]], FullForm[#[[2]]]} &, finalT[[1 ;; 11]]] // Grid

Mathematica graphics

There are two groups of exponents, one for the product of T1*T2 and another for T3.

We can extract those two groups as follows:

powerList = Module[
  {
   powers
   },
  powers = Cases[finalT, Rational[x_, y_], Infinity];
  {powers[[1 ;; -2 ;; 2]], powers[[2 ;; -2 ;; 2]]}
  ];

This looks like the following for the same subset

Grid@Transpose@{powerList[[1, 1 ;; 11]], powerList[[2, 1 ;; 11]]}

Mathematica graphics

$\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.